| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 __special_identifiers = set(map(lambda s: s.lower(), | 73 __special_identifiers = set(map(lambda s: s.lower(), |
| 74 ['DEFAULT', 'DEFAULT_ACTION', 'CATCH_ALL', 'PUSH_TOKEN'])) | 74 ['DEFAULT', 'DEFAULT_ACTION', 'CATCH_ALL', 'PUSH_TOKEN'])) |
| 75 | 75 |
| 76 def t_IDENTIFIER(self, t): | 76 def t_IDENTIFIER(self, t): |
| 77 r'[a-zA-Z][a-zA-Z0-9_]*' | 77 r'[a-zA-Z][a-zA-Z0-9_]*' |
| 78 if t.value in self.__special_identifiers: | 78 if t.value in self.__special_identifiers: |
| 79 t.type = t.value.upper() | 79 t.type = t.value.upper() |
| 80 return t | 80 return t |
| 81 | 81 |
| 82 t_STRING = r'"((\\("|\w|\\))|[^\\"])+"' | 82 t_STRING = r'"((\\("|\w|\\))|[^\\"])+"' |
| 83 t_REGEX = r'/[^\/]+/' | 83 t_REGEX = r'/(\\/|[^/])+/' |
| 84 t_CHARACTER_CLASS_REGEX = r'\[([^\]]|\\\])+\]' | 84 t_CHARACTER_CLASS_REGEX = r'\[([^\]]|\\\])+\]' |
| 85 | 85 |
| 86 t_PLUS = r'\+' | 86 t_PLUS = r'\+' |
| 87 t_QUESTION_MARK = r'\?' | 87 t_QUESTION_MARK = r'\?' |
| 88 t_STAR = r'\*' | 88 t_STAR = r'\*' |
| 89 t_OR = r'\|' | 89 t_OR = r'\|' |
| 90 t_EQUALS = '=' | 90 t_EQUALS = '=' |
| 91 t_LEFT_PARENTHESIS = r'\(' | 91 t_LEFT_PARENTHESIS = r'\(' |
| 92 t_RIGHT_PARENTHESIS = r'\)' | 92 t_RIGHT_PARENTHESIS = r'\)' |
| 93 t_LESS_THAN = '<' | 93 t_LESS_THAN = '<' |
| (...skipping 23 matching lines...) Expand all Loading... |
| 117 t.type = 'CODE_FRAGMENT' | 117 t.type = 'CODE_FRAGMENT' |
| 118 else: | 118 else: |
| 119 self.lexer.pop_state() | 119 self.lexer.pop_state() |
| 120 return t | 120 return t |
| 121 | 121 |
| 122 def t_ANY_error(self, t): | 122 def t_ANY_error(self, t): |
| 123 raise Exception("Illegal character '%s'" % t.value[0]) | 123 raise Exception("Illegal character '%s'" % t.value[0]) |
| 124 | 124 |
| 125 def build(self, **kwargs): | 125 def build(self, **kwargs): |
| 126 self.lexer = lex.lex(module=self, **kwargs) | 126 self.lexer = lex.lex(module=self, **kwargs) |
| OLD | NEW |