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

Unified Diff: tools/lexer_generator/rule_parser.py

Issue 61003003: Experimental parser: cleanup rule processing result (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 | « tools/lexer_generator/generator.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 f9787f7ba95d8d1f4812c33901ef398a4a88a2a8..f81444ca150c4c27af391a19650d279983e58ac3 100644
--- a/tools/lexer_generator/rule_parser.py
+++ b/tools/lexer_generator/rule_parser.py
@@ -234,9 +234,26 @@ class RuleProcessor(object):
return self.__automata['default']
def lex(self, string):
- (nfa, dfa) = self.default_automata()
+ dfa = self.default_automata().dfa()
return dfa.lex(string)
+ class Automata(object):
+
+ def __init__(self, nfa):
+ (start, dfa_nodes) = nfa.compute_dfa()
+ self.__nfa = nfa
+ self.__dfa = Dfa(start, dfa_nodes)
+ self.__minimial_dfa = self.__dfa.minimize()
+
+ def nfa(self):
+ return self.__dfa
+
+ def dfa(self):
+ return self.__dfa
+
+ def minimal_dfa(self):
+ return self.__minimial_dfa
+
def __process_parser_state(self, parser_state):
rule_map = {}
builder = NfaBuilder()
@@ -281,6 +298,4 @@ class RuleProcessor(object):
# build the automata
for rule_name, graph in rule_map.items():
nfa = builder.nfa(graph)
- (start, dfa_nodes) = nfa.compute_dfa()
- dfa = Dfa(start, dfa_nodes)
- self.__automata[rule_name] = (nfa, dfa)
+ self.__automata[rule_name] = RuleProcessor.Automata(nfa)
« no previous file with comments | « tools/lexer_generator/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698