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

Unified Diff: tools/idl_parser/idl_ppapi_lexer.py

Issue 13498002: Add WebIDL compliant parser plus tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 'Delay build of Lexer to handler tokens correctly.' Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/idl_parser/idl_parser_test.py ('k') | tools/idl_parser/run_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/idl_parser/idl_ppapi_lexer.py
diff --git a/tools/idl_parser/idl_ppapi_lexer.py b/tools/idl_parser/idl_ppapi_lexer.py
index 3accd2d164cceb14f03eedf00e5f7d3b4b820616..f615c77fba4863931f2bf903bd1223164095910b 100644
--- a/tools/idl_parser/idl_ppapi_lexer.py
+++ b/tools/idl_parser/idl_ppapi_lexer.py
@@ -23,32 +23,27 @@ import sys
# IDL PPAPI Lexer
#
class IDLPPAPILexer(IDLLexer):
- # 'tokens' is a value required by lex which specifies the complete list
- # of valid token types. To WebIDL we add the following token types
- IDLLexer.tokens += [
- # Operators
- 'LSHIFT',
- 'RSHIFT',
-
- # Pepper Extras
- 'INLINE',
- ]
-
- # 'keywords' is a map of string to token type. All tokens matching
- # KEYWORD_OR_SYMBOL are matched against keywords dictionary, to determine
- # if the token is actually a keyword. Add the new keywords to the
- # dictionary and set of tokens
- ppapi_keywords = ['LABEL', 'NAMESPACE', 'STRUCT']
- for keyword in ppapi_keywords:
- IDLLexer.keywords[ keyword.lower() ] = keyword
- IDLLexer.tokens.append(keyword)
-
# Special multi-character operators
- t_LSHIFT = r'<<'
- t_RSHIFT = r'>>'
+ def t_LSHIFT(self, t):
+ r'<<'
+ return t;
+
+ def t_RSHIFT(self, t):
+ r'>>'
+ return t;
- # Return a "preprocessor" inline block
def t_INLINE(self, t):
r'\#inline (.|\n)*?\#endinl.*'
self.AddLines(t.value.count('\n'))
return t
+
+ # Return a "preprocessor" inline block
+ def __init__(self):
+ IDLLexer.__init__(self)
+ self._AddTokens(['LSHIFT', 'RSHIFT', 'INLINE'])
+ self._AddKeywords(['label', 'namespace', 'struct'])
+
+
+# If run by itself, attempt to build the lexer
+if __name__ == '__main__':
+ lexer = IDLPPAPILexer()
« no previous file with comments | « tools/idl_parser/idl_parser_test.py ('k') | tools/idl_parser/run_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698