On 07/22/2010 01:55 PM, Akim Demaille wrote:
Le 21 juil. 2010 à 23:15, Panayiotis Karabassis a écrit :

Hi!


Well, it turns out it was a missing YYSTYPE definition from the parser file. 
Thus defaulting to int and having yystate accidentally overwritten on updating 
yylval. A difficult bug.

I might be missing something, but I don't understand how this would be 
possible.  How was that happening?
The parser incorrectly thought that yylval was of type int (the default).
The correct type (ASTNode *) was known to the scanner.

The scanner has a line to set yylval to NULL. Apparently yystate follows yylval in memory.

So whenever the lex function was called yylval was set to NULL.
This had the side effect of also setting yystate to 0, because the parser had reserved memory for yylval as sizeof(int) instead of sizeof(ASTNode *).

Thus each time lex was called yystate was set to 0. Which produced the erroneous behavior.

Making the YYSTYPE definition available to the parser caused it to reserve the correct amount of memory for yylval (sizeof(ASTNode *)) thus solving the problem.

I hope I explained it (and understand it) well enough.

Regards,
    Panayiotis

_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to