| 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 |
| 11 | 11 |
| 12 # Try to load the ply module, if not, then assume it is in the third_party | 12 # Try to load the ply module, if not, then assume it is in the third_party |
| 13 # directory. | 13 # directory. |
| 14 try: | 14 try: |
| 15 # Disable lint check which fails to find the ply module. | 15 # Disable lint check which fails to find the ply module. |
| 16 # pylint: disable=F0401 | 16 # pylint: disable=F0401 |
| 17 from ply import lex | 17 from ply import lex |
| 18 from ply import yacc | 18 from ply import yacc |
| 19 except ImportError: | 19 except ImportError: |
| 20 # This assumes this file is in src/mojo/public/tools/bindings/pylib/parse/. |
| 20 module_path, module_name = os.path.split(__file__) | 21 module_path, module_name = os.path.split(__file__) |
| 21 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, | 22 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, |
| 22 os.pardir, os.pardir, 'third_party') | 23 os.pardir, os.pardir, os.pardir, 'third_party') |
| 23 sys.path.append(third_party) | 24 sys.path.append(third_party) |
| 24 # pylint: disable=F0401 | 25 # pylint: disable=F0401 |
| 25 from ply import lex | 26 from ply import lex |
| 26 from ply import yacc | 27 from ply import yacc |
| 27 | 28 |
| 28 from mojo_lexer import Lexer | 29 from mojo_lexer import Lexer |
| 29 | 30 |
| 30 | 31 |
| 31 def _ListFromConcat(*items): | 32 def _ListFromConcat(*items): |
| 32 """Generate list by concatenating inputs (note: only concatenates lists, not | 33 """Generate list by concatenating inputs (note: only concatenates lists, not |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 print Parse(f.read(), filename) | 363 print Parse(f.read(), filename) |
| 363 except ParseError, e: | 364 except ParseError, e: |
| 364 print e | 365 print e |
| 365 return 1 | 366 return 1 |
| 366 | 367 |
| 367 return 0 | 368 return 0 |
| 368 | 369 |
| 369 | 370 |
| 370 if __name__ == '__main__': | 371 if __name__ == '__main__': |
| 371 sys.exit(main(sys.argv)) | 372 sys.exit(main(sys.argv)) |
| OLD | NEW |