| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 def __action(self, graph): | 207 def __action(self, graph): |
| 208 incoming = graph[3] | 208 incoming = graph[3] |
| 209 (start, ends) = self.__process(graph[1]) | 209 (start, ends) = self.__process(graph[1]) |
| 210 action = graph[2] | 210 action = graph[2] |
| 211 if incoming: | 211 if incoming: |
| 212 new_start = self.__new_state() | 212 new_start = self.__new_state() |
| 213 new_start.set_transition_action(action) | 213 new_start.set_transition_action(action) |
| 214 new_start.close(start) | 214 new_start.close(start) |
| 215 start = new_start | 215 start = new_start |
| 216 else: | 216 else: |
| 217 new_end = self.__new_state() |
| 217 for end in ends: | 218 for end in ends: |
| 218 end.set_transition_action(action) | 219 end.set_transition_action(action) |
| 220 self.__patch_ends(ends, new_end) |
| 221 ends = [new_end] |
| 219 return (start, ends) | 222 return (start, ends) |
| 220 | 223 |
| 221 def __continue(self, graph): | 224 def __continue(self, graph): |
| 222 (start, ends) = self.__process(graph[1]) | 225 (start, ends) = self.__process(graph[1]) |
| 223 state = self.__peek_state() | 226 state = self.__peek_state() |
| 224 if not state['start_node']: | 227 if not state['start_node']: |
| 225 state['start_node'] = self.__new_state() | 228 state['start_node'] = self.__new_state() |
| 226 end = self.__new_state() | 229 end = self.__new_state() |
| 227 self.__patch_ends(ends, end) | 230 self.__patch_ends(ends, end) |
| 228 ends = [end] | 231 ends = [end] |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 418 |
| 416 def compute_dfa(self): | 419 def compute_dfa(self): |
| 417 self.__compute_epsilon_closures() | 420 self.__compute_epsilon_closures() |
| 418 dfa_nodes = {} | 421 dfa_nodes = {} |
| 419 start_name = self.__to_dfa(set([self.__start]), dfa_nodes, self.__end) | 422 start_name = self.__to_dfa(set([self.__start]), dfa_nodes, self.__end) |
| 420 return (start_name, dfa_nodes) | 423 return (start_name, dfa_nodes) |
| 421 | 424 |
| 422 def to_dot(self): | 425 def to_dot(self): |
| 423 iterator = lambda visitor, state: self.__visit_all_edges(visitor, state) | 426 iterator = lambda visitor, state: self.__visit_all_edges(visitor, state) |
| 424 return self.generate_dot(self.__start, set([self.__end]), iterator) | 427 return self.generate_dot(self.__start, set([self.__end]), iterator) |
| OLD | NEW |