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

Unified Diff: tools/lexer_generator/nfa.py

Issue 62223002: Experimental lexer generator: transfer actions across epsilon transitions correctly when constructi… (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: code review (dcarney) 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') | tools/lexer_generator/rule_parser.py » ('j') | 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 b3f013d983924f8a6ed948cb0a96ee42ebafe073..d3e13d0024c4f024f41b2eb92a60d238cc4b9751 100644
--- a/tools/lexer_generator/nfa.py
+++ b/tools/lexer_generator/nfa.py
@@ -333,14 +333,24 @@ class Nfa:
f = lambda acc, state: acc | state.key_matches(key)
transitions = reduce(f, nfa_state_set, set())
match_states = set()
- actions = set()
+ actions = []
for (state, action) in transitions:
match_states.add(state)
if action:
- actions.add(action)
+ actions.append(action)
+
+ # Pull in actions which can be taken with an epsilon transition from the
+ # match state.
+ e = TransitionKey.epsilon()
+ if e in state.transitions():
+ for e_trans in state.transitions()[e]:
+ if e_trans[1]:
+ actions.append(e_trans[1])
+
assert len(match_states) == len(transitions)
- assert not actions or len(actions) == 1
- action = iter(actions).next() if actions else None
+
+ actions.sort()
+ action = actions[0] if actions else None
transition_state = Nfa.__to_dfa(match_states, dfa_nodes, end_node)
dfa_nodes[name]['transitions'][key] = (transition_state, action)
return name
« no previous file with comments | « tools/lexer_generator/generator.py ('k') | tools/lexer_generator/rule_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698