OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 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 """ Parser for PPAPI IDL """ | 6 """ Parser for PPAPI IDL """ |
7 | 7 |
8 # | 8 # |
9 # IDL Parser | 9 # IDL Parser |
10 # | 10 # |
(...skipping 18 matching lines...) Expand all Loading... |
29 # pylint: disable=R0201 | 29 # pylint: disable=R0201 |
30 # pylint: disable=C0301 | 30 # pylint: disable=C0301 |
31 | 31 |
32 import os.path | 32 import os.path |
33 import sys | 33 import sys |
34 import time | 34 import time |
35 | 35 |
36 from idl_lexer import IDLLexer | 36 from idl_lexer import IDLLexer |
37 from idl_node import IDLAttribute, IDLNode | 37 from idl_node import IDLAttribute, IDLNode |
38 | 38 |
39 # | 39 SRC_DIR = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) |
40 # Try to load the ply module, if not, then assume it is in the third_party | 40 sys.path.insert(0, os.path.join(SRC_DIR, 'third_party')) |
41 # directory. | 41 from ply import lex |
42 # | 42 from ply import yacc |
43 try: | 43 |
44 # Disable lint check which fails to find the ply module. | |
45 # pylint: disable=F0401 | |
46 from ply import lex | |
47 from ply import yacc | |
48 except ImportError: | |
49 module_path, module_name = os.path.split(__file__) | |
50 third_party = os.path.join(module_path, os.par, os.par, 'third_party') | |
51 sys.path.append(third_party) | |
52 # pylint: disable=F0401 | |
53 from ply import lex | |
54 from ply import yacc | |
55 | 44 |
56 # | 45 # |
57 # ERROR_REMAP | 46 # ERROR_REMAP |
58 # | 47 # |
59 # Maps the standard error formula into a more friendly error message. | 48 # Maps the standard error formula into a more friendly error message. |
60 # | 49 # |
61 ERROR_REMAP = { | 50 ERROR_REMAP = { |
62 'Unexpected ")" after "(".' : 'Empty argument list.', | 51 'Unexpected ")" after "(".' : 'Empty argument list.', |
63 'Unexpected ")" after ",".' : 'Missing argument.', | 52 'Unexpected ")" after ",".' : 'Missing argument.', |
64 'Unexpected "}" after ",".' : 'Trailing comma in block.', | 53 'Unexpected "}" after ",".' : 'Trailing comma in block.', |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 | 1288 |
1300 print '\n'.join(ast.Tree(accept_props=['PROD'])) | 1289 print '\n'.join(ast.Tree(accept_props=['PROD'])) |
1301 if errors: | 1290 if errors: |
1302 print '\nFound %d errors.\n' % errors | 1291 print '\nFound %d errors.\n' % errors |
1303 | 1292 |
1304 return errors | 1293 return errors |
1305 | 1294 |
1306 | 1295 |
1307 if __name__ == '__main__': | 1296 if __name__ == '__main__': |
1308 sys.exit(main(sys.argv[1:])) | 1297 sys.exit(main(sys.argv[1:])) |
OLD | NEW |