On Fri, Aug 6, 2010 at 5:17 AM, Sasan Forghani <sasanforgh...@gmail.com>wrote:

>
> ..
> expr : expr BL_ADDOP expr
> ...
>    char bufferT[6];
> ...
>    $<blIdentifier>$ = bufferT;
>

$<blIdentifier>$ is a char* isn't it?  In which case this assigns it to the
temporary bufferT, which is going to get wiped out as soon as it goes out of
scope.

Maybe use strdup?  "$<blIdentifier>$ = strdup(bufferT);" ?


...
> | '(' expr ')'
>  {
>    printf("This is the value of $<blIdentifier>$ at ( expr ): %s\n",
> $<blIdentifier>$);
>

At this point, you haven't assigned to $$.


...
> ref_name : BL_IDENTIFIER
> ...
>    char varLocation[7];
> ...
>    $<blIdentifier>$ = varLocation;
>

Another place where the buffer will go out of scope and wipe out $$. (strdup
again?)

Are you still a bit confused about how the $ variables work?  And/or how
bison rules have associated values?

-Chris
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
  • %left Sasan Forghani
    • Re: %left Chris verBurg

Reply via email to