mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-10 03:05:14 +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 | ||
|
|
506c368ab2 | ||
|
|
4f9dc3bdc1 | ||
|
|
0d81be2dc7 | ||
|
|
32f44f4bfb | ||
|
|
38a8287813 | ||
|
|
df752784c2 | ||
|
|
292409e91e | ||
|
|
eea56d70d9 | ||
|
|
6e2de439e6 | ||
|
|
e33cd4b824 | ||
|
|
0669780ff8 | ||
|
|
160df220b1 | ||
|
|
da5c072a62 | ||
|
|
73ac8ff409 | ||
|
|
0e0fb0efc9 | ||
|
|
bb1d776be0 | ||
|
|
d7e1abe656 | ||
|
|
13a1537dba | ||
|
|
ac2ba46053 | ||
|
|
2a7a2c1d3a | ||
|
|
c9b5b68c73 | ||
|
|
26aef31552 | ||
|
|
392f3caef6 | ||
|
|
ccaa8e29f9 | ||
|
|
76c3bccf40 | ||
|
|
6275137378 | ||
|
|
d0571c846f | ||
|
|
8c1002e4b7 | ||
|
|
dbd8fd71ba | ||
|
|
95bac741c3 | ||
|
|
f8ab4d81c0 | ||
|
|
d55c9b001a | ||
|
|
611495999f | ||
|
|
01d5f232a9 | ||
|
|
0407acbc59 | ||
|
|
0c0e778bd1 | ||
|
|
30357ae942 | ||
|
|
fb1d76d9a9 | ||
|
|
a61bc3f9f8 | ||
|
|
f0942df01a | ||
|
|
52ababbc89 | ||
|
|
8e11933e41 | ||
|
|
99efa35369 | ||
|
|
547545a795 | ||
|
|
1b5cf80e32 | ||
|
|
4c641c5189 | ||
|
|
3b05de2d05 | ||
|
|
902a235ad3 | ||
|
|
11027558c8 | ||
|
|
cd4e799da4 | ||
|
|
7346163840 | ||
|
|
89c4e1becf | ||
|
|
3262747c5b | ||
|
|
5f3cd49acc | ||
|
|
e6d928c4e8 | ||
|
|
b254b36db8 | ||
|
|
58e79539fc | ||
|
|
60366b152b | ||
|
|
c90110efd3 | ||
|
|
3b50adf7f4 | ||
|
|
3aaa971096 | ||
|
|
7eabe1c70b | ||
|
|
7fec669e42 | ||
|
|
cbbbe12e02 | ||
|
|
286d0755f8 | ||
|
|
1c3d79b871 | ||
|
|
9c72d3c5a8 | ||
|
|
bc083be055 | ||
|
|
22eeb1ab8a | ||
|
|
c4dbc1776c | ||
|
|
b74fc07d21 | ||
|
|
3ab12c1036 | ||
|
|
30ce43b2b5 | ||
|
|
150dc95395 | ||
|
|
bb7c4a5508 | ||
|
|
5c9f50b545 | ||
|
|
b42702d738 | ||
|
|
401e7c5c36 | ||
|
|
93fec67c46 | ||
|
|
4378e2dc3c | ||
|
|
81334eb5a0 | ||
|
|
df373f1ea1 | ||
|
|
9b7e7077dd | ||
|
|
5ab0086157 | ||
|
|
2831bd376f | ||
|
|
1d0e3ee896 | ||
|
|
0a64b76430 |
+1
-1
@@ -1 +1 @@
|
||||
3.5.4
|
||||
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,6 +1,32 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.5.90 (2020-04-18) [beta]
|
||||
* Noteworthy changes in release 3.6.2 (2020-05-17) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Some tests were fixed.
|
||||
|
||||
When token aliases contain comment delimiters:
|
||||
|
||||
%token FOO "/* foo */"
|
||||
|
||||
bison used to emit "nested" comments, which is invalid C.
|
||||
|
||||
* 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
|
||||
|
||||
In C++, yy::parser::symbol_type now has a public name() member function.
|
||||
|
||||
* Noteworthy changes in release 3.6 (2020-05-08) [stable]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
@@ -14,6 +40,12 @@ GNU Bison NEWS
|
||||
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
||||
parse.error verbose".
|
||||
|
||||
** Deprecated features
|
||||
|
||||
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
|
||||
It is deprecated and its support will be removed eventually.
|
||||
|
||||
** New features
|
||||
|
||||
*** Improved syntax error messages
|
||||
@@ -80,7 +112,7 @@ GNU Bison NEWS
|
||||
PLUS "+"
|
||||
MINUS "-"
|
||||
<double>
|
||||
NUM _("double precision number")
|
||||
NUM _("number")
|
||||
<symrec*>
|
||||
FUN _("function")
|
||||
VAR _("variable")
|
||||
@@ -99,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
|
||||
@@ -117,10 +161,10 @@ GNU Bison NEWS
|
||||
"yytoken_kind_t".
|
||||
|
||||
This type now also includes tokens that were previously hidden: YYEOF (end
|
||||
of input), YYUNDEF (undefined token), and YYERRCODE (error token). They
|
||||
of input), YYUNDEF (undefined token), and YYerror (error token). They
|
||||
now have string aliases, internationalized when internationalization is
|
||||
enabled. Therefore, by default, error messages now refer to "end of file"
|
||||
(internationalized) rather than the cryptic "$end", or to "invaid token"
|
||||
(internationalized) rather than the cryptic "$end", or to "invalid token"
|
||||
rather than "$undefined".
|
||||
|
||||
Therefore in most cases it is now useless to define the end-of-line token
|
||||
@@ -186,8 +230,8 @@ GNU Bison NEWS
|
||||
|
||||
*** Examples
|
||||
|
||||
There are now two examples in examples/java: a very simple calculator, and
|
||||
one that tracks locations to provide accurate error messages.
|
||||
There are now examples/java: a very simple calculator, and a more complete
|
||||
one (push-parser, location tracking, and debug traces).
|
||||
|
||||
The lexcalc example (a simple example in C based on Flex and Bison) now
|
||||
also demonstrates location tracking.
|
||||
@@ -2518,7 +2562,7 @@ GNU Bison NEWS
|
||||
Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
|
||||
halts in the middle of its course.
|
||||
|
||||
* Changes in version 2.5 (2011-05-14):
|
||||
* Noteworthy changes in release 2.5 (2011-05-14)
|
||||
|
||||
** Grammar symbol names can now contain non-initial dashes:
|
||||
|
||||
@@ -2873,7 +2917,7 @@ GNU Bison NEWS
|
||||
|
||||
This bug has been fixed.
|
||||
|
||||
* Changes in version 2.4.3 (2010-08-05):
|
||||
* Noteworthy changes in release 2.4.3 (2010-08-05)
|
||||
|
||||
** Bison now obeys -Werror and --warnings=error for warnings about
|
||||
grammar rules that are useless in the parser due to conflicts.
|
||||
@@ -2893,7 +2937,7 @@ GNU Bison NEWS
|
||||
|
||||
** Minor documentation fixes.
|
||||
|
||||
* Changes in version 2.4.2 (2010-03-20):
|
||||
* Noteworthy changes in release 2.4.2 (2010-03-20)
|
||||
|
||||
** Some portability problems that resulted in failures and livelocks
|
||||
in the test suite on some versions of at least Solaris, AIX, HP-UX,
|
||||
@@ -2987,7 +3031,7 @@ GNU Bison NEWS
|
||||
message translations were not installed although supported by the
|
||||
host system.
|
||||
|
||||
* Changes in version 2.4.1 (2008-12-11):
|
||||
* Noteworthy changes in release 2.4.1 (2008-12-11)
|
||||
|
||||
** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
|
||||
declarations have been fixed.
|
||||
@@ -3012,7 +3056,7 @@ GNU Bison NEWS
|
||||
|
||||
** A few minor improvements to the Bison manual.
|
||||
|
||||
* Changes in version 2.4 (2008-11-02):
|
||||
* Noteworthy changes in release 2.4 (2008-11-02)
|
||||
|
||||
** %language is an experimental feature.
|
||||
|
||||
@@ -3027,7 +3071,7 @@ GNU Bison NEWS
|
||||
** Several bugs in the C++ skeleton and the experimental Java skeleton have been
|
||||
fixed.
|
||||
|
||||
* Changes in version 2.3b (2008-05-27):
|
||||
* Noteworthy changes in release 2.3b (2008-05-27)
|
||||
|
||||
** The quotes around NAME that used to be required in the following directive
|
||||
are now deprecated:
|
||||
@@ -3213,7 +3257,7 @@ GNU Bison NEWS
|
||||
** The nonfunctional --no-parser, -n, and %no-parser options have been
|
||||
completely removed from Bison.
|
||||
|
||||
* Changes in version 2.3a, 2006-09-13:
|
||||
* Noteworthy changes in release 2.3a (2006-09-13)
|
||||
|
||||
** Instead of %union, you can define and use your own union type
|
||||
YYSTYPE if your grammar contains at least one <type> tag.
|
||||
@@ -3327,7 +3371,7 @@ GNU Bison NEWS
|
||||
The old spelling still works, but is not documented and may be removed
|
||||
in a future release.
|
||||
|
||||
* Changes in version 2.3, 2006-06-05:
|
||||
* Noteworthy changes in release 2.3 (2006-06-05)
|
||||
|
||||
** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
|
||||
for compatibility with LALR(1) grammars.
|
||||
@@ -3335,7 +3379,7 @@ GNU Bison NEWS
|
||||
** It is now documented that any definition of YYSTYPE or YYLTYPE should
|
||||
be to a type name that does not contain parentheses or brackets.
|
||||
|
||||
* Changes in version 2.2, 2006-05-19:
|
||||
* Noteworthy changes in release 2.2 (2006-05-19)
|
||||
|
||||
** The distribution terms for all Bison-generated parsers now permit
|
||||
using the parsers in nonfree programs. Previously, this permission
|
||||
@@ -3417,7 +3461,7 @@ GNU Bison NEWS
|
||||
|
||||
** DJGPP support added.
|
||||
|
||||
* Changes in version 2.1, 2005-09-16:
|
||||
* Noteworthy changes in release 2.1 (2005-09-16)
|
||||
|
||||
** The C++ lalr1.cc skeleton supports %lex-param.
|
||||
|
||||
@@ -3443,7 +3487,7 @@ GNU Bison NEWS
|
||||
print 'syntax error, unexpected number' instead of 'syntax error,
|
||||
unexpected "number"'.
|
||||
|
||||
* Changes in version 2.0, 2004-12-25:
|
||||
* Noteworthy changes in release 2.0 (2004-12-25)
|
||||
|
||||
** Possibly-incompatible changes
|
||||
|
||||
@@ -3506,7 +3550,7 @@ GNU Bison NEWS
|
||||
|
||||
- Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
|
||||
|
||||
* Changes in version 1.875, 2003-01-01:
|
||||
* Noteworthy changes in release 1.875 (2003-01-01)
|
||||
|
||||
** The documentation license has been upgraded to version 1.2
|
||||
of the GNU Free Documentation License.
|
||||
@@ -3626,7 +3670,7 @@ GNU Bison NEWS
|
||||
ago, but nobody noticed until we recently asked someone to try
|
||||
building Bison with a K&R C compiler.
|
||||
|
||||
* Changes in version 1.75, 2002-10-14:
|
||||
* Noteworthy changes in release 1.75 (2002-10-14)
|
||||
|
||||
** Bison should now work on 64-bit hosts.
|
||||
|
||||
@@ -3657,7 +3701,7 @@ GNU Bison NEWS
|
||||
was incorrectly rejected: $1 is defined in the second midrule
|
||||
action, and is equal to the $$ of the first midrule action.
|
||||
|
||||
* Changes in version 1.50, 2002-10-04:
|
||||
* Noteworthy changes in release 1.50 (2002-10-04)
|
||||
|
||||
** GLR parsing
|
||||
The declaration
|
||||
@@ -3801,7 +3845,7 @@ GNU Bison NEWS
|
||||
|
||||
** GNU M4 is now required when using Bison.
|
||||
|
||||
* Changes in version 1.35, 2002-03-25:
|
||||
* Noteworthy changes in release 1.35 (2002-03-25)
|
||||
|
||||
** C Skeleton
|
||||
Some projects use Bison's C parser with C++ compilers, and define
|
||||
@@ -3816,7 +3860,7 @@ GNU Bison NEWS
|
||||
This kludge also addresses some C++ problems when the stack was
|
||||
extended.
|
||||
|
||||
* Changes in version 1.34, 2002-03-12:
|
||||
* Noteworthy changes in release 1.34 (2002-03-12)
|
||||
|
||||
** File name clashes are detected
|
||||
$ bison foo.y -d -o foo.x
|
||||
@@ -3836,7 +3880,7 @@ GNU Bison NEWS
|
||||
|
||||
** Fix test suite portability problems.
|
||||
|
||||
* Changes in version 1.33, 2002-02-07:
|
||||
* Noteworthy changes in release 1.33 (2002-02-07)
|
||||
|
||||
** Fix C++ issues
|
||||
Groff could not be compiled for the definition of size_t was lacking
|
||||
@@ -3845,7 +3889,7 @@ GNU Bison NEWS
|
||||
** Catch invalid @n
|
||||
As is done with $n.
|
||||
|
||||
* Changes in version 1.32, 2002-01-23:
|
||||
* Noteworthy changes in release 1.32 (2002-01-23)
|
||||
|
||||
** Fix Yacc output file names
|
||||
|
||||
@@ -3853,7 +3897,7 @@ GNU Bison NEWS
|
||||
|
||||
** Italian, Dutch translations
|
||||
|
||||
* Changes in version 1.31, 2002-01-14:
|
||||
* Noteworthy changes in release 1.31 (2002-01-14)
|
||||
|
||||
** Many Bug Fixes
|
||||
|
||||
@@ -3940,7 +3984,7 @@ GNU Bison NEWS
|
||||
** --output
|
||||
New, aliasing "--output-file".
|
||||
|
||||
* Changes in version 1.30, 2001-10-26:
|
||||
* Noteworthy changes in release 1.30 (2001-10-26)
|
||||
|
||||
** "--defines" and "--graph" have now an optional argument which is the
|
||||
output file name. "-d" and "-g" do not change; they do not take any
|
||||
@@ -3951,7 +3995,7 @@ GNU Bison NEWS
|
||||
|
||||
** Portability fixes.
|
||||
|
||||
* Changes in version 1.29, 2001-09-07:
|
||||
* Noteworthy changes in release 1.29 (2001-09-07)
|
||||
|
||||
** The output file does not define const, as this caused problems when used
|
||||
with common autoconfiguration schemes. If you still use ancient compilers
|
||||
@@ -3986,7 +4030,7 @@ GNU Bison NEWS
|
||||
** @$
|
||||
Automatic location tracking.
|
||||
|
||||
* Changes in version 1.28, 1999-07-06:
|
||||
* Noteworthy changes in release 1.28 (1999-07-06)
|
||||
|
||||
** Should compile better now with K&R compilers.
|
||||
|
||||
@@ -3996,12 +4040,12 @@ GNU Bison NEWS
|
||||
|
||||
** There is now a FAQ.
|
||||
|
||||
* Changes in version 1.27:
|
||||
* Noteworthy changes in release 1.27
|
||||
|
||||
** The make rule which prevented bison.simple from being created on
|
||||
some systems has been fixed.
|
||||
|
||||
* Changes in version 1.26:
|
||||
* Noteworthy changes in release 1.26
|
||||
|
||||
** Bison now uses Automake.
|
||||
|
||||
@@ -4018,7 +4062,7 @@ GNU Bison NEWS
|
||||
** Generated parsers should now work even on operating systems which do
|
||||
not provide alloca().
|
||||
|
||||
* Changes in version 1.25, 1995-10-16:
|
||||
* Noteworthy changes in release 1.25 (1995-10-16)
|
||||
|
||||
** Errors in the input grammar are not fatal; Bison keeps reading
|
||||
the grammar file, and reports all the errors found in it.
|
||||
@@ -4043,7 +4087,7 @@ the parser engine; a project can now use its own parser engine.
|
||||
The actions go into a separate file called NAME.act, in the form of
|
||||
a switch statement body.
|
||||
|
||||
* Changes in version 1.23:
|
||||
* Noteworthy changes in release 1.23
|
||||
|
||||
The user can define YYPARSE_PARAM as the name of an argument to be
|
||||
passed into yyparse. The argument should have type void *. It should
|
||||
@@ -4052,11 +4096,11 @@ by casting it to the proper pointer type.
|
||||
|
||||
Line numbers in output file corrected.
|
||||
|
||||
* Changes in version 1.22:
|
||||
* Noteworthy changes in release 1.22
|
||||
|
||||
--help option added.
|
||||
|
||||
* Changes in version 1.20:
|
||||
* Noteworthy changes in release 1.20
|
||||
|
||||
Output file does not redefine const for C++.
|
||||
|
||||
@@ -4113,8 +4157,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata yytname
|
||||
LocalWords: yysymbol yytnamerr yyreport ctx ARGMAX yysyntax stderr LPAREN
|
||||
LocalWords: symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF
|
||||
LocalWords: autocompletion bistromathic submessages Cayuela lexcalc
|
||||
LocalWords: yytoken YYUNDEF YYERRCODE
|
||||
LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
|
||||
LocalWords: yytoken YYUNDEF YYerror
|
||||
|
||||
Local Variables:
|
||||
ispell-dictionary: "american"
|
||||
|
||||
@@ -37,6 +37,14 @@ Only user visible strings are to be translated: error messages, bits of the
|
||||
assert/abort), and all the --trace output which is meant for the maintainers
|
||||
only.
|
||||
|
||||
## Syntax highlighting
|
||||
It's quite nice to be in C++ mode when editing lalr1.cc for instance.
|
||||
However tools such as Emacs will be fooled by the fact that braces and
|
||||
parens do not nest, as in `[[}]]`. As a consequence you might be misguided
|
||||
by its visual pairing to parens. The m4-mode is safer. Unfortunately the
|
||||
m4-mode is also fooled by `#` which is sees as a comment, stops pairing with
|
||||
parens/brackets that are inside...
|
||||
|
||||
## Coding Style
|
||||
Do not add horizontal tab characters to any file in Bison's repository
|
||||
except where required. For example, do not use tabs to format C code.
|
||||
@@ -57,6 +65,31 @@ Actually, Bison has legacy code that we should replace with gnulib modules
|
||||
### Skeletons
|
||||
We try to use the "typical" coding style for each language.
|
||||
|
||||
#### CPP
|
||||
We indent the CPP directives this way:
|
||||
|
||||
```
|
||||
#if FOO
|
||||
# if BAR
|
||||
# define BAZ
|
||||
# endif
|
||||
#endif
|
||||
```
|
||||
|
||||
Don't indent with leading spaces in the skeletons (it's ok in the grammar
|
||||
files though, e.g., in `%code {...}` blocks).
|
||||
|
||||
On occasions, use `cppi -c` to see where we stand. We don't aim at full
|
||||
correctness: depending `-d`, some bits can be in the *.c file, or the *.h
|
||||
file within the double-inclusion cpp-guards. In that case, favor the case
|
||||
of the *.h file, but don't waste time on this.
|
||||
|
||||
Don't hesitate to leave a comment on the `#endif` (e.g., `#endif /* FOO
|
||||
*/`), especially for long blocks.
|
||||
|
||||
There is no conistency on `! defined` vs. `!defined`. The day gnulib
|
||||
decides, we'll follow them.
|
||||
|
||||
#### C/C++
|
||||
Follow the GNU Coding Standards.
|
||||
|
||||
@@ -370,6 +403,12 @@ again, since some early failures may stop latter tests from being run. Yet
|
||||
at some point, you'll have to fix remaining issues by hand...
|
||||
|
||||
|
||||
## Running Java parsers
|
||||
Use the `javaexec.sh` script. For instance to run the parser of test case
|
||||
504:
|
||||
|
||||
$ sh ./_build/javaexec.sh -cp ./_build/tests/testsuite.dir/504 Calc
|
||||
|
||||
## make maintainer-check-valgrind
|
||||
This target uses valgrind both to check bison, and the generated parsers.
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ Anthony Heading [email protected]
|
||||
Antonio Silva Correia [email protected]
|
||||
Arnold Robbins [email protected]
|
||||
Art Haas [email protected]
|
||||
Arthur Schwarz [email protected]
|
||||
Askar Safin [email protected]
|
||||
Balázs Scheidler [email protected]
|
||||
Baron Schwartz [email protected]
|
||||
@@ -57,6 +58,7 @@ Derek M. Jones [email protected]
|
||||
Di-an Jan [email protected]
|
||||
Dick Streefland [email protected]
|
||||
Didier Godefroy [email protected]
|
||||
Don Macpherson [email protected]
|
||||
Efi Fogel [email protected]
|
||||
Enrico Scholz [email protected]
|
||||
Eric Blake [email protected]
|
||||
@@ -154,6 +156,7 @@ Petr Machata [email protected]
|
||||
Pho [email protected]
|
||||
Piotr Gackiewicz [email protected]
|
||||
Piotr Marcińczyk [email protected]
|
||||
Pramod Kumbhar [email protected]
|
||||
Quentin Hocquet [email protected]
|
||||
Quoc Peyrot [email protected]
|
||||
R Blake [email protected]
|
||||
|
||||
@@ -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
|
||||
@@ -7,6 +18,10 @@
|
||||
- is there a migration path that would allow to use TokenKinds in
|
||||
yylex?
|
||||
|
||||
- define the tokens as an enum too.
|
||||
|
||||
- promote YYEOF rather than EOF.
|
||||
|
||||
*** D
|
||||
- is there a way to attach yysymbol_name to the enum itself? As we did
|
||||
in Java.
|
||||
@@ -14,17 +29,37 @@
|
||||
- It would be better to have TokenKind as return value. Can we use
|
||||
reflection to support both output types?
|
||||
|
||||
** Documentation
|
||||
- YYERRCODE, YYUNDEF, YYEOF
|
||||
- YYERRCODE and translation
|
||||
** YYerror
|
||||
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y;h=a712255af4f2f739c93336d4ff6556d932a426a5;hb=HEAD
|
||||
|
||||
should be updated to not use YYERRCODE. Returning an undef token is good
|
||||
enough.
|
||||
|
||||
** Java
|
||||
*** Examples
|
||||
Have an example with a push parser. Use autocompletion in that case.
|
||||
|
||||
*** calc.at
|
||||
Stop hard-coding "Calc". Adjust local.at (look for FIXME).
|
||||
|
||||
** Counter example generation
|
||||
See https://github.com/akimd/bison/pull/15.
|
||||
|
||||
** Clean up
|
||||
Rename user_token_number for tokens as "code". It's not a "user number",
|
||||
it's the token code, and the user can control it, but this code always
|
||||
exists.
|
||||
|
||||
See also USER_NUMBER_UNDEFINED and NUMBER_UNDEFINED.
|
||||
|
||||
Rename endtoken as eoftoken.
|
||||
|
||||
Also do it in data/skeletons.
|
||||
|
||||
Don't rename in Bison 3.6 (it would be logical to do so) because that
|
||||
would probably create many conflicts in Vincent's work (see previous point).
|
||||
|
||||
** A dev warning for b4_
|
||||
Maybe we should check for m4_ and b4_ leaking out of the m4 processing, as
|
||||
Autoconf does. It would have caught overquotation issues.
|
||||
|
||||
** doc
|
||||
I feel it's ugly to use the GNU style to declare functions in the doc. It
|
||||
generates tons of white space in the page, and may contribute to bad page
|
||||
@@ -35,7 +70,7 @@ token vs terminal, variable vs non terminal.
|
||||
|
||||
** api.token.raw
|
||||
The YYUNDEFTOK could be assigned a semantic value so that yyerror could be
|
||||
used to report invalid lexemes. See also the item "$undefined" below.
|
||||
used to report invalid lexemes.
|
||||
|
||||
** push parsers
|
||||
Consider deprecating impure push parsers. They add a lot of complexity, for
|
||||
@@ -43,21 +78,74 @@ a bad feature. On the other hand, that would make it much harder to sit
|
||||
push parsers on top of pull parser. Which is currently not relevant, since
|
||||
push parsers are measurably slower.
|
||||
|
||||
* Bison 3.7
|
||||
** Counter example generation
|
||||
See https://github.com/akimd/bison/pull/15.
|
||||
** %define parse.error formatted
|
||||
How about pushing bistromathics' yyreport_syntax_error as another standard
|
||||
way to generate the error message, and leave to the user the task of
|
||||
providing the message formats? Currently in bistro, it reads:
|
||||
|
||||
** Clean up
|
||||
Rename user_token_number for tokens as "code". It's not a "user number",
|
||||
it's the token code, and the user can control it, but this code always
|
||||
exists.
|
||||
const char *
|
||||
error_format_string (int argc)
|
||||
{
|
||||
switch (argc)
|
||||
{
|
||||
default: /* Avoid compiler warnings. */
|
||||
case 0: return _("%@: syntax error");
|
||||
case 1: return _("%@: syntax error: unexpected %u");
|
||||
// TRANSLATORS: '%@' is a location in a file, '%u' is an
|
||||
// "unexpected token", and '%0e', '%1e'... are expected tokens
|
||||
// at this point.
|
||||
//
|
||||
// For instance on the expression "1 + * 2", you'd get
|
||||
//
|
||||
// 1.5: syntax error: expected - or ( or number or function or variable before *
|
||||
case 2: return _("%@: syntax error: expected %0e before %u");
|
||||
case 3: return _("%@: syntax error: expected %0e or %1e before %u");
|
||||
case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
Rename endtoken as eoftoken.
|
||||
The message would have to be generated in a string, and pushed to yyerror.
|
||||
Which will be a pain in the neck in yacc.c.
|
||||
|
||||
Also do it in data/skeletons.
|
||||
If we want to do that, we should think very carefully about the syntax of
|
||||
the format string.
|
||||
|
||||
Don't rename in Bison 3.6 (it would be logical to do so) because that
|
||||
would probably create many conflicts in Vincent's work (see previous point).
|
||||
** yyclearin does not invoke the lookahead token's %destructor
|
||||
https://lists.gnu.org/r/bug-bison/2018-02/msg00000.html
|
||||
Rici:
|
||||
|
||||
> Modifying yyclearin so that it calls yydestruct seems like the simplest
|
||||
> solution to this issue, but it is conceivable that such a change would
|
||||
> break programs which already perform some kind of workaround in order to
|
||||
> destruct the lookahead symbol. So it might be necessary to use some kind of
|
||||
> compatibility %define, or to create a new replacement macro with a
|
||||
> different name such as yydiscardin.
|
||||
>
|
||||
> 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)
|
||||
@@ -133,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
|
||||
@@ -340,8 +428,12 @@ LORIA, INRIA Nancy - Grand Est, Nancy, France
|
||||
** More languages?
|
||||
Well, only if there is really some demand for it.
|
||||
|
||||
*** PHP
|
||||
https://github.com/scfc/bison-php/blob/master/data/lalr1.php
|
||||
|
||||
*** Python
|
||||
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
||||
|
||||
** Multiple start symbols
|
||||
Would be very useful when parsing closely related languages. The idea is to
|
||||
declare several start symbols, for instance
|
||||
@@ -460,15 +552,6 @@ move to partial orders (sounds like series/parallel orders to me).
|
||||
|
||||
This is a prerequisite for modules.
|
||||
|
||||
* $undefined
|
||||
From Hans:
|
||||
- If the Bison generated parser experiences an undefined number in the
|
||||
character range, that character is written out in diagnostic messages, an
|
||||
addition to the $undefined value.
|
||||
|
||||
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
||||
|
||||
|
||||
* Pre and post actions.
|
||||
From: Florian Krohm <[email protected]>
|
||||
Subject: YYACT_EPILOGUE
|
||||
|
||||
@@ -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
|
||||
@@ -156,7 +156,7 @@ exclude = \
|
||||
$(call exclude, \
|
||||
bindtextdomain=^lib/main.c$$ \
|
||||
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
||||
po_check=^(examples|tests)/|(^po/POTFILES.in|.md)$$ \
|
||||
po_check=^tests|(^po/POTFILES.in|.md)$$ \
|
||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||
program_name=^lib/main.c$$ \
|
||||
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||
|
||||
+11
-6
@@ -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]), [[-_]],
|
||||
@@ -261,9 +259,9 @@ if ! "$LEX_IS_FLEX" || test "X$LEX" = X:; then
|
||||
AC_MSG_WARN([bypassing lex because flex is required])
|
||||
LEX=:
|
||||
fi
|
||||
AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX])
|
||||
AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX && $FLEX_SUPPORTS_HEADER_OPT])
|
||||
AM_CONDITIONAL([FLEX_CXX_WORKS],
|
||||
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
|
||||
[$LEX_IS_FLEX && $FLEX_SUPPORTS_HEADER_OPT && test $bison_cv_cxx_works = yes])
|
||||
AC_PROG_YACC
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_GNU_M4
|
||||
@@ -332,6 +330,13 @@ AC_MSG_RESULT([$suppfile])
|
||||
# Whether we cannot run the compiled bison.
|
||||
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
||||
|
||||
# Build bistromathic if we have the lib and both readline/readline.h
|
||||
# and readline/history.h.
|
||||
AM_CONDITIONAL([ENABLE_BISTROMATHIC],
|
||||
[test "$gl_cv_lib_readline" != no &&
|
||||
test "$ac_cv_header_readline_readline_h" = yes &&
|
||||
test "$ac_cv_header_readline_history_h" = yes])
|
||||
|
||||
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||
# Needed by tests/atlocal.in.
|
||||
AC_SUBST([GCC])
|
||||
|
||||
@@ -72,8 +72,9 @@ version 2.2 of Bison.])
|
||||
# -------------
|
||||
# Issue a warning about private implementation details.
|
||||
m4_define([b4_disclaimer],
|
||||
[b4_comment([Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them.])
|
||||
[b4_comment([DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
||||
especially those whose name start with YY_ or yy_. They are
|
||||
private implementation details that can be changed or removed.])
|
||||
])
|
||||
|
||||
|
||||
@@ -369,6 +370,7 @@ m4_define([b4_$3_if],
|
||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||
b4_define_flag_if([has_translations]) # Whether some tokens are internationalized.
|
||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||
@@ -425,7 +427,7 @@ m4_define([b4_symbol_kind],
|
||||
m4_case([$1],
|
||||
[-2], [[YYEMPTY]],
|
||||
[0], [[YYEOF]],
|
||||
[1], [[YYERROR]],
|
||||
[1], [[YYerror]],
|
||||
[2], [[YYUNDEF]],
|
||||
[m4_case(b4_symbol([$1], [tag]),
|
||||
[$accept], [[YYACCEPT]],
|
||||
|
||||
+63
-28
@@ -259,14 +259,14 @@ m4_define([b4_public_types_declare],
|
||||
struct token
|
||||
{
|
||||
]b4_token_enums[
|
||||
/// Backward compatibility alias.
|
||||
/// Backward compatibility alias (Bison 3.6).
|
||||
typedef token_kind_type yytokentype;
|
||||
};
|
||||
|
||||
/// Token kind, as returned by yylex.
|
||||
typedef token::yytokentype token_kind_type;
|
||||
|
||||
/// Backward compatibility alias.
|
||||
/// Backward compatibility alias (Bison 3.6).
|
||||
typedef token_kind_type token_type;
|
||||
|
||||
/// Symbol kinds.
|
||||
@@ -352,12 +352,35 @@ m4_define([b4_symbol_type_define],
|
||||
break;
|
||||
}
|
||||
|
||||
// Type destructor.
|
||||
// Value type destructor.
|
||||
]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
/// Backward compatibility.
|
||||
]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;
|
||||
|
||||
/// Whether empty.
|
||||
@@ -380,45 +403,51 @@ m4_define([b4_symbol_type_define],
|
||||
};
|
||||
|
||||
/// Type access provider for token (enum) based symbols.
|
||||
struct by_type
|
||||
struct by_kind
|
||||
{
|
||||
/// Default constructor.
|
||||
by_type ();
|
||||
by_kind ();
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
by_type (by_type&& that);
|
||||
by_kind (by_kind&& that);
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
by_type (const by_type& that);
|
||||
by_kind (const by_kind& that);
|
||||
|
||||
/// The symbol kind as needed by the constructor.
|
||||
typedef token_kind_type kind_type;
|
||||
|
||||
/// Constructor from (external) token numbers.
|
||||
by_type (kind_type t);
|
||||
by_kind (kind_type t);
|
||||
|
||||
/// Record that this symbol is empty.
|
||||
void clear ();
|
||||
|
||||
/// Steal the symbol kind from \a that.
|
||||
void move (by_type& that);
|
||||
void move (by_kind& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a type).
|
||||
/// \a empty when empty.
|
||||
symbol_kind_type kind () const YY_NOEXCEPT;
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
||||
|
||||
/// The symbol kind.
|
||||
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||
symbol_kind_type type;
|
||||
symbol_kind_type kind_;
|
||||
};
|
||||
|
||||
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
||||
typedef by_kind by_type;
|
||||
|
||||
/// "External" symbols: returned by the scanner.
|
||||
struct symbol_type : basic_symbol<by_type>
|
||||
struct symbol_type : basic_symbol<by_kind>
|
||||
{]b4_variant_if([[
|
||||
/// Superclass.
|
||||
typedef basic_symbol<by_type> super_type;
|
||||
typedef basic_symbol<by_kind> super_type;
|
||||
|
||||
/// Empty symbol.
|
||||
symbol_type () {}
|
||||
@@ -492,44 +521,50 @@ m4_define([b4_public_types_define],
|
||||
location = YY_MOVE (s.location);])[
|
||||
}
|
||||
|
||||
// by_type.
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type ()
|
||||
: type (symbol_kind::]b4_symbol_prefix[YYEMPTY)
|
||||
// by_kind.
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
|
||||
: kind_ (symbol_kind::]b4_symbol_prefix[YYEMPTY)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (by_type&& that)
|
||||
: type (that.type)
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that)
|
||||
: kind_ (that.kind_)
|
||||
{
|
||||
that.clear ();
|
||||
}
|
||||
#endif
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (const by_type& that)
|
||||
: type (that.type)
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that)
|
||||
: kind_ (that.kind_)
|
||||
{}
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_kind_type t)
|
||||
: type (yytranslate_ (t))
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t)
|
||||
: kind_ (yytranslate_ (t))
|
||||
{}
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_type::clear ()
|
||||
]b4_parser_class[::by_kind::clear ()
|
||||
{
|
||||
type = symbol_kind::]b4_symbol_prefix[YYEMPTY;
|
||||
kind_ = symbol_kind::]b4_symbol_prefix[YYEMPTY;
|
||||
}
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_type::move (by_type& that)
|
||||
]b4_parser_class[::by_kind::move (by_kind& that)
|
||||
{
|
||||
type = that.type;
|
||||
kind_ = that.kind_;
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_type::kind () const YY_NOEXCEPT
|
||||
]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT
|
||||
{
|
||||
return type;
|
||||
return kind_;
|
||||
}
|
||||
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind ();
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
@@ -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])
|
||||
|
||||
|
||||
+60
-12
@@ -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
|
||||
@@ -439,7 +487,7 @@ m4_define([b4_symbol(-2, tag)], [[No symbol.]])
|
||||
|
||||
m4_if(b4_symbol(0, id), [YYEOF],
|
||||
[m4_define([b4_symbol(0, id)], [b4_api_PREFIX[][EOF]])])
|
||||
m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][ERRCODE]])
|
||||
m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][error]])
|
||||
m4_define([b4_symbol(2, id)], [b4_api_PREFIX[][UNDEF]])
|
||||
|
||||
|
||||
@@ -965,8 +1013,8 @@ m4_define([b4_yy_location_print_define],
|
||||
This macro was not mandated originally: define only if we know
|
||||
we won't break user code: when these are the locations we know. */
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||
# ifndef YY_LOCATION_PRINT
|
||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||
|
||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||
|
||||
@@ -996,17 +1044,17 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
||||
return res;
|
||||
}
|
||||
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
yy_location_print_ (File, &(Loc))
|
||||
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
#endif]],
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
# endif /* !defined YY_LOCATION_PRINT */]],
|
||||
[[/* This macro is provided for backward compatibility. */
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
#endif]])
|
||||
# ifndef YY_LOCATION_PRINT
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif]])
|
||||
])
|
||||
|
||||
# b4_yyloc_default
|
||||
|
||||
+85
-76
@@ -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
|
||||
@@ -261,6 +262,11 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
# define YY_(Msgid) Msgid
|
||||
# endif
|
||||
#endif
|
||||
]b4_has_translations_if([
|
||||
#ifndef N_
|
||||
# define N_(Msgid) Msgid
|
||||
#endif
|
||||
])[
|
||||
|
||||
#ifndef YYFREE
|
||||
# define YYFREE free
|
||||
@@ -272,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
|
||||
@@ -329,10 +332,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
#define YYMAXLEFT ]b4_max_left_semantic_context[
|
||||
|
||||
/* YYMAXUTOK -- Last valid token number (for yychar). */
|
||||
#define YYMAXUTOK ]b4_user_token_number_max[]b4_glr_cc_if([[
|
||||
/* YYFAULTYTOK -- Token number (for yychar) that denotes a
|
||||
syntax_error thrown from the scanner. */
|
||||
#define YYFAULTYTOK (YYMAXUTOK + 1)]])[
|
||||
#define YYMAXUTOK ]b4_user_token_number_max[
|
||||
|
||||
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, with out-of-bounds checking. */
|
||||
@@ -505,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
|
||||
@@ -525,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 {
|
||||
@@ -566,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;
|
||||
@@ -621,8 +621,8 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
static const char *const yy_sname[] =
|
||||
{
|
||||
]b4_symbol_names[
|
||||
};]m4_ifdef([b4_translatable], [[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YYTNAME[SYMBOL-NUM] is
|
||||
};]b4_has_translations_if([[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
||||
{
|
||||
@@ -664,12 +664,12 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
|
||||
]b4_yy_symbol_print_define[
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YY_FPRINTF ((stderr, "%s ", Title)); \
|
||||
yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \
|
||||
yy_symbol_print (stderr, Kind, Value]b4_locuser_args([Location])[); \
|
||||
YY_FPRINTF ((stderr, "\n")); \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -678,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;
|
||||
@@ -686,7 +686,7 @@ static void yypdumpstack (yyGLRStack* yystackp)
|
||||
#else /* !]b4_api_PREFIX[DEBUG */
|
||||
|
||||
# define YY_DPRINTF(Args) do {} while (yyfalse)
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
|
||||
|
||||
#endif /* !]b4_api_PREFIX[DEBUG */
|
||||
|
||||
@@ -694,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(
|
||||
@@ -729,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 (;;)
|
||||
@@ -825,7 +825,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
|
||||
// Map errors caught in the scanner to the undefined token,
|
||||
// so that error handling is started. However, record this
|
||||
// with this special value of yychar.
|
||||
*yycharp = YYFAULTYTOK;
|
||||
*yycharp = ]b4_symbol(1, id)[;
|
||||
}
|
||||
#endif // YY_EXCEPTIONS]], [[
|
||||
*yycharp = ]b4_lex[;]])[
|
||||
@@ -1030,8 +1030,14 @@ static inline int
|
||||
yygetLRActions (yy_state_t yystate, yysymbol_kind_t yytoken, const short** yyconflicts)
|
||||
{
|
||||
int yyindex = yypact[yystate] + yytoken;
|
||||
if (yyisDefaultedState (yystate)
|
||||
|| yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
|
||||
if (yytoken == ]b4_symbol(1, kind)[)
|
||||
{
|
||||
// This is the error token.
|
||||
*yyconflicts = yyconfl;
|
||||
return 0;
|
||||
}
|
||||
else if (yyisDefaultedState (yystate)
|
||||
|| yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
|
||||
{
|
||||
*yyconflicts = yyconfl;
|
||||
return -yydefact[yystate];
|
||||
@@ -1096,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 =
|
||||
@@ -1128,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)
|
||||
{
|
||||
@@ -1144,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;
|
||||
}
|
||||
|
||||
@@ -1157,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;
|
||||
@@ -1190,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;
|
||||
@@ -1200,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);
|
||||
@@ -1265,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];
|
||||
@@ -1289,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)
|
||||
{
|
||||
@@ -1322,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;
|
||||
@@ -1343,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);
|
||||
@@ -1374,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([
|
||||
@@ -1407,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);
|
||||
@@ -1459,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)
|
||||
{
|
||||
@@ -1484,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;
|
||||
@@ -1526,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)
|
||||
{
|
||||
@@ -1536,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;
|
||||
@@ -1546,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);
|
||||
@@ -1557,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);
|
||||
@@ -1988,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)
|
||||
{
|
||||
@@ -2029,10 +2035,10 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
|
||||
const int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
|
||||
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
||||
|
||||
while (*yyconflicts != 0)
|
||||
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,
|
||||
@@ -2048,7 +2054,6 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
|
||||
}
|
||||
else
|
||||
return yyflag;
|
||||
yyconflicts += 1;
|
||||
}
|
||||
|
||||
if (yyisShiftAction (yyaction))
|
||||
@@ -2103,7 +2108,7 @@ yypcontext_expected_tokens (const yyGLRStack* yystackp,
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
int yyx;
|
||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol_prefix[YYERROR
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
|
||||
&& !yytable_value_is_error (yytable[yyx + yyn]))
|
||||
{
|
||||
if (!yyarg)
|
||||
@@ -2114,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;
|
||||
}]])[
|
||||
|
||||
@@ -2221,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
|
||||
@@ -2252,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;
|
||||
@@ -2264,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)
|
||||
{
|
||||
@@ -2341,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;
|
||||
@@ -2361,8 +2368,8 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
int yyj = yypact[yys->yylrState];
|
||||
if (! yypact_value_is_default (yyj))
|
||||
{
|
||||
yyj += ]b4_symbol_prefix[YYERROR;
|
||||
if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == ]b4_symbol_prefix[YYERROR
|
||||
yyj += ]b4_symbol(1, kind)[;
|
||||
if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == ]b4_symbol(1, kind)[
|
||||
&& yyisShiftAction (yytable[yyj]))
|
||||
{
|
||||
/* Shift the error token. */
|
||||
@@ -2416,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"));
|
||||
|
||||
@@ -2445,7 +2452,7 @@ b4_dollar_popdef])[]dnl
|
||||
/* For efficiency, we have two loops, the first of which is
|
||||
specialized to deterministic operation (single stack, no
|
||||
potential ambiguity). */
|
||||
/* Standard mode */
|
||||
/* Standard mode. */
|
||||
while (yytrue)
|
||||
{
|
||||
yy_state_t yystate = yystack.yytops.yystates[0]->yylrState;
|
||||
@@ -2468,7 +2475,8 @@ b4_dollar_popdef])[]dnl
|
||||
yysymbol_kind_t yytoken = ]b4_yygetToken_call;[
|
||||
const short* yyconflicts;
|
||||
int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
|
||||
if (*yyconflicts != 0)
|
||||
if (*yyconflicts)
|
||||
/* Enter nondeterministic mode. */
|
||||
break;
|
||||
if (yyisShiftAction (yyaction))
|
||||
{
|
||||
@@ -2481,11 +2489,11 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
else if (yyisErrorAction (yyaction))
|
||||
{]b4_locations_if([[
|
||||
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[]b4_glr_cc_if([[
|
||||
/* Don't issue an error message again for exceptions
|
||||
thrown from the scanner. */
|
||||
if (yychar != YYFAULTYTOK)
|
||||
]])[ yyreportSyntaxError (&yystack]b4_user_args[);
|
||||
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
||||
/* Issue an error message unless the scanner already
|
||||
did. */
|
||||
if (yychar != ]b4_symbol(1, id)[)
|
||||
yyreportSyntaxError (&yystack]b4_user_args[);
|
||||
goto yyuser_error;
|
||||
}
|
||||
else
|
||||
@@ -2493,10 +2501,11 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
}
|
||||
|
||||
/* Nondeterministic mode. */
|
||||
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)[;
|
||||
@@ -2603,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])
|
||||
{
|
||||
@@ -2651,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]);
|
||||
}
|
||||
@@ -2696,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])));
|
||||
|
||||
+11
-9
@@ -167,7 +167,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[)
|
||||
const location_type* yylocationp]])[) const
|
||||
{]b4_locations_if([[
|
||||
YYUSE (yylocationp);]])[
|
||||
YYUSE (yyvaluep);
|
||||
@@ -181,7 +181,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[)
|
||||
const location_type* yylocationp]])[) const
|
||||
{
|
||||
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yytname[yykind] << " ("]b4_locations_if([[
|
||||
@@ -317,16 +317,16 @@ b4_percent_code_get([[requires]])[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[);
|
||||
const location_type* yylocationp]])[) const;
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[);
|
||||
const location_type* yylocationp]])[) const;
|
||||
private:
|
||||
// Debugging.
|
||||
/// Debug stream.
|
||||
std::ostream* yycdebug_;
|
||||
#endif
|
||||
|
||||
@@ -344,6 +344,8 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
#define ]b4_symbol(-2, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[
|
||||
#undef ]b4_symbol(0, [id])[
|
||||
#define ]b4_symbol(0, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[
|
||||
#undef ]b4_symbol(1, [id])[
|
||||
#define ]b4_symbol(1, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(1, [id])[
|
||||
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
||||
@@ -354,10 +356,10 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
|
||||
]m4_define([b4_declare_symbol_enum],
|
||||
[[typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
|
||||
#define ]b4_symbol_prefix[YYEMPTY ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
|
||||
#define ]b4_symbol_prefix[YYERROR ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYERROR
|
||||
#define ]b4_symbol_prefix[YYEOF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
|
||||
#define ]b4_symbol_prefix[YYUNDEF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
|
||||
#define ]b4_symbol_prefix[YYEMPTY ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
|
||||
#define ]b4_symbol_prefix[YYerror ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYerror
|
||||
#define ]b4_symbol_prefix[YYEOF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
|
||||
#define ]b4_symbol_prefix[YYUNDEF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
|
||||
]])[
|
||||
]b4_percent_code_get([[provides]])[
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
|
||||
@@ -137,9 +137,14 @@ m4_define([b4_integral_parser_table_define],
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_format([ /** Token number, to be returned by the scanner. */
|
||||
static final int %s = %s;
|
||||
], [$1])])
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_format([[ /** Token %s, to be returned by the scanner. */
|
||||
static final int %s = %s%s;
|
||||
]],
|
||||
b4_symbol([$1], [tag]),
|
||||
b4_symbol([$1], [id]),
|
||||
b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])))])])
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
@@ -344,7 +349,7 @@ m4_define([b4_symbol_translate],
|
||||
# ----------------
|
||||
# Translate a string if i18n is enabled. Avoid collision with b4_translate.
|
||||
m4_define([b4_trans],
|
||||
[m4_if(b4_has_translations, 0, [$1], [i18n($1)])])
|
||||
[b4_has_translations_if([i18n($1)], [$1])])
|
||||
|
||||
|
||||
|
||||
|
||||
+171
-117
@@ -204,6 +204,13 @@ m4_define([b4_shared_declarations],
|
||||
]b4_parser_class[ (]b4_parse_param_decl[);
|
||||
virtual ~]b4_parser_class[ ();
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
]b4_parser_class[ (const ]b4_parser_class[&) = delete;
|
||||
/// Non copyable.
|
||||
]b4_parser_class[& operator= (const ]b4_parser_class[&) = delete;
|
||||
#endif
|
||||
|
||||
/// Parse. An alias for parse ().
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
int operator() ();
|
||||
@@ -234,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
|
||||
@@ -255,10 +279,13 @@ m4_define([b4_shared_declarations],
|
||||
};
|
||||
]])[
|
||||
private:
|
||||
/// This class is not copyable.
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
]b4_parser_class[ (const ]b4_parser_class[&);
|
||||
]b4_parser_class[& operator= (const ]b4_parser_class[&);]b4_lac_if([[
|
||||
|
||||
/// Non copyable.
|
||||
]b4_parser_class[& operator= (const ]b4_parser_class[&);
|
||||
#endif
|
||||
]b4_lac_if([[
|
||||
/// Check the lookahead yytoken.
|
||||
/// \returns true iff the token will be eventually shifted.
|
||||
bool yy_lac_check_ (symbol_kind_type yytoken) const;
|
||||
@@ -305,35 +332,32 @@ m4_define([b4_shared_declarations],
|
||||
/// In theory \a t should be a token_kind_type, but character literals
|
||||
/// are valid, yet not members of the token_type enum.
|
||||
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);
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /// 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.
|
||||
static const char* const yytname_[];
|
||||
]])[
|
||||
|
||||
// Tables.
|
||||
]b4_parser_tables_declare[
|
||||
]b4_parse_error_case([verbose], [[
|
||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
static std::string yytnamerr_ (const char *n);
|
||||
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
]],
|
||||
[b4_token_table_if([], [[
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif
|
||||
]])])[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
]b4_integral_parser_table_declare([rline], [b4_rline],
|
||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
||||
virtual void yy_reduce_print_ (int r);
|
||||
virtual void yy_reduce_print_ (int r) const;
|
||||
/// Print the state stack on the debug stream.
|
||||
virtual void yystack_print_ ();
|
||||
virtual void yy_stack_print_ () const;
|
||||
|
||||
/// Debugging level.
|
||||
int yydebug_;
|
||||
@@ -455,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])[
|
||||
@@ -523,6 +548,11 @@ m4_if(b4_prefix, [yy], [],
|
||||
# define YY_(msgid) msgid
|
||||
# endif
|
||||
#endif
|
||||
]b4_has_translations_if([
|
||||
#ifndef N_
|
||||
# define N_(Msgid) Msgid
|
||||
#endif
|
||||
])[
|
||||
|
||||
// Whether we are compiled with exception support.
|
||||
#ifndef YY_EXCEPTIONS
|
||||
@@ -562,7 +592,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
# define YY_STACK_PRINT() \
|
||||
do { \
|
||||
if (yydebug_) \
|
||||
yystack_print_ (); \
|
||||
yy_stack_print_ (); \
|
||||
} while (false)
|
||||
|
||||
#else // !]b4_api_PREFIX[DEBUG
|
||||
@@ -582,71 +612,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
#define YYERROR goto yyerrorlab
|
||||
#define YYRECOVERING() (!!yyerrstatus_)
|
||||
|
||||
]b4_namespace_open[]b4_parse_error_bmatch([custom\|detailed], [[
|
||||
/* The user-facing name of the symbol whose (internal) number is
|
||||
YYSYMBOL. No bounds checking. */
|
||||
const char *
|
||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
static const char *const yy_sname[] =
|
||||
{
|
||||
]b4_symbol_names[
|
||||
};]m4_ifdef([b4_translatable], [[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YYTNAME[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];]])[
|
||||
}
|
||||
]])
|
||||
b4_parse_error_case([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;
|
||||
}
|
||||
]])[
|
||||
|
||||
]b4_namespace_open[
|
||||
/// Build a parser object.
|
||||
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
@@ -725,7 +691,7 @@ b4_parse_error_case([verbose], [[
|
||||
b4_symbol_variant([that.kind ()],
|
||||
[value], [move], [YY_MOVE (that.value)])])[
|
||||
// that is emptied.
|
||||
that.type = symbol_kind::]b4_symbol(-2, kind)[;
|
||||
that.kind_ = symbol_kind::]b4_symbol(-2, kind)[;
|
||||
}
|
||||
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
@@ -768,23 +734,21 @@ b4_parse_error_case([verbose], [[
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
template <typename Base>
|
||||
void
|
||||
]b4_parser_class[::yy_print_ (std::ostream& yyo,
|
||||
const basic_symbol<Base>& yysym) const
|
||||
]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
|
||||
{
|
||||
std::ostream& yyoutput = yyo;
|
||||
YYUSE (yyoutput);
|
||||
symbol_kind_type yykind = yysym.kind ();
|
||||
#if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ * 100 + __GNUC_MINOR__ <= 408
|
||||
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
|
||||
// below array bounds".
|
||||
if (yysym.empty ())
|
||||
std::abort ();
|
||||
#endif
|
||||
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yykind] << " ("]b4_locations_if([
|
||||
<< yysym.location << ": "])[;
|
||||
]b4_symbol_actions([printer])[
|
||||
yyo << ')';
|
||||
yyo << "empty symbol";
|
||||
else
|
||||
{
|
||||
symbol_kind_type yykind = yysym.kind ();
|
||||
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yysym.name () << " ("]b4_locations_if([
|
||||
<< yysym.location << ": "])[;
|
||||
]b4_symbol_actions([printer])[
|
||||
yyo << ')';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -943,7 +907,7 @@ b4_dollar_popdef])[]dnl
|
||||
{]b4_token_ctor_if([[
|
||||
symbol_type yylookahead (]b4_lex[);
|
||||
yyla.move (yylookahead);]], [[
|
||||
yyla.type = yytranslate_ (]b4_lex[);]])[
|
||||
yyla.kind_ = yytranslate_ (]b4_lex[);]])[
|
||||
}
|
||||
#if YY_EXCEPTIONS
|
||||
catch (const syntax_error& yyexc)
|
||||
@@ -956,6 +920,16 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
YY_SYMBOL_PRINT ("Next token is", yyla);
|
||||
|
||||
if (yyla.kind () == ]symbol_kind::b4_symbol(1, kind)[)
|
||||
{
|
||||
// The scanner already issued an error message, process directly
|
||||
// to error recovery. But do not keep the error token as
|
||||
// lookahead, it is too special and may lead us to an endless
|
||||
// loop in error recovery. */
|
||||
yyla.kind_ = ]symbol_kind::b4_symbol(2, kind)[;
|
||||
goto yyerrlab1;
|
||||
}
|
||||
|
||||
/* If the proper action on seeing token YYLA.TYPE is to reduce or
|
||||
to detect an error, take that action. */
|
||||
yyn += yyla.kind ();
|
||||
@@ -1130,9 +1104,9 @@ b4_dollar_popdef])[]dnl
|
||||
yyn = yypact_[+yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += symbol_kind::]b4_symbol_prefix[YYERROR;
|
||||
yyn += symbol_kind::]b4_symbol(1, kind)[;
|
||||
if (0 <= yyn && yyn <= yylast_
|
||||
&& yycheck_[yyn] == symbol_kind::]b4_symbol_prefix[YYERROR)
|
||||
&& yycheck_[yyn] == symbol_kind::]b4_symbol(1, kind)[)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -1222,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)
|
||||
@@ -1246,7 +1298,7 @@ b4_dollar_popdef])[]dnl
|
||||
for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
|
||||
{
|
||||
symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
|
||||
if (yysym != symbol_kind::]b4_symbol_prefix[YYERROR
|
||||
if (yysym != symbol_kind::]b4_symbol(1, kind)[
|
||||
&& yysym != symbol_kind::]b4_symbol_prefix[YYUNDEF
|
||||
&& yyparser_.yy_lac_check_ (yysym))
|
||||
{
|
||||
@@ -1269,7 +1321,7 @@ b4_dollar_popdef])[]dnl
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::]b4_symbol_prefix[YYERROR
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::]b4_symbol(1, kind)[
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (!yyarg)
|
||||
@@ -1281,6 +1333,8 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
}
|
||||
]])[
|
||||
if (yyarg && yycount == 0 && 0 < yyargn)
|
||||
yyarg[0] = symbol_kind::]b4_symbol(-2, kind)[;
|
||||
return yycount;
|
||||
}
|
||||
|
||||
@@ -1293,7 +1347,7 @@ b4_dollar_popdef])[]dnl
|
||||
yylac_stack_.clear ();
|
||||
// Reduce until we encounter a shift and thereby accept the token.
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
YYCDEBUG << "LAC: checking lookahead " << yytname_[yytoken] << ':';
|
||||
YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':';
|
||||
#endif
|
||||
std::ptrdiff_t lac_top = 0;
|
||||
while (true)
|
||||
@@ -1393,7 +1447,7 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
YYCDEBUG << "LAC: initial context established for "
|
||||
<< yytname_[yytoken] << '\n';
|
||||
<< symbol_name (yytoken) << '\n';
|
||||
#endif
|
||||
yy_lac_established_ = true;
|
||||
return yy_lac_check_ (yytoken);
|
||||
@@ -1502,9 +1556,7 @@ b4_dollar_popdef])[]dnl
|
||||
for (char const* yyp = yyformat; *yyp; ++yyp)
|
||||
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
||||
{
|
||||
yyres += ]b4_parse_error_case([verbose],
|
||||
[[yytnamerr_ (yytname_[yyarg[yyi++]])]],
|
||||
[[symbol_name (yyarg[yyi++])]])[;
|
||||
yyres += symbol_name (yyarg[yyi++]);
|
||||
++yyp;
|
||||
}
|
||||
else
|
||||
@@ -1519,7 +1571,8 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
]b4_tname_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||
]b4_parse_error_bmatch([simple\|verbose],
|
||||
[[#if ]b4_api_PREFIX[DEBUG]b4_tname_if([[ || 1]])[
|
||||
// YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
// First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
|
||||
const char*
|
||||
@@ -1527,13 +1580,14 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
]b4_tname[
|
||||
};
|
||||
]b4_tname_if([], [[#endif]])[
|
||||
#endif
|
||||
]])[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG][
|
||||
]b4_integral_parser_table_define([rline], [b4_rline])[
|
||||
|
||||
void
|
||||
]b4_parser_class[::yystack_print_ ()
|
||||
]b4_parser_class[::yy_stack_print_ () const
|
||||
{
|
||||
*yycdebug_ << "Stack now";
|
||||
for (stack_type::const_iterator
|
||||
@@ -1545,7 +1599,7 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_reduce_print_ (int yyrule)
|
||||
]b4_parser_class[::yy_reduce_print_ (int yyrule) const
|
||||
{
|
||||
int yylno = yyrline_[yyrule];
|
||||
int yynrhs = yyr2_[yyrule];
|
||||
|
||||
+47
-33
@@ -21,7 +21,7 @@ m4_include(b4_skeletonsdir/[d.m4])
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
|
||||
[2007-2012, 2019-2020])[
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
||||
])[
|
||||
version(D_Version2) {
|
||||
@@ -509,39 +509,53 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Next token is", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
detect an error, take that action. */
|
||||
yyn += yytoken;
|
||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
||||
label = YYDEFAULT;
|
||||
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
if (yytoken == SymbolKind.]b4_symbol(1, kind)[)
|
||||
{
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
label = YYERRLAB;
|
||||
else
|
||||
{
|
||||
yyn = -yyn;
|
||||
label = YYREDUCE;
|
||||
}
|
||||
// The scanner already issued an error message, process directly
|
||||
// to error recovery. But do not keep the error token as
|
||||
// lookahead, it is too special and may lead us to an endless
|
||||
// loop in error recovery. */
|
||||
yychar = TokenKind.YYUNDEF;
|
||||
yytoken = SymbolKind.]b4_symbol_prefix[YYUNDEF;]b4_locations_if([[
|
||||
yyerrloc = yylloc;]])[
|
||||
label = YYERRLAB1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
detect an error, take that action. */
|
||||
yyn += yytoken;
|
||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
||||
label = YYDEFAULT;
|
||||
|
||||
/* Discard the token being shifted. */
|
||||
yychar = TokenKind.YYEMPTY;
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
{
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
label = YYERRLAB;
|
||||
else
|
||||
{
|
||||
yyn = -yyn;
|
||||
label = YYREDUCE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
* status. */
|
||||
if (yyerrstatus_ > 0)
|
||||
--yyerrstatus_;
|
||||
/* Discard the token being shifted. */
|
||||
yychar = TokenKind.YYEMPTY;
|
||||
|
||||
yystate = yyn;
|
||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||
label = YYNEWSTATE;
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
* status. */
|
||||
if (yyerrstatus_ > 0)
|
||||
--yyerrstatus_;
|
||||
|
||||
yystate = yyn;
|
||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||
label = YYNEWSTATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -577,8 +591,8 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yytoken = SymbolKind.]b4_symbol(-2, kind)[;
|
||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||
}
|
||||
|
||||
]b4_locations_if([ yyerrloc = yylloc;])[
|
||||
]b4_locations_if([
|
||||
yyerrloc = yylloc;])[
|
||||
if (yyerrstatus_ == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
@@ -624,8 +638,8 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += SymbolKind.]b4_symbol_prefix[YYERROR;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == SymbolKind.]b4_symbol_prefix[YYERROR)
|
||||
yyn += SymbolKind.]b4_symbol(1, kind)[;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == SymbolKind.]b4_symbol(1, kind)[)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -731,14 +745,14 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol_prefix[YYERROR
|
||||
if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol(1, kind)[
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol_prefix[YYERROR
|
||||
if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol(1, kind)[
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||
|
||||
+144
-134
@@ -78,6 +78,7 @@ m4_define([b4_define_state],[[
|
||||
]b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2015, 2018-2020])[
|
||||
]b4_disclaimer[
|
||||
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
||||
]])[
|
||||
]b4_user_pre_prologue[
|
||||
@@ -120,7 +121,7 @@ import java.text.MessageFormat;
|
||||
* Locations represent a part of the input through the beginning
|
||||
* and ending positions.
|
||||
*/
|
||||
public class ]b4_location_type[ {
|
||||
public static class ]b4_location_type[ {
|
||||
/**
|
||||
* The first, inclusive, position in the range.
|
||||
*/
|
||||
@@ -163,12 +164,12 @@ import java.text.MessageFormat;
|
||||
}
|
||||
}
|
||||
|
||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
||||
private ]b4_location_type[ yylloc(YYStack rhs, int n)
|
||||
{
|
||||
if (0 < n)
|
||||
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
||||
return new ]b4_location_type[(rhs.locationAt(n-1).begin, rhs.locationAt(0).end);
|
||||
else
|
||||
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
||||
return new ]b4_location_type[(rhs.locationAt(0).end);
|
||||
}]])[
|
||||
|
||||
]b4_declare_symbol_enum[
|
||||
@@ -179,27 +180,26 @@ import java.text.MessageFormat;
|
||||
*/
|
||||
public interface Lexer {
|
||||
]b4_token_enums[
|
||||
/** Deprecated, use b4_symbol(0, id) instead. */
|
||||
/** Deprecated, use ]b4_symbol(0, id)[ instead. */
|
||||
public static final int EOF = ]b4_symbol(0, id)[;
|
||||
|
||||
]b4_locations_if([[
|
||||
]b4_pull_if([b4_locations_if([[
|
||||
/**
|
||||
* Method to retrieve the beginning position of the last scanned token.
|
||||
* @@return the position at which the last scanned token starts.
|
||||
*/
|
||||
]b4_position_type[ getStartPos ();
|
||||
]b4_position_type[ getStartPos();
|
||||
|
||||
/**
|
||||
* Method to retrieve the ending position of the last scanned token.
|
||||
* @@return the first position beyond the last scanned token.
|
||||
*/
|
||||
]b4_position_type[ getEndPos ();]])[
|
||||
]b4_position_type[ getEndPos();]])[
|
||||
|
||||
/**
|
||||
* Method to retrieve the semantic value of the last scanned token.
|
||||
* @@return the semantic value of the last scanned token.
|
||||
*/
|
||||
]b4_yystype[ getLVal ();
|
||||
]b4_yystype[ getLVal();
|
||||
|
||||
/**
|
||||
* Entry point for the scanner. Returns the token identifier corresponding
|
||||
@@ -207,24 +207,25 @@ import java.text.MessageFormat;
|
||||
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
||||
* @@return the token identifier corresponding to the next token.
|
||||
*/
|
||||
int yylex ()]b4_maybe_throws([b4_lex_throws])[;
|
||||
|
||||
int yylex()]b4_maybe_throws([b4_lex_throws])[;
|
||||
]])[
|
||||
/**
|
||||
* Entry point for error reporting. Emits an error
|
||||
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
|
||||
* Emit an error]b4_locations_if([ referring to the given location])[in a user-defined way.
|
||||
*
|
||||
*]b4_locations_if([[ @@param loc The location of the element to which the
|
||||
* error message is related]])[
|
||||
* error message is related.]])[
|
||||
* @@param msg The string for the error message.
|
||||
*/
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);
|
||||
void yyerror(]b4_locations_if([b4_location_type[ loc, ]])[String msg);
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom], [[
|
||||
/**
|
||||
* Build and emit a syntax error message.
|
||||
* Build and emit a "syntax error" message in a user-defined way.
|
||||
*
|
||||
* @@param ctx The context of the error.
|
||||
*/
|
||||
void reportSyntaxError (][Context yyctx);
|
||||
void reportSyntaxError (][Context ctx);
|
||||
]])[
|
||||
}
|
||||
|
||||
@@ -306,9 +307,8 @@ import java.text.MessageFormat;
|
||||
*]b4_locations_if([[ Use a <code>null</code> location.]])[
|
||||
* @@param msg The error message.
|
||||
*/
|
||||
public final void yyerror (String msg)
|
||||
{
|
||||
yylexer.yyerror (]b4_locations_if([[(]b4_location_type[)null, ]])[msg);
|
||||
public final void yyerror(String msg) {
|
||||
yylexer.yyerror(]b4_locations_if([[(]b4_location_type[)null, ]])[msg);
|
||||
}
|
||||
]b4_locations_if([[
|
||||
/**
|
||||
@@ -316,9 +316,8 @@ import java.text.MessageFormat;
|
||||
* @@param loc The location associated with the message.
|
||||
* @@param msg The error message.
|
||||
*/
|
||||
public final void yyerror (]b4_location_type[ loc, String msg)
|
||||
{
|
||||
yylexer.yyerror (loc, msg);
|
||||
public final void yyerror(]b4_location_type[ loc, String msg) {
|
||||
yylexer.yyerror(loc, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,9 +325,8 @@ import java.text.MessageFormat;
|
||||
* @@param pos The position associated with the message.
|
||||
* @@param msg The error message.
|
||||
*/
|
||||
public final void yyerror (]b4_position_type[ pos, String msg)
|
||||
{
|
||||
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
|
||||
public final void yyerror(]b4_position_type[ pos, String msg) {
|
||||
yylexer.yyerror(new ]b4_location_type[ (pos), msg);
|
||||
}]])[
|
||||
]b4_parse_trace_if([[
|
||||
protected final void yycdebug (String s) {
|
||||
@@ -468,7 +466,7 @@ import java.text.MessageFormat;
|
||||
return yydefgoto_[yysym - YYNTOKENS_];
|
||||
}
|
||||
|
||||
private int yyaction (int yyn, YYStack yystack, int yylen)]b4_maybe_throws([b4_throws])[
|
||||
private int yyaction(int yyn, YYStack yystack, int yylen)]b4_maybe_throws([b4_throws])[
|
||||
{
|
||||
/* If YYLEN is nonzero, implement the default value of the action:
|
||||
'$$ = $1'. Otherwise, use the top of the stack.
|
||||
@@ -476,10 +474,10 @@ import java.text.MessageFormat;
|
||||
Otherwise, the following line sets YYVAL to garbage.
|
||||
This behavior is undocumented and Bison
|
||||
users should not rely upon it. */
|
||||
]b4_yystype[ yyval = (0 < yylen) ? yystack.valueAt (yylen - 1) : yystack.valueAt (0);]b4_locations_if([[
|
||||
]b4_location_type[ yyloc = yylloc (yystack, yylen);]])[]b4_parse_trace_if([[
|
||||
]b4_yystype[ yyval = (0 < yylen) ? yystack.valueAt(yylen - 1) : yystack.valueAt(0);]b4_locations_if([[
|
||||
]b4_location_type[ yyloc = yylloc(yystack, yylen);]])[]b4_parse_trace_if([[
|
||||
|
||||
yyReducePrint (yyn, yystack);]])[
|
||||
yyReducePrint(yyn, yystack);]])[
|
||||
|
||||
switch (yyn)
|
||||
{
|
||||
@@ -487,13 +485,13 @@ import java.text.MessageFormat;
|
||||
default: break;
|
||||
}]b4_parse_trace_if([[
|
||||
|
||||
yySymbolPrint ("-> $$ =", SymbolKind.get (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
yySymbolPrint("-> $$ =", SymbolKind.get(yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystack.pop (yylen);
|
||||
yystack.pop(yylen);
|
||||
yylen = 0;
|
||||
/* Shift the result of the reduction. */
|
||||
int yystate = yyLRGotoState (yystack.stateAt (0), yyr1_[yyn]);
|
||||
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
|
||||
int yystate = yyLRGotoState(yystack.stateAt(0), yyr1_[yyn]);
|
||||
yystack.push(yystate, yyval]b4_locations_if([, yyloc])[);
|
||||
return YYNEWSTATE;
|
||||
}
|
||||
|
||||
@@ -503,13 +501,14 @@ import java.text.MessageFormat;
|
||||
`--------------------------------*/
|
||||
|
||||
private void yySymbolPrint(String s, SymbolKind yykind,
|
||||
]b4_yystype[ yyvalue]b4_locations_if([, ]b4_location_type[ yylocation])[)
|
||||
{
|
||||
yycdebug (s
|
||||
+ (yykind.getCode() < YYNTOKENS_ ? " token " : " nterm ")
|
||||
+ yykind.getName() + " ("]b4_locations_if([
|
||||
+ yylocation + ": "])[
|
||||
+ (yyvalue == null ? "(null)" : yyvalue.toString()) + ")");
|
||||
]b4_yystype[ yyvalue]b4_locations_if([, ]b4_location_type[ yylocation])[) {
|
||||
if (0 < yydebug) {
|
||||
yycdebug(s
|
||||
+ (yykind.getCode() < YYNTOKENS_ ? " token " : " nterm ")
|
||||
+ yykind.getName() + " ("]b4_locations_if([
|
||||
+ yylocation + ": "])[
|
||||
+ (yyvalue == null ? "(null)" : yyvalue.toString()) + ")");
|
||||
}
|
||||
}]])[
|
||||
|
||||
]b4_push_if([],[[
|
||||
@@ -520,7 +519,7 @@ import java.text.MessageFormat;
|
||||
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||
* imply that there were no syntax errors.
|
||||
*/
|
||||
public boolean parse ()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[]])[
|
||||
public boolean parse()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[]])[
|
||||
]b4_push_if([
|
||||
/**
|
||||
* Push Parse input from external lexer
|
||||
@@ -531,7 +530,7 @@ import java.text.MessageFormat;
|
||||
*
|
||||
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
||||
*/
|
||||
public int push_parse (int yylextoken, b4_yystype yylexval[]b4_locations_if([, b4_location_type yylexloc]))b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])])[
|
||||
public int push_parse(int yylextoken, b4_yystype yylexval[]b4_locations_if([, b4_location_type yylexloc]))b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])])[
|
||||
{]b4_locations_if([[
|
||||
/* @@$. */
|
||||
]b4_location_type[ yyloc;]])[
|
||||
@@ -611,44 +610,58 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* Convert token to internal form. */
|
||||
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Next token is", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);]])[
|
||||
yySymbolPrint("Next token is", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
detect an error, take that action. */
|
||||
yyn += yytoken.getCode ();
|
||||
if (yyn < 0 || YYLAST_ < yyn || yycheck_[yyn] != yytoken.getCode ())
|
||||
label = YYDEFAULT;
|
||||
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
if (yytoken == SymbolKind.]b4_symbol_prefix[YYerror)
|
||||
{
|
||||
if (yyTableValueIsError (yyn))
|
||||
label = YYERRLAB;
|
||||
else
|
||||
{
|
||||
yyn = -yyn;
|
||||
label = YYREDUCE;
|
||||
}
|
||||
// The scanner already issued an error message, process directly
|
||||
// to error recovery. But do not keep the error token as
|
||||
// lookahead, it is too special and may lead us to an endless
|
||||
// loop in error recovery. */
|
||||
yychar = Lexer.]b4_percent_define_get([api.token.prefix])[YYUNDEF;
|
||||
yytoken = SymbolKind.]b4_symbol_prefix[YYUNDEF;]b4_locations_if([[
|
||||
yyerrloc = yylloc;]])[
|
||||
label = YYERRLAB1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
detect an error, take that action. */
|
||||
yyn += yytoken.getCode ();
|
||||
if (yyn < 0 || YYLAST_ < yyn || yycheck_[yyn] != yytoken.getCode ())
|
||||
label = YYDEFAULT;
|
||||
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
{
|
||||
if (yyTableValueIsError (yyn))
|
||||
label = YYERRLAB;
|
||||
else
|
||||
{
|
||||
yyn = -yyn;
|
||||
label = YYREDUCE;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
]])[
|
||||
/* Discard the token being shifted. */
|
||||
yychar = YYEMPTY_;
|
||||
/* Discard the token being shifted. */
|
||||
yychar = YYEMPTY_;
|
||||
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
status. */
|
||||
if (yyerrstatus_ > 0)
|
||||
--yyerrstatus_;
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
status. */
|
||||
if (yyerrstatus_ > 0)
|
||||
--yyerrstatus_;
|
||||
|
||||
yystate = yyn;
|
||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||
label = YYNEWSTATE;
|
||||
yystate = yyn;
|
||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||
label = YYNEWSTATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -668,7 +681,7 @@ b4_dollar_popdef[]dnl
|
||||
`-----------------------------*/
|
||||
case YYREDUCE:
|
||||
yylen = yyr2_[yyn];
|
||||
label = yyaction (yyn, yystack, yylen);
|
||||
label = yyaction(yyn, yystack, yylen);
|
||||
yystate = yystack.stateAt (0);
|
||||
break;
|
||||
|
||||
@@ -684,7 +697,6 @@ b4_dollar_popdef[]dnl
|
||||
yytoken = null;
|
||||
yyreportSyntaxError (new Context (yystack, yytoken]b4_locations_if([[, yylloc]])[));
|
||||
}
|
||||
|
||||
]b4_locations_if([[
|
||||
yyerrloc = yylloc;]])[
|
||||
if (yyerrstatus_ == 3)
|
||||
@@ -732,9 +744,9 @@ b4_dollar_popdef[]dnl
|
||||
yyn = yypact_[yystate];
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
yyn += SymbolKind.]b4_symbol_prefix[YYERROR.getCode ();
|
||||
yyn += SymbolKind.]b4_symbol(1, kind)[.getCode ();
|
||||
if (0 <= yyn && yyn <= YYLAST_
|
||||
&& yycheck_[yyn] == SymbolKind.]b4_symbol_prefix[YYERROR.getCode ())
|
||||
&& yycheck_[yyn] == SymbolKind.]b4_symbol(1, kind)[.getCode ())
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -767,8 +779,8 @@ b4_dollar_popdef[]dnl
|
||||
yystack.pop (2);]])[
|
||||
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Shifting", SymbolKind.get (yystos_[yyn]),
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
yySymbolPrint("Shifting", SymbolKind.get (yystos_[yyn]),
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystate = yyn;
|
||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||
@@ -819,7 +831,7 @@ b4_dollar_popdef[]dnl
|
||||
this.push_parse_initialized = true;
|
||||
|
||||
}
|
||||
]b4_locations_if([
|
||||
]b4_locations_if([[
|
||||
/**
|
||||
* Push parse given input from an external lexer.
|
||||
*
|
||||
@@ -829,36 +841,32 @@ b4_dollar_popdef[]dnl
|
||||
*
|
||||
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
||||
*/
|
||||
public int push_parse (int yylextoken, b4_yystype yylexval, b4_position_type yylexpos)b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])
|
||||
{
|
||||
return push_parse (yylextoken, yylexval, new b4_location_type (yylexpos));
|
||||
public int push_parse(int yylextoken, ]b4_yystype[ yylexval, ]b4_position_type[ yylexpos)]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[ {
|
||||
return push_parse(yylextoken, yylexval, new ]b4_location_type[(yylexpos));
|
||||
}
|
||||
])[]])[
|
||||
]])])[
|
||||
|
||||
]b4_both_if([[
|
||||
/**
|
||||
* Parse input from the scanner that was specified at object construction
|
||||
* time. Return whether the end of the input was reached successfully.
|
||||
* This version of parse () is defined only when api.push-push=both.
|
||||
* This version of parse() is defined only when api.push-push=both.
|
||||
*
|
||||
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||
* imply that there were no syntax errors.
|
||||
*/
|
||||
public boolean parse ()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[
|
||||
{
|
||||
if (yylexer == null)
|
||||
throw new NullPointerException("Null Lexer");
|
||||
int status;
|
||||
do {
|
||||
int token = yylexer.yylex();
|
||||
]b4_yystype[ lval = yylexer.getLVal();
|
||||
]b4_locations_if([dnl
|
||||
b4_location_type yyloc = new b4_location_type (yylexer.getStartPos (),
|
||||
yylexer.getEndPos ());])[]b4_locations_if([[
|
||||
status = push_parse(token,lval,yyloc);]], [[
|
||||
status = push_parse(token,lval);]])[
|
||||
} while (status == YYPUSH_MORE);
|
||||
return (status == YYACCEPT);
|
||||
public boolean parse()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[ {
|
||||
if (yylexer == null)
|
||||
throw new NullPointerException("Null Lexer");
|
||||
int status;
|
||||
do {
|
||||
int token = yylexer.yylex();
|
||||
]b4_yystype[ lval = yylexer.getLVal();]b4_locations_if([[
|
||||
]b4_location_type[ yyloc = new ]b4_location_type[(yylexer.getStartPos(), yylexer.getEndPos());
|
||||
status = push_parse(token, lval, yyloc);]], [[
|
||||
status = push_parse(token, lval);]])[
|
||||
} while (status == YYPUSH_MORE);
|
||||
return status == YYACCEPT;
|
||||
}
|
||||
]])[
|
||||
|
||||
@@ -925,7 +933,7 @@ b4_dollar_popdef[]dnl
|
||||
int yychecklim = YYLAST_ - yyn + 1;
|
||||
int yyxend = yychecklim < NTOKENS ? yychecklim : NTOKENS;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != SymbolKind.]b4_symbol_prefix[YYERROR.getCode ()
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != SymbolKind.]b4_symbol(1, kind)[.getCode ()
|
||||
&& !yyTableValueIsError (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (yyarg == null)
|
||||
@@ -936,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;
|
||||
}
|
||||
}
|
||||
@@ -982,39 +992,39 @@ b4_dollar_popdef[]dnl
|
||||
}
|
||||
]])[
|
||||
|
||||
/**
|
||||
* Report a syntax error.
|
||||
/**
|
||||
* Build and emit a "syntax error" message in a user-defined way.
|
||||
*
|
||||
* @@param ctx The context of the error.
|
||||
*/
|
||||
private void yyreportSyntaxError (Context yyctx)
|
||||
{]b4_parse_error_bmatch(
|
||||
private void yyreportSyntaxError(Context yyctx) {]b4_parse_error_bmatch(
|
||||
[custom], [[
|
||||
yylexer.reportSyntaxError (yyctx);]],
|
||||
yylexer.reportSyntaxError(yyctx);]],
|
||||
[detailed\|verbose], [[
|
||||
if (yyErrorVerbose)
|
||||
{
|
||||
final int argmax = 5;
|
||||
SymbolKind[] yyarg = new SymbolKind[argmax];
|
||||
int yycount = yysyntaxErrorArguments (yyctx, yyarg, argmax);
|
||||
String[] yystr = new String[yycount];
|
||||
for (int yyi = 0; yyi < yycount; ++yyi)
|
||||
yystr[yyi] = yyarg[yyi].getName();
|
||||
String yyformat;
|
||||
switch (yycount)
|
||||
{
|
||||
default:
|
||||
case 0: yyformat = ]b4_trans(["syntax error"])[; break;
|
||||
case 1: yyformat = ]b4_trans(["syntax error, unexpected {0}"])[; break;
|
||||
case 2: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1}"])[; break;
|
||||
case 3: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2}"])[; break;
|
||||
case 4: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3}"])[; break;
|
||||
case 5: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3} or {4}"])[; break;
|
||||
if (yyErrorVerbose) {
|
||||
final int argmax = 5;
|
||||
SymbolKind[] yyarg = new SymbolKind[argmax];
|
||||
int yycount = yysyntaxErrorArguments(yyctx, yyarg, argmax);
|
||||
String[] yystr = new String[yycount];
|
||||
for (int yyi = 0; yyi < yycount; ++yyi) {
|
||||
yystr[yyi] = yyarg[yyi].getName();
|
||||
}
|
||||
yyerror (]b4_locations_if([[yyctx.yylocation, ]])[new MessageFormat (yyformat).format (yystr));
|
||||
return;
|
||||
}
|
||||
yyerror (]b4_locations_if([[yyctx.yylocation, ]])["syntax error");]],
|
||||
String yyformat;
|
||||
switch (yycount) {
|
||||
default:
|
||||
case 0: yyformat = ]b4_trans(["syntax error"])[; break;
|
||||
case 1: yyformat = ]b4_trans(["syntax error, unexpected {0}"])[; break;
|
||||
case 2: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1}"])[; break;
|
||||
case 3: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2}"])[; break;
|
||||
case 4: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3}"])[; break;
|
||||
case 5: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3} or {4}"])[; break;
|
||||
}
|
||||
yyerror(]b4_locations_if([[yyctx.yylocation, ]])[new MessageFormat(yyformat).format(yystr));
|
||||
} else {
|
||||
yyerror(]b4_locations_if([[yyctx.yylocation, ]])[]b4_trans(["syntax error"])[);
|
||||
}]],
|
||||
[simple], [[
|
||||
yyerror (]b4_locations_if([[yyctx.yylocation, ]])["syntax error");]])[
|
||||
yyerror(]b4_locations_if([[yyctx.yylocation, ]])[]b4_trans(["syntax error"])[);]])[
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1060,10 +1070,10 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* The symbols being reduced. */
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yySymbolPrint (" $" + (yyi + 1) + " =",
|
||||
SymbolKind.get (yystos_[yystack.stateAt (yynrhs - (yyi + 1))]),
|
||||
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
yySymbolPrint(" $" + (yyi + 1) + " =",
|
||||
SymbolKind.get (yystos_[yystack.stateAt (yynrhs - (yyi + 1))]),
|
||||
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}]])[
|
||||
|
||||
/* YYTRANSLATE_(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||
|
||||
@@ -41,6 +41,13 @@ m4_define([b4_stack_define],
|
||||
: seq_ (n)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
stack (const stack&) = delete;
|
||||
/// Non copyable.
|
||||
stack& operator= (const stack&) = delete;
|
||||
#endif
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
@@ -126,8 +133,12 @@ m4_define([b4_stack_define],
|
||||
};
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
stack (const stack&);
|
||||
/// Non copyable.
|
||||
stack& operator= (const stack&);
|
||||
#endif
|
||||
/// The wrapped container.
|
||||
S seq_;
|
||||
};
|
||||
|
||||
@@ -115,6 +115,13 @@ m4_define([b4_value_type_declare],
|
||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||
}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
semantic_type (const self_type&) = delete;
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&) = delete;
|
||||
#endif
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
~semantic_type () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
@@ -258,9 +265,12 @@ m4_define([b4_value_type_declare],
|
||||
}
|
||||
|
||||
private:
|
||||
/// Prohibit blind copies.
|
||||
self_type& operator= (const self_type&);
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
semantic_type (const self_type&);
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&);
|
||||
#endif
|
||||
|
||||
/// Accessor to raw memory as \a T.
|
||||
template <typename T>
|
||||
|
||||
+49
-70
@@ -132,6 +132,7 @@ m4_define([b4_rhs_value],
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
@@ -140,6 +141,7 @@ m4_define([b4_lhs_location],
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
|
||||
m4_define([b4_rhs_location],
|
||||
[(yylsp@{b4_subtract([$2], [$1])@})])
|
||||
|
||||
@@ -358,6 +360,7 @@ b4_output_begin([b4_parser_file_name])[
|
||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||
simplifying the original so-called "semantic" parser. */
|
||||
|
||||
]b4_disclaimer[
|
||||
/* All symbols defined below should begin with yy or YY, to avoid
|
||||
infringing on user name space. This should be done even for local
|
||||
variables, as they might otherwise be expanded by user macros.
|
||||
@@ -365,7 +368,6 @@ b4_output_begin([b4_parser_file_name])[
|
||||
define necessary library symbols; they are noted "INFRINGES ON
|
||||
USER NAME SPACE" below. */
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_identification[
|
||||
]b4_percent_code_get([[top]])[]dnl
|
||||
m4_if(b4_api_prefix, [yy], [],
|
||||
@@ -401,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;
|
||||
@@ -463,6 +425,11 @@ typedef int yy_state_fast_t;
|
||||
# define YY_(Msgid) Msgid
|
||||
# endif
|
||||
#endif
|
||||
]b4_has_translations_if([
|
||||
#ifndef N_
|
||||
# define N_(Msgid) Msgid
|
||||
#endif
|
||||
])[
|
||||
|
||||
]b4_attribute_define[
|
||||
|
||||
@@ -542,7 +509,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# endif]b4_lac_if([[
|
||||
# define YYCOPY_NEEDED 1]])[
|
||||
#endif]b4_lac_if([], [b4_parse_error_case([simple], [[/* !defined yyoverflow */]])])[
|
||||
#endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */
|
||||
|
||||
#if (! defined yyoverflow \
|
||||
&& (! defined __cplusplus \
|
||||
@@ -676,8 +643,8 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
static const char *const yy_sname[] =
|
||||
{
|
||||
]b4_symbol_names[
|
||||
};]m4_ifdef([b4_translatable], [[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YYTNAME[SYMBOL-NUM] is
|
||||
};]b4_has_translations_if([[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
||||
{
|
||||
@@ -690,14 +657,14 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
}]])[
|
||||
#endif
|
||||
|
||||
# ifdef YYPRINT
|
||||
#ifdef YYPRINT
|
||||
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
||||
(internal) symbol number NUM (which must be that of a token). */
|
||||
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
||||
{
|
||||
]b4_toknum[
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYPACT_NINF (]b4_pact_ninf[)
|
||||
|
||||
@@ -741,6 +708,9 @@ enum { YYENOMEM = -2 };
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Backward compatibility with an undocumented macro.
|
||||
Use ]b4_symbol(1, id)[ or ]b4_symbol(2, id)[. */
|
||||
#define YYERRCODE ]b4_symbol(2, id)[
|
||||
]b4_locations_if([[
|
||||
]b4_yylloc_default_define[
|
||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||
@@ -762,13 +732,13 @@ do { \
|
||||
|
||||
]b4_yy_location_print_define[
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
||||
Kind, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -818,9 +788,8 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *
|
||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||
yy_symbol_print (stderr,
|
||||
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
|
||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
||||
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||
b4_user_args[);
|
||||
&]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([,
|
||||
&]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
}
|
||||
@@ -836,7 +805,7 @@ do { \
|
||||
int yydebug;
|
||||
#else /* !]b4_api_PREFIX[DEBUG */
|
||||
# define YYDPRINTF(Args) ((void) 0)
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
|
||||
# define YY_STACK_PRINT(Bottom, Top)
|
||||
# define YY_REDUCE_PRINT(Rule)
|
||||
#endif /* !]b4_api_PREFIX[DEBUG */
|
||||
@@ -1149,7 +1118,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
||||
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
|
||||
{
|
||||
yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
|
||||
if (yysym != ]b4_symbol_prefix[YYERROR && yysym != ]b4_symbol_prefix[YYUNDEF)
|
||||
if (yysym != ]b4_symbol(1, kind)[ && yysym != ]b4_symbol_prefix[YYUNDEF)
|
||||
switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes, &yyps->yyes_capacity, yyps->yyssp, yysym]],
|
||||
[[yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym]])[))
|
||||
{
|
||||
@@ -1178,7 +1147,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
int yyx;
|
||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol_prefix[YYERROR
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
|
||||
&& !yytable_value_is_error (yytable[yyx + yyn]))
|
||||
{
|
||||
if (!yyarg)
|
||||
@@ -1189,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;
|
||||
}
|
||||
|
||||
@@ -1400,10 +1371,10 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
||||
|
||||
switch (yycount)
|
||||
{
|
||||
# define YYCASE_(N, S) \
|
||||
#define YYCASE_(N, S) \
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
@@ -1411,7 +1382,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
||||
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
||||
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
||||
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
||||
# undef YYCASE_
|
||||
#undef YYCASE_
|
||||
}
|
||||
|
||||
/* Compute error message size. Don't count the "%s"s, but reserve
|
||||
@@ -1693,7 +1664,7 @@ yysetstate:
|
||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
||||
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
||||
# undef YYSTACK_RELOCATE
|
||||
# undef YYSTACK_RELOCATE
|
||||
if (yyss1 != yyssa)
|
||||
YYSTACK_FREE (yyss1);
|
||||
}
|
||||
@@ -1765,6 +1736,17 @@ yyread_pushed_token:]])[
|
||||
yytoken = ]b4_symbol(0, [kind])[;
|
||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
||||
}
|
||||
else if (yychar == ]b4_symbol(1, [id])[)
|
||||
{
|
||||
/* The scanner already issued an error message, process directly
|
||||
to error recovery. But do not keep the error token as
|
||||
lookahead, it is too special and may lead us to an endless
|
||||
loop in error recovery. */
|
||||
yychar = ]b4_symbol(2, [id])[;
|
||||
yytoken = ]b4_symbol(1, [kind])[;]b4_locations_if([[
|
||||
yyerror_range[1] = yylloc;]])[
|
||||
goto yyerrlab1;
|
||||
}
|
||||
else
|
||||
{
|
||||
yytoken = YYTRANSLATE (yychar);
|
||||
@@ -1947,9 +1929,8 @@ yyerrlab:
|
||||
goto yyexhaustedlab;
|
||||
}]])[
|
||||
}
|
||||
|
||||
]b4_locations_if([[ yyerror_range[1] = yylloc;]])[
|
||||
|
||||
]b4_locations_if([[
|
||||
yyerror_range[1] = yylloc;]])[
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
@@ -1998,14 +1979,14 @@ 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];
|
||||
if (!yypact_value_is_default (yyn))
|
||||
{
|
||||
yyn += ]b4_symbol_prefix[YYERROR;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol_prefix[YYERROR)
|
||||
yyn += ]b4_symbol(1, kind)[;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol(1, kind)[)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -2034,10 +2015,8 @@ yyerrlab1:
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
]b4_locations_if([[
|
||||
yyerror_range[2] = yylloc;
|
||||
/* Using YYLLOC is tempting, but would change the location of
|
||||
the lookahead. YYLOC is available though. */
|
||||
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
|
||||
*++yylsp = yyloc;]])[
|
||||
++yylsp;
|
||||
YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);]])[
|
||||
|
||||
/* Shift the error token. */
|
||||
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
|
||||
|
||||
+210
-92
@@ -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.
|
||||
@@ -314,6 +311,7 @@ Parser C-Language Interface
|
||||
The Lexical Analyzer Function @code{yylex}
|
||||
|
||||
* Calling Convention:: How @code{yyparse} calls @code{yylex}.
|
||||
* Special Tokens:: Signaling end-of-file and errors to the parser.
|
||||
* Tokens from Literals:: Finding token kinds from string aliases.
|
||||
* Token Values:: How @code{yylex} must return the semantic value
|
||||
of the token it has read.
|
||||
@@ -2368,9 +2366,9 @@ yylex (void)
|
||||
@end group
|
||||
@end example
|
||||
|
||||
Basically, the lexical analyzer performs the same processing as before:
|
||||
it skips blanks and tabs, and reads numbers or single-character tokens.
|
||||
In addition, it updates @code{yylloc}, the global variable (of type
|
||||
Basically, the lexical analyzer performs the same processing as before: it
|
||||
skips blanks and tabs, and reads numbers or single-character tokens. In
|
||||
addition, it updates @code{yylloc}, the global variable (of type
|
||||
@code{YYLTYPE}) containing the token's location.
|
||||
|
||||
Now, each time this function returns a token, the parser has its kind as
|
||||
@@ -4504,12 +4502,17 @@ typedef struct YYLTYPE
|
||||
@} YYLTYPE;
|
||||
@end example
|
||||
|
||||
While default locations represent a range in the source file(s), this is not
|
||||
a requirement. It could be a single point or just a line number, or even
|
||||
more complex structures.
|
||||
|
||||
When @code{YYLTYPE} is not defined, at the beginning of the parsing, Bison
|
||||
initializes all these fields to 1 for @code{yylloc}. To initialize
|
||||
@code{yylloc} with a custom location type (or to chose a different
|
||||
initialization), use the @code{%initial-action} directive. @xref{Initial
|
||||
Action Decl}.
|
||||
|
||||
|
||||
@node Actions and Locations
|
||||
@subsection Actions and Locations
|
||||
@cindex location actions
|
||||
@@ -6131,7 +6134,7 @@ the @code{full} value was introduced in Bison 2.7
|
||||
@deffn Directive {%define api.push-pull} @var{kind}
|
||||
|
||||
@itemize @bullet
|
||||
@item Language(s): C (deterministic parsers only)
|
||||
@item Language(s): C (deterministic parsers only), Java
|
||||
|
||||
@item Purpose: Request a pull parser, a push parser, or both.
|
||||
@xref{Push Decl}.
|
||||
@@ -6921,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.
|
||||
@@ -7027,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.
|
||||
@@ -7050,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}
|
||||
@@ -7115,6 +7124,7 @@ that need it. @xref{Invocation}.
|
||||
|
||||
@menu
|
||||
* Calling Convention:: How @code{yyparse} calls @code{yylex}.
|
||||
* Special Tokens:: Signaling end-of-file and errors to the parser.
|
||||
* Tokens from Literals:: Finding token kinds from string aliases.
|
||||
* Token Values:: How @code{yylex} must return the semantic value
|
||||
of the token it has read.
|
||||
@@ -7168,6 +7178,49 @@ This interface has been designed so that the output from the @code{lex}
|
||||
utility can be used without change as the definition of @code{yylex}.
|
||||
|
||||
|
||||
@node Special Tokens
|
||||
@subsection Special Tokens
|
||||
|
||||
In addition to the user defined tokens, Bison generates a few special tokens
|
||||
that @code{yylex} may return.
|
||||
|
||||
The @code{YYEOF} token denotes the end of file, and signals to the parser
|
||||
that there is nothing left afterwards. @xref{Calling Convention}, for an
|
||||
example.
|
||||
|
||||
Returning @code{YYUNDEF} tells the parser that some lexical error was found.
|
||||
It will emit an error message about an ``invalid token'', and enter
|
||||
error-recovery (@pxref{Error Recovery}). Returning an unknown token kind
|
||||
results in the exact same behavior.
|
||||
|
||||
Returning @code{YYerror} requires the parser to enter error-recovery
|
||||
@emph{without} emitting an error message. This way the lexical analyzer can
|
||||
produce an accurate error messages about the invalid input (something the
|
||||
parser cannot do), and yet benefit from the error-recovery features of the
|
||||
parser.
|
||||
|
||||
@example
|
||||
int
|
||||
yylex (void)
|
||||
@{
|
||||
@dots{}
|
||||
switch (c)
|
||||
@{
|
||||
@dots{}
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
@dots{}
|
||||
return TOK_NUM;
|
||||
@dots{}
|
||||
case EOF:
|
||||
return YYEOF;
|
||||
default:
|
||||
yyerror ("syntax error: invalid character: %c", c);
|
||||
return YYerror;
|
||||
@}
|
||||
@}
|
||||
@end example
|
||||
|
||||
@node Tokens from Literals
|
||||
@subsection Finding Tokens by String Literals
|
||||
|
||||
@@ -7471,7 +7524,7 @@ enum yysymbol_kind_t
|
||||
@{
|
||||
YYSYMBOL_YYEMPTY = -2, /* No symbol. */
|
||||
YYSYMBOL_YYEOF = 0, /* "end of file" */
|
||||
YYSYMBOL_YYERROR = 1, /* error */
|
||||
YYSYMBOL_YYerror = 1, /* error */
|
||||
YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
|
||||
YYSYMBOL_PLUS = 3, /* "+" */
|
||||
YYSYMBOL_MINUS = 4, /* "-" */
|
||||
@@ -7497,24 +7550,31 @@ The location of the syntax error (that of the unexpected token).
|
||||
|
||||
@deftypefun int yypcontext_expected_tokens (@code{const yypcontext_t *}ctx, @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_YYEMPTY}, @code{YYSYMBOL_YYerror}, or
|
||||
@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
|
||||
values, which is always less than @code{YYNTOKENS}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {const char *} yysymbol_name (@code{symbol_kind_t} @var{symbol})
|
||||
@deftypefun {@r{string type}} yysymbol_name (@code{symbol_kind_t} @var{symbol})
|
||||
The name of the symbol whose kind is @var{symbol}, possibly translated.
|
||||
Depending on the options, may return a @code{const char*} or a
|
||||
@code{std::string}.
|
||||
@end deftypefun
|
||||
|
||||
A custom syntax error function looks as follows.
|
||||
A custom syntax error function looks as follows. This implementation is
|
||||
inappropriate for internationalization, see the @file{c/bistromathic}
|
||||
example for a better alternative.
|
||||
|
||||
@example
|
||||
int
|
||||
@@ -7606,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
|
||||
@@ -7802,7 +7862,7 @@ or @code{detailed}, token aliases can be internationalized:
|
||||
%token
|
||||
'\n' _("end of line")
|
||||
<double>
|
||||
NUM _("double precision number")
|
||||
NUM _("number")
|
||||
<symrec*>
|
||||
FUN _("function")
|
||||
VAR _("variable")
|
||||
@@ -8253,7 +8313,7 @@ the lookahead token has no precedence, then the default is to shift.
|
||||
@subsection Using Precedence For Non Operators
|
||||
|
||||
Using properly precedence and associativity directives can help fixing
|
||||
shift/reduce conflicts that do not involve arithmetics-like operators. For
|
||||
shift/reduce conflicts that do not involve arithmetic-like operators. For
|
||||
instance, the ``dangling @code{else}'' problem (@pxref{Shift/Reduce}) can be
|
||||
solved elegantly in two different ways.
|
||||
|
||||
@@ -9596,10 +9656,10 @@ and understand the parser run-time traces (@pxref{Tracing}).
|
||||
@node Understanding
|
||||
@section Understanding Your Parser
|
||||
|
||||
As documented elsewhere (@pxref{Algorithm})
|
||||
Bison parsers are @dfn{shift/reduce automata}. In some cases (much more
|
||||
frequent than one would hope), looking at this automaton is required to
|
||||
tune or simply fix a parser.
|
||||
As documented elsewhere (@pxref{Algorithm}) Bison parsers are
|
||||
@dfn{shift/reduce automata}. In some cases (much more frequent than one
|
||||
would hope), looking at this automaton is required to tune or simply fix a
|
||||
parser.
|
||||
|
||||
The textual file is generated when the options @option{--report} or
|
||||
@option{--verbose} are specified, see @ref{Invocation}. Its name is made by
|
||||
@@ -10555,6 +10615,26 @@ For compatibility with POSIX, the standard Bison distribution also contains
|
||||
a shell script called @command{yacc} that invokes Bison with the @option{-y}
|
||||
option.
|
||||
|
||||
@sp 1
|
||||
|
||||
The exit status of @command{bison} is:
|
||||
@table @asis
|
||||
@item 0 (success)
|
||||
when there were no errors. Warnings, which are diagnostics about dubious
|
||||
constructs, do not change the exit status, unless they are turned into
|
||||
errors (@pxref{-Werror,,@option{-Werror}}).
|
||||
|
||||
@item 1 (failure)
|
||||
when there were errors. No file was generated (except the reports generated
|
||||
by @option{--verbose}, etc.). In particular, the output files that possibly
|
||||
existed were not changed.
|
||||
|
||||
@item 63 (mistmatch)
|
||||
when @command{bison} does not meet the version requirements of the grammar
|
||||
file. @xref{Require Decl}. No file was generated or changed.
|
||||
@end table
|
||||
|
||||
|
||||
@menu
|
||||
* Bison Options:: All the options described in detail,
|
||||
in alphabetical order by short options.
|
||||
@@ -10601,7 +10681,7 @@ Print the version number of Bison and exit.
|
||||
Print the name of the directory containing locale-dependent data.
|
||||
|
||||
@item --print-datadir
|
||||
Print the name of the directory containing skeletons and XSLT.
|
||||
Print the name of the directory containing skeletons, CSS and XSLT.
|
||||
|
||||
@item -u
|
||||
@item --update
|
||||
@@ -10948,6 +11028,7 @@ instance, @option{-Wno-yacc} will hide the warnings about
|
||||
POSIX Yacc incompatibilities.
|
||||
|
||||
@item -Werror
|
||||
@anchor{-Werror}
|
||||
Turn enabled warnings for every @var{category} into errors, unless they are
|
||||
explicitly disabled by @option{-Wno-error=@var{category}}.
|
||||
|
||||
@@ -11545,7 +11626,7 @@ struct token
|
||||
@{
|
||||
YYEMPTY = -2, // No token.
|
||||
YYEOF = 0, // "end of file"
|
||||
YYERRCODE = 256, // error
|
||||
YYerror = 256, // error
|
||||
YYUNDEF = 257, // "invalid token"
|
||||
PLUS = 258, // "+"
|
||||
MINUS = 259, // "-"
|
||||
@@ -12062,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}.
|
||||
@@ -12072,9 +12154,13 @@ 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.
|
||||
A custom syntax error function looks as follows. This implementation is
|
||||
inappropriate for internationalization, see the @file{c/bistromathic}
|
||||
example for a better alternative.
|
||||
|
||||
@example
|
||||
void
|
||||
@@ -12202,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.
|
||||
@@ -12330,7 +12422,7 @@ interactions. A hand-written scanner is actually easier to interface with.
|
||||
@node Calc++ --- C++ Calculator
|
||||
@subsubsection Calc++ --- C++ Calculator
|
||||
|
||||
Of course the grammar is dedicated to arithmetics, a single expression,
|
||||
Of course the grammar is dedicated to arithmetic, a single expression,
|
||||
possibly preceded by variable assignments. An environment containing
|
||||
possibly predefined variables such as @code{one} and @code{two}, is
|
||||
exchanged with the parser. An example of valid input follows.
|
||||
@@ -12950,9 +13042,6 @@ of the parser is always local to an instance of the parser class.
|
||||
Therefore, all Java parsers are ``pure'', and the @code{%define api.pure}
|
||||
directive does nothing when used in Java.
|
||||
|
||||
Push parsers are currently unsupported in Java and @code{%define
|
||||
api.push-pull} have no effect.
|
||||
|
||||
GLR parsers are currently unsupported in Java. Do not use the
|
||||
@code{glr-parser} directive.
|
||||
|
||||
@@ -13224,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}.
|
||||
@@ -13267,9 +13357,9 @@ changed using @code{%define api.location.type @{@var{class-name}@}}.
|
||||
@end deftypemethod
|
||||
|
||||
@deftypemethod {Lexer} {int} yylex ()
|
||||
Return the next token. Its type is the return value, its semantic
|
||||
value and location are saved and returned by the their methods in the
|
||||
interface.
|
||||
Return the next token. Its type is the return value, its semantic value and
|
||||
location are saved and returned by the their methods in the interface. Not
|
||||
needed for push-only parsers.
|
||||
|
||||
Use @samp{%define lex_throws} to specify any uncaught exceptions.
|
||||
Default is @code{java.io.IOException}.
|
||||
@@ -13279,7 +13369,7 @@ Default is @code{java.io.IOException}.
|
||||
@deftypemethodx {Lexer} {Position} getEndPos ()
|
||||
Return respectively the first position of the last token that @code{yylex}
|
||||
returned, and the first position beyond it. These methods are not needed
|
||||
unless location tracking is active.
|
||||
unless location tracking and pull parsing are active.
|
||||
|
||||
They should return new objects for each call, to avoid that all the symbol
|
||||
share the same Position boundaries.
|
||||
@@ -13289,7 +13379,8 @@ The return type can be changed using @code{%define api.position.type
|
||||
@end deftypemethod
|
||||
|
||||
@deftypemethod {Lexer} {Object} getLVal ()
|
||||
Return the semantic value of the last token that yylex returned.
|
||||
Return the semantic value of the last token that yylex returned. Not needed
|
||||
for push-only parsers.
|
||||
|
||||
The return type can be changed using @samp{%define api.value.type
|
||||
@{@var{class-name}@}}.
|
||||
@@ -13327,6 +13418,10 @@ public void reportSyntaxError(YYParser.Context ctx) @{
|
||||
System.err.println("");
|
||||
@}
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
This implementation is inappropriate for internationalization, see the
|
||||
@file{c/bistromathic} example for a better alternative.
|
||||
@end deftypemethod
|
||||
|
||||
@node Java Action Features
|
||||
@@ -14613,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}.
|
||||
@@ -14662,8 +14765,8 @@ In semantic actions, it stores the location of the lookahead token.
|
||||
@end deffn
|
||||
|
||||
@deffn {Type} YYLTYPE
|
||||
Data type of @code{yylloc}; by default, a structure with four
|
||||
members. @xref{Location Type}.
|
||||
Data type of @code{yylloc}. By default in C, a structure with four members
|
||||
(start/end line/column). @xref{Location Type}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Variable} yylval
|
||||
@@ -14702,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
|
||||
@@ -14767,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
|
||||
@@ -14853,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
|
||||
@@ -15116,7 +15234,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
||||
@c LocalWords: redeclare automata Dparse localedir datadir XSLT midrule Wno
|
||||
@c LocalWords: multitable headitem hh basename Doxygen fno filename gdef de
|
||||
@c LocalWords: doxygen ival sval deftypemethod deallocate pos deftypemethodx
|
||||
@c LocalWords: Ctor defcv defcvx arg accessors arithmetics CPP ifndef CALCXX
|
||||
@c LocalWords: Ctor defcv defcvx arg accessors CPP ifndef CALCXX YYerror
|
||||
@c LocalWords: lexer's calcxx bool LPAREN RPAREN deallocation cerrno climits
|
||||
@c LocalWords: cstdlib Debian undef yywrap unput noyywrap nounput zA yyleng
|
||||
@c LocalWords: errno strtol ERANGE str strerror iostream argc argv Javadoc PSLR
|
||||
@@ -15150,7 +15268,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
||||
@c LocalWords: Wdangling yytoken erreur syntaxe inattendu attendait nombre
|
||||
@c LocalWords: YYUNDEF SymbolKind yypcontext YYENOMEM TOKENMAX getBundle
|
||||
@c LocalWords: ResourceBundle myResources getString getName getToken
|
||||
@c LocalWords: getLocation getExpectedTokens reportSyntaxError
|
||||
@c LocalWords: getLocation getExpectedTokens reportSyntaxError bistromathic
|
||||
|
||||
@c Local Variables:
|
||||
@c ispell-dictionary: "american"
|
||||
|
||||
+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
|
||||
|
||||
+26
-16
@@ -252,7 +252,6 @@ sub generate_grammar_triangular ($$@)
|
||||
my $out = new IO::File ">$base.y"
|
||||
or die;
|
||||
print $out <<EOF;
|
||||
%define parse.error detailed
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -388,7 +387,6 @@ sub generate_grammar_calc ($$@)
|
||||
%}
|
||||
|
||||
%define api.value.type union
|
||||
%define parse.error detailed
|
||||
$directives
|
||||
|
||||
%{
|
||||
@@ -812,7 +810,8 @@ sub compile ($)
|
||||
my ($base) = @_;
|
||||
my $compiler = compiler ($base);
|
||||
|
||||
my $my_bison = `sed -ne '/%bison "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
|
||||
my $my_bison = `sed -ne '/[/][/] %bison "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
|
||||
chop $my_bison;
|
||||
run ((length $my_bison ? $my_bison : $bison) . " $base.y -o $base.c");
|
||||
if ($gbench)
|
||||
{
|
||||
@@ -902,8 +901,13 @@ directive list.
|
||||
sub bench_with_gbenchmark ($@)
|
||||
{
|
||||
my ($grammar, @directive) = @_;
|
||||
my $compiler = compiler ("y0");
|
||||
|
||||
my $readme = new IO::File ">README.md";
|
||||
print $readme <<EOF;
|
||||
compiler: $compiler $cflags
|
||||
EOF
|
||||
|
||||
my @obj = ();
|
||||
for my $i (0 .. $#directive)
|
||||
{
|
||||
@@ -923,7 +927,6 @@ sub bench_with_gbenchmark ($@)
|
||||
BENCHMARK_MAIN();
|
||||
EOF
|
||||
|
||||
my $compiler = compiler ("y0");
|
||||
run "$compiler -o main $cflags main.c @obj -lbenchmark";
|
||||
run "./main | tee -a README.md";
|
||||
}
|
||||
@@ -1121,7 +1124,7 @@ sub parse_dir ()
|
||||
elsif ($token[0] eq '%b')
|
||||
{
|
||||
shift @token;
|
||||
@res = ("/*\n%bison \"$token[0]\"\\\n*/");
|
||||
@res = ("// %bison \"$token[0]\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1160,19 +1163,26 @@ sub getopt ()
|
||||
|
||||
getopt;
|
||||
|
||||
my $basedir = 'benches';
|
||||
|
||||
# Create the directory we work in.
|
||||
mkdir "benches" or die "cannot create benches"
|
||||
unless -d "benches";
|
||||
my $count = 1;
|
||||
++$count
|
||||
while -d "benches/$count";
|
||||
my $dir = "benches/$count";
|
||||
mkdir $basedir or die "cannot create directory $basedir"
|
||||
unless -d $basedir;
|
||||
|
||||
my $count = 0;
|
||||
my $dir;
|
||||
while (!$dir || -d $dir)
|
||||
{
|
||||
++$count;
|
||||
$dir = sprintf "%s/%03d", $basedir, $count;
|
||||
}
|
||||
mkdir $dir
|
||||
or die "cannot create $dir";
|
||||
unlink "benches/latest"
|
||||
or die "cannot unlink benches/latest"
|
||||
if -l "benches/latest";
|
||||
symlink $count, "benches/latest"
|
||||
or die "cannot create directory $dir";
|
||||
|
||||
unlink "$basedir/latest"
|
||||
or die "cannot unlink $basedir/latest"
|
||||
if -l "$basedir/latest";
|
||||
symlink sprintf("%03d", $count), "$basedir/latest"
|
||||
or die "cannot create symlink";
|
||||
chdir $dir
|
||||
or die "cannot chdir $dir";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace yy
|
||||
int
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
if (2 <= argc && isdigit (*argv[1]))
|
||||
if (2 <= argc && isdigit (static_cast<unsigned char> (*argv[1])))
|
||||
{
|
||||
auto maxl = strtol (argv[1], nullptr, 10);
|
||||
max = INT_MIN <= maxl && maxl <= INT_MAX ? int(maxl) : 4;
|
||||
|
||||
+11
-8
@@ -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
|
||||
@@ -53,10 +53,13 @@ push-parser model.
|
||||
This example demonstrates best practices when using Bison.
|
||||
- Its hand-written scanner tracks locations.
|
||||
- Its interface is pure.
|
||||
- It uses the `error` token to get error recovery.
|
||||
- Its interface is "incremental", well suited for interaction: it uses the
|
||||
push-parser API to feed the parser with the incoming tokens.
|
||||
- It features an interactive command line with completion based on the
|
||||
parser state, based on `yyexpected_tokens`.
|
||||
- It uses Bison's standard catalogue for internationalization of generated
|
||||
messages.
|
||||
- It uses a custom syntax error with location, lookahead correction and
|
||||
token internationalization.
|
||||
- It supports debug traces with semantic values.
|
||||
|
||||
@@ -3,20 +3,26 @@
|
||||
|
||||
BASE = bistromathic
|
||||
BISON = bison
|
||||
FLEX = flex
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
# We need to find the headers and libs for readline (and possibly intl).
|
||||
# You probably need to customize this for your own environment.
|
||||
CPPFLAGS = -I/opt/local/include
|
||||
LDFLAGS = -L/opt/local/lib
|
||||
|
||||
# Find the translation catalogue for Bison's generated messagess.
|
||||
BISON_LOCALEDIR = $(shell $(BISON) $(BISON_FLAGS) --print-localedir)
|
||||
CPPFLAGS += -DENABLE_NLS -DBISON_LOCALEDIR='"$(BISON_LOCALEDIR)"'
|
||||
|
||||
LIBS = -lreadline -lm # In some environments, -lintl is needed.
|
||||
|
||||
all: $(BASE)
|
||||
|
||||
%.c %.h %.xml %.gv: %.y
|
||||
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
%.c: %.l
|
||||
$(FLEX) $(FLEXFLAGS) -o$*.c $<
|
||||
|
||||
scan.o: parse.h
|
||||
$(BASE): parse.o scan.o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
$(BASE): parse.o
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type bistromathic expressions. Quit with ctrl-d."
|
||||
@@ -28,8 +34,7 @@ html: $(BASE).html
|
||||
|
||||
CLEANFILES = \
|
||||
$(BASE) *.o \
|
||||
parse.[ch] parse.output parse.xml parse.html parse.gv \
|
||||
scan.c
|
||||
parse.[ch] parse.output parse.xml parse.html parse.gv
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
This example demonstrates best practices when using Bison.
|
||||
- Its hand-written scanner tracks locations.
|
||||
- Its interface is pure.
|
||||
- It uses the `error` token to get error recovery.
|
||||
- Its interface is "incremental", well suited for interaction: it uses the
|
||||
push-parser API to feed the parser with the incoming tokens.
|
||||
- It features an interactive command line with completion based on the
|
||||
parser state, based on `yyexpected_tokens`.
|
||||
- It uses Bison's standard catalogue for internationalization of generated
|
||||
messages.
|
||||
- It uses a custom syntax error with location, lookahead correction and
|
||||
token internationalization.
|
||||
- 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,12 +15,47 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# macOS' version of readline does not repeat stdin on stdout in
|
||||
# non-interactive mode.
|
||||
if ! echo '1-1' | prog | grep '1-1'; then
|
||||
strip_prompt=true
|
||||
# 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.
|
||||
#
|
||||
# With recent versions of GNU Readline, input "1+2*3\n" gives
|
||||
# "> 1+2*3\n7\n> \n"
|
||||
#
|
||||
# macOS' version does not display the prompt and does not repeat stdin
|
||||
# on stdout, so input "1+2*3\n" gives "7\n" as output. Let's try to
|
||||
# cope with this.
|
||||
#
|
||||
# On OpenBSD 6.5 the prompt is displayed, but the input is not
|
||||
# repeated (!). So input "1+2*3\n" gives "> 7\n> \n" as output.
|
||||
#
|
||||
# On AIX, you get some escaping sequence before the prompt:
|
||||
# "<ESC>[?1034h> 1+2*3". It appears to pass the terminfo capability
|
||||
# "smm", to put the terminal in "meta mode": as if the user had hit
|
||||
# META.
|
||||
|
||||
echo >perfect '> 0
|
||||
0
|
||||
> '
|
||||
|
||||
echo >ok '0'
|
||||
echo '0' | prog >effective
|
||||
|
||||
echo "checking for readline output"
|
||||
if diff perfect effective; then
|
||||
# Alles ist gut.
|
||||
strip_prompt=false
|
||||
elif diff ok effective; then
|
||||
strip_prompt=true
|
||||
else
|
||||
skip "this is not the GNU Readline we expect"
|
||||
fi
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
EOF
|
||||
@@ -65,26 +100,159 @@ cat >input <<EOF
|
||||
*
|
||||
EOF
|
||||
run 0 '> *
|
||||
> err: 1.1: syntax error: expected end of file or - or ( or exit or double precision 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
|
||||
EOF
|
||||
run 0 '> 1 + 2 * * 3
|
||||
> err: 1.9: syntax error: expected - or ( or double precision number or function or variable before *'
|
||||
|
||||
cat >input <<EOF
|
||||
100%
|
||||
EOF
|
||||
run 0 '> 100%
|
||||
100
|
||||
> err: 1.4: error: invalid character'
|
||||
> ''
|
||||
err: 1.9: syntax error: expected - or ( or number or function or variable before *'
|
||||
|
||||
cat >input <<EOF
|
||||
1 / 0
|
||||
EOF
|
||||
run 0 '> 1 / 0
|
||||
> err: 1.1-5: error: division by zero'
|
||||
> ''
|
||||
err: 1.1-5: error: division by zero'
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Error recovery. ##
|
||||
## ---------------- ##
|
||||
|
||||
cat >input <<EOF
|
||||
((1 ++ 2) ** 3)
|
||||
(1 ++ 2) + (3 ** 4)
|
||||
EOF
|
||||
run 0 '> ((1 ++ 2) ** 3)
|
||||
666
|
||||
> (1 ++ 2) + (3 ** 4)
|
||||
1332
|
||||
> ''
|
||||
err: 1.6: syntax error: expected - or ( or number or function or variable before +
|
||||
err: 2.5: syntax error: expected - or ( or number or function or variable before +
|
||||
err: 2.16: syntax error: expected - or ( or number or function or variable before *'
|
||||
|
||||
# The rule "( error )" should work even if there are no tokens between "(" and ")".
|
||||
cat >input <<EOF
|
||||
()
|
||||
EOF
|
||||
run 0 '> ()
|
||||
666
|
||||
> ''
|
||||
err: 1.2: syntax error: expected - or ( or number or function or variable before )'
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
100% + 10
|
||||
EOF
|
||||
run 0 '> 100% + 10
|
||||
> ''
|
||||
err: 1.4: syntax error: invalid character: %'
|
||||
|
||||
# Traces. This allows to check the location of the error. If we
|
||||
# forget to map YYerror to YYUNDEF, error recovery enters an endless
|
||||
# loop with this input.
|
||||
cat >input <<EOF
|
||||
(+_)
|
||||
EOF
|
||||
run 0 '> (+_)
|
||||
666
|
||||
> ''
|
||||
err: Starting parse
|
||||
err: Entering state 0
|
||||
err: Stack now 0
|
||||
err: Reading a token
|
||||
err: Next token is token ( (1.1: )
|
||||
err: Shifting token ( (1.1: )
|
||||
err: Entering state 2
|
||||
err: Stack now 0 2
|
||||
err: Return for a new token:
|
||||
err: Reading a token
|
||||
err: Next token is token + (1.2: )
|
||||
err: LAC: initial context established for +
|
||||
err: LAC: checking lookahead +: Err
|
||||
err: LAC: checking lookahead end of file: Err
|
||||
err: LAC: checking lookahead +: Err
|
||||
err: LAC: checking lookahead -: S1
|
||||
err: LAC: checking lookahead *: Err
|
||||
err: LAC: checking lookahead /: Err
|
||||
err: LAC: checking lookahead ^: Err
|
||||
err: LAC: checking lookahead (: S2
|
||||
err: LAC: checking lookahead ): Err
|
||||
err: LAC: checking lookahead =: Err
|
||||
err: LAC: checking lookahead exit: Err
|
||||
err: LAC: checking lookahead number: S4
|
||||
err: LAC: checking lookahead function: S5
|
||||
err: LAC: checking lookahead variable: S6
|
||||
err: LAC: checking lookahead NEG: Err
|
||||
err: 1.2: syntax error: expected - or ( or number or function or variable before +
|
||||
err: LAC: initial context discarded due to error recovery
|
||||
err: Shifting token error (1.2: )
|
||||
err: Entering state 10
|
||||
err: Stack now 0 2 10
|
||||
err: Next token is token + (1.2: )
|
||||
err: LAC: initial context established for +
|
||||
err: LAC: checking lookahead +: Err
|
||||
err: Error: discarding token + (1.2: )
|
||||
err: Error: popping token error (1.2: )
|
||||
err: Stack now 0 2
|
||||
err: LAC: initial context discarded due to error recovery
|
||||
err: Shifting token error (1.2: )
|
||||
err: Entering state 10
|
||||
err: Stack now 0 2 10
|
||||
err: Return for a new token:
|
||||
err: 1.3: syntax error: invalid character: _
|
||||
err: Reading a token
|
||||
err: Error: popping token error (1.2: )
|
||||
err: Stack now 0 2
|
||||
err: Shifting token error (1.2-3: )
|
||||
err: Entering state 10
|
||||
err: Stack now 0 2 10
|
||||
err: Next token is token invalid token (1.3: )
|
||||
err: LAC: initial context established for invalid token
|
||||
err: LAC: checking lookahead invalid token: Always Err
|
||||
err: Error: discarding token invalid token (1.3: )
|
||||
err: Error: popping token error (1.2-3: )
|
||||
err: Stack now 0 2
|
||||
err: LAC: initial context discarded due to error recovery
|
||||
err: Shifting token error (1.2-3: )
|
||||
err: Entering state 10
|
||||
err: Stack now 0 2 10
|
||||
err: Return for a new token:
|
||||
err: Reading a token
|
||||
err: Next token is token ) (1.4: )
|
||||
err: Shifting token ) (1.4: )
|
||||
err: Entering state 20
|
||||
err: Stack now 0 2 10 20
|
||||
err: Reducing stack by rule 15 (line 151):
|
||||
err: $1 = token ( (1.1: )
|
||||
err: $2 = token error (1.2-3: )
|
||||
err: $3 = token ) (1.4: )
|
||||
err: -> $$ = nterm exp (1.1-4: 666)
|
||||
err: Entering state 7
|
||||
err: Stack now 0 7
|
||||
err: Return for a new token:
|
||||
err: Reading a token
|
||||
err: Now at end of input.
|
||||
err: LAC: initial context established for end of file
|
||||
err: LAC: checking lookahead end of file: R2 G8 S19
|
||||
err: Reducing stack by rule 2 (line 126):
|
||||
err: $1 = nterm exp (1.1-4: 666)
|
||||
err: -> $$ = nterm input (1.1-4: )
|
||||
err: Entering state 8
|
||||
err: Stack now 0 8
|
||||
err: Now at end of input.
|
||||
err: Shifting token end of file (1.5: )
|
||||
err: LAC: initial context discarded due to shift
|
||||
err: Entering state 19
|
||||
err: Stack now 0 8 19
|
||||
err: Stack now 0 8 19
|
||||
err: Cleanup: popping token end of file (1.5: )
|
||||
err: Cleanup: popping nterm input (1.1-4: )' -p
|
||||
|
||||
|
||||
|
||||
## ------------ ##
|
||||
@@ -94,38 +262,47 @@ run 0 '> 1 / 0
|
||||
# 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
|
||||
EOF
|
||||
run 0 '> (1+
|
||||
( cos ln
|
||||
- double precision number sin
|
||||
atan exp sqrt
|
||||
( - atan cos exp ln number sin sqrt
|
||||
> (1+
|
||||
> err: 1.4: syntax error: expected - or ( or double precision number or function or variable before end of file'
|
||||
> ''
|
||||
err: 1.4: syntax error: expected - or ( or number or function or variable before end of file'
|
||||
|
||||
# Check the completion of a word.
|
||||
sed -e 's/\\t/ /g' >input <<EOF
|
||||
(at\t\t
|
||||
EOF
|
||||
run 0 '> (atan ( ''
|
||||
> err: 1.9: syntax error: expected - or ( or double precision number or function or variable before end of file'
|
||||
> ''
|
||||
err: 1.9: syntax error: expected - or ( or number or function or variable before end of file'
|
||||
|
||||
# Check the completion at the very beginning.
|
||||
sed -e 's/\\t/ /g' >input <<EOF
|
||||
e\t\t
|
||||
EOF
|
||||
run 0 '> e
|
||||
run -n 0 '> e
|
||||
end of file exit exp ''
|
||||
> e
|
||||
0
|
||||
> err: '
|
||||
> ''
|
||||
err: '
|
||||
|
||||
@@ -19,16 +19,22 @@ bistromathicdir = $(docdir)/%D%
|
||||
## Bistromathics. ##
|
||||
## --------------- ##
|
||||
|
||||
check_PROGRAMS += %D%/bistromathic
|
||||
TESTS += %D%/bistromathic.test
|
||||
EXTRA_DIST += %D%/bistromathic.test
|
||||
nodist_%C%_bistromathic_SOURCES = %D%/parse.y %D%/parse.h
|
||||
%D%/parse.c: $(dependencies)
|
||||
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_bistromathic_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
%C%_bistromathic_LDADD = -lm -lreadline
|
||||
if ENABLE_BISTROMATHIC
|
||||
check_PROGRAMS += %D%/bistromathic
|
||||
TESTS += %D%/bistromathic.test
|
||||
nodist_%C%_bistromathic_SOURCES = %D%/parse.y
|
||||
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_bistromathic_CPPFLAGS = \
|
||||
-DBISON_LOCALEDIR='"$(localdir)"' \
|
||||
-DLOCALEDIR='"$(localdir)"' \
|
||||
-I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
%C%_bistromathic_LDADD = -lm $(LIBREADLINE) $(LIBINTL)
|
||||
endif
|
||||
|
||||
EXTRA_DIST += %D%/bistromathic.test
|
||||
dist_bistromathic_DATA = %D%/parse.y %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/parse.[ch] %D%/parse.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
+151
-45
@@ -1,15 +1,28 @@
|
||||
%require "3.6"
|
||||
|
||||
%code top {
|
||||
#include <assert.h>
|
||||
#include <ctype.h> // isdigit
|
||||
#include <locale.h> // LC_ALL
|
||||
#include <math.h> // cos, sin, etc.
|
||||
#include <stddef.h> // ptrdiff_t
|
||||
#include <stdarg.h> // va_start
|
||||
#include <stdio.h> // printf
|
||||
#include <stdlib.h> // calloc.
|
||||
#include <stdlib.h> // calloc
|
||||
#include <string.h> // strcmp
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#if defined ENABLE_NLS && ENABLE_NLS
|
||||
// Unable the translation of Bison's generated messages.
|
||||
# define YYENABLE_NLS 1
|
||||
# include <libintl.h>
|
||||
// Unless specified otherwise, we expect bistromathic's own
|
||||
// catalogue to be installed in the same tree as Bison's catalogue.
|
||||
# ifndef LOCALEDIR
|
||||
# define LOCALEDIR BISON_LOCALEDIR
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
%code requires {
|
||||
@@ -35,13 +48,22 @@
|
||||
}
|
||||
|
||||
%code provides {
|
||||
# ifndef __attribute__
|
||||
# ifndef __GNUC__
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
# endif
|
||||
int yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc);
|
||||
void yyerror (YYLTYPE *yylloc, char const *msg);
|
||||
void yyerror (YYLTYPE *loc, char const *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
}
|
||||
|
||||
%code {
|
||||
#define N_
|
||||
#define _
|
||||
#if defined ENABLE_NLS && ENABLE_NLS
|
||||
# define _(Msgid) gettext (Msgid)
|
||||
#else
|
||||
# define _(Msgid) (Msgid)
|
||||
#endif
|
||||
|
||||
// Whether to quit.
|
||||
int done = 0;
|
||||
@@ -82,7 +104,7 @@
|
||||
EQUAL "="
|
||||
EXIT "exit"
|
||||
<double>
|
||||
NUM _("double precision number")
|
||||
NUM _("number")
|
||||
<symrec*>
|
||||
FUN _("function")
|
||||
VAR _("variable")
|
||||
@@ -133,6 +155,7 @@ exp:
|
||||
| "-" exp %prec NEG { $$ = -$2; }
|
||||
| exp[l] "^" exp[r] { $$ = pow ($l, $r); }
|
||||
| "(" exp ")" { $$ = $2; }
|
||||
| "(" error ")" { $$ = 666; }
|
||||
;
|
||||
|
||||
// End of grammar.
|
||||
@@ -235,6 +258,8 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
case '(': return TOK_LPAREN;
|
||||
case ')': return TOK_RPAREN;
|
||||
|
||||
case '!': return TOK_YYUNDEF;
|
||||
|
||||
case '\0': return TOK_YYEOF;
|
||||
|
||||
// Numbers.
|
||||
@@ -244,9 +269,9 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
{
|
||||
int nchars = 0;
|
||||
sscanf (*line - 1, "%lf%n", &yylval->TOK_NUM, &nchars);
|
||||
*line += nchars - 1;
|
||||
yylloc->last_column += nchars - 1;
|
||||
return TOK_NUM;
|
||||
*line += nchars - 1;
|
||||
yylloc->last_column += nchars - 1;
|
||||
return TOK_NUM;
|
||||
}
|
||||
|
||||
// Identifiers.
|
||||
@@ -276,8 +301,8 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
|
||||
// Stray characters.
|
||||
default:
|
||||
yyerror (yylloc, "error: invalid character");
|
||||
return yylex (line, yylval, yylloc);
|
||||
yyerror (yylloc, "syntax error: invalid character: %c", c);
|
||||
return TOK_YYerror;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,40 +311,105 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
| Parser. |
|
||||
`---------*/
|
||||
|
||||
|
||||
const char *
|
||||
error_format_string (int argc)
|
||||
{
|
||||
switch (argc)
|
||||
{
|
||||
default: // Avoid compiler warnings.
|
||||
case 0: return _("%@: syntax error");
|
||||
case 1: return _("%@: syntax error: unexpected %u");
|
||||
// TRANSLATORS: '%@' is a location in a file, '%u' is an
|
||||
// "unexpected token", and '%0e', '%1e'... are expected tokens
|
||||
// at this point.
|
||||
//
|
||||
// For instance on the expression "1 + * 2", you'd get
|
||||
//
|
||||
// 1.5: syntax error: expected - or ( or number or function or variable before *
|
||||
case 2: return _("%@: syntax error: expected %0e before %u");
|
||||
case 3: return _("%@: syntax error: expected %0e or %1e before %u");
|
||||
case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
|
||||
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 etc., before %u");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
{
|
||||
int res = 0;
|
||||
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||
fprintf (stderr, ": syntax error");
|
||||
// Report the tokens expected at this point.
|
||||
{
|
||||
enum { TOKENMAX = 10 };
|
||||
yysymbol_kind_t expected[TOKENMAX];
|
||||
int n = yypcontext_expected_tokens (ctx, expected, TOKENMAX);
|
||||
if (n < 0)
|
||||
// Forward errors to yyparse.
|
||||
res = n;
|
||||
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 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.
|
||||
if (format[0] == '%' && format[1] == '@')
|
||||
{
|
||||
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||
format += 2;
|
||||
}
|
||||
// %u: unexpected token.
|
||||
else if (format[0] == '%' && format[1] == 'u')
|
||||
{
|
||||
fputs (yysymbol_name (yypcontext_token (ctx)), stderr);
|
||||
format += 2;
|
||||
}
|
||||
// %0e, %1e...: expected token.
|
||||
else if (format[0] == '%'
|
||||
&& isdigit ((unsigned char) format[1])
|
||||
&& format[2] == 'e'
|
||||
&& (format[1] - '0') < argsize)
|
||||
{
|
||||
int i = format[1] - '0';
|
||||
fputs (yysymbol_name (arg[i]), stderr);
|
||||
format += 3;
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < n; ++i)
|
||||
fprintf (stderr, "%s %s",
|
||||
i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
|
||||
}
|
||||
// Report the unexpected token.
|
||||
{
|
||||
yysymbol_kind_t lookahead = yypcontext_token (ctx);
|
||||
if (lookahead != YYSYMBOL_YYEMPTY)
|
||||
fprintf (stderr, " before %s", yysymbol_name (lookahead));
|
||||
}
|
||||
fprintf (stderr, "\n");
|
||||
return res;
|
||||
{
|
||||
fputc (*format, stderr);
|
||||
++format;
|
||||
}
|
||||
fputc ('\n', stderr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Called by yyparse on error.
|
||||
void yyerror (YYLTYPE *loc, char const *msg)
|
||||
void yyerror (YYLTYPE *loc, char const *format, ...)
|
||||
{
|
||||
YY_LOCATION_PRINT (stderr, *loc);
|
||||
fprintf (stderr, ": %s\n", msg);
|
||||
fputs (": ", stderr);
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
vfprintf (stderr, format, args);
|
||||
va_end (args);
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
|
||||
// Return a newly allocated copy of at most N bytes of STRING. In
|
||||
// other words, return a copy of the initial segment of length N of
|
||||
// STRING.
|
||||
static char *
|
||||
xstrndup (const char *string, size_t 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';
|
||||
return memcpy (new, string, len);
|
||||
}
|
||||
|
||||
|
||||
@@ -368,11 +458,11 @@ expected_tokens (const char *input,
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Attempt to complete on the contents of TEXT. START and END bound the
|
||||
region of rl_line_buffer that contains the word to complete. TEXT is
|
||||
the word to complete. We can use the entire contents of rl_line_buffer
|
||||
in case we want to do some simple parsing. Return the array of matches,
|
||||
or NULL if there aren't any. */
|
||||
// Attempt to complete on the contents of TEXT. START and END bound
|
||||
// the region of rl_line_buffer that contains the word to complete.
|
||||
// TEXT is the word to complete. We can use the entire contents of
|
||||
// rl_line_buffer in case we want to do some simple parsing. Return
|
||||
// the array of matches, or NULL if there aren't any.
|
||||
char **
|
||||
completion (const char *text, int start, int end)
|
||||
{
|
||||
@@ -383,7 +473,7 @@ completion (const char *text, int start, int end)
|
||||
|
||||
// Get list of token numbers.
|
||||
int tokens[YYNTOKENS];
|
||||
char *line = strndup (rl_line_buffer, start);
|
||||
char *line = xstrndup (rl_line_buffer, start);
|
||||
int ntokens = expected_tokens (line, tokens, YYNTOKENS);
|
||||
free (line);
|
||||
|
||||
@@ -425,7 +515,7 @@ completion (const char *text, int start, int end)
|
||||
for (int j = 0; j < lcplen; ++j)
|
||||
if (matches[1][j] != matches[i][j])
|
||||
lcplen = j;
|
||||
matches[0] = strndup (matches[1], lcplen);
|
||||
matches[0] = xstrndup (matches[1], lcplen);
|
||||
}
|
||||
|
||||
if (yydebug)
|
||||
@@ -467,8 +557,20 @@ void init_readline (void)
|
||||
|
||||
int main (int argc, char const* argv[])
|
||||
{
|
||||
#if defined ENABLE_NLS && ENABLE_NLS
|
||||
// Set up internationalization.
|
||||
setlocale (LC_ALL, "");
|
||||
// Use Bison's standard translation catalogue for error messages
|
||||
// (the generated messages).
|
||||
bindtextdomain ("bison-runtime", BISON_LOCALEDIR);
|
||||
// The translation catalogue of bistromathic is actually included in
|
||||
// Bison's. In your own project, use the name of your project.
|
||||
bindtextdomain ("bison", LOCALEDIR);
|
||||
textdomain ("bison");
|
||||
#endif
|
||||
|
||||
// Enable parse traces on option -p.
|
||||
if (argc == 2 && strcmp (argv[1], "-p") == 0)
|
||||
if (1 < argc && strcmp (argv[1], "-p") == 0)
|
||||
yydebug = 1;
|
||||
init_table ();
|
||||
init_readline ();
|
||||
@@ -477,7 +579,11 @@ int main (int argc, char const* argv[])
|
||||
{
|
||||
char *line = readline ("> ");
|
||||
if (!line)
|
||||
return 0;
|
||||
{
|
||||
// Finish the line started by the prompt.
|
||||
putchar ('\n');
|
||||
break;
|
||||
}
|
||||
if (*line)
|
||||
add_history (line);
|
||||
process_line (&lloc, line);
|
||||
|
||||
@@ -12,7 +12,7 @@ all: $(BASE)
|
||||
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
%.c %.h: %.l
|
||||
$(FLEX) $(FLEXFLAGS) -o$*.c --header-file=$*.h $<
|
||||
$(FLEX) $(FLEXFLAGS) -o$*.c --header=$*.h $<
|
||||
|
||||
scan.o: parse.h
|
||||
parse.o: scan.h
|
||||
|
||||
@@ -69,7 +69,9 @@ DASH = -
|
||||
$(AM_V_LEX)rm -f $@ $@.tmp
|
||||
$(AM_V_at)$(MKDIR_P) %D%
|
||||
$(AM_V_at)touch $@.tmp
|
||||
$(AM_V_at)$(LEX) $(AM_LFLAGS) $(LFLAGS) -o%D%/scan.c --header-file=%D%/scan.h $(srcdir)/%D%/scan.l
|
||||
## --header introduced in 2.5.6, renamed as --header-file in 2.6.4.
|
||||
## Backward compatibility ensured since --header is an unambiguous prefix.
|
||||
$(AM_V_at)$(LEX) $(AM_LFLAGS) $(LFLAGS) -o%D%/scan.c --header=%D%/scan.h $(srcdir)/%D%/scan.l
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
|
||||
|
||||
|
||||
@@ -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 || exit 77
|
||||
(seq 0) >/dev/null 2>&1 || skip "gimme one seq"
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
|
||||
@@ -9,7 +9,7 @@ afterwards.
|
||||
The usual calculator, a very simple version.
|
||||
|
||||
## calc/Calc.y
|
||||
The calculator, but with location tracking and debug traces.
|
||||
The calculator, but with location tracking, debug traces, and a push parser.
|
||||
|
||||
<!---
|
||||
|
||||
|
||||
+48
-19
@@ -2,6 +2,7 @@
|
||||
|
||||
%define api.parser.class {Calc}
|
||||
%define api.parser.public
|
||||
%define api.push-pull push
|
||||
|
||||
%define parse.error custom
|
||||
%define parse.trace
|
||||
@@ -20,12 +21,19 @@
|
||||
|
||||
%code {
|
||||
public static void main(String[] args) throws IOException {
|
||||
CalcLexer l = new CalcLexer(System.in);
|
||||
Calc p = new Calc(l);
|
||||
CalcLexer scanner = new CalcLexer(System.in);
|
||||
Calc parser = new Calc(scanner);
|
||||
for (String arg : args)
|
||||
if (arg.equals("-p"))
|
||||
p.setDebugLevel(1);
|
||||
if (!p.parse())
|
||||
parser.setDebugLevel(1);
|
||||
int status;
|
||||
do {
|
||||
int token = scanner.getToken();
|
||||
Object lval = scanner.getValue();
|
||||
Calc.Location yyloc = scanner.getLocation();
|
||||
status = parser.push_parse(token, lval, yyloc);
|
||||
} while (status == Calc.YYPUSH_MORE);
|
||||
if (status != Calc.YYACCEPT)
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -105,14 +113,17 @@ class CalcLexer implements Calc.Lexer {
|
||||
Position start = new Position(1, 0);
|
||||
Position end = new Position(1, 0);
|
||||
|
||||
public Position getStartPos() {
|
||||
return new Position(start);
|
||||
}
|
||||
|
||||
public Position getEndPos() {
|
||||
return new Position(end);
|
||||
/**
|
||||
* The location of the last token read.
|
||||
* Implemented with getStartPos and getEndPos in pull parsers.
|
||||
*/
|
||||
public Calc.Location getLocation() {
|
||||
return new Calc.Location(new Position(start), new Position(end));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and emit a syntax error message.
|
||||
*/
|
||||
public void reportSyntaxError(Calc.Context ctx) {
|
||||
System.err.print(ctx.getLocation() + ": syntax error");
|
||||
{
|
||||
@@ -131,26 +142,39 @@ class CalcLexer implements Calc.Lexer {
|
||||
System.err.println("");
|
||||
}
|
||||
|
||||
public void yyerror(Calc.Location l, String s) {
|
||||
if (l == null)
|
||||
System.err.println(s);
|
||||
/**
|
||||
* Emit an error referring to the given location in a user-defined way.
|
||||
*
|
||||
* @@param loc The location of the element to which the
|
||||
* error message is related.
|
||||
* @@param msg The string for the error message.
|
||||
*/
|
||||
public void yyerror(Calc.Location loc, String msg) {
|
||||
if (loc == null)
|
||||
System.err.println(msg);
|
||||
else
|
||||
System.err.println(l + ": " + s);
|
||||
System.err.println(loc + ": " + msg);
|
||||
}
|
||||
|
||||
Integer yylval;
|
||||
|
||||
public Object getLVal() {
|
||||
/**
|
||||
* The value of the last token read. Called getLVal in pull parsers.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return yylval;
|
||||
}
|
||||
|
||||
public int yylex() throws IOException {
|
||||
/**
|
||||
* Fetch the next token. Called yylex in pull parsers.
|
||||
*/
|
||||
public int getToken() throws IOException {
|
||||
start.set(reader.getPosition());
|
||||
int ttype = st.nextToken();
|
||||
end.set(reader.getPosition());
|
||||
switch (ttype) {
|
||||
case StreamTokenizer.TT_EOF:
|
||||
return EOF;
|
||||
return YYEOF;
|
||||
case StreamTokenizer.TT_EOL:
|
||||
end.line += 1;
|
||||
end.column = 0;
|
||||
@@ -160,7 +184,7 @@ class CalcLexer implements Calc.Lexer {
|
||||
end.set(reader.getPreviousPosition());
|
||||
return NUM;
|
||||
case ' ': case '\t':
|
||||
return yylex();
|
||||
return getToken();
|
||||
case '!':
|
||||
return BANG;
|
||||
case '+':
|
||||
@@ -185,7 +209,9 @@ class CalcLexer implements Calc.Lexer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A class defining a point in the input.
|
||||
*/
|
||||
class Position {
|
||||
public int line = 1;
|
||||
public int column = 1;
|
||||
@@ -227,6 +253,9 @@ class Position {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Stream reader that keeps track of the current Position.
|
||||
*/
|
||||
class PositionReader extends BufferedReader {
|
||||
|
||||
private Position position = new Position();
|
||||
|
||||
@@ -93,7 +93,7 @@ class CalcLexer implements Calc.Lexer {
|
||||
int ttype = st.nextToken();
|
||||
switch (ttype) {
|
||||
case StreamTokenizer.TT_EOF:
|
||||
return EOF;
|
||||
return YYEOF;
|
||||
case StreamTokenizer.TT_EOL:
|
||||
return (int) '\n';
|
||||
case StreamTokenizer.TT_WORD:
|
||||
|
||||
+59
-20
@@ -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,26 +75,49 @@ trap cleanup 0 1 2 13 15
|
||||
mkdir $$.dir
|
||||
cd $$.dir
|
||||
|
||||
# run [-noerr] EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# 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.
|
||||
# -n: not final end-of-line in expected-output
|
||||
run ()
|
||||
{
|
||||
noerr=false
|
||||
case $1 in
|
||||
(-noerr) noerr=true; shift;;
|
||||
esac
|
||||
echo=echo
|
||||
while true; do
|
||||
case $1 in
|
||||
(-noerr) noerr=true; shift;;
|
||||
(-n) echo=printf; shift;;
|
||||
(*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Expected exit status.
|
||||
sta_exp=$1
|
||||
shift
|
||||
|
||||
# Expected output.
|
||||
if $strip_prompt; then
|
||||
out_exp=$(echo "$1" | sed -e 's/^> err:/err:/;/^> /d')
|
||||
else
|
||||
out_exp=$1
|
||||
fi
|
||||
$echo "$1" |
|
||||
sed -e 's/Reducing stack by rule .* (line .*):/Reducing stack by rule XX (line XXX):/g' |
|
||||
if $strip_prompt; then
|
||||
# An extra EOL added in bistromathic's main. Keep that empty line.
|
||||
sed -e '/^> ./d;s/^> $//g'
|
||||
else
|
||||
cat
|
||||
fi >exp
|
||||
shift
|
||||
|
||||
# Effective exit status.
|
||||
@@ -96,33 +126,42 @@ run ()
|
||||
prog "$@" - <input >out_eff 2>err_eff || sta_eff=$?
|
||||
|
||||
# Combine effective output and error streams.
|
||||
out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff)
|
||||
{
|
||||
cat out_eff
|
||||
if ! $noerr; then
|
||||
sed -e 's/^/err: /g' \
|
||||
-e 's/Reducing stack by rule .* (line .*):/Reducing stack by rule XX (line XXX):/g' \
|
||||
err_eff
|
||||
fi
|
||||
} >eff
|
||||
|
||||
if test $sta_eff -eq $sta_exp; then
|
||||
if test "$out_eff" = "$out_exp"; then
|
||||
if diff $diff_opts eff exp >/dev/null 2>&1; then
|
||||
echo "$me: PASS: $number"
|
||||
else
|
||||
echo "$me: FAIL: $number"
|
||||
echo "$me: input:"
|
||||
sed -e 's/^/ /' input
|
||||
echo "$me: expected output:"
|
||||
echo "$out_exp" | sed -e 's/^/ /'
|
||||
sed -e 's/^/ /' exp
|
||||
echo "$me: effective output:"
|
||||
echo "$out_eff" | sed -e 's/^/ /'
|
||||
exit=false
|
||||
sed -e 's/^/ /' eff
|
||||
echo "$me: diff:"
|
||||
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: 64e1ff019f...ffbb0ced8b
@@ -1,3 +1,4 @@
|
||||
/remove-potcdate.sin~
|
||||
/*.gmo
|
||||
/*.po
|
||||
/LINGUAS
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/extern-inline.m4~
|
||||
/*~
|
||||
/00gnulib.m4
|
||||
/__inline.m4
|
||||
|
||||
+16
@@ -41,6 +41,22 @@ else
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_CACHE_CHECK([whether flex supports --header=FILE],
|
||||
[ac_cv_prog_lex_supports_header_opt],
|
||||
[if _AC_DO_VAR([LEX --header=conftest.h conftest.l]); then
|
||||
ac_cv_prog_lex_supports_header_opt=yes
|
||||
else
|
||||
ac_cv_prog_lex_supports_header_opt=no
|
||||
fi
|
||||
])
|
||||
if test "$ac_cv_prog_lex_supports_header_opt" = yes; then
|
||||
FLEX_SUPPORTS_HEADER_OPT=true
|
||||
else
|
||||
FLEX_SUPPORTS_HEADER_OPT=false
|
||||
fi
|
||||
|
||||
|
||||
cat >conftest.l <<_ACEOF[
|
||||
%%
|
||||
a { ECHO; }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
examples/c/bistromathic/parse.y
|
||||
examples/java/calc/Calc.y
|
||||
src/complain.c
|
||||
src/conflicts.c
|
||||
src/files.c
|
||||
@@ -5,6 +7,7 @@ src/fixits.c
|
||||
src/getargs.c
|
||||
src/gram.c
|
||||
src/graphviz.c
|
||||
src/i18n-strings.c
|
||||
src/location.c
|
||||
src/main.c
|
||||
src/muscle-tab.c
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@
|
||||
#include "system.h"
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <ctype.h>
|
||||
#include <c-ctype.h>
|
||||
#include <progname.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -600,7 +600,7 @@ syntax_error (location loc,
|
||||
CASE (2, _("expected %1$s before %0$s"));
|
||||
CASE (3, _("expected %1$s or %2$s before %0$s"));
|
||||
CASE (4, _("expected %1$s or %2$s or %3$s before %0$s"));
|
||||
CASE (5, _("expected %1$s or %2$s or %4$s or %5$s before %0$s"));
|
||||
CASE (5, _("expected %1$s or %2$s or %3$s or %4$s before %0$s"));
|
||||
#undef CASE
|
||||
}
|
||||
location_print (loc, stderr);
|
||||
@@ -609,7 +609,7 @@ syntax_error (location loc,
|
||||
|
||||
while (*format)
|
||||
if (format[0] == '%'
|
||||
&& isdigit (format[1])
|
||||
&& c_isdigit (format[1])
|
||||
&& format[2] == '$'
|
||||
&& format[3] == 's'
|
||||
&& (format[1] - '0') < argc)
|
||||
|
||||
+3
-2
@@ -124,10 +124,11 @@ fixits_run (void)
|
||||
FILE *out = xfopen (input, "w");
|
||||
size_t line = 1;
|
||||
size_t offset = 1;
|
||||
fixit const *f = NULL;
|
||||
void const *p = NULL;
|
||||
gl_list_iterator_t iter = gl_list_iterator (fixits);
|
||||
while (gl_list_iterator_next (&iter, (const void**) &f, NULL))
|
||||
while (gl_list_iterator_next (&iter, &p, NULL))
|
||||
{
|
||||
fixit const *f = p;
|
||||
/* Look for the correct line. */
|
||||
while (line < f->location.start.line)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* This file is not compiled in, it is used only to expose more
|
||||
strings to gettextize.
|
||||
|
||||
Why is this needed?
|
||||
|
||||
Bison emits strings to translate in the generated code, for builtin
|
||||
tokens. So they appear only in generated parsers, which are not
|
||||
shipped, so they are not in the src tree, so we cannot use them in
|
||||
our POTFILE.
|
||||
|
||||
Except src/parse-gram.c, which is in the source tree. And even in
|
||||
the git repo. But to avoid useless diffs in the repo, we do not
|
||||
keep the #line directives in the src tree. Yet, for the user, we
|
||||
ship a src/parse-gram.c _with_ the #lines. This is done in a
|
||||
dist-hook which regenerates src/parse-gram.c when we run "make
|
||||
dist".
|
||||
|
||||
Unfortunately, then, update-po traverses the whole tree and sees
|
||||
that the location of the strings to translate in src/parse-gram.c
|
||||
have changed, so the bison.pot is to be updated. And that is not
|
||||
possible in the "make dist" which is run within "make distcheck"
|
||||
(not the one preparing the dist for distcheck, the one run by
|
||||
distcheck to check that a distributed tarball can build a tarball)
|
||||
because then the src tree is read-only.
|
||||
|
||||
So let's not put src/parse-gram.c in the POTFILE, and expose these
|
||||
strings to gettextize by hand.
|
||||
*/
|
||||
|
||||
// Please syntax-check.
|
||||
#include <config.h>
|
||||
|
||||
static const char *const msgid[] =
|
||||
{
|
||||
N_("end of file"),
|
||||
N_("invalid token")
|
||||
}
|
||||
+1
-1
@@ -92,7 +92,7 @@ goto_print (goto_number i, FILE *out)
|
||||
const state_number dst = to_state[i];
|
||||
symbol_number var = states[dst]->accessing_symbol;
|
||||
fprintf (out,
|
||||
"goto[%ld] = (%d, %s, %d)", i, src, symbols[var]->tag, dst);
|
||||
"goto[%zu] = (%d, %s, %d)", i, src, symbols[var]->tag, dst);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+3
-2
@@ -117,6 +117,7 @@ BUILT_SOURCES += \
|
||||
# definition of libbison, beware that they might expand as flags such as
|
||||
# `-lm`. Keep them here. Or use a Libtool convenience library.
|
||||
src_bison_LDADD = \
|
||||
lib/libbison.a \
|
||||
$(ISNAND_LIBM) \
|
||||
$(ISNANF_LIBM) \
|
||||
$(ISNANL_LIBM) \
|
||||
@@ -126,10 +127,10 @@ src_bison_LDADD = \
|
||||
$(LIBTHREAD) \
|
||||
$(LIB_CLOCK_GETTIME) \
|
||||
$(LIB_GETHRXTIME) \
|
||||
$(LIBTEXTSTYLE) \
|
||||
lib/libbison.a
|
||||
$(LIBTEXTSTYLE)
|
||||
|
||||
|
||||
EXTRA_DIST += %D%/i18n-strings.c
|
||||
|
||||
|
||||
## ------ ##
|
||||
|
||||
+6
-21
@@ -186,16 +186,6 @@ xescape_trigraphs (const char *src)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Whether some symbol requires internationalization. */
|
||||
static bool
|
||||
has_translations (void)
|
||||
{
|
||||
for (int i = 0; i < nsyms; i++)
|
||||
if (symbols[i]->translatable)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The tag to show in the generated parsers. Use "end of file" rather
|
||||
than "$end". But keep "$end" in the reports, it's shorter and more
|
||||
consistent. Support i18n if the user already uses it. */
|
||||
@@ -219,11 +209,9 @@ symbol_tag (const symbol *sym)
|
||||
static void
|
||||
prepare_symbol_names (char const *muscle_name)
|
||||
{
|
||||
const bool eof_is_user_defined
|
||||
= !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end");
|
||||
|
||||
// Whether to add a pair of quotes around the name.
|
||||
const bool quote = STREQ (muscle_name, "tname");
|
||||
const bool with_translations = !quote && has_translations ();
|
||||
bool has_translations = false;
|
||||
|
||||
/* We assume that the table will be output starting at column 2. */
|
||||
int col = 2;
|
||||
@@ -233,11 +221,9 @@ prepare_symbol_names (char const *muscle_name)
|
||||
for (int i = 0; i < nsyms; i++)
|
||||
{
|
||||
const char *tag = symbol_tag (symbols[i]);
|
||||
bool translatable =
|
||||
with_translations
|
||||
&& (symbols[i]->translatable
|
||||
|| (!eof_is_user_defined && symbols[i]->content == endtoken->content)
|
||||
|| symbols[i]->content == undeftoken->content);
|
||||
bool translatable = !quote && symbols[i]->translatable;
|
||||
if (translatable)
|
||||
has_translations = true;
|
||||
|
||||
char *cp
|
||||
= tag[0] == '"' && !quote
|
||||
@@ -273,8 +259,7 @@ prepare_symbol_names (char const *muscle_name)
|
||||
muscle_insert (muscle_name, obstack_finish0 (&format_obstack));
|
||||
|
||||
/* Announce whether translation support is needed. */
|
||||
if (!quote)
|
||||
MUSCLE_INSERT_BOOL ("has_translations", with_translations);
|
||||
MUSCLE_INSERT_BOOL ("has_translations_flag", has_translations);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+54
-34
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 3.5.4.236-8d75. */
|
||||
/* A Bison parser, made by GNU Bison 3.6. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||
simplifying the original so-called "semantic" parser. */
|
||||
|
||||
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
||||
especially those whose name start with YY_ or yy_. They are
|
||||
private implementation details that can be changed or removed. */
|
||||
|
||||
/* All symbols defined below should begin with yy or YY, to avoid
|
||||
infringing on user name space. This should be done even for local
|
||||
variables, as they might otherwise be expanded by user macros.
|
||||
@@ -41,14 +45,11 @@
|
||||
define necessary library symbols; they are noted "INFRINGES ON
|
||||
USER NAME SPACE" below. */
|
||||
|
||||
/* Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them. */
|
||||
|
||||
/* Identify Bison output. */
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.5.4.236-8d75"
|
||||
#define YYBISON_VERSION "3.6"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@@ -105,7 +106,7 @@ enum yysymbol_kind_t
|
||||
{
|
||||
YYSYMBOL_YYEMPTY = -2,
|
||||
YYSYMBOL_YYEOF = 0, /* "end of file" */
|
||||
YYSYMBOL_YYERROR = 1, /* error */
|
||||
YYSYMBOL_YYerror = 1, /* error */
|
||||
YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
|
||||
YYSYMBOL_STRING = 3, /* "string" */
|
||||
YYSYMBOL_TSTRING = 4, /* "translatable string" */
|
||||
@@ -407,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;
|
||||
|
||||
@@ -425,6 +427,11 @@ typedef int yy_state_fast_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef N_
|
||||
# define N_(Msgid) Msgid
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef YY_ATTRIBUTE_PURE
|
||||
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
||||
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
@@ -524,7 +531,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# endif
|
||||
# define YYCOPY_NEEDED 1
|
||||
#endif
|
||||
#endif /* 1 */
|
||||
|
||||
#if (! defined yyoverflow \
|
||||
&& (! defined __cplusplus \
|
||||
@@ -643,7 +650,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
{
|
||||
static const char *const yy_sname[] =
|
||||
{
|
||||
N_("end of file"), "error", N_("invalid token"), N_("string"),
|
||||
N_("end of file"), N_("error"), N_("invalid token"), N_("string"),
|
||||
N_("translatable string"), "%token", "%nterm", "%type", "%destructor",
|
||||
"%printer", "%left", "%right", "%nonassoc", "%precedence", "%prec",
|
||||
"%dprec", "%merge", "%code", "%default-prec", "%define", "%defines",
|
||||
@@ -666,11 +673,11 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
"named_ref.opt", "variable", "value", "id", "id_colon", "symbol",
|
||||
"string_as_id", "epilogue.opt", YY_NULLPTR
|
||||
};
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YYTNAME[SYMBOL-NUM] is
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
static yytype_int8 yytranslatable[] =
|
||||
{
|
||||
0, 0, 0, 1, 1, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -684,7 +691,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifdef YYPRINT
|
||||
#ifdef YYPRINT
|
||||
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
||||
(internal) symbol number NUM (which must be that of a token). */
|
||||
static const yytype_int16 yytoknum[] =
|
||||
@@ -697,7 +704,7 @@ static const yytype_int16 yytoknum[] =
|
||||
305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
|
||||
315
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYPACT_NINF (-80)
|
||||
|
||||
@@ -925,6 +932,9 @@ enum { YYENOMEM = -2 };
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Backward compatibility with an undocumented macro.
|
||||
Use GRAM_error or GRAM_UNDEF. */
|
||||
#define YYERRCODE GRAM_UNDEF
|
||||
|
||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
@@ -972,8 +982,8 @@ do { \
|
||||
This macro was not mandated originally: define only if we know
|
||||
we won't break user code: when these are the locations we know. */
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
|
||||
# ifndef YY_LOCATION_PRINT
|
||||
# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
|
||||
|
||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||
|
||||
@@ -1003,22 +1013,22 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
||||
return res;
|
||||
}
|
||||
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
yy_location_print_ (File, &(Loc))
|
||||
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
#endif
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
# endif /* !defined YY_LOCATION_PRINT */
|
||||
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value, Location); \
|
||||
Kind, Value, Location); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -1295,8 +1305,8 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
|
||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||
yy_symbol_print (stderr,
|
||||
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
|
||||
&yyvsp[(yyi + 1) - (yynrhs)]
|
||||
, &(yylsp[(yyi + 1) - (yynrhs)]) );
|
||||
&yyvsp[(yyi + 1) - (yynrhs)],
|
||||
&(yylsp[(yyi + 1) - (yynrhs)]));
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
}
|
||||
@@ -1312,7 +1322,7 @@ do { \
|
||||
int yydebug;
|
||||
#else /* !GRAM_DEBUG */
|
||||
# define YYDPRINTF(Args) ((void) 0)
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
|
||||
# define YY_STACK_PRINT(Bottom, Top)
|
||||
# define YY_REDUCE_PRINT(Rule)
|
||||
#endif /* !GRAM_DEBUG */
|
||||
@@ -1606,7 +1616,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
||||
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
|
||||
{
|
||||
yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
|
||||
if (yysym != YYSYMBOL_YYERROR && yysym != YYSYMBOL_YYUNDEF)
|
||||
if (yysym != YYSYMBOL_YYerror && yysym != YYSYMBOL_YYUNDEF)
|
||||
switch (yy_lac (yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym))
|
||||
{
|
||||
case YYENOMEM:
|
||||
@@ -1622,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;
|
||||
}
|
||||
|
||||
@@ -1901,7 +1913,7 @@ yysetstate:
|
||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
||||
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
||||
# undef YYSTACK_RELOCATE
|
||||
# undef YYSTACK_RELOCATE
|
||||
if (yyss1 != yyssa)
|
||||
YYSTACK_FREE (yyss1);
|
||||
}
|
||||
@@ -1954,6 +1966,17 @@ yybackup:
|
||||
yytoken = YYSYMBOL_YYEOF;
|
||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
||||
}
|
||||
else if (yychar == GRAM_error)
|
||||
{
|
||||
/* The scanner already issued an error message, process directly
|
||||
to error recovery. But do not keep the error token as
|
||||
lookahead, it is too special and may lead us to an endless
|
||||
loop in error recovery. */
|
||||
yychar = GRAM_UNDEF;
|
||||
yytoken = YYSYMBOL_YYerror;
|
||||
yyerror_range[1] = yylloc;
|
||||
goto yyerrlab1;
|
||||
}
|
||||
else
|
||||
{
|
||||
yytoken = YYTRANSLATE (yychar);
|
||||
@@ -2619,7 +2642,6 @@ yyerrlab:
|
||||
/* Make sure we have latest lookahead translation. See comments at
|
||||
user semantic actions for why this is necessary. */
|
||||
yytoken = yychar == GRAM_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
|
||||
|
||||
/* If not already recovering from an error, report this error. */
|
||||
if (!yyerrstatus)
|
||||
{
|
||||
@@ -2635,7 +2657,6 @@ yyerrlab:
|
||||
}
|
||||
|
||||
yyerror_range[1] = yylloc;
|
||||
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
@@ -2684,13 +2705,14 @@ yyerrorlab:
|
||||
yyerrlab1:
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||
|
||||
/* Pop stack until we find a state that shifts the error token. */
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact[yystate];
|
||||
if (!yypact_value_is_default (yyn))
|
||||
{
|
||||
yyn += YYSYMBOL_YYERROR;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYERROR)
|
||||
yyn += YYSYMBOL_YYerror;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -2719,10 +2741,8 @@ yyerrlab1:
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
|
||||
yyerror_range[2] = yylloc;
|
||||
/* Using YYLLOC is tempting, but would change the location of
|
||||
the lookahead. YYLOC is available though. */
|
||||
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
|
||||
*++yylsp = yyloc;
|
||||
++yylsp;
|
||||
YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
|
||||
|
||||
/* Shift the error token. */
|
||||
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
|
||||
|
||||
+5
-4
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 3.5.4.236-8d75. */
|
||||
/* A Bison parser, made by GNU Bison 3.6. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
@@ -31,8 +31,9 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them. */
|
||||
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
||||
especially those whose name start with YY_ or yy_. They are
|
||||
private implementation details that can be changed or removed. */
|
||||
|
||||
#ifndef YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
|
||||
# define YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
|
||||
@@ -79,7 +80,7 @@ extern int gram_debug;
|
||||
{
|
||||
GRAM_EMPTY = -2,
|
||||
GRAM_EOF = 0, /* "end of file" */
|
||||
GRAM_ERRCODE = 1, /* error */
|
||||
GRAM_error = 1, /* error */
|
||||
GRAM_UNDEF = 2, /* "invalid token" */
|
||||
STRING = 3, /* "string" */
|
||||
TSTRING = 4, /* "translatable string" */
|
||||
|
||||
+53
-32
@@ -83,6 +83,23 @@ static boundary scanner_cursor;
|
||||
unput (Msg[i - 1]); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define STRING_GROW_ESCAPE(Char) \
|
||||
do { \
|
||||
long c = Char; \
|
||||
if (0 < c && c <= UCHAR_MAX) \
|
||||
obstack_1grow (&obstack_for_string, c); \
|
||||
else \
|
||||
{ \
|
||||
complain (loc, complaint, \
|
||||
_("invalid number after \\-escape: %s"), \
|
||||
yytext + 1); \
|
||||
/* Avoid additional errors about empty char literal. */ \
|
||||
obstack_1grow (&obstack_for_string, '?'); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* The current file name. Might change with #line. */
|
||||
static uniqstr current_file = NULL;
|
||||
|
||||
@@ -290,6 +307,7 @@ eqopt ({sp}=)?
|
||||
|
||||
"%"{id} {
|
||||
complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
|
||||
return GRAM_error;
|
||||
}
|
||||
|
||||
":" return COLON;
|
||||
@@ -311,6 +329,7 @@ eqopt ({sp}=)?
|
||||
accept "1FOO" as "1 FOO". */
|
||||
{int}{id} {
|
||||
complain (loc, complaint, _("invalid identifier: %s"), quote (yytext));
|
||||
return GRAM_error;
|
||||
}
|
||||
|
||||
/* Characters. */
|
||||
@@ -361,10 +380,11 @@ eqopt ({sp}=)?
|
||||
BEGIN SC_BRACKETED_ID;
|
||||
}
|
||||
|
||||
[^\[%A-Za-z0-9_<>{}\"\'*;|=/, \f\r\n\t\v]+|. {
|
||||
[^\[%A-Za-z0-9_<>{}""''*;|=/, \f\r\n\t\v]+|. {
|
||||
complain (loc, complaint, "%s: %s",
|
||||
ngettext ("invalid character", "invalid characters", yyleng),
|
||||
quote_mem (yytext, yyleng));
|
||||
return GRAM_error;
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
@@ -381,7 +401,11 @@ eqopt ({sp}=)?
|
||||
|
||||
<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_TSTRING,SC_TAG>
|
||||
{
|
||||
\0 complain (loc, complaint, _("invalid null character"));
|
||||
\0 {
|
||||
complain (loc, complaint, _("invalid null character"));
|
||||
STRING_FREE;
|
||||
return GRAM_error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -437,6 +461,7 @@ eqopt ({sp}=)?
|
||||
complain (loc, complaint,
|
||||
_("unexpected identifier in bracketed name: %s"),
|
||||
quote (yytext));
|
||||
return GRAM_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -457,7 +482,10 @@ eqopt ({sp}=)?
|
||||
}
|
||||
}
|
||||
else
|
||||
complain (loc, complaint, _("an identifier expected"));
|
||||
{
|
||||
complain (loc, complaint, _("an identifier expected"));
|
||||
return GRAM_error;
|
||||
}
|
||||
}
|
||||
|
||||
[^\].A-Za-z0-9_/ \f\r\n\t\v]+|. {
|
||||
@@ -465,6 +493,7 @@ eqopt ({sp}=)?
|
||||
ngettext ("invalid character in bracketed name",
|
||||
"invalid characters in bracketed name", yyleng),
|
||||
quote_mem (yytext, yyleng));
|
||||
return GRAM_error;
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
@@ -563,22 +592,27 @@ eqopt ({sp}=)?
|
||||
{
|
||||
"'" {
|
||||
STRING_FINISH;
|
||||
BEGIN INITIAL;
|
||||
loc->start = token_start;
|
||||
val->CHAR = last_string[0];
|
||||
|
||||
/* FIXME: Eventually, make these errors. */
|
||||
if (last_string[0] == '\0')
|
||||
{
|
||||
complain (loc, Wother, _("empty character literal"));
|
||||
/* '\0' seems dangerous even if we are about to complain. */
|
||||
val->CHAR = '\'';
|
||||
}
|
||||
{
|
||||
complain (loc, complaint, _("empty character literal"));
|
||||
STRING_FREE;
|
||||
return GRAM_error;
|
||||
}
|
||||
else if (last_string[1] != '\0')
|
||||
complain (loc, Wother,
|
||||
_("extra characters in character literal"));
|
||||
STRING_FREE;
|
||||
BEGIN INITIAL;
|
||||
return CHAR;
|
||||
{
|
||||
complain (loc, complaint, _("extra characters in character literal"));
|
||||
STRING_FREE;
|
||||
return GRAM_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
STRING_FREE;
|
||||
return CHAR;
|
||||
}
|
||||
}
|
||||
{eol} unexpected_newline (token_start, "'");
|
||||
<<EOF>> unexpected_eof (token_start, "'");
|
||||
@@ -620,22 +654,12 @@ eqopt ({sp}=)?
|
||||
{
|
||||
\\[0-7]{1,3} {
|
||||
verify (UCHAR_MAX < ULONG_MAX);
|
||||
long c = strtol (yytext + 1, NULL, 8);
|
||||
if (0 < c && c <= UCHAR_MAX)
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
else
|
||||
complain (loc, complaint, _("invalid number after \\-escape: %s"),
|
||||
yytext+1);
|
||||
STRING_GROW_ESCAPE (strtol (yytext + 1, NULL, 8));
|
||||
}
|
||||
|
||||
\\x[0-9abcdefABCDEF]+ {
|
||||
verify (UCHAR_MAX < ULONG_MAX);
|
||||
long c = strtol (yytext + 2, NULL, 16);
|
||||
if (0 < c && c <= UCHAR_MAX)
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
else
|
||||
complain (loc, complaint, _("invalid number after \\-escape: %s"),
|
||||
yytext+1);
|
||||
STRING_GROW_ESCAPE (strtol (yytext + 2, NULL, 16));
|
||||
}
|
||||
|
||||
\\a obstack_1grow (&obstack_for_string, '\a');
|
||||
@@ -650,13 +674,9 @@ eqopt ({sp}=)?
|
||||
\\("\""|"'"|"?"|"\\") obstack_1grow (&obstack_for_string, yytext[1]);
|
||||
|
||||
\\(u|U[0-9abcdefABCDEF]{4})[0-9abcdefABCDEF]{4} {
|
||||
int c = convert_ucn_to_byte (yytext);
|
||||
if (c <= 0)
|
||||
complain (loc, complaint, _("invalid number after \\-escape: %s"),
|
||||
yytext+1);
|
||||
else
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
STRING_GROW_ESCAPE (convert_ucn_to_byte (yytext));
|
||||
}
|
||||
|
||||
\\(.|{eol}) {
|
||||
char const *p = yytext + 1;
|
||||
/* Quote only if escaping won't make the character visible. */
|
||||
@@ -666,6 +686,7 @@ eqopt ({sp}=)?
|
||||
p = quotearg_style_mem (escape_quoting_style, p, 1);
|
||||
complain (loc, complaint, _("invalid character after \\-escape: %s"),
|
||||
p);
|
||||
obstack_1grow (&obstack_for_string, '?');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ static void fail_for_invalid_at (char const *at);
|
||||
"@output(" at_init (&argc, argv, &at_ptr, &at_output);
|
||||
|
||||
/* This pattern must not match more than the previous @ patterns. */
|
||||
@[^@{}\'(\n]* fail_for_invalid_at (yytext);
|
||||
@[^@{}''(\n]* fail_for_invalid_at (yytext);
|
||||
\n out_lineno++; ECHO;
|
||||
[^@\n]+ ECHO;
|
||||
|
||||
|
||||
+4
-1
@@ -67,7 +67,10 @@
|
||||
Conflict resolution can decide that certain tokens in certain
|
||||
states should explicitly be errors (for implementing %nonassoc).
|
||||
For each state, the tokens that are errors for this reason are
|
||||
recorded in an errs structure, which holds the token numbers.
|
||||
recorded in an errs structure. The generated parser does not
|
||||
depend on this errs structure, it is used only in the reports
|
||||
(*.output, etc.) to describe conflicted actions that have been
|
||||
discarded.
|
||||
|
||||
There is at least one goto transition present in state zero. It
|
||||
leads to a next-to-final state whose accessing_symbol is the
|
||||
|
||||
+29
-2
@@ -847,8 +847,8 @@ symbols_new (void)
|
||||
accept->content->class = nterm_sym;
|
||||
accept->content->number = nvars++;
|
||||
|
||||
/* Construct the YYERRCODE/"error" token */
|
||||
errtoken = symbol_get ("YYERRCODE", empty_loc);
|
||||
/* Construct the YYerror/"error" token */
|
||||
errtoken = symbol_get ("YYerror", empty_loc);
|
||||
errtoken->content->class = token_sym;
|
||||
errtoken->content->number = ntokens++;
|
||||
{
|
||||
@@ -1095,6 +1095,21 @@ symbols_token_translations_init (void)
|
||||
}
|
||||
|
||||
|
||||
/* Whether some symbol requires internationalization. */
|
||||
static bool
|
||||
has_translations (void)
|
||||
{
|
||||
for (const void *entry = hash_get_first (symbol_table);
|
||||
entry;
|
||||
entry = hash_get_next (symbol_table, entry))
|
||||
{
|
||||
const symbol *sym = (const symbol *) entry;
|
||||
if (sym->translatable)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------.
|
||||
| Assign symbol numbers, and write definition of token names into |
|
||||
| FDEFINES. Set up vectors SYMBOL_TABLE, TAGS of symbols. |
|
||||
@@ -1137,6 +1152,18 @@ symbols_pack (void)
|
||||
complain (&startsymbol_loc, fatal,
|
||||
_("the start symbol %s is a token"),
|
||||
startsymbol->tag);
|
||||
|
||||
// If some user tokens are internationalized, the internal ones
|
||||
// should be too.
|
||||
if (has_translations ())
|
||||
{
|
||||
const bool eof_is_user_defined
|
||||
= !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end");
|
||||
if (!eof_is_user_defined)
|
||||
endtoken->alias->translatable = true;
|
||||
undeftoken->alias->translatable = true;
|
||||
errtoken->alias->translatable = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
+58
-9
@@ -201,8 +201,8 @@ read_integer (]AT_YYLEX_FORMALS[)
|
||||
/* Skip white spaces. */
|
||||
do
|
||||
{
|
||||
]AT_LOCATION_IF(
|
||||
[ AT_LOC_FIRST_COLUMN = AT_LOC_LAST_COLUMN;
|
||||
]AT_LOCATION_IF([
|
||||
AT_LOC_FIRST_COLUMN = AT_LOC_LAST_COLUMN;
|
||||
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
|
||||
])[
|
||||
}
|
||||
@@ -220,6 +220,15 @@ read_integer (]AT_YYLEX_FORMALS[)
|
||||
if (c == EOF)
|
||||
return ]AT_TOKEN_PREFIX[CALC_EOF;
|
||||
|
||||
/* An explicit error raised by the scanner. */
|
||||
if (c == '#')
|
||||
{]AT_LOCATION_IF([
|
||||
fprintf (stderr, "%d.%d: ",
|
||||
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);])[
|
||||
fputs ("syntax error: invalid character: '#'\n", stderr);
|
||||
return ]AT_TOKEN_PREFIX[]AT_API_PREFIX[error;
|
||||
}
|
||||
|
||||
/* Return single chars. */
|
||||
return c;
|
||||
}
|
||||
@@ -304,7 +313,7 @@ class CalcLexer(R) : Lexer
|
||||
location.end.column += 1;]])[
|
||||
}
|
||||
|
||||
// Handle EOF.
|
||||
// EOF.
|
||||
if (input.empty)
|
||||
return TokenKind.CALC_EOF;
|
||||
|
||||
@@ -325,6 +334,14 @@ class CalcLexer(R) : Lexer
|
||||
else
|
||||
location.end.column += 1;]])[
|
||||
input.popFront;
|
||||
|
||||
// An explicit error raised by the scanner. */
|
||||
if (c == '#')
|
||||
{
|
||||
stderr.writeln (]AT_LOCATION_IF([location, ": ", ])["syntax error: invalid character: '#'");
|
||||
return TokenKind.YYerror;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -370,12 +387,12 @@ m4_define([AT_CALC_YYLEX(java)],
|
||||
|
||||
public int yylex () throws IOException {;]AT_LOCATION_IF([[
|
||||
start.set (reader.getPosition ());]])[
|
||||
int ttype = st.nextToken ();]AT_LOCATION_IF([[
|
||||
int tkind = st.nextToken ();]AT_LOCATION_IF([[
|
||||
end.set (reader.getPosition ());]])[
|
||||
switch (ttype)
|
||||
switch (tkind)
|
||||
{
|
||||
case StreamTokenizer.TT_EOF:
|
||||
return EOF;
|
||||
return CALC_EOF;
|
||||
case StreamTokenizer.TT_EOL:;]AT_LOCATION_IF([[
|
||||
end.line += 1;
|
||||
end.column = 0;]])[
|
||||
@@ -386,8 +403,11 @@ m4_define([AT_CALC_YYLEX(java)],
|
||||
return NUM;
|
||||
case ' ': case '\t':
|
||||
return yylex ();
|
||||
case '#':
|
||||
System.err.println(]AT_LOCATION_IF([[start + ": " + ]])["syntax error: invalid character: '#'");
|
||||
return YYerror;
|
||||
default:
|
||||
return ttype;
|
||||
return tkind;
|
||||
}
|
||||
}
|
||||
]AT_LEXPARAM_IF([], [[}]])[
|
||||
@@ -763,8 +783,8 @@ AT_JAVA_IF(
|
||||
[AT_PARSER_CHECK([calc input], 0, [AT_PARAM_IF([m4_n([$3])])], [stderr])])
|
||||
AT_LANG_MATCH([c\|c++\|java],
|
||||
[AT_GLR_IF([],
|
||||
[AT_CHECK([grep -v 'Return for a new token:' stderr | wc -l],
|
||||
[0],
|
||||
[AT_CHECK([grep -c -v 'Return for a new token:' stderr],
|
||||
[ignore],
|
||||
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
|
||||
])
|
||||
|
||||
@@ -1004,6 +1024,35 @@ _AT_CHECK_CALC_ERROR([$1], [0], [(* *) + (*) + (*)],
|
||||
]AT_JAVA_IF([1.10-1.11], [1.10])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])
|
||||
]AT_JAVA_IF([1.16-1.17], [1.16])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])]])
|
||||
|
||||
|
||||
# YYerror.
|
||||
# --------
|
||||
# Check that returning YYerror from the scanner properly enters
|
||||
# error-recovery without issuing a second error message.
|
||||
|
||||
_AT_CHECK_CALC_ERROR([$1], [0], [(#) + (#) = 2222],
|
||||
[[final: 2222 0 0]],
|
||||
[102],
|
||||
[[1.2: syntax error: invalid character: '#'
|
||||
1.8: syntax error: invalid character: '#']])
|
||||
|
||||
_AT_CHECK_CALC_ERROR([$1], [0], [(1 + #) = 1111],
|
||||
[[final: 1111 0 0]],
|
||||
[102],
|
||||
[[1.6: syntax error: invalid character: '#']])
|
||||
|
||||
_AT_CHECK_CALC_ERROR([$1], [0], [(# + 1) = 1111],
|
||||
[[final: 1111 0 0]],
|
||||
[102],
|
||||
[[1.2: syntax error: invalid character: '#']])
|
||||
|
||||
_AT_CHECK_CALC_ERROR([$1], [0], [(1 + # + 1) = 1111],
|
||||
[[final: 1111 0 0]],
|
||||
[102],
|
||||
[[1.6: syntax error: invalid character: '#']])
|
||||
|
||||
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
+27
-13
@@ -19,7 +19,7 @@ AT_BANNER([[Diagnostics.]])
|
||||
|
||||
|
||||
# AT_TEST($1: TITLE, $2: GRAMMAR, $3: EXIT-STATUS, $4: OUTPUT-WITH-STYLE,
|
||||
# $5: EXTRA_ENV
|
||||
# $5: EXTRA_ENV, $6: SKIP-IF)
|
||||
# -----------------------------------------------------------------------
|
||||
# Run Bison on GRAMMAR with debugging style enabled, and expect
|
||||
# OUTPUT-WITH-STYLE as diagnostics.
|
||||
@@ -33,6 +33,9 @@ AT_KEYWORDS([diagnostics])
|
||||
locale=`locale -a | $EGREP '^en_US\.(UTF-8|utf8)$' | sed 1q`
|
||||
AT_SKIP_IF([test x == x"$locale"])
|
||||
|
||||
m4_ifval([$6],
|
||||
[AT_SKIP_IF([$6])])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS
|
||||
|
||||
AT_DATA_GRAMMAR([[input.y]], [$2])
|
||||
@@ -220,15 +223,14 @@ exp: an\005error.
|
||||
|
||||
AT_TEST([[Tabulations and multibyte characters]],
|
||||
[[%%
|
||||
exp: a b c d e f g h
|
||||
exp: a b c d e f g
|
||||
a: { }
|
||||
b: { }
|
||||
c: {------------}
|
||||
d: {éééééééééééé}
|
||||
e: {∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}
|
||||
f: { 42 }
|
||||
g: { "฿¥$€₦" }
|
||||
h: { 🐃 }
|
||||
e: { 42 }
|
||||
f: { "฿¥$€₦" }
|
||||
g: { 🐃 }
|
||||
]],
|
||||
[0],
|
||||
[[input.y:11.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
||||
@@ -248,25 +250,37 @@ input.y:14.4-17: <warning>warning:</warning> empty rule without %empty [<warning
|
||||
| <warning>^~~~~~~~~~~~~~</warning>
|
||||
| <fixit-insert>%empty</fixit-insert>
|
||||
input.y:15.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
||||
15 | e: <warning>{∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}</warning>
|
||||
15 | e: <warning>{ 42 }</warning>
|
||||
| <warning>^~~~~~~~~~~~~~</warning>
|
||||
| <fixit-insert>%empty</fixit-insert>
|
||||
input.y:16.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
||||
16 | f: <warning>{ 42 }</warning>
|
||||
16 | f: <warning>{ "฿¥$€₦" }</warning>
|
||||
| <warning>^~~~~~~~~~~~~~</warning>
|
||||
| <fixit-insert>%empty</fixit-insert>
|
||||
input.y:17.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
||||
17 | g: <warning>{ "฿¥$€₦" }</warning>
|
||||
| <warning>^~~~~~~~~~~~~~</warning>
|
||||
| <fixit-insert>%empty</fixit-insert>
|
||||
input.y:18.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
||||
18 | h: <warning>{ 🐃 }</warning>
|
||||
17 | g: <warning>{ 🐃 }</warning>
|
||||
| <warning>^~~~~~~~~~~~~~</warning>
|
||||
| <fixit-insert>%empty</fixit-insert>
|
||||
input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
|
||||
]])
|
||||
|
||||
|
||||
# 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]],
|
||||
[[%%
|
||||
e: {∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}
|
||||
]],
|
||||
[0],
|
||||
[[input.y:10.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
||||
10 | e: <warning>{∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}</warning>
|
||||
| <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 | $EGREP -i 'aix|cygwin'])
|
||||
|
||||
|
||||
## --------------- ##
|
||||
## Special files. ##
|
||||
## --------------- ##
|
||||
|
||||
+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
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ AT_PERL_CHECK([[-n -0777 -e '
|
||||
|YYChar
|
||||
|YYNTOKENS # This is actual scoped in a C++ class.
|
||||
|YYPUSH_MORE(?:_DEFINED)?
|
||||
|S_(YY(ACCEPT|EMPTY|EOF|ERROR|UNDEF)) # These guys are scoped.
|
||||
|S_(YY(ACCEPT|EMPTY|EOF|error|UNDEF)) # These guys are scoped.
|
||||
|YYUSE
|
||||
|YY_ATTRIBUTE(?:_PURE|_UNUSED)
|
||||
|YY(?:_REINTERPRET)?_CAST
|
||||
|
||||
+30
-24
@@ -102,7 +102,6 @@ input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
|
||||
input.y:7.1: error: invalid character: '%'
|
||||
input.y:7.2: error: invalid character: '-'
|
||||
input.y:8.1-9.0: error: missing '%}' at end of file
|
||||
input.y:8.1-9.0: error: unexpected %{...%}
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -343,9 +342,9 @@ exp:
|
||||
%%
|
||||
int main (void)
|
||||
{
|
||||
assert (YYERRCODE == 123);
|
||||
assert (YYerror == 123);
|
||||
assert (YYTRANSLATE (YYEOF) == YYSYMBOL_YYEOF);
|
||||
assert (YYTRANSLATE (YYERRCODE) == YYSYMBOL_YYERROR);
|
||||
assert (YYTRANSLATE (YYerror) == YYSYMBOL_YYerror);
|
||||
assert (YYTRANSLATE (YYUNDEF) == YYSYMBOL_YYUNDEF);
|
||||
return 0;
|
||||
}
|
||||
@@ -432,7 +431,7 @@ AT_BISON_CHECK([-Wno-other -S./dump-symbols.m4 input.y])
|
||||
AT_CHECK([cat symbols.csv], [],
|
||||
[[number, class, tag, id, user_number, type,
|
||||
0, Token, "end of file", YYEOF, 0, ,
|
||||
1, Token, error, YYERRCODE, 256, ,
|
||||
1, Token, error, YYerror, 256, ,
|
||||
2, Token, "invalid token", YYUNDEF, 257, ,
|
||||
3, Token, 'a', , 97, ,
|
||||
4, Token, "A1", A1, 1, ,
|
||||
@@ -1353,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.";
|
||||
|
||||
@@ -1425,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
|
||||
@@ -2339,19 +2355,19 @@ start: '
|
||||
start: ']])
|
||||
|
||||
AT_BISON_CHECK([-fcaret empty.y], [1], [],
|
||||
[[empty.y:2.8-9: warning: empty character literal [-Wother]
|
||||
[[empty.y:2.8-9: error: empty character literal
|
||||
2 | start: '';
|
||||
| ^~
|
||||
empty.y:3.8-4.0: error: missing "'" at end of line
|
||||
3 | start: '
|
||||
| ^
|
||||
empty.y:3.8-4.0: warning: empty character literal [-Wother]
|
||||
empty.y:3.8-4.0: error: empty character literal
|
||||
3 | start: '
|
||||
| ^
|
||||
empty.y:4.8: error: missing "'" at end of file
|
||||
4 | start: '
|
||||
| ^
|
||||
empty.y:4.8: warning: empty character literal [-Wother]
|
||||
empty.y:4.8: error: empty character literal
|
||||
4 | start: '
|
||||
| ^
|
||||
]])
|
||||
@@ -2363,11 +2379,11 @@ start: 'ab
|
||||
start: 'ab]])
|
||||
|
||||
AT_BISON_CHECK([two.y], [1], [],
|
||||
[[two.y:2.8-11: warning: extra characters in character literal [-Wother]
|
||||
[[two.y:2.8-11: error: extra characters in character literal
|
||||
two.y:3.8-4.0: error: missing "'" at end of line
|
||||
two.y:3.8-4.0: warning: extra characters in character literal [-Wother]
|
||||
two.y:3.8-4.0: error: extra characters in character literal
|
||||
two.y:4.8-10: error: missing "'" at end of file
|
||||
two.y:4.8-10: warning: extra characters in character literal [-Wother]
|
||||
two.y:4.8-10: error: extra characters in character literal
|
||||
]])
|
||||
|
||||
AT_DATA_NO_FINAL_EOL([three.y],
|
||||
@@ -2377,11 +2393,11 @@ start: 'abc
|
||||
start: 'abc]])
|
||||
|
||||
AT_BISON_CHECK([three.y], [1], [],
|
||||
[[three.y:2.8-12: warning: extra characters in character literal [-Wother]
|
||||
[[three.y:2.8-12: error: extra characters in character literal
|
||||
three.y:3.8-4.0: error: missing "'" at end of line
|
||||
three.y:3.8-4.0: warning: extra characters in character literal [-Wother]
|
||||
three.y:3.8-4.0: error: extra characters in character literal
|
||||
three.y:4.8-11: error: missing "'" at end of file
|
||||
three.y:4.8-11: warning: extra characters in character literal [-Wother]
|
||||
three.y:4.8-11: error: extra characters in character literal
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -2408,25 +2424,15 @@ AT_PERL_REQUIRE([[-e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y]])
|
||||
|
||||
AT_BISON_CHECK([input.y], [1], [],
|
||||
[[input.y:2.9-12: error: invalid number after \-escape: 777
|
||||
input.y:2.8-13: warning: empty character literal [-Wother]
|
||||
input.y:2.16-17: error: invalid number after \-escape: 0
|
||||
input.y:2.15-18: warning: empty character literal [-Wother]
|
||||
input.y:2.21-25: error: invalid number after \-escape: xfff
|
||||
input.y:2.20-26: warning: empty character literal [-Wother]
|
||||
input.y:2.29-31: error: invalid number after \-escape: x0
|
||||
input.y:2.28-32: warning: empty character literal [-Wother]
|
||||
input.y:3.9-14: error: invalid number after \-escape: uffff
|
||||
input.y:3.8-15: warning: empty character literal [-Wother]
|
||||
input.y:3.18-23: error: invalid number after \-escape: u0000
|
||||
input.y:3.17-24: warning: empty character literal [-Wother]
|
||||
input.y:3.27-36: error: invalid number after \-escape: Uffffffff
|
||||
input.y:3.26-37: warning: empty character literal [-Wother]
|
||||
input.y:3.40-49: error: invalid number after \-escape: U00000000
|
||||
input.y:3.39-50: warning: empty character literal [-Wother]
|
||||
input.y:4.9-10: error: invalid character after \-escape: ' '
|
||||
input.y:4.8-11: warning: empty character literal [-Wother]
|
||||
input.y:4.14-15: error: invalid character after \-escape: A
|
||||
input.y:4.13-16: warning: empty character literal [-Wother]
|
||||
input.y:5.9-16: error: invalid character after \-escape: \t
|
||||
input.y:5.17: error: invalid character after \-escape: \f
|
||||
input.y:5.18: error: invalid character after \-escape: \0
|
||||
|
||||
+37
-37
@@ -18,9 +18,9 @@
|
||||
AT_BANNER([[Java Calculator.]])
|
||||
|
||||
|
||||
# ------------------------- #
|
||||
# Java invalid directives. #
|
||||
# ------------------------- #
|
||||
## ------------------------- ##
|
||||
## Java invalid directives. ##
|
||||
## ------------------------- ##
|
||||
|
||||
AT_SETUP([Java invalid directives])
|
||||
|
||||
@@ -42,9 +42,9 @@ YYParser.y:4.13-30: error: %destructor does not make sense in Java
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ------------------------- #
|
||||
# Helping Autotest macros. #
|
||||
# ------------------------- #
|
||||
## ------------------------- ##
|
||||
## Helping Autotest macros. ##
|
||||
## ------------------------- ##
|
||||
|
||||
|
||||
# AT_JAVA_POSITION_DEFINE_OLD
|
||||
@@ -91,9 +91,9 @@ m4_define([AT_JAVA_POSITION_DEFINE_OLD],
|
||||
|
||||
|
||||
|
||||
# -----------------#
|
||||
# Java Parameters. #
|
||||
# -----------------#
|
||||
## ----------------- ##
|
||||
## Java Parameters. ##
|
||||
## ----------------- ##
|
||||
|
||||
AT_BANNER([Java Parameters.])
|
||||
|
||||
@@ -146,7 +146,7 @@ m4_define([AT_CHECK_JAVA_MINIMAL_W_LEXER],
|
||||
System.err.println (loc + ": " + s);
|
||||
}
|
||||
|
||||
public int yylex ()$2
|
||||
public int yylex()$2
|
||||
{
|
||||
$3
|
||||
}
|
||||
@@ -164,9 +164,9 @@ m4_define([AT_CHECK_JAVA_GREP],
|
||||
])])
|
||||
|
||||
|
||||
# ------------------------------------- #
|
||||
# Java parser class and package names. #
|
||||
# ------------------------------------- #
|
||||
## ------------------------------------- ##
|
||||
## Java parser class and package names. ##
|
||||
## ------------------------------------- ##
|
||||
|
||||
AT_SETUP([Java parser class and package names])
|
||||
|
||||
@@ -191,9 +191,9 @@ AT_CHECK_JAVA_GREP([[package user_java_package;]])
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ----------------------------- #
|
||||
# Java parser class modifiers. #
|
||||
# ----------------------------- #
|
||||
## ----------------------------- ##
|
||||
## Java parser class modifiers. ##
|
||||
## ----------------------------- ##
|
||||
|
||||
AT_SETUP([Java parser class modifiers])
|
||||
|
||||
@@ -255,9 +255,9 @@ AT_CHECK_JAVA_GREP([[/\*@Deprecated @SuppressWarnings("unchecked") @SuppressWarn
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ---------------------------------------- #
|
||||
# Java parser class extends and implements #
|
||||
# ---------------------------------------- #
|
||||
## ---------------------------------------- ##
|
||||
## Java parser class extends and implements ##
|
||||
## ---------------------------------------- ##
|
||||
|
||||
AT_SETUP([Java parser class extends and implements])
|
||||
|
||||
@@ -275,9 +275,9 @@ AT_CHECK_JAVA_GREP([[class YYParser extends Thread implements Cloneable]])
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# -------------------------------- #
|
||||
# Java %parse-param and %lex-param #
|
||||
# -------------------------------- #
|
||||
## -------------------------------- ##
|
||||
## Java %parse-param and %lex-param ##
|
||||
## -------------------------------- ##
|
||||
|
||||
AT_SETUP([Java %parse-param and %lex-param])
|
||||
|
||||
@@ -349,9 +349,9 @@ AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2])
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ------------------------- #
|
||||
# Java throw specifications #
|
||||
# ------------------------- #
|
||||
## --------------------------- ##
|
||||
## Java throw specifications. ##
|
||||
## --------------------------- ##
|
||||
|
||||
AT_SETUP([Java throws specifications])
|
||||
|
||||
@@ -430,17 +430,17 @@ AT_JT_initial_action],
|
||||
[AT_JT_yylex_action],
|
||||
[],
|
||||
[AT_JT_parse_action])])
|
||||
AT_CHECK_JAVA_GREP([[ *int yylex ()]AT_JT_yylex_throws *[;]])
|
||||
AT_CHECK_JAVA_GREP([[ *private int yyaction ([^)]*)]AT_JT_yyaction_throws[ *]])
|
||||
AT_CHECK_JAVA_GREP([[ *public boolean parse ()]AT_JT_parse_throws[ *]])
|
||||
AT_CHECK_JAVA_GREP([[ *int yylex()]AT_JT_yylex_throws *[;]])
|
||||
AT_CHECK_JAVA_GREP([[ *private int yyaction([^)]*)]AT_JT_yyaction_throws[ *]])
|
||||
AT_CHECK_JAVA_GREP([[ *public boolean parse()]AT_JT_parse_throws[ *]])
|
||||
])])])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ------------------------------------- #
|
||||
# Java constructor init and init_throws #
|
||||
# ------------------------------------- #
|
||||
## --------------------------------------- ##
|
||||
## Java constructor init and init_throws. ##
|
||||
## --------------------------------------- ##
|
||||
|
||||
AT_SETUP([Java constructor init and init_throws])
|
||||
|
||||
@@ -465,9 +465,9 @@ m4_popdef([AT_Witness])
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ------------------------------------------ #
|
||||
# Java value, position, and location types. #
|
||||
# ------------------------------------------ #
|
||||
## ------------------------------------------ ##
|
||||
## Java value, position, and location types. ##
|
||||
## ------------------------------------------ ##
|
||||
|
||||
AT_SETUP([Java value, position, and location types])
|
||||
|
||||
@@ -496,9 +496,9 @@ AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep -w 'Location']], [1], [ignore
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ----------------------------------------------- #
|
||||
# Java syntax error handling without error token. #
|
||||
# ----------------------------------------------- #
|
||||
## ------------------------------------------------ ##
|
||||
## Java syntax error handling without error token. ##
|
||||
## ------------------------------------------------ ##
|
||||
|
||||
AT_SETUP([Java syntax error handling without error token])
|
||||
|
||||
|
||||
+6
-6
@@ -180,28 +180,28 @@ AT_DATA([[input.y]],
|
||||
# Verify that the proper procedure(s) are generated for each case.
|
||||
AT_BISON_CHECK([[-Dapi.push-pull=pull -o Main.java input.y]])
|
||||
AT_CHECK_JAVA_GREP([[Main.java]],
|
||||
[[.*public boolean parse ().*]],
|
||||
[[.*public boolean parse().*]],
|
||||
[1])
|
||||
# If BISON_USE_PUSH_FOR_PULL is set, then we have one occurrence of
|
||||
# this function, otherwise it should not be there.
|
||||
AT_CHECK_JAVA_GREP([[Main.java]],
|
||||
[[.*public int push_parse (int yylextoken, Object yylexval).*]],
|
||||
[[.*public int push_parse(int yylextoken, Object yylexval).*]],
|
||||
[${BISON_USE_PUSH_FOR_PULL-0}])
|
||||
|
||||
AT_BISON_CHECK([[-Dapi.push-pull=both -o Main.java input.y]])
|
||||
AT_CHECK_JAVA_GREP([[Main.java]],
|
||||
[[.*public boolean parse ().*]],
|
||||
[[.*public boolean parse().*]],
|
||||
[1])
|
||||
AT_CHECK_JAVA_GREP([[Main.java]],
|
||||
[[.*public int push_parse (int yylextoken, Object yylexval).*]],
|
||||
[[.*public int push_parse(int yylextoken, Object yylexval).*]],
|
||||
[1])
|
||||
|
||||
AT_BISON_CHECK([[-Dapi.push-pull=push -o Main.java input.y]])
|
||||
AT_CHECK_JAVA_GREP([[Main.java]],
|
||||
[[.*public boolean parse ().*]],
|
||||
[[.*public boolean parse().*]],
|
||||
[0])
|
||||
AT_CHECK_JAVA_GREP([[Main.java]],
|
||||
[[.*public int push_parse (int yylextoken, Object yylexval).*]],
|
||||
[[.*public int push_parse(int yylextoken, Object yylexval).*]],
|
||||
[1])
|
||||
|
||||
AT_JAVA_COMPILE([[Main.java]])
|
||||
|
||||
+12
-2
@@ -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
|
||||
[}
|
||||
]])
|
||||
@@ -1601,7 +1611,7 @@ $9
|
||||
# (C90 and C++98) guarantee: 32767. In that case, GCC's -pedantic
|
||||
# will issue an error.
|
||||
#
|
||||
# There is no "" around `wc` since some indent the result.
|
||||
# There is no "" around `wc` since some wc indent the result.
|
||||
m4_bmatch([$4], [%define lr.type canonical-lr],
|
||||
[if test 32767 -lt `wc -l < input.c`; then
|
||||
CFLAGS=`echo " $CFLAGS " | sed -e 's/ -pedantic / /'`
|
||||
|
||||
@@ -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