| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 class RuleLexer: | 30 class RuleLexer: |
| 31 | 31 |
| 32 tokens = ( | 32 tokens = ( |
| 33 'ALIAS', | 33 'ALIAS', |
| 34 'EQUALS', | 34 'EQUALS', |
| 35 'REGEX', | 35 'REGEX', |
| 36 'CONDITION', | 36 'CONDITION', |
| 37 'CONDITION_BEGIN', | 37 'CONDITION_BEGIN', |
| 38 'CONDITION_END', | 38 'CONDITION_END', |
| 39 'REGEX_AND_TRANSITION', | 39 'REGEX_TRANSITION_BODY', |
| 40 'REGEX_AND_BODY', | 40 'REGEX_TRANSITION', |
| 41 'REGEX_BODY', |
| 41 ) | 42 ) |
| 42 | 43 |
| 43 t_ANY_ignore = " \t\n" | 44 t_ANY_ignore = " \t\n" |
| 44 | 45 |
| 45 states = ( | 46 states = ( |
| 46 ('afterAlias', 'exclusive'), | 47 ('afterAlias', 'exclusive'), |
| 47 ('afterAliasEquals', 'exclusive'), | 48 ('afterAliasEquals', 'exclusive'), |
| 48 ('inCondition', 'exclusive'), | 49 ('inCondition', 'exclusive'), |
| 49 ('seenCondition', 'exclusive'), | 50 ('seenCondition', 'exclusive'), |
| 50 ('afterCondition', 'exclusive')) | 51 ('afterCondition', 'exclusive')) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 r'<' | 69 r'<' |
| 69 self.lexer.begin('inCondition') | 70 self.lexer.begin('inCondition') |
| 70 return t | 71 return t |
| 71 | 72 |
| 72 def t_inCondition_CONDITION(self, t): | 73 def t_inCondition_CONDITION(self, t): |
| 73 r'[a-zA-Z0-9_]+' | 74 r'[a-zA-Z0-9_]+' |
| 74 self.lexer.begin('seenCondition') | 75 self.lexer.begin('seenCondition') |
| 75 return t | 76 return t |
| 76 | 77 |
| 77 def t_seenCondition_CONDITION_END(self, t): | 78 def t_seenCondition_CONDITION_END(self, t): |
| 78 r'>' | 79 r'>\s*' |
| 79 self.lexer.begin('afterCondition') | 80 self.lexer.begin('afterCondition') |
| 80 return t | 81 return t |
| 81 | 82 |
| 82 def t_afterCondition_REGEX_AND_TRANSITION(self, t): | 83 def t_afterCondition_REGEX_TRANSITION_BODY(self, t): |
| 84 r'(?P<regex>.+)\s*=>\s*(?P<new>.+)\s*{\s*(?P<body>.+)\s*}\s*' |
| 85 self.lexer.begin('INITIAL') |
| 86 return t |
| 87 |
| 88 def t_afterCondition_REGEX_TRANSITION(self, t): |
| 83 r'(?P<regex>.+)\s*:=>\s*(?P<new>.+)\s*' | 89 r'(?P<regex>.+)\s*:=>\s*(?P<new>.+)\s*' |
| 84 self.lexer.begin('INITIAL') | 90 self.lexer.begin('INITIAL') |
| 85 return t | 91 return t |
| 86 | 92 |
| 87 def t_afterCondition_REGEX_AND_BODY(self, t): | 93 def t_afterCondition_REGEX_BODY(self, t): |
| 88 r'(?P<regex>.+)\s*{\s*(?P<body>.+)\s*}\s*' | 94 r'(?P<regex>.+?)\s+{\s*(?P<body>.+)\s*}\s*' |
| 89 self.lexer.begin('INITIAL') | 95 self.lexer.begin('INITIAL') |
| 90 return t | 96 return t |
| 91 | 97 |
| 92 def t_error(self, t): | 98 def t_ANY_error(self, t): |
| 93 raise Exception("Illegal character '%s'" % t.value[0]) | 99 raise Exception("Illegal character '%s'" % t.value[0]) |
| 94 | 100 |
| 95 def build(self, **kwargs): | 101 def build(self, **kwargs): |
| 96 self.lexer = lex.lex(module=self, **kwargs) | 102 self.lexer = lex.lex(module=self, **kwargs) |
| OLD | NEW |