OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 sys.path.insert(1, third_party) | 64 sys.path.insert(1, third_party) |
65 from ply import yacc | 65 from ply import yacc |
66 | 66 |
67 # Base parser is in Chromium src/tools/idl_parser | 67 # Base parser is in Chromium src/tools/idl_parser |
68 tools_dir = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pardir
, os.pardir, 'tools') | 68 tools_dir = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pardir
, os.pardir, 'tools') |
69 sys.path.append(tools_dir) | 69 sys.path.append(tools_dir) |
70 from idl_parser.idl_parser import IDLParser, ListFromConcat | 70 from idl_parser.idl_parser import IDLParser, ListFromConcat |
71 from idl_parser.idl_parser import ParseFile as parse_file | 71 from idl_parser.idl_parser import ParseFile as parse_file |
72 | 72 |
73 from blink_idl_lexer import BlinkIDLLexer | 73 from blink_idl_lexer import BlinkIDLLexer |
| 74 import blink_idl_lexer |
74 | 75 |
75 | 76 |
76 # Explicitly set starting symbol to rule defined only in base parser. | 77 # Explicitly set starting symbol to rule defined only in base parser. |
77 # BEWARE that the starting symbol should NOT be defined in both the base parser | 78 # BEWARE that the starting symbol should NOT be defined in both the base parser |
78 # and the derived one, as otherwise which is used depends on which line number | 79 # and the derived one, as otherwise which is used depends on which line number |
79 # is lower, which is fragile. Instead, either use one in base parser or | 80 # is lower, which is fragile. Instead, either use one in base parser or |
80 # create a new symbol, so that this is unambiguous. | 81 # create a new symbol, so that this is unambiguous. |
81 # FIXME: unfortunately, this doesn't work in PLY 3.4, so need to duplicate the | 82 # FIXME: unfortunately, this doesn't work in PLY 3.4, so need to duplicate the |
82 # rule below. | 83 # rule below. |
83 STARTING_SYMBOL = 'Definitions' | 84 STARTING_SYMBOL = 'Definitions' |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 self._parse_errors = 0 | 434 self._parse_errors = 0 |
434 self._parse_warnings = 0 | 435 self._parse_warnings = 0 |
435 self._last_error_msg = None | 436 self._last_error_msg = None |
436 self._last_error_lineno = 0 | 437 self._last_error_lineno = 0 |
437 self._last_error_pos = 0 | 438 self._last_error_pos = 0 |
438 | 439 |
439 | 440 |
440 ################################################################################ | 441 ################################################################################ |
441 | 442 |
442 def main(argv): | 443 def main(argv): |
443 # If file itself executed, cache parse table | 444 # If file itself executed, cache lex/parse tables |
444 try: | 445 try: |
445 outputdir = argv[1] | 446 outputdir = argv[1] |
446 except IndexError as err: | 447 except IndexError as err: |
447 print 'Usage: %s OUTPUT_DIR' % argv[0] | 448 print 'Usage: %s OUTPUT_DIR' % argv[0] |
448 return 1 | 449 return 1 |
| 450 blink_idl_lexer.main(argv) |
449 # Important: rewrite_tables=True causes the cache file to be deleted if it | 451 # Important: rewrite_tables=True causes the cache file to be deleted if it |
450 # exists, thus making sure that PLY doesn't load it instead of regenerating | 452 # exists, thus making sure that PLY doesn't load it instead of regenerating |
451 # the parse table. | 453 # the parse table. |
452 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) | 454 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) |
453 | 455 |
454 | 456 |
455 if __name__ == '__main__': | 457 if __name__ == '__main__': |
456 sys.exit(main(sys.argv)) | 458 sys.exit(main(sys.argv)) |
OLD | NEW |