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

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

Issue 152823002: Experimental parser: use sentinal values for 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/code_generator.py ('k') | tools/lexer_generator/dfa_optimizer.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 * 29 from automaton import *
30 from transition_keys import TransitionKey 30 from transition_keys import TransitionKey
31 31
32 class DfaState(AutomatonState): 32 class DfaState(AutomatonState):
33 33
34 def __init__(self, name, action): 34 def __init__(self, name, action):
35 super(DfaState, self).__init__() 35 super(DfaState, self).__init__()
36 self.__name = name 36 self.__name = name
37 self.__transitions = {} 37 self.__transitions = {}
38 self.__action = action 38 self.__action = action
39 assert isinstance(action, Action)
39 40
40 def transitions_to_multiple_states(self): 41 def transitions_to_multiple_states(self):
41 return False 42 return False
42 43
43 def name(self): 44 def name(self):
44 return self.__name 45 return self.__name
45 46
46 def action(self): 47 def action(self):
47 return self.__action 48 return self.__action
48 49
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 elif len(intersection) <= len(difference): 388 elif len(intersection) <= len(difference):
388 working_set.add(intersection) 389 working_set.add(intersection)
389 else: 390 else:
390 working_set.add(difference) 391 working_set.add(difference)
391 if old_partitions: 392 if old_partitions:
392 partitions -= old_partitions 393 partitions -= old_partitions
393 if new_partitions: 394 if new_partitions:
394 partitions |= new_partitions 395 partitions |= new_partitions
395 (start_name, mapping) = self.__create_states_from_partitions(partitions) 396 (start_name, mapping) = self.__create_states_from_partitions(partitions)
396 return Dfa(self.__dfa.encoding(), start_name, mapping) 397 return Dfa(self.__dfa.encoding(), start_name, mapping)
OLDNEW
« no previous file with comments | « tools/lexer_generator/code_generator.py ('k') | tools/lexer_generator/dfa_optimizer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698