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

Unified Diff: tools/lexer_generator/dfa.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 | « no previous file | tools/lexer_generator/nfa.py » ('j') | 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 154caef89c09d0ca26ed4fd2507994d251815e95..12d3dce014e8efeba8f891310a3e85b079af3170 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -59,10 +59,8 @@ class DfaState(AutomatonState):
# TODO abstract state matching
def __matches(self, match_func, value):
- # f collects states whose corresponding TransitionKey matches 'value'.
- f = (lambda acc, (key, state):
- acc | set([state]) if match_func(key, value) else acc)
- return reduce(f, self.__transitions.items(), set())
+ items = self.__transitions.items()
+ return [state for (key, state) in items if match_func(key, value)]
def transition_state_iter_for_char(self, value):
return iter(self.__matches(lambda k, v : k.matches_char(v), value))
@@ -76,7 +74,7 @@ class DfaState(AutomatonState):
return None
# Since this is a dfa, we should have at most one such state. Return it.
assert len(matches) == 1
- return iter(matches).next()
+ return matches[0]
class Dfa(Automaton):
« no previous file with comments | « no previous file | tools/lexer_generator/nfa.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698