[Top][All Lists]

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

Re: Bug Using GLR parser. Symptom is an occasional incorrect pattern mat

From: Joel E. Denny
Subject: Re: Bug Using GLR parser. Symptom is an occasional incorrect pattern match
Date: Wed, 9 Dec 2009 15:36:39 -0500 (EST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

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.

reply via email to

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