| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 328 |
| 329 class RuleProcessor(object): | 329 class RuleProcessor(object): |
| 330 | 330 |
| 331 def __init__(self, string, encoding_name): | 331 def __init__(self, string, encoding_name): |
| 332 self.__automata = {} | 332 self.__automata = {} |
| 333 self.__default_action = None | 333 self.__default_action = None |
| 334 self.__parser_state = RuleParserState(KeyEncoding.get(encoding_name)) | 334 self.__parser_state = RuleParserState(KeyEncoding.get(encoding_name)) |
| 335 RuleParser.parse(string, self.__parser_state) | 335 RuleParser.parse(string, self.__parser_state) |
| 336 self.__process_parser_state() | 336 self.__process_parser_state() |
| 337 | 337 |
| 338 def alias_iter(self): |
| 339 return iter(self.__parser_state.aliases.items()) |
| 340 |
| 338 def automata_iter(self): | 341 def automata_iter(self): |
| 339 return iter(self.__automata.items()) | 342 return iter(self.__automata.items()) |
| 340 | 343 |
| 341 def default_automata(self): | 344 def default_automata(self): |
| 342 return self.__automata['default'] | 345 return self.__automata['default'] |
| 343 | 346 |
| 344 def default_action(self): | 347 def default_action(self): |
| 345 return self.__default_action | 348 return self.__default_action |
| 346 | 349 |
| 347 class Automata(object): | 350 class Automata(object): |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 for tree_name, v in parser_state.rules.items(): | 399 for tree_name, v in parser_state.rules.items(): |
| 397 assert v['trees'], "lexer state %s is empty" % tree_name | 400 assert v['trees'], "lexer state %s is empty" % tree_name |
| 398 rule_map[tree_name] = NfaBuilder.or_terms(v['trees']) | 401 rule_map[tree_name] = NfaBuilder.or_terms(v['trees']) |
| 399 # build the automata | 402 # build the automata |
| 400 for name, tree in rule_map.items(): | 403 for name, tree in rule_map.items(): |
| 401 self.__automata[name] = RuleProcessor.Automata( | 404 self.__automata[name] = RuleProcessor.Automata( |
| 402 parser_state.encoding, parser_state.character_classes, rule_map, name) | 405 parser_state.encoding, parser_state.character_classes, rule_map, name) |
| 403 # process default_action | 406 # process default_action |
| 404 default_action = parser_state.rules['default']['default_action'] | 407 default_action = parser_state.rules['default']['default_action'] |
| 405 self.__default_action = Action(Term.empty_term(), default_action) | 408 self.__default_action = Action(Term.empty_term(), default_action) |
| OLD | NEW |