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

Unified Diff: tools/lexer_generator/dfa.py

Issue 73143002: Experimental parser: cleanup after grammar refactor (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_test.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/dfa.py
diff --git a/tools/lexer_generator/dfa.py b/tools/lexer_generator/dfa.py
index 8bfbeea76f68fa58daa193b5f4e5e593f1a309d2..c3807e0eabe8c20b427da3e88b3038d957e5e771 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -117,23 +117,31 @@ class Dfa(Automaton):
assert len(match) == 1
return match[0]
+ @staticmethod
+ def terminal_action():
+ return Action(None, ('TERMINATE', None))
+
+ @staticmethod
+ def miss_action():
+ return Action(None, ('Miss', None))
+
def collect_actions(self, string):
state = self.__start
for c in string:
state = Dfa.__match_char(state, c)
if not state:
- yield Action('MISS')
+ yield self.miss_action()
return
if state.action():
yield state.action()
if state in self.__terminal_set:
- yield Action('TERMINATE')
+ yield self.terminal_action()
else:
- yield Action('MISS')
+ yield self.miss_action()
def matches(self, string):
actions = list(self.collect_actions(string))
- return actions and actions[-1].entry_action() == 'TERMINATE'
+ return actions and actions[-1] == self.terminal_action()
def lex(self, string):
state = self.__start
« no previous file with comments | « tools/lexer_generator/code_generator_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698