mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-13 12:45:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9beba1919c | ||
|
|
80ebbe7330 | ||
|
|
028df02a9f | ||
|
|
71dfc86d58 | ||
|
|
5c1069c7d8 | ||
|
|
3fc3ef658e | ||
|
|
dd6e78360a | ||
|
|
eeb5d6f11b | ||
|
|
70441b5ab1 | ||
|
|
7538d8dc1a | ||
|
|
b07b5ce423 | ||
|
|
157e91dcc6 | ||
|
|
b820718adf | ||
|
|
6e6e11795c | ||
|
|
6bfdf22c50 | ||
|
|
d432079f8a | ||
|
|
b6ac175a1c | ||
|
|
5f90ef59a4 | ||
|
|
10ee04479f | ||
|
|
c09524cf8f | ||
|
|
28152fc10a | ||
|
|
9babd05a90 | ||
|
|
3e94b12ddd | ||
|
|
7cb6de2533 | ||
|
|
4ec4309cce | ||
|
|
ca96df89b2 | ||
|
|
2142e59155 | ||
|
|
a75072476e | ||
|
|
7c47598d4f | ||
|
|
fdaedc780a | ||
|
|
85f5e3b9d5 | ||
|
|
c3a4686a03 | ||
|
|
9cdfd86cbb | ||
|
|
659376b590 | ||
|
|
0343acbe89 | ||
|
|
5d9ccd5a87 | ||
|
|
ad9b8a069f | ||
|
|
ec3375ab4e | ||
|
|
12c8e427c7 | ||
|
|
9f8f3d2e77 | ||
|
|
108724c2e7 | ||
|
|
da0f993fb9 | ||
|
|
075a879052 | ||
|
|
a7ded4284e | ||
|
|
a5c55bb758 | ||
|
|
bc5aa8e274 | ||
|
|
0a82bf5c07 | ||
|
|
a70e75b8a4 | ||
|
|
3afa9757da | ||
|
|
36f37568ba | ||
|
|
f2c568d3ef | ||
|
|
bb7860d208 |
+1
-1
@@ -1 +1 @@
|
|||||||
3.7.6
|
3.8.1
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ jobs:
|
|||||||
- git fetch --unshallow || true
|
- git fetch --unshallow || true
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
|
# As of 2021-08, we don't have Autoconf 2.71 on Ubuntu.
|
||||||
|
- sed -i 's/AC_PREREQ(\[2\.71\])/AC_PREREQ([2.69])/g' configure.ac
|
||||||
- ./bootstrap
|
- ./bootstrap
|
||||||
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
||||||
- make -j2
|
- make -j2
|
||||||
|
|||||||
@@ -1,6 +1,24 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
* Noteworthy changes in release 3.7.90 (2021-08-13) [beta]
|
* Noteworthy changes in release 3.8.2 (2021-09-25) [stable]
|
||||||
|
|
||||||
|
Fixed portability issues of bison on Cygwin.
|
||||||
|
|
||||||
|
Improvements in glr2.cc: add support for custom error messages (`%define
|
||||||
|
parse.error custom`), allow linking several parsers together.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.8.1 (2021-09-11) [stable]
|
||||||
|
|
||||||
|
The generation of prototypes for yylex and yyerror in Yacc mode is
|
||||||
|
breaking existing grammar files. To avoid breaking too many grammars, the
|
||||||
|
prototypes are now generated when `-y/--yacc` is used *and* the
|
||||||
|
`POSIXLY_CORRECT` environment variable is defined.
|
||||||
|
|
||||||
|
Avoid using `-y`/`--yacc` simply to comply with Yacc's file name
|
||||||
|
conventions, rather, use `-o y.tab.c`. Autoconf's AC_PROG_YACC macro uses
|
||||||
|
`-y`. Avoid it if possible, for instance by using gnulib's gl_PROG_BISON.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.8 (2021-09-07) [stable]
|
||||||
|
|
||||||
** Backward incompatible changes
|
** Backward incompatible changes
|
||||||
|
|
||||||
@@ -4703,7 +4721,7 @@ LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
|
|||||||
LocalWords: yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
|
LocalWords: yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
|
||||||
LocalWords: gotos readline Imbimbo Wcounterexamples Wcex Nonunifying rcex
|
LocalWords: gotos readline Imbimbo Wcounterexamples Wcex Nonunifying rcex
|
||||||
LocalWords: Vais xsltproc YYNOMEM YYLOCATION signedness YYBISON MITRE's
|
LocalWords: Vais xsltproc YYNOMEM YYLOCATION signedness YYBISON MITRE's
|
||||||
LocalWords: libreadline YYMALLOC YYFREE MSVC redefinitions
|
LocalWords: libreadline YYMALLOC YYFREE MSVC redefinitions POSIXLY
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ simple desk calculators to complex programming languages.
|
|||||||
|
|
||||||
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
||||||
work with Bison with no change. Anyone familiar with Yacc should be able to
|
work with Bison with no change. Anyone familiar with Yacc should be able to
|
||||||
use Bison with little trouble. You need to be fluent in C, C++ or Java
|
use Bison with little trouble. You need to be fluent in C, C++, D or Java
|
||||||
programming in order to use Bison.
|
programming in order to use Bison.
|
||||||
|
|
||||||
Bison and the parsers it generates are portable, they do not require any
|
Bison and the parsers it generates are portable, they do not require any
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ Les catégories d'avertissements incluent :
|
|||||||
|
|
||||||
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
||||||
|
|
||||||
* Bison 3.8
|
* Bison 3.9
|
||||||
** Rewrite glr.cc (currently glr2.cc)
|
** Rewrite glr.cc (currently glr2.cc)
|
||||||
*** custom error messages
|
*** custom error messages
|
||||||
|
|
||||||
@@ -517,6 +517,9 @@ https://github.com/scfc/bison-php/blob/master/data/lalr1.php
|
|||||||
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
||||||
|
|
||||||
** Multiple start symbols
|
** Multiple start symbols
|
||||||
|
Revert a70e75b8a41755ab96ab211a0ea111ac68a4aadd.
|
||||||
|
Revert tests: disable "Multistart reports".
|
||||||
|
|
||||||
Would be very useful when parsing closely related languages. The idea is to
|
Would be very useful when parsing closely related languages. The idea is to
|
||||||
declare several start symbols, for instance
|
declare several start symbols, for instance
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ gnulib_modules='
|
|||||||
realloc-posix
|
realloc-posix
|
||||||
relocatable-prog relocatable-script
|
relocatable-prog relocatable-script
|
||||||
rename
|
rename
|
||||||
spawn-pipe stdbool stpcpy stpncpy strdup-posix strerror strverscmp
|
spawn-pipe stdbool stpcpy stpncpy strdup-posix strerror strtod strverscmp
|
||||||
sys_ioctl
|
sys_ioctl
|
||||||
termios
|
termios
|
||||||
timevar
|
timevar
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ url_dir_list = \
|
|||||||
# Tests not to run as part of "make distcheck".
|
# Tests not to run as part of "make distcheck".
|
||||||
local-checks-to-skip = \
|
local-checks-to-skip = \
|
||||||
sc_immutable_NEWS \
|
sc_immutable_NEWS \
|
||||||
sc_prohibit_atoi_atof
|
sc_indent
|
||||||
|
|
||||||
# The local directory containing the checked-out copy of gnulib used in
|
# The local directory containing the checked-out copy of gnulib used in
|
||||||
# this release. Used solely to get a date for the "announcement" target.
|
# this release. Used solely to get a date for the "announcement" target.
|
||||||
@@ -164,6 +164,7 @@ $(call exclude,
|
|||||||
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||||
|
prohibit_atoi_atof=^(doc|etc|examples|tests)/ \
|
||||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||||
|
|||||||
@@ -15,11 +15,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# In order for some versions of Sun Studio to compile our C++ test cases
|
|
||||||
# correctly, we need Autoconf 2.64 or better to handle the restrict
|
|
||||||
# keyword in at least string.h from gnulib. We need Autoconf 2.68 or
|
|
||||||
# better to avoid a typo in the 'configure --help' entry for the YACC
|
|
||||||
# environment variable.
|
|
||||||
AC_PREREQ([2.71])
|
AC_PREREQ([2.71])
|
||||||
m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
|
m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
|
||||||
m4_pattern_allow([^BISON_USE_NLS$])
|
m4_pattern_allow([^BISON_USE_NLS$])
|
||||||
|
|||||||
@@ -409,8 +409,12 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
|||||||
# b4_glr_cc_if([IF-TRUE], [IF-FALSE])
|
# b4_glr_cc_if([IF-TRUE], [IF-FALSE])
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
m4_define([b4_glr_cc_if],
|
m4_define([b4_glr_cc_if],
|
||||||
[m4_if(m4_bregexp(b4_skeleton, [^"glr.cc"$]), [0], $@)])
|
[m4_if(b4_skeleton, ["glr.cc"], $@)])
|
||||||
|
|
||||||
|
# b4_glr2_cc_if([IF-TRUE], [IF-FALSE])
|
||||||
|
# ------------------------------------
|
||||||
|
m4_define([b4_glr2_cc_if],
|
||||||
|
[m4_if(b4_skeleton, ["glr2.cc"], $@)])
|
||||||
|
|
||||||
## --------- ##
|
## --------- ##
|
||||||
## Symbols. ##
|
## Symbols. ##
|
||||||
@@ -1110,6 +1114,7 @@ b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
|||||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||||
b4_percent_define_if_define([parse.assert])
|
b4_percent_define_if_define([parse.assert])
|
||||||
b4_percent_define_if_define([parse.trace])
|
b4_percent_define_if_define([parse.trace])
|
||||||
|
b4_percent_define_if_define([posix])
|
||||||
|
|
||||||
|
|
||||||
# b4_bison_locations_if([IF-TRUE])
|
# b4_bison_locations_if([IF-TRUE])
|
||||||
|
|||||||
+86
-30
@@ -227,6 +227,8 @@ m4_define([b4_value_type_declare],
|
|||||||
# Define the public types: token, semantic value, location, and so forth.
|
# Define the public types: token, semantic value, location, and so forth.
|
||||||
# Depending on %define token_lex, may be output in the header or source file.
|
# Depending on %define token_lex, may be output in the header or source file.
|
||||||
m4_define([b4_public_types_declare],
|
m4_define([b4_public_types_declare],
|
||||||
|
[b4_glr2_cc_if(
|
||||||
|
[b4_value_type_declare],
|
||||||
[[#ifdef ]b4_api_PREFIX[STYPE
|
[[#ifdef ]b4_api_PREFIX[STYPE
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
||||||
@@ -236,7 +238,8 @@ m4_define([b4_public_types_declare],
|
|||||||
]b4_value_type_declare[
|
]b4_value_type_declare[
|
||||||
#endif
|
#endif
|
||||||
/// Backward compatibility (Bison 3.8).
|
/// Backward compatibility (Bison 3.8).
|
||||||
typedef value_type semantic_type;]b4_locations_if([
|
typedef value_type semantic_type;
|
||||||
|
]])[]b4_locations_if([
|
||||||
/// Symbol locations.
|
/// Symbol locations.
|
||||||
typedef b4_percent_define_get([[api.location.type]],
|
typedef b4_percent_define_get([[api.location.type]],
|
||||||
[[location]]) location_type;])[
|
[[location]]) location_type;])[
|
||||||
@@ -262,16 +265,16 @@ m4_define([b4_public_types_declare],
|
|||||||
/// Token kinds.
|
/// Token kinds.
|
||||||
struct token
|
struct token
|
||||||
{
|
{
|
||||||
]b4_token_enums[
|
]b4_token_enums[]b4_glr2_cc_if([], [[
|
||||||
/// Backward compatibility alias (Bison 3.6).
|
/// Backward compatibility alias (Bison 3.6).
|
||||||
typedef token_kind_type yytokentype;
|
typedef token_kind_type yytokentype;]])[
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Token kind, as returned by yylex.
|
/// Token kind, as returned by yylex.
|
||||||
typedef token::yytokentype token_kind_type;
|
typedef token::token_kind_type token_kind_type;]b4_glr2_cc_if([], [[
|
||||||
|
|
||||||
/// Backward compatibility alias (Bison 3.6).
|
/// Backward compatibility alias (Bison 3.6).
|
||||||
typedef token_kind_type token_type;
|
typedef token_kind_type token_type;]])[
|
||||||
|
|
||||||
/// Symbol kinds.
|
/// Symbol kinds.
|
||||||
struct symbol_kind
|
struct symbol_kind
|
||||||
@@ -305,7 +308,7 @@ m4_define([b4_symbol_type_define],
|
|||||||
typedef Base super_type;
|
typedef Base super_type;
|
||||||
|
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
basic_symbol ()
|
basic_symbol () YY_NOEXCEPT
|
||||||
: value ()]b4_locations_if([
|
: value ()]b4_locations_if([
|
||||||
, location ()])[
|
, location ()])[
|
||||||
{}
|
{}
|
||||||
@@ -343,6 +346,30 @@ m4_define([b4_symbol_type_define],
|
|||||||
clear ();
|
clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]b4_glr2_cc_if([[
|
||||||
|
/// Copy assignment.
|
||||||
|
basic_symbol& operator= (const basic_symbol& that)
|
||||||
|
{
|
||||||
|
Base::operator= (that);]b4_variant_if([[
|
||||||
|
]b4_symbol_variant([this->kind ()], [value], [copy],
|
||||||
|
[that.value])], [[
|
||||||
|
value = that.value]])[;]b4_locations_if([[
|
||||||
|
location = that.location;]])[
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move assignment.
|
||||||
|
basic_symbol& operator= (basic_symbol&& that)
|
||||||
|
{
|
||||||
|
Base::operator= (std::move (that));]b4_variant_if([[
|
||||||
|
]b4_symbol_variant([this->kind ()], [value], [move],
|
||||||
|
[std::move (that.value)])], [[
|
||||||
|
value = std::move (that.value)]])[;]b4_locations_if([[
|
||||||
|
location = std::move (that.location);]])[
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
/// Destroy contents, and record that is empty.
|
/// Destroy contents, and record that is empty.
|
||||||
void clear () YY_NOEXCEPT
|
void clear () YY_NOEXCEPT
|
||||||
{]b4_variant_if([[
|
{]b4_variant_if([[
|
||||||
@@ -383,10 +410,10 @@ m4_define([b4_symbol_type_define],
|
|||||||
std::string name () const YY_NOEXCEPT
|
std::string name () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||||
}]])[
|
}]])[]b4_glr2_cc_if([], [[
|
||||||
|
|
||||||
/// Backward compatibility (Bison 3.6).
|
/// Backward compatibility (Bison 3.6).
|
||||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||||
|
|
||||||
/// Whether empty.
|
/// Whether empty.
|
||||||
bool empty () const YY_NOEXCEPT;
|
bool empty () const YY_NOEXCEPT;
|
||||||
@@ -410,22 +437,30 @@ m4_define([b4_symbol_type_define],
|
|||||||
/// Type access provider for token (enum) based symbols.
|
/// Type access provider for token (enum) based symbols.
|
||||||
struct by_kind
|
struct by_kind
|
||||||
{
|
{
|
||||||
/// Default constructor.
|
|
||||||
by_kind ();
|
|
||||||
|
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
|
||||||
/// Move constructor.
|
|
||||||
by_kind (by_kind&& that);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Copy constructor.
|
|
||||||
by_kind (const by_kind& that);
|
|
||||||
|
|
||||||
/// The symbol kind as needed by the constructor.
|
/// The symbol kind as needed by the constructor.
|
||||||
typedef token_kind_type kind_type;
|
typedef token_kind_type kind_type;
|
||||||
|
|
||||||
|
/// Default constructor.
|
||||||
|
by_kind () YY_NOEXCEPT;
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Move constructor.
|
||||||
|
by_kind (by_kind&& that) YY_NOEXCEPT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Copy constructor.
|
||||||
|
by_kind (const by_kind& that) YY_NOEXCEPT;
|
||||||
|
|
||||||
/// Constructor from (external) token numbers.
|
/// Constructor from (external) token numbers.
|
||||||
by_kind (kind_type t);
|
by_kind (kind_type t) YY_NOEXCEPT;
|
||||||
|
|
||||||
|
]b4_glr2_cc_if([[
|
||||||
|
/// Copy assignment.
|
||||||
|
by_kind& operator= (const by_kind& that);
|
||||||
|
|
||||||
|
/// Move assignment.
|
||||||
|
by_kind& operator= (by_kind&& that);
|
||||||
|
]])[
|
||||||
|
|
||||||
/// Record that this symbol is empty.
|
/// Record that this symbol is empty.
|
||||||
void clear () YY_NOEXCEPT;
|
void clear () YY_NOEXCEPT;
|
||||||
@@ -435,18 +470,18 @@ m4_define([b4_symbol_type_define],
|
|||||||
|
|
||||||
/// The (internal) type number (corresponding to \a type).
|
/// The (internal) type number (corresponding to \a type).
|
||||||
/// \a empty when empty.
|
/// \a empty when empty.
|
||||||
symbol_kind_type kind () const YY_NOEXCEPT;
|
symbol_kind_type kind () const YY_NOEXCEPT;]b4_glr2_cc_if([], [[
|
||||||
|
|
||||||
/// Backward compatibility (Bison 3.6).
|
/// Backward compatibility (Bison 3.6).
|
||||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||||
|
|
||||||
/// The symbol kind.
|
/// The symbol kind.
|
||||||
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||||
symbol_kind_type kind_;
|
symbol_kind_type kind_;
|
||||||
};
|
};]b4_glr2_cc_if([], [[
|
||||||
|
|
||||||
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
||||||
typedef by_kind by_type;
|
typedef by_kind by_type;]])[
|
||||||
|
|
||||||
/// "External" symbols: returned by the scanner.
|
/// "External" symbols: returned by the scanner.
|
||||||
struct symbol_type : basic_symbol<by_kind>
|
struct symbol_type : basic_symbol<by_kind>
|
||||||
@@ -455,7 +490,7 @@ m4_define([b4_symbol_type_define],
|
|||||||
typedef basic_symbol<by_kind> super_type;
|
typedef basic_symbol<by_kind> super_type;
|
||||||
|
|
||||||
/// Empty symbol.
|
/// Empty symbol.
|
||||||
symbol_type () {}
|
symbol_type () YY_NOEXCEPT {}
|
||||||
|
|
||||||
/// Constructor for valueless symbols, and symbols from each type.
|
/// Constructor for valueless symbols, and symbols from each type.
|
||||||
]b4_type_foreach([_b4_symbol_constructor_define])dnl
|
]b4_type_foreach([_b4_symbol_constructor_define])dnl
|
||||||
@@ -501,12 +536,14 @@ m4_define([b4_public_types_define],
|
|||||||
(void) v;
|
(void) v;
|
||||||
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||||
|
|
||||||
|
]b4_glr2_cc_if([], [[
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class[::symbol_kind_type
|
]b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return this->kind ();
|
return this->kind ();
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
bool
|
bool
|
||||||
@@ -527,26 +564,43 @@ m4_define([b4_public_types_define],
|
|||||||
}
|
}
|
||||||
|
|
||||||
// by_kind.
|
// by_kind.
|
||||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT
|
||||||
: kind_ (]b4_symbol(empty, kind)[)
|
: kind_ (]b4_symbol(empty, kind)[)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that)
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
|
||||||
: kind_ (that.kind_)
|
: kind_ (that.kind_)
|
||||||
{
|
{
|
||||||
that.clear ();
|
that.clear ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that)
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
|
||||||
: kind_ (that.kind_)
|
: kind_ (that.kind_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t)
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
|
||||||
: kind_ (yytranslate_ (t))
|
: kind_ (yytranslate_ (t))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
]b4_glr2_cc_if([[
|
||||||
|
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||||
|
b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that)
|
||||||
|
{
|
||||||
|
kind_ = that.kind_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||||
|
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that)
|
||||||
|
{
|
||||||
|
kind_ = that.kind_;
|
||||||
|
that.clear ();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
]b4_inline([$1])[void
|
]b4_inline([$1])[void
|
||||||
]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
|
]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
@@ -566,11 +620,13 @@ m4_define([b4_public_types_define],
|
|||||||
return kind_;
|
return kind_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]b4_glr2_cc_if([], [[
|
||||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return this->kind ();
|
return this->kind ();
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
@@ -587,7 +643,7 @@ m4_define([b4_token_constructor_define], [])
|
|||||||
# sometimes in the cc file.
|
# sometimes in the cc file.
|
||||||
m4_define([b4_yytranslate_define],
|
m4_define([b4_yytranslate_define],
|
||||||
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::yytranslate_ (int t)
|
]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
]b4_api_token_raw_if(
|
]b4_api_token_raw_if(
|
||||||
[[ return static_cast<symbol_kind_type> (t);]],
|
[[ return static_cast<symbol_kind_type> (t);]],
|
||||||
|
|||||||
+2501
-2440
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -325,19 +325,19 @@ m4_define([b4_shared_declarations],
|
|||||||
|
|
||||||
/// Whether the given \c yypact_ value indicates a defaulted state.
|
/// Whether the given \c yypact_ value indicates a defaulted state.
|
||||||
/// \param yyvalue the value to check
|
/// \param yyvalue the value to check
|
||||||
static bool yy_pact_value_is_default_ (int yyvalue);
|
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
|
||||||
|
|
||||||
/// Whether the given \c yytable_ value indicates a syntax error.
|
/// Whether the given \c yytable_ value indicates a syntax error.
|
||||||
/// \param yyvalue the value to check
|
/// \param yyvalue the value to check
|
||||||
static bool yy_table_value_is_error_ (int yyvalue);
|
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
|
||||||
|
|
||||||
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
|
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
|
||||||
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
|
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
|
||||||
|
|
||||||
/// Convert a scanner token kind \a t to a symbol kind.
|
/// Convert a scanner token kind \a t to a symbol kind.
|
||||||
/// In theory \a t should be a token_kind_type, but character literals
|
/// In theory \a t should be a token_kind_type, but character literals
|
||||||
/// are valid, yet not members of the token_type enum.
|
/// are valid, yet not members of the token_kind_type enum.
|
||||||
static symbol_kind_type yytranslate_ (int t);
|
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
|
||||||
|
|
||||||
]b4_parse_error_bmatch(
|
]b4_parse_error_bmatch(
|
||||||
[simple],
|
[simple],
|
||||||
@@ -474,7 +474,7 @@ m4_define([b4_shared_declarations],
|
|||||||
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
|
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||||
|
|
||||||
/// Pop \a n symbols from the stack.
|
/// Pop \a n symbols from the stack.
|
||||||
void yypop_ (int n = 1);
|
void yypop_ (int n = 1) YY_NOEXCEPT;
|
||||||
|
|
||||||
/// Constants.
|
/// Constants.
|
||||||
enum
|
enum
|
||||||
@@ -637,9 +637,9 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*---------------.
|
/*---------.
|
||||||
| symbol kinds. |
|
| symbol. |
|
||||||
`---------------*/
|
`---------*/
|
||||||
|
|
||||||
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
|
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
|
||||||
|
|
||||||
@@ -779,7 +779,7 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class[::yypop_ (int n)
|
]b4_parser_class[::yypop_ (int n) YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
yystack_.pop (n);
|
yystack_.pop (n);
|
||||||
}
|
}
|
||||||
@@ -822,13 +822,13 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue)
|
]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return yyvalue == yypact_ninf_;
|
return yyvalue == yypact_ninf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
]b4_parser_class[::yy_table_value_is_error_ (int yyvalue)
|
]b4_parser_class[::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return yyvalue == yytable_ninf_;
|
return yyvalue == yytable_ninf_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ m4_define([b4_stack_define],
|
|||||||
typedef typename S::size_type size_type;
|
typedef typename S::size_type size_type;
|
||||||
typedef typename std::ptrdiff_t index_type;
|
typedef typename std::ptrdiff_t index_type;
|
||||||
|
|
||||||
stack (size_type n = 200)
|
stack (size_type n = 200) YY_NOEXCEPT
|
||||||
: seq_ (n)
|
: seq_ (n)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ m4_define([b4_stack_define],
|
|||||||
class slice
|
class slice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
slice (const stack& stack, index_type range)
|
slice (const stack& stack, index_type range) YY_NOEXCEPT
|
||||||
: stack_ (stack)
|
: stack_ (stack)
|
||||||
, range_ (range)
|
, range_ (range)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -470,21 +470,23 @@ m4_define([_b4_symbol_constructor_define],
|
|||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[b4_symbol([$1], [type]) v]),
|
[b4_symbol([$1], [type]) v]),
|
||||||
b4_locations_if([location_type l]))[)
|
b4_locations_if([location_type l]))[)
|
||||||
: super_type(]b4_join([token_type (tok)],
|
: super_type (]b4_join([token_kind_type (tok)],
|
||||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||||
b4_locations_if([std::move (l)]))[)
|
b4_locations_if([std::move (l)]))[)
|
||||||
#else
|
#else
|
||||||
symbol_type (]b4_join(
|
symbol_type (]b4_join(
|
||||||
[int tok],
|
[int tok],
|
||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[const b4_symbol([$1], [type])& v]),
|
[const b4_symbol([$1], [type])& v]),
|
||||||
b4_locations_if([const location_type& l]))[)
|
b4_locations_if([const location_type& l]))[)
|
||||||
: super_type(]b4_join([token_type (tok)],
|
: super_type (]b4_join([token_kind_type (tok)],
|
||||||
b4_symbol_if([$1], [has_type], [v]),
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
b4_locations_if([l]))[)
|
b4_locations_if([l]))[)
|
||||||
#endif
|
#endif
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
|
#if !defined _MSC_VER || defined __clang__
|
||||||
]b4_assert[ (]b4_tok_in($@)[);
|
]b4_assert[ (]b4_tok_in($@)[);
|
||||||
|
#endif
|
||||||
]])[}
|
]])[}
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ m4_define([b4_declare_yyparse],
|
|||||||
# Comply with POSIX Yacc.
|
# Comply with POSIX Yacc.
|
||||||
# <https://austingroupbugs.net/view.php?id=1388#c5220>
|
# <https://austingroupbugs.net/view.php?id=1388#c5220>
|
||||||
m4_define([b4_declare_yyerror_and_yylex],
|
m4_define([b4_declare_yyerror_and_yylex],
|
||||||
[b4_yacc_if([[#if !defined ]b4_prefix[error && !defined ]b4_api_PREFIX[ERROR_IS_DECLARED
|
[b4_posix_if([[#if !defined ]b4_prefix[error && !defined ]b4_api_PREFIX[ERROR_IS_DECLARED
|
||||||
]b4_function_declare([b4_prefix[error]], void, b4_yyerror_formals)[
|
]b4_function_declare([b4_prefix[error]], void, b4_yyerror_formals)[
|
||||||
#endif
|
#endif
|
||||||
#if !defined ]b4_prefix[lex && !defined ]b4_api_PREFIX[LEX_IS_DECLARED
|
#if !defined ]b4_prefix[lex && !defined ]b4_api_PREFIX[LEX_IS_DECLARED
|
||||||
|
|||||||
+13
-10
@@ -1283,17 +1283,17 @@ follows:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
stmt:
|
stmt:
|
||||||
expr ';' %merge <stmtMerge>
|
expr ';' %merge <stmt_merge>
|
||||||
| decl %merge <stmtMerge>
|
| decl %merge <stmt_merge>
|
||||||
;
|
;
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
and define the @code{stmtMerge} function as:
|
and define the @code{stmt_merge} function as:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static YYSTYPE
|
static YYSTYPE
|
||||||
stmtMerge (YYSTYPE x0, YYSTYPE x1)
|
stmt_merge (YYSTYPE x0, YYSTYPE x1)
|
||||||
@{
|
@{
|
||||||
printf ("<OR> ");
|
printf ("<OR> ");
|
||||||
return "";
|
return "";
|
||||||
@@ -1306,7 +1306,7 @@ in the C declarations at the beginning of the file:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
%@{
|
%@{
|
||||||
static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
static YYSTYPE stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
%@}
|
%@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -1331,7 +1331,7 @@ previous example, the merged-to symbol (@code{stmt}) does not have a
|
|||||||
specific type, and the merger is
|
specific type, and the merger is
|
||||||
|
|
||||||
@example
|
@example
|
||||||
YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
YYSTYPE stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -1358,12 +1358,12 @@ or
|
|||||||
then the prototype of the merger must be:
|
then the prototype of the merger must be:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
Node *stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
(This signature might be a mistake originally, and maybe it should have been
|
(This signature might be a mistake originally, and maybe it should have been
|
||||||
@samp{Node *stmtMerge (Node *x0, Node *x1)}. If you have an opinion about
|
@samp{Node *stmt_merge (Node *x0, Node *x1)}. If you have an opinion about
|
||||||
it, please let us know.)
|
it, please let us know.)
|
||||||
|
|
||||||
@node GLR Semantic Actions
|
@node GLR Semantic Actions
|
||||||
@@ -11877,7 +11877,10 @@ Generate different diagnostics (it implies @option{-Wyacc}).
|
|||||||
Generate @code{#define} statements in addition to an @code{enum} to
|
Generate @code{#define} statements in addition to an @code{enum} to
|
||||||
associate token codes with token kind names.
|
associate token codes with token kind names.
|
||||||
@item
|
@item
|
||||||
Generate prototypes for @code{yyerror} and @code{yylex} (since Bison 3.8):
|
If the @code{POSIXLY_CORRECT} environment variable is defined, generate
|
||||||
|
prototypes for @code{yyerror} and @code{yylex}@footnote{See
|
||||||
|
@url{https://austingroupbugs.net/view.php?id=1388#c5220}.} (since Bison
|
||||||
|
3.8):
|
||||||
@example
|
@example
|
||||||
int yylex (void);
|
int yylex (void);
|
||||||
void yyerror (const char *);
|
void yyerror (const char *);
|
||||||
@@ -16594,7 +16597,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
|||||||
@c LocalWords: rpcalc Lexer Expr ltcalc mfcalc yylex defaultprec Donnelly Gotos
|
@c LocalWords: rpcalc Lexer Expr ltcalc mfcalc yylex defaultprec Donnelly Gotos
|
||||||
@c LocalWords: yyerror pxref LR yylval cindex dfn LALR samp gpl BNF xref yypush
|
@c LocalWords: yyerror pxref LR yylval cindex dfn LALR samp gpl BNF xref yypush
|
||||||
@c LocalWords: const int paren ifnotinfo AC noindent emph expr stmt findex lr
|
@c LocalWords: const int paren ifnotinfo AC noindent emph expr stmt findex lr
|
||||||
@c LocalWords: glr YYSTYPE TYPENAME prog dprec printf decl init stmtMerge POSIX
|
@c LocalWords: glr YYSTYPE TYPENAME prog dprec printf decl init POSIX ODR
|
||||||
@c LocalWords: pre STDC GNUC endif yy YY alloca lf stddef stdlib YYDEBUG yypull
|
@c LocalWords: pre STDC GNUC endif yy YY alloca lf stddef stdlib YYDEBUG yypull
|
||||||
@c LocalWords: NUM exp subsubsection kbd Ctrl ctype EOF getchar isdigit nonfree
|
@c LocalWords: NUM exp subsubsection kbd Ctrl ctype EOF getchar isdigit nonfree
|
||||||
@c LocalWords: ungetc stdin scanf sc calc ulator ls lm cc NEG prec yyerrok rr
|
@c LocalWords: ungetc stdin scanf sc calc ulator ls lm cc NEG prec yyerrok rr
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ examples.
|
|||||||
Extracted from the documentation: [A Complete C++
|
Extracted from the documentation: [A Complete C++
|
||||||
Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html).
|
Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html).
|
||||||
|
|
||||||
|
## glr
|
||||||
|
|
||||||
|
This example demonstrates the use of GLR parsers to handle (local)
|
||||||
|
ambiguities in the C++ language. See the node "Merging GLR Parses" in
|
||||||
|
Bison's documentation.
|
||||||
|
|
||||||
|
It uses (Bison) variants to store objects as semantic values. It also
|
||||||
|
demonstrates custom error messages in C++.
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ This example demonstrates the use of GLR parsers to handle (local)
|
|||||||
ambiguities in the C++ language. See the node "Merging GLR Parses" in
|
ambiguities in the C++ language. See the node "Merging GLR Parses" in
|
||||||
Bison's documentation.
|
Bison's documentation.
|
||||||
|
|
||||||
|
It uses (Bison) variants to store objects as semantic values. It also
|
||||||
|
demonstrates custom error messages in C++.
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
Local Variables:
|
Local Variables:
|
||||||
fill-column: 76
|
fill-column: 76
|
||||||
|
|||||||
@@ -47,4 +47,4 @@ run 0 "\
|
|||||||
5.0-13: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
|
5.0-13: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
|
||||||
7.0-15: <error>
|
7.0-15: <error>
|
||||||
9.0-5: +(z, q)
|
9.0-5: +(z, q)
|
||||||
err: 7.5: syntax error, unexpected identifier, expecting = or + or )"
|
err: 7.5: syntax error on token identifier (expected = or + or ))"
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
%locations
|
%locations
|
||||||
%debug
|
%debug
|
||||||
|
|
||||||
// Nice error messages with details.
|
// Custom error messages.
|
||||||
%define parse.error detailed
|
%define parse.error custom
|
||||||
|
|
||||||
%code requires
|
%code requires
|
||||||
{
|
{
|
||||||
@@ -44,9 +44,11 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
// Merge two semantic values.
|
||||||
static Node
|
static Node
|
||||||
stmtMerge (const Node& x0, const Node& x1);
|
stmt_merge (const Node& x0, const Node& x1);
|
||||||
|
|
||||||
|
// Fetch a token.
|
||||||
static yy::parser::symbol_type
|
static yy::parser::symbol_type
|
||||||
yylex ();
|
yylex ();
|
||||||
}
|
}
|
||||||
@@ -74,9 +76,9 @@ prog : %empty
|
|||||||
| prog stmt { std::cout << @2 << ": " << $2 << '\n'; }
|
| prog stmt { std::cout << @2 << ": " << $2 << '\n'; }
|
||||||
;
|
;
|
||||||
|
|
||||||
stmt : expr ";" %merge <stmtMerge> { $$ = $1; }
|
stmt : expr ";" %merge <stmt_merge> { $$ = $1; }
|
||||||
| decl %merge <stmtMerge>
|
| decl %merge <stmt_merge>
|
||||||
| error ";" { $$ = Nterm ("<error>"); }
|
| error ";" { $$ = Nterm ("<error>"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
expr : ID
|
expr : ID
|
||||||
@@ -100,13 +102,41 @@ declarator
|
|||||||
std::istream* input = nullptr;
|
std::istream* input = nullptr;
|
||||||
yy::parser::location_type loc;
|
yy::parser::location_type loc;
|
||||||
|
|
||||||
// An error reporting function.
|
|
||||||
|
/*---------.
|
||||||
|
| Parser. |
|
||||||
|
`---------*/
|
||||||
|
|
||||||
|
// Generate a custom error message.
|
||||||
|
void
|
||||||
|
yy::parser::report_syntax_error (const context& ctx) const
|
||||||
|
{
|
||||||
|
std::cerr << ctx.location () << ": syntax error";
|
||||||
|
if (!ctx.lookahead ().empty ())
|
||||||
|
std::cerr << " on token " << ctx.lookahead ().name ();
|
||||||
|
{
|
||||||
|
enum { TOKENMAX = 10 };
|
||||||
|
symbol_kind_type expected[TOKENMAX];
|
||||||
|
int n = ctx.expected_tokens (expected, TOKENMAX);
|
||||||
|
if (0 < n)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n; ++i)
|
||||||
|
std::cerr << (i == 0 ? " (expected " : " or ")
|
||||||
|
<< symbol_name (expected[i]);
|
||||||
|
std::cerr << ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cerr << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Report the error to the user.
|
||||||
void
|
void
|
||||||
yy::parser::error (const location_type& l, const std::string& m)
|
yy::parser::error (const location_type& l, const std::string& m)
|
||||||
{
|
{
|
||||||
std::cerr << l << ": " << m << '\n';
|
std::cerr << l << ": " << m << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch the next token.
|
||||||
static yy::parser::symbol_type
|
static yy::parser::symbol_type
|
||||||
yylex ()
|
yylex ()
|
||||||
{
|
{
|
||||||
@@ -168,12 +198,19 @@ yylex ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge two semantic values as an AST including both alternatives.
|
||||||
static Node
|
static Node
|
||||||
stmtMerge (const Node& x0, const Node& x1)
|
stmt_merge (const Node& x0, const Node& x1)
|
||||||
{
|
{
|
||||||
return Nterm ("<OR>", x0, x1);
|
return Nterm ("<OR>", x0, x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------.
|
||||||
|
| Main. |
|
||||||
|
`-------*/
|
||||||
|
|
||||||
|
// Parse `file` using parser `parse`.
|
||||||
int
|
int
|
||||||
process (yy::parser& parse, const std::string& file)
|
process (yy::parser& parse, const std::string& file)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -465,8 +465,9 @@ yyreport_syntax_error (const yypcontext_t *ctx, const user_context *uctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Called by yyparse on error.
|
// Called by yyparse on errors to report the error to the user.
|
||||||
void yyerror (const YYLTYPE *loc, const user_context *uctx, char const *format, ...)
|
void
|
||||||
|
yyerror (const YYLTYPE *loc, const user_context *uctx, char const *format, ...)
|
||||||
{
|
{
|
||||||
if (uctx->silent)
|
if (uctx->silent)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
static void free_node (Node *);
|
static void free_node (Node *);
|
||||||
static char *node_to_string (const Node *);
|
static char *node_to_string (const Node *);
|
||||||
static void node_print (FILE *, const Node *);
|
static void node_print (FILE *, const Node *);
|
||||||
static Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
static Node *stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
|
|
||||||
static void yyerror (YYLTYPE const * const loc, const char *msg);
|
static void yyerror (YYLTYPE const * const loc, const char *msg);
|
||||||
static yytoken_kind_t yylex (YYSTYPE *lval, YYLTYPE *lloc);
|
static yytoken_kind_t yylex (YYSTYPE *lval, YYLTYPE *lloc);
|
||||||
@@ -83,9 +83,9 @@
|
|||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
|
|
||||||
%type <Node*> stmt expr decl declarator TYPENAME ID
|
%type <Node *> stmt expr decl declarator TYPENAME ID
|
||||||
%destructor { free_node ($$); } <Node*>
|
%destructor { free_node ($$); } <Node *>
|
||||||
%printer { node_print (yyo, $$); } <Node*>
|
%printer { node_print (yyo, $$); } <Node *>
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ prog : %empty
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
stmt : expr ';' %merge <stmtMerge> { $$ = $1; }
|
stmt : expr ';' %merge <stmt_merge> { $$ = $1; }
|
||||||
| decl %merge <stmtMerge>
|
| decl %merge <stmt_merge>
|
||||||
| error ';' { $$ = new_nterm ("<error>", NULL, NULL, NULL); }
|
| error ';' { $$ = new_nterm ("<error>", NULL, NULL, NULL); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ node_print (FILE *out, const Node *n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Node*
|
static Node *
|
||||||
stmtMerge (YYSTYPE x0, YYSTYPE x1)
|
stmt_merge (YYSTYPE x0, YYSTYPE x1)
|
||||||
{
|
{
|
||||||
return new_nterm ("<OR>(%s, %s)", x0.stmt, x1.stmt, NULL);
|
return new_nterm ("<OR>(%s, %s)", x0.stmt, x1.stmt, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,26 +38,9 @@ run -noerr 0 9 -p
|
|||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
(1+2) *
|
(1+2) *
|
||||||
EOF
|
EOF
|
||||||
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number
|
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number'
|
||||||
err: errors: 1'
|
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
1 / (2 - 2)
|
1 / (2 - 2)
|
||||||
EOF
|
EOF
|
||||||
run 1 'err: 1.1-11: error: division by zero
|
run 1 'err: 1.1-11: error: division by zero'
|
||||||
err: errors: 1'
|
|
||||||
|
|
||||||
|
|
||||||
# Multistart: parse "expression" instead of "input".
|
|
||||||
cat >input <<EOF
|
|
||||||
1+2*3
|
|
||||||
EOF
|
|
||||||
run 0 'expression: 7' -e
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
1
|
|
||||||
2
|
|
||||||
EOF
|
|
||||||
run 1 'expression: failure
|
|
||||||
err: 2.1: syntax error, unexpected number, expecting end of file
|
|
||||||
err: errors: 1' -e
|
|
||||||
|
|||||||
+14
-34
@@ -25,10 +25,10 @@
|
|||||||
{
|
{
|
||||||
// Tell Flex the expected prototype of yylex.
|
// Tell Flex the expected prototype of yylex.
|
||||||
#define YY_DECL \
|
#define YY_DECL \
|
||||||
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc)
|
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc, int *nerrs)
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
void yyerror (const YYLTYPE *loc, const char *msg);
|
void yyerror (const YYLTYPE *loc, int *nerrs, const char *msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emitted on top of the implementation file.
|
// Emitted on top of the implementation file.
|
||||||
@@ -62,6 +62,9 @@
|
|||||||
// Enable debug traces (see yydebug in main).
|
// Enable debug traces (see yydebug in main).
|
||||||
%define parse.trace
|
%define parse.trace
|
||||||
|
|
||||||
|
// Error count, exchanged between main, yyparse and yylex.
|
||||||
|
%param {int *nerrs}
|
||||||
|
|
||||||
%token
|
%token
|
||||||
PLUS "+"
|
PLUS "+"
|
||||||
MINUS "-"
|
MINUS "-"
|
||||||
@@ -73,11 +76,9 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
%token <int> NUM "number"
|
%token <int> NUM "number"
|
||||||
%type <int> exp expression line
|
%type <int> exp
|
||||||
%printer { fprintf (yyo, "%d", $$); } <int>
|
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||||
|
|
||||||
%start input expression NUM
|
|
||||||
|
|
||||||
// Precedence (from lowest to highest) and associativity.
|
// Precedence (from lowest to highest) and associativity.
|
||||||
%left "+" "-"
|
%left "+" "-"
|
||||||
%left "*" "/"
|
%left "*" "/"
|
||||||
@@ -90,12 +91,8 @@ input:
|
|||||||
;
|
;
|
||||||
|
|
||||||
line:
|
line:
|
||||||
exp EOL { $$ = $exp; printf ("%d\n", $$); }
|
exp EOL { printf ("%d\n", $exp); }
|
||||||
| error EOL { $$ = 0; yyerrok; }
|
| error EOL { yyerrok; }
|
||||||
;
|
|
||||||
|
|
||||||
expression:
|
|
||||||
exp EOL { $$ = $exp; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
exp:
|
exp:
|
||||||
@@ -106,7 +103,7 @@ exp:
|
|||||||
{
|
{
|
||||||
if ($3 == 0)
|
if ($3 == 0)
|
||||||
{
|
{
|
||||||
yyerror (&@$, "error: division by zero");
|
yyerror (&@$, nerrs, "error: division by zero");
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -118,41 +115,24 @@ exp:
|
|||||||
%%
|
%%
|
||||||
// Epilogue (C code).
|
// Epilogue (C code).
|
||||||
|
|
||||||
void yyerror (const YYLTYPE *loc, const char *msg)
|
void yyerror (const YYLTYPE *loc, int *nerrs, const char *msg)
|
||||||
{
|
{
|
||||||
YYLOCATION_PRINT (stderr, loc);
|
YYLOCATION_PRINT (stderr, loc);
|
||||||
fprintf (stderr, ": %s\n", msg);
|
fprintf (stderr, ": %s\n", msg);
|
||||||
|
++*nerrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, const char *argv[])
|
int main (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
// Possibly enable parser runtime debugging.
|
// Possibly enable parser runtime debugging.
|
||||||
yydebug = !!getenv ("YYDEBUG");
|
yydebug = !!getenv ("YYDEBUG");
|
||||||
int parse_expression_p = 0;
|
|
||||||
int nerrs = 0;
|
|
||||||
|
|
||||||
// Enable parse traces on option -p.
|
// Enable parse traces on option -p.
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
if (strcmp (argv[i], "-e") == 0)
|
if (strcmp (argv[i], "-p") == 0)
|
||||||
parse_expression_p = 1;
|
|
||||||
else if (strcmp (argv[i], "-p") == 0)
|
|
||||||
yydebug = 1;
|
yydebug = 1;
|
||||||
|
|
||||||
if (parse_expression_p)
|
int nerrs = 0;
|
||||||
{
|
yyparse (&nerrs);
|
||||||
yyparse_expression_t res = yyparse_expression ();
|
|
||||||
nerrs = res.yynerrs;
|
|
||||||
if (res.yystatus == 0)
|
|
||||||
printf ("expression: %d\n", res.yyvalue);
|
|
||||||
else
|
|
||||||
printf ("expression: failure\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nerrs = yyparse_input ().yynerrs;
|
|
||||||
|
|
||||||
if (nerrs)
|
|
||||||
fprintf (stderr, "errors: %d\n", nerrs);
|
|
||||||
|
|
||||||
// Exit on failure if there were errors.
|
// Exit on failure if there were errors.
|
||||||
return !!nerrs;
|
return !!nerrs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
long n = strtol (yytext, NULL, 10);
|
long n = strtol (yytext, NULL, 10);
|
||||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||||
yyerror (yylloc, "integer is out of range");
|
yyerror (yylloc, nerrs, "integer is out of range");
|
||||||
yylval->TOK_NUM = (int) n;
|
yylval->TOK_NUM = (int) n;
|
||||||
return TOK_NUM;
|
return TOK_NUM;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
/* Ignore white spaces. */
|
/* Ignore white spaces. */
|
||||||
[ \t]+ LOCATION_STEP (); continue;
|
[ \t]+ LOCATION_STEP (); continue;
|
||||||
|
|
||||||
. yyerror (yylloc, "syntax error, invalid character"); continue;
|
. yyerror (yylloc, nerrs, "syntax error, invalid character"); continue;
|
||||||
|
|
||||||
<<EOF>> return TOK_YYEOF;
|
<<EOF>> return TOK_YYEOF;
|
||||||
%%
|
%%
|
||||||
|
|||||||
+1
-1
Submodule gnulib updated: 964ce0a92b...7818455627
@@ -362,6 +362,7 @@
|
|||||||
/stat-w32.c
|
/stat-w32.c
|
||||||
/stat-w32.h
|
/stat-w32.h
|
||||||
/stat.c
|
/stat.c
|
||||||
|
/stdalign.in.h
|
||||||
/stdbool.h
|
/stdbool.h
|
||||||
/stdbool.in.h
|
/stdbool.in.h
|
||||||
/stddef.h
|
/stddef.h
|
||||||
@@ -391,6 +392,7 @@
|
|||||||
/stripslash.c
|
/stripslash.c
|
||||||
/strndup.c
|
/strndup.c
|
||||||
/strnlen.c
|
/strnlen.c
|
||||||
|
/strtod.c
|
||||||
/strverscmp.c
|
/strverscmp.c
|
||||||
/sys
|
/sys
|
||||||
/sys_ioctl.in.h
|
/sys_ioctl.in.h
|
||||||
|
|||||||
@@ -200,6 +200,7 @@
|
|||||||
/stat-time.m4
|
/stat-time.m4
|
||||||
/stat.m4
|
/stat.m4
|
||||||
/std-gnu11.m4
|
/std-gnu11.m4
|
||||||
|
/stdalign.m4
|
||||||
/stdbool.m4
|
/stdbool.m4
|
||||||
/stddef_h.m4
|
/stddef_h.m4
|
||||||
/stdint.m4
|
/stdint.m4
|
||||||
@@ -216,6 +217,7 @@
|
|||||||
/strings_h.m4
|
/strings_h.m4
|
||||||
/strndup.m4
|
/strndup.m4
|
||||||
/strnlen.m4
|
/strnlen.m4
|
||||||
|
/strtod.m4
|
||||||
/strverscmp.m4
|
/strverscmp.m4
|
||||||
/sys_ioctl_h.m4
|
/sys_ioctl_h.m4
|
||||||
/sys_resource_h.m4
|
/sys_resource_h.m4
|
||||||
|
|||||||
+24
-22
@@ -7,36 +7,22 @@
|
|||||||
# with or without modifications, as long as this notice is preserved.
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_98_snippet],
|
m4_define([_BISON_CXXSTD_98_snippet],
|
||||||
[[#include <cassert>
|
[[]])
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void cxx98_vector ()
|
|
||||||
{
|
|
||||||
typedef std::vector<int> ints;
|
|
||||||
|
|
||||||
// Check support for std::vector<T,Allocator>::data.
|
|
||||||
// GCC 4.2 on macOS claims to support C++98, but does not feature it.
|
|
||||||
//
|
|
||||||
// input.cc: In member function 'void state_stack::yycompressStack()':
|
|
||||||
// input.cc:1774: error: 'class std::vector<glr_stack_item, std::allocator<glr_stack_item> >' has no member named 'data'
|
|
||||||
//
|
|
||||||
// <https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>.
|
|
||||||
ints my_ints;
|
|
||||||
assert (my_ints.data () == &my_ints[0]);
|
|
||||||
}
|
|
||||||
]])
|
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_03_snippet],
|
m4_define([_BISON_CXXSTD_03_snippet],
|
||||||
[])
|
[[]])
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_11_snippet],
|
m4_define([_BISON_CXXSTD_11_snippet],
|
||||||
[[#include <algorithm>
|
[[ // C++11
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility> // std::swap
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// C++11
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct check
|
struct check
|
||||||
{
|
{
|
||||||
@@ -80,6 +66,22 @@ m4_define([_BISON_CXXSTD_11_snippet],
|
|||||||
|
|
||||||
// GCC 4.8.2 on Solaris 11.3 does not support to_string.
|
// GCC 4.8.2 on Solaris 11.3 does not support to_string.
|
||||||
auto e = std::to_string(42);
|
auto e = std::to_string(42);
|
||||||
|
|
||||||
|
// Needed by glr2.cc.
|
||||||
|
void cxx11_vector_data ()
|
||||||
|
{
|
||||||
|
std::vector<int> ints;
|
||||||
|
ints.emplace_back (42);
|
||||||
|
assert (ints.data () == &ints[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needed by glr2.cc.
|
||||||
|
void cxx11_array_swap ()
|
||||||
|
{
|
||||||
|
int i0[4] = { 1, 2, 3, 4 };
|
||||||
|
int i1[4] = { 5, 6, 7, 8 };
|
||||||
|
std::swap (i0, i1);
|
||||||
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_14_snippet],
|
m4_define([_BISON_CXXSTD_14_snippet],
|
||||||
@@ -177,7 +179,7 @@ m4_define([_BISON_CXXSTD_testbody],
|
|||||||
|
|
||||||
# BISON_CXXSTD(STD)
|
# BISON_CXXSTD(STD)
|
||||||
# -----------------
|
# -----------------
|
||||||
# Check whether the C++ compiler support STD (11, 98, 2b, etc.).
|
# Check whether the C++ compiler supports STD (11, 98, 2b, etc.).
|
||||||
# If it does, AC_SUBST 'CXX<STD>_CXXFLAGS' to the corresponding flags.
|
# If it does, AC_SUBST 'CXX<STD>_CXXFLAGS' to the corresponding flags.
|
||||||
AC_DEFUN([BISON_CXXSTD],
|
AC_DEFUN([BISON_CXXSTD],
|
||||||
[AC_REQUIRE([AC_PROG_CXX])
|
[AC_REQUIRE([AC_PROG_CXX])
|
||||||
|
|||||||
@@ -28,17 +28,13 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
|
|||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[
|
[[
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
using namespace std;]],
|
using namespace std;]],
|
||||||
[[std::cerr << "";
|
[[std::cerr << "";
|
||||||
cout << "";
|
cout << "";
|
||||||
std::vector<int> ints;
|
|
||||||
assert(ints.data () == &ints[0]);
|
|
||||||
typedef std::pair<unsigned, int> uipair;
|
typedef std::pair<unsigned, int> uipair;
|
||||||
std::map<unsigned, int> m;
|
std::map<unsigned, int> m;
|
||||||
std::map<unsigned, int>::iterator i;
|
std::map<unsigned, int>::iterator i;
|
||||||
|
|||||||
@@ -57,12 +57,12 @@
|
|||||||
|
|
||||||
/** The time limit before printing an assurance message to the user to
|
/** The time limit before printing an assurance message to the user to
|
||||||
* indicate that the search is still running. */
|
* indicate that the search is still running. */
|
||||||
#define ASSURANCE_LIMIT 2.0f
|
#define ASSURANCE_LIMIT 2.0
|
||||||
|
|
||||||
/* The time limit before giving up looking for unifying counterexample. */
|
/* The time limit before giving up looking for unifying counterexample. */
|
||||||
static float time_limit = 5.0f;
|
static double time_limit = 5.0;
|
||||||
|
|
||||||
#define CUMULATIVE_TIME_LIMIT 120.0f
|
#define CUMULATIVE_TIME_LIMIT 120.0
|
||||||
|
|
||||||
// This is the fastest way to get the tail node from the gl_list API.
|
// This is the fastest way to get the tail node from the gl_list API.
|
||||||
static gl_list_node_t
|
static gl_list_node_t
|
||||||
@@ -1164,7 +1164,7 @@ unifying_example (state_item_number itm1,
|
|||||||
}
|
}
|
||||||
if (TIME_LIMIT_ENFORCED)
|
if (TIME_LIMIT_ENFORCED)
|
||||||
{
|
{
|
||||||
float time_passed = difftime (time (NULL), start);
|
double time_passed = difftime (time (NULL), start);
|
||||||
if (!assurance_printed && time_passed > ASSURANCE_LIMIT
|
if (!assurance_printed && time_passed > ASSURANCE_LIMIT
|
||||||
&& stage3result)
|
&& stage3result)
|
||||||
{
|
{
|
||||||
@@ -1218,7 +1218,7 @@ counterexample_init (void)
|
|||||||
if (cp)
|
if (cp)
|
||||||
{
|
{
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
float v = strtof (cp, &end);
|
double v = strtod (cp, &end);
|
||||||
if (*end == '\0' && errno == 0)
|
if (*end == '\0' && errno == 0)
|
||||||
time_limit = v;
|
time_limit = v;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-3
@@ -71,6 +71,18 @@ struct bison_language const *language = &valid_languages[0];
|
|||||||
|
|
||||||
typedef int* (xargmatch_fn) (const char *context, const char *arg);
|
typedef int* (xargmatch_fn) (const char *context, const char *arg);
|
||||||
|
|
||||||
|
void
|
||||||
|
set_yacc (location loc)
|
||||||
|
{
|
||||||
|
yacc_loc = loc;
|
||||||
|
if (getenv ("POSIXLY_CORRECT"))
|
||||||
|
muscle_percent_define_insert ("posix",
|
||||||
|
loc,
|
||||||
|
muscle_keyword, "",
|
||||||
|
MUSCLE_PERCENT_DEFINE_D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Decode an option's key.
|
/** Decode an option's key.
|
||||||
*
|
*
|
||||||
* \param opt option being decoded.
|
* \param opt option being decoded.
|
||||||
@@ -631,8 +643,7 @@ static struct option const long_options[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Build a location for the current command line argument. */
|
/* Build a location for the current command line argument. */
|
||||||
static
|
static location
|
||||||
location
|
|
||||||
command_line_location (void)
|
command_line_location (void)
|
||||||
{
|
{
|
||||||
location res;
|
location res;
|
||||||
@@ -835,7 +846,7 @@ getargs (int argc, char *argv[])
|
|||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
warning_argmatch ("yacc", 0, 0);
|
warning_argmatch ("yacc", 0, 0);
|
||||||
yacc_loc = loc;
|
set_yacc (loc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_OPTION:
|
case COLOR_OPTION:
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ void getargs (int argc, char *argv[]);
|
|||||||
/* Used by parse-gram.y. */
|
/* Used by parse-gram.y. */
|
||||||
void language_argmatch (char const *arg, int prio, location loc);
|
void language_argmatch (char const *arg, int prio, location loc);
|
||||||
void skeleton_arg (const char *arg, int prio, location loc);
|
void skeleton_arg (const char *arg, int prio, location loc);
|
||||||
|
void set_yacc (location loc);
|
||||||
|
|
||||||
/** In the string \c s, replace all characters \c from by \c to. */
|
/** In the string \c s, replace all characters \c from by \c to. */
|
||||||
void tr (char *s, char from, char to);
|
void tr (char *s, char from, char to);
|
||||||
|
|||||||
+11
-5
@@ -512,22 +512,28 @@ location_empty (location loc)
|
|||||||
&& !loc.end.file && !loc.end.line && !loc.end.column;
|
&& !loc.end.file && !loc.end.line && !loc.end.column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
str_to_int (const char *s)
|
||||||
|
{
|
||||||
|
long l = strtol (s, NULL, 10);
|
||||||
|
return l < 0 ? -1 : l <= INT_MAX ? l : INT_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
boundary_set_from_string (boundary *bound, char *str)
|
boundary_set_from_string (boundary *bound, char *str)
|
||||||
{
|
{
|
||||||
/* Must search in reverse since the file name field may contain '.'
|
/* Search backwards: the file name may contain '.' or ':'. */
|
||||||
or ':'. */
|
|
||||||
char *at = strrchr (str, '@');
|
char *at = strrchr (str, '@');
|
||||||
if (at)
|
if (at)
|
||||||
{
|
{
|
||||||
*at = '\0';
|
*at = '\0';
|
||||||
bound->byte = atoi (at+1);
|
bound->byte = str_to_int (at + 1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
char *dot = strrchr (str, '.');
|
char *dot = strrchr (str, '.');
|
||||||
aver (dot);
|
aver (dot);
|
||||||
*dot = '\0';
|
*dot = '\0';
|
||||||
bound->column = atoi (dot+1);
|
bound->column = str_to_int (dot + 1);
|
||||||
if (!at)
|
if (!at)
|
||||||
bound->byte = bound->column;
|
bound->byte = bound->column;
|
||||||
}
|
}
|
||||||
@@ -535,7 +541,7 @@ boundary_set_from_string (boundary *bound, char *str)
|
|||||||
char *colon = strrchr (str, ':');
|
char *colon = strrchr (str, ':');
|
||||||
aver (colon);
|
aver (colon);
|
||||||
*colon = '\0';
|
*colon = '\0';
|
||||||
bound->line = atoi (colon+1);
|
bound->line = str_to_int (colon + 1);
|
||||||
}
|
}
|
||||||
bound->file = uniqstr_new (str);
|
bound->file = uniqstr_new (str);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -146,8 +146,9 @@ location_cmp (location a, location b)
|
|||||||
/* Whether this is the empty location. */
|
/* Whether this is the empty location. */
|
||||||
bool location_empty (location loc);
|
bool location_empty (location loc);
|
||||||
|
|
||||||
/* STR must be formatted as 'file:line.column@byte' or 'file:line.column',
|
/* STR must be formatted as 'file:line.column@byte' or 'file:line.column'.
|
||||||
it will be modified. */
|
It may be '<command line>:3.-1@-1', with -1 to denote no-column/no-byte.
|
||||||
|
STR will be modified. */
|
||||||
void boundary_set_from_string (boundary *bound, char *str);
|
void boundary_set_from_string (boundary *bound, char *str);
|
||||||
|
|
||||||
#endif /* ! defined LOCATION_H_ */
|
#endif /* ! defined LOCATION_H_ */
|
||||||
|
|||||||
@@ -63,6 +63,12 @@
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
char *cp = getenv ("BISON_PROGRAM_NAME");
|
||||||
|
if (cp)
|
||||||
|
argv[0] = cp;
|
||||||
|
}
|
||||||
|
|
||||||
#define DEPENDS_ON_LIBINTL 1
|
#define DEPENDS_ON_LIBINTL 1
|
||||||
set_program_name (argv[0]);
|
set_program_name (argv[0]);
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|||||||
+2
-1
@@ -517,8 +517,9 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
|||||||
char const *current_value = muscle_find_const (name);
|
char const *current_value = muscle_find_const (name);
|
||||||
if (current_value)
|
if (current_value)
|
||||||
{
|
{
|
||||||
|
long l = strtol (muscle_find_const (how_name), NULL, 10);
|
||||||
muscle_percent_define_how how_old
|
muscle_percent_define_how how_old
|
||||||
= atoi (muscle_find_const (how_name));
|
= 0 <= l && l <= INT_MAX ? l : INT_MAX;
|
||||||
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
||||||
goto end;
|
goto end;
|
||||||
/* If assigning the same value, make it a warning. */
|
/* If assigning the same value, make it a warning. */
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 3.7.5.297-b46a. */
|
/* A Bison parser, made by GNU Bison 3.8.1. */
|
||||||
|
|
||||||
/* Bison implementation for Yacc-like parsers in C
|
/* Bison implementation for Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -46,10 +46,10 @@
|
|||||||
USER NAME SPACE" below. */
|
USER NAME SPACE" below. */
|
||||||
|
|
||||||
/* Identify Bison output, and Bison version. */
|
/* Identify Bison output, and Bison version. */
|
||||||
#define YYBISON 30705
|
#define YYBISON 30801
|
||||||
|
|
||||||
/* Bison version string. */
|
/* Bison version string. */
|
||||||
#define YYBISON_VERSION "3.7.5.297-b46a"
|
#define YYBISON_VERSION "3.8.1"
|
||||||
|
|
||||||
/* Skeleton name. */
|
/* Skeleton name. */
|
||||||
#define YYSKELETON_NAME "yacc.c"
|
#define YYSKELETON_NAME "yacc.c"
|
||||||
@@ -3129,7 +3129,7 @@ handle_yacc (location const *loc)
|
|||||||
const char *directive = "%yacc";
|
const char *directive = "%yacc";
|
||||||
bison_directive (loc, directive);
|
bison_directive (loc, directive);
|
||||||
if (location_empty (yacc_loc))
|
if (location_empty (yacc_loc))
|
||||||
yacc_loc = *loc;
|
set_yacc (*loc);
|
||||||
else
|
else
|
||||||
duplicate_directive (directive, yacc_loc, *loc);
|
duplicate_directive (directive, yacc_loc, *loc);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 3.7.5.297-b46a. */
|
/* A Bison parser, made by GNU Bison 3.8.1. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -215,6 +215,7 @@ struct GRAM_LTYPE
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int gram_parse (void);
|
int gram_parse (void);
|
||||||
|
|
||||||
/* "%code provides" blocks. */
|
/* "%code provides" blocks. */
|
||||||
|
|||||||
+1
-1
@@ -1112,7 +1112,7 @@ handle_yacc (location const *loc)
|
|||||||
const char *directive = "%yacc";
|
const char *directive = "%yacc";
|
||||||
bison_directive (loc, directive);
|
bison_directive (loc, directive);
|
||||||
if (location_empty (yacc_loc))
|
if (location_empty (yacc_loc))
|
||||||
yacc_loc = *loc;
|
set_yacc (*loc);
|
||||||
else
|
else
|
||||||
duplicate_directive (directive, yacc_loc, *loc);
|
duplicate_directive (directive, yacc_loc, *loc);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-19
@@ -25,27 +25,13 @@ abs_top_builddir='@abs_top_builddir@'
|
|||||||
BISON_PKGDATADIR=$abs_top_srcdir/data
|
BISON_PKGDATADIR=$abs_top_srcdir/data
|
||||||
export BISON_PKGDATADIR
|
export BISON_PKGDATADIR
|
||||||
|
|
||||||
stderr=tmp-bison.$$
|
|
||||||
|
|
||||||
# If stderr is a tty, force --color=yes to simulate --color=auto
|
|
||||||
# although we save and modify stderr.
|
|
||||||
if test -t 2; then
|
|
||||||
set x --color=yes ${1+"$@"}
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
# We redirect stderr, which breaks the computation of the terminal
|
|
||||||
# screen width. So export COLUMNS to Bison, hoping for the shell to
|
|
||||||
# have defined it.
|
|
||||||
: ${COLUMNS=`(tput cols) 2>/dev/null || echo 132`}
|
|
||||||
export COLUMNS
|
|
||||||
$PREBISON "$abs_top_builddir/src/bison" ${1+"$@"} 2>"$stderr"
|
|
||||||
status=$?
|
|
||||||
|
|
||||||
# Neutralize path differences in error messages so that check and
|
# Neutralize path differences in error messages so that check and
|
||||||
# installcheck behave the same way.
|
# installcheck behave the same way.
|
||||||
sed -e "s,$abs_top_builddir/src/,,g" <"$stderr" >&2
|
BISON_PROGRAM_NAME=bison
|
||||||
rm -f "$stderr"
|
export BISON_PROGRAM_NAME
|
||||||
|
|
||||||
|
$PREBISON "$abs_top_builddir/src/bison" ${1+"$@"}
|
||||||
|
status=$?
|
||||||
|
|
||||||
# As a special dark magic, if we are actually using this wrapper to
|
# As a special dark magic, if we are actually using this wrapper to
|
||||||
# compile Bison's src/parse-gram.y, post-process the synclines to
|
# compile Bison's src/parse-gram.y, post-process the synclines to
|
||||||
|
|||||||
+3
-2
@@ -969,7 +969,7 @@ AT_DATA_GRAMMAR([[input.yy]],
|
|||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
int yylex (yy::parser::semantic_type *);
|
int yylex (yy::parser::value_type *);
|
||||||
}
|
}
|
||||||
|
|
||||||
%define parse.error verbose
|
%define parse.error verbose
|
||||||
@@ -1013,7 +1013,7 @@ AT_DATA_SOURCE([scan.cc],
|
|||||||
|
|
||||||
// 'a': valid item, 's': syntax error, 'l': lexical error.
|
// 'a': valid item, 's': syntax error, 'l': lexical error.
|
||||||
int
|
int
|
||||||
yylex (yy::parser::semantic_type *lval)
|
yylex (yy::parser::value_type *lval)
|
||||||
{
|
{
|
||||||
switch (int res = getchar ())
|
switch (int res = getchar ())
|
||||||
{
|
{
|
||||||
@@ -1031,6 +1031,7 @@ yylex (yy::parser::semantic_type *lval)
|
|||||||
AT_BISON_CHECK([[-o input.cc input.yy]])
|
AT_BISON_CHECK([[-o input.cc input.yy]])
|
||||||
|
|
||||||
AT_FOR_EACH_CXX([
|
AT_FOR_EACH_CXX([
|
||||||
|
AT_GLR2_CC_IF([AT_REQUIRE_CXX_STD(11, [echo "$at_std not supported"; continue])])
|
||||||
AT_LANG_COMPILE([[input]], [[input.cc scan.cc]])
|
AT_LANG_COMPILE([[input]], [[input.cc scan.cc]])
|
||||||
|
|
||||||
# Leave enough valid tokens to make sure we recovered from the
|
# Leave enough valid tokens to make sure we recovered from the
|
||||||
|
|||||||
+19
-2
@@ -268,7 +268,7 @@ read_integer (]AT_YYLEX_FORMALS[)
|
|||||||
|
|
||||||
|
|
||||||
m4_define([_AT_DATA_CALC_Y(c)],
|
m4_define([_AT_DATA_CALC_Y(c)],
|
||||||
[AT_DATA_GRAMMAR([calc.y],
|
[AT_DATA_GRAMMAR([calc.y.tmp],
|
||||||
[[/* Infix notation calculator--calc */
|
[[/* Infix notation calculator--calc */
|
||||||
]$4[
|
]$4[
|
||||||
%code requires
|
%code requires
|
||||||
@@ -493,6 +493,18 @@ location_print (FILE *o, Span s)
|
|||||||
[AT_CALC_YYLEX
|
[AT_CALC_YYLEX
|
||||||
AT_CALC_MAIN])])
|
AT_CALC_MAIN])])
|
||||||
|
|
||||||
|
# Remove the generated prototypes.
|
||||||
|
AT_CHECK(
|
||||||
|
[AT_YACC_IF([[
|
||||||
|
if "$POSIXLY_CORRECT_IS_EXPORTED"; then
|
||||||
|
sed -e '/\/\* !POSIX \*\//d' calc.y.tmp >calc.y
|
||||||
|
else
|
||||||
|
mv calc.y.tmp calc.y
|
||||||
|
fi
|
||||||
|
]],
|
||||||
|
[[mv calc.y.tmp calc.y]])
|
||||||
|
])
|
||||||
|
|
||||||
AT_HEADER_IF([AT_DATA_SOURCE([[calc-lex.]AT_LANG_EXT],
|
AT_HEADER_IF([AT_DATA_SOURCE([[calc-lex.]AT_LANG_EXT],
|
||||||
[[#include "calc.]AT_LANG_HDR["
|
[[#include "calc.]AT_LANG_HDR["
|
||||||
|
|
||||||
@@ -970,7 +982,7 @@ AT_JAVA_IF(
|
|||||||
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
|
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
|
||||||
AT_LANG_MATCH([c\|c++\|java],
|
AT_LANG_MATCH([c\|c++\|java],
|
||||||
[AT_GLR_IF([],
|
[AT_GLR_IF([],
|
||||||
[AT_CHECK([grep -c -v -E 'Return for a new token:|LAC:' stderr],
|
[AT_CHECK([$EGREP -c -v 'Return for a new token:|LAC:' stderr],
|
||||||
[ignore],
|
[ignore],
|
||||||
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
|
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
|
||||||
])
|
])
|
||||||
@@ -1386,6 +1398,7 @@ AT_CHECK_CALC_GLR([%define api.pure %locations])
|
|||||||
AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
|
AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR([%define parse.error custom %locations %header %name-prefix "calc" %verbose])
|
AT_CHECK_CALC_GLR([%define parse.error custom %locations %header %name-prefix "calc" %verbose])
|
||||||
|
AT_CHECK_CALC_GLR([%define parse.error custom %locations %header %name-prefix "calc" %verbose %define api.pure])
|
||||||
AT_CHECK_CALC_GLR([%define parse.error detailed %locations %header %name-prefix "calc" %verbose])
|
AT_CHECK_CALC_GLR([%define parse.error detailed %locations %header %name-prefix "calc" %verbose])
|
||||||
AT_CHECK_CALC_GLR([%define parse.error verbose %locations %header %name-prefix "calc" %verbose])
|
AT_CHECK_CALC_GLR([%define parse.error verbose %locations %header %name-prefix "calc" %verbose])
|
||||||
|
|
||||||
@@ -1468,7 +1481,11 @@ AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix {calc} %ver
|
|||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%debug])
|
AT_CHECK_CALC_GLR_CC([%debug])
|
||||||
|
|
||||||
|
# parse.error.
|
||||||
|
AT_CHECK_CALC_GLR_CC([%define parse.error detailed %debug %name-prefix "calc" %verbose])
|
||||||
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose])
|
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose])
|
||||||
|
AT_CHECK_CALC([%skeleton "glr2.cc" %define parse.error custom %debug %name-prefix "calc" %verbose]) # Only glr2.cc.
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose])
|
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%locations %header %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
|
AT_CHECK_CALC_GLR_CC([%locations %header %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
|
||||||
|
|||||||
+9
-9
@@ -61,8 +61,8 @@ $1
|
|||||||
static Node *new_term (char *);
|
static Node *new_term (char *);
|
||||||
static void free_node (Node *);
|
static void free_node (Node *);
|
||||||
static char *node_to_string (Node *);
|
static char *node_to_string (Node *);
|
||||||
]m4_bmatch([$2], [stmtMerge],
|
]m4_bmatch([$2], [stmt_merge],
|
||||||
[ static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);])[
|
[ static YYSTYPE stmt_merge (YYSTYPE x0, YYSTYPE x1);])[
|
||||||
#define YYINITDEPTH 10
|
#define YYINITDEPTH 10
|
||||||
#define YYSTACKEXPANDABLE 1
|
#define YYSTACKEXPANDABLE 1
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
@@ -291,9 +291,9 @@ node_to_string (Node *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
]]
|
]]
|
||||||
m4_bmatch([$2], [stmtMerge],
|
m4_bmatch([$2], [stmt_merge],
|
||||||
[[static YYSTYPE
|
[[static YYSTYPE
|
||||||
stmtMerge (YYSTYPE x0, YYSTYPE x1)
|
stmt_merge (YYSTYPE x0, YYSTYPE x1)
|
||||||
{
|
{
|
||||||
return new_nterm ("<OR>(%s,%s)", x0, x1, YY_NULLPTR);
|
return new_nterm ("<OR>(%s,%s)", x0, x1, YY_NULLPTR);
|
||||||
}
|
}
|
||||||
@@ -431,30 +431,30 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([],
|
_AT_TEST_GLR_CXXTYPES([],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%locations],
|
_AT_TEST_GLR_CXXTYPES([%locations],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
||||||
[%merge <stmtMerge>],[%merge <stmtMerge>])
|
[%merge <stmt_merge>],[%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define parse.error verbose],
|
_AT_TEST_GLR_CXXTYPES([%define parse.error verbose],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_VERBOSE_GLR_STDERR])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_VERBOSE_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|||||||
+15
-11
@@ -42,13 +42,12 @@ yyparse ()
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
m4_define([AT_PRINT_LOOKAHEAD_DECLARE],
|
m4_define([AT_PRINT_LOOKAHEAD_DECLARE],
|
||||||
[AT_GLR2_CC_IF(
|
[AT_GLR2_CC_IF(
|
||||||
[[ static void
|
[[static void
|
||||||
print_lookahead (int yytoken, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
print_lookahead (yy::parser::symbol_type yylookahead, char const *reduction);
|
||||||
char const *reduction);
|
|
||||||
#define PRINT_LOOKAHEAD(Msg) \
|
#define PRINT_LOOKAHEAD(Msg) \
|
||||||
print_lookahead (yytoken, &yylval, &yylloc, Msg)
|
print_lookahead (yyla, Msg)
|
||||||
]],
|
]],
|
||||||
[[ static void
|
[[static void
|
||||||
print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
||||||
char const *reduction);
|
char const *reduction);
|
||||||
#define PRINT_LOOKAHEAD(Msg) \
|
#define PRINT_LOOKAHEAD(Msg) \
|
||||||
@@ -60,8 +59,7 @@ m4_define([AT_PRINT_LOOKAHEAD_DECLARE],
|
|||||||
m4_define([AT_PRINT_LOOKAHEAD_DEFINE],
|
m4_define([AT_PRINT_LOOKAHEAD_DEFINE],
|
||||||
[AT_GLR2_CC_IF(
|
[AT_GLR2_CC_IF(
|
||||||
[[static void
|
[[static void
|
||||||
print_lookahead (int yytoken, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
print_lookahead (yy::parser::symbol_type yylookahead, char const *reduction)
|
||||||
char const *reduction)
|
|
||||||
]],
|
]],
|
||||||
[[static void
|
[[static void
|
||||||
print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
||||||
@@ -80,11 +78,12 @@ print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
|||||||
// | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// 117 | : '?';
|
// 117 | : '?';
|
||||||
// | ~~~~~
|
// | ~~~~~
|
||||||
|
int yytoken = yylookahead.kind ();
|
||||||
int yychr
|
int yychr
|
||||||
= yytoken == yy::parser::symbol_kind::S_YYEMPTY ? -2
|
= yytoken == yy::parser::symbol_kind::S_YYEMPTY ? -2
|
||||||
: yytoken == yy::parser::symbol_kind::S_YYEOF ? 0
|
: yytoken == yy::parser::symbol_kind::S_YYEOF ? 0
|
||||||
: yytoken == yy::parser::yytranslate_ ('a') ? 'a'
|
: yytoken == yy::parser::symbol_kind::S_3_a_ ? 'a'
|
||||||
: yytoken == yy::parser::yytranslate_ ('b') ? 'b'
|
: yytoken == yy::parser::symbol_kind::S_4_b_ ? 'b'
|
||||||
: '?';
|
: '?';
|
||||||
]])[
|
]])[
|
||||||
printf ("%s:\n yychar=", reduction);
|
printf ("%s:\n yychar=", reduction);
|
||||||
@@ -94,12 +93,17 @@ print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
|
|||||||
printf ("YYEOF");
|
printf ("YYEOF");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf ("'%c', yylval='", yychr);
|
printf ("'%c', yylval='", yychr);]AT_GLR2_CC_IF([[
|
||||||
|
if (yylookahead.value.value > ' ')
|
||||||
|
printf ("%c", yylookahead.value.value);
|
||||||
|
printf ("', yylloc=(%d,%d),(%d,%d)",
|
||||||
|
yylookahead.location.]AT_FIRST_LINE[, yylookahead.location.]AT_FIRST_COLUMN[,
|
||||||
|
yylookahead.location.]AT_LAST_LINE[, yylookahead.location.]AT_LAST_COLUMN[);]], [[
|
||||||
if (yylvalp->value > ' ')
|
if (yylvalp->value > ' ')
|
||||||
printf ("%c", yylvalp->value);
|
printf ("%c", yylvalp->value);
|
||||||
printf ("', yylloc=(%d,%d),(%d,%d)",
|
printf ("', yylloc=(%d,%d),(%d,%d)",
|
||||||
yyllocp->]AT_FIRST_LINE[, yyllocp->]AT_FIRST_COLUMN[,
|
yyllocp->]AT_FIRST_LINE[, yyllocp->]AT_FIRST_COLUMN[,
|
||||||
yyllocp->]AT_LAST_LINE[, yyllocp->]AT_LAST_COLUMN[);
|
yyllocp->]AT_LAST_LINE[, yyllocp->]AT_LAST_COLUMN[);]])[
|
||||||
}
|
}
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-2
@@ -241,6 +241,8 @@ exp:
|
|||||||
| 'x' '9' { printf ("x9\n"); }
|
| 'x' '9' { printf ("x9\n"); }
|
||||||
| 'x' 'a' { printf ("xa\n"); }
|
| 'x' 'a' { printf ("xa\n"); }
|
||||||
| 'x' 'b' { printf ("xb\n"); }
|
| 'x' 'b' { printf ("xb\n"); }
|
||||||
|
| 'x' 'c' { printf ("xc\n"); }
|
||||||
|
| 'x' 'd' { printf ("xd\n"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -279,6 +281,8 @@ extern "C"
|
|||||||
#include "x9.hh"
|
#include "x9.hh"
|
||||||
#include "xa.hh"
|
#include "xa.hh"
|
||||||
#include "xb.hh"
|
#include "xb.hh"
|
||||||
|
#include "xc.hh"
|
||||||
|
#include "xd.hh"
|
||||||
|
|
||||||
#define RUN(S) \
|
#define RUN(S) \
|
||||||
do { \
|
do { \
|
||||||
@@ -305,6 +309,10 @@ main (void)
|
|||||||
RUN(pa.parse());
|
RUN(pa.parse());
|
||||||
xb_::parser pb;
|
xb_::parser pb;
|
||||||
RUN(pb.parse());
|
RUN(pb.parse());
|
||||||
|
xc_::parser pc;
|
||||||
|
RUN(pc.parse());
|
||||||
|
xd_::parser pd;
|
||||||
|
RUN(pd.parse());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])# main.cc
|
]])# main.cc
|
||||||
@@ -320,7 +328,8 @@ AT_TEST([x8], [%define api.pure %define api.push-pull both])
|
|||||||
AT_TEST([x9], [%locations %code requires {#include "location.hh"} %define api.location.type {::x5_::location} %debug %language "c++"])
|
AT_TEST([x9], [%locations %code requires {#include "location.hh"} %define api.location.type {::x5_::location} %debug %language "c++"])
|
||||||
AT_TEST([xa], [%locations %code requires {#include "location.hh"} %define api.location.type {::x5_::location} %language "c++" %define api.value.type variant])
|
AT_TEST([xa], [%locations %code requires {#include "location.hh"} %define api.location.type {::x5_::location} %language "c++" %define api.value.type variant])
|
||||||
AT_TEST([xb], [%locations %define api.location.file none %language "c++" %define api.value.type variant])
|
AT_TEST([xb], [%locations %define api.location.file none %language "c++" %define api.value.type variant])
|
||||||
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
|
AT_TEST([xc], [%locations %code requires {#include "location.hh"} %define api.location.type {::x5_::location} %skeleton "glr2.cc"])
|
||||||
|
AT_TEST([xd], [%locations %define api.location.file none %skeleton "glr2.cc"])
|
||||||
|
|
||||||
# Check that api.prefix works properly:
|
# Check that api.prefix works properly:
|
||||||
#
|
#
|
||||||
@@ -377,7 +386,11 @@ AT_PERL_CHECK([[-n -0777 -e '
|
|||||||
# Do this late, so that other checks have been performed.
|
# Do this late, so that other checks have been performed.
|
||||||
AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
|
AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
|
||||||
|
|
||||||
AT_COMPILE_CXX([parser], [[x[1-9a-b].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
|
# The header generated by glr2.cc requires C++11. Push the options to
|
||||||
|
# prepare AT_COMPILE_CXX.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%skeleton "glr2.cc"])
|
||||||
|
AT_COMPILE_CXX([parser], [[x[1-9a-d].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_PARSER_CHECK([parser], [0], [[expout]])
|
AT_PARSER_CHECK([parser], [0], [[expout]])
|
||||||
|
|
||||||
m4_popdef([AT_TEST])
|
m4_popdef([AT_TEST])
|
||||||
|
|||||||
+16
-11
@@ -378,7 +378,7 @@ m4_pushdef([AT_TOKEN],
|
|||||||
|
|
||||||
|
|
||||||
m4_pushdef([AT_YYSTYPE],
|
m4_pushdef([AT_YYSTYPE],
|
||||||
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::semantic_type]],
|
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::value_type]],
|
||||||
[AT_API_PREFIX[STYPE]])])
|
[AT_API_PREFIX[STYPE]])])
|
||||||
m4_pushdef([AT_YYLTYPE],
|
m4_pushdef([AT_YYLTYPE],
|
||||||
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::location_type]],
|
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::location_type]],
|
||||||
@@ -687,8 +687,8 @@ m4_define([AT_YYERROR_DECLARE_EXTERN(c)],
|
|||||||
m4_define([AT_YYERROR_DECLARE(c)],
|
m4_define([AT_YYERROR_DECLARE(c)],
|
||||||
[[#include <stdio.h>
|
[[#include <stdio.h>
|
||||||
]AT_LOCATION_PRINT_DECLARE[
|
]AT_LOCATION_PRINT_DECLARE[
|
||||||
]AT_YACC_IF([], [[static ]AT_YYERROR_DECLARE_EXTERN])])
|
/* !POSIX */ static ]AT_YYERROR_DECLARE_EXTERN[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
# "%define parse.error custom" uses a different format, easy to check.
|
# "%define parse.error custom" uses a different format, easy to check.
|
||||||
# The "verbose" one can be computed from it (see _AT_CHECK_CALC_ERROR).
|
# The "verbose" one can be computed from it (see _AT_CHECK_CALC_ERROR).
|
||||||
@@ -733,7 +733,7 @@ yyreport_syntax_error (const yypcontext_t *ctx]AT_PARAM_IF([, AT_PARSE_PARAMS])[
|
|||||||
]])[
|
]])[
|
||||||
|
|
||||||
/* A C error reporting function. */
|
/* A C error reporting function. */
|
||||||
]AT_YACC_IF([], [static])[
|
/* !POSIX */ static
|
||||||
]AT_YYERROR_PROTOTYPE[
|
]AT_YYERROR_PROTOTYPE[
|
||||||
{]m4_bpatsubst(m4_defn([AT_PARSE_PARAMS]),
|
{]m4_bpatsubst(m4_defn([AT_PARSE_PARAMS]),
|
||||||
[[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\),* *], [
|
[[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\),* *], [
|
||||||
@@ -823,11 +823,8 @@ void
|
|||||||
++*nerrs;]])[]AT_LOCATION_IF([[
|
++*nerrs;]])[]AT_LOCATION_IF([[
|
||||||
std::cerr << ctx.location () << ": ";]])[
|
std::cerr << ctx.location () << ": ";]])[
|
||||||
std::cerr << "syntax error";
|
std::cerr << "syntax error";
|
||||||
{
|
if (!ctx.lookahead ().empty ())
|
||||||
symbol_kind_type la = ctx.token ();
|
std::cerr << " on token [" << ctx.lookahead ().name () << ']';
|
||||||
if (la != symbol_kind::S_YYEMPTY)
|
|
||||||
std::cerr << " on token [" << symbol_name (la) << ']';
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
enum { TOKENMAX = 10 };
|
enum { TOKENMAX = 10 };
|
||||||
symbol_kind_type expected[TOKENMAX];
|
symbol_kind_type expected[TOKENMAX];
|
||||||
@@ -1361,11 +1358,19 @@ AT_CHECK(m4_join([ ],
|
|||||||
# If OUTPUT does not contain '.', assume that we are linking too,
|
# If OUTPUT does not contain '.', assume that we are linking too,
|
||||||
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
||||||
# with trailing ".o" removed, and ".cc" appended.
|
# with trailing ".o" removed, and ".cc" appended.
|
||||||
|
#
|
||||||
|
# glr2.cc require C++11.
|
||||||
m4_define([AT_COMPILE_CXX],
|
m4_define([AT_COMPILE_CXX],
|
||||||
[AT_KEYWORDS(c++)
|
[AT_KEYWORDS([c++])
|
||||||
AT_SKIP_IF([[! $BISON_CXX_WORKS]])
|
AT_SKIP_IF([[! $BISON_CXX_WORKS]])
|
||||||
|
m4_ifdef([AT_GLR2_CC_IF],
|
||||||
|
[AT_GLR2_CC_IF([AT_SKIP_IF([[test x"$CXX11_CXXFLAGS" == x]])])])
|
||||||
AT_CHECK(m4_join([ ],
|
AT_CHECK(m4_join([ ],
|
||||||
[$CXX $CXXFLAGS $CPPFLAGS $3],
|
[$CXX],
|
||||||
|
[$CPPFLAGS],
|
||||||
|
[m4_ifdef([AT_GLR2_CC_IF], [AT_GLR2_CC_IF([$CXX11_CXXFLAGS])])],
|
||||||
|
[$CXXFLAGS],
|
||||||
|
[$3],
|
||||||
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
||||||
[-o $1],
|
[-o $1],
|
||||||
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
|
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ m4_popdef([AT_TEST])
|
|||||||
AT_SETUP([C++ Output File Prefix Mapping])
|
AT_SETUP([C++ Output File Prefix Mapping])
|
||||||
|
|
||||||
# AT_TEST([PREFIX], [DIRECTIVES])
|
# AT_TEST([PREFIX], [DIRECTIVES])
|
||||||
|
# -------------------------------
|
||||||
m4_pushdef([AT_TEST],
|
m4_pushdef([AT_TEST],
|
||||||
[AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %define api.namespace {$1} $2])
|
[AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %define api.namespace {$1} $2])
|
||||||
AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])
|
AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])
|
||||||
|
|||||||
+1598
-1595
File diff suppressed because it is too large
Load Diff
@@ -105,6 +105,7 @@ start: $3;
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
AT_LANG_FOR_EACH_STD([
|
AT_LANG_FOR_EACH_STD([
|
||||||
|
AT_GLR2_CC_IF([AT_REQUIRE_CXX_STD(11, [echo "$at_std not supported"; continue])])
|
||||||
$7
|
$7
|
||||||
AT_FULL_COMPILE([[test]])
|
AT_FULL_COMPILE([[test]])
|
||||||
AT_PARSER_CHECK([[test]], 0, [[$6
|
AT_PARSER_CHECK([[test]], 0, [[$6
|
||||||
|
|||||||
Reference in New Issue
Block a user