From 5f108727a13ff887f889948b2484724f14c125e9 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 2 Jul 2012 14:56:22 +0200 Subject: [PATCH 1/9] api.prefix: also rename YYDEBUG. The testsuite in master has shown weird errors for the "Mulitple Parsers" tests: the caller of p5.parse() received some apparently random value, while tracing p5.parse() showed that the function was consistently returning 0. It happens when mixing several parser headers, some generated without %debug, others with. In particular the C++ parser was generated with %debug, i.e., with: #ifndef YYDEBUG # define YYDEBUG 1 #endif and compiled separatedly. Yet, its header was included after the one of another parser, this time without %debug, i.e., with #ifndef YYDEBUG # define YYDEBUG 0 #endif in its header. As a result, the parser was compiled with YYDEBUG set, but its header was used without. Since the layout of the objects are then completely different, boom. Therefore, do not change the value of YYDEBUG. Rather, use it as a default value for DEBUG. * data/c.m4 (b4_YYDEBUG_define): New. (b4_declare_yydebug): Rename as... (b4_yydebug_declare): this, for consistency. * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it. * NEWS: Document it. --- NEWS | 17 +++++++++++++---- data/c.m4 | 28 +++++++++++++++++++++++----- data/glr.c | 22 +++++++++++----------- data/glr.cc | 13 +++++-------- data/lalr1.cc | 33 +++++++++++++++------------------ data/yacc.c | 18 +++++++++--------- 6 files changed, 76 insertions(+), 55 deletions(-) diff --git a/NEWS b/NEWS index 403265fa..ec4e33a5 100644 --- a/NEWS +++ b/NEWS @@ -94,10 +94,19 @@ GNU Bison NEWS # define BAR_FOO_H # define BAR_FOO_H /* Enabling traces. */ /* Enabling traces. */ - # ifndef YYDEBUG # ifndef YYDEBUG - # define YYDEBUG 0 # define YYDEBUG 0 - # endif # endif - # if YYDEBUG # if YYDEBUG + # ifndef YYDEBUG | # ifndef BAR_DEBUG + > # if defined YYDEBUG + > # if YYDEBUG + > # define BAR_DEBUG 1 + > # else + > # define BAR_DEBUG 0 + > # endif + > # else + # define YYDEBUG 0 | # define BAR_DEBUG 0 + > # endif + # endif | # endif + + # if YYDEBUG | # if BAR_DEBUG extern int bar_debug; extern int bar_debug; # endif # endif diff --git a/data/c.m4 b/data/c.m4 index 0b2699a1..3c6c6f4d 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -581,14 +581,32 @@ b4_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval; ]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl ]) +# b4_YYDEBUG_define +# ------------------ +m4_define([b4_YYDEBUG_define], +[[/* Enabling traces. */ +]m4_if(b4_api_prefix, [yy], +[[#ifndef YYDEBUG +# define YYDEBUG ]b4_debug_flag[ +#endif]], +[[#ifndef ]b4_api_PREFIX[DEBUG +# if defined YYDEBUG +# if YYDEBUG +# define ]b4_api_PREFIX[DEBUG 1 +# else +# define ]b4_api_PREFIX[DEBUG 0 +# endif +# else /* ! defined YYDEBUG */ +# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[ +# endif /* ! defined ]b4_api_PREFIX[DEBUG */ +#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl +]) + # b4_declare_yydebug # ------------------ m4_define([b4_declare_yydebug], -[[/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ -#endif -#if YYDEBUG +[b4_YYDEBUG_define[ +#if ]b4_api_PREFIX[DEBUG extern int ]b4_prefix[debug; #endif][]dnl ]) diff --git a/data/glr.c b/data/glr.c index ce611600..8dd21085 100644 --- a/data/glr.c +++ b/data/glr.c @@ -349,7 +349,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = ]b4_translate[ }; -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = @@ -370,7 +370,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ +#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -553,7 +553,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ while (YYID (0)) -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG # ifndef YYFPRINTF # define YYFPRINTF fprintf @@ -581,12 +581,12 @@ do { \ multiple parsers can coexist. */ int yydebug; -#else /* !YYDEBUG */ +#else /* !]b4_api_PREFIX[DEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) -#endif /* !YYDEBUG */ +#endif /* !]b4_api_PREFIX[DEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH @@ -825,7 +825,7 @@ yyMemoryExhausted (yyGLRStack* yystackp) YYLONGJMP (yystackp->yyexception_buffer, 2); } -#if YYDEBUG || YYERROR_VERBOSE +#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE /** A printable representation of TOKEN. */ static inline const char* yytokenName (yySymbol yytoken) @@ -962,7 +962,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[) &yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[); else { -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG if (yydebug) { if (yys->yysemantics.yyfirstVal) @@ -1391,7 +1391,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, } } -#if !YYDEBUG +#if !]b4_api_PREFIX[DEBUG # define YY_REDUCE_PRINT(Args) #else # define YY_REDUCE_PRINT(Args) \ @@ -1712,7 +1712,7 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, return yyflag; } -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG static void yyreportTree (yySemanticOption* yyx, int yyindent) { @@ -1767,7 +1767,7 @@ yyreportAmbiguity (yySemanticOption* yyx0, YYUSE (yyx0); YYUSE (yyx1); -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG YYFPRINTF (stderr, "Ambiguity detected.\n"); YYFPRINTF (stderr, "Option 1,\n"); yyreportTree (yyx0, 2); @@ -2551,7 +2551,7 @@ m4_popdef([b4_at_dollar])])dnl } /* DEBUGGING ONLY */ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG static void yypstack (yyGLRStack* yystackp, size_t yyk) __attribute__ ((__unused__)); static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__)); diff --git a/data/glr.cc b/data/glr.cc index d1eb6bd2..ce3951e2 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -127,7 +127,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl [ /// Build a parser object. ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ :])[ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false), yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[ #endif]b4_parse_param_cons[ @@ -144,7 +144,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl return ::yyparse (*this]b4_user_args[); } -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /*--------------------. | Print this symbol. | `--------------------*/ @@ -239,10 +239,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], ]b4_percent_define_ifdef([[location_type]], [], [[#include "location.hh"]])[ -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ -#endif +]b4_YYDEBUG_define[ /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends @@ -321,7 +318,7 @@ b4_user_stype virtual void error (const location_type& loc, const std::string& msg); private: -#if YYDEBUG +# if ]b4_api_PREFIX[DEBUG public: /// \brief Report a symbol value on the debug stream. /// \param yytype The token type. @@ -341,7 +338,7 @@ b4_user_stype /* Debugging. */ int yydebug_; std::ostream* yycdebug_; -#endif +# endif ]b4_parse_param_vars[ }; diff --git a/data/lalr1.cc b/data/lalr1.cc index 337af10a..afff0a51 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -57,10 +57,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], ]b4_null_define[ -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ -#endif +]b4_YYDEBUG_define[ ]b4_namespace_open[ @@ -100,7 +97,7 @@ b4_user_stype /// \returns 0 iff parsing succeeded. virtual int parse (); -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /// The current debugging stream. std::ostream& debug_stream () const; /// Set the current debugging stream. @@ -125,7 +122,7 @@ b4_user_stype /// \param tok the lookahead token. virtual std::string yysyntax_error_ (int yystate, int tok); -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /// \brief Report a symbol value on the debug stream. /// \param yytype The token type. /// \param yyvaluep Its semantic value. @@ -203,10 +200,10 @@ b4_user_stype /// Convert the symbol name \a n to a form suitable for a diagnostic. static std::string yytnamerr_ (const char *n);])[ -]b4_token_table_if([], [[#if YYDEBUG]])[ +]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[ /// For a symbol, its name in clear. static const char* const yytname_[]; -]b4_token_table_if([[#if YYDEBUG]])[ +]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ /// A type to store symbol numbers and -1. typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type; /// A `-1'-separated list of the rules' RHS. @@ -325,7 +322,7 @@ b4_percent_code_get[]dnl #define YYUSE(e) ((void) (e)) /* Enable debugging if requested. */ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /* A pseudo ostream that takes yydebug_ into account. */ # define YYCDEBUG if (yydebug_) (*yycdebug_) @@ -352,14 +349,14 @@ do { \ yystack_print_ (); \ } while (false) -#else /* !YYDEBUG */ +#else /* !]b4_api_PREFIX[DEBUG */ # define YYCDEBUG if (false) std::cerr # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_REDUCE_PRINT(Rule) # define YY_STACK_PRINT() -#endif /* !YYDEBUG */ +#endif /* !]b4_api_PREFIX[DEBUG */ #define yyerrok (yyerrstatus_ = 0) #define yyclearin (yychar = yyempty_) @@ -412,7 +409,7 @@ do { \ /// Build a parser object. ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ :])[ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false), yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[ #endif]b4_parse_param_cons[ @@ -423,7 +420,7 @@ do { \ { } -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ @@ -484,7 +481,7 @@ do { \ yylocation_stack_.pop (n); } -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG std::ostream& ]b4_parser_class_name[::debug_stream () const { @@ -1012,7 +1009,7 @@ b4_error_verbose_if([int yystate, int yytoken], ]b4_stos[ }; -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding to YYLEX-NUM. */ const ]b4_int_type_for([b4_toknum])[ @@ -1036,7 +1033,7 @@ b4_error_verbose_if([int yystate, int yytoken], ]b4_r2[ }; -]b4_token_table_if([], [[#if YYDEBUG]])[ +]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at \a yyntokens_, nonterminals. */ const char* @@ -1045,7 +1042,7 @@ b4_error_verbose_if([int yystate, int yytoken], ]b4_tname[ }; -]b4_token_table_if([[#if YYDEBUG]])[ +]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ /* YYRHS -- A `-1'-separated list of the rules' RHS. */ const ]b4_parser_class_name[::rhs_number_type ]b4_parser_class_name[::yyrhs_[] = @@ -1095,7 +1092,7 @@ b4_error_verbose_if([int yystate, int yytoken], &]b4_rhs_value(yynrhs, yyi + 1)[, &]b4_rhs_location(yynrhs, yyi + 1)[); } -#endif // YYDEBUG +#endif // ]b4_api_PREFIX[DEBUG /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ ]b4_parser_class_name[::token_number_type diff --git a/data/yacc.c b/data/yacc.c index 8c595f9a..3a679141 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -589,7 +589,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = ]b4_translate[ }; -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = @@ -610,7 +610,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ +#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -803,7 +803,7 @@ while (YYID (0)) #endif /* Enable debugging if requested. */ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ @@ -890,12 +890,12 @@ do { \ /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; -#else /* !YYDEBUG */ +#else /* !]b4_api_PREFIX[DEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ +#endif /* !]b4_api_PREFIX[DEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ @@ -926,7 +926,7 @@ int yydebug; required. Return 1 if memory is exhausted. */ static int yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG char const *yydebug_prefix, char const *yydebug_suffix, #endif @@ -1032,7 +1032,7 @@ do { \ the parser stacks to try to find a new initial context in which the current lookahead is syntactically acceptable. If it fails to find such a context, it discards the lookahead. */ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG # define YY_LAC_DISCARD(Event) \ do { \ if (yy_lac_established) \ @@ -1135,7 +1135,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, else { if (yy_lac_stack_realloc (yyes_capacity, 1, -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG " (", ")", #endif yyes, yyesa, &yyesp, yyes_prev)) @@ -1342,7 +1342,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yysize = yysize1; } }]b4_lac_if([[ -# if YYDEBUG +# if ]b4_api_PREFIX[DEBUG else if (yydebug) YYFPRINTF (stderr, "No expected tokens.\n"); # endif]])[ From b142cfd1280d38cc7a26be7c94bfcf02f400b848 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 2 Jul 2012 12:11:51 +0200 Subject: [PATCH 2/9] tests: more logs. * tests/headers.at (Several parsers): Here. --- tests/headers.at | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/headers.at b/tests/headers.at index 970d3f1b..4660f97f 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -166,7 +166,8 @@ AT_BISON_OPTION_POPDEFS ]) AT_DATA([main.cc], -[[extern "C" +[[#define ECHO(S) std::cerr << #S": " << S << std::endl; +extern "C" { #include "x1.h" #include "x2.h" @@ -175,18 +176,18 @@ AT_DATA([main.cc], } #include "x5.hh" //#include "x6.hh" + int main (void) { - int errs = 0; - errs += x1_parse(); - errs += x2_parse(); - errs += x3_parse(); - errs += x4_parse(); + ECHO(x1_parse()); + ECHO(x2_parse()); + ECHO(x3_parse()); + ECHO(x4_parse()); x5_::parser p5; - errs += p5.parse(); -// errs += x6_parse(); - return !!errs; + ECHO(p5.parse()); +// ECHO(x6_parse()); + return 0; } ]]) @@ -204,6 +205,12 @@ x2 x3 x4 x5 +]], +[[x1_parse(): 0 +x2_parse(): 0 +x3_parse(): 0 +x4_parse(): 0 +p5.parse(): 0 ]]) AT_CLEANUP From a7385a21ce39c0511e74765510a9eb13305a37c8 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 2 Jul 2012 14:55:54 +0200 Subject: [PATCH 3/9] glr.cc: formatting changes. * data/glr.cc: here. --- data/glr.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data/glr.cc b/data/glr.cc index ce3951e2..b3280a5e 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -234,10 +234,10 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], ]b4_percent_code_get([[requires]])[ -#include -#include +# include +# include ]b4_percent_define_ifdef([[location_type]], [], - [[#include "location.hh"]])[ + [[# include "location.hh"]])[ ]b4_YYDEBUG_define[ @@ -245,8 +245,8 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (N) \ { \ @@ -258,7 +258,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ } \ while (/*CONSTCOND*/ 0) -#endif +# endif ]b4_namespace_open[ /// A Bison parser. @@ -266,7 +266,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], { public: /// Symbol semantic values. -#ifndef ]b4_api_PREFIX[STYPE +# ifndef ]b4_api_PREFIX[STYPE ]m4_ifdef([b4_stype], [ union semantic_type { @@ -275,9 +275,9 @@ b4_user_stype [m4_if(b4_tag_seen_flag, 0, [[ typedef int semantic_type;]], [[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[ -#else +# else typedef ]b4_api_PREFIX[STYPE semantic_type; -#endif +# endif /// Symbol locations. typedef ]b4_percent_define_get([[location_type]], [[location]])[ location_type; From 771dc643242bf582944be05d2d3566aac21887d5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Jul 2012 09:57:40 +0200 Subject: [PATCH 4/9] c++: fewer #includes in the headers. * data/lalr1.cc: Define YY_NULL in the *.cc file, it is not needed in the header. * data/location.cc: iosfwd suffices. --- data/lalr1.cc | 14 +++++++------- data/location.cc | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/data/lalr1.cc b/data/lalr1.cc index afff0a51..5e83ee32 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -55,8 +55,6 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], ]b4_percent_define_ifdef([[location_type]], [], [[#include "location.hh"]])[ -]b4_null_define[ - ]b4_YYDEBUG_define[ ]b4_namespace_open[ @@ -277,16 +275,18 @@ m4_if(b4_prefix, [yy], [], #define yylex b4_prefix[]lex])[ /* First part of user declarations. */ -]b4_user_pre_prologue +]b4_user_pre_prologue[ -b4_defines_if([[ +]b4_defines_if([[ #include "@basename(]b4_spec_defines_file[@)"]])[ /* User implementation prologue. */ -]b4_user_post_prologue -b4_percent_code_get[]dnl +]b4_user_post_prologue[ +]b4_percent_code_get[ -[#ifndef YY_ +]b4_null_define[ + +#ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* FIXME: INFRINGES ON USER NAME SPACE */ diff --git a/data/location.cc b/data/location.cc index f45f634e..b7383d65 100644 --- a/data/location.cc +++ b/data/location.cc @@ -29,9 +29,9 @@ b4_copyright([Positions for Bison parsers in C++], ]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[ -# include +# include // std::max +# include # include -# include ]b4_null_define[ From 1168b32295f6acde7a777d9519723fe276155b6b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Jul 2012 12:04:07 +0200 Subject: [PATCH 5/9] tests: portability fixes. Reported by Hydra. * tests/headers.at (Several headers): Be sure to include config.h in the files to compile. --- tests/headers.at | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/headers.at b/tests/headers.at index 4660f97f..2eba7769 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -130,7 +130,7 @@ AT_SETUP([Several parsers]) # the header (but YYDEBUG and YYPARSE_PARAM). m4_define([AT_DATA_GRAMMAR_SEVERAL], [AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2]) -AT_DATA_GRAMMAR([AT_SKEL_CC_IF([$1.yy], [$1.y])], +AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])], [[%define api.prefix "$1_" $2 %union @@ -166,8 +166,8 @@ AT_BISON_OPTION_POPDEFS ]) AT_DATA([main.cc], -[[#define ECHO(S) std::cerr << #S": " << S << std::endl; -extern "C" +[AT_DATA_SOURCE_PROLOGUE +[extern "C" { #include "x1.h" #include "x2.h" @@ -177,6 +177,8 @@ extern "C" #include "x5.hh" //#include "x6.hh" +#define ECHO(S) std::cerr << #S": " << S << std::endl; + int main (void) { From 9104636b039b322fe29f64cc1546ecd94812ef46 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Jul 2012 11:04:52 +0200 Subject: [PATCH 6/9] api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc. The following mixture is insane: #define YYSTYPE_IS_TRIVIAL PREFIX_STYPE_IS_TRIVIAL #if (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL) since, of course YYSTYPE_IS_TRIVIAL is defined. Instead we could define YYSTYPE_IS_TRIVIAL as PREFIX_STYPE_IS_TRIVIAL only when the later is defined, but let's avoid stacking CPP on top of M4: rather, use #if (defined PREFIX_STYPE_IS_TRIVIAL && PREFIX_STYPE_IS_TRIVIAL) * data/glr.c, data/yacc.c: Use YYSTYPE_IS_TRIVIAL, YYSTYPE_IS_DECLARED, YYLTYPE_IS_TRIVIAL and YYLTYPE_IS_DECLARED under their api.prefix-renamed name. --- data/glr.c | 14 +++++--------- data/yacc.c | 16 ++++++---------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/data/glr.c b/data/glr.c index 8dd21085..dd02aece 100644 --- a/data/glr.c +++ b/data/glr.c @@ -190,12 +190,8 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C], b4_percent_code_get([[top]])[ ]m4_if(b4_api_prefix, [yy], [], [[/* Substitute the type names. */ -#define YYSTYPE ]b4_api_PREFIX[STYPE -#define YYSTYPE_IS_TRIVIAL ]b4_api_PREFIX[STYPE_IS_TRIVIAL -#define YYSTYPE_IS_DECLARED ]b4_api_PREFIX[STYPE_IS_DECLARED]b4_locations_if([[ -#define YYLTYPE ]b4_api_PREFIX[LTYPE -#define YYLTYPE_IS_TRIVIAL ]b4_api_PREFIX[LTYPE_IS_TRIVIAL -#define YYLTYPE_IS_DECLARED ]b4_api_PREFIX[LTYPE_IS_DECLARED]])])[ +#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[ +#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[ ]m4_if(b4_prefix, [yy], [], [[/* Substitute the variable and function names. */ #define yyparse ]b4_prefix[parse @@ -613,8 +609,8 @@ int yydebug; #ifndef YYSTACKEXPANDABLE # if (! defined __cplusplus \ - || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)) + || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \ + && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)) # define YYSTACKEXPANDABLE 1 # else # define YYSTACKEXPANDABLE 0 @@ -2319,7 +2315,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) yychar = YYEMPTY; yylval = yyval_default; ]b4_locations_if([ -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; #endif diff --git a/data/yacc.c b/data/yacc.c index 3a679141..8623847e 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -309,12 +309,8 @@ b4_copyright([Bison implementation for Yacc-like parsers in C], b4_percent_code_get([[top]])[]dnl m4_if(b4_api_prefix, [yy], [], [[/* Substitute the type names. */ -#define YYSTYPE ]b4_api_PREFIX[STYPE -#define YYSTYPE_IS_TRIVIAL ]b4_api_PREFIX[STYPE_IS_TRIVIAL -#define YYSTYPE_IS_DECLARED ]b4_api_PREFIX[STYPE_IS_DECLARED]b4_locations_if([[ -#define YYLTYPE ]b4_api_PREFIX[LTYPE -#define YYLTYPE_IS_TRIVIAL ]b4_api_PREFIX[LTYPE_IS_TRIVIAL -#define YYLTYPE_IS_DECLARED ]b4_api_PREFIX[LTYPE_IS_DECLARED]])])[ +#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[ +#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[ ]m4_if(b4_prefix, [yy], [], [[/* Substitute the variable and function names. */]b4_pull_if([[ #define yyparse ]b4_prefix[parse]])b4_push_if([[ @@ -498,8 +494,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \ + && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -776,7 +772,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1585,7 +1581,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ yyvsp = yyvs;]b4_locations_if([[ yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; From 426903aa75c4c92c6953f1304ee24c16c600210e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Jul 2012 11:41:06 +0200 Subject: [PATCH 7/9] YYLLOC_DEFAULT: factor, and don't export it in headers. * data/c++.m4, data/c.m4 (b4_yylloc_default_define): New. * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it. * data/glr.cc: Do not define YYLLOC_DEFAULT in the header file, but in the implementation one. --- data/c++.m4 | 29 +++++++++++++++++++++++++++++ data/c.m4 | 29 +++++++++++++++++++++++++++++ data/glr.c | 25 ++----------------------- data/glr.cc | 29 ++++++----------------------- data/lalr1.cc | 19 +------------------ data/yacc.c | 26 ++------------------------ 6 files changed, 69 insertions(+), 88 deletions(-) diff --git a/data/c++.m4 b/data/c++.m4 index 9913a172..45c4ddaf 100644 --- a/data/c++.m4 +++ b/data/c++.m4 @@ -174,3 +174,32 @@ m4_define([b4_cc_var_decls], ], [$@])]) m4_define([b4_cc_var_decl], [ $1;]) + + +## ---------## +## Values. ## +## ---------## + +# b4_yylloc_default_define +# ------------------------ +# Define YYLLOC_DEFAULT. +m4_define([b4_yylloc_default_define], +[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif +]]) diff --git a/data/c.m4 b/data/c.m4 index 3c6c6f4d..08296c65 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -610,3 +610,32 @@ m4_define([b4_declare_yydebug], extern int ]b4_prefix[debug; #endif][]dnl ]) + +# b4_yylloc_default_define +# ------------------------ +# Define YYLLOC_DEFAULT. +m4_define([b4_yylloc_default_define], +[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif +]]) diff --git a/data/glr.c b/data/glr.c index dd02aece..c4b394a2 100644 --- a/data/glr.c +++ b/data/glr.c @@ -467,34 +467,13 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = ]b4_stos[ }; - /* Error token number */ #define YYTERROR 1 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - ]b4_locations_if([[ -#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) +]b4_yylloc_default_define[ +# define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know diff --git a/data/glr.cc b/data/glr.cc index b3280a5e..2579091f 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -90,11 +90,13 @@ m4_define([b4_yy_symbol_print_generate], ]]) -# Declare yyerror. +# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT +# and declaration of yyerror. m4_append([b4_post_prologue], -[b4_syncline([@oline@], [@ofile@]) - -b4_c_ansi_function_decl([yyerror], +[b4_syncline([@oline@], [@ofile@])[ +]b4_yylloc_default_define[ +#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) +]b4_c_ansi_function_decl([yyerror], [static void], [[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp], [yylocationp]], @@ -241,25 +243,6 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], ]b4_YYDEBUG_define[ -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -# ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).begin = YYRHSLOC (Rhs, 1).begin; \ - (Current).end = YYRHSLOC (Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ - } \ - while (/*CONSTCOND*/ 0) -# endif - ]b4_namespace_open[ /// A Bison parser. class ]b4_parser_class_name[ diff --git a/data/lalr1.cc b/data/lalr1.cc index 5e83ee32..17a8f22c 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -298,25 +298,8 @@ m4_if(b4_prefix, [yy], [], # endif #endif -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - #define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).begin = YYRHSLOC (Rhs, 1).begin; \ - (Current).end = YYRHSLOC (Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ - } \ - while (false) -#endif +]b4_yylloc_default_define[ /* Suppress unused-variable warnings by "using" E. */ #define YYUSE(e) ((void) (e)) diff --git a/data/yacc.c b/data/yacc.c index 8623847e..2e46a1e2 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -740,31 +740,9 @@ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - +]b4_yylloc_default_define[ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif]b4_locations_if([[ +]b4_locations_if([[ /* YY_LOCATION_PRINT -- Print the location on the stream. From 53ab797db7343b9e7033c6325b70a4a0df8c066b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Jul 2012 12:00:24 +0200 Subject: [PATCH 8/9] glr.cc: do not override C++ definitions by C macros. * data/glr.c: here. * data/glr.cc: Fix overquotation. * tests/headers.at: Comment changes. --- data/glr.c | 6 ++++-- data/glr.cc | 17 +++++++++-------- tests/headers.at | 5 +++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/data/glr.c b/data/glr.c index c4b394a2..ebef9694 100644 --- a/data/glr.c +++ b/data/glr.c @@ -18,7 +18,10 @@ # along with this program. If not, see . -m4_include(b4_pkgdatadir/[c.m4]) +# If we are loaded by glr.cc, do not override c++.m4 definitions by +# those of c.m4. +m4_if(b4_skeleton, ["glr.c"], + [m4_include(b4_pkgdatadir/[c.m4])]) ## ---------------- ## ## Default values. ## @@ -494,7 +497,6 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif - /* YYLEX -- calling `yylex' with the right arguments. */ #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ diff --git a/data/glr.cc b/data/glr.cc index 2579091f..ba6ceac0 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -78,9 +78,9 @@ m4_define([b4_yy_symbol_print_generate], [static void], [[FILE *], []], [[int yytype], [yytype]], - [[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep], + [[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep], [yyvaluep]], - [[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp], + [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp], [yylocationp]], b4_parse_param)[ { @@ -98,13 +98,14 @@ m4_append([b4_post_prologue], #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) ]b4_c_ansi_function_decl([yyerror], [static void], - [[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp], + [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp], [yylocationp]], b4_parse_param, [[const char* msg], [msg]])]) -# Define yyerror. +# Hijack the epilogue to define implementations (yyerror, parser member +# functions etc.). m4_append([b4_epilogue], [b4_syncline([@oline@], [@ofile@])[ /*------------------. @@ -113,7 +114,7 @@ m4_append([b4_epilogue], ]b4_c_ansi_function_def([yyerror], [static void], - [[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp], + [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp], [yylocationp]], b4_parse_param, [[const char* msg], [msg]])[ @@ -217,10 +218,10 @@ b4_namespace_close[ # Let glr.c believe that the user arguments include the parser itself. m4_ifset([b4_parse_param], [m4_pushdef([b4_parse_param], - m4_dquote([[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]],] -m4_defn([b4_parse_param])))], + [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],] +m4_defn([b4_parse_param]))], [m4_pushdef([b4_parse_param], - [[[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]]]]) + [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]]) ]) m4_include(b4_pkgdatadir/[glr.c]) m4_popdef([b4_parse_param]) diff --git a/tests/headers.at b/tests/headers.at index 2eba7769..e1e74f5e 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -188,7 +188,8 @@ main (void) ECHO(x4_parse()); x5_::parser p5; ECHO(p5.parse()); -// ECHO(x6_parse()); +// x6_::parser p6; +// ECHO(p6.parse()); return 0; } ]]) @@ -198,7 +199,7 @@ AT_DATA_GRAMMAR_SEVERAL([x2], [%locations %debug]) AT_DATA_GRAMMAR_SEVERAL([x3], [%glr-parser]) AT_DATA_GRAMMAR_SEVERAL([x4], [%locations %debug %glr-parser]) AT_DATA_GRAMMAR_SEVERAL([x5], [%locations %debug %language "c++"]) -#AT_DATA_GRAMMAR_SEVERAL([x6], [%locations %language "c++"]) +#AT_DATA_GRAMMAR_SEVERAL([x5], [%locations %language "c++" %glr-parser]) AT_COMPILE_CXX([parser], [x1.o x2.o x3.o x4.o x5.o main.cc]) AT_CHECK([./parser], [0], From faff3bef5b72ac85093799f997596631c3202c12 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Jul 2012 12:04:19 +0200 Subject: [PATCH 9/9] tests: headers.at: strengthen. * tests/headers.at (Several headers): Be stricter when checking the exported macros. --- tests/headers.at | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/headers.at b/tests/headers.at index e1e74f5e..70891292 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -160,7 +160,14 @@ exp: AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])]) # C++ output relies on namespaces and still uses yy a lot. AT_SKEL_CC_IF([], - [AT_CHECK([$EGREP -i yy $1.h | $EGREP -v 'YY(DEBUG|PARSE_PARAM)'], [1])]) + [AT_CHECK([$EGREP yy $1.h], [1])]) + +# Ignore comments. Ignore YYPARSE_PARAM. YYDEBUG (not renamed) can be +# read, but not changed. +AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \ + -e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ | + $EGREP -wv '(YYPARSE_PARAM|defined YYDEBUG|if YYDEBUG)']], + [1]) AT_LANG_COMPILE([$1.o]) AT_BISON_OPTION_POPDEFS ])