Re: defined YYERROR_VERBOSE, but still got only "parse error"

genew@mail.ocis.net (Gene Wirchenko)
5 Sep 2001 22:11:04 -0400

          From comp.compilers

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)
| List of all articles for this month |

From: genew@mail.ocis.net (Gene Wirchenko)
Newsgroups: comp.compilers
Date: 5 Sep 2001 22:11:04 -0400
Organization: Posted via Supernews, http://www.supernews.com
References: 01-09-010
Keywords: errors
Posted-Date: 05 Sep 2001 22:11:04 EDT

s_gherman@yahoo.com (Sorin Gherman) wrote:


>Hi,
>This is my first time using Bison and I run into the following
>problem: I defined YYERROR_VERBOSE (and confirmed it is defined into
>the generated .c file by inserting a printf there) but I still got
>only the usual "parse error" message when an error occurs.
>
>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


Computerese Irregular Verb Conjugation:
          I have preferences.
          You have biases.
          He/She has prejudices.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.