Lines Matching refs:self

30     def __init__(self, file_name, token_type, value):
31 self.token_type = token_type
32 self.value = value
33 self.row = 1
34 self.col = 1
35 self.file_name = file_name
37 def clean(self):
38 self.token_type = TokenType.UNKNOWN
39 self.value = ""
40 self.row = 1
41 self.col = 1
43 def dump(self):
44 return "<{}:{}:{}: {},'{}'>".format(self.file_name, self.row, self.col,
45 self.token_type, self.value)
47 def info(self):
48 return "{}:{}:{}".format(self.file_name, self.row, self.col)
52 def __init__(self, is_eof, char):
53 self.is_eof = is_eof
54 self.char = char
56 def dump(self):
57 return "{%s, %s}" % (self.is_eof, self.char)
61 def __init__(self, idl_file_path):
62 self.have_peek = False
65 self.data = file_info
66 self.data_len = len(self.data)
67 self.read_index = 0
68 self.cur_token = Token(os.path.basename(idl_file_path),
70 self.cur_row = 1
71 self.cur_col = 1
73 def peek_char(self, peek_count=0):
74 index = self.read_index + peek_count
75 if index >= self.data_len:
77 return Char(False, self.data[index])
79 def get_char(self):
80 if self.read_index >= self.data_len:
82 read_index = self.read_index
83 self.read_index += 1
84 if self.data[read_index] == '\n':
85 self.cur_row += 1
86 self.cur_col = 1
88 self.cur_col += 1
89 return Char(False, self.data[read_index])
91 def peek_token(self):
92 if not self.have_peek:
93 self.read_token()
94 self.have_peek = True
95 return self.cur_token
97 def get_token(self):
98 if not self.have_peek:
99 self.read_token()
100 self.have_peek = False
101 return self.cur_token
103 def read_token(self):
104 self.cur_token.clean()
105 while not self.peek_char().is_eof:
106 new_char = self.peek_char()
108 self.get_char()
110 self.cur_token.row = self.cur_row
111 self.cur_token.col = self.cur_col
113 self.read_include()
116 self.read_string()
119 self.read_comment()
121 self.cur_token.value = new_char.char
122 self.cur_token.token_type = TokenType.UNKNOWN
123 self.get_char()
125 self.cur_token.token_type = TokenType.END_OF_FILE
127 def read_include(self):
129 token_value.append(self.get_char().char)
130 while not self.peek_char().is_eof:
131 new_char = self.peek_char()
134 self.get_char()
139 self.cur_token.token_type = TokenType.INCLUDE
141 self.cur_token.token_type = TokenType.UNKNOWN
142 self.cur_token.value = key_str
144 def read_string(self):
146 self.get_char()
147 while not self.peek_char().is_eof and self.peek_char().char != '"':
148 token_value.append(self.get_char().char)
150 if self.peek_char().char == '"':
151 self.cur_token.token_type = TokenType.STRING
152 self.get_char()
154 self.cur_token.token_type = TokenType.UNKNOWN
155 self.cur_token.value = "".join(token_value)
157 def read_comment(self):
159 token_value.append(self.get_char().char)
160 new_char = self.peek_char()
163 self.read_line_comment(token_value)
166 self.read_block_comment(token_value)
168 self.cur_token.token_type = TokenType.UNKNOWN
169 self.cur_token.value = "".join(token_value)
171 def read_line_comment(self, token_value):
172 token_value.append(self.get_char().char)
173 while not self.peek_char().is_eof:
174 new_char = self.get_char()
178 self.cur_token.token_type = TokenType.COMMENT
179 self.cur_token.value = "".join(token_value)
181 def read_block_comment(self, token_value):
183 token_value.append(self.get_char().char)
184 while not self.peek_char().is_eof:
185 new_char = self.get_char()
187 if new_char.char == '*' and self.peek_char().char == '/':
188 token_value.append(self.get_char().char)
192 self.cur_token.token_type = TokenType.COMMENT
194 self.cur_token.token_type = TokenType.UNKNOWN
195 self.cur_token.value = value
199 def __init__(self):
200 self.all_hcs_files = set()
201 self.src_queue = Queue()
204 def get_hcs_info(self):
206 all_hcs_files_list = sorted(list(self.all_hcs_files))
211 def parse(self, root_hcs_file):
214 self.src_queue.put(os.path.abspath(root_hcs_file))
215 while not self.src_queue.empty():
216 cur_hcs_file = self.src_queue.get()
217 self.all_hcs_files.add(cur_hcs_file)
218 self.parse_one(cur_hcs_file)
220 def parse_one(self, cur_hcs_file_path):
226 self.parse_include(lex, hcs_file_dir)
230 def parse_include(self, lex, hcs_file_dir):
238 self.src_queue.put(os.path.abspath(hcs_file_path))