Related articles |
---|
Bug in YACC discovered? wsineel@lso.win.tue.nl (1990-03-06) |
From: | wsineel@lso.win.tue.nl (e.vriezekolk) |
Newsgroups: | comp.compilers |
Date: | 6 Mar 90 09:23:48 GMT |
Organization: | Eindhoven University of Technology, The Netherlands |
Keywords: | yacc,question |
I offered someone to write a (small) compiler to be included
in his program. I use YACC, but I run into a strange problem.
My YACC-rules are mostly of the form:
nonterminal: A_TOKEN
{if (!some_test($1))
report("user friendly error message");
}
ANOTHER_TOKEN
{if (!another_test($3))
report("user friendly error message");
}
YET_ANOTHER_TOKEN AND_ANOTHER
{if (!still_more_tests($5,$6))
report("user friendly error message");
}
LAST_TOKEN
{final_actions();}
;
(Tab size is 4..., sorry);
The problem is that in the "final_actions" part, the value of
$1 is somehow overwritten. I encountered this in two different
places. Even if I write a rule like:
nonterm: TOKEN1
{printf($1);}
TOKEN2 TOKEN3 TOKEN4 TOKEN5
{printf($1);}
;
Now two different values are printed!
There is a lot of C-code between the tokens in my rules, but
this shouldn't change the $x values, does it?
Any ideas about what YACC thinks of this are welcome...
Eelco Vriezekolk
wsineel@lso.win.tue.nl
Return to the
comp.compilers page.
Search the
comp.compilers archives again.