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

Unified Diff: tools/lexer_generator/rule_parser.py

Issue 141293003: Experimental parser: visualize rule trees. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: . Created 6 years, 11 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/rule_parser.py
diff --git a/tools/lexer_generator/rule_parser.py b/tools/lexer_generator/rule_parser.py
index 65b3f17a158fe9601a9c4e52ac4ad8e8cc92f779..fb823ca088511a38e896ed036f4314d533de57f5 100644
--- a/tools/lexer_generator/rule_parser.py
+++ b/tools/lexer_generator/rule_parser.py
@@ -246,6 +246,7 @@ class RuleProcessor(object):
def __init__(self, parser_state):
self.__automata = {}
+ self.__rule_trees = {}
self.__process_parser_state(parser_state)
@staticmethod
@@ -260,6 +261,12 @@ class RuleProcessor(object):
def default_automata(self):
return self.__automata['default']
+ def rule_tree_dots(self):
+ result = {}
+ for rule in self.__rule_trees:
+ result[rule] = NfaBuilder.rule_tree_dot(self.__rule_trees[rule])
+ return result
+
class Automata(object):
def __init__(self, builder, graph):
@@ -328,6 +335,7 @@ class RuleProcessor(object):
# build the automata
for rule_name, graph in rule_map.items():
self.__automata[rule_name] = RuleProcessor.Automata(builder, graph)
+ self.__rule_trees[rule_name] = graph
# process default_action
default_action = parser_state.rules['default']['default_action']
self.default_action = Action(None, default_action[1]) if default_action else None
« 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