| 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 24 matching lines...) Expand all Loading... |
| 35 happens. When we generate code based on the transition key, the character | 35 happens. When we generate code based on the transition key, the character |
| 36 ranges generate simple checks and the class ranges generate more complicated | 36 ranges generate simple checks and the class ranges generate more complicated |
| 37 conditions, e.g., function calls.''' | 37 conditions, e.g., function calls.''' |
| 38 | 38 |
| 39 __class_bounds = { | 39 __class_bounds = { |
| 40 'latin_1' : (1, 255), | 40 'latin_1' : (1, 255), |
| 41 # These are not real ranges; they just need to be separate from any real | 41 # These are not real ranges; they just need to be separate from any real |
| 42 # ranges. | 42 # ranges. |
| 43 'non_latin_1_whitespace' : (256, 256), | 43 'non_latin_1_whitespace' : (256, 256), |
| 44 'non_latin_1_letter' : (257, 257), | 44 'non_latin_1_letter' : (257, 257), |
| 45 'non_latin1_identifier_part_not_letter' : (258, 258), | 45 'non_latin_1_identifier_part_not_letter' : (258, 258), |
| 46 'non_latin1_line_terminator' : (259, 259), | 46 'non_latin_1_line_terminator' : (259, 259), |
| 47 'eos' : (260, 260), | 47 'eos' : (260, 260), |
| 48 'zero' : (261, 261), | 48 'zero' : (261, 261), |
| 49 'byte_order_mark' : (262, 262), | 49 'byte_order_mark' : (262, 262), |
| 50 'non_latin_1_everything_else' : (263, 263), |
| 50 } | 51 } |
| 51 __lower_bound = min(__class_bounds.values(), key=lambda item: item[0])[0] | 52 __lower_bound = min(__class_bounds.values(), key=lambda item: item[0])[0] |
| 52 __upper_bound = max(__class_bounds.values(), key=lambda item: item[1])[1] | 53 __upper_bound = max(__class_bounds.values(), key=lambda item: item[1])[1] |
| 53 | 54 |
| 54 __cached_keys = {} | 55 __cached_keys = {} |
| 55 | 56 |
| 56 __unique_key_counter = -1 | 57 __unique_key_counter = -1 |
| 57 | 58 |
| 58 __predefined_ranges = { | 59 __predefined_ranges = { |
| 59 'whitespace' : [ | 60 'whitespace' : [ |
| 60 (9, 9), (11, 12), (32, 32), (133, 133), (160, 160), | 61 (9, 9), (11, 12), (32, 32), (133, 133), (160, 160), |
| 61 __class_bounds['non_latin_1_whitespace']], | 62 __class_bounds['non_latin_1_whitespace']], |
| 62 'letter' : [ | 63 'letter' : [ |
| 63 (65, 90), (97, 122), (170, 170), (181, 181), | 64 (65, 90), (97, 122), (170, 170), (181, 181), |
| 64 (186, 186), (192, 214), (216, 246), (248, 255), | 65 (186, 186), (192, 214), (216, 246), (248, 255), |
| 65 __class_bounds['non_latin_1_letter']], | 66 __class_bounds['non_latin_1_letter']], |
| 66 'line_terminator' : [ | 67 'line_terminator' : [ |
| 67 (10, 10), (13, 13), | 68 (10, 10), (13, 13), |
| 68 __class_bounds['non_latin1_line_terminator']], | 69 __class_bounds['non_latin_1_line_terminator']], |
| 69 'identifier_part_not_letter' : [ | 70 'identifier_part_not_letter' : [ |
| 70 (48, 57), (95, 95), | 71 (48, 57), (95, 95), |
| 71 __class_bounds['non_latin1_identifier_part_not_letter']], | 72 __class_bounds['non_latin_1_identifier_part_not_letter']], |
| 72 } | 73 } |
| 73 | 74 |
| 74 @staticmethod | 75 @staticmethod |
| 75 def __in_latin_1(char): | 76 def __in_latin_1(char): |
| 76 bound = TransitionKey.__class_bounds['latin_1'] | 77 bound = TransitionKey.__class_bounds['latin_1'] |
| 77 return (bound[0] <= char and char <= bound[1]) | 78 return (bound[0] <= char and char <= bound[1]) |
| 78 | 79 |
| 79 @staticmethod | 80 @staticmethod |
| 80 def __is_class_range(r): | 81 def __is_class_range(r): |
| 81 return r[0] == r[1] and not TransitionKey.__in_latin_1(r[0]) | 82 return r[0] == r[1] and not TransitionKey.__in_latin_1(r[0]) |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 elif last[1] + 1 < r[0]: | 416 elif last[1] + 1 < r[0]: |
| 416 inverted.append((last[1] + 1, r[0] - 1)) | 417 inverted.append((last[1] + 1, r[0] - 1)) |
| 417 last = r | 418 last = r |
| 418 upper_bound = latin_1[1] | 419 upper_bound = latin_1[1] |
| 419 if last == None: | 420 if last == None: |
| 420 inverted.append(latin_1) | 421 inverted.append(latin_1) |
| 421 elif last[1] < upper_bound: | 422 elif last[1] < upper_bound: |
| 422 inverted.append((last[1] + 1, upper_bound)) | 423 inverted.append((last[1] + 1, upper_bound)) |
| 423 inverted += list(classes) | 424 inverted += list(classes) |
| 424 return inverted | 425 return inverted |
| OLD | NEW |