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

Unified Diff: ppapi/generators/idl_lexer.py

Issue 11565053: Allow leading underscore on identifier names in IDL parser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added test file that I forgot in first patchset Created 8 years 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 | « no previous file | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/generators/idl_lexer.py
diff --git a/ppapi/generators/idl_lexer.py b/ppapi/generators/idl_lexer.py
index d45a4b8ea425110e3314946a42f844c98a565602..4120ac7cfdd3aaa7441d07e5ed1e3f6c368e8406 100755
--- a/ppapi/generators/idl_lexer.py
+++ b/ppapi/generators/idl_lexer.py
@@ -64,7 +64,6 @@ class IDLLexer(object):
# Invented for apps use
'NAMESPACE',
-
# Data types
'FLOAT',
'OCT',
@@ -144,10 +143,15 @@ class IDLLexer(object):
# A symbol or keyword.
def t_KEYWORD_SYMBOL(self, t):
- r'[A-Za-z][A-Za-z_0-9]*'
+ r'_?[A-Za-z][A-Za-z_0-9]*'
- #All non-keywords are assumed to be symbols
+ # All non-keywords are assumed to be symbols
t.type = self.keywords.get(t.value, 'SYMBOL')
+
+ # We strip leading underscores so that you can specify symbols with the same
+ # value as a keywords (E.g. a dictionary named 'interface').
+ if t.value[0] == '_':
+ t.value = t.value[1:]
return t
def t_ANY_error(self, t):
« no previous file with comments | « no previous file | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698