| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 def p_maybe_modifier(self, p): | 223 def p_maybe_modifier(self, p): |
| 224 '''maybe_modifier : ONE_OR_MORE | 224 '''maybe_modifier : ONE_OR_MORE |
| 225 | ZERO_OR_ONE | 225 | ZERO_OR_ONE |
| 226 | ZERO_OR_MORE | 226 | ZERO_OR_MORE |
| 227 | REPEAT_BEGIN NUMBER REPEAT_END | 227 | REPEAT_BEGIN NUMBER REPEAT_END |
| 228 | REPEAT_BEGIN NUMBER COMMA NUMBER REPEAT_END | 228 | REPEAT_BEGIN NUMBER COMMA NUMBER REPEAT_END |
| 229 | empty''' | 229 | empty''' |
| 230 if len(p) == 4: | 230 if len(p) == 4: |
| 231 p[0] = ("REPEAT", p[2], p[2]) | 231 p[0] = ("REPEAT", p[2], p[2]) |
| 232 elif len(p) == 5: | 232 elif len(p) == 6: |
| 233 p[0] = ("REPEAT", p[2], p[4]) | 233 p[0] = ("REPEAT", p[2], p[4]) |
| 234 elif p[1]: | 234 elif p[1]: |
| 235 p[0] = (self.token_map[p[1]],) | 235 p[0] = (self.token_map[p[1]],) |
| 236 else: | 236 else: |
| 237 p[0] = None | 237 p[0] = None |
| 238 | 238 |
| 239 def p_literal(self, p): | 239 def p_literal(self, p): |
| 240 '''literal : LITERAL''' | 240 '''literal : LITERAL''' |
| 241 p[0] = Term('LITERAL', p[1]) | 241 p[0] = Term('LITERAL', p[1]) |
| 242 | 242 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 @staticmethod | 284 @staticmethod |
| 285 def __cat(left, right): | 285 def __cat(left, right): |
| 286 assert left | 286 assert left |
| 287 return NfaBuilder.cat_terms([left] if not right else [left, right]) | 287 return NfaBuilder.cat_terms([left] if not right else [left, right]) |
| 288 | 288 |
| 289 @staticmethod | 289 @staticmethod |
| 290 def parse(string): | 290 def parse(string): |
| 291 new_lexer = lambda: RegexLexer() | 291 new_lexer = lambda: RegexLexer() |
| 292 new_parser = lambda: RegexParser() | 292 new_parser = lambda: RegexParser() |
| 293 return ParserBuilder.parse(string, "RegexParser", new_lexer, new_parser) | 293 return ParserBuilder.parse(string, "RegexParser", new_lexer, new_parser) |
| OLD | NEW |