| 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
|
|
|