comparison lwcc/lex.c @ 300:8d6c47395653 ccdev

Implemented #include and #line Theoretically, directives are now implemented.
author William Astle <lost@l-w.ca>
date Sun, 15 Sep 2013 13:49:00 -0600
parents 856caf91ffaa
children d85d173ba120
comparison
equal deleted inserted replaced
299:856caf91ffaa 300:8d6c47395653
289 if (c == CPP_EOL) 289 if (c == CPP_EOL)
290 { 290 {
291 pp -> eolseen = 1; 291 pp -> eolseen = 1;
292 return c; 292 return c;
293 } 293 }
294 294
295 pp -> eolseen = 0; 295 pp -> eolseen = 0;
296 296
297 /* convert comments to a single space here */ 297 /* convert comments to a single space here */
298 if (c == '/') 298 if (c == '/')
299 { 299 {
349 int ttype = TOK_NONE; 349 int ttype = TOK_NONE;
350 int c, c2; 350 int c, c2;
351 int cl; 351 int cl;
352 struct strbuf *strbuf; 352 struct strbuf *strbuf;
353 struct token *t; 353 struct token *t;
354 354 struct preproc_info *fs;
355
356 fileagain:
355 c = preproc_lex_fetch_byte(pp); 357 c = preproc_lex_fetch_byte(pp);
356 if (c == CPP_EOF) 358 if (c == CPP_EOF)
357 { 359 {
358 if (pp -> nlseen == 0) 360 if (pp -> nlseen == 0)
359 { 361 {
361 } 363 }
362 } 364 }
363 365
364 if (c == CPP_EOF) 366 if (c == CPP_EOF)
365 { 367 {
366 ttype = TOK_EOF; 368 /* check if we fell off the end of an include file */
367 goto out; 369 if (pp -> filestack)
370 {
371 if (pp -> skip_level || pp -> found_level)
372 {
373 preproc_throw_error(pp, "Unbalanced conditionals in include file");
374 }
375 fclose(pp -> fp);
376 fs = pp -> filestack;
377 *pp = *fs;
378 pp -> filestack = fs -> n;
379 goto fileagain;
380 }
381 else
382 {
383 ttype = TOK_EOF;
384 goto out;
385 }
368 } 386 }
369 if (c == CPP_EOL) 387 if (c == CPP_EOL)
370 { 388 {
371 pp -> nlseen = 1; 389 pp -> nlseen = 1;
372 ttype = TOK_EOL; 390 ttype = TOK_EOL;