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

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

Issue 64153002: Experimental parser: more dot escaping (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 | no next file » | 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return state 54 return state
55 55
56 @staticmethod 56 @staticmethod
57 def generate_dot(start_node, terminal_set, edge_iterator): 57 def generate_dot(start_node, terminal_set, edge_iterator):
58 58
59 def escape(v): 59 def escape(v):
60 v = str(v).replace('\r', '\\\\r') 60 v = str(v).replace('\r', '\\\\r')
61 v = str(v).replace('\t', '\\\\t') 61 v = str(v).replace('\t', '\\\\t')
62 v = str(v).replace('\n', '\\\\n') 62 v = str(v).replace('\n', '\\\\n')
63 v = str(v).replace('\\', '\\\\') 63 v = str(v).replace('\\', '\\\\')
64 v = str(v).replace('\"', '\\\"')
64 return v 65 return v
65 66
66 def f(node, node_content): 67 def f(node, node_content):
67 for key, values in node.transitions().items(): 68 for key, values in node.transitions().items():
68 if key == TransitionKey.epsilon(): 69 if key == TransitionKey.epsilon():
69 key = "ε" 70 key = "ε"
70 # TODO pass this action as parameter 71 # TODO pass this action as parameter
71 if type(values) == TupleType: 72 if type(values) == TupleType:
72 values = [values] 73 values = [values]
73 for (state, action) in values: 74 for (state, action) in values:
(...skipping 22 matching lines...) Expand all
96 rankdir=LR; 97 rankdir=LR;
97 node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s 98 node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s
98 node [shape = doublecircle, style=unfilled]; %s 99 node [shape = doublecircle, style=unfilled]; %s
99 node [shape = circle]; 100 node [shape = circle];
100 %s 101 %s
101 } 102 }
102 ''' % (start_shape, 103 ''' % (start_shape,
103 start_number, 104 start_number,
104 " ".join(terminals), 105 " ".join(terminals),
105 "\n".join(node_content)) 106 "\n".join(node_content))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698