ref: ff1930a80bcd28f0273e053e9b981d840f6b3cff
parent: f49504fa77710aaef3b063275b262ec8b2db73ac
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Oct 29 13:30:52 EDT 2013
Fix enumeration declarer After an expect(IDEN) we can not trust the content of yytext, because it will be the string of the next token. We have to check that yytoken is equal to IDEN with an '==', and it is not necessary check against '}' because this test is done after the loop.
--- a/decl.c
+++ b/decl.c
@@ -149,12 +149,11 @@
register struct symbol *sym;
register struct ctype *tp = ctype(NULL, INT);
- if (yytoken == '}')
+ if (yytoken != IDEN)
break;
-
- expect(IDEN);
sym = lookup(yytext, NS_IDEN);
sym->ctype = tp;
+ next();
if (accept('=')) {
expect(CONSTANT);
val = yyval->i;