| 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 30 matching lines...) Expand all Loading... |
| 41 'ONE_OR_MORE', | 41 'ONE_OR_MORE', |
| 42 'ZERO_OR_MORE', | 42 'ZERO_OR_MORE', |
| 43 'ZERO_OR_ONE', | 43 'ZERO_OR_ONE', |
| 44 'ANY', | 44 'ANY', |
| 45 | 45 |
| 46 'LITERAL', | 46 'LITERAL', |
| 47 | 47 |
| 48 'RANGE', | 48 'RANGE', |
| 49 'NOT', | 49 'NOT', |
| 50 'CLASS_LITERAL', | 50 'CLASS_LITERAL', |
| 51 'CHARACTER_CLASS', |
| 51 ) | 52 ) |
| 52 | 53 |
| 53 states = ( | 54 states = ( |
| 54 ('class','exclusive'), | 55 ('class','exclusive'), |
| 55 ) | 56 ) |
| 56 | 57 |
| 57 def t_ESCAPED_LITERAL(self, t): | 58 def t_ESCAPED_LITERAL(self, t): |
| 58 r'\\\(|\\\)|\\\[|\\\]|\\\||\\\+|\\\*|\\\?|\\\.|\\\\' | 59 r'\\\(|\\\)|\\\[|\\\]|\\\||\\\+|\\\*|\\\?|\\\.|\\\\' |
| 59 t.type = 'LITERAL' | 60 t.type = 'LITERAL' |
| 60 t.value = t.value[1:] | 61 t.value = t.value[1:] |
| (...skipping 16 matching lines...) Expand all Loading... |
| 77 self.lexer.push_state('class') | 78 self.lexer.push_state('class') |
| 78 return t | 79 return t |
| 79 | 80 |
| 80 def t_class_CLASS_END(self, t): | 81 def t_class_CLASS_END(self, t): |
| 81 r'\]' | 82 r'\]' |
| 82 self.lexer.pop_state() | 83 self.lexer.pop_state() |
| 83 return t | 84 return t |
| 84 | 85 |
| 85 t_class_RANGE = '-' | 86 t_class_RANGE = '-' |
| 86 t_class_NOT = '\^' | 87 t_class_NOT = '\^' |
| 88 t_class_CHARACTER_CLASS = ':ws:|:lit:' |
| 87 | 89 |
| 88 def t_class_ESCAPED_CLASS_LITERAL(self, t): | 90 def t_class_ESCAPED_CLASS_LITERAL(self, t): |
| 89 r'\\\^|\\-|\\\[|\\\]' | 91 r'\\\^|\\-|\\\[|\\\]\\:' |
| 90 t.type = 'CLASS_LITERAL' | 92 t.type = 'CLASS_LITERAL' |
| 91 t.value = t.value[1:] | 93 t.value = t.value[1:] |
| 92 return t | 94 return t |
| 93 | 95 |
| 94 t_class_CLASS_LITERAL = r'[a-zA-Z0-9]' # fix this | 96 t_class_CLASS_LITERAL = r'[a-zA-Z0-9]' # fix this |
| 95 | 97 |
| 96 t_ANY_ignore = '\n' | 98 t_ANY_ignore = '\n' |
| 97 | 99 |
| 98 def t_ANY_error(self, t): | 100 def t_ANY_error(self, t): |
| 99 raise Exception("Illegal character '%s'" % t.value[0]) | 101 raise Exception("Illegal character '%s'" % t.value[0]) |
| 100 | 102 |
| 101 def build(self, **kwargs): | 103 def build(self, **kwargs): |
| 102 self.lexer = lex.lex(module=self, **kwargs) | 104 self.lexer = lex.lex(module=self, **kwargs) |
| OLD | NEW |