Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: mojo/public/bindings/pylib/parse/mojo_parser.py

Issue 221953005: Mojo: Mojom: Add basic lexer tests, and remove hex float constants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 def p_identifier(self, p): 312 def p_identifier(self, p):
313 """identifier : NAME 313 """identifier : NAME
314 | NAME DOT identifier""" 314 | NAME DOT identifier"""
315 p[0] = ''.join(p[1:]) 315 p[0] = ''.join(p[1:])
316 316
317 def p_constant(self, p): 317 def p_constant(self, p):
318 """constant : INT_CONST_DEC 318 """constant : INT_CONST_DEC
319 | INT_CONST_OCT 319 | INT_CONST_OCT
320 | INT_CONST_HEX 320 | INT_CONST_HEX
321 | FLOAT_CONST 321 | FLOAT_CONST
322 | HEX_FLOAT_CONST
323 | CHAR_CONST 322 | CHAR_CONST
324 | STRING_LITERAL""" 323 | STRING_LITERAL"""
325 p[0] = _ListFromConcat(*p[1:]) 324 p[0] = _ListFromConcat(*p[1:])
326 325
327 def p_error(self, e): 326 def p_error(self, e):
328 if e is None: 327 if e is None:
329 # Unexpected EOF. 328 # Unexpected EOF.
330 # TODO(vtl): Can we figure out what's missing? 329 # TODO(vtl): Can we figure out what's missing?
331 raise ParseError(self.filename, eof=True) 330 raise ParseError(self.filename, eof=True)
332 331
(...skipping 26 matching lines...) Expand all
359 print Parse(f.read(), filename) 358 print Parse(f.read(), filename)
360 except ParseError, e: 359 except ParseError, e:
361 print e 360 print e
362 return 1 361 return 1
363 362
364 return 0 363 return 0
365 364
366 365
367 if __name__ == '__main__': 366 if __name__ == '__main__':
368 sys.exit(main(sys.argv)) 367 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « mojo/public/bindings/pylib/parse/mojo_lexer_unittest.py ('k') | mojo/public/bindings/pylib/parse/mojo_parser_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698