[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
error: else without a previous if
From: |
tys lefering |
Subject: |
error: else without a previous if |
Date: |
Wed, 13 Jan 2010 20:59:35 +0100 |
User-agent: |
SquirrelMail/1.4.18 |
Hi,
when updating today bison, gnulib and autoconf from git repo
and installing bison the generated yacc parser does not compile
with this error when using gcc or g++:
y.tab.c: In function yyparse:
y.tab.c:5998: error: else without a previous if
used the YYERROR_VERBOSE in the parser code like this:
/* let parser print verbose error message at parse error */
#define YYERROR_VERBOSE 1
source code part of the parser is here
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (YY_("syntax error"));
#else
while (1)
{
int yysyntax_error_status =
yysyntax_error (&yymsg_alloc, &yymsg, yystate, yytoken);
if (yysyntax_error_status == 2 && 0 < yymsg_alloc)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (yymsg)
continue;
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
}
if (yysyntax_error_status == 0)
yyerror (yymsg);
else /* <-- y.tab.c:5998: error: else without a previous if*/
yyerror (YY_("syntax error"));
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
break;
}
#endif
}
version from bison git:
bison (GNU Bison) 2.4.464-fca9c-dirty
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc version:
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
the generated bison parser looks good to me but gcc does not want it.
when changing parser code to this adding '{' and '}' gcc / g++ does accept
it:
if (yysyntax_error_status == 0) {
yyerror (yymsg);
} else {
yyerror (YY_("syntax error"));
}
any solution ? maybe add the '{' '}' in the yacc parser code ?
y.tab.c
Description: Text Data
- error: else without a previous if,
tys lefering <=