Related articles |
---|
defined YYERROR_VERBOSE, but still got only "parse error" s_gherman@yahoo.com (2001-09-03) |
Re: defined YYERROR_VERBOSE, but still got only "parse error" genew@mail.ocis.net (2001-09-05) |
Re: defined YYERROR_VERBOSE, but still got only "parse error" s_gherman@yahoo.com (2001-09-16) |
From: | s_gherman@yahoo.com (Sorin Gherman) |
Newsgroups: | comp.compilers |
Date: | 16 Sep 2001 00:32:44 -0400 |
Organization: | http://groups.google.com/ |
References: | 01-09-010 01-09-018 |
Keywords: | yacc, question |
Posted-Date: | 16 Sep 2001 00:32:44 EDT |
> s_gherman@yahoo.com (Sorin Gherman) wrote:
>
...
> >I've looked into the code that actully generates the error message:
> >if (count < 5)
> >{
> > count = 0;
> > for (x = (yyn < 0 ? -yyn : 0);
> > x < (sizeof(yytname) / sizeof(char *)); x++)
> > if (yycheck[x + yyn] == x)
> > {
> > strcat(msg, count == 0 ? ", expecting `" : " or `");
> > strcat(msg, yytname[x]);
> > strcat(msg, "'");
> > count++;
> > }
> >}
> >
> >
> >and found out that count == 5 from the beginning; replacing
> >if (count < 5)
> >with
> >if (1)
> >resulted in an informative error message ("expected" ... "or" ...).
> >
> >What's the problem? Do I need to set up other variables as well, or
> >what?
>
> 5 isn't less than 5.
>
> If count==5, then count<5 is FALSE. You changed the semantics.
>
> Sincerely,
>
> Gene Wirchenko
Well, that was exactly the purpose of my experiment, to change the
semantics and force it to go into that piece of code. Now I realized
that the reason I didn't get the "expected..." part of the error
message was that there were too many alternatives for Yacc at the
point of the error, and the constant 5 is there exactly to prevent
reporting that when more than 5 possible alternative exist.
Thanks anyway,
Sorin Gherman
Return to the
comp.compilers page.
Search the
comp.compilers archives again.