| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 Id, MAYBE(_ParentInterfaces), MAYBE(['{', MAYBE(MANY(_Member)), | 97 Id, MAYBE(_ParentInterfaces), MAYBE(['{', MAYBE(MANY(_Member)), |
| 98 '}']), ';']) | 98 '}']), ';']) |
| 99 | 99 |
| 100 def _Member(): | 100 def _Member(): |
| 101 return syntax_switch( | 101 return syntax_switch( |
| 102 # Web IDL: | 102 # Web IDL: |
| 103 OR(Const, Attribute, Operation, ExtAttrs), | 103 OR(Const, Attribute, Operation, ExtAttrs), |
| 104 # WebKit: | 104 # WebKit: |
| 105 OR(Const, Attribute, Operation), | 105 OR(Const, Attribute, Operation), |
| 106 # FremontCut: | 106 # FremontCut: |
| 107 OR(Const, Attribute, Operation, Snippet)) | 107 OR(Const, Attribute, Operation)) |
| 108 | 108 |
| 109 # Interface inheritance: | 109 # Interface inheritance: |
| 110 def _ParentInterfaces(): | 110 def _ParentInterfaces(): |
| 111 return [':', MANY(ParentInterface, separator=',')] | 111 return [':', MANY(ParentInterface, separator=',')] |
| 112 | 112 |
| 113 def ParentInterface(): | 113 def ParentInterface(): |
| 114 return syntax_switch( | 114 return syntax_switch( |
| 115 # Web IDL: | 115 # Web IDL: |
| 116 [InterfaceType], | 116 [InterfaceType], |
| 117 # WebKit: | 117 # WebKit: |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 374 |
| 375 def _AnnotationBody(): | 375 def _AnnotationBody(): |
| 376 return ['(', MAYBE(MANY(AnnotationArg, ',')), ')'] | 376 return ['(', MAYBE(MANY(AnnotationArg, ',')), ')'] |
| 377 | 377 |
| 378 def AnnotationArg(): | 378 def AnnotationArg(): |
| 379 return [Id, MAYBE(['=', AnnotationArgValue])] | 379 return [Id, MAYBE(['=', AnnotationArgValue])] |
| 380 | 380 |
| 381 def AnnotationArgValue(): | 381 def AnnotationArgValue(): |
| 382 return re.compile(r'[\w&0-9:/\-\.]+') | 382 return re.compile(r'[\w&0-9:/\-\.]+') |
| 383 | 383 |
| 384 # Snippets - used in the FremontCut IDL grammer: | |
| 385 def Snippet(): | |
| 386 return [MAYBE(_Annotations), 'snippet', '{', SnippetText, '}', ';'] | |
| 387 | |
| 388 def SnippetText(): | |
| 389 return re.compile(r'[^\}]*') | |
| 390 | |
| 391 ###################### END GRAMMAR ##################### | 384 ###################### END GRAMMAR ##################### |
| 392 | 385 |
| 393 # Return the grammar's root rule: | 386 # Return the grammar's root rule: |
| 394 return MANY(_Definition) | 387 return MANY(_Definition) |
| 395 | 388 |
| 396 def _whitespace_grammar(self): | 389 def _whitespace_grammar(self): |
| 397 return OR(re.compile(r'\s+'), | 390 return OR(re.compile(r'\s+'), |
| 398 re.compile(r'//.*'), | 391 re.compile(r'//.*'), |
| 399 re.compile(r'#.*'), | 392 re.compile(r'#.*'), |
| 400 re.compile(r'/\*.*?\*/', re.S)) | 393 re.compile(r'/\*.*?\*/', re.S)) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 Args: | 429 Args: |
| 437 content -- text to parse. | 430 content -- text to parse. |
| 438 defines -- an array of pre-processor defines. | 431 defines -- an array of pre-processor defines. |
| 439 includePaths -- an array of path strings used by the | 432 includePaths -- an array of path strings used by the |
| 440 gcc pre-processor. | 433 gcc pre-processor. |
| 441 """ | 434 """ |
| 442 if self._syntax == WEBKIT_SYNTAX: | 435 if self._syntax == WEBKIT_SYNTAX: |
| 443 content = self._pre_process(content, defines, includePaths) | 436 content = self._pre_process(content, defines, includePaths) |
| 444 | 437 |
| 445 return self._pegparser.parse(content) | 438 return self._pegparser.parse(content) |
| OLD | NEW |