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

Side by Side Diff: tools/lexer_generator/automaton.py

Issue 66163014: Experimental parser: fix up action_type display (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/lexer_generator/code_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 the V8 project authors. All rights reserved. 1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 def escape(v): 130 def escape(v):
131 v = str(v) 131 v = str(v)
132 v = v.replace('\r', '\\\\r').replace('\t', '\\\\t').replace('\n', '\\\\n') 132 v = v.replace('\r', '\\\\r').replace('\t', '\\\\t').replace('\n', '\\\\n')
133 v = v.replace('\\', '\\\\').replace('\"', '\\\"') 133 v = v.replace('\\', '\\\\').replace('\"', '\\\"')
134 return v 134 return v
135 135
136 def f(node, (node_content, edge_content)): 136 def f(node, (node_content, edge_content)):
137 if node.action(): 137 if node.action():
138 action = node.action() 138 action = node.action()
139 if action.type() == 'code': 139 if action.type() == 'code':
140 # assert action.data()
141 action_text = action.data() 140 action_text = action.data()
141 elif action.type() == 'push_token':
142 action_text = "token(" + action.data() + ")"
142 else: 143 else:
143 action_text = action.type() 144 action_text = action.type()
144 action_text = escape(action_text) 145 action_text = escape(action_text)
145 node_content.append(' S_l%s[shape = box, label="%s"];' % 146 node_content.append(' S_l%s[shape = box, label="%s"];' %
146 (node.node_number(), action_text)) 147 (node.node_number(), action_text))
147 node_content.append(' S_%s -> S_l%s [arrowhead = none];' % 148 node_content.append(' S_%s -> S_l%s [arrowhead = none];' %
148 (node.node_number(), node.node_number())) 149 (node.node_number(), node.node_number()))
149 for key, state in node.key_state_iter(): 150 for key, state in node.key_state_iter():
150 if key == TransitionKey.epsilon(): 151 if key == TransitionKey.epsilon():
151 key = "ε" 152 key = "ε"
(...skipping 21 matching lines...) Expand all
173 node [shape = doublecircle, style=unfilled]; %s 174 node [shape = doublecircle, style=unfilled]; %s
174 node [shape = circle]; 175 node [shape = circle];
175 %s 176 %s
176 %s 177 %s
177 } 178 }
178 ''' % (start_shape, 179 ''' % (start_shape,
179 start_number, 180 start_number,
180 " ".join(terminals), 181 " ".join(terminals),
181 "\n".join(edge_content), 182 "\n".join(edge_content),
182 "\n".join(node_content)) 183 "\n".join(node_content))
OLDNEW
« no previous file with comments | « no previous file | tools/lexer_generator/code_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698