[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in Yacc or Metal ?




Bad news: this is a disturbing BUG we already knew about. It doesn't lie in
lex nor in yacc but in the way we build the tree using yacc action. We are
fooled when yacc does a look-ahead because the call to lex overwrites the
last read token string.

One way to get around it is to use a case construction as you suggest.
Another way is to do the look-ahead in lex:

[a-zA-Z][a-zA-Z0-9_]*			{                return(VARID); }
[a-zA-Z][a-zA-Z0-9_]*[ \t\n]*(		{ clean(yytext); return(ID)   ; }

Then define clean as a C function that unputs (see lex function unput(char))
the "(" and the blanks, and clears them in yytext. ID and VARID have now the
same lex description but are chosen according to the context.

The bug is in our things-to-do list. Tough, it might not be corrected in the
next (imminent) release.