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

Unified Diff: tools/lexer_generator/dfa.py

Issue 73023005: Experimental lexer generator: random refactoring + comments. (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/code_generator.py ('k') | 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 d191e0518550f014d15076cf259b102dfd77786b..545fe84b6ee5d5e5531b89eabfdc84cc72c1dc23 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -55,14 +55,17 @@ class DfaState(AutomatonState):
# TODO abstract state matching
def __matches(self, match_func, value):
- f = lambda acc, (k, vs): acc | set([vs]) if match_func(k, value) else acc
+ # f collects states whose corresponding TransitionKey matches 'value'.
+ f = (lambda acc, (key, state):
+ acc | set([state]) if match_func(key, value) else acc)
matches = reduce(f, self.__transitions.items(), set())
+ # Since this is a dfa, we should have at most one such state. Return it.
if not matches:
return None
assert len(matches) == 1
return iter(matches).next()
- def char_matches(self, value):
+ def next_state_with_char(self, value):
return self.__matches(lambda k, v : k.matches_char(v), value)
def key_matches(self, value):
« no previous file with comments | « tools/lexer_generator/code_generator.py ('k') | tools/lexer_generator/nfa.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698