aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/bison/data/skeletons
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-08-11 11:42:23 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-08-11 11:54:06 +0300
commitcd788243496b69e548998f9e3f9ff80e34977652 (patch)
tree0fd50f566b69bc2cfd0d9c4c18eea1b77d5ec276 /contrib/tools/bison/data/skeletons
parentc7230d56fb1b7998da0edb829f1751640da9c8b4 (diff)
downloadydb-cd788243496b69e548998f9e3f9ff80e34977652.tar.gz
Update contrib/tools/bison to 3.7.6
583623e1fb299df0a04a0aecdc47eb759ef412b9
Diffstat (limited to 'contrib/tools/bison/data/skeletons')
-rw-r--r--contrib/tools/bison/data/skeletons/bison.m460
-rw-r--r--contrib/tools/bison/data/skeletons/c++-skel.m44
-rw-r--r--contrib/tools/bison/data/skeletons/c++.m430
-rw-r--r--contrib/tools/bison/data/skeletons/c-like.m44
-rw-r--r--contrib/tools/bison/data/skeletons/c-skel.m44
-rw-r--r--contrib/tools/bison/data/skeletons/c.m473
-rw-r--r--contrib/tools/bison/data/skeletons/glr.cc66
-rw-r--r--contrib/tools/bison/data/skeletons/lalr1.cc59
-rw-r--r--contrib/tools/bison/data/skeletons/location.cc24
-rw-r--r--contrib/tools/bison/data/skeletons/stack.hh6
-rw-r--r--contrib/tools/bison/data/skeletons/variant.hh146
-rw-r--r--contrib/tools/bison/data/skeletons/yacc.c202
12 files changed, 394 insertions, 284 deletions
diff --git a/contrib/tools/bison/data/skeletons/bison.m4 b/contrib/tools/bison/data/skeletons/bison.m4
index 637d2fcbf2..12946c6917 100644
--- a/contrib/tools/bison/data/skeletons/bison.m4
+++ b/contrib/tools/bison/data/skeletons/bison.m4
@@ -2,7 +2,7 @@
# Language-independent M4 Macros for Bison.
-# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
+# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation,
# Inc.
# This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
@@ -38,6 +38,8 @@ m4_define([b4_gsub],
[$4], [$5]),
[$6], [$7])])
+# m4_shift2 and m4_shift3 are provided by m4sugar.
+m4_define([m4_shift4], [m4_shift(m4_shift(m4_shift(m4_shift($@))))])
## ---------------- ##
@@ -47,7 +49,7 @@ m4_define([b4_gsub],
# b4_generated_by
# ---------------
m4_define([b4_generated_by],
-[b4_comment([A Bison parser, made by GNU Bison b4_version.])
+[b4_comment([A Bison parser, made by GNU Bison b4_version_string.])
])
# b4_copyright(TITLE, [YEARS])
@@ -72,7 +74,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.])
+along with this program. If not, see <https://www.gnu.org/licenses/>.])
b4_comment([As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -183,7 +185,7 @@ m4_define([b4_error],
[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl
[m4_if([$#], [4], [],
[m4_foreach([b4_arg],
- m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
+ m4_dquote(m4_shift4($@)),
[[@,]b4_arg])])[@)]])])
# b4_warn(FORMAT, [ARG1], [ARG2], ...)
@@ -436,14 +438,14 @@ m4_define([b4_symbol_token_kind],
_b4_symbol([$1], [id])])
-# b4_symbol_kind(NUM)
-# -------------------
+# b4_symbol_kind_base(NUM)
+# ------------------------
# Build the name of the kind of this symbol. It must always exist,
# otherwise some symbols might not be represented in the enum, which
# might be compiled into too small a type to contain all the symbol
# numbers.
m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])])
-m4_define([b4_symbol_kind],
+m4_define([b4_symbol_kind_base],
[b4_percent_define_get([api.symbol.prefix])dnl
m4_case([$1],
[-2], [[YYEMPTY]],
@@ -456,6 +458,26 @@ m4_case([$1],
[m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])])
+# b4_symbol_kind(NUM)
+# -------------------
+# Same as b4_symbol_kind, but possibly with a prefix in some
+# languages. E.g., EOF's kind_base and kind are YYSYMBOL_YYEOF in C,
+# but are S_YYEMPTY and symbol_kind::S_YYEMPTY in C++.
+m4_copy([b4_symbol_kind_base], [b4_symbol_kind])
+
+
+# b4_symbol_slot(NUM)
+# -------------------
+# The name of union member that contains the value of these symbols.
+# Currently, we are messy, this should actually be type_tag, but type_tag
+# has several meanings.
+m4_define([b4_symbol_slot],
+[m4_case(b4_percent_define_get([[api.value.type]]),
+ [union], [b4_symbol([$1], [type_tag])],
+ [variant], [b4_symbol([$1], [type_tag])],
+ [b4_symbol([$1], [type])])])
+
+
# b4_symbol(NUM, FIELD)
# ---------------------
# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined.
@@ -463,8 +485,10 @@ m4_case([$1],
# If FIELD = id, prepend the token prefix.
m4_define([b4_symbol],
[m4_case([$2],
- [id], [b4_symbol_token_kind([$1])],
- [kind], [b4_symbol_kind([$1])],
+ [id], [b4_symbol_token_kind([$1])],
+ [kind_base], [b4_symbol_kind_base([$1])],
+ [kind], [b4_symbol_kind([$1])],
+ [slot], [b4_symbol_slot([$1])],
[_b4_symbol($@)])])
@@ -527,7 +551,7 @@ m4_defn([b4_actions_])[]dnl
break;
}dnl
],
-[YYUSE (m4_default([$2], [yykind]));])dnl
+[YY_USE (m4_default([$2], [yykind]));])dnl
m4_popdef([b4_actions_])dnl
])
@@ -537,7 +561,7 @@ m4_popdef([b4_actions_])dnl
# easier to use with m4_map, but then, use []dnl to suppress the last
# one.
m4_define([_b4_symbol_case],
-[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
+[case b4_symbol([$1], [kind]): b4_symbol_tag_comment([$1])])
])
@@ -585,8 +609,8 @@ m4_define([b4_any_token_visible_if],
m4_define([b4_token_format],
[b4_token_visible_if([$2],
[m4_format([[$1]],
- m4_expand(b4_symbol([$2], [id])),
- m4_expand(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])])
+ b4_symbol([$2], [id]),
+ b4_symbol([$2], b4_api_token_raw_if([[number]], [[code]])))])])
# b4_last_enum_token
@@ -623,11 +647,11 @@ m4_define([_b4_type_action],
])])
-# b4_type_foreach(MACRO)
-# ----------------------
+# b4_type_foreach(MACRO, [SEP])
+# -----------------------------
# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set.
m4_define([b4_type_foreach],
- [m4_map([$1], m4_defn([b4_type_names]))])
+ [m4_map_sep([$1], [$2], m4_defn([b4_type_names]))])
@@ -748,7 +772,7 @@ m4_define([b4_check_user_names],
[m4_pushdef([b4_occurrence], b4_occurrence)dnl
m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl
m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl
-m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl
+m4_pushdef([b4_end], m4_shift2(b4_occurrence))dnl
m4_ifndef($3[(]m4_quote(b4_user_name)[)],
[b4_complain_at([b4_start], [b4_end],
[[%s '%s' is not used]],
diff --git a/contrib/tools/bison/data/skeletons/c++-skel.m4 b/contrib/tools/bison/data/skeletons/c++-skel.m4
index 6d3becf5e6..f22002b961 100644
--- a/contrib/tools/bison/data/skeletons/c++-skel.m4
+++ b/contrib/tools/bison/data/skeletons/c++-skel.m4
@@ -2,7 +2,7 @@
# C++ skeleton dispatching for Bison.
-# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
+# Copyright (C) 2006-2007, 2009-2015, 2018-2021 Free Software
# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
diff --git a/contrib/tools/bison/data/skeletons/c++.m4 b/contrib/tools/bison/data/skeletons/c++.m4
index b862bf3ca7..2d1e90d0f4 100644
--- a/contrib/tools/bison/data/skeletons/c++.m4
+++ b/contrib/tools/bison/data/skeletons/c++.m4
@@ -2,7 +2,7 @@
# C++ skeleton for Bison
-# Copyright (C) 2002-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2021 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
@@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Sanity checks, before defaults installed by c.m4.
b4_percent_define_ifdef([[api.value.union.name]],
@@ -105,7 +105,7 @@ b4_percent_define_default([[api.parser.class]], [[parser]])
#
# b4_percent_define_default([[api.location.type]], [[location]])
-b4_percent_define_default([[filename_type]], [[std::string]])
+b4_percent_define_default([[api.filename.type]], [[const std::string]])
# Make it a warning for those who used betas of Bison 3.0.
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
@@ -193,7 +193,7 @@ m4_define([b4_declare_symbol_enum],
[[enum symbol_kind_type
{
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
- ]b4_symbol_kind([-2])[ = -2,
+ ]b4_symbol(-2, kind_base)[ = -2,
]b4_symbol_foreach([ b4_symbol_enum])dnl
[ };]])
@@ -321,8 +321,9 @@ m4_define([b4_symbol_type_define],
/// Copy constructor.
basic_symbol (const basic_symbol& that);]b4_variant_if([[
- /// Constructor for valueless symbols, and symbols from each type.
-]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
+ /// Constructors for typed symbols.
+]b4_type_foreach([b4_basic_symbol_constructor_define], [
+])], [[
/// Constructor for valueless symbols.
basic_symbol (typename Base::kind_type t]b4_locations_if([,
YY_MOVE_REF (location_type) l])[);
@@ -339,7 +340,7 @@ m4_define([b4_symbol_type_define],
}
/// Destroy contents, and record that is empty.
- void clear ()
+ void clear () YY_NOEXCEPT
{]b4_variant_if([[
// User destructor.
symbol_kind_type yykind = this->kind ();
@@ -423,7 +424,7 @@ m4_define([b4_symbol_type_define],
by_kind (kind_type t);
/// Record that this symbol is empty.
- void clear ();
+ void clear () YY_NOEXCEPT;
/// Steal the symbol kind from \a that.
void move (by_kind& that);
@@ -507,7 +508,7 @@ m4_define([b4_public_types_define],
bool
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
{
- return this->kind () == symbol_kind::]b4_symbol_prefix[YYEMPTY;
+ return this->kind () == ]b4_symbol(-2, kind)[;
}
template <typename Base>
@@ -523,7 +524,7 @@ m4_define([b4_public_types_define],
// by_kind.
]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
- : kind_ (symbol_kind::]b4_symbol_prefix[YYEMPTY)
+ : kind_ (]b4_symbol(-2, kind)[)
{}
#if 201103L <= YY_CPLUSPLUS
@@ -543,9 +544,9 @@ m4_define([b4_public_types_define],
{}
]b4_inline([$1])[void
- ]b4_parser_class[::by_kind::clear ()
+ ]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
{
- kind_ = symbol_kind::]b4_symbol_prefix[YYEMPTY;
+ kind_ = ]b4_symbol(-2, kind)[;
}
]b4_inline([$1])[void
@@ -594,11 +595,12 @@ m4_define([b4_yytranslate_define],
{
]b4_translate[
};
- const int user_token_number_max_ = ]b4_user_token_number_max[;
+ // Last valid token kind.
+ const int code_max = ]b4_code_max[;
if (t <= 0)
return symbol_kind::]b4_symbol_prefix[YYEOF;
- else if (t <= user_token_number_max_)
+ else if (t <= code_max)
return YY_CAST (symbol_kind_type, translate_table[t]);
else
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
diff --git a/contrib/tools/bison/data/skeletons/c-like.m4 b/contrib/tools/bison/data/skeletons/c-like.m4
index 1e5ab02c8a..a9bbc2e86e 100644
--- a/contrib/tools/bison/data/skeletons/c-like.m4
+++ b/contrib/tools/bison/data/skeletons/c-like.m4
@@ -2,7 +2,7 @@
# Common code for C-like languages (C, C++, Java, etc.)
-# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015, 2018-2021 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
@@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# _b4_comment(TEXT, OPEN, CONTINUE, END)
diff --git a/contrib/tools/bison/data/skeletons/c-skel.m4 b/contrib/tools/bison/data/skeletons/c-skel.m4
index 68d057cb74..ac6ddd687c 100644
--- a/contrib/tools/bison/data/skeletons/c-skel.m4
+++ b/contrib/tools/bison/data/skeletons/c-skel.m4
@@ -2,7 +2,7 @@
# C skeleton dispatching for Bison.
-# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
+# Copyright (C) 2006-2007, 2009-2015, 2018-2021 Free Software
# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
diff --git a/contrib/tools/bison/data/skeletons/c.m4 b/contrib/tools/bison/data/skeletons/c.m4
index 3c6daef23a..f95fc88cdf 100644
--- a/contrib/tools/bison/data/skeletons/c.m4
+++ b/contrib/tools/bison/data/skeletons/c.m4
@@ -2,7 +2,7 @@
# C M4 Macros for Bison.
-# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
+# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation,
# Inc.
# This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
m4_include(b4_skeletonsdir/[c-like.m4])
@@ -58,11 +58,11 @@ m4_define([b4_cpp_guard_close],
# b4_pull_flag if they use the values of the %define variables api.pure or
# api.push-pull.
m4_define([b4_identification],
-[[/* Identify Bison output. */
-#define YYBISON 1
+[[/* Identify Bison output, and Bison version. */
+#define YYBISON ]b4_version[
-/* Bison version. */
-#define YYBISON_VERSION "]b4_version["
+/* Bison version string. */
+#define YYBISON_VERSION "]b4_version_string["
/* Skeleton name. */
#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[
@@ -160,11 +160,11 @@ m4_popdef([$1])dnl
# b4_parse_param_use([VAL], [LOC])
# --------------------------------
-# 'YYUSE' VAL, LOC if locations are enabled, and all the parse-params.
+# 'YY_USE' VAL, LOC if locations are enabled, and all the parse-params.
m4_define([b4_parse_param_use],
-[m4_ifvaln([$1], [ YYUSE ([$1]);])dnl
-b4_locations_if([m4_ifvaln([$2], [ YYUSE ([$2]);])])dnl
-b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
+[m4_ifvaln([$1], [ YY_USE ([$1]);])dnl
+b4_locations_if([m4_ifvaln([$2], [ YY_USE ([$2]);])])dnl
+b4_parse_param_for([Decl], [Formal], [ YY_USE (Formal);
])dnl
])
@@ -242,6 +242,18 @@ typedef int_least16_t yytype_int16;
typedef short yytype_int16;
#endif
+/* Work around bug in HP-UX 11.23, which defines these macros
+ incorrectly for preprocessor constants. This workaround can likely
+ be removed in 2023, as HPE has promised support for HP-UX 11.23
+ (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
+ <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
+#ifdef __hpux
+# undef UINT_LEAST8_MAX
+# undef UINT_LEAST16_MAX
+# define UINT_LEAST8_MAX 255
+# define UINT_LEAST16_MAX 65535
+#endif
+
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
@@ -355,17 +367,27 @@ m4_define([b4_attribute_define],
#endif
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
-]dnl This is an exact copy of lib/_Noreturn.h.
+]dnl This is close to lib/_Noreturn.h, except that we do enable
+dnl the use of [[noreturn]], because _Noreturn is used in places
+dnl where [[noreturn]] works in C++. We need this in particular
+dnl because of glr.cc which compiles code from glr.c in C++.
+dnl And the C++ compiler chokes on _Noreturn. Also, we do not
+dnl use C' _Noreturn in C++, to avoid -Wc11-extensions warnings.
[#ifndef _Noreturn
# if (defined __cplusplus \
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
# define _Noreturn [[noreturn]]
# elif ((!defined __cplusplus || defined __clang__) \
- && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
- || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
+ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
+ || (!defined __STRICT_ANSI__ \
+ && (__4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
+ || (defined __apple_build_version__ \
+ ? 6000000 <= __apple_build_version__ \
+ : 3 < __clang_major__ + (5 <= __clang_minor__))))))
/* _Noreturn works as-is. */
-# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
+# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
+ || 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
# define _Noreturn __declspec (noreturn)
@@ -376,9 +398,9 @@ m4_define([b4_attribute_define],
]])[/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
+# define YY_USE(E) ((void) (E))
#else
-# define YYUSE(E) /* empty */
+# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
@@ -501,10 +523,11 @@ m4_define([b4_token_define],
# ----------------
# Output the definition of the tokens.
m4_define([b4_token_defines],
-[b4_any_token_visible_if([/* Token kinds. */
-m4_join([
+[[/* Token kinds. */
+#define ]b4_symbol([-2], [id])[ -2
+]m4_join([
], b4_symbol_map([b4_token_define]))
-])])
+])
# b4_token_enum(TOKEN-NUM)
@@ -515,7 +538,7 @@ m4_define([b4_token_enum],
[m4_format([ %-30s %s],
m4_format([[%s = %s%s%s]],
b4_symbol([$1], [id]),
- b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])),
+ b4_symbol([$1], b4_api_token_raw_if([[number]], [[code]])),
m4_if([$1], b4_last_enum_token, [], [[,]])),
[b4_symbol_tag_comment([$1])])])])
@@ -564,7 +587,7 @@ m4_define([b4_symbol_translate],
m4_define([b4_symbol_enum],
[m4_format([ %-40s %s],
m4_format([[%s = %s%s%s]],
- b4_symbol([$1], [kind]),
+ b4_symbol([$1], [kind_base]),
[$1],
m4_if([$1], b4_last_symbol, [], [[,]])),
[b4_symbol_tag_comment([$1])])])
@@ -579,7 +602,7 @@ m4_define([b4_declare_symbol_enum],
[[/* Symbol kind. */
enum yysymbol_kind_t
{
- ]b4_symbol_kind([-2])[ = -2,
+ ]b4_symbol([-2], kind_base)[ = -2,
]b4_symbol_foreach([b4_symbol_enum])dnl
[};
typedef enum yysymbol_kind_t yysymbol_kind_t;
@@ -658,10 +681,10 @@ m4_define([b4_sync_start], [[#]line $1 $2])
## User actions. ##
## -------------- ##
-# b4_case(LABEL, STATEMENTS)
-# --------------------------
+# b4_case(LABEL, STATEMENTS, [COMMENTS])
+# --------------------------------------
m4_define([b4_case],
-[ case $1:
+[ case $1:m4_ifval([$3], [ b4_comment([$3])])
$2
b4_syncline([@oline@], [@ofile@])dnl
break;])
diff --git a/contrib/tools/bison/data/skeletons/glr.cc b/contrib/tools/bison/data/skeletons/glr.cc
index 658b9f20ca..ff23cdc5ff 100644
--- a/contrib/tools/bison/data/skeletons/glr.cc
+++ b/contrib/tools/bison/data/skeletons/glr.cc
@@ -1,6 +1,6 @@
# C++ GLR skeleton for Bison
-# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015, 2018-2021 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
@@ -13,7 +13,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This skeleton produces a C++ class that encapsulates a C glr parser.
@@ -66,12 +66,6 @@ m4_defn([b4_parse_param]))],
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
])
-# b4_declare_symbol_enum
-# ----------------------
-m4_append([b4_declare_symbol_enum],
-[[typedef symbol_kind_type yysymbol_kind_t;
-]])
-
# b4_yy_symbol_print_define
# -------------------------
@@ -105,9 +99,9 @@ yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
])[const char* msg);]])[
-# Hijack the epilogue to define implementations (yyerror, parser member
+# Inserted before the epilogue to define implementations (yyerror, parser member
# functions etc.).
-]m4_append([b4_epilogue],
+]m4_define([b4_glr_cc_pre_epilogue],
[b4_syncline([@oline@], [@ofile@])dnl
[
/*------------------.
@@ -150,7 +144,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
int
]b4_parser_class[::parse ()
{
- return ::yyparse (*this]b4_user_args[);
+ return ::yy_parse_impl (*this]b4_user_args[);
}
#if ]b4_api_PREFIX[DEBUG
@@ -163,11 +157,11 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
const semantic_type* yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[) const
{]b4_locations_if([[
- YYUSE (yylocationp);]])[
- YYUSE (yyvaluep);
+ YY_USE (yylocationp);]])[
+ YY_USE (yyvaluep);
std::ostream& yyo = debug_stream ();
std::ostream& yyoutput = yyo;
- YYUSE (yyoutput);
+ YY_USE (yyoutput);
]b4_symbol_actions([printer])[
}
@@ -178,7 +172,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
const location_type* yylocationp]])[) const
{
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
- << ' ' << yytname[yykind] << " ("]b4_locations_if([[
+ << ' ' << yysymbol_name (yykind) << " ("]b4_locations_if([[
<< *yylocationp << ": "]])[;
yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[);
*yycdebug_ << ')';
@@ -216,6 +210,12 @@ b4_namespace_close[]dnl
])
+m4_define([b4_define_symbol_kind],
+[m4_format([#define %-15s %s],
+ b4_symbol($][1, kind_base),
+ b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol($1, kind_base))
+])
+
# b4_glr_cc_setup
# ---------------
# Setup redirections for glr.c: Map the names used in c.m4 to the ones used
@@ -236,10 +236,15 @@ m4_define([b4_glr_cc_setup],
#endif
typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
-#define ]b4_symbol_prefix[YYEMPTY ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
-#define ]b4_symbol_prefix[YYerror ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYerror
-#define ]b4_symbol_prefix[YYEOF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
-#define ]b4_symbol_prefix[YYUNDEF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
+
+// Expose C++ symbol kinds to C.
+]b4_define_symbol_kind(-2)dnl
+b4_symbol_foreach([b4_define_symbol_kind])])[
+]])
+
+
+m4_define([b4_undef_symbol_kind],
+[[#undef ]b4_symbol($1, kind_base)[
]])
@@ -247,20 +252,13 @@ typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
# -----------------
# Remove redirections for glr.c.
m4_define([b4_glr_cc_cleanup],
-[b4_percent_define_flag_if([[global_tokens_and_yystype]], [],
[[#undef ]b4_symbol(-2, [id])[
#undef ]b4_symbol(0, [id])[
#undef ]b4_symbol(1, [id])[
-]])[
-
-#undef ]b4_api_PREFIX[STYPE
-#undef ]b4_api_PREFIX[LTYPE
-#undef ]b4_symbol_prefix[YYEMPTY
-#undef ]b4_symbol_prefix[YYerror
-#undef ]b4_symbol_prefix[YYEOF
-#undef ]b4_symbol_prefix[YYUNDEF
-]])
+]b4_undef_symbol_kind(-2)dnl
+b4_symbol_foreach([b4_undef_symbol_kind])dnl
+])
# b4_shared_declarations(hh|cc)
@@ -374,10 +372,6 @@ b4_percent_code_get([[requires]])[
]b4_parse_param_vars[
};
-]dnl Redirections for glr.c.
-b4_percent_define_flag_if([[global_tokens_and_yystype]],
-[b4_token_defines
-])[
]b4_namespace_close[
]b4_percent_code_get([[provides]])[
@@ -387,13 +381,13 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
]b4_defines_if(
[b4_output_begin([b4_spec_header_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
- [2002-2015, 2018-2020])[
+ [2002-2015, 2018-2021])[
// C++ GLR parser skeleton written by Akim Demaille.
]b4_disclaimer[
-]b4_cpp_guard_open([b4_spec_header_file])[
+]b4_cpp_guard_open([b4_spec_mapped_header_file])[
]b4_shared_declarations[
-]b4_cpp_guard_close([b4_spec_header_file])[
+]b4_cpp_guard_close([b4_spec_mapped_header_file])[
]b4_output_end])
# Let glr.c (and b4_shared_declarations) believe that the user
diff --git a/contrib/tools/bison/data/skeletons/lalr1.cc b/contrib/tools/bison/data/skeletons/lalr1.cc
index dfffb74b8e..cc8113e2a0 100644
--- a/contrib/tools/bison/data/skeletons/lalr1.cc
+++ b/contrib/tools/bison/data/skeletons/lalr1.cc
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
-# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015, 2018-2021 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
@@ -13,7 +13,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
m4_include(b4_skeletonsdir/[c++.m4])
@@ -59,6 +59,13 @@ m4_define([b4_integral_parser_table_define],
};dnl
])
+
+# b4_symbol_kind(NUM)
+# -------------------
+m4_define([b4_symbol_kind],
+[symbol_kind::b4_symbol_kind_base($@)])
+
+
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
# -------------------------------------------------
# Same as b4_symbol_value, but used in a template method. It makes
@@ -153,7 +160,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
m4_pushdef([b4_copyright_years],
- [2002-2015, 2018-2020])
+ [2002-2015, 2018-2021])
m4_define([b4_parser_class],
[b4_percent_define_get([[api.parser.class]])])
@@ -264,9 +271,9 @@ m4_define([b4_shared_declarations],
{
public:
context (const ]b4_parser_class[& yyparser, const symbol_type& yyla);
- const symbol_type& lookahead () const { return yyla_; }
- symbol_kind_type token () const { return yyla_.kind (); }]b4_locations_if([[
- const location_type& location () const { return yyla_.location; }
+ const symbol_type& lookahead () const YY_NOEXCEPT { return yyla_; }
+ symbol_kind_type token () const YY_NOEXCEPT { return yyla_.kind (); }]b4_locations_if([[
+ const location_type& location () const YY_NOEXCEPT { return yyla_.location; }
]])[
/// Put in YYARG at most YYARGN of the expected tokens, and return the
/// number of tokens stored in YYARG. If YYARG is null, return the
@@ -486,14 +493,6 @@ m4_define([b4_shared_declarations],
]b4_public_types_define([$1])])[
]b4_namespace_close[
-]b4_percent_define_flag_if([[global_tokens_and_yystype]],
-[b4_token_defines
-
-#ifndef ]b4_api_PREFIX[STYPE
- // Redirection for backward compatibility.
-# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class::semantic_type
-#endif
-])[
]b4_percent_code_get([[provides]])[
]])
@@ -506,16 +505,16 @@ b4_defines_if(
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
[
/**
- ** \file ]b4_spec_header_file[
+ ** \file ]b4_spec_mapped_header_file[
** Define the ]b4_namespace_ref[::parser class.
*/
// C++ LALR(1) parser skeleton written by Akim Demaille.
]b4_disclaimer[
-]b4_cpp_guard_open([b4_spec_header_file])[
+]b4_cpp_guard_open([b4_spec_mapped_header_file])[
]b4_shared_declarations(hh)[
-]b4_cpp_guard_close([b4_spec_header_file])[
+]b4_cpp_guard_close([b4_spec_mapped_header_file])[
]b4_output_end[
]])
@@ -598,7 +597,7 @@ 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_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol)
# define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
# define YY_STACK_PRINT() static_cast<void> (0)
@@ -666,7 +665,7 @@ m4_if(b4_prefix, [yy], [],
]b4_parser_class[::by_state::kind () const YY_NOEXCEPT
{
if (state == empty_state)
- return symbol_kind::]b4_symbol(-2, kind)[;
+ return ]b4_symbol(-2, kind)[;
else
return YY_CAST (symbol_kind_type, yystos_[+state]);
}
@@ -691,7 +690,7 @@ m4_if(b4_prefix, [yy], [],
b4_symbol_variant([that.kind ()],
[value], [move], [YY_MOVE (that.value)])])[
// that is emptied.
- that.kind_ = symbol_kind::]b4_symbol(-2, kind)[;
+ that.kind_ = ]b4_symbol(-2, kind)[;
}
#if YY_CPLUSPLUS < 201103L
@@ -737,7 +736,7 @@ m4_if(b4_prefix, [yy], [],
]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
{
std::ostream& yyoutput = yyo;
- YYUSE (yyoutput);
+ YY_USE (yyoutput);
if (yysym.empty ())
yyo << "empty symbol";
else
@@ -920,13 +919,13 @@ b4_dollar_popdef])[]dnl
}
YY_SYMBOL_PRINT ("Next token is", yyla);
- if (yyla.kind () == ]symbol_kind::b4_symbol(1, kind)[)
+ if (yyla.kind () == ]b4_symbol(1, kind)[)
{
// The scanner already issued an error message, process directly
// to error recovery. But do not keep the error token as
// lookahead, it is too special and may lead us to an endless
// loop in error recovery. */
- yyla.kind_ = ]symbol_kind::b4_symbol(2, kind)[;
+ yyla.kind_ = ]b4_symbol(2, kind)[;
goto yyerrlab1;
}
@@ -1063,7 +1062,7 @@ b4_dollar_popdef])[]dnl
error, discard it. */
// Return failure if at end of input.
- if (yyla.kind () == symbol_kind::]b4_symbol_prefix[YYEOF)
+ if (yyla.kind () == ]b4_symbol(0, kind)[)
YYABORT;
else if (!yyla.empty ())
{
@@ -1104,9 +1103,9 @@ b4_dollar_popdef])[]dnl
yyn = yypact_[+yystack_[0].state];
if (!yy_pact_value_is_default_ (yyn))
{
- yyn += symbol_kind::]b4_symbol(1, kind)[;
+ yyn += ]b4_symbol(1, kind)[;
if (0 <= yyn && yyn <= yylast_
- && yycheck_[yyn] == symbol_kind::]b4_symbol(1, kind)[)
+ && yycheck_[yyn] == ]b4_symbol(1, kind)[)
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -1298,8 +1297,8 @@ b4_dollar_popdef])[]dnl
for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
{
symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
- if (yysym != symbol_kind::]b4_symbol(1, kind)[
- && yysym != symbol_kind::]b4_symbol_prefix[YYUNDEF
+ if (yysym != ]b4_symbol(1, kind)[
+ && yysym != ]b4_symbol(2, kind)[
&& yyparser_.yy_lac_check_ (yysym))
{
if (!yyarg)
@@ -1321,7 +1320,7 @@ b4_dollar_popdef])[]dnl
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::]b4_symbol(1, kind)[
+ if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
{
if (!yyarg)
@@ -1334,7 +1333,7 @@ b4_dollar_popdef])[]dnl
}
]])[
if (yyarg && yycount == 0 && 0 < yyargn)
- yyarg[0] = symbol_kind::]b4_symbol(-2, kind)[;
+ yyarg[0] = ]b4_symbol(-2, kind)[;
return yycount;
}
diff --git a/contrib/tools/bison/data/skeletons/location.cc b/contrib/tools/bison/data/skeletons/location.cc
index 34db41881c..1ec48de749 100644
--- a/contrib/tools/bison/data/skeletons/location.cc
+++ b/contrib/tools/bison/data/skeletons/location.cc
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
-# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015, 2018-2021 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
@@ -13,16 +13,16 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
- [2002-2015, 2018-2020])
+ [2002-2015, 2018-2021])
# b4_position_file
# ----------------
# Name of the file containing the position class, if we want this file.
-b4_defines_if([b4_required_version_if([302], [],
+b4_defines_if([b4_required_version_if([30200], [],
[m4_define([b4_position_file], [position.hh])])])])
@@ -48,7 +48,7 @@ m4_ifdef([b4_location_file],
["b4_location_file"])])
m4_define([b4_location_path],
b4_percent_define_get([[api.location.include]],
- ["b4_dir_prefix[]b4_location_file"]))
+ ["b4_mapped_dir_prefix[]b4_location_file"]))
m4_define([b4_location_path],
m4_substr(m4_defn([b4_location_path]), 1, m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
])
@@ -63,11 +63,13 @@ m4_define([b4_location_define],
class position
{
public:
+ /// Type for file name.
+ typedef ]b4_percent_define_get([[api.filename.type]])[ filename_type;
/// Type for line and column numbers.
typedef int counter_type;
]m4_ifdef([b4_location_constructors], [[
/// Construct a position.
- explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
+ explicit position (filename_type* f = YY_NULLPTR,
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
: filename (f)
@@ -77,7 +79,7 @@ m4_define([b4_location_define],
]])[
/// Initialization.
- void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
+ void initialize (filename_type* fn = YY_NULLPTR,
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
{
@@ -106,7 +108,7 @@ m4_define([b4_location_define],
/** \} */
/// File name to which this position refers.
- ]b4_percent_define_get([[filename_type]])[* filename;
+ filename_type* filename;
/// Current line number.
counter_type line;
/// Current column number.
@@ -184,6 +186,8 @@ m4_define([b4_location_define],
class location
{
public:
+ /// Type for file name.
+ typedef position::filename_type filename_type;
/// Type for line and column numbers.
typedef position::counter_type counter_type;
]m4_ifdef([b4_location_constructors], [
@@ -200,7 +204,7 @@ m4_define([b4_location_define],
{}
/// Construct a 0-width location in \a f, \a l, \a c.
- explicit location (]b4_percent_define_get([[filename_type]])[* f,
+ explicit location (filename_type* f,
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
: begin (f, l, c)
@@ -209,7 +213,7 @@ m4_define([b4_location_define],
])[
/// Initialization.
- void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
+ void initialize (filename_type* f = YY_NULLPTR,
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
{
diff --git a/contrib/tools/bison/data/skeletons/stack.hh b/contrib/tools/bison/data/skeletons/stack.hh
index 0fd3625836..c76fad599c 100644
--- a/contrib/tools/bison/data/skeletons/stack.hh
+++ b/contrib/tools/bison/data/skeletons/stack.hh
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
-# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015, 2018-2021 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
@@ -13,13 +13,13 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# b4_stack_file
# -------------
# Name of the file containing the stack class, if we want this file.
-b4_defines_if([b4_required_version_if([302], [],
+b4_defines_if([b4_required_version_if([30200], [],
[m4_define([b4_stack_file], [stack.hh])])])
diff --git a/contrib/tools/bison/data/skeletons/variant.hh b/contrib/tools/bison/data/skeletons/variant.hh
index b594af3808..2f68b0ca3f 100644
--- a/contrib/tools/bison/data/skeletons/variant.hh
+++ b/contrib/tools/bison/data/skeletons/variant.hh
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
-# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015, 2018-2021 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
@@ -13,13 +13,20 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
## --------- ##
## variant. ##
## --------- ##
+# b4_assert
+# ---------
+# The name of YY_ASSERT.
+m4_define([b4_assert],
+ [b4_api_PREFIX[]_ASSERT])
+
+
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
# ------------------------------------------------
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
@@ -71,12 +78,12 @@ m4_map([ b4_symbol_tag_comment], [$@])dnl
# -------------------
# The needed includes for variants support.
m4_define([b4_variant_includes],
-[b4_parse_assert_if([[#include <typeinfo>]])[
-#ifndef YY_ASSERT
+[b4_parse_assert_if([[#include <typeinfo>
+#ifndef ]b4_assert[
# include <cassert>
-# define YY_ASSERT assert
+# define ]b4_assert[ assert
#endif
-]])
+]])])
@@ -110,8 +117,8 @@ m4_define([b4_value_type_declare],
template <typename T>
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
: yytypeid_ (&typeid (T))])[
- {
- YY_ASSERT (sizeof (T) <= size);
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (sizeof (T) <= size);]])[
new (yyas_<T> ()) T (YY_MOVE (t));
}
@@ -125,7 +132,7 @@ m4_define([b4_value_type_declare],
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
{]b4_parse_assert_if([
- YY_ASSERT (!yytypeid_);
+ ]b4_assert[ (!yytypeid_);
])[}
# if 201103L <= YY_CPLUSPLUS
@@ -133,10 +140,10 @@ m4_define([b4_value_type_declare],
template <typename T, typename... U>
T&
emplace (U&&... u)
- {]b4_parse_assert_if([
- YY_ASSERT (!yytypeid_);
- YY_ASSERT (sizeof (T) <= size);
- yytypeid_ = & typeid (T);])[
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (!yytypeid_);
+ ]b4_assert[ (sizeof (T) <= size);
+ yytypeid_ = & typeid (T);]])[
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
}
# else
@@ -144,10 +151,10 @@ m4_define([b4_value_type_declare],
template <typename T>
T&
emplace ()
- {]b4_parse_assert_if([
- YY_ASSERT (!yytypeid_);
- YY_ASSERT (sizeof (T) <= size);
- yytypeid_ = & typeid (T);])[
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (!yytypeid_);
+ ]b4_assert[ (sizeof (T) <= size);
+ yytypeid_ = & typeid (T);]])[
return *new (yyas_<T> ()) T ();
}
@@ -155,10 +162,10 @@ m4_define([b4_value_type_declare],
template <typename T>
T&
emplace (const T& t)
- {]b4_parse_assert_if([
- YY_ASSERT (!yytypeid_);
- YY_ASSERT (sizeof (T) <= size);
- yytypeid_ = & typeid (T);])[
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (!yytypeid_);
+ ]b4_assert[ (sizeof (T) <= size);
+ yytypeid_ = & typeid (T);]])[
return *new (yyas_<T> ()) T (t);
}
# endif
@@ -185,10 +192,10 @@ m4_define([b4_value_type_declare],
template <typename T>
T&
as () YY_NOEXCEPT
- {]b4_parse_assert_if([
- YY_ASSERT (yytypeid_);
- YY_ASSERT (*yytypeid_ == typeid (T));
- YY_ASSERT (sizeof (T) <= size);])[
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (yytypeid_);
+ ]b4_assert[ (*yytypeid_ == typeid (T));
+ ]b4_assert[ (sizeof (T) <= size);]])[
return *yyas_<T> ();
}
@@ -196,10 +203,10 @@ m4_define([b4_value_type_declare],
template <typename T>
const T&
as () const YY_NOEXCEPT
- {]b4_parse_assert_if([
- YY_ASSERT (yytypeid_);
- YY_ASSERT (*yytypeid_ == typeid (T));
- YY_ASSERT (sizeof (T) <= size);])[
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (yytypeid_);
+ ]b4_assert[ (*yytypeid_ == typeid (T));
+ ]b4_assert[ (sizeof (T) <= size);]])[
return *yyas_<T> ();
}
@@ -214,9 +221,9 @@ m4_define([b4_value_type_declare],
template <typename T>
void
swap (self_type& that) YY_NOEXCEPT
- {]b4_parse_assert_if([
- YY_ASSERT (yytypeid_);
- YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (yytypeid_);
+ ]b4_assert[ (*yytypeid_ == *that.yytypeid_);]])[
std::swap (as<T> (), that.as<T> ());
}
@@ -388,11 +395,67 @@ m4_define([_b4_token_maker_define],
])])
-m4_define([_b4_type_clause],
-[b4_symbol_if([$1], [is_token],
- [b4_symbol_if([$1], [has_id],
- [tok == token::b4_symbol([$1], [id])],
- [tok == b4_symbol([$1], [user_number])])])])
+# b4_token_kind(SYMBOL-NUM)
+# -------------------------
+# Some tokens don't have an ID.
+m4_define([b4_token_kind],
+[b4_symbol_if([$1], [has_id],
+ [token::b4_symbol([$1], [id])],
+ [b4_symbol([$1], [code])])])
+
+
+# _b4_tok_in(SYMBOL-NUM, ...)
+# ---------------------------
+# See b4_tok_in below. The SYMBOL-NUMs... are tokens only.
+#
+# We iterate over the tokens to group them by "range" of token numbers (not
+# symbols numbers!).
+#
+# b4_fst is the start of that range.
+# b4_prev is the previous value.
+# b4_val is the current value.
+# If b4_val is the successor of b4_prev in token numbers, update the latter,
+# otherwise emit the code for range b4_fst .. b4_prev.
+# $1 is also used as a terminator in the foreach, but it will not be printed.
+#
+m4_define([_b4_tok_in],
+[m4_pushdef([b4_prev], [$1])dnl
+m4_pushdef([b4_fst], [$1])dnl
+m4_pushdef([b4_sep], [])dnl
+m4_foreach([b4_val], m4_dquote(m4_shift($@, $1)),
+ [m4_if(b4_symbol(b4_val, [code]), m4_eval(b4_symbol(b4_prev, [code]) + 1), [],
+ [b4_sep[]m4_if(b4_fst, b4_prev,
+ [tok == b4_token_kind(b4_fst)],
+ [(b4_token_kind(b4_fst) <= tok && tok <= b4_token_kind(b4_prev))])[]dnl
+m4_define([b4_fst], b4_val)dnl
+m4_define([b4_sep], [
+ || ])])dnl
+m4_define([b4_prev], b4_val)])dnl
+m4_popdef([b4_sep])dnl
+m4_popdef([b4_fst])dnl
+m4_popdef([b4_prev])dnl
+])
+
+
+# _b4_filter_tokens(SYMBOL-NUM, ...)
+# ----------------------------------
+# Expand as the list of tokens amongst SYMBOL-NUM.
+m4_define([_b4_filter_tokens],
+[m4_pushdef([b4_sep])dnl
+m4_foreach([b4_val], [$@],
+ [b4_symbol_if(b4_val, [is_token], [b4_sep[]b4_val[]m4_define([b4_sep], [,])])])dnl
+m4_popdef([b4_sep])dnl
+])
+
+
+# b4_tok_in(SYMBOL-NUM, ...)
+# ---------------------------
+# A C++ conditional that checks that `tok` is a member of this list of symbol
+# numbers.
+m4_define([b4_tok_in],
+ [_$0(_b4_filter_tokens($@))])
+
+
# _b4_token_constructor_define(SYMBOL-NUM...)
@@ -410,9 +473,6 @@ m4_define([_b4_token_constructor_define],
: super_type(]b4_join([token_type (tok)],
b4_symbol_if([$1], [has_type], [std::move (v)]),
b4_locations_if([std::move (l)]))[)
- {
- YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
- }
#else
symbol_type (]b4_join(
[int tok],
@@ -422,10 +482,10 @@ m4_define([_b4_token_constructor_define],
: super_type(]b4_join([token_type (tok)],
b4_symbol_if([$1], [has_type], [v]),
b4_locations_if([l]))[)
- {
- YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
- }
#endif
+ {]b4_parse_assert_if([[
+ ]b4_assert[ (]b4_tok_in($@)[);
+ ]])[}
]])])
diff --git a/contrib/tools/bison/data/skeletons/yacc.c b/contrib/tools/bison/data/skeletons/yacc.c
index bd5e7d8448..afdb508565 100644
--- a/contrib/tools/bison/data/skeletons/yacc.c
+++ b/contrib/tools/bison/data/skeletons/yacc.c
@@ -1,11 +1,11 @@
# -*- C -*-
# Yacc compatible skeleton for Bison
-# Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software
+# Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software
# Foundation, Inc.
m4_pushdef([b4_copyright_years],
- [1984, 1989-1990, 2000-2015, 2018-2020])
+ [1984, 1989-1990, 2000-2015, 2018-2021])
# 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
@@ -18,7 +18,7 @@ m4_pushdef([b4_copyright_years],
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
m4_include(b4_skeletonsdir/[c.m4])
@@ -48,6 +48,10 @@ m4_define([b4_pure_if],
## api.push-pull. ##
## --------------- ##
+# b4_pull_if, b4_push_if
+# ----------------------
+# Whether the pull/push APIs are needed. Both can be enabled.
+
b4_percent_define_default([[api.push-pull]], [[pull]])
b4_percent_define_check_values([[[[api.push-pull]],
[[pull]], [[push]], [[both]]]])
@@ -155,7 +159,7 @@ m4_define([b4_rhs_location],
# Declare the variables that are global, or local to YYPARSE if
# pure-parser.
m4_define([b4_declare_scanner_communication_variables], [[
-/* The lookahead symbol. */
+/* Lookahead token kind. */
int yychar;
]b4_pure_if([[
@@ -176,68 +180,47 @@ YYLTYPE yylloc]b4_yyloc_default[;]])[
int yynerrs;]])])
-# b4_declare_parser_state_variables
-# ---------------------------------
+# b4_declare_parser_state_variables([INIT])
+# -----------------------------------------
# Declare all the variables that are needed to maintain the parser state
# between calls to yypush_parse.
+# If INIT is non-null, initialize these variables.
m4_define([b4_declare_parser_state_variables],
[b4_pure_if([[
/* Number of syntax errors so far. */
- int yynerrs;
+ int yynerrs]m4_ifval([$1], [ = 0])[;
]])[
- yy_state_fast_t yystate;
+ yy_state_fast_t yystate]m4_ifval([$1], [ = 0])[;
/* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- 'yyss': related to states.
- 'yyvs': related to semantic values.]b4_locations_if([[
- 'yyls': related to locations.]])[
+ int yyerrstatus]m4_ifval([$1], [ = 0])[;
- Refer to the stacks through separate pointers, to allow yyoverflow
+ /* Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* Their size. */
- YYPTRDIFF_T yystacksize;
+ YYPTRDIFF_T yystacksize]m4_ifval([$1], [ = YYINITDEPTH])[;
- /* The state stack. */
+ /* The state stack: array, bottom, top. */
yy_state_t yyssa[YYINITDEPTH];
- yy_state_t *yyss;
- yy_state_t *yyssp;
+ yy_state_t *yyss]m4_ifval([$1], [ = yyssa])[;
+ yy_state_t *yyssp]m4_ifval([$1], [ = yyss])[;
- /* The semantic value stack. */
+ /* The semantic value stack: array, bottom, top. */
YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;]b4_locations_if([[
+ YYSTYPE *yyvs]m4_ifval([$1], [ = yyvsa])[;
+ YYSTYPE *yyvsp]m4_ifval([$1], [ = yyvs])[;]b4_locations_if([[
- /* The location stack. */
+ /* The location stack: array, bottom, top. */
YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls;
- YYLTYPE *yylsp;]])[]b4_lac_if([[
+ YYLTYPE *yyls]m4_ifval([$1], [ = yylsa])[;
+ YYLTYPE *yylsp]m4_ifval([$1], [ = yyls])[;]])[]b4_lac_if([[
yy_state_t yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
- yy_state_t *yyes;
- YYPTRDIFF_T yyes_capacity;]])])
-
-
-# b4_initialize_parser_state_variables
-# ------------------------------------
-# Initialize these variables.
-m4_define([b4_initialize_parser_state_variables],
-[[ yynerrs = 0;
- yystate = 0;
- yyerrstatus = 0;
-
- yystacksize = YYINITDEPTH;
- yyssp = yyss = yyssa;
- yyvsp = yyvs = yyvsa;]b4_locations_if([[
- yylsp = yyls = yylsa;]])[]b4_lac_if([[
-
- yyes = yyesa;
- yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[;
- if (YYMAXDEPTH < yyes_capacity)
- yyes_capacity = YYMAXDEPTH;]])[
-]])
+ yy_state_t *yyes]m4_ifval([$1], [ = yyesa])[;
+ YYPTRDIFF_T yyes_capacity][]m4_ifval([$1],
+ [m4_do([ = b4_percent_define_get([[parse.lac.es-capacity-initial]]) < YYMAXDEPTH],
+ [ ? b4_percent_define_get([[parse.lac.es-capacity-initial]])],
+ [ : YYMAXDEPTH])])[;]])])
m4_define([b4_macro_define],
@@ -313,14 +296,14 @@ m4_define([b4_declare_yyparse],
# Declaration that might either go into the header (if --defines)
# or open coded in the parser body.
m4_define([b4_shared_declarations],
-[b4_cpp_guard_open([b4_spec_header_file])[
+[b4_cpp_guard_open([b4_spec_mapped_header_file])[
]b4_declare_yydebug[
]b4_percent_code_get([[requires]])[
]b4_token_enums_defines[
]b4_declare_yylstype[
]b4_declare_yyparse[
]b4_percent_code_get([[provides]])[
-]b4_cpp_guard_close([b4_spec_header_file])[]dnl
+]b4_cpp_guard_close([b4_spec_mapped_header_file])[]dnl
])
@@ -335,7 +318,7 @@ m4_define([b4_header_include_if],
[$2])],
[$2])])
-m4_if(b4_spec_header_file, [[y.tab.h]],
+m4_if(b4_spec_header_file, [y.tab.h], [],
[b4_percent_define_default([[api.header.include]],
[["@basename(]b4_spec_header_file[@)"]])])
@@ -592,7 +575,8 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES ]b4_states_number[
-#define YYMAXUTOK ]b4_user_token_number_max[
+/* YYMAXUTOK -- Last valid token kind. */
+#define YYMAXUTOK ]b4_code_max[
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
@@ -829,7 +813,8 @@ int yydebug;
/* Parser data structure. */
struct yypstate
{]b4_declare_parser_state_variables[
- /* Whether this instance has not started parsing yet. */
+ /* Whether this instance has not started parsing yet.
+ * If 2, it corresponds to a finished parsing. */
int yynew;
};]b4_pure_if([], [[
@@ -1444,36 +1429,33 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
int
yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
{
- return yypull_parse (YY_NULLPTR]b4_user_args[);
+ yypstate *yyps = yypstate_new ();
+ if (!yyps)
+ {]b4_pure_if([b4_locations_if([[
+ static YYLTYPE yyloc_default][]b4_yyloc_default[;
+ YYLTYPE yylloc = yyloc_default;]])[
+ yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[
+ if (!yypstate_allocated)
+ yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[
+ return 2;
+ }
+ int yystatus = yypull_parse (yyps]b4_user_args[);
+ yypstate_delete (yyps);
+ return yystatus;
}
int
yypull_parse (yypstate *yyps]b4_user_formals[)
-{]b4_pure_if([b4_locations_if([[
+{
+ YY_ASSERT (yyps);]b4_pure_if([b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default[;
YYLTYPE yylloc = yyloc_default;]])])[
- yypstate *yyps_local;
- if (yyps)
- yyps_local = yyps;
- else
- {
- yyps_local = yypstate_new ();
- if (!yyps_local)
- {]b4_pure_if([[
- yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[
- if (!yypstate_allocated)
- yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[
- return 2;
- }
- }
int yystatus;
do {
]b4_pure_if([[ YYSTYPE yylval;
int ]])[yychar = ]b4_lex[;
- yystatus = yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
+ yystatus = yypush_parse (yyps]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
} while (yystatus == YYPUSH_MORE);
- if (!yyps)
- yypstate_delete (yyps_local);
return yystatus;
}]])[
@@ -1483,10 +1465,18 @@ yypull_parse (yypstate *yyps]b4_user_formals[)
static void
yypstate_clear (yypstate *yyps)
{
-]b4_initialize_parser_state_variables[
+ yynerrs = 0;
+ yystate = 0;
+ yyerrstatus = 0;
+
+ yyssp = yyss;
+ yyvsp = yyvs;]b4_locations_if([[
+ yylsp = yyls;]])[
+
/* Initialize the state stack, in case yypcontext_expected_tokens is
called before the first call to yyparse. */
*yyssp = 0;
+ yyps->yynew = 1;
}
/* Initialize the parser data structure. */
@@ -1496,11 +1486,18 @@ yypstate_new (void)
yypstate *yyps;]b4_pure_if([], [[
if (yypstate_allocated)
return YY_NULLPTR;]])[
- yyps = YY_CAST (yypstate *, malloc (sizeof *yyps));
+ yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
if (!yyps)
- return YY_NULLPTR;
- yyps->yynew = 1;]b4_pure_if([], [[
+ return YY_NULLPTR;]b4_pure_if([], [[
yypstate_allocated = 1;]])[
+ yystacksize = YYINITDEPTH;
+ yyss = yyssa;
+ yyvs = yyvsa;]b4_locations_if([[
+ yyls = yylsa;]])[]b4_lac_if([[
+ yyes = yyesa;
+ yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[;
+ if (YYMAXDEPTH < yyes_capacity)
+ yyes_capacity = YYMAXDEPTH;]])[
yypstate_clear (yyps);
return yyps;
}
@@ -1513,12 +1510,12 @@ yypstate_delete (yypstate *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 && yyss != yyssa)
+ if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif]b4_lac_if([[
- if (!yyps->yynew && yyes != yyesa)
+ if (yyes != yyesa)
YYSTACK_FREE (yyes);]])[
- free (yyps);]b4_pure_if([], [[
+ YYFREE (yyps);]b4_pure_if([], [[
yypstate_allocated = 0;]])[
}
}
@@ -1545,14 +1542,14 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[
YYSTYPE yypushed_val = yylval;]b4_locations_if([[
YYLTYPE yypushed_loc = yylloc;]])
])],
- [b4_declare_parser_state_variables
+ [b4_declare_parser_state_variables([init])
])b4_lac_if([[
/* Whether LAC context is established. A Boolean. */
int yy_lac_established = 0;]])[
int yyn;
/* The return value of yyparse. */
int yyresult;
- /* Lookahead token as an internal (translated) token number. */
+ /* Lookahead symbol kind. */
yysymbol_kind_t yytoken = ]b4_symbol(-2, kind)[;
/* The variables used to return semantic value and location from the
action routines. */
@@ -1572,14 +1569,21 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
- int yylen = 0;
-]b4_push_if([[
- if (!yyps->yynew)
+ int yylen = 0;]b4_push_if([[
+
+ switch (yyps->yynew)
{
+ case 0:
yyn = yypact[yystate];
goto yyread_pushed_token;
- }]], [
-b4_initialize_parser_state_variables])[
+
+ case 2:
+ yypstate_clear (yyps);
+ break;
+
+ default:
+ break;
+ }]])[
YYDPRINTF ((stderr, "Starting parse\n"));
@@ -2048,13 +2052,13 @@ yyabortlab:
yyexhaustedlab:
yyerror (]b4_yyerror_args[YY_("memory exhausted"));
yyresult = 2;
- /* Fall through. */
+ goto yyreturn;
#endif
-/*-----------------------------------------------------.
-| yyreturn -- parsing is finished, return the result. |
-`-----------------------------------------------------*/
+/*-------------------------------------------------------.
+| yyreturn -- parsing is finished, clean up and return. |
+`-------------------------------------------------------*/
yyreturn:
if (yychar != ]b4_symbol(-2, id)[)
{
@@ -2073,21 +2077,21 @@ yyreturn:
yydestruct ("Cleanup: popping",
YY_ACCESSING_SYMBOL (+*yyssp), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
- }
+ }]b4_push_if([[
+ yyps->yynew = 2;
+ goto yypushreturn;
+
+
+/*-------------------------.
+| yypushreturn -- return. |
+`-------------------------*/
+yypushreturn:]], [[
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif]b4_lac_if([[
if (yyes != yyesa)
- YYSTACK_FREE (yyes);]])b4_push_if([[
- yypstate_clear (yyps);
- yyps->yynew = 1;
-
-
-/*-----------------------------------------.
-| yypushreturn -- ask for the next token. |
-`-----------------------------------------*/
-yypushreturn:]])[
+ YYSTACK_FREE (yyes);]])])[
]b4_parse_error_bmatch([detailed\|verbose],
[[ if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);]])[