Reviewers: dcarney_chromium.org.,
Message:
Committed patchset #1 manually as r17616.
Description:
Experimental lexer generator: fix actions in graphs.
Actions are now associated to a node, not an edge. So much beautiful.
[email protected].
BUG=
Committed: https://code.google.com/p/v8/source/detail?r=17616
Please review this at https://codereview.chromium.org/68523003/
SVN Base: https://v8.googlecode.com/svn/branches/experimental/parser
Affected files (+14, -15 lines):
M tools/lexer_generator/automaton.py
Index: tools/lexer_generator/automaton.py
diff --git a/tools/lexer_generator/automaton.py
b/tools/lexer_generator/automaton.py
index
8b1e12772f0a56beb69a897d3a96d884f431e92c..470a918244295d2bcf71d2c427a30a4d7d97b96b
100644
--- a/tools/lexer_generator/automaton.py
+++ b/tools/lexer_generator/automaton.py
@@ -67,27 +67,24 @@ class Automaton(object):
v = str(v).replace('\"', '\\\"')
return v
- def f(node, node_content):
+ def f(node, content):
+ (node_content, edge_content) = content
+ if node.action():
+ action_text = node.action()[1].split('\n')[0]
+ 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, values in node.transitions().items():
if key == TransitionKey.epsilon():
key = "ε"
for state in state_iterator(values):
- action = state.action()
- if action:
- content = " S_%s -> S_%s [ label = \"%s {%s}:%d\" ];" % (
- node.node_number(),
- state.node_number(),
- escape(key),
- escape(action[1]),
- action[0])
- else:
- content = " S_%s -> S_%s [ label = \"%s\" ];" % (
- node.node_number(), state.node_number(), escape(key))
- node_content.append(content)
- return node_content
+ 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_iterator(f, [])
terminals = ["S_%d;" % x.node_number() for x in terminal_set]
+ (node_content, edge_content) = edge_iterator(f, ([], []))
start_number = start_node.node_number()
start_shape = "circle"
if start_node in terminal_set:
@@ -100,8 +97,10 @@ digraph finite_state_machine {
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))
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.