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

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

Issue 59403010: Experimental parser: easier to read rules and default rule (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 | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 yield ('MISS',) 110 yield ('MISS',)
111 111
112 def matches(self, string): 112 def matches(self, string):
113 actions = list(self.collect_actions(string)) 113 actions = list(self.collect_actions(string))
114 return actions and actions[-1][0] == 'TERMINATE' 114 return actions and actions[-1][0] == 'TERMINATE'
115 115
116 def to_dot(self): 116 def to_dot(self):
117 117
118 def f(node, node_content): 118 def f(node, node_content):
119 for key, (state, action) in node.transitions().items(): 119 for key, (state, action) in node.transitions().items():
120 key = str(key).replace('\\', '\\\\')
120 if action: 121 if action:
121 node_content.append( 122 node_content.append(
122 " S_%s -> S_%s [ label = \"%s {%s} -> %s\" ];" % 123 " S_%s -> S_%s [ label = \"%s {%s} -> %s\" ];" %
123 (node.node_number(), state.node_number(), key, action[0], 124 (node.node_number(), state.node_number(), key, action[0],
124 action[1])) 125 action[1]))
125 else: 126 else:
126 node_content.append( 127 node_content.append(
127 " S_%s -> S_%s [ label = \"%s\" ];" % 128 " S_%s -> S_%s [ label = \"%s\" ];" %
128 (node.node_number(), state.node_number(), key)) 129 (node.node_number(), state.node_number(), key))
129 return node_content 130 return node_content
(...skipping 10 matching lines...) Expand all
140 rankdir=LR; 141 rankdir=LR;
141 node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s 142 node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s
142 node [shape = doublecircle, style=unfilled]; %s 143 node [shape = doublecircle, style=unfilled]; %s
143 node [shape = circle]; 144 node [shape = circle];
144 %s 145 %s
145 } 146 }
146 ''' % (start_shape, 147 ''' % (start_shape,
147 start_number, 148 start_number,
148 " ".join(terminals), 149 " ".join(terminals),
149 "\n".join(node_content)) 150 "\n".join(node_content))
OLDNEW
« no previous file with comments | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698