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

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

Issue 82803003: Experimental parser: add utf8 encoding (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 def f(node, (node_content, edge_content)): 210 def f(node, (node_content, edge_content)):
211 if node.action(): 211 if node.action():
212 action_text = escape(node.action()) 212 action_text = escape(node.action())
213 node_content.append(' S_l%s[shape = box, label="%s"];' % 213 node_content.append(' S_l%s[shape = box, label="%s"];' %
214 (node.node_number(), action_text)) 214 (node.node_number(), action_text))
215 node_content.append(' S_%s -> S_l%s [arrowhead = none];' % 215 node_content.append(' S_%s -> S_l%s [arrowhead = none];' %
216 (node.node_number(), node.node_number())) 216 (node.node_number(), node.node_number()))
217 for key, state in node.key_state_iter(): 217 for key, state in node.key_state_iter():
218 if key == TransitionKey.epsilon(): 218 if key == TransitionKey.epsilon():
219 key = "ε" 219 key = "ε"
220 else:
221 key = key.to_string(self.encoding())
220 edge_content.append(" S_%s -> S_%s [ label = \"%s\" ];" % ( 222 edge_content.append(" S_%s -> S_%s [ label = \"%s\" ];" % (
221 node.node_number(), state.node_number(), escape(key))) 223 node.node_number(), state.node_number(), escape(key)))
222 return (node_content, edge_content) 224 return (node_content, edge_content)
223 225
224 (node_content, edge_content) = self.visit_all_states(f, ([], [])) 226 (node_content, edge_content) = self.visit_all_states(f, ([], []))
225 227
226 start_set = self.start_set() 228 start_set = self.start_set()
227 assert len(start_set) == 1 229 assert len(start_set) == 1
228 start_node = iter(start_set).next() 230 start_node = iter(start_set).next()
229 terminal_set = self.terminal_set() 231 terminal_set = self.terminal_set()
(...skipping 11 matching lines...) Expand all
241 node [shape = doublecircle, style=unfilled]; %s 243 node [shape = doublecircle, style=unfilled]; %s
242 node [shape = circle]; 244 node [shape = circle];
243 %s 245 %s
244 %s 246 %s
245 } 247 }
246 ''' % (start_shape, 248 ''' % (start_shape,
247 start_number, 249 start_number,
248 " ".join(terminals), 250 " ".join(terminals),
249 "\n".join(edge_content), 251 "\n".join(edge_content),
250 "\n".join(node_content)) 252 "\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