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

Unified Diff: tools/lexer_generator/dfa.py

Issue 70443006: Expermental parser: fix state iteration in codegen (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/code_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/dfa.py
diff --git a/tools/lexer_generator/dfa.py b/tools/lexer_generator/dfa.py
index a7b388c1a78bb4338789b5b5f8814c6e0598c3ce..0431a0f53371a9fcca1fa0506001e9fa13fd821b 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -91,9 +91,6 @@ class Dfa(Automaton):
def terminal_set(self):
return set(self.__terminal_set)
- def all_states_iter(self):
- return self.__start.state_iter()
-
@staticmethod
def __match_char(state, char):
match = list(state.state_iter(key_filter = lambda k: k.matches_char(char)))
@@ -136,4 +133,22 @@ class Dfa(Automaton):
yield (state.action(), last_position, len(string))
def minimize(self):
- pass
+ paritions = []
+ working_set = []
+ action_map = {}
+ id_map = {}
+ def f(state, visitor_state):
+ node_number = state.node_number()
+ assert not node_number in id_map
+ id_map[node_number] = state
+ action = state.action()
+ if not action in action_map:
+ action_map[action] = set()
+ action_map[action].add(node_number)
+ self.visit_all_states(f)
+ total = 0
+ for p in action_map.values():
+ paritions.append(p)
+ total += len(p)
+ assert total == self.__node_count
+
« no previous file with comments | « tools/lexer_generator/code_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698