Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: tools/lexer_generator/rule_parser.py

Issue 75353003: Experimental lexer generator: Lex files with zeros properly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/lexer_generator/code_generator.jinja ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « tools/lexer_generator/code_generator.jinja ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698