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

Unified Diff: tools/lexer_generator/regex_parser.py

Issue 145723010: Experimental parser: better rule tree visualization (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 10 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/lexer_generator/nfa_builder.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/regex_parser.py
diff --git a/tools/lexer_generator/regex_parser.py b/tools/lexer_generator/regex_parser.py
index d19a5432570508bef88dd5e8e99fb28ec4fe7ea8..b624584d2d849b91e1ea6dce645e87a50febf7fa 100644
--- a/tools/lexer_generator/regex_parser.py
+++ b/tools/lexer_generator/regex_parser.py
@@ -171,7 +171,7 @@ class RegexParser:
p[0] = self.__cat(p[1], p[2])
def p_fragment(self, p):
- '''fragment : literal maybe_modifier
+ '''fragment : literal_array maybe_modifier
| class maybe_modifier
| group maybe_modifier
| any maybe_modifier
@@ -202,9 +202,22 @@ class RegexParser:
else:
p[0] = ("REPEAT", p[2], p[4])
- def p_literal(self, p):
- '''literal : LITERAL'''
- p[0] = Term('LITERAL', p[1])
+ def p_literal_array(self, p):
+ '''literal_array : literals'''
+ p[0] = Term('LITERAL', ''.join(reversed(p[1])))
+
+ def p_literals(self, p):
+ '''literals : LITERAL maybe_literals'''
+ if not p[2]:
+ p[0] = [p[1]]
+ else:
+ p[2].append(p[1])
+ p[0] = p[2]
+
+ def p_maybe_literals(self, p):
+ '''maybe_literals : literals
+ | empty'''
+ p[0] = p[1]
def p_any(self, p):
'''any : ANY'''
« no previous file with comments | « tools/lexer_generator/nfa_builder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698