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

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

Issue 78153002: Experimental parser: remove some dead code (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/nfa_builder.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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 action = Action(entry_action, match_action, precedence) 299 action = Action(entry_action, match_action, precedence)
300 graph = NfaBuilder.add_action(graph, action) 300 graph = NfaBuilder.add_action(graph, action)
301 if not transition: 301 if not transition:
302 pass 302 pass
303 elif transition == 'continue': 303 elif transition == 'continue':
304 assert not subgraph == 'default' 304 assert not subgraph == 'default'
305 continues += 1 305 continues += 1
306 graph = NfaBuilder.add_continue(graph) 306 graph = NfaBuilder.add_continue(graph)
307 else: 307 else:
308 assert subgraph == 'default' 308 assert subgraph == 'default'
309 subgraph_modifier = None
310 graph = NfaBuilder.join_subgraph( 309 graph = NfaBuilder.join_subgraph(
311 graph, transition, rule_map[transition], subgraph_modifier) 310 graph, transition, rule_map[transition])
312 graphs.append(graph) 311 graphs.append(graph)
313 if continues == len(graphs): 312 if continues == len(graphs):
314 graphs.append(NfaBuilder.epsilon()) 313 graphs.append(NfaBuilder.epsilon())
315 if v['catch_all']: 314 if v['catch_all']:
316 (precedence, catch_all) = v['catch_all'] 315 (precedence, catch_all) = v['catch_all']
317 assert catch_all == (None, None, 'continue'), "unimplemented" 316 assert catch_all == (None, None, 'continue'), "unimplemented"
318 graphs.append(NfaBuilder.add_continue(NfaBuilder.catch_all())) 317 graphs.append(NfaBuilder.add_continue(NfaBuilder.catch_all()))
319 graph = NfaBuilder.or_graphs(graphs) 318 graph = NfaBuilder.or_graphs(graphs)
320 rule_map[subgraph] = graph 319 rule_map[subgraph] = graph
321 # process first the subgraphs, then the default graph 320 # process first the subgraphs, then the default graph
322 for k, v in parser_state.rules.items(): 321 for k, v in parser_state.rules.items():
323 if k == 'default': continue 322 if k == 'default': continue
324 process(k, v) 323 process(k, v)
325 process('default', parser_state.rules['default']) 324 process('default', parser_state.rules['default'])
326 # build the automata 325 # build the automata
327 for rule_name, graph in rule_map.items(): 326 for rule_name, graph in rule_map.items():
328 self.__automata[rule_name] = RuleProcessor.Automata(builder, graph) 327 self.__automata[rule_name] = RuleProcessor.Automata(builder, graph)
329 # process default_action 328 # process default_action
330 default_action = parser_state.rules['default']['default_action'] 329 default_action = parser_state.rules['default']['default_action']
331 self.default_action = Action(None, default_action[1]) if default_action else None 330 self.default_action = Action(None, default_action[1]) if default_action else None
OLDNEW
« no previous file with comments | « tools/lexer_generator/nfa_builder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698