ref: f883b8ec98db46ad0d718ab8618fcafe39ec6278
parent: 07371e86ec98830a211e87ef6d0dc7516e7da9b0
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu May 15 10:35:21 EDT 2014
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
--- 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 {
@@ -465,8 +463,6 @@
int8_t sclass;
Symbol *sym;
char *err;
-
- forbid_eof = 0; /* TODO: Fix when find EOF */
switch (yytoken) {
case IDEN: case TYPE: case SCLASS: case TQUALIFIER:
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -378,15 +378,11 @@
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 @@
}
if (c == EOF) {
+ strcpy(yybuf, "EOF");
yyntoken = EOFTOK;
goto ret;
}