commit ff1930a80bcd28f0273e053e9b981d840f6b3cff
parent f49504fa77710aaef3b063275b262ec8b2db73ac
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 29 Oct 2013 17:30:52 +0100
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.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/decl.c b/decl.c
@@ -149,12 +149,11 @@ enumdcl(struct ctype *base)
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;