| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | LAND | 247 | LAND |
| 248 | LOR""" | 248 | LOR""" |
| 249 p[0] = p[1] | 249 p[0] = p[1] |
| 250 | 250 |
| 251 def p_unary_expression(self, p): | 251 def p_unary_expression(self, p): |
| 252 """unary_expression : primary_expression | 252 """unary_expression : primary_expression |
| 253 | unary_operator expression""" | 253 | unary_operator expression""" |
| 254 p[0] = ''.join(p[1:]) | 254 p[0] = ''.join(p[1:]) |
| 255 | 255 |
| 256 def p_unary_operator(self, p): | 256 def p_unary_operator(self, p): |
| 257 """unary_operator : TIMES | 257 """unary_operator : PLUS |
| 258 | PLUS | |
| 259 | MINUS | 258 | MINUS |
| 260 | NOT | 259 | NOT |
| 261 | LNOT""" | 260 | LNOT""" |
| 262 p[0] = p[1] | 261 p[0] = p[1] |
| 263 | 262 |
| 264 def p_primary_expression(self, p): | 263 def p_primary_expression(self, p): |
| 265 """primary_expression : constant | 264 """primary_expression : constant |
| 266 | NAME | 265 | NAME |
| 267 | LPAREN expression RPAREN""" | 266 | LPAREN expression RPAREN""" |
| 268 p[0] = ''.join(p[1:]) | 267 p[0] = ''.join(p[1:]) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 297 def Main(): | 296 def Main(): |
| 298 if len(sys.argv) < 2: | 297 if len(sys.argv) < 2: |
| 299 print("usage: %s filename" % (sys.argv[0])) | 298 print("usage: %s filename" % (sys.argv[0])) |
| 300 sys.exit(1) | 299 sys.exit(1) |
| 301 tree = Parse(filename=sys.argv[1]) | 300 tree = Parse(filename=sys.argv[1]) |
| 302 print(tree) | 301 print(tree) |
| 303 | 302 |
| 304 | 303 |
| 305 if __name__ == '__main__': | 304 if __name__ == '__main__': |
| 306 Main() | 305 Main() |
| OLD | NEW |