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

Unified Diff: tools/lexer_generator/automaton.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 | « tools/lexer_generator/automata_test.py ('k') | tools/lexer_generator/dot_utilities.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 a3082fd313640c36b539bfa7dfc537dff7b4821f..776b88a3d9f0d3cfacfd32f0f7bc92264fbadffb 100644
--- a/tools/lexer_generator/automaton.py
+++ b/tools/lexer_generator/automaton.py
@@ -145,55 +145,3 @@ class Automaton(object):
assert default_action
action = default_action
yield (action, last_position, len(string))
-
- def to_dot(self):
-
- def escape(v):
- v = str(v)
- v = v.replace('\r', '\\\\r').replace('\t', '\\\\t').replace('\n', '\\\\n')
- v = v.replace('\\', '\\\\').replace('\"', '\\\"')
- return v
-
- def f(node, (node_content, edge_content)):
- if node.action():
- action_text = escape(node.action())
- node_content.append(' S_l%s[shape = box, label="%s"];' %
- (node.node_number(), action_text))
- node_content.append(' S_%s -> S_l%s [arrowhead = none];' %
- (node.node_number(), node.node_number()))
- for key, state in node.key_state_iter():
- if key == TransitionKey.epsilon():
- key = "ε"
- else:
- key = key.to_string(self.encoding())
- edge_content.append(" S_%s -> S_%s [ label = \"%s\" ];" % (
- node.node_number(), state.node_number(), escape(key)))
- return (node_content, edge_content)
-
- (node_content, edge_content) = self.visit_all_states(f, ([], []))
-
- start_set = self.start_set()
- assert len(start_set) == 1
- start_node = iter(start_set).next()
- terminal_set = self.terminal_set()
-
- terminals = ["S_%d;" % x.node_number() for x in terminal_set]
- start_number = start_node.node_number()
- start_shape = "circle"
- if start_node in terminal_set:
- start_shape = "doublecircle"
-
- return '''
-digraph finite_state_machine {
- rankdir=LR;
- node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s
- node [shape = doublecircle, style=unfilled]; %s
- node [shape = circle];
-%s
-%s
-}
- ''' % (start_shape,
- start_number,
- " ".join(terminals),
- "\n".join(edge_content),
- "\n".join(node_content))
« no previous file with comments | « tools/lexer_generator/automata_test.py ('k') | tools/lexer_generator/dot_utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698