| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 action_map = {} | 211 action_map = {} |
| 212 id_map = {} | 212 id_map = {} |
| 213 terminal_set = self.__dfa.terminal_set() | 213 terminal_set = self.__dfa.terminal_set() |
| 214 all_keys = [] | 214 all_keys = [] |
| 215 def f(state, visitor_state): | 215 def f(state, visitor_state): |
| 216 state_id = len(id_map) | 216 state_id = len(id_map) |
| 217 id_map[state_id] = state | 217 id_map[state_id] = state |
| 218 action = state.action() | 218 action = state.action() |
| 219 all_keys.append(state.key_iter()) | 219 all_keys.append(state.key_iter()) |
| 220 if action: | 220 if action: |
| 221 # TODO add this back | |
| 222 # assert state in self.__terminal_set | |
| 223 if state not in terminal_set: | 221 if state not in terminal_set: |
| 224 action = "nonterminal action " + str(action) | 222 assert action.entry_action() |
| 223 action = ("nonterminal action", action) |
| 225 elif state in terminal_set: | 224 elif state in terminal_set: |
| 226 action = "terminal_set" | 225 action = "terminal_set" |
| 227 if not action in action_map: | 226 if not action in action_map: |
| 228 action_map[action] = set() | 227 action_map[action] = set() |
| 229 action_map[action].add(state_id) | 228 action_map[action].add(state_id) |
| 230 self.__dfa.visit_all_states(f) | 229 self.__dfa.visit_all_states(f) |
| 231 partitions = set() | 230 partitions = set() |
| 232 for p in action_map.values(): | 231 for p in action_map.values(): |
| 233 partitions.add(StatePartition(p)) | 232 partitions.add(StatePartition(p)) |
| 234 reverse_id_map = {v : k for k, v in id_map.items()} | 233 reverse_id_map = {v : k for k, v in id_map.items()} |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 elif len(intersection) <= len(difference): | 354 elif len(intersection) <= len(difference): |
| 356 working_set.add(intersection) | 355 working_set.add(intersection) |
| 357 else: | 356 else: |
| 358 working_set.add(difference) | 357 working_set.add(difference) |
| 359 if old_partitions: | 358 if old_partitions: |
| 360 partitions -= old_partitions | 359 partitions -= old_partitions |
| 361 if new_partitions: | 360 if new_partitions: |
| 362 partitions |= new_partitions | 361 partitions |= new_partitions |
| 363 (start_name, mapping) = self.__merge_partitions(partitions) | 362 (start_name, mapping) = self.__merge_partitions(partitions) |
| 364 return Dfa(start_name, mapping) | 363 return Dfa(start_name, mapping) |
| OLD | NEW |