| OLD | NEW |
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if not self.transitions_to_multiple_states(): | 125 if not self.transitions_to_multiple_states(): |
| 126 if state_filter(states): | 126 if state_filter(states): |
| 127 yield yield_func(key, states) | 127 yield yield_func(key, states) |
| 128 else: | 128 else: |
| 129 for state in states: | 129 for state in states: |
| 130 if state_filter(state): | 130 if state_filter(state): |
| 131 yield yield_func(key, state) | 131 yield yield_func(key, state) |
| 132 | 132 |
| 133 class Automaton(object): | 133 class Automaton(object): |
| 134 | 134 |
| 135 def __init__(self, encoding): |
| 136 self.__encoding = encoding |
| 137 |
| 138 def encoding(self): |
| 139 return self.__encoding |
| 140 |
| 135 @staticmethod | 141 @staticmethod |
| 136 def visit_states(edge, visitor, visit_state = None, state_iter = None): | 142 def visit_states(edge, visitor, visit_state = None, state_iter = None): |
| 137 if not state_iter: | 143 if not state_iter: |
| 138 state_iter = lambda node: node.state_iter() | 144 state_iter = lambda node: node.state_iter() |
| 139 visited = set() | 145 visited = set() |
| 140 while edge: | 146 while edge: |
| 141 next_edge_iters = [] | 147 next_edge_iters = [] |
| 142 def f(visit_state, node): | 148 def f(visit_state, node): |
| 143 next_edge_iters.append(state_iter(node)) | 149 next_edge_iters.append(state_iter(node)) |
| 144 return visitor(node, visit_state) | 150 return visitor(node, visit_state) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 node [shape = doublecircle, style=unfilled]; %s | 241 node [shape = doublecircle, style=unfilled]; %s |
| 236 node [shape = circle]; | 242 node [shape = circle]; |
| 237 %s | 243 %s |
| 238 %s | 244 %s |
| 239 } | 245 } |
| 240 ''' % (start_shape, | 246 ''' % (start_shape, |
| 241 start_number, | 247 start_number, |
| 242 " ".join(terminals), | 248 " ".join(terminals), |
| 243 "\n".join(edge_content), | 249 "\n".join(edge_content), |
| 244 "\n".join(node_content)) | 250 "\n".join(node_content)) |
| OLD | NEW |