| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 'OR', | 44 'OR', |
| 45 'STAR', | 45 'STAR', |
| 46 'LEFT_PARENTHESIS', | 46 'LEFT_PARENTHESIS', |
| 47 'RIGHT_PARENTHESIS', | 47 'RIGHT_PARENTHESIS', |
| 48 'GRAPH_OPEN', | 48 'GRAPH_OPEN', |
| 49 'GRAPH_CLOSE', | 49 'GRAPH_CLOSE', |
| 50 'SEMICOLON', | 50 'SEMICOLON', |
| 51 'ACTION_OPEN', | 51 'ACTION_OPEN', |
| 52 'ACTION_CLOSE', | 52 'ACTION_CLOSE', |
| 53 | 53 |
| 54 'LEFT_BRACKET', | |
| 55 'RIGHT_BRACKET', | |
| 56 | |
| 57 'CODE_FRAGMENT', | |
| 58 | |
| 59 'COMMA', | 54 'COMMA', |
| 60 ) | 55 ) |
| 61 | 56 |
| 62 states = ( | |
| 63 ('code','exclusive'), | |
| 64 ) | |
| 65 | |
| 66 t_ignore = " \t\n\r" | 57 t_ignore = " \t\n\r" |
| 67 t_code_ignore = "" | |
| 68 | 58 |
| 69 def t_COMMENT(self, t): | 59 def t_COMMENT(self, t): |
| 70 r'\#.*[\n\r]+' | 60 r'\#.*[\n\r]+' |
| 71 pass | 61 pass |
| 72 | 62 |
| 73 __special_identifiers = set(map(lambda s: s.lower(), | 63 __special_identifiers = set(map(lambda s: s.lower(), |
| 74 ['DEFAULT_ACTION', 'CATCH_ALL'])) | 64 ['DEFAULT_ACTION', 'CATCH_ALL'])) |
| 75 | 65 |
| 76 def t_IDENTIFIER(self, t): | 66 def t_IDENTIFIER(self, t): |
| 77 r'[a-zA-Z0-9_]+' | 67 r'[a-zA-Z0-9_]+' |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 t_ACTION_OPEN = '<' | 86 t_ACTION_OPEN = '<' |
| 97 t_ACTION_CLOSE = '>' | 87 t_ACTION_CLOSE = '>' |
| 98 t_COMMA = ',' | 88 t_COMMA = ',' |
| 99 | 89 |
| 100 def t_LEFT_BRACKET(self, t): | 90 def t_LEFT_BRACKET(self, t): |
| 101 r'{' | 91 r'{' |
| 102 self.lexer.push_state('code') | 92 self.lexer.push_state('code') |
| 103 self.nesting = 1 | 93 self.nesting = 1 |
| 104 return t | 94 return t |
| 105 | 95 |
| 106 t_code_CODE_FRAGMENT = r'[^{}]+' | |
| 107 | |
| 108 def t_code_LEFT_BRACKET(self, t): | |
| 109 r'{' | |
| 110 self.nesting += 1 | |
| 111 t.type = 'CODE_FRAGMENT' | |
| 112 return t | |
| 113 | |
| 114 def t_code_RIGHT_BRACKET(self, t): | |
| 115 r'}' | |
| 116 self.nesting -= 1 | |
| 117 if self.nesting: | |
| 118 t.type = 'CODE_FRAGMENT' | |
| 119 else: | |
| 120 self.lexer.pop_state() | |
| 121 return t | |
| 122 | |
| 123 def t_ANY_error(self, t): | 96 def t_ANY_error(self, t): |
| 124 raise Exception("Illegal character '%s'" % t.value[0]) | 97 raise Exception("Illegal character '%s'" % t.value[0]) |
| 125 | 98 |
| 126 def build(self, **kwargs): | 99 def build(self, **kwargs): |
| 127 self.lexer = lex.lex(module=self, **kwargs) | 100 self.lexer = lex.lex(module=self, **kwargs) |
| OLD | NEW |