help-bison
[Top][All Lists]
Advanced

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

RE: bison puts too many tokens in the semantic value


From: Richard Garand
Subject: RE: bison puts too many tokens in the semantic value
Date: Sun, 4 Mar 2001 10:22:52 +0100

[Please keep cc to Bison Help.]

Is there any way to get around this problem? I thought it was possible to
access tokens in the middle of a rule from an action at the end.

Richard Garand
address@hidden
ICQ: 12190132
"The original, complete, and unadulterated Descent! Play the game that
turned 3D action on its head and made it puke!" - CGW

> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Behalf Of Hans Aberg
> Sent: Saturday, March 03, 2001 6:02 PM
> To: Richard Garand
> Cc: address@hidden
> Subject: RE: bison puts too many tokens in the semantic value
>
> No, the problem isn't in Bison.
>
> What you do is that in the rule
>   foo: '"' NAME '"' { s; }
> when you get the $2 value, you hand over the yytext pointer (which points
> into the buffer that the Flex scanner uses), which is then temporarily \0
> terminated, and prints out nicely. After that you get the \" from the Flex
> scanner, so the latter puts back the \" (read the code that the Flex
> scanner writes!), and then hands over that position.
>
> After that the action "s;" is executed, and so the non-copied $2 is NAME
> plus the ", followed by the temporary \0 the Flex scanner puts in (as
> yytext is just into the buffer that the Flex scanner uses). That
> is, if the
> Flex scanner does not refill the buffer between reading the NAME and the "
> ...
>
>
>   Hans Aberg
>





reply via email to

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