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

Unified Diff: tools/lexer_generator/rule_lexer.py

Issue 69293005: Experimental parser: add catch all rule (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month 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
Index: tools/lexer_generator/rule_lexer.py
diff --git a/tools/lexer_generator/rule_lexer.py b/tools/lexer_generator/rule_lexer.py
index 3fa1efed8639021ee365d6969a5df9fc485fa191..048fa203a07678926aa4b31ec1b7e9b2832a149a 100644
--- a/tools/lexer_generator/rule_lexer.py
+++ b/tools/lexer_generator/rule_lexer.py
@@ -32,6 +32,8 @@ class RuleLexer:
tokens = (
'DEFAULT',
'DEFAULT_ACTION',
+ 'CATCH_ALL',
+
'IDENTIFIER',
'STRING',
'REGEX',
@@ -67,12 +69,13 @@ class RuleLexer:
r'\#.*[\n\r]+'
pass
+ __special_identifiers = set(map(lambda s: s.lower(),
+ ['DEFAULT', 'DEFAULT_ACTION', 'CATCH_ALL',]))
+
def t_IDENTIFIER(self, t):
r'[a-zA-Z][a-zA-Z0-9_]*'
- if t.value == 'default':
- t.type = 'DEFAULT'
- if t.value == 'default_action':
- t.type = 'DEFAULT_ACTION'
+ if t.value in self.__special_identifiers:
+ t.type = t.value.upper()
return t
t_STRING = r'"((\\("|\w|\\))|[^\\"])+"'

Powered by Google App Engine
This is Rietveld 408576698