| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 def node_number(self): | 49 def node_number(self): |
| 50 return self.__node_number | 50 return self.__node_number |
| 51 | 51 |
| 52 def __str__(self): | 52 def __str__(self): |
| 53 return "%s(%d)" % (type(self), self.node_number()) | 53 return "%s(%d)" % (type(self), self.node_number()) |
| 54 | 54 |
| 55 __pass = lambda x : True | 55 __pass = lambda x : True |
| 56 | 56 |
| 57 def key_iter(self, key_filter = __pass): | 57 def key_iter(self, key_filter = __pass): |
| 58 for k in self.transitions().keys(): | 58 return self.key_state_iter( |
| 59 if key_filter(k): yield k | 59 key_filter = key_filter, yield_func = lambda x, y: x) |
| 60 | 60 |
| 61 def state_iter(self, key_filter = __pass, state_filter = __pass): | 61 def state_iter(self, key_filter = __pass, state_filter = __pass): |
| 62 return self.key_state_iter(key_filter, state_filter, lambda x, y: y) | 62 return self.key_state_iter( |
| 63 key_filter = key_filter, state_filter = state_filter, |
| 64 yield_func = lambda x, y: y) |
| 63 | 65 |
| 64 def key_state_iter( | 66 def transition_state_iter_for_char(self, value): |
| 65 self, | 67 return self.key_state_iter( |
| 66 key_filter = __pass, | 68 match_func = lambda k, v : k.matches_char(value), |
| 67 state_filter = __pass, | 69 yield_func = lambda x, y: y) |
| 68 yield_func = lambda x, y : (x, y)): | 70 |
| 69 for key, states in self.transitions().items(): | 71 def transition_state_iter_for_key(self, value): |
| 70 if key_filter(key): | 72 return self.key_state_iter( |
| 71 if not self.transitions_to_multiple_states(): | 73 match_func = lambda k, v : k.is_superset_of_key(value), |
| 72 if state_filter(states): | 74 yield_func = lambda x, y: y) |
| 73 yield yield_func(key, states) | |
| 74 else: | |
| 75 for state in states: | |
| 76 if state_filter(state): | |
| 77 yield yield_func(key, state) | |
| 78 | 75 |
| 79 class Automaton(object): | 76 class Automaton(object): |
| 80 | 77 |
| 81 def __init__(self, encoding): | 78 def __init__(self, encoding): |
| 82 self.__encoding = encoding | 79 self.__encoding = encoding |
| 83 | 80 |
| 84 def encoding(self): | 81 def encoding(self): |
| 85 return self.__encoding | 82 return self.__encoding |
| 86 | 83 |
| 87 @staticmethod | 84 @staticmethod |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 node [shape = doublecircle, style=unfilled]; %s | 190 node [shape = doublecircle, style=unfilled]; %s |
| 194 node [shape = circle]; | 191 node [shape = circle]; |
| 195 %s | 192 %s |
| 196 %s | 193 %s |
| 197 } | 194 } |
| 198 ''' % (start_shape, | 195 ''' % (start_shape, |
| 199 start_number, | 196 start_number, |
| 200 " ".join(terminals), | 197 " ".join(terminals), |
| 201 "\n".join(edge_content), | 198 "\n".join(edge_content), |
| 202 "\n".join(node_content)) | 199 "\n".join(node_content)) |
| OLD | NEW |