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

Unified Diff: tools/lexer_generator/term.py

Issue 169523003: Experimental parser: split and rename some files (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 10 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 | « tools/lexer_generator/rule_parser.py ('k') | tools/lexer_generator/test/automata_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/term.py
diff --git a/tools/lexer_generator/action.py b/tools/lexer_generator/term.py
similarity index 67%
rename from tools/lexer_generator/action.py
rename to tools/lexer_generator/term.py
index 8a377f7aa127d076b233ca3c863138bccc0cdfe5..3dde1bb689bda54a67059bc177daa1d2060a885c 100644
--- a/tools/lexer_generator/action.py
+++ b/tools/lexer_generator/term.py
@@ -69,54 +69,3 @@ class Term(object):
if self.__str == None:
self.__str = '(%s)' % ','.join(map(str, self.__tuple))
return self.__str
-
-class Action(object):
-
- __empty_action = None
-
- @staticmethod
- def empty_action():
- if Action.__empty_action == None:
- Action.__empty_action = Action(Term.empty_term(), -1)
- return Action.__empty_action
-
- @staticmethod
- def dominant_action(actions):
- dominant = Action.empty_action()
- for action in actions:
- if not action:
- continue
- if not dominant:
- dominant = action
- continue
- if action.precedence() == dominant.precedence():
- assert action.__term == dominant.__term
- elif action.precedence() < dominant.precedence():
- dominant = action
- return dominant
-
- def __init__(self, term, precedence):
- assert isinstance(term, Term)
- assert type(precedence) == IntType
- assert not term or precedence >= 0, 'action must have positive precedence'
- self.__term = term
- self.__precedence = precedence
-
- def name(self):
- return self.__term.name()
-
- def term(self):
- return self.__term
-
- def precedence(self):
- return self.__precedence
-
- def __nonzero__(self):
- 'true <==> self == empty_action'
- return bool(self.__term)
-
- def __eq__(self, other):
- return isinstance(other, self.__class__) and self.__term == other.__term
-
- def __str__(self):
- return "action <%s>" % ('' if not self.__term else str(self.__term))
« no previous file with comments | « tools/lexer_generator/rule_parser.py ('k') | tools/lexer_generator/test/automata_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698