| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 assert (TransitionKey.__lower_bound <= char and | 63 assert (TransitionKey.__lower_bound <= char and |
| 64 char <= TransitionKey.__latin_1_upper_bound) | 64 char <= TransitionKey.__latin_1_upper_bound) |
| 65 return TransitionKey.__create([(char, char)]) | 65 return TransitionKey.__create([(char, char)]) |
| 66 | 66 |
| 67 @staticmethod | 67 @staticmethod |
| 68 def character_class(invert, graph): | 68 def character_class(invert, graph): |
| 69 # TODO | 69 # TODO |
| 70 return TransitionKey.__create([(129, 129)]) | 70 return TransitionKey.__create([(129, 129)]) |
| 71 | 71 |
| 72 def matches_char(self, char): | 72 def matches_char(self, char): |
| 73 char = ord(char) |
| 73 for r in self.__ranges: | 74 for r in self.__ranges: |
| 74 if r[0] <= char and char <= r[1]: return True | 75 if r[0] <= char and char <= r[1]: return True |
| 75 return False | 76 return False |
| 76 | 77 |
| 77 def matches_key(self, key): | 78 def matches_key(self, key): |
| 78 assert isinstance(key, self.__class__) | 79 assert isinstance(key, self.__class__) |
| 79 assert key != TransitionKey.epsilon() | 80 assert key != TransitionKey.epsilon() |
| 80 if self == key: return True | 81 if self == key: return True |
| 81 if self == TransitionKey.epsilon(): return False | 82 if self == TransitionKey.epsilon(): return False |
| 82 # TODO | 83 # TODO |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 return "epsilon" | 105 return "epsilon" |
| 105 if self == self.any(): | 106 if self == self.any(): |
| 106 return "any" | 107 return "any" |
| 107 return ", ".join(TransitionKey.__print_range(x) for x in self.__ranges) | 108 return ", ".join(TransitionKey.__print_range(x) for x in self.__ranges) |
| 108 | 109 |
| 109 @staticmethod | 110 @staticmethod |
| 110 def merge_key_set(key_set): | 111 def merge_key_set(key_set): |
| 111 key_set -= set([TransitionKey.epsilon()]) | 112 key_set -= set([TransitionKey.epsilon()]) |
| 112 # TODO need intersections and symmetric differences | 113 # TODO need intersections and symmetric differences |
| 113 return key_set | 114 return key_set |
| OLD | NEW |