| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generates a syntax tree from a Mojo IDL file.""" | 5 """Generates a syntax tree from a Mojo IDL file.""" |
| 6 | 6 |
| 7 import imp | 7 import imp |
| 8 import os.path | 8 import os.path |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 def p_struct_body(self, p): | 132 def p_struct_body(self, p): |
| 133 """struct_body : field struct_body | 133 """struct_body : field struct_body |
| 134 | enum struct_body | 134 | enum struct_body |
| 135 | const struct_body | 135 | const struct_body |
| 136 | """ | 136 | """ |
| 137 if len(p) > 1: | 137 if len(p) > 1: |
| 138 p[0] = _ListFromConcat(p[1], p[2]) | 138 p[0] = _ListFromConcat(p[1], p[2]) |
| 139 | 139 |
| 140 def p_field(self, p): | 140 def p_field(self, p): |
| 141 """field : typename NAME default ordinal SEMI""" | 141 """field : typename NAME ordinal default SEMI""" |
| 142 p[0] = ('FIELD', p[1], p[2], p[4], p[3]) | 142 p[0] = ('FIELD', p[1], p[2], p[3], p[4]) |
| 143 | 143 |
| 144 def p_default(self, p): | 144 def p_default(self, p): |
| 145 """default : EQUALS expression | 145 """default : EQUALS expression |
| 146 | """ | 146 | """ |
| 147 if len(p) > 2: | 147 if len(p) > 2: |
| 148 p[0] = p[2] | 148 p[0] = p[2] |
| 149 | 149 |
| 150 def p_interface(self, p): | 150 def p_interface(self, p): |
| 151 """interface : attribute_section INTERFACE NAME LBRACE interface_body \ | 151 """interface : attribute_section INTERFACE NAME LBRACE interface_body \ |
| 152 RBRACE SEMI""" | 152 RBRACE SEMI""" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 def Parse(source, filename): | 330 def Parse(source, filename): |
| 331 lexer = Lexer(filename) | 331 lexer = Lexer(filename) |
| 332 parser = Parser(lexer, source, filename) | 332 parser = Parser(lexer, source, filename) |
| 333 | 333 |
| 334 lex.lex(object=lexer) | 334 lex.lex(object=lexer) |
| 335 yacc.yacc(module=parser, debug=0, write_tables=0) | 335 yacc.yacc(module=parser, debug=0, write_tables=0) |
| 336 | 336 |
| 337 tree = yacc.parse(source) | 337 tree = yacc.parse(source) |
| 338 return tree | 338 return tree |
| OLD | NEW |