scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit f883b8ec98db46ad0d718ab8618fcafe39ec6278
parent 07371e86ec98830a211e87ef6d0dc7516e7da9b0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 15 May 2014 14:35:21 +0200

Remove unused forbid_eof

This varaible was not used at all, and it is not the correct way
of handling this problem. This solution is not enough good,
and it can cause the program stop forever waiting for a character

Diffstat:
cc1/decl.c | 4----
cc1/lex.c | 7++-----
2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -10,8 +10,6 @@ #define ID_EXPECTED 1 #define ID_ACCEPTED 2 -int8_t forbid_eof; - struct dcldata { uint8_t op; union { @@ -466,8 +464,6 @@ extdecl(void) Symbol *sym; char *err; - forbid_eof = 0; /* TODO: Fix when find EOF */ - switch (yytoken) { case IDEN: case TYPE: case SCLASS: case TQUALIFIER: base = specifier(&sclass); diff --git a/cc1/lex.c b/cc1/lex.c @@ -378,15 +378,11 @@ uint8_t next(void) { static int c; - extern int8_t forbid_eof; strcpy(yytext, yybuf); yylval = yynlval; - if ((yytoken = yyntoken) == EOFTOK) { - if (forbid_eof) - error("Find EOF while parsing"); + if ((yytoken = yyntoken) == EOFTOK) goto ret; - } while (isspace(c = getc(yyin))) { if (c == '\n') @@ -394,6 +390,7 @@ next(void) } if (c == EOF) { + strcpy(yybuf, "EOF"); yyntoken = EOFTOK; goto ret; }