mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-10 11:15:15 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a100a3c4c1 | ||
|
|
b18ceb50f1 | ||
|
|
ff4d67ede8 | ||
|
|
465babb635 | ||
|
|
6a28e6d412 | ||
|
|
f4495da337 | ||
|
|
dbaed0bbf2 | ||
|
|
78c7fb6460 | ||
|
|
da29809969 | ||
|
|
87e4895189 | ||
|
|
01e3f45f83 | ||
|
|
091943f265 | ||
|
|
bf98d94f4f | ||
|
|
6bb37dbe27 | ||
|
|
c3585f41ef | ||
|
|
6525abdc83 | ||
|
|
2b63c54f5a | ||
|
|
2da399d15f | ||
|
|
0c77d69721 | ||
|
|
307fcdee00 | ||
|
|
d26d10ad6c | ||
|
|
1b4108da3e | ||
|
|
53bfc7df94 | ||
|
|
a5fb4a88ef | ||
|
|
54df196d49 | ||
|
|
52bb6f0525 | ||
|
|
76dab18af3 | ||
|
|
c982974f33 | ||
|
|
dc2a3578b7 | ||
|
|
9661b2fcbc | ||
|
|
d9a9b054ae | ||
|
|
cb9f4cb543 | ||
|
|
b86dcaf40b | ||
|
|
0fafbbdefb | ||
|
|
4b85b969d0 | ||
|
|
7727693711 | ||
|
|
ce27796b74 | ||
|
|
6135fdc152 | ||
|
|
f1497356e8 | ||
|
|
1429569362 |
+1
-1
@@ -1 +1 @@
|
||||
3.5.92
|
||||
3.6.1
|
||||
|
||||
+58
-40
@@ -46,7 +46,7 @@ jobs:
|
||||
- ./bootstrap
|
||||
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
||||
- make -j2
|
||||
- make -j2 dist
|
||||
- make -j2 dist-xz
|
||||
# Can help understanding why we get "dirty" tarballs.
|
||||
- git status
|
||||
- dist=$(echo bison*.xz)
|
||||
@@ -69,53 +69,53 @@ jobs:
|
||||
|
||||
# Start with three completely different environments, to get errors asap.
|
||||
|
||||
- name: "GCC 9 -O3"
|
||||
- name: "GCC 10 -O3"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons: &gcc9
|
||||
addons: &gcc10
|
||||
apt:
|
||||
sources:
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
packages: g++-9
|
||||
packages: g++-10
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CC=gcc-10
|
||||
- CXX=g++-10
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
|
||||
# ASAN is time consuming, and we timeout the 50min granted by
|
||||
# Travis if we run all the tests in one go. Run in two parts.
|
||||
- name: "Clang 9 libc++ and ASAN part 1"
|
||||
- name: "Clang 10 libc++ and ASAN part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons: &clang9
|
||||
addons: &clang10
|
||||
apt:
|
||||
sources:
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
packages:
|
||||
- clang-9
|
||||
- libc++-9-dev
|
||||
- libc++abi-9-dev
|
||||
- clang-10
|
||||
- libc++-10-dev
|
||||
- libc++abi-10-dev
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- CC='clang-9 -fsanitize=address'
|
||||
- CXX='clang++-9 -fsanitize=address -stdlib=libc++'
|
||||
- CC='clang-10 -fsanitize=address'
|
||||
- CXX='clang++-10 -fsanitize=address -stdlib=libc++'
|
||||
- PART=1
|
||||
|
||||
- name: "Clang 9 libc++ and ASAN part 2"
|
||||
- name: "Clang 10 libc++ and ASAN part 2"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons: *clang9
|
||||
addons: *clang10
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- CC='clang-9 -fsanitize=address'
|
||||
- CXX='clang++-9 -fsanitize=address -stdlib=libc++'
|
||||
- CC='clang-10 -fsanitize=address'
|
||||
- CXX='clang++-10 -fsanitize=address -stdlib=libc++'
|
||||
- PART=2
|
||||
|
||||
- name: "ICC"
|
||||
@@ -135,46 +135,41 @@ jobs:
|
||||
packages:
|
||||
- intel-oneapi-icc
|
||||
|
||||
## ------- ##
|
||||
## First. ##
|
||||
## ------- ##
|
||||
|
||||
# Start with three completely different environments, to get
|
||||
# errors asap.
|
||||
|
||||
- name: "ARM64: GCC 9 -O3 part 1"
|
||||
- name: "ARM64: GCC 10 -O3 part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
arch: arm64
|
||||
dist: bionic
|
||||
addons: *gcc9
|
||||
addons: *gcc10
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CC=gcc-10
|
||||
- CXX=g++-10
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
- PART=1
|
||||
|
||||
# GCC10 on PPC seems to be buggy.
|
||||
# E.g., https://travis-ci.org/github/akimd/bison/jobs/687812428.
|
||||
- name: "PPC64le: GCC 9 part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
arch: ppc64le
|
||||
dist: bionic
|
||||
addons: *gcc9
|
||||
addons: *gcc10
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CONFIGUREFLAGS='CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
- PART=1
|
||||
|
||||
- name: "s390x: GCC 9 part 1"
|
||||
- name: "s390x: GCC 10 part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
arch: s390x
|
||||
dist: bionic
|
||||
addons: *gcc9
|
||||
addons: *gcc10
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CC=gcc-10
|
||||
- CXX=g++-10
|
||||
- CONFIGUREFLAGS='CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
- PART=1
|
||||
|
||||
@@ -182,15 +177,19 @@ jobs:
|
||||
## GCC. ##
|
||||
## ----- ##
|
||||
|
||||
- name: "GCC 8 with sanitizers part 1"
|
||||
- name: "GCC 9 with sanitizers part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages: g++-8
|
||||
sources:
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
packages: g++-9
|
||||
env:
|
||||
- CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||
- CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||
- CC='gcc-9 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||
- CXX='g++-9 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||
- CONFIGUREFLAGS='CFLAGS=-O1 CXXFLAGS=-O1'
|
||||
- PART=1
|
||||
|
||||
@@ -292,7 +291,27 @@ jobs:
|
||||
## Clang. ##
|
||||
## ------- ##
|
||||
|
||||
- name: "Clang 8 -O3"
|
||||
- name: "Clang 9 -O3"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
packages:
|
||||
- clang-9
|
||||
- libc++-9-dev
|
||||
- libc++abi-9-dev
|
||||
env:
|
||||
- CC='clang-9'
|
||||
- CXX='clang++-9 -stdlib=libc++'
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
|
||||
- name: "Clang 8"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
@@ -305,7 +324,6 @@ jobs:
|
||||
env:
|
||||
- CC=clang-8
|
||||
- CXX='clang++-8 -stdlib=libc++'
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
|
||||
- name: "Clang 7"
|
||||
stage: check
|
||||
|
||||
@@ -127,3 +127,7 @@ gen-ChangeLog:
|
||||
--since=$(gen_start_date) > $$cl.tmp && \
|
||||
mv -f $$cl.tmp $$cl; \
|
||||
fi
|
||||
|
||||
# Useful to debug.
|
||||
.c.i:
|
||||
$(CC) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -o $@ -E $<
|
||||
|
||||
@@ -1,39 +1,32 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.5.93 (2020-05-03) [beta]
|
||||
* Noteworthy changes in release 3.6.2 (2020-05-17) [stable]
|
||||
|
||||
Portability issues.
|
||||
** Bug fixes
|
||||
|
||||
* Noteworthy changes in release 3.5.92 (2020-05-03) [beta]
|
||||
Some tests were fixed.
|
||||
|
||||
Portability issues.
|
||||
When token aliases contain comment delimiters:
|
||||
|
||||
More documentation.
|
||||
%token FOO "/* foo */"
|
||||
|
||||
Backward compatibility issues with C++.
|
||||
bison used to emit "nested" comments, which is invalid C.
|
||||
|
||||
* Noteworthy changes in release 3.5.91 (2020-04-29) [stable]
|
||||
* Noteworthy changes in release 3.6.1 (2020-05-10) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Restored ANSI-C compliance in yacc.c.
|
||||
|
||||
GNU readline portability issues.
|
||||
|
||||
In C++, yy::parser::symbol_name is now a public member, as was intended.
|
||||
|
||||
** New features
|
||||
|
||||
*** Returning the error token
|
||||
In C++, yy::parser::symbol_type now has a public name() member function.
|
||||
|
||||
When the scanner returns an invalid token or the undefined token
|
||||
(YYUNDEF), the parser generates an error message and enters error
|
||||
recovery. Because of that error message, most scanners that find lexical
|
||||
errors generate an error message, and then ignore the invalid input
|
||||
without entering the error-recovery.
|
||||
|
||||
The scanners may now return YYerror, the error token, to enter the
|
||||
error-recovery mode without triggering an additional error message. See
|
||||
the bistromathic for an example.
|
||||
|
||||
*** The bistromathic features internationalization
|
||||
|
||||
Its way to build the error message is more general and is easy to use in
|
||||
other projects.
|
||||
|
||||
* Noteworthy changes in release 3.5.90 (2020-04-18) [beta]
|
||||
* Noteworthy changes in release 3.6 (2020-05-08) [stable]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
@@ -138,6 +131,18 @@ GNU Bison NEWS
|
||||
It makes little sense to use this feature without enabling LAC (lookahead
|
||||
correction).
|
||||
|
||||
*** Returning the error token
|
||||
|
||||
When the scanner returns an invalid token or the undefined token
|
||||
(YYUNDEF), the parser generates an error message and enters error
|
||||
recovery. Because of that error message, most scanners that find lexical
|
||||
errors generate an error message, and then ignore the invalid input
|
||||
without entering the error-recovery.
|
||||
|
||||
The scanners may now return YYerror, the error token, to enter the
|
||||
error-recovery mode without triggering an additional error message. See
|
||||
the bistromathic for an example.
|
||||
|
||||
*** Deep overhaul of the symbol and token kinds
|
||||
|
||||
To avoid the confusion with types in programming languages, we now refer
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
* Bison 3.6
|
||||
* Bison 3.7
|
||||
** Bistromathic
|
||||
- Hitting tab on a line with a syntax error is ugly
|
||||
|
||||
- Be robust to existing ~/.inputrc
|
||||
|
||||
- How about not evaluating incomplete lines when the text is not finished
|
||||
(as shells do).
|
||||
|
||||
** Doc
|
||||
*** api.header.include
|
||||
|
||||
** Questions
|
||||
*** Java
|
||||
- Should i18n be part of the Lexer? Currently it's a static method of
|
||||
@@ -28,7 +39,6 @@ enough.
|
||||
*** calc.at
|
||||
Stop hard-coding "Calc". Adjust local.at (look for FIXME).
|
||||
|
||||
* Bison 3.7
|
||||
** Counter example generation
|
||||
See https://github.com/akimd/bison/pull/15.
|
||||
|
||||
@@ -118,6 +128,25 @@ Rici:
|
||||
> At a minimum, the fact that yyclearin does not invoke the %destructor
|
||||
> should be highlighted in the documentation, since it is not at all obvious.
|
||||
|
||||
** Issues in i18n
|
||||
|
||||
Les catégories d'avertissements incluent :
|
||||
conflicts-sr conflits S/R (activé par défaut)
|
||||
conflicts-rr conflits R/R (activé par défaut)
|
||||
dangling-alias l'alias chaîne n'est pas attaché à un symbole
|
||||
deprecated construction obsolète
|
||||
empty-rule règle vide sans %empty
|
||||
midrule-values valeurs de règle intermédiaire non définies ou inutilisées
|
||||
precedence priorité et associativité inutiles
|
||||
yacc incompatibilités avec POSIX Yacc
|
||||
other tous les autres avertissements (activé par défaut)
|
||||
all tous les avertissements sauf « dangling-alias » et « yacc »
|
||||
no-CATEGORY désactiver les avertissements dans CATEGORIE
|
||||
none désactiver tous les avertissements
|
||||
error[=CATEGORY] traiter les avertissements comme des erreurs
|
||||
|
||||
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
||||
|
||||
* Bison 3.8
|
||||
** Unit rules / Injection rules (Akim Demaille)
|
||||
Maybe we could expand unit rules (or "injections", see
|
||||
@@ -192,10 +221,10 @@ define it to the same type as the C ptrdiff_t type.
|
||||
* Completion
|
||||
Several features are not available in all the backends.
|
||||
|
||||
- push parsers: glr.c, glr.cc, lalr1.cc
|
||||
- lac: D, Java
|
||||
- glr: D, Java
|
||||
- token constructors: Java, C, D
|
||||
- lac: D, Java (easy)
|
||||
- push parsers: glr.c, glr.cc, lalr1.cc (not very difficult)
|
||||
- token constructors: Java, C, D (a bit difficult)
|
||||
- glr: D, Java (super difficult)
|
||||
|
||||
* Bugs
|
||||
** Autotest has quotation issues
|
||||
|
||||
@@ -73,6 +73,11 @@ def diff_to_re(match):
|
||||
is_diff = True
|
||||
to.append(l)
|
||||
if is_diff:
|
||||
# Do not run s//SOMETHING/g (with an emty pattern), that won't
|
||||
# work well...
|
||||
if frm == []:
|
||||
trace("no from for", match.group(1))
|
||||
return
|
||||
frm = "\n".join(frm)
|
||||
to = "\n".join(to)
|
||||
subst[frm] = to
|
||||
@@ -112,4 +117,6 @@ def process(logfile):
|
||||
|
||||
for logfile in args.logs:
|
||||
trace("FILE:", logfile)
|
||||
if os.path.isdir(logfile):
|
||||
logfile = os.path.join(logfile, 'testsuite.log')
|
||||
process(logfile)
|
||||
|
||||
@@ -51,7 +51,7 @@ gnulib_dir = $(srcdir)/gnulib
|
||||
bootstrap-tools = autoconf,automake,flex,gettext,gnulib
|
||||
|
||||
announcement_Cc_ = \
|
||||
[email protected], [email protected], bison-patches@gnu.org, \
|
||||
[email protected], bison-announce@gnu.org, \
|
||||
[email protected]
|
||||
|
||||
update-copyright: update-b4-copyright update-package-copyright-year
|
||||
|
||||
+2
-4
@@ -36,10 +36,8 @@ AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# We use Automake 1.14's %D% and %C%.
|
||||
#
|
||||
# When we move to Automake 1.16, simplify examples/c/reccalc/local.mk.
|
||||
# Our CI runs on Xenial, which has only Automake 1.15.
|
||||
# Our CI build the packages on Bionic, which has only Automake 1.15.
|
||||
#
|
||||
# We want gnits strictness only when rolling a stable release. For
|
||||
# release candidates, we use version strings like 2.4.3_rc1, but gnits
|
||||
@@ -47,7 +45,7 @@ AC_CONFIG_MACRO_DIR([m4])
|
||||
# releases, we want to be able run make dist without being required to
|
||||
# add a bogus NEWS entry. In that case, the version string
|
||||
# automatically contains a dash, which we also let disable gnits.
|
||||
AM_INIT_AUTOMAKE([1.14 dist-xz nostdinc
|
||||
AM_INIT_AUTOMAKE([1.15 dist-lzip dist-xz nostdinc
|
||||
color-tests parallel-tests
|
||||
silent-rules]
|
||||
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
||||
|
||||
@@ -357,6 +357,29 @@ m4_define([b4_symbol_type_define],
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom\|detailed],
|
||||
[[ /// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
/// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /// The user-facing name of this symbol.
|
||||
std::string name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}]])[
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
||||
|
||||
|
||||
@@ -22,10 +22,14 @@
|
||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||
# Avoid adding indentation to the first line, as the indentation comes
|
||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||
# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close
|
||||
# the comments before its end.
|
||||
#
|
||||
# Prefix all the output lines with PREFIX.
|
||||
m4_define([_b4_comment],
|
||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
||||
[$2[]m4_bpatsubsts(m4_expand([$1]),
|
||||
[[*]/], [*\\/],
|
||||
[/[*]], [/\\*], [
|
||||
\(.\)], [
|
||||
$3\1])$4])
|
||||
|
||||
|
||||
+49
-1
@@ -205,7 +205,11 @@ m4_define([b4_c99_int_type],
|
||||
# Define private types suitable for holding small integers in C99 or later.
|
||||
m4_define([b4_c99_int_type_define],
|
||||
[m4_copy_force([b4_c99_int_type], [b4_int_type])dnl
|
||||
[/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
|
||||
[#ifdef short
|
||||
# undef short
|
||||
#endif
|
||||
|
||||
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
|
||||
<limits.h> and (if available) <stdint.h> are included
|
||||
so that the code can choose integer types of a good width. */
|
||||
|
||||
@@ -261,6 +265,50 @@ typedef int yytype_uint16;
|
||||
#endif]])
|
||||
|
||||
|
||||
# b4_sizes_types_define
|
||||
# ---------------------
|
||||
# Define YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM,
|
||||
# and YYSIZEOF.
|
||||
m4_define([b4_sizes_types_define],
|
||||
[[#ifndef YYPTRDIFF_T
|
||||
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
|
||||
# define YYPTRDIFF_T __PTRDIFF_TYPE__
|
||||
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
|
||||
# elif defined PTRDIFF_MAX
|
||||
# ifndef ptrdiff_t
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# define YYPTRDIFF_T ptrdiff_t
|
||||
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
|
||||
# else
|
||||
# define YYPTRDIFF_T long
|
||||
# define YYPTRDIFF_MAXIMUM LONG_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
# ifdef __SIZE_TYPE__
|
||||
# define YYSIZE_T __SIZE_TYPE__
|
||||
# elif defined size_t
|
||||
# define YYSIZE_T size_t
|
||||
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYSIZE_MAXIMUM \
|
||||
YY_CAST (YYPTRDIFF_T, \
|
||||
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
|
||||
? YYPTRDIFF_MAXIMUM \
|
||||
: YY_CAST (YYSIZE_T, -1)))
|
||||
|
||||
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
||||
]])
|
||||
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return a narrow int type able to handle numbers ranging from
|
||||
|
||||
+52
-52
@@ -249,6 +249,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
#include <string.h>
|
||||
|
||||
]b4_c99_int_type_define[
|
||||
]b4_sizes_types_define[
|
||||
|
||||
#ifndef YY_
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
@@ -277,9 +278,6 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
# define YYREALLOC realloc
|
||||
#endif
|
||||
|
||||
#define YYSIZEMAX \
|
||||
(PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef bool yybool;
|
||||
# define yytrue true
|
||||
@@ -507,7 +505,7 @@ struct yyGLRState {
|
||||
/** Preceding state in this stack */
|
||||
yyGLRState* yypred;
|
||||
/** Source position of the last token produced by my symbol */
|
||||
ptrdiff_t yyposn;
|
||||
YYPTRDIFF_T yyposn;
|
||||
union {
|
||||
/** First in a chain of alternative reductions producing the
|
||||
* nonterminal corresponding to this state, threaded through
|
||||
@@ -527,8 +525,8 @@ struct yyGLRStateSet {
|
||||
* operation, yylookaheadNeeds[0] is not maintained since it would merely
|
||||
* duplicate yychar != ]b4_symbol(-2, id)[. */
|
||||
yybool* yylookaheadNeeds;
|
||||
ptrdiff_t yysize;
|
||||
ptrdiff_t yycapacity;
|
||||
YYPTRDIFF_T yysize;
|
||||
YYPTRDIFF_T yycapacity;
|
||||
};
|
||||
|
||||
struct yySemanticOption {
|
||||
@@ -568,7 +566,7 @@ struct yyGLRStack {
|
||||
YYJMP_BUF yyexception_buffer;
|
||||
yyGLRStackItem* yyitems;
|
||||
yyGLRStackItem* yynextFree;
|
||||
ptrdiff_t yyspaceLeft;
|
||||
YYPTRDIFF_T yyspaceLeft;
|
||||
yyGLRState* yysplitPoint;
|
||||
yyGLRState* yylastDeleted;
|
||||
yyGLRStateSet yytops;
|
||||
@@ -680,7 +678,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
multiple parsers can coexist. */
|
||||
int yydebug;
|
||||
|
||||
static void yypstack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
static void yypstack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
||||
YY_ATTRIBUTE_UNUSED;
|
||||
static void yypdumpstack (yyGLRStack* yystackp)
|
||||
YY_ATTRIBUTE_UNUSED;
|
||||
@@ -696,7 +694,7 @@ static void yypdumpstack (yyGLRStack* yystackp)
|
||||
[simple],
|
||||
[[]],
|
||||
[[#ifndef yystrlen
|
||||
# define yystrlen(S) (YY_CAST (ptrdiff_t, strlen (S)))
|
||||
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
|
||||
#endif
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
@@ -731,12 +729,12 @@ yystpcpy (char *yydest, const char *yysrc)
|
||||
backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
||||
null, do not copy; instead, return the length of what the result
|
||||
would have been. */
|
||||
static ptrdiff_t
|
||||
static YYPTRDIFF_T
|
||||
yytnamerr (char *yyres, const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
ptrdiff_t yyn = 0;
|
||||
YYPTRDIFF_T yyn = 0;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
@@ -1104,7 +1102,7 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
|
||||
* alternative actions for YYSTATE. Assumes that YYRHS comes from
|
||||
* stack #YYK of *YYSTACKP. */
|
||||
static void
|
||||
yyaddDeferredAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyGLRState* yystate,
|
||||
yyaddDeferredAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyGLRState* yystate,
|
||||
yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
{
|
||||
yySemanticOption* yynewOption =
|
||||
@@ -1136,14 +1134,14 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
||||
yyset->yycapacity = 16;
|
||||
yyset->yystates
|
||||
= YY_CAST (yyGLRState**,
|
||||
YYMALLOC (YY_CAST (size_t, yyset->yycapacity)
|
||||
YYMALLOC (YY_CAST (YYSIZE_T, yyset->yycapacity)
|
||||
* sizeof yyset->yystates[0]));
|
||||
if (! yyset->yystates)
|
||||
return yyfalse;
|
||||
yyset->yystates[0] = YY_NULLPTR;
|
||||
yyset->yylookaheadNeeds
|
||||
= YY_CAST (yybool*,
|
||||
YYMALLOC (YY_CAST (size_t, yyset->yycapacity)
|
||||
YYMALLOC (YY_CAST (YYSIZE_T, yyset->yycapacity)
|
||||
* sizeof yyset->yylookaheadNeeds[0]));
|
||||
if (! yyset->yylookaheadNeeds)
|
||||
{
|
||||
@@ -1152,7 +1150,7 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
||||
}
|
||||
memset (yyset->yylookaheadNeeds,
|
||||
0,
|
||||
YY_CAST (size_t, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]);
|
||||
YY_CAST (YYSIZE_T, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]);
|
||||
return yytrue;
|
||||
}
|
||||
|
||||
@@ -1165,14 +1163,14 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
|
||||
/** Initialize *YYSTACKP to a single empty stack, with total maximum
|
||||
* capacity for all stacks of YYSIZE. */
|
||||
static yybool
|
||||
yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize)
|
||||
yyinitGLRStack (yyGLRStack* yystackp, YYPTRDIFF_T yysize)
|
||||
{
|
||||
yystackp->yyerrState = 0;
|
||||
yynerrs = 0;
|
||||
yystackp->yyspaceLeft = yysize;
|
||||
yystackp->yyitems
|
||||
= YY_CAST (yyGLRStackItem*,
|
||||
YYMALLOC (YY_CAST (size_t, yysize)
|
||||
YYMALLOC (YY_CAST (YYSIZE_T, yysize)
|
||||
* sizeof yystackp->yynextFree[0]));
|
||||
if (!yystackp->yyitems)
|
||||
return yyfalse;
|
||||
@@ -1198,9 +1196,9 @@ yyexpandGLRStack (yyGLRStack* yystackp)
|
||||
{
|
||||
yyGLRStackItem* yynewItems;
|
||||
yyGLRStackItem* yyp0, *yyp1;
|
||||
ptrdiff_t yynewSize;
|
||||
ptrdiff_t yyn;
|
||||
ptrdiff_t yysize = yystackp->yynextFree - yystackp->yyitems;
|
||||
YYPTRDIFF_T yynewSize;
|
||||
YYPTRDIFF_T yyn;
|
||||
YYPTRDIFF_T yysize = yystackp->yynextFree - yystackp->yyitems;
|
||||
if (YYMAXDEPTH - YYHEADROOM < yysize)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yynewSize = 2*yysize;
|
||||
@@ -1208,7 +1206,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
|
||||
yynewSize = YYMAXDEPTH;
|
||||
yynewItems
|
||||
= YY_CAST (yyGLRStackItem*,
|
||||
YYMALLOC (YY_CAST (size_t, yynewSize)
|
||||
YYMALLOC (YY_CAST (YYSIZE_T, yynewSize)
|
||||
* sizeof yynewItems[0]));
|
||||
if (! yynewItems)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1273,7 +1271,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
||||
|
||||
/** Invalidate stack #YYK in *YYSTACKP. */
|
||||
static inline void
|
||||
yymarkStackDeleted (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
yymarkStackDeleted (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
||||
{
|
||||
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
|
||||
@@ -1297,7 +1295,7 @@ yyundeleteLastStack (yyGLRStack* yystackp)
|
||||
static inline void
|
||||
yyremoveDeletes (yyGLRStack* yystackp)
|
||||
{
|
||||
ptrdiff_t yyi, yyj;
|
||||
YYPTRDIFF_T yyi, yyj;
|
||||
yyi = yyj = 0;
|
||||
while (yyj < yystackp->yytops.yysize)
|
||||
{
|
||||
@@ -1330,8 +1328,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
||||
* state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
|
||||
* value *YYVALP and source location *YYLOCP. */
|
||||
static inline void
|
||||
yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState,
|
||||
ptrdiff_t yyposn,
|
||||
yyglrShift (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yy_state_t yylrState,
|
||||
YYPTRDIFF_T yyposn,
|
||||
YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
|
||||
{
|
||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||
@@ -1351,8 +1349,8 @@ yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState,
|
||||
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
||||
* semantic value of YYRHS under the action for YYRULE. */
|
||||
static inline void
|
||||
yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState,
|
||||
ptrdiff_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
yyglrShiftDefer (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yy_state_t yylrState,
|
||||
YYPTRDIFF_T yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
{
|
||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||
YY_ASSERT (yynewState->yyisState);
|
||||
@@ -1382,7 +1380,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState,
|
||||
`----------------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, YYPTRDIFF_T yyk,
|
||||
yyRuleNum yyrule]b4_user_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
||||
@@ -1415,7 +1413,7 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
|
||||
* and *YYLOCP to the computed location (if any). Return value is as
|
||||
* for userAction. */
|
||||
static inline YYRESULTTAG
|
||||
yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
yydoAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyRuleNum yyrule,
|
||||
YYSTYPE* yyvalp]b4_locuser_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);
|
||||
@@ -1467,10 +1465,10 @@ yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
* added to the options for the existing state's semantic value.
|
||||
*/
|
||||
static inline YYRESULTTAG
|
||||
yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
yyglrReduce (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyRuleNum yyrule,
|
||||
yybool yyforceEval]b4_user_formals[)
|
||||
{
|
||||
ptrdiff_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
||||
YYPTRDIFF_T yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
||||
|
||||
if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR)
|
||||
{
|
||||
@@ -1492,7 +1490,7 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrdiff_t yyi;
|
||||
YYPTRDIFF_T yyi;
|
||||
int yyn;
|
||||
yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
|
||||
yy_state_t yynewLRState;
|
||||
@@ -1534,8 +1532,8 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
return yyok;
|
||||
}
|
||||
|
||||
static ptrdiff_t
|
||||
yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
static YYPTRDIFF_T
|
||||
yysplitStack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
||||
{
|
||||
if (yystackp->yysplitPoint == YY_NULLPTR)
|
||||
{
|
||||
@@ -1544,8 +1542,8 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
}
|
||||
if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize)
|
||||
{
|
||||
ptrdiff_t state_size = sizeof yystackp->yytops.yystates[0];
|
||||
ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
|
||||
YYPTRDIFF_T state_size = YYSIZEOF (yystackp->yytops.yystates[0]);
|
||||
YYPTRDIFF_T half_max_capacity = YYSIZE_MAXIMUM / 2 / state_size;
|
||||
if (half_max_capacity < yystackp->yytops.yycapacity)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yystackp->yytops.yycapacity *= 2;
|
||||
@@ -1554,7 +1552,7 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
yyGLRState** yynewStates
|
||||
= YY_CAST (yyGLRState**,
|
||||
YYREALLOC (yystackp->yytops.yystates,
|
||||
(YY_CAST (size_t, yystackp->yytops.yycapacity)
|
||||
(YY_CAST (YYSIZE_T, yystackp->yytops.yycapacity)
|
||||
* sizeof yynewStates[0])));
|
||||
if (yynewStates == YY_NULLPTR)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1565,7 +1563,7 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
yybool* yynewLookaheadNeeds
|
||||
= YY_CAST (yybool*,
|
||||
YYREALLOC (yystackp->yytops.yylookaheadNeeds,
|
||||
(YY_CAST (size_t, yystackp->yytops.yycapacity)
|
||||
(YY_CAST (YYSIZE_T, yystackp->yytops.yycapacity)
|
||||
* sizeof yynewLookaheadNeeds[0])));
|
||||
if (yynewLookaheadNeeds == YY_NULLPTR)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1996,8 +1994,8 @@ yycompressStack (yyGLRStack* yystackp)
|
||||
}
|
||||
|
||||
static YYRESULTTAG
|
||||
yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
|
||||
ptrdiff_t yyposn]b4_pure_formals[)
|
||||
yyprocessOneStack (yyGLRStack* yystackp, YYPTRDIFF_T yyk,
|
||||
YYPTRDIFF_T yyposn]b4_pure_formals[)
|
||||
{
|
||||
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
{
|
||||
@@ -2040,7 +2038,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
|
||||
for (/* nothing */; *yyconflicts; yyconflicts += 1)
|
||||
{
|
||||
YYRESULTTAG yyflag;
|
||||
ptrdiff_t yynewStack = yysplitStack (yystackp, yyk);
|
||||
YYPTRDIFF_T yynewStack = yysplitStack (yystackp, yyk);
|
||||
YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
|
||||
YY_CAST (long, yynewStack), YY_CAST (long, yyk)));
|
||||
yyflag = yyglrReduce (yystackp, yynewStack,
|
||||
@@ -2121,6 +2119,8 @@ yypcontext_expected_tokens (const yyGLRStack* yystackp,
|
||||
yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
|
||||
}
|
||||
}
|
||||
if (yyarg && yycount == 0 && 0 < yyargn)
|
||||
yyarg[0] = ]b4_symbol(-2, kind)[;
|
||||
return yycount;
|
||||
}]])[
|
||||
|
||||
@@ -2228,7 +2228,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
one per "expected"). */
|
||||
yysymbol_kind_t yyarg[YYARGS_MAX];
|
||||
/* Cumulated lengths of YYARG. */
|
||||
ptrdiff_t yysize = 0;
|
||||
YYPTRDIFF_T yysize = 0;
|
||||
|
||||
/* Actual size of YYARG. */
|
||||
int yycount
|
||||
@@ -2259,11 +2259,11 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
int yyi;
|
||||
for (yyi = 0; yyi < yycount; ++yyi)
|
||||
{
|
||||
ptrdiff_t yysz
|
||||
YYPTRDIFF_T yysz
|
||||
= ]b4_parse_error_case(
|
||||
[verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
|
||||
[[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
|
||||
if (YYSIZEMAX - yysize < yysz)
|
||||
if (YYSIZE_MAXIMUM - yysize < yysz)
|
||||
yysize_overflow = yytrue;
|
||||
else
|
||||
yysize += yysz;
|
||||
@@ -2271,7 +2271,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
}
|
||||
|
||||
if (!yysize_overflow)
|
||||
yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (size_t, yysize)));
|
||||
yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (YYSIZE_T, yysize)));
|
||||
|
||||
if (yymsg)
|
||||
{
|
||||
@@ -2348,7 +2348,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
|
||||
/* Reduce to one stack. */
|
||||
{
|
||||
ptrdiff_t yyk;
|
||||
YYPTRDIFF_T yyk;
|
||||
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
|
||||
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
break;
|
||||
@@ -2423,7 +2423,7 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
|
||||
int yyresult;
|
||||
yyGLRStack yystack;
|
||||
yyGLRStack* const yystackp = &yystack;
|
||||
ptrdiff_t yyposn;
|
||||
YYPTRDIFF_T yyposn;
|
||||
|
||||
YY_DPRINTF ((stderr, "Starting parse\n"));
|
||||
|
||||
@@ -2505,7 +2505,7 @@ b4_dollar_popdef])[]dnl
|
||||
while (yytrue)
|
||||
{
|
||||
yysymbol_kind_t yytoken_to_shift;
|
||||
ptrdiff_t yys;
|
||||
YYPTRDIFF_T yys;
|
||||
|
||||
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
||||
yystackp->yytops.yylookaheadNeeds[yys] = yychar != ]b4_symbol(-2, id)[;
|
||||
@@ -2612,8 +2612,8 @@ b4_dollar_popdef])[]dnl
|
||||
yyGLRState** yystates = yystack.yytops.yystates;
|
||||
if (yystates)
|
||||
{
|
||||
ptrdiff_t yysize = yystack.yytops.yysize;
|
||||
ptrdiff_t yyk;
|
||||
YYPTRDIFF_T yysize = yystack.yytops.yysize;
|
||||
YYPTRDIFF_T yyk;
|
||||
for (yyk = 0; yyk < yysize; yyk += 1)
|
||||
if (yystates[yyk])
|
||||
{
|
||||
@@ -2660,7 +2660,7 @@ yypstates (yyGLRState* yyst)
|
||||
}
|
||||
|
||||
static void
|
||||
yypstack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
yypstack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
||||
{
|
||||
yypstates (yystackp->yytops.yystates[yyk]);
|
||||
}
|
||||
@@ -2705,7 +2705,7 @@ yypdumpstack (yyGLRStack* yystackp)
|
||||
|
||||
YY_FPRINTF ((stderr, "Tops:"));
|
||||
{
|
||||
ptrdiff_t yyi;
|
||||
YYPTRDIFF_T yyi;
|
||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||
YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi),
|
||||
YYINDEX (yystackp->yytops.yystates[yyi])));
|
||||
|
||||
+101
-92
@@ -241,6 +241,23 @@ m4_define([b4_shared_declarations],
|
||||
/// Report a syntax error.
|
||||
void error (const syntax_error& err);
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom\|detailed],
|
||||
[[ /// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static const char *symbol_name (symbol_kind_type yysymbol);]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
/// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static const char *symbol_name (symbol_kind_type yysymbol);
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static std::string symbol_name (symbol_kind_type yysymbol);]])[
|
||||
|
||||
]b4_token_constructor_define[
|
||||
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
|
||||
class context
|
||||
@@ -317,26 +334,14 @@ m4_define([b4_shared_declarations],
|
||||
static symbol_kind_type yytranslate_ (int t);
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom\|detailed],
|
||||
[[ /// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static const char *symbol_name (symbol_kind_type yysymbol);]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
/// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static const char *symbol_name (symbol_kind_type yysymbol);
|
||||
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static std::string symbol_name (symbol_kind_type yysymbol);
|
||||
|
||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
[[ /// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
static std::string yytnamerr_ (const char *yystr);
|
||||
|
||||
/// For a symbol, its name in clear.
|
||||
@@ -474,6 +479,7 @@ m4_define([b4_shared_declarations],
|
||||
};
|
||||
|
||||
]b4_parse_param_vars[
|
||||
]b4_percent_code_get([[yy_bison_internal_hook]])[
|
||||
};
|
||||
|
||||
]b4_token_ctor_if([b4_yytranslate_define([$1])[
|
||||
@@ -607,83 +613,6 @@ m4_if(b4_prefix, [yy], [],
|
||||
#define YYRECOVERING() (!!yyerrstatus_)
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_parse_error_bmatch([custom\|detailed],
|
||||
[[ const char *
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
static const char *const yy_sname[] =
|
||||
{
|
||||
]b4_symbol_names[
|
||||
};]b4_has_translations_if([[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
||||
{
|
||||
]b4_translatable[
|
||||
};
|
||||
return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
|
||||
? _(yy_sname[yysymbol])
|
||||
: yy_sname[yysymbol]);]], [[
|
||||
return yy_sname[yysymbol];]])[
|
||||
}
|
||||
]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
const char *
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
return yytname_[yysymbol];
|
||||
}
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
std::string
|
||||
]b4_parser_class[::yytnamerr_ (const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
std::string yyr;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
switch (*++yyp)
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
goto do_not_strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
yyr += *yyp;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr;
|
||||
}
|
||||
do_not_strip_quotes: ;
|
||||
}
|
||||
|
||||
return yystr;
|
||||
}
|
||||
|
||||
std::string
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
return yytnamerr_ (yytname_[yysymbol]);
|
||||
}
|
||||
]])[
|
||||
|
||||
/// Build a parser object.
|
||||
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
@@ -815,7 +744,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
{
|
||||
symbol_kind_type yykind = yysym.kind ();
|
||||
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << symbol_name (yykind) << " ("]b4_locations_if([
|
||||
<< ' ' << yysym.name () << " ("]b4_locations_if([
|
||||
<< yysym.location << ": "])[;
|
||||
]b4_symbol_actions([printer])[
|
||||
yyo << ')';
|
||||
@@ -1267,8 +1196,86 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
error (]b4_join(b4_locations_if([yyexc.location]),
|
||||
[[yyexc.what ()]])[);
|
||||
}]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch([custom\|detailed],
|
||||
[[ const char *
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
static const char *const yy_sname[] =
|
||||
{
|
||||
]b4_symbol_names[
|
||||
};]b4_has_translations_if([[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
||||
{
|
||||
]b4_translatable[
|
||||
};
|
||||
return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
|
||||
? _(yy_sname[yysymbol])
|
||||
: yy_sname[yysymbol]);]], [[
|
||||
return yy_sname[yysymbol];]])[
|
||||
}
|
||||
]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
const char *
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
return yytname_[yysymbol];
|
||||
}
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
std::string
|
||||
]b4_parser_class[::yytnamerr_ (const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
std::string yyr;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
switch (*++yyp)
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
goto do_not_strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
yyr += *yyp;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr;
|
||||
}
|
||||
do_not_strip_quotes: ;
|
||||
}
|
||||
|
||||
return yystr;
|
||||
}
|
||||
|
||||
std::string
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
return yytnamerr_ (yytname_[yysymbol]);
|
||||
}
|
||||
]])[
|
||||
|
||||
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
|
||||
// ]b4_parser_class[::context.
|
||||
]b4_parser_class[::context::context (const ]b4_parser_class[& yyparser, const symbol_type& yyla)
|
||||
: yyparser_ (yyparser)
|
||||
@@ -1326,6 +1333,8 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
}
|
||||
]])[
|
||||
if (yyarg && yycount == 0 && 0 < yyargn)
|
||||
yyarg[0] = symbol_kind::]b4_symbol(-2, kind)[;
|
||||
return yycount;
|
||||
}
|
||||
|
||||
|
||||
@@ -944,6 +944,8 @@ b4_dollar_popdef[]dnl
|
||||
yyarg[yycount++] = SymbolKind.get (yyx);
|
||||
}
|
||||
}
|
||||
if (yyarg != null && yycount == yyoffset && yyoffset < yyargn)
|
||||
yyarg[yycount] = null;
|
||||
return yycount - yyoffset;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-43
@@ -403,50 +403,10 @@ m4_if(b4_api_prefix, [yy], [],
|
||||
]b4_declare_symbol_enum[
|
||||
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
[#ifdef short
|
||||
# undef short
|
||||
#endif
|
||||
|
||||
]b4_percent_code_get[
|
||||
]b4_c99_int_type_define[
|
||||
|
||||
#ifndef YYPTRDIFF_T
|
||||
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
|
||||
# define YYPTRDIFF_T __PTRDIFF_TYPE__
|
||||
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
|
||||
# elif defined PTRDIFF_MAX
|
||||
# ifndef ptrdiff_t
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# define YYPTRDIFF_T ptrdiff_t
|
||||
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
|
||||
# else
|
||||
# define YYPTRDIFF_T long
|
||||
# define YYPTRDIFF_MAXIMUM LONG_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
# ifdef __SIZE_TYPE__
|
||||
# define YYSIZE_T __SIZE_TYPE__
|
||||
# elif defined size_t
|
||||
# define YYSIZE_T size_t
|
||||
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYSIZE_MAXIMUM \
|
||||
YY_CAST (YYPTRDIFF_T, \
|
||||
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
|
||||
? YYPTRDIFF_MAXIMUM \
|
||||
: YY_CAST (YYSIZE_T, -1)))
|
||||
|
||||
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
||||
]b4_sizes_types_define[
|
||||
|
||||
/* Stored state numbers (used for stacks). */
|
||||
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;
|
||||
@@ -1198,6 +1158,8 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
||||
yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
|
||||
}
|
||||
}]])[
|
||||
if (yyarg && yycount == 0 && 0 < yyargn)
|
||||
yyarg[0] = ]b4_symbol(-2, kind)[;
|
||||
return yycount;
|
||||
}
|
||||
|
||||
@@ -2017,7 +1979,7 @@ yyerrorlab:
|
||||
yyerrlab1:
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||
|
||||
// Pop stack until we find a state that shifts the error token.
|
||||
/* Pop stack until we find a state that shifts the error token. */
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact[yystate];
|
||||
|
||||
+101
-62
@@ -300,10 +300,7 @@ Bison Declarations
|
||||
Parser C-Language Interface
|
||||
|
||||
* Parser Function:: How to call @code{yyparse} and what it returns.
|
||||
* Push Parser Function:: How to call @code{yypush_parse} and what it returns.
|
||||
* Pull Parser Function:: How to call @code{yypull_parse} and what it returns.
|
||||
* Parser Create Function:: How to call @code{yypstate_new} and what it returns.
|
||||
* Parser Delete Function:: How to call @code{yypstate_delete} and what it returns.
|
||||
* Push Parser Interface:: How to create, use, and destroy push parsers.
|
||||
* Lexical:: You must supply a function @code{yylex}
|
||||
which reads tokens.
|
||||
* Error Reporting:: Passing error messages to the user.
|
||||
@@ -6927,10 +6924,7 @@ in the grammar file, you are likely to run into trouble.
|
||||
|
||||
@menu
|
||||
* Parser Function:: How to call @code{yyparse} and what it returns.
|
||||
* Push Parser Function:: How to call @code{yypush_parse} and what it returns.
|
||||
* Pull Parser Function:: How to call @code{yypull_parse} and what it returns.
|
||||
* Parser Create Function:: How to call @code{yypstate_new} and what it returns.
|
||||
* Parser Delete Function:: How to call @code{yypstate_delete} and what it returns.
|
||||
* Push Parser Interface:: How to create, use, and destroy push parsers.
|
||||
* Lexical:: You must supply a function @code{yylex}
|
||||
which reads tokens.
|
||||
* Error Reporting:: Passing error messages to the user.
|
||||
@@ -7033,16 +7027,40 @@ void yyerror (YYLTYPE *llocp, int *randomness, const char *msg);
|
||||
int yyparse (int *randomness);
|
||||
@end example
|
||||
|
||||
@node Push Parser Function
|
||||
@section The Push Parser Function @code{yypush_parse}
|
||||
@findex yypush_parse
|
||||
@node Push Parser Interface
|
||||
@section Push Parser Interface
|
||||
|
||||
You call the function @code{yypush_parse} to parse a single token. This
|
||||
@findex yypstate_new
|
||||
You call the function @code{yypstate_new} to create a new parser instance.
|
||||
This function is available if either the @samp{%define api.push-pull push}
|
||||
or @samp{%define api.push-pull both} declaration is used. @xref{Push Decl}.
|
||||
|
||||
@deftypefun {yypstate*} yypstate_new (@code{void})
|
||||
@anchor{yypstate_new}
|
||||
Return a valid parser instance if there is memory available, 0 otherwise.
|
||||
In impure mode, it will also return 0 if a parser instance is currently
|
||||
allocated.
|
||||
@end deftypefun
|
||||
|
||||
@findex yypstate_delete
|
||||
You call the function @code{yypstate_delete} to delete a parser instance.
|
||||
function is available if either the @samp{%define api.push-pull push} or
|
||||
@samp{%define api.push-pull both} declaration is used.
|
||||
@xref{Push Decl}.
|
||||
|
||||
@deftypefun void yypstate_delete (@code{yypstate *}@var{yyps})
|
||||
@anchor{yypstate_delete}
|
||||
Reclaim the memory associated with a parser instance. After this call, you
|
||||
should no longer attempt to use the parser instance.
|
||||
@end deftypefun
|
||||
|
||||
@findex yypush_parse
|
||||
You call the function @code{yypush_parse} to parse a single token. This
|
||||
function is available if either the @samp{%define api.push-pull push} or
|
||||
@samp{%define api.push-pull both} declaration is used. @xref{Push Decl}.
|
||||
|
||||
@deftypefun int yypush_parse (@code{yypstate *}@var{yyps})
|
||||
@anchor{yypush_parse}
|
||||
The value returned by @code{yypush_parse} is the same as for @code{yyparse}
|
||||
with the following exception: it returns @code{YYPUSH_MORE} if more input is
|
||||
required to finish parsing the grammar.
|
||||
@@ -7056,50 +7074,35 @@ reuse. For example, a calculator application which parses each input line
|
||||
as an expression can just keep reusing the same @code{yyps} even if an input
|
||||
was invalid.
|
||||
|
||||
@node Pull Parser Function
|
||||
@section The Pull Parser Function @code{yypull_parse}
|
||||
@findex yypull_parse
|
||||
|
||||
You call the function @code{yypull_parse} to parse the rest of the input
|
||||
stream. This function is available if the @samp{%define api.push-pull both}
|
||||
declaration is used.
|
||||
@xref{Push Decl}.
|
||||
declaration is used. @xref{Push Decl}.
|
||||
|
||||
@deftypefun int yypull_parse (@code{yypstate *}@var{yyps})
|
||||
@anchor{yypull_parse}
|
||||
The value returned by @code{yypull_parse} is the same as for @code{yyparse}.
|
||||
|
||||
The parser instance @code{yyps} may be reused for new parses.
|
||||
@end deftypefun
|
||||
|
||||
@node Parser Create Function
|
||||
@section The Parser Create Function @code{yystate_new}
|
||||
@findex yypstate_new
|
||||
@deftypefun int yypstate_expected_tokens (@code{const yypstate *}yyps, @code{yysymbol_kind_t} @var{argv}@code{[]}, @code{int} @var{argc})
|
||||
Fill @var{argv} with the expected tokens, which never includes
|
||||
@code{YYSYMBOL_YYEMPTY}, @code{YYSYMBOL_YYerror}, or
|
||||
@code{YYSYMBOL_YYUNDEF}.
|
||||
|
||||
You call the function @code{yypstate_new} to create a new parser instance.
|
||||
This function is available if either the @samp{%define api.push-pull push} or
|
||||
@samp{%define api.push-pull both} declaration is used.
|
||||
@xref{Push Decl}.
|
||||
Never put more than @var{argc} elements into @var{argv}, and on success
|
||||
return the number of tokens stored in @var{argv}. If there are more
|
||||
expected tokens than @var{argc}, fill @var{argv} up to @var{argc} and return
|
||||
0. If there are no expected tokens, also return 0, but set @code{argv[0]}
|
||||
to @code{YYSYMBOL_YYEMPTY}.
|
||||
|
||||
@deftypefun {yypstate*} yypstate_new (@code{void})
|
||||
The function will return a valid parser instance if there was memory available
|
||||
or 0 if no memory was available.
|
||||
In impure mode, it will also return 0 if a parser instance is currently
|
||||
allocated.
|
||||
When LAC is enabled, may return a negative number on errors,
|
||||
such as @code{YYENOMEM} on memory exhaustion.
|
||||
|
||||
If @var{argv} is null, return the size needed to store all the possible
|
||||
values, which is always less than @code{YYNTOKENS}.
|
||||
@end deftypefun
|
||||
|
||||
@node Parser Delete Function
|
||||
@section The Parser Delete Function @code{yystate_delete}
|
||||
@findex yypstate_delete
|
||||
|
||||
You call the function @code{yypstate_delete} to delete a parser instance.
|
||||
function is available if either the @samp{%define api.push-pull push} or
|
||||
@samp{%define api.push-pull both} declaration is used.
|
||||
@xref{Push Decl}.
|
||||
|
||||
@deftypefun void yypstate_delete (@code{yypstate *}@var{yyps})
|
||||
This function will reclaim the memory associated with a parser instance.
|
||||
After this call, you should no longer attempt to use the parser instance.
|
||||
@end deftypefun
|
||||
|
||||
@node Lexical
|
||||
@section The Lexical Analyzer Function @code{yylex}
|
||||
@@ -7551,9 +7554,12 @@ Fill @var{argv} with the expected tokens, which never includes
|
||||
@code{YYSYMBOL_YYUNDEF}.
|
||||
|
||||
Never put more than @var{argc} elements into @var{argv}, and on success
|
||||
return the effective number of tokens stored in @var{argv}. Return 0 if
|
||||
there are more than @var{argc} expected tokens, yet fill @var{argv} up to
|
||||
@var{argc}. When LAC is enabled, may return a negative number on errors,
|
||||
return the number of tokens stored in @var{argv}. If there are more
|
||||
expected tokens than @var{argc}, fill @var{argv} up to @var{argc} and return
|
||||
0. If there are no expected tokens, also return 0, but set @code{argv[0]}
|
||||
to @code{YYSYMBOL_YYEMPTY}.
|
||||
|
||||
When LAC is enabled, may return a negative number on errors,
|
||||
such as @code{YYENOMEM} on memory exhaustion.
|
||||
|
||||
If @var{argv} is null, return the size needed to store all the possible
|
||||
@@ -7660,11 +7666,11 @@ recovery.
|
||||
In either case, the rest of the action is not executed.
|
||||
@end deffn
|
||||
|
||||
@deffn {Macro} YYEMPTY
|
||||
@deffn {Value} YYEMPTY
|
||||
Value stored in @code{yychar} when there is no lookahead token.
|
||||
@end deffn
|
||||
|
||||
@deffn {Macro} YYEOF
|
||||
@deffn {Value} YYEOF
|
||||
Value stored in @code{yychar} when the lookahead is the end of the input
|
||||
stream.
|
||||
@end deffn
|
||||
@@ -12137,9 +12143,10 @@ Fill @var{argv} with the expected tokens, which never includes
|
||||
@code{symbol_kind::S_YYUNDEF}.
|
||||
|
||||
Never put more than @var{argc} elements into @var{argv}, and on success
|
||||
return the effective number of tokens stored in @var{argv}. Return 0 if
|
||||
there are more than @var{argc} expected tokens, yet fill @var{argv} up to
|
||||
@var{argc}.
|
||||
return the number of tokens stored in @var{argv}. If there are more
|
||||
expected tokens than @var{argc}, fill @var{argv} up to @var{argc} and return
|
||||
0. If there are no expected tokens, also return 0, but set @code{argv[0]}
|
||||
to @code{symbol_kind::S_YYEMPTY}.
|
||||
|
||||
If @var{argv} is null, return the size needed to store all the possible
|
||||
values, which is always less than @code{YYNTOKENS}.
|
||||
@@ -12147,6 +12154,8 @@ values, which is always less than @code{YYNTOKENS}.
|
||||
|
||||
@deftypemethod {parser} {const char *} symbol_name (@code{symbol_kind_t} @var{symbol}) @code{const}
|
||||
The name of the symbol whose kind is @var{symbol}, possibly translated.
|
||||
|
||||
Returns a @code{std::string} when @code{parse.error} is @code{verbose}.
|
||||
@end deftypemethod
|
||||
|
||||
A custom syntax error function looks as follows. This implementation is
|
||||
@@ -12279,6 +12288,12 @@ applicable) location.
|
||||
The kind of this symbol.
|
||||
@end deftypemethod
|
||||
|
||||
@deftypemethod {symbol_type} {const char *} name () @code{const}
|
||||
The name of the kind of this symbol.
|
||||
|
||||
Returns a @code{std::string} when @code{parse.error} is @code{verbose}.
|
||||
@end deftypemethod
|
||||
|
||||
@sp 1
|
||||
|
||||
For each token kind, Bison generates named constructors as follows.
|
||||
@@ -13298,9 +13313,10 @@ Fill @var{argv} with the expected tokens, which never includes
|
||||
@code{SymbolKind.S_YYERROR}, or @code{SymbolKind.S_YYUNDEF}.
|
||||
|
||||
Never put more than @var{argc} elements into @var{argv}, and on success
|
||||
return the effective number of tokens stored in @var{argv}. Return 0 if
|
||||
there are more than @var{argc} expected tokens, yet fill @var{argv} up to
|
||||
@var{argc}.
|
||||
return the number of tokens stored in @var{argv}. If there are more
|
||||
expected tokens than @var{argc}, fill @var{argv} up to @var{argc} and return
|
||||
0. If there are no expected tokens, also return 0, but set @code{argv[0]}
|
||||
to @code{null}.
|
||||
|
||||
If @var{argv} is null, return the size needed to store all the possible
|
||||
values, which is always less than @code{YYNTOKENS}.
|
||||
@@ -14692,6 +14708,14 @@ is given a nonzero value, the parser will output information on input
|
||||
symbols and parser action. @xref{Tracing}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Value} YYEMPTY
|
||||
The pseudo token kind when there is no lookahead token.
|
||||
@end deffn
|
||||
|
||||
@deffn {Value} YYEOF
|
||||
The token kind denoting is the end of the input stream.
|
||||
@end deffn
|
||||
|
||||
@deffn {Macro} yyerrok
|
||||
Macro to cause parser to recover immediately to its normal mode
|
||||
after a syntax error. @xref{Error Recovery}.
|
||||
@@ -14781,24 +14805,26 @@ Deprecated, use @code{%printer} instead (@pxref{Printer Decl}).
|
||||
@deffn {Function} yypstate_delete
|
||||
The function to delete a parser instance, produced by Bison in push mode;
|
||||
call this function to delete the memory associated with a parser.
|
||||
@xref{Parser Delete Function}. Does nothing when called with a null pointer.
|
||||
@xref{yypstate_delete,,@code{yypstate_delete}}. Does nothing when called
|
||||
with a null pointer.
|
||||
@end deffn
|
||||
|
||||
@deffn {Function} yypstate_new
|
||||
The function to create a parser instance, produced by Bison in push mode;
|
||||
call this function to create a new parser.
|
||||
@xref{Parser Create Function}.
|
||||
@xref{yypstate_new,,@code{yypstate_new}}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Function} yypull_parse
|
||||
The parser function produced by Bison in push mode; call this function to
|
||||
parse the rest of the input stream.
|
||||
@xref{Pull Parser Function}.
|
||||
@xref{yypull_parse,,@code{yypull_parse}}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Function} yypush_parse
|
||||
The parser function produced by Bison in push mode; call this function to
|
||||
parse a single token. @xref{Push Parser Function}.
|
||||
parse a single token.
|
||||
@xref{yypush_parse,,@code{yypush_parse}}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Macro} YYRECOVERING
|
||||
@@ -14846,6 +14872,10 @@ should not be confused with the @emph{symbol kinds}, used internally by the
|
||||
parser.
|
||||
@end deffn
|
||||
|
||||
@deffn {Value} YYUNDEF
|
||||
The token kind denoting an unknown token.
|
||||
@end deffn
|
||||
|
||||
|
||||
@node Glossary
|
||||
@appendix Glossary
|
||||
@@ -14932,12 +14962,21 @@ A continuous flow of data between devices or programs.
|
||||
@item Kind
|
||||
``Token'' and ``symbol'' are each overloaded to mean either a grammar symbol
|
||||
(kind) or all parse info (kind, value, location) associated with occurrences
|
||||
of that grammar symbol from the input. To disambiguate, we use ``token
|
||||
kind'' and ``symbol kind'' to mean both grammar symbols and the types that
|
||||
represent them in a base programming language (C, C++, etc.). However, we
|
||||
use ``token'' and ``symbol'' without the word ``kind'' to mean parsed
|
||||
of that grammar symbol from the input. To disambiguate,
|
||||
|
||||
@itemize
|
||||
@item
|
||||
we use ``token kind'' and ``symbol kind'' to mean both grammar symbols and
|
||||
the values that represent them in a base programming language (C, C++,
|
||||
etc.). The names of the types of these values are typically
|
||||
@code{token_kind_t}, or @code{token_kind_type}, or @code{TokenKind},
|
||||
depending on the programming language.
|
||||
|
||||
@item
|
||||
we use ``token'' and ``symbol'' without the word ``kind'' to mean parsed
|
||||
occurrences, and we append the word ``type'' to refer to the types that
|
||||
represent them in a base programming language.
|
||||
@end itemize
|
||||
|
||||
In summary: When you see ``kind'', interpret ``symbol'' or ``token'' to mean
|
||||
a @emph{grammar symbol}. When you don't see ``kind'' (including when you
|
||||
|
||||
+24
-10
@@ -131,7 +131,7 @@ dist_man_MANS = $(top_srcdir)/%D%/bison.1
|
||||
EXTRA_DIST += $(dist_man_MANS:.1=.x)
|
||||
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
||||
|
||||
# Differences to ignore when comparing the man page (the date).
|
||||
# Differences to ignore when comparing man pages (the date).
|
||||
remove_time_stamp = \
|
||||
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
||||
|
||||
@@ -140,17 +140,31 @@ if ! CROSS_COMPILING
|
||||
MAN_DEPS = %D%/bison.help %D%/bison.x $(top_srcdir)/configure
|
||||
endif
|
||||
|
||||
# If we don't have help2man, just touch the target. Maintainers must
|
||||
# have the real thing, so if there's a .git directory, fail hard.
|
||||
#
|
||||
# We shouldn't need this, but on some OS the timestamps in the tarball
|
||||
# leave us no choice. See
|
||||
# https://lists.gnu.org/r/bug-bison/2020-05/msg00055.html.
|
||||
$(top_srcdir)/%D%/bison.1: $(MAN_DEPS)
|
||||
$(AM_V_GEN)$(HELP2MAN) \
|
||||
--include=$(top_srcdir)/%D%/bison.x \
|
||||
--output=$@.tmp tests/bison
|
||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.tmp 2>/dev/null && \
|
||||
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
|
||||
touch $@; \
|
||||
else \
|
||||
mv $@.tmp $@; \
|
||||
$(AM_V_GEN)if $(HELP2MAN) --version >/dev/null 2>&1; then \
|
||||
$(HELP2MAN) \
|
||||
--include=$(top_srcdir)/%D%/bison.x \
|
||||
--output=$@.tmp tests/bison && \
|
||||
{ $(remove_time_stamp) $@ >$@a.tmp || true; } && \
|
||||
$(remove_time_stamp) $@.tmp >$@b.tmp && \
|
||||
if diff $@a.tmp $@b.tmp >/dev/null 2>&1; then \
|
||||
touch $@; \
|
||||
else \
|
||||
mv $@.tmp $@; \
|
||||
fi && \
|
||||
rm -f $@*.tmp; \
|
||||
elif test -d $(srcdir)/.git; then \
|
||||
echo >&2 "ERROR: $@: help2man is needed"; \
|
||||
exit 1; \
|
||||
else \
|
||||
touch $@; \
|
||||
fi
|
||||
$(AM_V_at)rm -f $@*.tmp
|
||||
|
||||
if ENABLE_YACC
|
||||
nodist_man_MANS = %D%/yacc.1
|
||||
|
||||
@@ -13,8 +13,8 @@ semantic value.
|
||||
|
||||
Run as `./simple`.
|
||||
|
||||
Extracted from the documentation: "A Simple C++ Example".
|
||||
https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html
|
||||
Extracted from the documentation: [A Simple C++
|
||||
Example](https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html).
|
||||
|
||||
## variant.yy - Self-contained example in C++98
|
||||
A variation of simple.yy, in C++98.
|
||||
@@ -36,8 +36,8 @@ starting point for a clean parser in C++. The previous examples are better
|
||||
introductory examples, and the C examples are also useful introductory
|
||||
examples.
|
||||
|
||||
Extracted from the documentation: "A Complete C++ Example".
|
||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
||||
Extracted from the documentation: [A Complete C++
|
||||
Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html).
|
||||
|
||||
<!---
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ saw the traditional implementation in C, please first read
|
||||
examples/c/lexcalc, which can be seen as a C precursor of this example.
|
||||
|
||||
Read the corresponding chapter in the documentation: "A Complete C++
|
||||
Example". It is also available on line (maybe with a different version of
|
||||
Bison):
|
||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
||||
Example". It is also available [on
|
||||
line](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html)
|
||||
(maybe with a different version of Bison).
|
||||
|
||||
To use it, copy this directory into some work directory, and run `make` to
|
||||
compile the executable, and try it. It is a simple calculator which accepts
|
||||
|
||||
@@ -10,8 +10,8 @@ The first example is that of a simple double-precision Reverse Polish
|
||||
Notation calculator (a calculator using postfix operators). This example
|
||||
provides a good starting point, since operator precedence is not an issue.
|
||||
|
||||
Extracted from the documentation: "Reverse Polish Notation Calculator"
|
||||
https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
|
||||
Extracted from the documentation: [Reverse Polish Notation
|
||||
Calculator](https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html).
|
||||
|
||||
## calc - Simple Calculator
|
||||
This example is slightly more complex than rpcalc: it features infix
|
||||
@@ -24,18 +24,18 @@ A more complete C example: a multi-function calculator. More complex than
|
||||
the previous example. Using precedence directives to support infix
|
||||
operators.
|
||||
|
||||
Extracted from the documentation: "Multi-Function Calculator: mfcalc".
|
||||
https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
|
||||
Extracted from the documentation: [Multi-Function Calculator:
|
||||
mfcalc](https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html).
|
||||
|
||||
## lexcalc - calculator with Flex and Bison
|
||||
The calculator with precedence directives and location tracking. It uses
|
||||
Flex to generate the scanner.
|
||||
|
||||
## reccalc - recursive calculator with Flex and Bison
|
||||
The example builds on top of the previous one to provide a reentrant parser.
|
||||
Such parsers can be called concurrently in different threads, or even
|
||||
recursively. To demonstrate this feature, expressions in parentheses are
|
||||
tokenized as strings, and then recursively parsed from the parser. So
|
||||
This example builds on top of the previous one to provide a reentrant
|
||||
parser. Such parsers can be called concurrently in different threads, or
|
||||
even recursively. To demonstrate this feature, expressions in parentheses
|
||||
are tokenized as strings, and then recursively parsed from the parser. So
|
||||
`(((1)+(2))*((3)+(4)))` uses eight parsers, with a depth of four.
|
||||
|
||||
## pushcalc - calculator implemented with a push parser
|
||||
|
||||
@@ -14,6 +14,9 @@ This example demonstrates best practices when using Bison.
|
||||
- It supports debug traces with semantic values.
|
||||
- It uses named references instead of the traditional $1, $2, etc.
|
||||
|
||||
To customize the interaction with bistromathic, see the GNU Readline user
|
||||
manual (see `info rluserman`).
|
||||
|
||||
<!---
|
||||
Local Variables:
|
||||
fill-column: 76
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Users may customize the behavior of readline, which might break our
|
||||
# expected results.
|
||||
INPUTRC=/dev/null
|
||||
export INPUTRC
|
||||
|
||||
# Beware of portability issues of readline when not feeding it from a
|
||||
# terminal.
|
||||
@@ -41,13 +45,14 @@ echo >perfect '> 0
|
||||
echo >ok '0'
|
||||
echo '0' | prog >effective
|
||||
|
||||
if diff perfect effective >/dev/null 2>&1; then
|
||||
echo "checking for readline output"
|
||||
if diff perfect effective; then
|
||||
# Alles ist gut.
|
||||
elif diff ok effective >/dev/null 2>&1; then
|
||||
strip_prompt=false
|
||||
elif diff ok effective; then
|
||||
strip_prompt=true
|
||||
else
|
||||
echo "SKIP: this is not the GNU Readline we expect"
|
||||
exit 77
|
||||
skip "this is not the GNU Readline we expect"
|
||||
fi
|
||||
|
||||
|
||||
@@ -96,7 +101,7 @@ cat >input <<EOF
|
||||
EOF
|
||||
run 0 '> *
|
||||
> ''
|
||||
err: 1.1: syntax error: expected end of file or - or ( or exit or number or function or variable before *'
|
||||
err: 1.1: syntax error: expected end of file or - or ( or exit or number or function etc., before *'
|
||||
|
||||
cat >input <<EOF
|
||||
1 + 2 * * 3
|
||||
@@ -257,14 +262,22 @@ err: Cleanup: popping nterm input (1.1-4: )' -p
|
||||
# From now on, the differences between versions of GNU Readline are
|
||||
# too painful to try to cope with.
|
||||
if $strip_prompt; then
|
||||
echo "SKIP: this is not the GNU Readline we expect"
|
||||
if $exit; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
echo "SKIP: this is not the GNU Readline we expect"
|
||||
exit $status
|
||||
fi
|
||||
|
||||
# On Windows10/MSYS2 the ^G coming from <tab> completion is not
|
||||
# emitted the same way
|
||||
# (https://lists.gnu.org/r/bug-bison/2020-05/msg00076.html).
|
||||
echo "checking for kernel name"
|
||||
case `uname -s` in
|
||||
(MSYS*)
|
||||
echo "SKIP: this is Windows/MSYS"
|
||||
exit $status
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# Check completion after an operator.
|
||||
sed -e 's/\\t/ /g' >input <<EOF
|
||||
(1+\t\t
|
||||
|
||||
@@ -333,7 +333,7 @@ error_format_string (int argc)
|
||||
case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
|
||||
case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
|
||||
case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
|
||||
case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e or %6e before %u");
|
||||
case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e etc., before %u");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,12 +341,15 @@ error_format_string (int argc)
|
||||
int
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
{
|
||||
enum { ARGS_MAX = 7 };
|
||||
enum { ARGS_MAX = 6 };
|
||||
yysymbol_kind_t arg[ARGS_MAX];
|
||||
int argsize = yypcontext_expected_tokens (ctx, arg, ARGS_MAX);
|
||||
if (argsize < 0)
|
||||
return argsize;
|
||||
const char *format = error_format_string (1 + argsize);
|
||||
const int too_many_expected_tokens = argsize == 0 && arg[0] != YYSYMBOL_YYEMPTY;
|
||||
if (too_many_expected_tokens)
|
||||
argsize = ARGS_MAX;
|
||||
const char *format = error_format_string (1 + argsize + too_many_expected_tokens);
|
||||
|
||||
while (*format)
|
||||
// %@: location.
|
||||
@@ -400,7 +403,9 @@ void yyerror (YYLTYPE *loc, char const *format, ...)
|
||||
static char *
|
||||
xstrndup (const char *string, size_t n)
|
||||
{
|
||||
size_t len = strnlen (string, n);
|
||||
// len = strnlen (string, n), portably.
|
||||
const char *end = memchr (string, '\0', n);
|
||||
size_t len = end ? (size_t) (end - string) : n;
|
||||
char *new = malloc (len + 1);
|
||||
assert (new);
|
||||
new[len] = '\0';
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(seq 0) >/dev/null 2>&1 || exit 77
|
||||
(seq 0) >/dev/null 2>&1 || skip "gimme one seq"
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
|
||||
+29
-8
@@ -25,7 +25,7 @@ medir=$(dirname "$1" | sed -e 's,.*examples/,,')
|
||||
number=1
|
||||
|
||||
# Exit status of this script.
|
||||
exit=true
|
||||
status=0
|
||||
|
||||
# top_builddir.
|
||||
cwd=$(pwd)
|
||||
@@ -34,6 +34,13 @@ cwd=$(pwd)
|
||||
# See bistromathic.test.
|
||||
strip_prompt=false
|
||||
|
||||
# If diff supports --strip-trailing-cr, use it, to avoid EOL issues
|
||||
# when testing Java programs on Windows.
|
||||
echo "checking for diff --strip-trailing-cr"
|
||||
if diff --strip-trailing-cr "$1" "$1"; then
|
||||
diff_opts=--strip-trailing-cr
|
||||
fi
|
||||
|
||||
# The exercised program.
|
||||
abs_medir=$cwd/examples/$medir
|
||||
if test -x "$abs_medir/$me"; then
|
||||
@@ -68,6 +75,20 @@ trap cleanup 0 1 2 13 15
|
||||
mkdir $$.dir
|
||||
cd $$.dir
|
||||
|
||||
|
||||
# skip [MSG]
|
||||
# ----------
|
||||
# Skip this test.
|
||||
skip ()
|
||||
{
|
||||
if test x"$1" != x; then
|
||||
echo "SKIP: $1"
|
||||
fi
|
||||
# See Autoconf's doc on 'trap'.
|
||||
(exit 77); exit 77
|
||||
}
|
||||
|
||||
|
||||
# run [-noerr, -n] EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
|
||||
# ----------------------------------------------------------------------
|
||||
# -noerr: ignore stderr, otherwise merge it into effective output.
|
||||
@@ -115,7 +136,7 @@ run ()
|
||||
} >eff
|
||||
|
||||
if test $sta_eff -eq $sta_exp; then
|
||||
if diff eff exp >/dev/null 2>&1; then
|
||||
if diff $diff_opts eff exp >/dev/null 2>&1; then
|
||||
echo "$me: PASS: $number"
|
||||
else
|
||||
echo "$me: FAIL: $number"
|
||||
@@ -126,21 +147,21 @@ run ()
|
||||
echo "$me: effective output:"
|
||||
sed -e 's/^/ /' eff
|
||||
echo "$me: diff:"
|
||||
diff -u exp eff | sed -e 's/^/ /'
|
||||
exit=false
|
||||
diff $diff_opts -u exp eff | sed -e 's/^/ /'
|
||||
status=1
|
||||
fi
|
||||
else
|
||||
echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)"
|
||||
cat err_eff
|
||||
exit=false
|
||||
status=1
|
||||
fi
|
||||
number=$(expr $number + 1)
|
||||
}
|
||||
|
||||
# We have cd'd one level deeper.
|
||||
case $1 in
|
||||
/*) . "$1";;
|
||||
*) . "../$1";;
|
||||
/*) . "$1" || status=2;;
|
||||
*) . "../$1" || status=2;;
|
||||
esac
|
||||
|
||||
$exit
|
||||
exit $status
|
||||
|
||||
+1
-1
Submodule gnulib updated: 2ac33b29fc...ffbb0ced8b
+6
-3
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 3.5.91. */
|
||||
/* A Bison parser, made by GNU Bison 3.6. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.5.91"
|
||||
#define YYBISON_VERSION "3.6"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@@ -408,6 +408,7 @@ typedef int yytype_uint16;
|
||||
|
||||
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
||||
|
||||
|
||||
/* Stored state numbers (used for stacks). */
|
||||
typedef yytype_uint8 yy_state_t;
|
||||
|
||||
@@ -1631,6 +1632,8 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
||||
yyarg[yycount++] = yysym;
|
||||
}
|
||||
}
|
||||
if (yyarg && yycount == 0 && 0 < yyargn)
|
||||
yyarg[0] = YYSYMBOL_YYEMPTY;
|
||||
return yycount;
|
||||
}
|
||||
|
||||
@@ -2702,7 +2705,7 @@ yyerrorlab:
|
||||
yyerrlab1:
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||
|
||||
// Pop stack until we find a state that shifts the error token.
|
||||
/* Pop stack until we find a state that shifts the error token. */
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact[yystate];
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 3.5.91. */
|
||||
/* A Bison parser, made by GNU Bison 3.6. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
|
||||
@@ -144,3 +144,44 @@ export LC_CTYPE
|
||||
|
||||
# Empty if no xsltproc was found
|
||||
: ${XSLTPROC='@XSLTPROC@'}
|
||||
|
||||
|
||||
# Some tests expect a precise diff format. See AT_DIFF_U_CHECK.
|
||||
# See https://lists.gnu.org/r/bug-bison/2020-05/msg00049.html.
|
||||
cat >conftest.1 <<EOF
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
EOF
|
||||
|
||||
cat >conftest.2 <<EOF
|
||||
1
|
||||
22
|
||||
3
|
||||
4
|
||||
55
|
||||
6
|
||||
EOF
|
||||
|
||||
cat >conftest.expected <<EOF
|
||||
@@ -1,6 +1,6 @@
|
||||
1
|
||||
-2
|
||||
+22
|
||||
3
|
||||
4
|
||||
-5
|
||||
+55
|
||||
6
|
||||
EOF
|
||||
|
||||
diff -u conftest.1 conftest.2 2>/dev/null | sed -n '/^@@/,$p' | sed 's/^ $//' >conftest.diff
|
||||
if diff conftest.expected conftest.diff >/dev/null; then
|
||||
DIFF_U_WORKS=true
|
||||
else
|
||||
DIFF_U_WORKS=false
|
||||
fi
|
||||
rm conftest.*
|
||||
|
||||
+18
-11
@@ -109,11 +109,6 @@ AT_DATA_GRAMMAR([list.yy],
|
||||
%define parse.assert
|
||||
%debug
|
||||
|
||||
%code top
|
||||
{
|
||||
// Get access to stack_symbol_type for the tests.
|
||||
# define private public
|
||||
}
|
||||
%code provides
|
||||
{
|
||||
]AT_YYLEX_DECLARE[
|
||||
@@ -136,6 +131,14 @@ AT_DATA_GRAMMAR([list.yy],
|
||||
%code requires { #include <vector> }
|
||||
%code { int yylex (yy::parser::semantic_type* lvalp); }
|
||||
|
||||
// A hack which relies on internal hooks to check stack_symbol_type,
|
||||
// which is private.
|
||||
%code yy_bison_internal_hook {
|
||||
public:
|
||||
typedef stack_symbol_type yy_stack_symbol_type;
|
||||
typedef stack_type yy_stack_type;
|
||||
}
|
||||
|
||||
%%
|
||||
exp: "int" { $$.push_back ($1); }
|
||||
%%
|
||||
@@ -157,6 +160,9 @@ int main()
|
||||
// symbol_type: construction, accessor.
|
||||
{
|
||||
parser::symbol_type s = parser::make_INT (12);
|
||||
assert_eq (s.kind (), parser::symbol_kind::S_INT);
|
||||
assert_eq (parser::symbol_name (s.kind ()), std::string ("\"int\""));
|
||||
assert_eq (s.name (), std::string ("\"int\""));
|
||||
assert_eq (s.value.as<int> (), 12);
|
||||
}
|
||||
|
||||
@@ -180,12 +186,13 @@ int main()
|
||||
}
|
||||
|
||||
// stack_symbol_type: construction, accessor.
|
||||
typedef parser::yy_stack_symbol_type stack_symbol_type;
|
||||
{
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
auto ss = parser::stack_symbol_type(1, parser::make_INT(123));
|
||||
auto ss = stack_symbol_type (1, parser::make_INT(123));
|
||||
#else
|
||||
parser::symbol_type s = parser::make_INT (123);
|
||||
parser::stack_symbol_type ss(1, s);
|
||||
stack_symbol_type ss(1, s);
|
||||
#endif
|
||||
assert_eq (ss.value.as<int> (), 123);
|
||||
}
|
||||
@@ -194,17 +201,17 @@ int main()
|
||||
// Sufficiently many so that it will be resized.
|
||||
// Probably 3 times (starting at 200).
|
||||
{
|
||||
parser::stack_type st;
|
||||
parser::yy_stack_type st;
|
||||
const int mucho = 1700;
|
||||
const int int_reduction_state = 1; // Read list.output to find it.
|
||||
for (int i = 0; i < mucho; ++i)
|
||||
{
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
st.push(parser::stack_symbol_type{int_reduction_state,
|
||||
parser::make_INT (i)});
|
||||
st.push(stack_symbol_type{int_reduction_state,
|
||||
parser::make_INT (i)});
|
||||
#else
|
||||
parser::symbol_type s = parser::make_INT (i);
|
||||
parser::stack_symbol_type ss (int_reduction_state, s);
|
||||
stack_symbol_type ss (int_reduction_state, s);
|
||||
st.push (ss);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -265,7 +265,8 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
|
||||
]])
|
||||
|
||||
|
||||
# Likewise, but currently not portable to Cygwin.
|
||||
# Likewise, but currently not portable to AIX and Cygwin.
|
||||
# https://lists.gnu.org/r/bug-bison/2020-05/msg00050.html
|
||||
# https://lists.gnu.org/r/bug-bison/2020-05/msg00003.html.
|
||||
AT_TEST([[Tabulations and multibyte characters]],
|
||||
[[%%
|
||||
@@ -277,7 +278,7 @@ e: {∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}
|
||||
| <warning>^~~~~~~~~~~~~~</warning>
|
||||
| <fixit-insert>%empty</fixit-insert>
|
||||
input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
|
||||
]], [], [uname -a | grep -i cygwin])
|
||||
]], [], [uname -a | $EGREP -i 'aix|cygwin'])
|
||||
|
||||
|
||||
## --------------- ##
|
||||
|
||||
+2
-7
@@ -35,14 +35,9 @@ dnl time comes, just use sed to drop the line numbers. For now, as LR(1)
|
||||
dnl support is rapidly evolving, let's keep that information to be careful.
|
||||
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
|
||||
m4_pushdef([AT_LALR1_DIFF_CHECK],
|
||||
[dnl We need diff -u, which is not portable.
|
||||
AT_CHECK([diff -u /dev/null /dev/null || exit 77], [0], [ignore])
|
||||
|
||||
AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
||||
[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
||||
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
|
||||
AT_CHECK([[diff -u input-lalr.output input.output \
|
||||
| sed -n '/^@@/,$p' | sed 's/^ $//']],
|
||||
[[0]], [$1])])
|
||||
AT_DIFF_U_CHECK([[input-lalr.output input.output]], [$1])])
|
||||
|
||||
AT_TEST_TABLES_AND_PARSE([$2[: LALR(1)]], [[LALR]], [[last-state]],
|
||||
[[%define lr.type lalr
|
||||
|
||||
+18
-1
@@ -1352,8 +1352,20 @@ AT_BISON_CHECK([-fcaret input.y], [1], [],
|
||||
]])
|
||||
|
||||
|
||||
# Clang chokes on some of our comments, because it tries to "parse"
|
||||
# some documentation directives in the comments:
|
||||
#
|
||||
# input.c:166:50: error: '\a' command does not have a valid word argument [-Werror,-Wdocumentation]
|
||||
# FAKE = 258 /* "fake [] \a\b\f\n\r\t\v\"'?\\[\\ ??!??'??(??)??-??/??<??=??> \001\001" */
|
||||
# ~~^
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[[%{
|
||||
[[%code requires {
|
||||
#if defined __clang__ && 10 <= __clang_major__
|
||||
# pragma clang diagnostic ignored "-Wdocumentation"
|
||||
#endif
|
||||
}
|
||||
|
||||
%{
|
||||
/* This is seen in GCC: a %{ and %} in middle of a comment. */
|
||||
const char *foo = "So %{ and %} can be here too.";
|
||||
|
||||
@@ -1424,6 +1436,11 @@ char quote[] = "@:>@@:>@,";
|
||||
/* Exercise quotes in strings. */
|
||||
%token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
|
||||
|
||||
/* Beware of the generated comments that embed string aliases that
|
||||
might close the comment. */
|
||||
%token COMMENT_CLOSE "*/"
|
||||
%token COMMENT "/* comment */"
|
||||
|
||||
%%
|
||||
/* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
|
||||
exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
|
||||
|
||||
+11
-1
@@ -83,6 +83,16 @@ set x `LC_ALL=C ls -l '$1'` &&
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# AT_DIFF_U_CHECK(DIFF-ARGS, EXPECTED-DIFF)
|
||||
# -----------------------------------------
|
||||
# If diff -u works as we expect, use it, with headers stripped.
|
||||
m4_define([AT_DIFF_U_CHECK],
|
||||
[if $DIFF_U_WORKS; then
|
||||
AT_CHECK([diff -u $1 | sed -n '/^@@/,$p' | sed 's/^ $//'], [0], [$2])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
# AT_PERL_CHECK(PERL-ARGS, ...)
|
||||
# -----------------------------
|
||||
# If Perl is available, run this test.
|
||||
@@ -490,7 +500,7 @@ m4_define([AT_DATA_SOURCE_PROLOGUE],
|
||||
# The prologue that should be included in any grammar whose parser is
|
||||
# meant to be compiled.
|
||||
m4_define([AT_DATA_GRAMMAR_PROLOGUE],
|
||||
[[%code top {
|
||||
[[%code top { /* -*- ]AT_LANG[ -*- */
|
||||
]AT_DATA_SOURCE_PROLOGUE[]dnl
|
||||
[}
|
||||
]])
|
||||
|
||||
@@ -56,6 +56,7 @@ TESTSUITE_AT = \
|
||||
%D%/java.at \
|
||||
%D%/javapush.at \
|
||||
%D%/local.at \
|
||||
%D%/m4.at \
|
||||
%D%/named-refs.at \
|
||||
%D%/output.at \
|
||||
%D%/package.m4 \
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
# Basic m4 macros. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2020 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# 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/>.
|
||||
|
||||
AT_BANNER([[M4 Macros.]])
|
||||
|
||||
|
||||
AT_SETUP([Generating Comments])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[%%
|
||||
exp:
|
||||
])
|
||||
|
||||
AT_DATA([input.m4],
|
||||
[[m4@&t@_include(b4_skeletonsdir/[c.m4])
|
||||
|
||||
b4_output_begin([output.txt])
|
||||
b4_comment([["/* () */"]])
|
||||
b4_comment([["/* ( */"]])
|
||||
b4_comment([["/* ) */"]])
|
||||
b4_output_end([output.txt])
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-S ./input.m4 input.y])
|
||||
|
||||
AT_CHECK([cat output.txt], [],
|
||||
[/* "/\* () *\/" */
|
||||
/* "/\* ( *\/" */
|
||||
/* "/\* ) *\/" */
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
+17
-6
@@ -372,8 +372,19 @@ m4_pushdef([AT_TEST],
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
||||
|
||||
|
||||
# Clang chokes on some of our comments, because it tries to "parse"
|
||||
# some documentation directives in the comments:
|
||||
#
|
||||
# input.c:131:48: error: '\a' command does not have a valid word argument [-Werror,-Wdocumentation]
|
||||
# SPECIAL = 261 /* "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" */
|
||||
# ~~^
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[%{
|
||||
#if defined __clang__ && 10 <= __clang_major__
|
||||
# pragma clang diagnostic ignored "-Wdocumentation"
|
||||
#endif
|
||||
|
||||
]AT_YYERROR_DECLARE[
|
||||
]AT_YYLEX_DECLARE[
|
||||
%}
|
||||
@@ -398,14 +409,14 @@ exp: ]AT_ERROR_VERBOSE_IF(["\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"], ["
|
||||
# C-string literal. Also notice that unnecessary escaping, such as "\?", from
|
||||
# the user specification is eliminated.
|
||||
AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
|
||||
[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
|
||||
22 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
|
||||
[[input.y:26.8-14: warning: symbol SPECIAL redeclared [-Wother]
|
||||
26 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
|
||||
| ^~~~~~~
|
||||
input.y:21.8-14: note: previous declaration
|
||||
21 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
|
||||
input.y:25.8-14: note: previous declaration
|
||||
25 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
|
||||
| ^~~~~~~
|
||||
input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
|
||||
22 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
|
||||
input.y:26.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
|
||||
26 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
]])
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Basic M4 macros.
|
||||
m4_include([m4.at])
|
||||
|
||||
# Resistance to user bugs.
|
||||
m4_include([input.at])
|
||||
|
||||
Reference in New Issue
Block a user