diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-06-26 23:46:47 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-06-26 23:57:08 +0300 |
commit | ac037438ef5c581b0dc01829e7ba173d4b2a4d42 (patch) | |
tree | 567767475824d592c71612b198b47118923d68f5 /contrib/tools/bison/data | |
parent | 10d8655dd385fe03395d60abfbb5903fcc87b2a4 (diff) | |
download | ydb-ac037438ef5c581b0dc01829e7ba173d4b2a4d42.tar.gz |
Update contrib/tools/bison to 3.1
3649391e5dae6eedaa45d736e3febbde1342c10a
Diffstat (limited to 'contrib/tools/bison/data')
-rw-r--r-- | contrib/tools/bison/data/README | 8 | ||||
-rw-r--r-- | contrib/tools/bison/data/bison.m4 | 8 | ||||
-rw-r--r-- | contrib/tools/bison/data/c++-skel.m4 | 3 | ||||
-rw-r--r-- | contrib/tools/bison/data/c++.m4 | 129 | ||||
-rw-r--r-- | contrib/tools/bison/data/c-like.m4 | 2 | ||||
-rw-r--r-- | contrib/tools/bison/data/c-skel.m4 | 3 | ||||
-rw-r--r-- | contrib/tools/bison/data/c.m4 | 80 | ||||
-rw-r--r-- | contrib/tools/bison/data/glr.cc | 6 | ||||
-rw-r--r-- | contrib/tools/bison/data/lalr1.cc | 331 | ||||
-rw-r--r-- | contrib/tools/bison/data/location.cc | 89 | ||||
-rw-r--r-- | contrib/tools/bison/data/m4sugar/foreach.m4 | 4 | ||||
-rw-r--r-- | contrib/tools/bison/data/m4sugar/m4sugar.m4 | 13 | ||||
-rw-r--r-- | contrib/tools/bison/data/stack.hh | 47 | ||||
-rw-r--r-- | contrib/tools/bison/data/variant.hh | 49 | ||||
-rw-r--r-- | contrib/tools/bison/data/yacc.c | 62 |
15 files changed, 463 insertions, 371 deletions
diff --git a/contrib/tools/bison/data/README b/contrib/tools/bison/data/README index 842c004186..798750f7a9 100644 --- a/contrib/tools/bison/data/README +++ b/contrib/tools/bison/data/README @@ -1,5 +1,3 @@ --*- outline -*- - This directory contains data needed by Bison. * Skeletons @@ -52,7 +50,11 @@ into various formats. ----- -Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc. +Local Variables: +mode: outline +End: + +Copyright (C) 2002, 2008-2015, 2018 Free Software Foundation, Inc. This file is part of GNU Bison. diff --git a/contrib/tools/bison/data/bison.m4 b/contrib/tools/bison/data/bison.m4 index ca27159c87..80e025c9b4 100644 --- a/contrib/tools/bison/data/bison.m4 +++ b/contrib/tools/bison/data/bison.m4 @@ -2,7 +2,7 @@ # Language-independent M4 Macros for Bison. -# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -437,7 +437,6 @@ m4_define([b4_symbol_action_location], # b4_symbol_action(SYMBOL-NUM, KIND) # ---------------------------------- # Run the action KIND (destructor or printer) for SYMBOL-NUM. -# Same as in C, but using references instead of pointers. m4_define([b4_symbol_action], [b4_symbol_if([$1], [has_$2], [b4_dollar_pushdef([(*yyvaluep)], @@ -445,7 +444,7 @@ m4_define([b4_symbol_action], [m4_dquote(b4_symbol([$1], [type]))]), [(*yylocationp)])dnl b4_symbol_case_([$1])[]dnl -b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"]) +b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])]) b4_symbol([$1], [$2]) b4_syncline([@oline@], [@ofile@]) break; @@ -1061,3 +1060,6 @@ b4_percent_define_ifdef([api.value.type], [['%s' and '%s' cannot be used together]], [%yacc], [%define api.value.type "union"])])])]) + +# api.value.union.name. +b4_percent_define_check_kind([api.value.union.name], [keyword]) diff --git a/contrib/tools/bison/data/c++-skel.m4 b/contrib/tools/bison/data/c++-skel.m4 index 06597a8bff..3cd56789f3 100644 --- a/contrib/tools/bison/data/c++-skel.m4 +++ b/contrib/tools/bison/data/c++-skel.m4 @@ -2,7 +2,8 @@ # C++ skeleton dispatching for Bison. -# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, +# Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/data/c++.m4 b/contrib/tools/bison/data/c++.m4 index be12c0a2fe..396d86132d 100644 --- a/contrib/tools/bison/data/c++.m4 +++ b/contrib/tools/bison/data/c++.m4 @@ -2,7 +2,7 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,6 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +# Sanity checks, before defaults installed by c.m4. +b4_percent_define_ifdef([[api.value.union.name]], + [b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]), + [named %union is invalid in C++])]) + m4_include(b4_pkgdatadir/[c.m4]) # b4_comment(TEXT, [PREFIX]) @@ -25,6 +30,16 @@ m4_include(b4_pkgdatadir/[c.m4]) m4_define([b4_comment], [b4_comment_([$1], [$2// ], [$2// ])]) +# b4_inline(hh|cc) +# ---------------- +# Expand to `inline\n ` if $1 is hh. +m4_define([b4_inline], +[m4_case([$1], + [cc], [], + [hh], [[inline + ]], + [m4_fatal([$0: invalid argument: $1])])]) + ## -------- ## ## Checks. ## ## -------- ## @@ -169,9 +184,12 @@ m4_define([b4_public_types_declare], /// (External) token type, as returned by yylex. typedef token::yytokentype token_type; - /// Internal symbol number. + /// Symbol type: an internal symbol number. typedef int symbol_number_type; + /// The symbol type number to denote an empty symbol. + enum { empty_symbol = -2 }; + /// Internal symbol number for tokens (subsumed by symbol_number_type). typedef ]b4_int_type_for([b4_translate])[ token_number_type; @@ -204,8 +222,15 @@ m4_define([b4_public_types_declare], const semantic_type& v]b4_locations_if([, const location_type& l])[); + /// Destroy the symbol. ~basic_symbol (); + /// Destroy contents, and record that is empty. + void clear (); + + /// Whether empty. + bool empty () const; + /// Destructive move, \a s is emptied into this. void move (basic_symbol& s); @@ -235,21 +260,23 @@ m4_define([b4_public_types_declare], /// Constructor from (external) token numbers. by_type (kind_type t); + /// Record that this symbol is empty. + void clear (); + /// Steal the symbol type from \a that. void move (by_type& that); /// The (internal) type number (corresponding to \a type). - /// -1 when this symbol is empty. + /// \a empty when empty. symbol_number_type type_get () const; /// The token. token_type token () const; - enum { empty = 0 }; - /// The symbol type. - /// -1 when this symbol is empty. - token_number_type type; + /// \a empty_symbol when empty. + /// An int, not token_number_type, to be able to store empty_symbol. + int type; }; /// "External" symbols: returned by the scanner. @@ -258,38 +285,33 @@ m4_define([b4_public_types_declare], ]b4_symbol_constructor_declare]) -# b4_public_types_define -# ---------------------- +# b4_public_types_define(hh|cc) +# ----------------------------- # Provide the implementation needed by the public types. m4_define([b4_public_types_define], -[[ inline - ]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) +[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) : std::runtime_error (m)]b4_locations_if([ , location (l)])[ {} // basic_symbol. template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol () - : value () + : value ()]b4_locations_if([ + , location ()])[ {} template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other) : Base (other) - , value ()]b4_locations_if([ + , value (]b4_variant_if([], [other.value])[)]b4_locations_if([ , location (other.location)])[ - { - ]b4_variant_if([b4_symbol_variant([other.type_get ()], [value], [copy], - [other.value])], - [value = other.value;])[ + {]b4_variant_if([ + b4_symbol_variant([other.type_get ()], [value], [copy], + [other.value])])[ } - template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], [const semantic_type& v], @@ -306,7 +328,6 @@ m4_define([b4_public_types_define], ]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ /// Constructor for valueless symbols. template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], b4_locations_if([const location_type& l]))[) @@ -316,11 +337,19 @@ m4_define([b4_public_types_define], {}]])[ template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol () + { + clear (); + } + + template <typename Base> + void + ]b4_parser_class_name[::basic_symbol<Base>::clear () {]b4_variant_if([[ // User destructor. symbol_number_type yytype = this->type_get (); + basic_symbol<Base>& yysym = *this; + (void) yysym; switch (yytype) { ]b4_symbol_foreach([b4_symbol_destructor])dnl @@ -330,14 +359,21 @@ m4_define([b4_public_types_define], // Type destructor. ]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[ + Base::clear (); + } + + template <typename Base> + bool + ]b4_parser_class_name[::basic_symbol<Base>::empty () const + { + return Base::type_get () == empty_symbol; } template <typename Base> - inline void ]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s) { - super_type::move(s); + super_type::move (s); ]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move], [s.value])], [value = s.value;])[]b4_locations_if([ @@ -345,38 +381,38 @@ m4_define([b4_public_types_define], } // by_type. - inline - ]b4_parser_class_name[::by_type::by_type () - : type (empty) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type () + : type (empty_symbol) {} - inline - ]b4_parser_class_name[::by_type::by_type (const by_type& other) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other) : type (other.type) {} - inline - ]b4_parser_class_name[::by_type::by_type (token_type t) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t) : type (yytranslate_ (t)) {} - inline - void + ]b4_inline([$1])[void + ]b4_parser_class_name[::by_type::clear () + { + type = empty_symbol; + } + + ]b4_inline([$1])[void ]b4_parser_class_name[::by_type::move (by_type& that) { type = that.type; - that.type = empty; + that.clear (); } - inline - int + ]b4_inline([$1])[int ]b4_parser_class_name[::by_type::type_get () const { return type; } ]b4_token_ctor_if([[ - inline - ]b4_parser_class_name[::token_type + ]b4_inline([$1])b4_parser_class_name[::token_type ]b4_parser_class_name[::by_type::token () const { // YYTOKNUM[NUM] -- (External) token number corresponding to the @@ -402,14 +438,13 @@ m4_define([b4_symbol_constructor_declare], []) m4_define([b4_symbol_constructor_define], []) -# b4_yytranslate_define -# --------------------- -# Define yytranslate_. Sometimes used in the header file, +# b4_yytranslate_define(cc|hh) +# ---------------------------- +# Define yytranslate_. Sometimes used in the header file ($1=hh), # sometimes in the cc file. m4_define([b4_yytranslate_define], [[ // Symbol number corresponding to token number t. - inline - ]b4_parser_class_name[::token_number_type + ]b4_inline([$1])b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t) { @@ -419,12 +454,12 @@ m4_define([b4_yytranslate_define], { ]b4_translate[ }; - const unsigned int user_token_number_max_ = ]b4_user_token_number_max[; + const unsigned user_token_number_max_ = ]b4_user_token_number_max[; const token_number_type undef_token_ = ]b4_undef_token_number[; - if (static_cast<int>(t) <= yyeof_) + if (static_cast<int> (t) <= yyeof_) return yyeof_; - else if (static_cast<unsigned int> (t) <= user_token_number_max_) + else if (static_cast<unsigned> (t) <= user_token_number_max_) return translate_table[t]; else return undef_token_; diff --git a/contrib/tools/bison/data/c-like.m4 b/contrib/tools/bison/data/c-like.m4 index eb06de2a4d..26bab42eae 100644 --- a/contrib/tools/bison/data/c-like.m4 +++ b/contrib/tools/bison/data/c-like.m4 @@ -2,7 +2,7 @@ # Common code for C-like languages (C, C++, Java, etc.) -# Copyright (C) 2012-2013 Free Software Foundation, Inc. +# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/data/c-skel.m4 b/contrib/tools/bison/data/c-skel.m4 index 36904aaf7b..cb9a7a21a9 100644 --- a/contrib/tools/bison/data/c-skel.m4 +++ b/contrib/tools/bison/data/c-skel.m4 @@ -2,7 +2,8 @@ # C skeleton dispatching for Bison. -# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, +# Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/data/c.m4 b/contrib/tools/bison/data/c.m4 index b1b4394871..346b8fd30c 100644 --- a/contrib/tools/bison/data/c.m4 +++ b/contrib/tools/bison/data/c.m4 @@ -2,7 +2,7 @@ # C M4 Macros for Bison. -# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -97,7 +97,8 @@ m4_define([b4_api_PREFIX], m4_define_default([b4_prefix], [b4_api_prefix]) # If the %union is not named, its name is YYSTYPE. -m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE]) +b4_percent_define_default([[api.value.union.name]], + [b4_api_PREFIX[][STYPE]]) ## ------------------------ ## @@ -171,10 +172,10 @@ m4_define([b4_int_type], [m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], b4_ints_in($@, [-128], [127]), [1], [signed char], - b4_ints_in($@, [0], [65535]), [1], [unsigned short int], - b4_ints_in($@, [-32768], [32767]), [1], [short int], + b4_ints_in($@, [0], [65535]), [1], [unsigned short], + b4_ints_in($@, [-32768], [32767]), [1], [short], - m4_eval([0 <= $1]), [1], [unsigned int], + m4_eval([0 <= $1]), [1], [unsigned], [int])]) @@ -205,13 +206,32 @@ m4_define([b4_table_value_equals], # b4_attribute_define # ------------------- -# Provide portability for __attribute__. +# Provide portable compiler "attributes". m4_define([b4_attribute_define], -[#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ +[#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif @@ -222,7 +242,7 @@ m4_define([b4_attribute_define], # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -250,14 +270,14 @@ m4_define([b4_attribute_define], # b4_null_define # -------------- -# Portability issues: define a YY_NULL appropriate for the current +# Portability issues: define a YY_NULLPTR appropriate for the current # language (C, C++98, or C++11). m4_define([b4_null_define], -[# ifndef YY_NULL +[# ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# define YY_NULLPTR nullptr # else -# define YY_NULL 0 +# define YY_NULLPTR 0 # endif # endif[]dnl ]) @@ -266,7 +286,7 @@ m4_define([b4_null_define], # b4_null # ------- # Return a null pointer constant. -m4_define([b4_null], [YY_NULL]) +m4_define([b4_null], [YY_NULLPTR]) # b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT) # ------------------------------------------------------------- @@ -439,7 +459,8 @@ b4_syncline([@oline@], [@ofile@]) # ------------------------------------ m4_define([b4_predicate_case], [ case $1: - if (! ($2)) YYERROR; + if (! ( +$2)) YYERROR; b4_syncline([@oline@], [@ofile@]) break;]) @@ -541,15 +562,15 @@ b4_locations_if([, yylocationp])[]b4_user_args[); # b4_symbol_type_register(SYMBOL-NUM) # ----------------------------------- # Symbol SYMBOL-NUM has a type (for variant) instead of a type-tag. -# Extend the definition of %union's body with a field of that type, -# and extend the symbol's "type" field to point to the field name, -# instead of the type name. +# Extend the definition of %union's body (b4_union_members) with a +# field of that type, and extend the symbol's "type" field to point to +# the field name, instead of the type name. m4_define([b4_symbol_type_register], [m4_define([b4_symbol($1, type_tag)], [b4_symbol_if([$1], [has_id], [b4_symbol([$1], [id])], [yytype_[]b4_symbol([$1], [number])])])dnl -m4_append([b4_user_union_members], +m4_append([b4_union_members], m4_expand([ b4_symbol_tag_comment([$1])dnl b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);])) @@ -589,10 +610,9 @@ m4_copy_force([b4_symbol_value_union], [b4_symbol_value]) ]) -# ---------------- # -# api.value.type. # -# ---------------- # - +# -------------------------- # +# api.value.type = variant. # +# -------------------------- # # b4_value_type_setup_variant # --------------------------- @@ -667,11 +687,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE; [m4_bmatch(b4_percent_define_get([[api.value.type]]), [union\|union-directive], [[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED -typedef union ]b4_union_name[ ]b4_api_PREFIX[STYPE; -union ]b4_union_name[ +]b4_percent_define_get_syncline([[api.value.union.name]])[ +union ]b4_percent_define_get([[api.value.union.name]])[ { ]b4_user_union_members[ }; +]b4_percent_define_get_syncline([[api.value.union.name]])[ +typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE; # define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1 # define ]b4_api_PREFIX[STYPE_IS_DECLARED 1 #endif @@ -783,7 +805,7 @@ m4_define([b4_yy_location_print_define], /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ -__attribute__((__unused__)) +YY_ATTRIBUTE_UNUSED ]b4_function_define([yy_location_print_], [static unsigned], [[FILE *yyo], [yyo]], diff --git a/contrib/tools/bison/data/glr.cc b/contrib/tools/bison/data/glr.cc index e57308bd82..2ce14bc090 100644 --- a/contrib/tools/bison/data/glr.cc +++ b/contrib/tools/bison/data/glr.cc @@ -1,6 +1,6 @@ # C++ GLR skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -177,7 +177,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl | Print this symbol. | `--------------------*/ - inline void + void ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, const semantic_type* yyvaluep]b4_locations_if([[, const location_type* yylocationp]])[) @@ -329,7 +329,7 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]], b4_defines_if( [b4_output_begin([b4_spec_defines_file]) b4_copyright([Skeleton interface for Bison GLR parsers in C++], - [2002-2013])[ + [2002-2015, 2018])[ // C++ GLR parser skeleton written by Akim Demaille. diff --git a/contrib/tools/bison/data/lalr1.cc b/contrib/tools/bison/data/lalr1.cc index 3294f59110..143f3d4b18 100644 --- a/contrib/tools/bison/data/lalr1.cc +++ b/contrib/tools/bison/data/lalr1.cc @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -107,7 +107,7 @@ b4_dollar_pushdef([yysym.value], [m4_dquote(b4_symbol([$1], [type]))]), [yysym.location])dnl b4_symbol_case_([$1]) -b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"]) +b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])]) b4_symbol([$1], [$2]) b4_syncline([@oline@], [@ofile@]) break; @@ -131,7 +131,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])]) m4_pushdef([b4_copyright_years], - [2002-2013]) + [2002-2015, 2018]) m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])]) @@ -142,21 +142,24 @@ b4_bison_locations_if([# Backward compatibility. m4_include(b4_pkgdatadir/[stack.hh]) b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])]) -# b4_shared_declarations -# ---------------------- -# Declaration that might either go into the header (if --defines) +# b4_shared_declarations(hh|cc) +# ----------------------------- +# Declaration that might either go into the header (if --defines, $1 = hh) # or open coded in the parser body. m4_define([b4_shared_declarations], [b4_percent_code_get([[requires]])[ ]b4_parse_assert_if([# include <cassert>])[ -# include <vector> +# include <cstdlib> // std::abort # include <iostream> # include <stdexcept> -# include <string>]b4_defines_if([[ +# include <string> +# include <vector>]b4_defines_if([[ # include "stack.hh" ]b4_bison_locations_if([[# include "location.hh"]])])[ ]b4_variant_if([b4_variant_includes])[ +]b4_attribute_define[ +]b4_null_define[ ]b4_YYDEBUG_define[ ]b4_namespace_open[ @@ -183,14 +186,14 @@ b4_location_define])])[ #if ]b4_api_PREFIX[DEBUG /// The current debugging stream. - std::ostream& debug_stream () const; + std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; /// Set the current debugging stream. void set_debug_stream (std::ostream &); /// Type for debugging levels. typedef int debug_level_type; /// The current debugging level. - debug_level_type debug_level () const; + debug_level_type debug_level () const YY_ATTRIBUTE_PURE; /// Set the current debugging level. void set_debug_level (debug_level_type l); #endif @@ -213,14 +216,14 @@ b4_location_define])])[ /// Generate an error message. /// \param yystate the state where the error occurred. - /// \param yytoken the lookahead token type, or yyempty_. + /// \param yyla the lookahead token. virtual std::string yysyntax_error_ (state_type yystate, - symbol_number_type yytoken) const; + const symbol_type& yyla) const; /// Compute post-reduction state. /// \param yystate the current state - /// \param yylhs the nonterminal to push on the stack - state_type yy_lr_goto_state_ (state_type yystate, int yylhs); + /// \param yysym the nonterminal to push on the stack + state_type yy_lr_goto_state_ (state_type yystate, int yysym); /// Whether the given \c yypact_ value indicates a defaulted state. /// \param yyvalue the value to check @@ -267,7 +270,7 @@ b4_location_define])])[ /// \brief Reclaim the memory associated to a symbol. /// \param yymsg Why this token is reclaimed. /// If null, print nothing. - /// \param s The symbol. + /// \param yysym The symbol. template <typename Base> void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const; @@ -287,16 +290,21 @@ b4_location_define])])[ /// Copy constructor. by_state (const by_state& other); + /// Record that this symbol is empty. + void clear (); + /// Steal the symbol type from \a that. void move (by_state& that); /// The (internal) type number (corresponding to \a state). - /// "empty" when empty. + /// \a empty_symbol when empty. symbol_number_type type_get () const; - enum { empty = 0 }; + /// The state number used to denote an empty symbol. + enum { empty_state = -1 }; /// The state. + /// \a empty when empty. state_type state; }; @@ -307,6 +315,8 @@ b4_location_define])])[ typedef basic_symbol<by_state> super_type; /// Construct an empty symbol. stack_symbol_type (); + /// Copy construct (for efficiency). + stack_symbol_type (const stack_symbol_type& that); /// Steal the contents from \a sym to build this. stack_symbol_type (state_type s, symbol_type& sym); /// Assignment, needed by push_back. @@ -335,26 +345,25 @@ b4_location_define])])[ void yypush_ (const char* m, state_type s, symbol_type& sym); /// Pop \a n symbols the three stacks. - void yypop_ (unsigned int n = 1); + void yypop_ (unsigned n = 1); - // Constants. + /// Constants. enum { yyeof_ = 0, - yylast_ = ]b4_last[, //< Last index in yytable_. - yynnts_ = ]b4_nterms_number[, //< Number of nonterminal symbols. - yyempty_ = -2, - yyfinal_ = ]b4_final_state_number[, //< Termination state number. + yylast_ = ]b4_last[, ///< Last index in yytable_. + yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols. + yyfinal_ = ]b4_final_state_number[, ///< Termination state number. yyterror_ = 1, yyerrcode_ = 256, - yyntokens_ = ]b4_tokens_number[ //< Number of tokens. + yyntokens_ = ]b4_tokens_number[ ///< Number of tokens. }; ]b4_parse_param_vars[ }; -]b4_token_ctor_if([b4_yytranslate_define -b4_public_types_define])[ +]b4_token_ctor_if([b4_yytranslate_define([$1])[ +]b4_public_types_define([$1])])[ ]b4_namespace_close[ ]b4_percent_define_flag_if([[global_tokens_and_yystype]], @@ -380,7 +389,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) // C++ LALR(1) parser skeleton written by Akim Demaille. ]b4_cpp_guard_open([b4_spec_defines_file])[ -]b4_shared_declarations[ +]b4_shared_declarations(hh)[ ]b4_cpp_guard_close([b4_spec_defines_file]) b4_output_end() ]) @@ -400,7 +409,7 @@ m4_if(b4_prefix, [yy], [], ]b4_null_define[ ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], - [b4_shared_declarations])[ + [b4_shared_declarations([cc])])[ // User implementation prologue. ]b4_user_post_prologue[ @@ -418,6 +427,15 @@ m4_if(b4_prefix, [yy], [], # endif #endif +// Whether we are compiled with exception support. +#ifndef YY_EXCEPTIONS +# if defined __GNUC__ && !defined __EXCEPTIONS +# define YY_EXCEPTIONS 0 +# else +# define YY_EXCEPTIONS 1 +# endif +#endif + ]b4_locations_if([dnl [#define YYRHSLOC(Rhs, K) ((Rhs)[K].location) ]b4_yylloc_default_define])[ @@ -437,7 +455,7 @@ m4_if(b4_prefix, [yy], [], { \ *yycdebug_ << Title << ' '; \ yy_print_ (*yycdebug_, Symbol); \ - *yycdebug_ << std::endl; \ + *yycdebug_ << '\n'; \ } \ } while (false) @@ -456,14 +474,14 @@ m4_if(b4_prefix, [yy], [], #else // !]b4_api_PREFIX[DEBUG # define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol) -# define YY_REDUCE_PRINT(Rule) static_cast<void>(0) -# define YY_STACK_PRINT() static_cast<void>(0) +# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE (Symbol) +# define YY_REDUCE_PRINT(Rule) static_cast<void> (0) +# define YY_STACK_PRINT() static_cast<void> (0) #endif // !]b4_api_PREFIX[DEBUG #define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yyempty = true) +#define yyclearin (yyla.clear ()) #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -527,56 +545,63 @@ m4_if(b4_prefix, [yy], [], | Symbol types. | `---------------*/ -]b4_token_ctor_if([], [b4_public_types_define])[ +]b4_token_ctor_if([], [b4_public_types_define([cc])])[ // by_state. - inline ]b4_parser_class_name[::by_state::by_state () - : state (empty) + : state (empty_state) {} - inline ]b4_parser_class_name[::by_state::by_state (const by_state& other) : state (other.state) {} - inline + void + ]b4_parser_class_name[::by_state::clear () + { + state = empty_state; + } + void ]b4_parser_class_name[::by_state::move (by_state& that) { state = that.state; - that.state = empty; + that.clear (); } - inline ]b4_parser_class_name[::by_state::by_state (state_type s) : state (s) {} - inline ]b4_parser_class_name[::symbol_number_type ]b4_parser_class_name[::by_state::type_get () const { - return state == empty ? 0 : yystos_[state]; + if (state == empty_state) + return empty_symbol; + else + return yystos_[state]; } - inline ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type () {} - - inline - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) - : super_type (s]b4_locations_if([, that.location])[) + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that) + : super_type (that.state]b4_locations_if([, that.location])[) { ]b4_variant_if([b4_symbol_variant([that.type_get ()], - [value], [move], [that.value])], + [value], [copy], [that.value])], [[value = that.value;]])[ + } + + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) + : super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, that.location])[) + {]b4_variant_if([ + b4_symbol_variant([that.type_get ()], + [value], [move], [that.value])])[ // that is emptied. - that.type = empty; + that.type = empty_symbol; } - inline ]b4_parser_class_name[::stack_symbol_type& ]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that) { @@ -590,7 +615,6 @@ m4_if(b4_prefix, [yy], [], template <typename Base> - inline void ]b4_parser_class_name[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const { @@ -610,6 +634,10 @@ m4_if(b4_prefix, [yy], [], std::ostream& yyoutput = yyo; YYUSE (yyoutput); symbol_number_type yytype = yysym.type_get (); + // Avoid a (spurious) G++ 4.8 warning about "array subscript is + // below array bounds". + if (yysym.empty ()) + std::abort (); yyo << (yytype < yyntokens_ ? "token" : "nterm") << ' ' << yytname_[yytype] << " ("]b4_locations_if([ << yysym.location << ": "])[; @@ -618,7 +646,6 @@ m4_if(b4_prefix, [yy], [], } #endif - inline void ]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym) { @@ -626,7 +653,6 @@ m4_if(b4_prefix, [yy], [], yypush_ (m, t); } - inline void ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s) { @@ -635,9 +661,8 @@ m4_if(b4_prefix, [yy], [], yystack_.push (s); } - inline void - ]b4_parser_class_name[::yypop_ (unsigned int n) + ]b4_parser_class_name[::yypop_ (unsigned n) { yystack_.pop (n); } @@ -669,23 +694,23 @@ m4_if(b4_prefix, [yy], [], } #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) + ]b4_parser_class_name[::state_type + ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yysym) { - int yyr = yypgoto_[yylhs - yyntokens_] + yystate; + int yyr = yypgoto_[yysym - yyntokens_] + yystate; if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) return yytable_[yyr]; else - return yydefgoto_[yylhs - yyntokens_]; + return yydefgoto_[yysym - yyntokens_]; } - inline bool + bool ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) { return yyvalue == yypact_ninf_; } - inline bool + bool ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) { return yyvalue == yytable_ninf_; @@ -694,11 +719,9 @@ m4_if(b4_prefix, [yy], [], int ]b4_parser_class_name[::parse () { - /// Whether yyla contains a lookahead. - bool yyempty = true; - // State. int yyn; + /// Length of the RHS of the rule being reduced. int yylen = 0; // Error handling. @@ -711,17 +734,14 @@ m4_if(b4_prefix, [yy], [], /// The locations where the error started and ended. stack_symbol_type yyerror_range[3];]])[ - /// $$ and @@$. - stack_symbol_type yylhs; - /// The return value of parse (). int yyresult; - // FIXME: This shoud be completely indented. It is not yet to - // avoid gratuitous conflicts when merging into the master branch. +#if YY_EXCEPTIONS try +#endif // YY_EXCEPTIONS { - YYCDEBUG << "Starting parse" << std::endl; + YYCDEBUG << "Starting parse\n"; ]m4_ifdef([b4_initial_action], [ b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl @@ -734,11 +754,11 @@ b4_dollar_popdef])[]dnl location values to have been already stored, initialize these stacks with a primary value. */ yystack_.clear (); - yypush_ (YY_NULL, 0, yyla); + yypush_ (YY_NULLPTR, 0, yyla); // A new symbol was pushed on the stack. yynewstate: - YYCDEBUG << "Entering state " << yystack_[0].state << std::endl; + YYCDEBUG << "Entering state " << yystack_[0].state << '\n'; // Accept? if (yystack_[0].state == yyfinal_) @@ -748,28 +768,30 @@ b4_dollar_popdef])[]dnl // Backup. yybackup: - // Try to take a decision without lookahead. yyn = yypact_[yystack_[0].state]; if (yy_pact_value_is_default_ (yyn)) goto yydefault; // Read a lookahead token. - if (yyempty) + if (yyla.empty ()) { YYCDEBUG << "Reading a token: "; +#if YY_EXCEPTIONS try +#endif // YY_EXCEPTIONS {]b4_token_ctor_if([[ symbol_type yylookahead (]b4_lex[); yyla.move (yylookahead);]], [[ yyla.type = yytranslate_ (]b4_lex[);]])[ } +#if YY_EXCEPTIONS catch (const syntax_error& yyexc) { error (yyexc); goto yyerrlab1; } - yyempty = false; +#endif // YY_EXCEPTIONS } YY_SYMBOL_PRINT ("Next token is", yyla); @@ -789,9 +811,6 @@ b4_dollar_popdef])[]dnl goto yyreduce; } - // Discard the token being shifted. - yyempty = true; - // Count tokens shifted since error; after three, turn off error status. if (yyerrstatus_) --yyerrstatus_; @@ -814,52 +833,60 @@ b4_dollar_popdef])[]dnl `-----------------------------*/ yyreduce: yylen = yyr2_[yyn]; - yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ - /* Variants are always initialized to an empty instance of the - correct type. The default $$=$1 action is NOT applied when using - variants. */ - b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])],[ - /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. Otherwise, use the top of the stack. - - Otherwise, the following line sets YYLHS.VALUE to garbage. - This behavior is undocumented and Bison - users should not rely upon it. */ - if (yylen) - yylhs.value = yystack_@{yylen - 1@}.value; - else - yylhs.value = yystack_@{0@}.value;])[ + { + stack_symbol_type yylhs; + yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ + /* Variants are always initialized to an empty instance of the + correct type. The default '$$ = $1' action is NOT applied + when using variants. */ + b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])], [ + /* If YYLEN is nonzero, implement the default value of the + action: '$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYLHS.VALUE to garbage. + This behavior is undocumented and Bison users should not rely + upon it. */ + if (yylen) + yylhs.value = yystack_@{yylen - 1@}.value; + else + yylhs.value = yystack_@{0@}.value;])[ ]b4_locations_if([dnl [ - // Compute the default @@$. - { - slice<stack_symbol_type, stack_type> slice (yystack_, yylen); - YYLLOC_DEFAULT (yylhs.location, slice, yylen); - }]])[ - - // Perform the reduction. - YY_REDUCE_PRINT (yyn); - try + // Default location. { - switch (yyn) - { + slice<stack_symbol_type, stack_type> slice (yystack_, yylen); + YYLLOC_DEFAULT (yylhs.location, slice, yylen); + yyerror_range[1].location = yylhs.location; + }]])[ + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); +#if YY_EXCEPTIONS + try +#endif // YY_EXCEPTIONS + { + switch (yyn) + { ]b4_user_actions[ - default: - break; - } - } - catch (const syntax_error& yyexc) - { - error (yyexc); - YYERROR; - } - YY_SYMBOL_PRINT ("-> $$ =", yylhs); - yypop_ (yylen); - yylen = 0; - YY_STACK_PRINT (); - - // Shift the result of the reduction. - yypush_ (YY_NULL, yylhs); + default: + break; + } + } +#if YY_EXCEPTIONS + catch (const syntax_error& yyexc) + { + error (yyexc); + YYERROR; + } +#endif // YY_EXCEPTIONS + YY_SYMBOL_PRINT ("-> $$ =", yylhs); + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + // Shift the result of the reduction. + yypush_ (YY_NULLPTR, yylhs); + } goto yynewstate; /*--------------------------------------. @@ -871,8 +898,7 @@ b4_dollar_popdef])[]dnl { ++yynerrs_; error (]b4_join(b4_locations_if([yyla.location]), - [[yysyntax_error_ (yystack_[0].state, - yyempty ? yyempty_ : yyla.type_get ())]])[); + [[yysyntax_error_ (yystack_[0].state, yyla)]])[); } ]b4_locations_if([[ @@ -885,10 +911,10 @@ b4_dollar_popdef])[]dnl // Return failure if at end of input. if (yyla.type_get () == yyeof_) YYABORT; - else if (!yyempty) + else if (!yyla.empty ()) { yy_destroy_ ("Error: discarding", yyla); - yyempty = true; + yyla.clear (); } } @@ -905,11 +931,7 @@ b4_dollar_popdef])[]dnl YYERROR and the label yyerrorlab therefore never appears in user code. */ if (false) - goto yyerrorlab;]b4_locations_if([[ - yyerror_range[1].location = yystack_[yylen - 1].location;]])b4_variant_if([[ - /* $$ was initialized before running the user action. */ - YY_SYMBOL_PRINT ("Error: discarding", yylhs); - yylhs.~stack_symbol_type();]])[ + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ yypop_ (yylen); @@ -967,7 +989,7 @@ b4_dollar_popdef])[]dnl goto yyreturn; yyreturn: - if (!yyempty) + if (!yyla.empty ()) yy_destroy_ ("Cleanup: discarding lookahead", yyla); /* Do not reclaim the symbols of the rule whose action triggered @@ -981,38 +1003,38 @@ b4_dollar_popdef])[]dnl return yyresult; } +#if YY_EXCEPTIONS catch (...) { - YYCDEBUG << "Exception caught: cleaning lookahead and stack" - << std::endl; + YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; // Do not try to display the values of the reclaimed symbols, - // as their printer might throw an exception. - if (!yyempty) - yy_destroy_ (YY_NULL, yyla); + // as their printers might throw an exception. + if (!yyla.empty ()) + yy_destroy_ (YY_NULLPTR, yyla); while (1 < yystack_.size ()) { - yy_destroy_ (YY_NULL, yystack_[0]); + yy_destroy_ (YY_NULLPTR, yystack_[0]); yypop_ (); } throw; } +#endif // YY_EXCEPTIONS } void ]b4_parser_class_name[::error (const syntax_error& yyexc) { error (]b4_join(b4_locations_if([yyexc.location]), - [[yyexc.what()]])[); + [[yyexc.what ()]])[); } // Generate an error message. std::string ]b4_parser_class_name[::yysyntax_error_ (]dnl -b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], - [state_type, symbol_number_type])[) const +b4_error_verbose_if([state_type yystate, const symbol_type& yyla], + [state_type, const symbol_type&])[) const {]b4_error_verbose_if([[ - std::string yyres; // Number of reported tokens (one for the "unexpected", one per // "expected"). size_t yycount = 0; @@ -1026,7 +1048,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - - The only way there can be no lookahead present (in yytoken) is + - The only way there can be no lookahead present (in yyla) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to @@ -1046,8 +1068,9 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], token that will not be accepted due to an error action in a later state. */ - if (yytoken != yyempty_) + if (!yyla.empty ()) { + int yytoken = yyla.type_get (); yyarg[yycount++] = yytname_[yytoken]; int yyn = yypact_[yystate]; if (!yy_pact_value_is_default_ (yyn)) @@ -1074,22 +1097,24 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], } } - char const* yyformat = YY_NULL; + char const* yyformat = YY_NULLPTR; switch (yycount) { #define YYCASE_(N, S) \ case N: \ yyformat = S; \ break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); + default: // Avoid compiler warnings. + YYCASE_ (0, YY_("syntax error")); + YYCASE_ (1, YY_("syntax error, unexpected %s")); + YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); #undef YYCASE_ } + std::string yyres; // Argument number. size_t yyi = 0; for (char const* yyp = yyformat; *yyp; ++yyp) @@ -1133,18 +1158,18 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], i_end = yystack_.end (); i != i_end; ++i) *yycdebug_ << ' ' << i->state; - *yycdebug_ << std::endl; + *yycdebug_ << '\n'; } // Report on the debug stream that the rule \a yyrule is going to be reduced. void ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) { - unsigned int yylno = yyrline_[yyrule]; + unsigned yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; // Print the symbols being reduced, and their result. *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):" << std::endl; + << " (line " << yylno << "):\n"; // The symbols being reduced. for (int yyi = 0; yyi < yynrhs; yyi++) YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", @@ -1152,7 +1177,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], } #endif // ]b4_api_PREFIX[DEBUG -]b4_token_ctor_if([], [b4_yytranslate_define])[ +]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[ ]b4_namespace_close[ ]b4_epilogue[]dnl b4_output_end() diff --git a/contrib/tools/bison/data/location.cc b/contrib/tools/bison/data/location.cc index 9a60f2503f..07f1ca62fb 100644 --- a/contrib/tools/bison/data/location.cc +++ b/contrib/tools/bison/data/location.cc @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2013]) + [2002-2015, 2018]) # b4_position_define # ------------------ @@ -27,20 +27,19 @@ m4_define([b4_position_define], { public:]m4_ifdef([b4_location_constructors], [[ /// Construct a position. - explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULL, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) : filename (f) , line (l) , column (c) - { - } + {} ]])[ /// Initialization. - void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR, + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) { filename = fn; line = l; @@ -69,21 +68,19 @@ m4_define([b4_position_define], /// File name to which this position refers. ]b4_percent_define_get([[filename_type]])[* filename; /// Current line number. - unsigned int line; + unsigned line; /// Current column number. - unsigned int column; + unsigned column; private: - /// Compute max(min, lhs+rhs) (provided min <= lhs). - static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min) + /// Compute max(min, lhs+rhs). + static unsigned add_ (unsigned lhs, int rhs, int min) { - return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs - ? rhs + lhs - : min); + return static_cast<unsigned>(std::max(min, static_cast<int>(lhs) + rhs)); } }; - /// Add and assign a position. + /// Add \a width columns, in place. inline position& operator+= (position& res, int width) { @@ -91,21 +88,21 @@ m4_define([b4_position_define], return res; } - /// Add two position objects. + /// Add \a width columns. inline position operator+ (position res, int width) { return res += width; } - /// Add and assign a position. + /// Subtract \a width columns, in place. inline position& operator-= (position& res, int width) { return res += -width; } - /// Add two position objects. + /// Subtract \a width columns. inline position operator- (position res, int width) { @@ -135,7 +132,7 @@ m4_define([b4_position_define], ** \param pos a reference to the position to redirect */ template <typename YYChar> - inline std::basic_ostream<YYChar>& + std::basic_ostream<YYChar>& operator<< (std::basic_ostream<YYChar>& ostr, const position& pos) { if (pos.filename) @@ -157,30 +154,27 @@ m4_define([b4_location_define], location (const position& b, const position& e) : begin (b) , end (e) - { - } + {} /// Construct a 0-width location in \a p. explicit location (const position& p = position ()) : begin (p) , end (p) - { - } + {} /// Construct a 0-width location in \a f, \a l, \a c. explicit location (]b4_percent_define_get([[filename_type]])[* f, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) : begin (f, l, c) , end (f, l, c) - { - } + {} ])[ /// Initialization. - void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULL, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) { begin.initialize (f, l, c); end = begin; @@ -216,36 +210,42 @@ m4_define([b4_location_define], position end; }; - /// Join two location objects to create a location. - inline location operator+ (location res, const location& end) + /// Join two locations, in place. + inline location& operator+= (location& res, const location& end) { res.end = end.end; return res; } - /// Change end position in place. + /// Join two locations. + inline location operator+ (location res, const location& end) + { + return res += end; + } + + /// Add \a width columns to the end position, in place. inline location& operator+= (location& res, int width) { res.columns (width); return res; } - /// Change end position. + /// Add \a width columns to the end position. inline location operator+ (location res, int width) { return res += width; } - /// Change end position in place. + /// Subtract \a width columns to the end position, in place. inline location& operator-= (location& res, int width) { return res += -width; } - /// Change end position. - inline location operator- (const location& begin, int width) + /// Subtract \a width columns to the end position. + inline location operator- (location res, int width) { - return begin + -width; + return res -= width; } ]b4_percent_define_flag_if([[define_location_comparison]], [[ /// Compare two location objects. @@ -269,12 +269,11 @@ m4_define([b4_location_define], ** Avoid duplicate information. */ template <typename YYChar> - inline std::basic_ostream<YYChar>& + std::basic_ostream<YYChar>& operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) { - unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; - ostr << loc.begin// << "(" << loc.end << ") " -; + unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; + ostr << loc.begin; if (loc.end.filename && (!loc.begin.filename || *loc.begin.filename != *loc.end.filename)) diff --git a/contrib/tools/bison/data/m4sugar/foreach.m4 b/contrib/tools/bison/data/m4sugar/foreach.m4 index f6a6394472..7093d0fcc4 100644 --- a/contrib/tools/bison/data/m4sugar/foreach.m4 +++ b/contrib/tools/bison/data/m4sugar/foreach.m4 @@ -4,7 +4,7 @@ # Speeds up GNU M4 1.4.x by avoiding quadratic $@ recursion, but penalizes # GNU M4 1.6 by requiring more memory and macro expansions. # -# Copyright (C) 2008-2013 Free Software Foundation, Inc. +# Copyright (C) 2008-2017 Free Software Foundation, Inc. # This file is part of Autoconf. This program is free # software; you can redistribute it and/or modify it under the @@ -24,7 +24,7 @@ # You should have received a copy of the GNU General Public License # and a copy of the Autoconf Configure Script Exception along with # this program; see the files COPYINGv3 and COPYING.EXCEPTION -# respectively. If not, see <http://www.gnu.org/licenses/>. +# respectively. If not, see <https://www.gnu.org/licenses/>. # Written by Eric Blake. diff --git a/contrib/tools/bison/data/m4sugar/m4sugar.m4 b/contrib/tools/bison/data/m4sugar/m4sugar.m4 index b732abc789..bbd695836a 100644 --- a/contrib/tools/bison/data/m4sugar/m4sugar.m4 +++ b/contrib/tools/bison/data/m4sugar/m4sugar.m4 @@ -3,7 +3,7 @@ divert(-1)# -*- Autoconf -*- # Base M4 layer. # Requires GNU M4. # -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # This file is part of Autoconf. This program is free # software; you can redistribute it and/or modify it under the @@ -23,7 +23,7 @@ divert(-1)# -*- Autoconf -*- # You should have received a copy of the GNU General Public License # and a copy of the Autoconf Configure Script Exception along with # this program; see the files COPYINGv3 and COPYING.EXCEPTION -# respectively. If not, see <http://www.gnu.org/licenses/>. +# respectively. If not, see <https://www.gnu.org/licenses/>. # Written by Akim Demaille. @@ -2000,7 +2000,7 @@ m4_define([_m4_defun_once], # m4_pattern_forbid(ERE, [WHY]) # ----------------------------- -# Declare that no token matching the forbidden extended regular +# Declare that no token matching the forbidden perl extended regular # expression ERE should be seen in the output unless... m4_define([m4_pattern_forbid], []) @@ -2008,7 +2008,7 @@ m4_define([m4_pattern_forbid], []) # m4_pattern_allow(ERE) # --------------------- # ... that token also matches the allowed extended regular expression ERE. -# Both used via traces. +# Both used via traces, by autom4te post-processing. m4_define([m4_pattern_allow], []) @@ -2107,7 +2107,7 @@ m4_define([_m4_require_check], [m4_if(_m4_defn([_m4_diverting]), [$2], [m4_ignore], m4_ifdef([_m4_diverting([$2])], [-]), [-], [m4_warn([syntax], [$3: `$1' was expanded before it was required -http://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required])_m4_require_call], +https://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required])_m4_require_call], [m4_ignore])]) @@ -3126,7 +3126,8 @@ m4_define([m4_set_empty], # guaranteed. This is faster than the corresponding m4_foreach([VAR], # m4_indir([m4_dquote]m4_set_listc([SET])), [ACTION]) m4_define([m4_set_foreach], -[m4_pushdef([$2])m4_set_map_sep([$1], [m4_define([$2],], [)$3])]) +[m4_pushdef([$2])m4_set_map_sep([$1], +[m4_define([$2],], [)$3])m4_popdef([$2])]) # m4_set_intersection(SET1, SET2) # ------------------------------- diff --git a/contrib/tools/bison/data/stack.hh b/contrib/tools/bison/data/stack.hh index aa64d63d84..f3ac21f949 100644 --- a/contrib/tools/bison/data/stack.hh +++ b/contrib/tools/bison/data/stack.hh @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,39 +16,44 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2013]) + [2002-2015, 2018]) # b4_stack_define # --------------- m4_define([b4_stack_define], -[[ template <class T, class S = std::vector<T> > +[[ /// A stack with random access from its top. + template <class T, class S = std::vector<T> > class stack { public: // Hide our reversed order. typedef typename S::reverse_iterator iterator; typedef typename S::const_reverse_iterator const_iterator; + typedef typename S::size_type size_type; stack () - : seq_ () { + seq_.reserve (200); } - stack (unsigned int n) + stack (size_type n) : seq_ (n) - { - } + {} - inline + /// Random access. + /// + /// Index 0 returns the topmost element. T& - operator[] (unsigned int i) + operator[] (size_type i) { return seq_[seq_.size () - 1 - i]; } - inline + /// Random access. + /// + /// Index 0 returns the topmost element. const T& - operator[] (unsigned int i) const + operator[] (size_type i) const { return seq_[seq_.size () - 1 - i]; } @@ -56,7 +61,6 @@ m4_define([b4_stack_define], /// Steal the contents of \a t. /// /// Close to move-semantics. - inline void push (T& t) { @@ -64,9 +68,8 @@ m4_define([b4_stack_define], operator[](0).move (t); } - inline void - pop (unsigned int n = 1) + pop (size_type n = 1) { for (; n; --n) seq_.pop_back (); @@ -78,21 +81,18 @@ m4_define([b4_stack_define], seq_.clear (); } - inline - typename S::size_type + size_type size () const { return seq_.size (); } - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { @@ -111,22 +111,21 @@ m4_define([b4_stack_define], class slice { public: - slice (const S& stack, unsigned int range) + typedef typename S::size_type size_type; + slice (const S& stack, size_type range) : stack_ (stack) , range_ (range) - { - } + {} - inline const T& - operator [] (unsigned int i) const + operator[] (size_type i) const { return stack_[range_ - i]; } private: const S& stack_; - unsigned int range_; + size_type range_; }; ]]) diff --git a/contrib/tools/bison/data/variant.hh b/contrib/tools/bison/data/variant.hh index ac4f7a7850..8d0f06f6e3 100644 --- a/contrib/tools/bison/data/variant.hh +++ b/contrib/tools/bison/data/variant.hh @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ m4_define([b4_symbol_variant], [m4_pushdef([b4_dollar_dollar], [$2.$3< $][3 > (m4_shift3($@))])dnl - switch ($1) +switch ($1) { b4_type_foreach([b4_type_action_])[]dnl default: @@ -94,14 +94,15 @@ m4_define([b4_variant_define], typedef variant<S> self_type; /// Empty construction. - variant ()]b4_parse_assert_if([ - : yytname_ (YY_NULL)])[ + variant () + : yybuffer_ ()]b4_parse_assert_if([ + , yytypeid_ (YY_NULLPTR)])[ {} /// Construct and fill. template <typename T> variant (const T& t)]b4_parse_assert_if([ - : yytname_ (typeid (T).name ())])[ + : yytypeid_ (&typeid (T))])[ { YYASSERT (sizeof (T) <= S); new (yyas_<T> ()) T (t); @@ -110,7 +111,7 @@ m4_define([b4_variant_define], /// Destruction, allowed only if empty. ~variant () {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); ])[} /// Instantiate an empty \a T in here. @@ -118,10 +119,10 @@ m4_define([b4_variant_define], T& build () {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); YYASSERT (sizeof (T) <= S); - yytname_ = typeid (T).name ();])[ - return *new (yyas_<T> ()) T; + yytypeid_ = & typeid (T);])[ + return *new (yyas_<T> ()) T (); } /// Instantiate a \a T in here from \a t. @@ -129,9 +130,9 @@ m4_define([b4_variant_define], T& build (const T& t) {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); YYASSERT (sizeof (T) <= S); - yytname_ = typeid (T).name ();])[ + yytypeid_ = & typeid (T);])[ return *new (yyas_<T> ()) T (t); } @@ -140,7 +141,8 @@ m4_define([b4_variant_define], T& as () {]b4_parse_assert_if([ - YYASSERT (yytname_ == typeid (T).name ()); + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (sizeof (T) <= S);])[ return *yyas_<T> (); } @@ -150,7 +152,8 @@ m4_define([b4_variant_define], const T& as () const {]b4_parse_assert_if([ - YYASSERT (yytname_ == typeid (T).name ()); + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (sizeof (T) <= S);])[ return *yyas_<T> (); } @@ -167,8 +170,8 @@ m4_define([b4_variant_define], void swap (self_type& other) {]b4_parse_assert_if([ - YYASSERT (yytname_); - YYASSERT (yytname_ == other.yytname_);])[ + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == *other.yytypeid_);])[ std::swap (as<T> (), other.as<T> ()); } @@ -178,8 +181,7 @@ m4_define([b4_variant_define], template <typename T> void move (self_type& other) - {]b4_parse_assert_if([ - YYASSERT (!yytname_);])[ + { build<T> (); swap<T> (other); other.destroy<T> (); @@ -199,7 +201,7 @@ m4_define([b4_variant_define], destroy () { as<T> ().~T ();]b4_parse_assert_if([ - yytname_ = YY_NULL;])[ + yytypeid_ = YY_NULLPTR;])[ } private: @@ -234,7 +236,7 @@ m4_define([b4_variant_define], } yybuffer_;]b4_parse_assert_if([ /// Whether the content is built: if defined, the name of the stored type. - const char *yytname_;])[ + const std::type_info *yytypeid_;])[ }; ]]) @@ -321,7 +323,6 @@ b4_join(b4_symbol_if([$1], [has_type], return symbol_type (b4_join([token::b4_symbol([$1], [id])], b4_symbol_if([$1], [has_type], [v]), b4_locations_if([l]))); - } ])])]) @@ -334,7 +335,7 @@ m4_define([b4_basic_symbol_constructor_declare], [[ basic_symbol (]b4_join( [typename Base::kind_type t], - b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[ v]), + b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]), b4_locations_if([const location_type& l]))[); ]]) @@ -346,10 +347,10 @@ m4_define([b4_basic_symbol_constructor_define], template <typename Base> ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], - b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[ v]), + b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]), b4_locations_if([const location_type& l]))[) - : Base (t) - , value (]b4_symbol_if([$1], [has_type], [v])[)]b4_locations_if([ + : Base (t)]b4_symbol_if([$1], [has_type], [ + , value (v)])[]b4_locations_if([ , location (l)])[ {} ]]) diff --git a/contrib/tools/bison/data/yacc.c b/contrib/tools/bison/data/yacc.c index 822656b8d8..e72b098b7a 100644 --- a/contrib/tools/bison/data/yacc.c +++ b/contrib/tools/bison/data/yacc.c @@ -1,11 +1,11 @@ -*- C -*- # Yacc compatible skeleton for Bison -# Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, -# Inc. +# Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software +# Foundation, Inc. m4_pushdef([b4_copyright_years], - [1984, 1989-1990, 2000-2013]) + [1984, 1989-1990, 2000-2015, 2018]) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -118,7 +118,7 @@ m4_define([b4_int_type], b4_ints_in($@, [0], [65535]), [1], [yytype_uint16], b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16], - m4_eval([0 <= $1]), [1], [unsigned int], + m4_eval([0 <= $1]), [1], [unsigned], [int])]) @@ -377,13 +377,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -395,7 +395,7 @@ typedef short int yytype_int16; # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -571,7 +571,7 @@ union yyalloc #define YYMAXUTOK ]b4_user_token_number_max[ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ @@ -719,7 +719,7 @@ do { \ ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, b4_parse_param]))[ { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -827,7 +827,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]), [full], [[ YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix, - (unsigned long int) yyalloc, yydebug_suffix));]])[ + (unsigned long) yyalloc, yydebug_suffix));]])[ } return 0; } @@ -1108,11 +1108,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes, YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1187,7 +1187,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1207,6 +1207,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1271,7 +1272,7 @@ static char yypstate_allocated = 0;]])b4_pull_if([ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ { - return yypull_parse (YY_NULL]m4_ifset([b4_parse_param], + return yypull_parse (YY_NULLPTR]m4_ifset([b4_parse_param], [[, ]b4_args(b4_parse_param)])[); } @@ -1313,10 +1314,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ { yypstate *yyps;]b4_pure_if([], [[ if (yypstate_allocated) - return YY_NULL;]])[ + return YY_NULLPTR;]])[ yyps = (yypstate *) malloc (sizeof *yyps); if (!yyps) - return YY_NULL; + return YY_NULLPTR; yyps->yynew = 1;]b4_pure_if([], [[ yypstate_allocated = 1;]])[ return yyps; @@ -1325,16 +1326,19 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ ]b4_function_define([[yypstate_delete]], [[void]], [[[yypstate *yyps]], [[yyps]]])[ { + if (yyps) + { #ifndef yyoverflow - /* If the stack was reallocated but the parse did not complete, then the - stack still needs to be freed. */ - if (!yyps->yynew && yyps->yyss != yyps->yyssa) - YYSTACK_FREE (yyps->yyss); + /* If the stack was reallocated but the parse did not complete, then the + stack still needs to be freed. */ + if (!yyps->yynew && yyps->yyss != yyps->yyssa) + YYSTACK_FREE (yyps->yyss); #endif]b4_lac_if([[ - if (!yyps->yynew && yyps->yyes != yyps->yyesa) - YYSTACK_FREE (yyps->yyes);]])[ - free (yyps);]b4_pure_if([], [[ - yypstate_allocated = 0;]])[ + if (!yyps->yynew && yyps->yyes != yyps->yyesa) + YYSTACK_FREE (yyps->yyes);]])[ + free (yyps);]b4_pure_if([], [[ + yypstate_allocated = 0;]])[ + } } ]b4_pure_if([[ #define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[ @@ -1509,7 +1513,7 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo yylsp = yyls + yysize - 1;])[ YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; @@ -1641,8 +1645,9 @@ yyreduce: yyval = yyvsp[1-yylen]; ]b4_locations_if( -[[ /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[ +[[ /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc;]])[ YY_REDUCE_PRINT (yyn);]b4_lac_if([[ { int yychar_backup = yychar; @@ -1782,8 +1787,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; -]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen]; -]])[ /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; |