Mercurial > hg > index.cgi
comparison lwcc/lex.c @ 299:856caf91ffaa ccdev
Added token list structure and switched some stuff to use it
Swithced to using a token list structure instead of manually fiddling
pointers throughout the macro expansion code. Also fixed up some problematic
things related to stringification and concatenation.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 15 Sep 2013 13:06:00 -0600 |
parents | 6112c67728ba |
children | 8d6c47395653 |
comparison
equal
deleted
inserted
replaced
298:6112c67728ba | 299:856caf91ffaa |
---|---|
594 c = preproc_lex_fetch_byte(pp); | 594 c = preproc_lex_fetch_byte(pp); |
595 if (c == CPP_EOF || c == CPP_EOL) | 595 if (c == CPP_EOF || c == CPP_EOL) |
596 { | 596 { |
597 if (!pp -> lexstr) | 597 if (!pp -> lexstr) |
598 preproc_throw_error(pp, "Invalid character constant"); | 598 preproc_throw_error(pp, "Invalid character constant"); |
599 break; | 599 ttype = TOK_ERROR; |
600 strval = strbuf_end(strbuf); | |
601 goto out; | |
600 } | 602 } |
601 cl++; | 603 cl++; |
602 strbuf_add(strbuf, c); | 604 strbuf_add(strbuf, c); |
603 continue; | 605 continue; |
604 } | 606 } |
605 strbuf_add(strbuf, c); | 607 strbuf_add(strbuf, c); |
606 } | 608 } |
607 if (cl == 0 && !pp -> lexstr) | |
608 preproc_throw_error(pp, "Invalid character constant"); | |
609 strval = strbuf_end(strbuf); | 609 strval = strbuf_end(strbuf); |
610 ttype = TOK_CHR_LIT; | 610 if (cl == 0) |
611 { | |
612 ttype = TOK_ERROR; | |
613 if (!pp -> lexstr) | |
614 preproc_throw_error(pp, "Invalid character constant"); | |
615 } | |
616 else | |
617 ttype = TOK_CHR_LIT; | |
611 goto out; | 618 goto out; |
612 | 619 |
613 case '"': | 620 case '"': |
614 strlit: | 621 strlit: |
615 /* string literal */ | 622 /* string literal */ |
616 strbuf = strbuf_new(); | 623 strbuf = strbuf_new(); |
617 for (;;) | 624 for (;;) |
618 { | 625 { |
619 c = preproc_lex_fetch_byte(pp); | 626 c = preproc_lex_fetch_byte(pp); |
620 if (c == CPP_EOF || c == CPP_EOL || c == '"') | 627 if (c == CPP_EOF || c == CPP_EOL) |
628 { | |
629 ttype = TOK_ERROR; | |
630 strval = strbuf_end(strbuf); | |
631 if (!pp -> lexstr) | |
632 preproc_throw_error(pp, "Invalid string constant"); | |
633 goto out; | |
634 } | |
635 if (c == '"') | |
621 break; | 636 break; |
622 if (c == '\\') | 637 if (c == '\\') |
623 { | 638 { |
624 strbuf_add(strbuf, '\\'); | 639 strbuf_add(strbuf, '\\'); |
625 c = preproc_lex_fetch_byte(pp); | 640 c = preproc_lex_fetch_byte(pp); |
626 if (c == CPP_EOF || c == CPP_EOL) | 641 if (c == CPP_EOF || c == CPP_EOL) |
627 { | 642 { |
643 ttype = TOK_ERROR; | |
628 if (!pp -> lexstr) | 644 if (!pp -> lexstr) |
629 preproc_throw_error(pp, "Invalid string constant"); | 645 preproc_throw_error(pp, "Invalid string constant"); |
630 break; | 646 strval = strbuf_end(strbuf); |
647 goto out; | |
631 } | 648 } |
632 cl++; | 649 cl++; |
633 strbuf_add(strbuf, c); | 650 strbuf_add(strbuf, c); |
634 continue; | 651 continue; |
635 } | 652 } |