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

Unified Diff: tools/lexer_generator/automaton.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/automata_test.py ('k') | tools/lexer_generator/code_generator_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 9c8e5bfe7dfeffef86c2d50b4c55adfe2d2de73f..3c4434456b2a9df1dd2cc05a1bbbb746ddef99ea 100644
--- a/tools/lexer_generator/automaton.py
+++ b/tools/lexer_generator/automaton.py
@@ -31,8 +31,12 @@ from transition_keys import TransitionKey
class Action(object):
- def __init__(self, entry_action, match_action = None, precedence = -1):
- assert type
+ def __init__(self, entry_action, match_action, precedence = -1):
+ for action in [entry_action, match_action]:
+ if action == None:
+ continue
+ assert type(action) == TupleType and len(action)
+ assert action[0] != None
self.__entry_action = entry_action
self.__match_action = match_action
self.__precedence = precedence
@@ -55,7 +59,15 @@ class Action(object):
self.__match_action == other.__match_action)
def __str__(self):
- return "action<%s, %s>" % (self.__entry_action, self.__match_action)
+ parts = []
+ for action in [self.__entry_action, self.__match_action]:
+ part = ""
+ if action:
+ part += action[0]
+ if action[1]:
+ part += "(%s)" % action[1]
+ parts.append(part)
+ return "action< %s >" % " | ".join(parts)
class AutomatonState(object):
« no previous file with comments | « tools/lexer_generator/automata_test.py ('k') | tools/lexer_generator/code_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698