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

Unified Diff: tools/lexer_generator/action.py

Issue 159853009: Experimental parser: split off dot processing (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 | « no previous file | tools/lexer_generator/automata_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/action.py
diff --git a/tools/lexer_generator/action.py b/tools/lexer_generator/action.py
index 40a3fd37041deb9ece7bbb106b44e3813c2aff8b..03e6c305b1c6a6b55816611799b6c1eeecfdd2d8 100644
--- a/tools/lexer_generator/action.py
+++ b/tools/lexer_generator/action.py
@@ -74,36 +74,6 @@ class Term(object):
self.__str = '(%s)' % ','.join(map(str, self.__tuple))
return self.__str
- def to_dot(self):
- node_ix = [0]
- node_template = 'node [label="%s"]; N_%d;'
- edge_template = 'N_%d -> N_%d'
- nodes = []
- edges = []
-
- def escape(v): # TODO(dcarney): abstract into utilities
- v = str(v)
- v = v.replace('\r', '\\\\r').replace('\t', '\\\\t').replace('\n', '\\\\n')
- v = v.replace('\\', '\\\\').replace('\"', '\\\"')
- return v
-
- def process(term):
- if type(term) == StringType or type(term) == IntType:
- node_ix[0] += 1
- nodes.append(node_template % (escape(str(term)), node_ix[0]))
- return node_ix[0]
- elif isinstance(term, Term):
- child_ixs = map(process, term.args())
- node_ix[0] += 1
- nodes.append(node_template % (escape(term.name()), node_ix[0]))
- for child_ix in child_ixs:
- edges.append(edge_template % (node_ix[0], child_ix))
- return node_ix[0]
- raise Exception
-
- process(self)
- return 'digraph { %s %s }' % ('\n'.join(nodes), '\n'.join(edges))
-
class Action(object):
__empty_action = None
« no previous file with comments | « no previous file | tools/lexer_generator/automata_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698