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: | 3 Sep 2001 22:57:43 -0400 |
Organization: | http://groups.google.com/ |
Keywords: | yacc, question |
Posted-Date: | 03 Sep 2001 22:57:43 EDT |
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?
Thanks in advance,
Sorin Gherman
Return to the
comp.compilers page.
Search the
comp.compilers archives again.