| 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 from automaton import Action | 29 from automaton import Action |
| 30 from rule_lexer import RuleLexer | 30 from rule_lexer import RuleLexer |
| 31 from regex_parser import RegexParser | 31 from regex_parser import RegexParser |
| 32 from nfa_builder import NfaBuilder | 32 from nfa_builder import NfaBuilder |
| 33 from dfa import Dfa | 33 from dfa import Dfa |
| 34 from transition_keys import TransitionKey | 34 from transition_keys import TransitionKey |
| 35 | 35 |
| 36 class RuleParserState: | 36 class RuleParserState: |
| 37 | 37 |
| 38 def __init__(self): | 38 def __init__(self): |
| 39 self.aliases = { | 39 self.aliases = {} |
| 40 'eof' : RegexParser.parse("[\\0]"), | |
| 41 } | |
| 42 self.character_classes = {} | 40 self.character_classes = {} |
| 43 self.current_state = None | 41 self.current_state = None |
| 44 self.rules = {} | 42 self.rules = {} |
| 45 self.transitions = set() | 43 self.transitions = set() |
| 46 | 44 |
| 47 def parse(self, string): | 45 def parse(self, string): |
| 48 return RuleParser.parse(string, self) | 46 return RuleParser.parse(string, self) |
| 49 | 47 |
| 50 class RuleParser: | 48 class RuleParser: |
| 51 | 49 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 for k, v in parser_state.rules.items(): | 322 for k, v in parser_state.rules.items(): |
| 325 if k == 'default': continue | 323 if k == 'default': continue |
| 326 process(k, v) | 324 process(k, v) |
| 327 process('default', parser_state.rules['default']) | 325 process('default', parser_state.rules['default']) |
| 328 # build the automata | 326 # build the automata |
| 329 for rule_name, graph in rule_map.items(): | 327 for rule_name, graph in rule_map.items(): |
| 330 self.__automata[rule_name] = RuleProcessor.Automata(builder, graph) | 328 self.__automata[rule_name] = RuleProcessor.Automata(builder, graph) |
| 331 # process default_action | 329 # process default_action |
| 332 default_action = parser_state.rules['default']['default_action'] | 330 default_action = parser_state.rules['default']['default_action'] |
| 333 self.default_action = Action(None, default_action[1]) if default_action else
None | 331 self.default_action = Action(None, default_action[1]) if default_action else
None |
| OLD | NEW |