| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return TransitionKey.__cached_keys[name] | 96 return TransitionKey.__cached_keys[name] |
| 97 | 97 |
| 98 @staticmethod | 98 @staticmethod |
| 99 def epsilon(): | 99 def epsilon(): |
| 100 '''Returns a TransitionKey for the epsilon (empty) transition.''' | 100 '''Returns a TransitionKey for the epsilon (empty) transition.''' |
| 101 return TransitionKey.__cached_key('epsilon', lambda name : []) | 101 return TransitionKey.__cached_key('epsilon', lambda name : []) |
| 102 | 102 |
| 103 @staticmethod | 103 @staticmethod |
| 104 def any(): | 104 def any(): |
| 105 '''Returns a TransitionKey which matches any character.''' | 105 '''Returns a TransitionKey which matches any character.''' |
| 106 def bounds_getter(name): | 106 return TransitionKey.__cached_key( |
| 107 bounds = TransitionKey.__class_bounds.values() | 107 'any', |
| 108 bounds.sort() | 108 lambda name : sorted(TransitionKey.__class_bounds.values())) |
| 109 return bounds | |
| 110 return TransitionKey.__cached_key('any', bounds_getter) | |
| 111 | 109 |
| 112 @staticmethod | 110 @staticmethod |
| 113 def single_char(char): | 111 def single_char(char): |
| 114 '''Returns a TransitionKey for a single-character transition.''' | 112 '''Returns a TransitionKey for a single-character transition.''' |
| 115 char = ord(char) | 113 char = ord(char) |
| 116 assert TransitionKey.__in_latin_1(char) | 114 assert TransitionKey.__in_latin_1(char) |
| 117 return TransitionKey([(char, char)]) | 115 return TransitionKey([(char, char)]) |
| 118 | 116 |
| 119 @staticmethod | 117 @staticmethod |
| 120 def unique(name): | 118 def unique(name): |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 elif last[1] + 1 < r[0]: | 389 elif last[1] + 1 < r[0]: |
| 392 inverted.append((last[1] + 1, r[0] - 1)) | 390 inverted.append((last[1] + 1, r[0] - 1)) |
| 393 last = r | 391 last = r |
| 394 upper_bound = latin_1[1] | 392 upper_bound = latin_1[1] |
| 395 if last == None: | 393 if last == None: |
| 396 inverted.append(latin_1) | 394 inverted.append(latin_1) |
| 397 elif last[1] < upper_bound: | 395 elif last[1] < upper_bound: |
| 398 inverted.append((last[1] + 1, upper_bound)) | 396 inverted.append((last[1] + 1, upper_bound)) |
| 399 inverted += list(classes) | 397 inverted += list(classes) |
| 400 return inverted | 398 return inverted |
| OLD | NEW |