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

Unified Diff: tools/lexer_generator/automaton.py

Issue 143643005: Experimental parser: add tests for subgraph handling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 11 months 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/lexer_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/automaton.py
diff --git a/tools/lexer_generator/automaton.py b/tools/lexer_generator/automaton.py
index e10fac14f45489e3cb1714ed7eb8f094775d0bde..a911a1bb0f3ae61158ad847927ba261317265eaa 100644
--- a/tools/lexer_generator/automaton.py
+++ b/tools/lexer_generator/automaton.py
@@ -179,7 +179,7 @@ class Automaton(object):
valid_states = self.epsilon_closure(valid_states)
return len(self.terminal_set().intersection(valid_states)) > 0
- def lex(self, string):
+ def lex(self, string, default_action):
last_position = 0
valid_states = self.start_set()
for pos, c in enumerate(string):
@@ -188,7 +188,9 @@ class Automaton(object):
valid_states = transitions
continue
action = Action.dominant_action(valid_states)
- assert action # must invoke default action here
+ if not action:
+ assert default_action
+ action = default_action
yield (action, last_position, pos)
last_position = pos
# lex next token
@@ -196,7 +198,9 @@ class Automaton(object):
assert valid_states
valid_states = self.epsilon_closure(valid_states)
action = Action.dominant_action(valid_states)
- assert action # must invoke default action here
+ if not action:
+ assert default_action
+ action = default_action
yield (action, last_position, len(string))
def to_dot(self):
« no previous file with comments | « no previous file | tools/lexer_generator/lexer_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698