From: Akim Demaille Date: Wed, 4 Jul 2012 15:14:35 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/maint' X-Git-Tag: v2.7.90~404 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/ccdc1577ef7fb32a5e30cb655337e7cd42b98987 Merge remote-tracking branch 'origin/maint' * origin/maint: tests: headers.at: strengthen. glr.cc: do not override C++ definitions by C macros. YYLLOC_DEFAULT: factor, and don't export it in headers. api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc. tests: portability fixes. c++: fewer #includes in the headers. glr.cc: formatting changes. tests: more logs. api.prefix: also rename YYDEBUG. Conflicts: data/c.m4 data/glr.c data/glr.cc data/lalr1.cc data/yacc.c --- ccdc1577ef7fb32a5e30cb655337e7cd42b98987 diff --cc data/c++.m4 index 4bc6c4c7,45c4ddaf..a64777c3 --- a/data/c++.m4 +++ b/data/c++.m4 @@@ -424,7 -170,36 +424,36 @@@ m4_define([b4_parse_param_vars] /* User arguments. */ b4_cc_var_decls(b4_parse_param)])]) m4_define([b4_cc_var_decls], - [m4_map_sep([b4_cc_var_decl], [ + [m4_map_sep([b4_cc_var_decl], [ ], [$@])]) m4_define([b4_cc_var_decl], - [ $1;]) + [ $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 --cc data/c.m4 index 831274cb,08296c65..adf5d4f1 --- a/data/c.m4 +++ b/data/c.m4 @@@ -618,14 -581,32 +618,32 @@@ b4_pure_if([], [[extern ]b4_api_PREFIX[ ]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl ]) - # b4_declare_yydebug + # b4_YYDEBUG_define # ------------------ - m4_define([b4_declare_yydebug], + m4_define([b4_YYDEBUG_define], [[/* Enabling traces. */ - #ifndef YYDEBUG + ]m4_if(b4_api_prefix, [yy], + [[#ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ +# define YYDEBUG ]b4_parse_trace_if([1], [0])[ - #endif + #endif]], + [[#ifndef ]b4_api_PREFIX[DEBUG + # if defined YYDEBUG -# if 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[ ++# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[ + # endif /* ! defined ]b4_api_PREFIX[DEBUG */ + #endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl + ]) + + # b4_declare_yydebug + # ------------------ + m4_define([b4_declare_yydebug], + [b4_YYDEBUG_define[ + #if ]b4_api_PREFIX[DEBUG extern int ]b4_prefix[debug; #endif][]dnl ]) diff --cc data/glr.c index 32932bac,ebef9694..37cf1a4a --- a/data/glr.c +++ b/data/glr.c @@@ -357,7 -348,20 +356,7 @@@ static const ]b4_int_type_for([b4_trans ]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[] = -{ - ]b4_prhs[ -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = -{ - ]b4_rhs[ -}; - /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const ]b4_int_type_for([b4_rline])[ yyrline[] = { @@@ -494,14 -526,11 +472,14 @@@ static const int YYEMPTY = -2 typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; -#define YYCHK(YYE) \ - do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ - while (YYID (0)) +#define YYCHK(YYE) \ + do { \ + YYRESULTTAG yychk_flag = YYE; \ + if (yychk_flag != yyok) \ + return yychk_flag; \ + } while (YYID (0)) - #if YYDEBUG + #if ]b4_api_PREFIX[DEBUG # ifndef YYFPRINTF # define YYFPRINTF fprintf @@@ -790,16 -825,9 +768,16 @@@ yyfillin (yyGLRStackItem *yyvsp, int yy yyGLRState *s = yyvsp[yylow0].yystate.yypred; for (i = yylow0-1; i >= yylow1; i -= 1) { - #if YYDEBUG - YYASSERT (s->yyresolved); - yyvsp[i].yystate.yyresolved = yytrue; - yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[ ++#if ]b4_api_PREFIX[DEBUG + yyvsp[i].yystate.yylrState = s->yylrState; +#endif + yyvsp[i].yystate.yyresolved = s->yyresolved; + if (s->yyresolved) + yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval; + else + /* The effect of using yysval or yyloc (in an immediate rule) is + * undefined. */ + yyvsp[i].yystate.yysemantics.yyfirstVal = YY_NULL;]b4_locations_if([[ yyvsp[i].yystate.yyloc = s->yyloc;]])[ s = yyvsp[i].yystate.yypred = s->yypred; } @@@ -1289,55 -1316,14 +1267,55 @@@ yyglrShiftDefer (yyGLRStack* yystackp, yystackp->yytops.yystates[yyk] = yynewState; /* Invokes YY_RESERVE_GLRSTACK. */ - yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule); + yyaddDeferredAction (yystackp, yyk, yynewState, yyrhs, yyrule); +} + - #if !YYDEBUG ++#if !]b4_api_PREFIX[DEBUG +# define YY_REDUCE_PRINT(Args) +#else +# define YY_REDUCE_PRINT(Args) \ +do { \ + if (yydebug) \ + yy_reduce_print Args; \ +} while (YYID (0)) + +/*----------------------------------------------------------------------. +| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. | +`----------------------------------------------------------------------*/ + +/*ARGSUSED*/ static inline void +yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk, + yyRuleNum yyrule]b4_user_formals[) +{ + int yynrhs = yyrhsLength (yyrule);]b4_locations_if([ + int yylow = 1;])[ + int yyi; + YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", + (unsigned long int) yyk, yyrule - 1, + (unsigned long int) yyrline[yyrule]); + if (! yynormal) + yyfillin (yyvsp, 1, -yynrhs); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState], + &yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval + ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl + b4_user_args[); + if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved) + YYFPRINTF (stderr, " (unresolved)"); + YYFPRINTF (stderr, "\n"); + } } +#endif -/** Pop the symbols consumed by reduction #RULE from the top of stack - * #K of STACK, and perform the appropriate semantic action on their +/** Pop the symbols consumed by reduction #YYRULE from the top of stack + * #YYK of *YYSTACKP, and perform the appropriate semantic action on their * semantic values. Assumes that all ambiguities in semantic values - * have been previously resolved. Set *VALP to the resulting value, - * and *LOCP to the computed location (if any). Return value is as + * have been previously resolved. Set *YYVALP to the resulting value, + * and *YYLOCP to the computed location (if any). Return value is as * for userAction. */ static inline YYRESULTTAG yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, diff --cc data/glr.cc index a1652a10,ba6ceac0..2f986da2 --- a/data/glr.cc +++ b/data/glr.cc @@@ -125,8 -130,9 +128,8 @@@ m4_pushdef([b4_parse_param], m4_defn([b [ /// 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], [,])[ + ]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[ #endif]b4_parse_param_cons[ { } @@@ -230,35 -237,12 +233,13 @@@ b4_copyright([Skeleton interface for Bi ]b4_percent_code_get([[requires]])[ -# include -# include +#include +#include +#include ]b4_percent_define_ifdef([[location_type]], [], - [[# include "location.hh"]])[ + [[#include "location.hh"]])[ - /* Enabling traces. */ - #ifndef YYDEBUG - # define YYDEBUG ]b4_parse_trace_if([1], [0])[ - #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). */ - - #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_YYDEBUG_define[ ]b4_namespace_open[ /// A Bison parser. @@@ -292,8 -300,9 +273,8 @@@ /// \param loc where the syntax error is found. /// \param msg a description of the syntax error. 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. diff --cc data/lalr1.cc index dbcc7349,17a8f22c..59b30964 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@@ -145,25 -46,16 +145,20 @@@ b4_copyright([Skeleton interface for Bi /* C++ LALR(1) parser skeleton written by Akim Demaille. */ ]b4_cpp_guard_open([b4_spec_defines_file])[ - ]b4_percent_code_get([[requires]])[ - -#include -#include -#include "stack.hh" -]b4_percent_define_ifdef([[location_type]], [], - [[#include "location.hh"]])[ +]b4_parse_assert_if([# include ])[ +# include +# include +# include +# include "stack.hh" +]b4_locations_if([b4_percent_define_ifdef([[location_type]], [], + [[# include "location.hh"]])])[ + +]b4_variant_if([b4_namespace_open +b4_variant_define +b4_namespace_close])[ - ]b4_null_define[ - - /* Enabling traces. */ - #ifndef YYDEBUG - # define YYDEBUG ]b4_parse_trace_if([1], [0])[ - #endif + ]b4_YYDEBUG_define[ ]b4_namespace_open[ @@@ -235,84 -198,42 +230,84 @@@ /// 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. - static const rhs_number_type yyrhs_[]; - /// For each rule, the index of the first RHS symbol in \a yyrhs_. - static const ]b4_int_type_for([b4_prhs])[ yyprhs_[]; - /// For each rule, its source line number. - static const ]b4_int_type_for([b4_rline])[ yyrline_[]; - /// For each scanner token number, its symbol number. - static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[]; +]b4_integral_parser_table_declare([rline], [b4_rline], + [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ /// Report on the debug stream that the rule \a r is going to be reduced. virtual void yy_reduce_print_ (int r); /// Print the state stack on the debug stream. virtual void yystack_print_ (); - /* Debugging. */ + // Debugging. int yydebug_; std::ostream* yycdebug_; - #endif // YYDEBUG -#endif ++#endif // ]b4_api_PREFIX[DEBUG /// Convert a scanner token number \a t to a symbol number. - token_number_type yytranslate_ (int t); + static inline token_number_type yytranslate_ (]b4_lex_symbol_if([token_type], [int])[ t); + - #if YYDEBUG ++#if ]b4_api_PREFIX[DEBUG + /// \brief Display a symbol type, value and location. + /// \param yyo The output stream. + /// \param yysym The symbol. + template + void yy_print_ (std::ostream& yyo, + const symbol_base_type& yysym) const; +#endif /// \brief Reclaim the memory associated to a symbol. - /// \param yymsg Why this token is reclaimed. - /// \param yytype The symbol type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - inline void yydestruct_ (const char* yymsg, - int yytype, - semantic_type* yyvaluep, - location_type* yylocationp); + /// \param yymsg Why this token is reclaimed. + /// If null, print nothing. + /// \param s The symbol. + template + inline void yy_destroy_ (const char* yymsg, + symbol_base_type& yysym) const; + + private: + /// Element of the stack: a state and its attributes. + struct stack_symbol_type : symbol_base_type + { + /// The parent class. + typedef symbol_base_type super_type; + + /// Default constructor. + inline stack_symbol_type (); + + /// Constructor. + inline stack_symbol_type (]b4_args([state_type s], + [const semantic_type& v], + b4_locations_if([const location_type& l]))[); + + /// The state. + state_type state; + + /// The type (corresponding to \a state). + inline int type_get_ () const; + }; + + /// Stack type. + typedef stack stack_type; + + /// The stack. + stack_type yystack_; + + /// Push a new state on the stack. + /// \param m a debug message to display + /// if null, no trace is output. + /// \param s the symbol + /// \warning the contents of \a s.value is stolen. + inline void yypush_ (const char* m, stack_symbol_type& s); + + /// Push a new look ahead token on the state on the stack. + /// \param m a debug message to display + /// if null, no trace is output. + /// \param s the state + /// \param sym the symbol (for its value and location). + /// \warning the contents of \a s.value is stolen. + inline void yypush_ (const char* m, state_type s, symbol_type& sym); /// Pop \a n symbols the three stacks. inline void yypop_ (unsigned int n = 1); @@@ -358,13 -277,16 +353,15 @@@ m4_if(b4_prefix, [yy], [] /* First part of user declarations. */ ]b4_user_pre_prologue[ -]b4_defines_if([[ -#include "@basename(]b4_spec_defines_file[@)"]])[ +#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[ + + ]b4_null_define[ - [#ifndef YY_ + #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* FIXME: INFRINGES ON USER NAME SPACE */ @@@ -376,26 -298,8 +373,9 @@@ # endif #endif -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -]b4_yylloc_default_define[ +]b4_locations_if([dnl - [/* 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].location) - #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]])[ ++[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location) ++]b4_yylloc_default_define])[ /* Suppress unused-variable warnings by "using" E. */ #define YYUSE(e) ((void) (e)) @@@ -406,43 -310,43 +386,43 @@@ /* A pseudo ostream that takes yydebug_ into account. */ # define YYCDEBUG if (yydebug_) (*yycdebug_) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug_) \ - { \ - *yycdebug_ << Title << ' '; \ - yy_symbol_print_ ((Type), (Value), (Location)); \ - *yycdebug_ << std::endl; \ - } \ -} while (false) - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug_) \ - yy_reduce_print_ (Rule); \ -} while (false) - -# define YY_STACK_PRINT() \ -do { \ - if (yydebug_) \ - yystack_print_ (); \ -} while (false) +# define YY_SYMBOL_PRINT(Title, Symbol) \ + do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_print_ (*yycdebug_, Symbol); \ + *yycdebug_ << std::endl; \ + } \ + } while (false) + +# define YY_REDUCE_PRINT(Rule) \ + do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ + } while (false) + +# define YY_STACK_PRINT() \ + do { \ + if (yydebug_) \ + 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() +# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) - #endif /* !YYDEBUG */ + #endif /* !]b4_api_PREFIX[DEBUG */ -#define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yychar = yyempty_) +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yyempty = true) -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus_) ]b4_namespace_open[]b4_error_verbose_if([[ @@@ -499,120 -403,68 +479,120 @@@ { } -#if ]b4_api_PREFIX[DEBUG - /*--------------------------------. - | Print this symbol on YYOUTPUT. | - `--------------------------------*/ - inline void - ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) + /*---------------. + | Symbol types. | + `---------------*/ + +]b4_lex_symbol_if([], [b4_public_types_define])[ + + // stack_symbol_type. + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type () + : super_type () + , state () + { + } + + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_args( + [state_type s], + [const semantic_type& v], + b4_locations_if([const location_type& l]))[) + : super_type (v]b4_locations_if([, l])[) + , state (s) + { + } + + int + ]b4_parser_class_name[::stack_symbol_type::type_get_ () const + { + return yystos_[state]; + } + + + template + void + ]b4_parser_class_name[::yy_destroy_ (const char* yymsg, + symbol_base_type& yysym) const + { + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yysym); + + // User destructor. + int yytype = yysym.type_get (); + switch (yytype) + { +]b4_symbol_foreach([b4_symbol_destructor])dnl +[ default: + break; + }]b4_variant_if([ + + // Type destructor. + b4_symbol_variant([[yytype]], [[yysym.value]], [[template destroy]])])[ + } + - #if YYDEBUG ++#if ]b4_api_PREFIX[DEBUG + template + void + ]b4_parser_class_name[::yy_print_ (std::ostream& yyo, + const symbol_base_type& yysym) const { - YYUSE (yylocationp); - YYUSE (yyvaluep); - std::ostream& yyo = debug_stream (); std::ostream& yyoutput = yyo; YYUSE (yyoutput); + int yytype = yysym.type_get (); + yyo << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " ("]b4_locations_if([ + << yysym.location << ": "])[; switch (yytype) { - ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl +]b4_symbol_foreach([b4_symbol_printer])dnl [ default: - break; + break; } + yyo << ')'; } - +#endif void - ]b4_parser_class_name[::yy_symbol_print_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) + ]b4_parser_class_name[::yypush_ (const char* m, state_type s, + symbol_type& sym) { - *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") - << ' ' << yytname_[yytype] << " (" - << *yylocationp << ": "; - yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); - *yycdebug_ << ')'; + if (m) + YY_SYMBOL_PRINT (m, sym); +]b4_variant_if( +[[ yystack_.push (stack_symbol_type (]b4_args( + [s], + [semantic_type()], + b4_locations_if([sym.location]))[)); + ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]], + [build], [sym.value])], +[[ yystack_.push (stack_symbol_type (]b4_args( + [s], + [sym.value], + b4_locations_if([sym.location]))[));]])[ } -#endif void - ]b4_parser_class_name[::yydestruct_ (const char* yymsg, - int yytype, semantic_type* yyvaluep, location_type* yylocationp) + ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s) { - YYUSE (yylocationp); - YYUSE (yymsg); - YYUSE (yyvaluep); - - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ - default: - break; - } + if (m) + YY_SYMBOL_PRINT (m, s); +]b4_variant_if( +[[ yystack_.push (stack_symbol_type (]b4_args( + [s.state], + [semantic_type()], + b4_locations_if([s.location]))[)); + ]b4_symbol_variant([[yystos_[s.state]]], [[yystack_[0].value]], + [build], [s.value])], +[ yystack_.push (s);])[ } void ]b4_parser_class_name[::yypop_ (unsigned int n) { - yystate_stack_.pop (n); - yysemantic_stack_.pop (n); - yylocation_stack_.pop (n); + yystack_.pop (n); } - #if YYDEBUG + #if ]b4_api_PREFIX[DEBUG std::ostream& ]b4_parser_class_name[::debug_stream () const { @@@ -637,17 -489,7 +617,17 @@@ { yydebug_ = l; } - #endif // YYDEBUG -#endif ++#endif // ]b4_api_PREFIX[DEBUG + + inline ]b4_parser_class_name[::state_type + ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yylhs) + { + int yyr = yypgoto_[yylhs - yyntokens_] + yystate; + if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) + return yytable_[yyr]; + else + return yydefgoto_[yylhs - yyntokens_]; + } inline bool ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) @@@ -1076,23 -935,118 +1056,23 @@@ b4_error_verbose_if([state_type yystate } - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[; - const ]b4_int_type_for([b4_pact])[ - ]b4_parser_class_name[::yypact_[] = - { - ]b4_pact[ - }; - - /* YYDEFACT[S] -- default reduction number in state S. Performed when - YYTABLE doesn't specify something else to do. Zero means the - default is an error. */ - const ]b4_int_type_for([b4_defact])[ - ]b4_parser_class_name[::yydefact_[] = - { - ]b4_defact[ - }; - - /* YYPGOTO[NTERM-NUM]. */ - const ]b4_int_type_for([b4_pgoto])[ - ]b4_parser_class_name[::yypgoto_[] = - { - ]b4_pgoto[ - }; - - /* YYDEFGOTO[NTERM-NUM]. */ - const ]b4_int_type_for([b4_defgoto])[ - ]b4_parser_class_name[::yydefgoto_[] = - { - ]b4_defgoto[ - }; - /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF_, syntax error. */ const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; - const ]b4_int_type_for([b4_table])[ - ]b4_parser_class_name[::yytable_[] = - { - ]b4_table[ - }; - - /* YYCHECK. */ - const ]b4_int_type_for([b4_check])[ - ]b4_parser_class_name[::yycheck_[] = - { - ]b4_check[ - }; - /* STOS_[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ - const ]b4_int_type_for([b4_stos])[ - ]b4_parser_class_name[::yystos_[] = - { - ]b4_stos[ - }; - -#if ]b4_api_PREFIX[DEBUG - /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding - to YYLEX-NUM. */ - const ]b4_int_type_for([b4_toknum])[ - ]b4_parser_class_name[::yytoken_number_[] = - { - ]b4_toknum[ - }; -#endif - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ - const ]b4_int_type_for([b4_r1])[ - ]b4_parser_class_name[::yyr1_[] = - { - ]b4_r1[ - }; - - /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ - const ]b4_int_type_for([b4_r2])[ - ]b4_parser_class_name[::yyr2_[] = - { - ]b4_r2[ - }; +]b4_parser_tables_define[ - ]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* const ]b4_parser_class_name[::yytname_[] = { - ]b4_tname[ + ]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_[] = - { - ]b4_rhs[ - }; - - /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ - const ]b4_int_type_for([b4_prhs])[ - ]b4_parser_class_name[::yyprhs_[] = - { - ]b4_prhs[ - }; - - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ - const ]b4_int_type_for([b4_rline])[ - ]b4_parser_class_name[::yyrline_[] = - { - ]b4_rline[ - }; +]b4_integral_parser_table_define([rline], [b4_rline])[ // Print the state stack on the debug stream. void @@@ -1119,12 -1071,40 +1099,12 @@@ /* The symbols being reduced. */ for (int yyi = 0; yyi < yynrhs; yyi++) YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", - yyrhs_[yyprhs_[yyrule] + yyi], - &]b4_rhs_value(yynrhs, yyi + 1)[, - &]b4_rhs_location(yynrhs, yyi + 1)[); + ]b4_rhs_data(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 - ]b4_parser_class_name[::yytranslate_ (int t) - { - static - const token_number_type - translate_table[] = - { - ]b4_translate[ - }; - if ((unsigned int) t <= yyuser_token_number_max_) - return translate_table[t]; - else - return yyundef_token_; - } - - const int ]b4_parser_class_name[::yyeof_ = 0; - const int ]b4_parser_class_name[::yylast_ = ]b4_last[; - const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[; - const int ]b4_parser_class_name[::yyempty_ = -2; - const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[; - const int ]b4_parser_class_name[::yyterror_ = 1; - const int ]b4_parser_class_name[::yyerrcode_ = 256; - const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[; - - const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[; - const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; - +]b4_lex_symbol_if([], [b4_yytranslate_define])[ ]b4_namespace_close[ -]b4_epilogue +]b4_epilogue[]dnl m4_divert_pop(0) +m4_popdef([b4_copyright_years])dnl diff --cc data/yacc.c index 7e51b56f,2e46a1e2..a98c4ed9 --- a/data/yacc.c +++ b/data/yacc.c @@@ -499,8 -494,8 +495,8 @@@ void free (void *); /* INFRINGES ON USE #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))) ++ || (]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 @@@ -592,12 -585,28 +588,12 @@@ static const ]b4_int_type_for([b4_trans ]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[] = -{ - ]b4_prhs[ -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = -{ - ]b4_rhs[ -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const ]b4_int_type_for([b4_rline])[ yyrline[] = -{ - ]b4_rline[ -}; +]b4_integral_parser_table_define([rline], [b4_rline], + [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ #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[] = @@@ -673,46 -737,24 +669,23 @@@ d while (YYID (0)) -#define YYTERROR 1 -#define YYERRCODE 256 +#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_locations_if([[ + ]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. This macro was not mandated originally: define only if we know 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, \ - (Loc).last_line, (Loc).last_column) +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif diff --cc tests/atlocal.in index ef31d9fc,7302209f..315e98ed --- a/tests/atlocal.in +++ b/tests/atlocal.in @@@ -75,8 -75,8 +75,9 @@@ CONF_JAVA='@CONF_JAVA@ # Empty if no xsltproc was found : ${XSLTPROC='@XSLTPROC@'} --# We need egrep. ++# We need egrep and perl. : ${EGREP='@EGREP@'} ++: ${PERL='@PERL@'} # Use simple quotes (lib/quote.c). LC_CTYPE=C diff --cc tests/headers.at index 970d3f1b,70891292..36142cc9 --- a/tests/headers.at +++ b/tests/headers.at @@@ -160,7 -160,14 +160,15 @@@ 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])[ | ++AT_CHECK([[$PERL -0777 -e 's{/\*.*?\*/}{}sg;s,//.*,,;' \ ++ ]$1.AT_SKEL_CC_IF([hh], [h])[ | ++ grep 'YY' | + $EGREP -wv '(YYPARSE_PARAM|defined YYDEBUG|if YYDEBUG)']], + [1]) AT_LANG_COMPILE([$1.o]) AT_BISON_OPTION_POPDEFS ])