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

Unified Diff: tools/lexer_generator/nfa.py

Issue 78133002: Experimental parser: cleanup transition iteration a little (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/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 289ec48eee21980b156b2a1eea7a153372d59bd6..344ef70c54d861eb2e3be489b1ef3209d3bdc788 100644
--- a/tools/lexer_generator/nfa.py
+++ b/tools/lexer_generator/nfa.py
@@ -99,15 +99,15 @@ class NfaState(AutomatonState):
def __matches(self, match_func, value):
# f collects states whose corresponding TransitionKey matches 'value'.
- f = (lambda acc, (key, states):
- acc | states if match_func(key, value) else acc)
- return reduce(f, self.__transitions.items(), set())
+ items = self.__transitions.items()
+ iters = [iter(states) for (key, states) in items if match_func(key, value)]
+ return chain(*iters)
def transition_state_iter_for_char(self, value):
- return iter(self.__matches(lambda k, v : k.matches_char(v), value))
+ return self.__matches(lambda k, v : k.matches_char(v), value)
def transition_state_iter_for_key(self, value):
- return iter(self.__matches(lambda k, v : k.is_superset_of_key(v), value))
+ return self.__matches(lambda k, v : k.is_superset_of_key(v), value)
class Nfa(Automaton):
« 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