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

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

Issue 85853003: Experimental parser: simplify goto logic (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.jinja » ('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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return (isinstance(other, self.__class__) and 73 return (isinstance(other, self.__class__) and
74 self.__entry_action == other.__entry_action and 74 self.__entry_action == other.__entry_action and
75 self.__match_action == other.__match_action) 75 self.__match_action == other.__match_action)
76 76
77 def __str__(self): 77 def __str__(self):
78 parts = [] 78 parts = []
79 for action in [self.__entry_action, self.__match_action]: 79 for action in [self.__entry_action, self.__match_action]:
80 part = "" 80 part = ""
81 if action: 81 if action:
82 part += action[0] 82 part += action[0]
83 if action[1] and isinstance(action[1], str): 83 if action[1]:
84 part += "(%s)" % action[1] 84 part += "(%s)" % str(action[1])
85 parts.append(part) 85 parts.append(part)
86 return "action< %s >" % " | ".join(parts) 86 return "action< %s >" % " | ".join(parts)
87 87
88 class AutomatonState(object): 88 class AutomatonState(object):
89 89
90 __node_number_counter = 0 90 __node_number_counter = 0
91 91
92 def __init__(self): 92 def __init__(self):
93 self.__node_number = AutomatonState.__node_number_counter 93 self.__node_number = AutomatonState.__node_number_counter
94 AutomatonState.__node_number_counter += 1 94 AutomatonState.__node_number_counter += 1
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 node [shape = doublecircle, style=unfilled]; %s 243 node [shape = doublecircle, style=unfilled]; %s
244 node [shape = circle]; 244 node [shape = circle];
245 %s 245 %s
246 %s 246 %s
247 } 247 }
248 ''' % (start_shape, 248 ''' % (start_shape,
249 start_number, 249 start_number,
250 " ".join(terminals), 250 " ".join(terminals),
251 "\n".join(edge_content), 251 "\n".join(edge_content),
252 "\n".join(node_content)) 252 "\n".join(node_content))
OLDNEW
« no previous file with comments | « no previous file | tools/lexer_generator/code_generator.jinja » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698