| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 class KeyEncoding(object): | 31 class KeyEncoding(object): |
| 32 | 32 |
| 33 __encodings = {} | 33 __encodings = {} |
| 34 | 34 |
| 35 @staticmethod | 35 @staticmethod |
| 36 def get(name): | 36 def get(name): |
| 37 if not KeyEncoding.__encodings: | 37 if not KeyEncoding.__encodings: |
| 38 Latin1Encoding() | 38 Latin1Encoding() |
| 39 Utf16Encoding() | 39 Utf16Encoding() |
| 40 Utf8Encoding() |
| 40 return KeyEncoding.__encodings[name] | 41 return KeyEncoding.__encodings[name] |
| 41 | 42 |
| 42 def __init__(self, name, primary_range, class_names): | 43 def __init__(self, name, primary_range, class_names): |
| 43 assert not name in KeyEncoding.__encodings | 44 assert not name in KeyEncoding.__encodings |
| 44 KeyEncoding.__encodings[name] = self | 45 KeyEncoding.__encodings[name] = self |
| 45 assert primary_range[0] <= primary_range[1] | 46 assert primary_range[0] <= primary_range[1] |
| 46 assert primary_range[0] >= 0 | 47 assert primary_range[0] >= 0 |
| 47 self.__name = name | 48 self.__name = name |
| 48 self.__primary_range = primary_range | 49 self.__primary_range = primary_range |
| 49 self.__lower_bound = primary_range[0] | 50 self.__lower_bound = primary_range[0] |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 (65, 90), (97, 122), (170, 170), (181, 181), | 495 (65, 90), (97, 122), (170, 170), (181, 181), |
| 495 (186, 186), (192, 214), (216, 246), (248, 255), | 496 (186, 186), (192, 214), (216, 246), (248, 255), |
| 496 self.class_range('non_latin_1_letter')]) | 497 self.class_range('non_latin_1_letter')]) |
| 497 self.add_predefined_range( | 498 self.add_predefined_range( |
| 498 'line_terminator', | 499 'line_terminator', |
| 499 [(10, 10), (13, 13), self.class_range('non_latin_1_line_terminator')]) | 500 [(10, 10), (13, 13), self.class_range('non_latin_1_line_terminator')]) |
| 500 self.add_predefined_range( | 501 self.add_predefined_range( |
| 501 'identifier_part_not_letter', | 502 'identifier_part_not_letter', |
| 502 [(48, 57), (95, 95), | 503 [(48, 57), (95, 95), |
| 503 self.class_range('non_latin_1_identifier_part_not_letter')]) | 504 self.class_range('non_latin_1_identifier_part_not_letter')]) |
| 505 |
| 506 class Utf8Encoding(KeyEncoding): |
| 507 |
| 508 def __init__(self): |
| 509 super(Utf8Encoding, self).__init__( |
| 510 'utf8', |
| 511 (1, 127), |
| 512 ['eos', 'zero', 'byte_order_mark', |
| 513 'non_ascii_whitespace', |
| 514 'non_ascii_letter', |
| 515 'non_ascii_identifier_part_not_letter', |
| 516 'non_ascii_line_terminator', |
| 517 'non_ascii_everything_else']) |
| 518 self.add_predefined_range( |
| 519 'whitespace', |
| 520 [(9, 9), (11, 12), (32, 32), self.class_range('non_ascii_whitespace')]) |
| 521 self.add_predefined_range( |
| 522 'letter', [(65, 90), (97, 122), self.class_range('non_ascii_letter')]) |
| 523 self.add_predefined_range( |
| 524 'line_terminator', |
| 525 [(10, 10), (13, 13), self.class_range('non_ascii_line_terminator')]) |
| 526 self.add_predefined_range( |
| 527 'identifier_part_not_letter', |
| 528 [(48, 57), (95, 95), |
| 529 self.class_range('non_ascii_identifier_part_not_letter')]) |
| OLD | NEW |