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

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

Issue 82803003: Experimental parser: add utf8 encoding (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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/dfa.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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 __add_transition(self, key, next_state): 64 def __add_transition(self, key, next_state):
65 assert key != None
65 if next_state == None: 66 if next_state == None:
66 assert not self.is_closed(), "already closed" 67 assert not self.is_closed(), "already closed"
67 self.__unclosed.add(key) 68 self.__unclosed.add(key)
68 return 69 return
69 if not key in self.__transitions: 70 if not key in self.__transitions:
70 self.__transitions[key] = set() 71 self.__transitions[key] = set()
71 self.__transitions[key].add(next_state) 72 self.__transitions[key].add(next_state)
72 73
73 def add_unclosed_transition(self, key): 74 def add_unclosed_transition(self, key):
74 assert key != TransitionKey.epsilon() 75 assert key != TransitionKey.epsilon()
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 f = lambda state: state.transition_state_iter_for_key(key) 147 f = lambda state: state.transition_state_iter_for_key(key)
147 match_states |= set(chain(*map(f, nfa_state_set))) 148 match_states |= set(chain(*map(f, nfa_state_set)))
148 transition_state = self.__to_dfa(match_states, dfa_nodes, end_node) 149 transition_state = self.__to_dfa(match_states, dfa_nodes, end_node)
149 dfa_nodes[name]['transitions'][key] = transition_state 150 dfa_nodes[name]['transitions'][key] = transition_state
150 return name 151 return name
151 152
152 def compute_dfa(self): 153 def compute_dfa(self):
153 dfa_nodes = {} 154 dfa_nodes = {}
154 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)
155 return (start_name, dfa_nodes) 156 return (start_name, dfa_nodes)
OLDNEW
« no previous file with comments | « tools/lexer_generator/dfa.py ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698