| 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 19 matching lines...) Expand all Loading... |
| 30 from regex_parser import RegexParser | 30 from regex_parser import RegexParser |
| 31 from nfa import NfaBuilder | 31 from nfa import NfaBuilder |
| 32 from transition_keys import TransitionKey | 32 from transition_keys import TransitionKey |
| 33 | 33 |
| 34 class RuleParser: | 34 class RuleParser: |
| 35 | 35 |
| 36 tokens = RuleLexer.tokens | 36 tokens = RuleLexer.tokens |
| 37 | 37 |
| 38 def __init__(self): | 38 def __init__(self): |
| 39 self.aliases = { | 39 self.aliases = { |
| 40 'eof' : RegexParser.parse("eof"), #RegexParser.parse("[\0]"), | 40 'eof' : RegexParser.parse("[\\0]"), |
| 41 'any' : RegexParser.parse("."), | 41 'any' : RegexParser.parse("."), |
| 42 } | 42 } |
| 43 self.character_classes = {} | 43 self.character_classes = {} |
| 44 self.current_transition = None | 44 self.current_transition = None |
| 45 self.rules = {} | 45 self.rules = {} |
| 46 | 46 |
| 47 def p_statements(self, p): | 47 def p_statements(self, p): |
| 48 'statements : statement maybe_statements' | 48 'statements : statement maybe_statements' |
| 49 | 49 |
| 50 def p_maybe_statement(self, p): | 50 def p_maybe_statement(self, p): |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 def p_error(self, p): | 163 def p_error(self, p): |
| 164 raise Exception("Syntax error in input '%s'" % p) | 164 raise Exception("Syntax error in input '%s'" % p) |
| 165 | 165 |
| 166 def build(self, **kwargs): | 166 def build(self, **kwargs): |
| 167 self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs) | 167 self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs) |
| 168 self.lexer = RuleLexer() | 168 self.lexer = RuleLexer() |
| 169 self.lexer.build(**kwargs) | 169 self.lexer.build(**kwargs) |
| 170 | 170 |
| 171 def parse(self, data): | 171 def parse(self, data): |
| 172 return self.parser.parse(data, lexer=self.lexer.lexer) | 172 return self.parser.parse(data, lexer=self.lexer.lexer) |
| OLD | NEW |