On Wed, 9 Dec 2009, Levo wrote:
> I found a bug using bison 2.4.1, i cant think of a work around or a solution.
>
> In my lex file
>
> [0-9]+ { return INTEGER; }
>
> in my test.y file
>
> ValLiteral:
> INTEGER
> { $$ = strdup(yytext); printf("Is this a int? %s\n",
> yytext); }
>
> INTEGER is ONLY use in ValLiteral. In my .y file i searched { $$ and replace
> with //{ $$. I then removed the comment for only the rule above. My output
> shows
>
> Is this a int? 5
> Is this a int? ,
yytext is the text of the last token scanned.
You seem to expect yytext to be the text for $1. Even without GLR, that's
not always true because, depending on your grammar, there might be a
lookahead. With GLR, it's especially difficult to predict when it's true
because some parser actions are deferred until after the scanner has
recognized many more tokens.
I recommend you make your scanner store yytext in yylval. In your parser
actions, you should then use $1. See the Bison manual for details on how
to do this.
> I wont go into more details unless
> someone would like to correct the bug. I prefer not to publicly post my
> files so email me if your interested in correcting the bug.
I'm afraid I don't have time to debug it, but hopefully the above hints
will help.