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

Unified Diff: tools/lexer_generator/regex_lexer.py

Issue 59043005: Experimental rule generator: fix previous commit. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/regex_lexer.py
diff --git a/tools/lexer_generator/regex_lexer.py b/tools/lexer_generator/regex_lexer.py
index a2c98f7aa83e8be7742203d5fa58b454cde815ef..55c3bda94192668f6c085c55e5561103b680f5d2 100644
--- a/tools/lexer_generator/regex_lexer.py
+++ b/tools/lexer_generator/regex_lexer.py
@@ -58,10 +58,11 @@ class RegexLexer:
states = (
('class','exclusive'),
+ ('repeat','exclusive'),
)
def t_ESCAPED_LITERAL(self, t):
- r'\\\(|\\\)|\\\[|\\\]|\\\||\\\+|\\\*|\\\?|\\\.|\\\\'
+ r'\\\(|\\\)|\\\[|\\\]|\\\||\\\+|\\\*|\\\?|\\\.|\\\\|\\\{|\\\}'
t.type = 'LITERAL'
t.value = t.value[1:]
return t
@@ -69,17 +70,11 @@ class RegexLexer:
t_GROUP_BEGIN = r'\('
t_GROUP_END = r'\)'
- t_REPEAT_BEGIN = r'\{'
- t_REPEAT_END = r'\}'
-
t_OR = r'\|'
t_ONE_OR_MORE = r'\+'
t_ZERO_OR_MORE = r'\*'
t_ZERO_OR_ONE = r'\?'
- t_NUMBER = r'[0-9]+'
- t_COMMA = r','
-
t_ANY = r'\.'
t_LITERAL = r'.'
@@ -106,6 +101,19 @@ class RegexLexer:
t_class_CLASS_LITERAL = r'[\w $_+]' # fix this
+ def t_REPEAT_BEGIN(self, t):
+ r'\{'
+ self.lexer.push_state('repeat')
+ return t
+
+ def t_repeat_REPEAT_END(self, t):
+ r'\}'
+ self.lexer.pop_state()
+ return t
+
+ t_repeat_NUMBER = r'[0-9]+'
+ t_repeat_COMMA = r','
+
t_ANY_ignore = '\n'
def t_ANY_error(self, t):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698