Chromium Code Reviews| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 """parameter : typename NAME ordinal""" | 186 """parameter : typename NAME ordinal""" |
| 187 p[0] = ('PARAM', p[1], p[2], p[3]) | 187 p[0] = ('PARAM', p[1], p[2], p[3]) |
| 188 | 188 |
| 189 def p_typename(self, p): | 189 def p_typename(self, p): |
| 190 """typename : basictypename | 190 """typename : basictypename |
| 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 | HANDLE | 196 | handletype""" |
| 197 | specializedhandle""" | |
| 198 p[0] = p[1] | 197 p[0] = p[1] |
| 199 | 198 |
| 200 def p_specializedhandle(self, p): | 199 def p_handletype(self, p): |
| 201 """specializedhandle : HANDLE LANGLE specializedhandlename RANGLE""" | 200 """handletype : HANDLE |
| 202 p[0] = "handle<" + p[3] + ">" | 201 | HANDLE LANGLE identifier RANGLE""" |
| 203 | 202 if len(p) == 2: |
| 204 def p_specializedhandlename(self, p): | 203 p[0] = p[1] |
| 205 """specializedhandlename : DATA_PIPE_CONSUMER | 204 else: |
| 206 | DATA_PIPE_PRODUCER | 205 if p[3] not in ('data_pipe_consumer', 'data_pipe_producer', |
|
darin (slow to review)
2014/05/19 21:14:33
nit: you might list these one per line so that fut
viettrungluu
2014/05/19 21:22:34
Done.
| |
| 207 | MESSAGE_PIPE | 206 'message_pipe', 'shared_buffer'): |
| 208 | SHARED_BUFFER""" | 207 # Note: We don't enable tracking of line numbers for everything, so we |
| 209 p[0] = p[1] | 208 # can't use |p.lineno(3)|. |
| 209 raise ParseError(self.filename, "Invalid handle type %r:" % p[3], | |
| 210 lineno=p.lineno(1), | |
| 211 snippet=self._GetSnippet(p.lineno(1))) | |
| 212 p[0] = "handle<" + p[3] + ">" | |
| 210 | 213 |
| 211 def p_array(self, p): | 214 def p_array(self, p): |
| 212 """array : typename LBRACKET RBRACKET""" | 215 """array : typename LBRACKET RBRACKET""" |
| 213 p[0] = p[1] + "[]" | 216 p[0] = p[1] + "[]" |
| 214 | 217 |
| 215 def p_ordinal(self, p): | 218 def p_ordinal(self, p): |
| 216 """ordinal : ORDINAL | 219 """ordinal : ORDINAL |
| 217 | """ | 220 | """ |
| 218 if len(p) > 1: | 221 if len(p) > 1: |
| 219 value = int(p[1][1:]) | 222 value = int(p[1][1:]) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 | 362 |
| 360 def Parse(source, filename): | 363 def Parse(source, filename): |
| 361 lexer = Lexer(filename) | 364 lexer = Lexer(filename) |
| 362 parser = Parser(lexer, source, filename) | 365 parser = Parser(lexer, source, filename) |
| 363 | 366 |
| 364 lex.lex(object=lexer) | 367 lex.lex(object=lexer) |
| 365 yacc.yacc(module=parser, debug=0, write_tables=0) | 368 yacc.yacc(module=parser, debug=0, write_tables=0) |
| 366 | 369 |
| 367 tree = yacc.parse(source) | 370 tree = yacc.parse(source) |
| 368 return tree | 371 return tree |
| OLD | NEW |