| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 matches = reduce(f, self.__transitions.items(), set()) | 59 matches = reduce(f, self.__transitions.items(), set()) |
| 60 if not matches: | 60 if not matches: |
| 61 return None | 61 return None |
| 62 assert len(matches) == 1 | 62 assert len(matches) == 1 |
| 63 return iter(matches).next() | 63 return iter(matches).next() |
| 64 | 64 |
| 65 def char_matches(self, value): | 65 def char_matches(self, value): |
| 66 return self.__matches(lambda k, v : k.matches_char(v), value) | 66 return self.__matches(lambda k, v : k.matches_char(v), value) |
| 67 | 67 |
| 68 def key_matches(self, value): | 68 def key_matches(self, value): |
| 69 return self.__matches(lambda k, v : k.matches_key(v), value) | 69 return self.__matches(lambda k, v : k.is_superset_of_key(v), value) |
| 70 | 70 |
| 71 class Dfa(Automaton): | 71 class Dfa(Automaton): |
| 72 | 72 |
| 73 def __init__(self, start_name, mapping): | 73 def __init__(self, start_name, mapping): |
| 74 super(Dfa, self).__init__() | 74 super(Dfa, self).__init__() |
| 75 self.__terminal_set = set() | 75 self.__terminal_set = set() |
| 76 name_map = {} | 76 name_map = {} |
| 77 for name, node_data in mapping.items(): | 77 for name, node_data in mapping.items(): |
| 78 node = DfaState(name, node_data['action']) | 78 node = DfaState(name, node_data['action']) |
| 79 name_map[name] = node | 79 name_map[name] = node |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 elif len(intersection) <= len(difference): | 361 elif len(intersection) <= len(difference): |
| 362 working_set.add(intersection) | 362 working_set.add(intersection) |
| 363 else: | 363 else: |
| 364 working_set.add(difference) | 364 working_set.add(difference) |
| 365 if old_partitions: | 365 if old_partitions: |
| 366 partitions -= old_partitions | 366 partitions -= old_partitions |
| 367 if new_partitions: | 367 if new_partitions: |
| 368 partitions |= new_partitions | 368 partitions |= new_partitions |
| 369 (start_name, mapping) = self.__merge_partitions(partitions) | 369 (start_name, mapping) = self.__merge_partitions(partitions) |
| 370 return Dfa(start_name, mapping) | 370 return Dfa(start_name, mapping) |
| OLD | NEW |