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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | array""" | 191 | array""" |
192 p[0] = p[1] | 192 p[0] = p[1] |
193 | 193 |
194 def p_basictypename(self, p): | 194 def p_basictypename(self, p): |
195 """basictypename : identifier | 195 """basictypename : identifier |
196 | handletype""" | 196 | handletype""" |
197 p[0] = p[1] | 197 p[0] = p[1] |
198 | 198 |
199 def p_handletype(self, p): | 199 def p_handletype(self, p): |
200 """handletype : HANDLE | 200 """handletype : HANDLE |
201 | HANDLE LANGLE identifier RANGLE""" | 201 | HANDLE LANGLE NAME RANGLE""" |
202 if len(p) == 2: | 202 if len(p) == 2: |
203 p[0] = p[1] | 203 p[0] = p[1] |
204 else: | 204 else: |
205 if p[3] not in ('data_pipe_consumer', | 205 if p[3] not in ('data_pipe_consumer', |
206 'data_pipe_producer', | 206 'data_pipe_producer', |
207 'message_pipe', | 207 'message_pipe', |
208 'shared_buffer'): | 208 'shared_buffer'): |
209 # Note: We don't enable tracking of line numbers for everything, so we | 209 # Note: We don't enable tracking of line numbers for everything, so we |
210 # can't use |p.lineno(3)|. | 210 # can't use |p.lineno(3)|. |
211 raise ParseError(self.filename, "Invalid handle type %r:" % p[3], | 211 raise ParseError(self.filename, "Invalid handle type %r:" % p[3], |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 def Parse(source, filename): | 365 def Parse(source, filename): |
366 lexer = Lexer(filename) | 366 lexer = Lexer(filename) |
367 parser = Parser(lexer, source, filename) | 367 parser = Parser(lexer, source, filename) |
368 | 368 |
369 lex.lex(object=lexer) | 369 lex.lex(object=lexer) |
370 yacc.yacc(module=parser, debug=0, write_tables=0) | 370 yacc.yacc(module=parser, debug=0, write_tables=0) |
371 | 371 |
372 tree = yacc.parse(source) | 372 tree = yacc.parse(source) |
373 return tree | 373 return tree |
OLD | NEW |