| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import re | 6 import re |
| 7 import subprocess | 7 import subprocess |
| 8 import tempfile | 8 import tempfile |
| 9 | 9 |
| 10 from pegparser import * | 10 from pegparser import * |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 # Types: | 276 # Types: |
| 277 def Type(): | 277 def Type(): |
| 278 return _Type | 278 return _Type |
| 279 | 279 |
| 280 def ReturnType(): | 280 def ReturnType(): |
| 281 return OR(VoidType, _Type) | 281 return OR(VoidType, _Type) |
| 282 | 282 |
| 283 def InterfaceType(): | 283 def InterfaceType(): |
| 284 return ScopedName | 284 return ScopedName |
| 285 | 285 |
| 286 def ArrayModifiers(): |
| 287 return re.compile(r'(\[\])+') |
| 288 |
| 286 def _Type(): | 289 def _Type(): |
| 287 return OR(AnyArrayType, AnyType, ObjectType, _NullableType) | 290 return [OR(AnyType, ObjectType, _NullableType), MAYBE(ArrayModifiers)] |
| 288 | 291 |
| 289 def _NullableType(): | 292 def _NullableType(): |
| 290 return [OR(_IntegerType, BooleanType, OctetType, FloatType, | 293 return [OR(_IntegerType, BooleanType, OctetType, FloatType, |
| 291 DoubleType, SequenceType, DOMStringArrayType, ScopedName), | 294 DoubleType, SequenceType, ScopedName), |
| 292 MAYBE(Nullable)] | 295 MAYBE(Nullable)] |
| 293 | 296 |
| 294 def Nullable(): | 297 def Nullable(): |
| 295 return '?' | 298 return '?' |
| 296 | 299 |
| 297 def SequenceType(): | 300 def SequenceType(): |
| 298 return ['sequence', '<', Type, '>'] | 301 return ['sequence', '<', Type, '>'] |
| 299 | 302 |
| 300 def AnyType(): | 303 def AnyType(): |
| 301 return 'any' | 304 return 'any' |
| 302 | 305 |
| 303 def AnyArrayType(): | |
| 304 # TODO(sra): Do more general handling of array types. | |
| 305 return 'any[]' | |
| 306 | |
| 307 def ObjectType(): | 306 def ObjectType(): |
| 308 return re.compile(r'(object|Object)\b') # both spellings. | 307 return re.compile(r'(object|Object)\b') # both spellings. |
| 309 | 308 |
| 310 def VoidType(): | 309 def VoidType(): |
| 311 return 'void' | 310 return 'void' |
| 312 | 311 |
| 313 def _IntegerType(): | 312 def _IntegerType(): |
| 314 return [MAYBE(Unsigned), OR(ByteType, IntType, LongLongType, | 313 return [MAYBE(Unsigned), OR(ByteType, IntType, LongLongType, |
| 315 LongType, OctetType, ShortType)] | 314 LongType, OctetType, ShortType)] |
| 316 | 315 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 343 | 342 |
| 344 def DoubleType(): | 343 def DoubleType(): |
| 345 return 'double' | 344 return 'double' |
| 346 | 345 |
| 347 def _ScopedNames(): | 346 def _ScopedNames(): |
| 348 return MANY(ScopedName, separator=',') | 347 return MANY(ScopedName, separator=',') |
| 349 | 348 |
| 350 def ScopedName(): | 349 def ScopedName(): |
| 351 return re.compile(r'[\w\_\:\.\<\>]+') | 350 return re.compile(r'[\w\_\:\.\<\>]+') |
| 352 | 351 |
| 353 def DOMStringArrayType(): | |
| 354 return 'DOMString[]' | |
| 355 | |
| 356 # Extended Attributes: | 352 # Extended Attributes: |
| 357 def ExtAttrs(): | 353 def ExtAttrs(): |
| 358 return ['[', MAYBE(MANY(ExtAttr, ',')), ']'] | 354 return ['[', MAYBE(MANY(ExtAttr, ',')), ']'] |
| 359 | 355 |
| 360 def ExtAttr(): | 356 def ExtAttr(): |
| 361 return [Id, MAYBE(OR(['=', ExtAttrValue], ExtAttrArgList))] | 357 return [Id, MAYBE(OR(['=', ExtAttrValue], ExtAttrArgList))] |
| 362 | 358 |
| 363 def ExtAttrValue(): | 359 def ExtAttrValue(): |
| 364 return OR(ExtAttrFunctionValue, re.compile(r'[\w&0-9:\-\|]+')) | 360 return OR(ExtAttrFunctionValue, re.compile(r'[\w&0-9:\-\|]+')) |
| 365 | 361 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 Args: | 429 Args: |
| 434 content -- text to parse. | 430 content -- text to parse. |
| 435 defines -- an array of pre-processor defines. | 431 defines -- an array of pre-processor defines. |
| 436 includePaths -- an array of path strings used by the | 432 includePaths -- an array of path strings used by the |
| 437 gcc pre-processor. | 433 gcc pre-processor. |
| 438 """ | 434 """ |
| 439 if self._syntax == WEBKIT_SYNTAX: | 435 if self._syntax == WEBKIT_SYNTAX: |
| 440 content = self._pre_process(content, defines, includePaths) | 436 content = self._pre_process(content, defines, includePaths) |
| 441 | 437 |
| 442 return self._pegparser.parse(content) | 438 return self._pegparser.parse(content) |
| OLD | NEW |