| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return | 126 return |
| 127 if state.action(): | 127 if state.action(): |
| 128 yield state.action() | 128 yield state.action() |
| 129 if state in self.__terminal_set: | 129 if state in self.__terminal_set: |
| 130 yield Action('TERMINATE') | 130 yield Action('TERMINATE') |
| 131 else: | 131 else: |
| 132 yield Action('MISS') | 132 yield Action('MISS') |
| 133 | 133 |
| 134 def matches(self, string): | 134 def matches(self, string): |
| 135 actions = list(self.collect_actions(string)) | 135 actions = list(self.collect_actions(string)) |
| 136 return actions and actions[-1].type() == 'TERMINATE' | 136 return actions and actions[-1].entry_action() == 'TERMINATE' |
| 137 | 137 |
| 138 def lex(self, string): | 138 def lex(self, string): |
| 139 state = self.__start | 139 state = self.__start |
| 140 last_position = 0 | 140 last_position = 0 |
| 141 for pos, c in enumerate(string): | 141 for pos, c in enumerate(string): |
| 142 next = Dfa.__match_char(state, c) | 142 next = Dfa.__match_char(state, c) |
| 143 if not next: | 143 if not next: |
| 144 assert state.action() # must invoke default action here | 144 assert state.action() # must invoke default action here |
| 145 yield (state.action(), last_position, pos) | 145 yield (state.action(), last_position, pos) |
| 146 last_position = pos | 146 last_position = pos |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 elif len(intersection) <= len(difference): | 347 elif len(intersection) <= len(difference): |
| 348 working_set.add(intersection) | 348 working_set.add(intersection) |
| 349 else: | 349 else: |
| 350 working_set.add(difference) | 350 working_set.add(difference) |
| 351 if old_partitions: | 351 if old_partitions: |
| 352 partitions -= old_partitions | 352 partitions -= old_partitions |
| 353 if new_partitions: | 353 if new_partitions: |
| 354 partitions |= new_partitions | 354 partitions |= new_partitions |
| 355 (start_name, mapping) = self.__merge_partitions(partitions) | 355 (start_name, mapping) = self.__merge_partitions(partitions) |
| 356 return Dfa(start_name, mapping) | 356 return Dfa(start_name, mapping) |
| OLD | NEW |