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

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

Issue 160443002: Experimental parser: remove match actions (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/regex_parser.py ('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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 # process tree 181 # process tree
182 if p[1] == 'eos' or p[1] == 'catch_all': 182 if p[1] == 'eos' or p[1] == 'catch_all':
183 assert p[1] not in rules['uniques'], "cannot redefine %s in %s" % ( 183 assert p[1] not in rules['uniques'], "cannot redefine %s in %s" % (
184 p[1], self.__state.current_state) 184 p[1], self.__state.current_state)
185 rules['uniques'][p[1]] = True 185 rules['uniques'][p[1]] = True
186 tree = NfaBuilder.unique_key(p[1]) 186 tree = NfaBuilder.unique_key(p[1])
187 elif p[1] == 'epsilon': 187 elif p[1] == 'epsilon':
188 tree = Term.empty_term() 188 tree = Term.empty_term()
189 else: 189 else:
190 tree = p[1] # regex case 190 tree = p[1] # regex case
191 # handle actions 191 # install actions
192 if entry_action or match_action: 192 tree = NfaBuilder.add_action(tree, entry_action, match_action, precedence)
193 tree = NfaBuilder.add_action(
194 tree, Action(entry_action, match_action, precedence))
195 # handle transitions 193 # handle transitions
196 if not transition: 194 if not transition:
197 pass 195 pass
198 elif transition.name() == 'continue': 196 elif transition.name() == 'continue':
199 tree = NfaBuilder.add_continue(tree, transition.args()[0]) 197 tree = NfaBuilder.add_continue(tree, transition.args()[0])
200 else: 198 else:
201 tree = NfaBuilder.join_subtree(tree, transition.name()) 199 tree = NfaBuilder.join_subtree(tree, transition.name())
202 # store tree 200 # store tree
203 rules['trees'].append(tree) 201 rules['trees'].append(tree)
204 202
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 # process all subgraphs 400 # process all subgraphs
403 for tree_name, v in parser_state.rules.items(): 401 for tree_name, v in parser_state.rules.items():
404 assert v['trees'], "lexer state %s is empty" % tree_name 402 assert v['trees'], "lexer state %s is empty" % tree_name
405 rule_map[tree_name] = NfaBuilder.or_terms(v['trees']) 403 rule_map[tree_name] = NfaBuilder.or_terms(v['trees'])
406 # build the automata 404 # build the automata
407 for name, tree in rule_map.items(): 405 for name, tree in rule_map.items():
408 self.__automata[name] = RuleProcessor.Automata( 406 self.__automata[name] = RuleProcessor.Automata(
409 parser_state.encoding, parser_state.character_classes, rule_map, name) 407 parser_state.encoding, parser_state.character_classes, rule_map, name)
410 # process default_action 408 # process default_action
411 default_action = parser_state.rules['default']['default_action'] 409 default_action = parser_state.rules['default']['default_action']
412 self.__default_action = Action(Term.empty_term(), default_action) 410 self.__default_action = Action(default_action, 0)
OLDNEW
« no previous file with comments | « tools/lexer_generator/regex_parser.py ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698