OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Generates a syntax tree from a Mojo IDL file.""" | 6 """Generates a syntax tree from a Mojo IDL file.""" |
7 | 7 |
8 | 8 |
9 import sys | 9 import sys |
10 import os.path | 10 import os.path |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | array""" | 181 | array""" |
182 p[0] = p[1] | 182 p[0] = p[1] |
183 | 183 |
184 def p_basictypename(self, p): | 184 def p_basictypename(self, p): |
185 """basictypename : identifier | 185 """basictypename : identifier |
186 | HANDLE | 186 | HANDLE |
187 | specializedhandle""" | 187 | specializedhandle""" |
188 p[0] = p[1] | 188 p[0] = p[1] |
189 | 189 |
190 def p_specializedhandle(self, p): | 190 def p_specializedhandle(self, p): |
191 """specializedhandle : HANDLE LT specializedhandlename GT""" | 191 """specializedhandle : HANDLE LANGLE specializedhandlename RANGLE""" |
192 p[0] = "handle<" + p[3] + ">" | 192 p[0] = "handle<" + p[3] + ">" |
193 | 193 |
194 def p_specializedhandlename(self, p): | 194 def p_specializedhandlename(self, p): |
195 """specializedhandlename : DATA_PIPE_CONSUMER | 195 """specializedhandlename : DATA_PIPE_CONSUMER |
196 | DATA_PIPE_PRODUCER | 196 | DATA_PIPE_PRODUCER |
197 | MESSAGE_PIPE""" | 197 | MESSAGE_PIPE""" |
198 p[0] = p[1] | 198 p[0] = p[1] |
199 | 199 |
200 def p_array(self, p): | 200 def p_array(self, p): |
201 """array : basictypename LBRACKET RBRACKET""" | 201 """array : basictypename LBRACKET RBRACKET""" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 p[0] = _ListFromConcat(*p[1:]) | 279 p[0] = _ListFromConcat(*p[1:]) |
280 | 280 |
281 def p_binary_operator(self, p): | 281 def p_binary_operator(self, p): |
282 """binary_operator : TIMES | 282 """binary_operator : TIMES |
283 | DIVIDE | 283 | DIVIDE |
284 | MOD | 284 | MOD |
285 | PLUS | 285 | PLUS |
286 | MINUS | 286 | MINUS |
287 | RSHIFT | 287 | RSHIFT |
288 | LSHIFT | 288 | LSHIFT |
289 | LT | |
290 | LE | |
291 | GE | |
292 | GT | |
293 | EQ | |
294 | NE | |
295 | AND | 289 | AND |
296 | OR | 290 | OR |
297 | XOR | 291 | XOR""" |
298 | LAND | |
299 | LOR""" | |
300 p[0] = p[1] | 292 p[0] = p[1] |
301 | 293 |
302 def p_unary_expression(self, p): | 294 def p_unary_expression(self, p): |
303 """unary_expression : primary_expression | 295 """unary_expression : primary_expression |
304 | unary_operator expression""" | 296 | unary_operator expression""" |
305 p[0] = _ListFromConcat(*p[1:]) | 297 p[0] = _ListFromConcat(*p[1:]) |
306 | 298 |
307 def p_unary_operator(self, p): | 299 def p_unary_operator(self, p): |
308 """unary_operator : PLUS | 300 """unary_operator : PLUS |
309 | MINUS | 301 | MINUS |
310 | NOT | 302 | NOT""" |
311 | LNOT""" | |
312 p[0] = p[1] | 303 p[0] = p[1] |
313 | 304 |
314 def p_primary_expression(self, p): | 305 def p_primary_expression(self, p): |
315 """primary_expression : constant | 306 """primary_expression : constant |
316 | identifier | 307 | identifier |
317 | LPAREN expression RPAREN""" | 308 | LPAREN expression RPAREN""" |
318 p[0] = _ListFromConcat(*p[1:]) | 309 p[0] = _ListFromConcat(*p[1:]) |
319 | 310 |
320 def p_identifier(self, p): | 311 def p_identifier(self, p): |
321 """identifier : NAME | 312 """identifier : NAME |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 print Parse(f.read(), filename) | 358 print Parse(f.read(), filename) |
368 except ParseError, e: | 359 except ParseError, e: |
369 print e | 360 print e |
370 return 1 | 361 return 1 |
371 | 362 |
372 return 0 | 363 return 0 |
373 | 364 |
374 | 365 |
375 if __name__ == '__main__': | 366 if __name__ == '__main__': |
376 sys.exit(main(sys.argv)) | 367 sys.exit(main(sys.argv)) |
OLD | NEW |