diff options
author | nbarth@chromium.org <nbarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 11:20:50 +0000 |
---|---|---|
committer | nbarth@chromium.org <nbarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 11:20:50 +0000 |
commit | 5311147515a6632dab64ba87962f51a790a4b194 (patch) | |
tree | 2f373f3130669a31bb93614fb2544564dc6df273 /tools/idl_parser/idl_parser.py | |
parent | f3a76a55d8f94fc399fcec5c27408470965b7258 (diff) | |
download | chromium_src-5311147515a6632dab64ba87962f51a790a4b194.zip chromium_src-5311147515a6632dab64ba87962f51a790a4b194.tar.gz chromium_src-5311147515a6632dab64ba87962f51a790a4b194.tar.bz2 |
IDL parser: fix lint errors and PPAPI ExtAttr grammar (+ test)
This fixes Pylint errors in the IDL parser.
It also fixes the grammar for PPAPI-specific extended attributes,
and adds tests.
Beyond beautification, this allows us to use Pylint in future
(skipping long line checks).
Review URL: https://chromiumcodereview.appspot.com/22411002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/idl_parser/idl_parser.py')
-rwxr-xr-x | tools/idl_parser/idl_parser.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py index 10428de..8a682ea 100755 --- a/tools/idl_parser/idl_parser.py +++ b/tools/idl_parser/idl_parser.py @@ -36,8 +36,22 @@ import time from idl_lexer import IDLLexer from idl_node import IDLAttribute, IDLNode -from ply import lex -from ply import yacc +# +# Try to load the ply module, if not, then assume it is in the third_party +# directory. +# +try: + # Disable lint check which fails to find the ply module. + # pylint: disable=F0401 + from ply import lex + from ply import yacc +except ImportError: + module_path, module_name = os.path.split(__file__) + third_party = os.path.join(module_path, os.par, os.par, 'third_party') + sys.path.append(third_party) + # pylint: disable=F0401 + from ply import lex + from ply import yacc # # ERROR_REMAP @@ -862,7 +876,7 @@ class IDLParser(object): def __init__(self, lexer, verbose=False, debug=False, mute_error=False): self.lexer = lexer self.tokens = lexer.KnownTokens() - self.yaccobj = yacc.yacc(module=self, tabmodule=None, debug=False, + self.yaccobj = yacc.yacc(module=self, tabmodule=None, debug=debug, optimize=0, write_tables=0) self.parse_debug = debug self.verbose = verbose @@ -973,6 +987,8 @@ class IDLParser(object): return IDLAttribute(key, Boolean(True)) def GetErrors(self): + # Access lexer errors, despite being private + # pylint: disable=W0212 return self._parse_errors + self.lexer._lex_errors # |