Reputation: 28407
If I set a breakpoint in a Bison .y file, is there a way I can inspect the contents of $$ pseudo variable at that breakpoint?
Upvotes: 2
Views: 1404
Reputation: 9330
I redefined the type of yylval
with %union
:
%union {
int int_val;
double double_val;
}
And what I get is either yyval.int_val
or yyval.double_val
depending on the type of $$
.
But just as Richard Pennington said, the best way would be to look at the generated .tab.c
code.
Upvotes: 0
Reputation: 146073
Bison keeps the stacks as local variables in yyparse()
, dynamically allocated.
Probably the easiest way to solve a temporary debugging issue is to patch y.tab.c
so that the line *++yyvsp = yylval
also drops a copy in a global. You may also want to hack YYPOPSTACK()
to do the same thing.
Upvotes: 2
Reputation: 19965
$$ is be the top of the semantic value stack. It may be a little difficult to interpret. If you really need to, the stack pointer might be called yyssp and the stack might be called yyvsa, so something like yyvsa[yyssp] might give you what you want, depending on the version of bison you're using. Look at .tab.c code that was generated.
Upvotes: 5