bug-bison
[Top][All Lists]
Advanced

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

M4 problem for yacc.c parser.


From: A.Steenveld
Subject: M4 problem for yacc.c parser.
Date: Tue, 22 Jul 2008 11:24:58 +0200

When compiling the bison output based on skeleton yacc.c Microsoft Visual
Studio C/C++ complains "error C2449: found '{' at file scope (missing function
header?)" at file yy.yacc.c at line 885.

Removing a semicolon at line 882 corrects the problem.

The bit of code concerning this complaint runs as follows:
*** lines 864-886 from yy.yacc.c
/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM)
# else
int yyparse (YYPARSE_PARAM)
  void *YYPARSE_PARAM;
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int
yyparse (void)
#else
int
yyparse ()
    ;             /* <<<--- line 882 */
#endif
#endif
{                 /* <<<--- line 885 */
*** end lines 864-886 from yy.yacc.c

The direct problem is caused 3 lines above, line 882, by the single semicolon.

This semicolon is inserted by the M4 generator used on the skeleton file
yacc.c, in particular the macro's b4_c_knr_formal_decls, wich reads like

*** lines 268-279 from ...\GnuWin32\share\bison\c.m4
# b4_c_knr_formal_decls([DECL1, NAME1], ...)
# ------------------------------------------
# Output the K&R argument declarations.
m4_define([b4_c_knr_formal_decls],
[m4_map_sep([b4_c_knr_formal_decl],
            [
],
            address@hidden)])

m4_define([b4_c_knr_formal_decl],
[    $1;])

*** end lines 268-279 from ...\GnuWin32\share\bison\c.m4

These two macro's genereate the lines 880-882 in yy.yacc.c but when called
with an empty argument list it still closes the definition with a semicolon
changing the definition into a declaration and forcing the definition code
block to stand on its own.

I can reason out what is happening but I don't know M4 well enough. Who has
any suggestions to correct the M4 code?

Kind regards,

Andre Steenveld.

Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het 
handelsregister onder nummer 41055629.
The Radboud University Nijmegen Medical Centre is listed in the Commercial 
Register of the Chamber of Commerce under file number 41055629.






reply via email to

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