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

Side by Side Diff: tools/lexer_generator/nfa.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 | « no previous file | tools/lexer_generator/nfa_builder.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 def set_action(self, action): 55 def set_action(self, action):
56 assert not self.is_closed() 56 assert not self.is_closed()
57 assert not self.__action 57 assert not self.__action
58 self.__action = action 58 self.__action = action
59 59
60 def transitions(self): 60 def transitions(self):
61 assert self.is_closed() 61 assert self.is_closed()
62 return self.__transitions 62 return self.__transitions
63 63
64 def next_states(self, key_filter):
65 assert self.is_closed()
66 f = lambda acc, (k, v) : acc if not key_filter(k) else acc | set(v)
67 return reduce(f, self.__transitions.items(), set())
68
69 def __add_transition(self, key, next_state): 64 def __add_transition(self, key, next_state):
70 if next_state == None: 65 if next_state == None:
71 assert not self.is_closed(), "already closed" 66 assert not self.is_closed(), "already closed"
72 self.__unclosed.add(key) 67 self.__unclosed.add(key)
73 return 68 return
74 if not key in self.__transitions: 69 if not key in self.__transitions:
75 self.__transitions[key] = set() 70 self.__transitions[key] = set()
76 self.__transitions[key].add(next_state) 71 self.__transitions[key].add(next_state)
77 72
78 def add_unclosed_transition(self, key): 73 def add_unclosed_transition(self, key):
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 f = lambda state: state.transition_state_iter_for_key(key) 147 f = lambda state: state.transition_state_iter_for_key(key)
153 match_states |= set(chain(*map(f, nfa_state_set))) 148 match_states |= set(chain(*map(f, nfa_state_set)))
154 transition_state = Nfa.__to_dfa(match_states, dfa_nodes, end_node) 149 transition_state = Nfa.__to_dfa(match_states, dfa_nodes, end_node)
155 dfa_nodes[name]['transitions'][key] = transition_state 150 dfa_nodes[name]['transitions'][key] = transition_state
156 return name 151 return name
157 152
158 def compute_dfa(self): 153 def compute_dfa(self):
159 dfa_nodes = {} 154 dfa_nodes = {}
160 start_name = self.__to_dfa(set([self.__start]), dfa_nodes, self.__end) 155 start_name = self.__to_dfa(set([self.__start]), dfa_nodes, self.__end)
161 return (start_name, dfa_nodes) 156 return (start_name, dfa_nodes)
OLDNEW
« no previous file with comments | « no previous file | tools/lexer_generator/nfa_builder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698