| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | regex_alias modifier''' | 143 | regex_alias modifier''' |
| 144 modifier = p[len(p)-1] | 144 modifier = p[len(p)-1] |
| 145 graph = p[2] if len(p) == 5 else p[1] | 145 graph = p[2] if len(p) == 5 else p[1] |
| 146 if modifier: | 146 if modifier: |
| 147 p[0] = NfaBuilder.apply_modifier(modifier, graph) | 147 p[0] = NfaBuilder.apply_modifier(modifier, graph) |
| 148 else: | 148 else: |
| 149 p[0] = graph | 149 p[0] = graph |
| 150 | 150 |
| 151 def p_regex_string_literal(self, p): | 151 def p_regex_string_literal(self, p): |
| 152 'regex_string_literal : STRING' | 152 'regex_string_literal : STRING' |
| 153 string = p[1][1:-1] |
| 153 escape_char = lambda string, char: string.replace(char, "\\" + char) | 154 escape_char = lambda string, char: string.replace(char, "\\" + char) |
| 154 string = reduce(escape_char, "\+?*|.[](){}", p[1][1:-1]) | 155 string = reduce(escape_char, "+?*|.[](){}", string).replace("\\\"", "\"") |
| 155 p[0] = RegexParser.parse(string) | 156 p[0] = RegexParser.parse(string) |
| 156 | 157 |
| 157 def p_regex(self, p): | 158 def p_regex(self, p): |
| 158 'regex : REGEX' | 159 'regex : REGEX' |
| 159 p[0] = RegexParser.parse(p[1][1:-1]) | 160 p[0] = RegexParser.parse(p[1][1:-1]) |
| 160 | 161 |
| 161 def p_regex_class(self, p): | 162 def p_regex_class(self, p): |
| 162 'regex_class : CHARACTER_CLASS_REGEX' | 163 'regex_class : CHARACTER_CLASS_REGEX' |
| 163 p[0] = RegexParser.parse(p[1]) | 164 p[0] = RegexParser.parse(p[1]) |
| 164 | 165 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 parser.build() | 205 parser.build() |
| 205 RuleParser.__static_instance = parser | 206 RuleParser.__static_instance = parser |
| 206 parser.__state = parser_state | 207 parser.__state = parser_state |
| 207 try: | 208 try: |
| 208 parser.parser.parse(data, lexer=parser.lexer.lexer) | 209 parser.parser.parse(data, lexer=parser.lexer.lexer) |
| 209 except Exception: | 210 except Exception: |
| 210 RuleParser.__static_instance = None | 211 RuleParser.__static_instance = None |
| 211 raise | 212 raise |
| 212 parser.__state = None | 213 parser.__state = None |
| 213 assert parser_state.transitions <= set(parser_state.rules.keys()) | 214 assert parser_state.transitions <= set(parser_state.rules.keys()) |
| OLD | NEW |