scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 24738fc266c6aefd6f9cdd21cdcd28e7757020bf
parent 6ef69d3ee0b835e5aad1532e946977035de9c405
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  7 May 2015 08:48:47 +0200

Remove STRING token

This token was totally useless because it is identical to CONSTANT.
This patch also fix the type of the string. because it was char* while
the correct type is an array of chars.

Diffstat:
Mcc1/cc1.h | 1-
Mcc1/expr.c | 3++-
Mcc1/lex.c | 4++--
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -130,7 +130,6 @@ enum tokens { SHL_EQ, SHR_EQ, ELLIPSIS, - STRING, /* TODO: remove this */ CASE, DEFAULT, IF, diff --git a/cc1/expr.c b/cc1/expr.c @@ -457,7 +457,8 @@ primary(void) Symbol *sym; switch (yytoken) { - case STRING: case CONSTANT: case IDEN: + case CONSTANT: + case IDEN: if ((sym = yylval.sym) == NULL) error("'%s' undeclared", yytext); np = symbol(yylval.sym); diff --git a/cc1/lex.c b/cc1/lex.c @@ -181,9 +181,9 @@ end_string: *bp = '\0'; sym = install("", NS_IDEN); sym->u.s = xstrdup(buf); - sym->type = mktype(chartype, PTR, 0, NULL); + sym->type = mktype(chartype, ARY, (bp - buf) + 1, NULL); yylval.sym = sym; - return STRING; + return CONSTANT; } static uint8_t