help-bison
[Top][All Lists]
Advanced

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

Re: %left


From: Chris verBurg
Subject: Re: %left
Date: Fri, 6 Aug 2010 16:47:46 -0700

On Fri, Aug 6, 2010 at 5:17 AM, Sasan Forghani <address@hidden>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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]