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

Unified Diff: tools/lexer_generator/nfa.py

Issue 153993014: Experimental parser: cleanup dfa.py (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/dfa.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/nfa.py
diff --git a/tools/lexer_generator/nfa.py b/tools/lexer_generator/nfa.py
index ed0b10dcacfbd44234cb2730791341950c156642..cf887304a7fdc6cbe12872c5b5444787c606706d 100644
--- a/tools/lexer_generator/nfa.py
+++ b/tools/lexer_generator/nfa.py
@@ -130,7 +130,7 @@ class Nfa(Automaton):
keys.discard(TransitionKey.epsilon())
return TransitionKey.disjoint_keys(encoding, keys)
- def __to_dfa(self, nfa_state_set, dfa_nodes, end_node):
+ def __to_dfa(self, nfa_state_set, dfa_nodes):
nfa_state_set = Automaton.epsilon_closure(nfa_state_set)
# nfa_state_set will be a state in the dfa.
assert nfa_state_set
@@ -139,7 +139,7 @@ class Nfa(Automaton):
return name
dfa_nodes[name] = {
'transitions': {},
- 'terminal': end_node in nfa_state_set,
+ 'terminal': self.__end in nfa_state_set,
'action' : Action.dominant_action(nfa_state_set)}
# Gather the set of transition keys for which the dfa state will have
# transitions (the disjoint set of all the transition keys from all the
@@ -153,11 +153,11 @@ class Nfa(Automaton):
# states ("match_states") (more accurately, its epsilon closure).
f = lambda state: state.transition_state_iter_for_key(key)
match_states = set(chain(*map(f, nfa_state_set)))
- transition_state = self.__to_dfa(match_states, dfa_nodes, end_node)
+ transition_state = self.__to_dfa(match_states, dfa_nodes)
dfa_nodes[name]['transitions'][key] = transition_state
return name
def compute_dfa(self):
dfa_nodes = {}
- start_name = self.__to_dfa(set([self.__start]), dfa_nodes, self.__end)
+ start_name = self.__to_dfa(set([self.__start]), dfa_nodes)
return (start_name, dfa_nodes)
« no previous file with comments | « tools/lexer_generator/dfa.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698