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

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

Issue 136753019: Experimental parser: output alias dot to html (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 10 months 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/generator.py ('k') | no next file » | 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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)
OLDNEW
« no previous file with comments | « tools/lexer_generator/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698