src/lexer_scanner.cc

changeset 82
841562f5a32f
parent 79
2425fa6a4f21
child 85
264a61e9eba0
equal deleted inserted replaced
81:071715c17296 82:841562f5a32f
75 "const", 75 "const",
76 "default", 76 "default",
77 "do", 77 "do",
78 "else", 78 "else",
79 "event", 79 "event",
80 "eventdef",
80 "for", 81 "for",
82 "funcdef",
81 "goto", 83 "goto",
82 "if", 84 "if",
83 "int", 85 "int",
84 "mainloop", 86 "mainloop",
85 "onenter", 87 "onenter",
192 m_ptr++; 194 m_ptr++;
193 195
194 while (*m_ptr != '\"') 196 while (*m_ptr != '\"')
195 { 197 {
196 if (!*m_ptr) 198 if (!*m_ptr)
197 return false; 199 error ("unterminated string");
198 200
199 if (check_string ("\\n")) 201 if (check_string ("\\n"))
200 { 202 {
201 m_token_text += '\n'; 203 m_token_text += '\n';
202 continue; 204 continue;
214 216
215 m_token_text += *m_ptr++; 217 m_token_text += *m_ptr++;
216 } 218 }
217 219
218 m_token_type = tk_string; 220 m_token_type = tk_string;
219 m_ptr++; // skip the final quote 221 skip(); // skip the final quote
220 return true; 222 return true;
221 } 223 }
222 224
223 if (isdigit (*m_ptr)) 225 if (isdigit (*m_ptr))
224 { 226 {
231 233
232 if (is_symbol_char (*m_ptr, false)) 234 if (is_symbol_char (*m_ptr, false))
233 { 235 {
234 m_token_type = tk_symbol; 236 m_token_type = tk_symbol;
235 237
236 while (m_ptr != '\0') 238 do
237 { 239 {
238 if (!is_symbol_char (*m_ptr, true)) 240 if (!is_symbol_char (*m_ptr, true))
239 break; 241 break;
240 242
241 m_token_text += *m_ptr++; 243 m_token_text += *m_ptr++;
242 } 244 } while (*m_ptr != '\0');
243 245
244 return true; 246 return true;
245 } 247 }
246 248
247 error ("unknown character \"%1\"", *m_ptr); 249 error ("unknown character \"%1\"", *m_ptr);
274 string lexer_scanner::get_token_string (e_token a) 276 string lexer_scanner::get_token_string (e_token a)
275 { 277 {
276 assert ((int) a <= tk_last_named_token); 278 assert ((int) a <= tk_last_named_token);
277 return g_token_strings[a]; 279 return g_token_strings[a];
278 } 280 }
281
282 // =============================================================================
283 //
284 string lexer_scanner::read_line()
285 {
286 string line;
287
288 while (*m_ptr != '\n')
289 line += *(m_ptr++);
290
291 return line;
292 }

mercurial