| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 all_keys = [] # Will contain all TransitionKeys in the dfa. | 182 all_keys = [] # Will contain all TransitionKeys in the dfa. |
| 183 | 183 |
| 184 # f fills in initial_partitions, id_to_state and all_keys. | 184 # f fills in initial_partitions, id_to_state and all_keys. |
| 185 def f(state, visitor_state): | 185 def f(state, visitor_state): |
| 186 state_id = len(id_to_state) | 186 state_id = len(id_to_state) |
| 187 id_to_state[state_id] = state | 187 id_to_state[state_id] = state |
| 188 action = state.action() | 188 action = state.action() |
| 189 all_keys.append(state.key_iter()) | 189 all_keys.append(state.key_iter()) |
| 190 if action: | 190 if action: |
| 191 if state not in terminal_set: | 191 if state not in terminal_set: |
| 192 assert action.entry_action() | 192 # Match actions are valid only if we have matched the whole token, not |
| 193 # just some sub-part of it. |
| 194 assert not action.match_action() |
| 193 key = ("nonterminal action", action) | 195 key = ("nonterminal action", action) |
| 194 else: | 196 else: |
| 195 key = ("terminal action", action) | 197 key = ("terminal action", action) |
| 196 elif state in terminal_set: | 198 elif state in terminal_set: |
| 197 key = ("terminal set",) | 199 key = ("terminal set",) |
| 198 else: | 200 else: |
| 199 key = ("nonterminal set",) | 201 key = ("nonterminal set",) |
| 200 if not key in initial_partitions: | 202 if not key in initial_partitions: |
| 201 initial_partitions[key] = set() | 203 initial_partitions[key] = set() |
| 202 initial_partitions[key].add(state_id) | 204 initial_partitions[key].add(state_id) |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 elif len(intersection) <= len(difference): | 387 elif len(intersection) <= len(difference): |
| 386 working_set.add(intersection) | 388 working_set.add(intersection) |
| 387 else: | 389 else: |
| 388 working_set.add(difference) | 390 working_set.add(difference) |
| 389 if old_partitions: | 391 if old_partitions: |
| 390 partitions -= old_partitions | 392 partitions -= old_partitions |
| 391 if new_partitions: | 393 if new_partitions: |
| 392 partitions |= new_partitions | 394 partitions |= new_partitions |
| 393 (start_name, mapping) = self.__create_states_from_partitions(partitions) | 395 (start_name, mapping) = self.__create_states_from_partitions(partitions) |
| 394 return Dfa(self.__dfa.encoding(), start_name, mapping) | 396 return Dfa(self.__dfa.encoding(), start_name, mapping) |
| OLD | NEW |