mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 10:15:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b948b7696 | ||
|
|
8b5fb7c4c3 | ||
|
|
d6ae95fb50 | ||
|
|
e86b14069d | ||
|
|
5d983253f7 | ||
|
|
caadfc552b | ||
|
|
c4c25e091c | ||
|
|
fc18b4313a | ||
|
|
758172a8b9 | ||
|
|
e9454c3456 | ||
|
|
8f01cf0269 | ||
|
|
dab08da605 | ||
|
|
8cedb4b40e | ||
|
|
258c2c967f | ||
|
|
9a33570493 | ||
|
|
42ab6c1e44 | ||
|
|
dc1035bada | ||
|
|
71e3f6d4da | ||
|
|
3877b7210e | ||
|
|
64aec0a8d8 | ||
|
|
5e2e9af56d | ||
|
|
7a226860ef | ||
|
|
c973361138 | ||
|
|
5839f4d289 | ||
|
|
ffa46e6516 | ||
|
|
ff50f6f223 | ||
|
|
05be0fef95 | ||
|
|
72c9fa4510 | ||
|
|
a555b41990 | ||
|
|
ecf5cb7e0e | ||
|
|
e50de09886 | ||
|
|
95421df67b | ||
|
|
a4ed94bc13 | ||
|
|
07726f1178 | ||
|
|
e78596955d | ||
|
|
ecd5cae2d4 | ||
|
|
8dcc25a1e4 | ||
|
|
1a5f74d2f6 | ||
|
|
00a654c8ad | ||
|
|
6c5f690da4 | ||
|
|
007e1b5f0a | ||
|
|
bbb9750b3e | ||
|
|
52d0e77c2c | ||
|
|
088d5668a9 | ||
|
|
87579e03e0 | ||
|
|
11225a5d2f | ||
|
|
3dcfb4fd88 | ||
|
|
c0ccb8e5b4 | ||
|
|
79f967ac0d | ||
|
|
0f6ab8e692 | ||
|
|
e657f04b62 | ||
|
|
10e61eec6d | ||
|
|
149e280aab | ||
|
|
e9fddab715 | ||
|
|
cc68bbf799 | ||
|
|
f0bb82ae9e | ||
|
|
04d62346f3 | ||
|
|
9b70d69f39 | ||
|
|
2b7bde9d13 | ||
|
|
ff2fc62138 | ||
|
|
2c05fc750a | ||
|
|
57bc3c9013 | ||
|
|
7aee4586ca | ||
|
|
6c44f2dce3 | ||
|
|
5604903f7a | ||
|
|
225a67321b | ||
|
|
4e3c06b0f8 | ||
|
|
4e26809ab9 | ||
|
|
678853da7e | ||
|
|
76e11b5a3e | ||
|
|
f9c73eec5f | ||
|
|
f6dcecb287 | ||
|
|
ad31c3cdf4 | ||
|
|
7fa23136ca | ||
|
|
961ea2ac85 | ||
|
|
cc6e5cf854 | ||
|
|
1376a7c6e2 | ||
|
|
1c273826d4 | ||
|
|
4a55a5ea9a | ||
|
|
72f04ca80f | ||
|
|
fd98afaf10 | ||
|
|
cca8c73431 | ||
|
|
cb40f5c624 | ||
|
|
6c23b012b9 | ||
|
|
ef88dfba81 | ||
|
|
6e89bc0fd2 | ||
|
|
e3e21cc0d8 | ||
|
|
a0ee2a7543 | ||
|
|
7e28dbea11 | ||
|
|
65df8d6747 | ||
|
|
beea39b2ec | ||
|
|
086506bf23 | ||
|
|
39792f57fb | ||
|
|
65bbaf9598 | ||
|
|
9039c571f4 | ||
|
|
d3db22d788 | ||
|
|
9434571f95 | ||
|
|
0cdbcee0ce | ||
|
|
fd37eb057e | ||
|
|
ecc3a13c34 | ||
|
|
04904e4d28 | ||
|
|
75a605454d | ||
|
|
d7f39ac507 | ||
|
|
f3c18c8e80 | ||
|
|
00c80bc96c | ||
|
|
f62f1db298 | ||
|
|
3ba001baac | ||
|
|
4140320a0a | ||
|
|
af19fd7e0f | ||
|
|
2c74872991 | ||
|
|
50517d578c | ||
|
|
59d820d1ef | ||
|
|
90f0500ef8 | ||
|
|
17a9542c4f | ||
|
|
b7045aa706 | ||
|
|
ee56b6e0f2 | ||
|
|
1edc98f793 | ||
|
|
4192de1f41 | ||
|
|
00b0d02955 | ||
|
|
1045c8d0ef | ||
|
|
ef8965b5f5 | ||
|
|
84b1972c96 | ||
|
|
1079595b2a | ||
|
|
e364bcdbc5 | ||
|
|
5a8db8a739 | ||
|
|
5acc29041e | ||
|
|
5b0b0a1e08 | ||
|
|
1c694e08cc | ||
|
|
4cfb067d93 | ||
|
|
cf60d0a617 | ||
|
|
c0e8489605 | ||
|
|
788b1a6858 | ||
|
|
56414791e9 | ||
|
|
675dcf1962 | ||
|
|
466fb66578 | ||
|
|
cbb967dbad | ||
|
|
44ac18d136 | ||
|
|
0c3dd3a669 | ||
|
|
951da960e6 | ||
|
|
15ea35019f | ||
|
|
f49684a577 | ||
|
|
044ad1288c | ||
|
|
e3812bb8c3 | ||
|
|
cfcd823e16 | ||
|
|
2f02d9beae | ||
|
|
b638603477 | ||
|
|
e21ff47f5d | ||
|
|
b82b387da9 | ||
|
|
641e326303 | ||
|
|
192e9fdf77 | ||
|
|
a4a3f08c11 | ||
|
|
666df338a7 | ||
|
|
b437b16603 | ||
|
|
b493c173c9 | ||
|
|
aab3feb5a1 | ||
|
|
b7942f2661 | ||
|
|
cefb538ab0 | ||
|
|
ecd922024e | ||
|
|
2353ce7216 | ||
|
|
9cc76ee62c | ||
|
|
2f83ef57f3 | ||
|
|
744171ddbf | ||
|
|
4fd3282dd7 | ||
|
|
67793793e8 | ||
|
|
f334775dbf | ||
|
|
feb1011c8b | ||
|
|
99bedadf23 | ||
|
|
79c3f2b8fd | ||
|
|
4cca30d2e6 | ||
|
|
5789f9d91e | ||
|
|
b269a45fa4 | ||
|
|
1478fccd23 | ||
|
|
535281f0ff | ||
|
|
c4a7e7a1ab | ||
|
|
388e12ac0f | ||
|
|
b870d5fee4 | ||
|
|
30d01b21e7 | ||
|
|
c2cca46795 | ||
|
|
879530cb95 | ||
|
|
72acecb30c | ||
|
|
d4fcd5c3d0 | ||
|
|
368fcf0af5 | ||
|
|
6fe063da8f | ||
|
|
296660304c | ||
|
|
323731ff74 | ||
|
|
6f7f949708 | ||
|
|
15e57d9108 | ||
|
|
30ba94081c | ||
|
|
0e7bc7a6d8 | ||
|
|
eff4d16175 | ||
|
|
b0e11f4523 | ||
|
|
d9b2270bed | ||
|
|
7a28659495 | ||
|
|
e09a72eeb0 | ||
|
|
a09d0ae4d1 | ||
|
|
1e25cb44d1 | ||
|
|
3ed42d2487 | ||
|
|
26c5f48c1c | ||
|
|
7f921d18dd | ||
|
|
cc3760ef51 | ||
|
|
2f23ca6f65 | ||
|
|
468b68c5cd | ||
|
|
9ed802a026 | ||
|
|
fb554c2804 | ||
|
|
47850d4f58 | ||
|
|
57b035a242 | ||
|
|
e7a202d762 | ||
|
|
11e2b755f0 | ||
|
|
f3d33c3613 | ||
|
|
163a35d6dd | ||
|
|
cdb42f7730 | ||
|
|
126252333d | ||
|
|
8637f2c7d6 | ||
|
|
6946149701 | ||
|
|
1368b9dbc9 | ||
|
|
0e96eaf612 | ||
|
|
77bdcc6f0c | ||
|
|
57647bb656 | ||
|
|
63cd2918ff | ||
|
|
d810aa3d8f | ||
|
|
ed1eedbbcb | ||
|
|
bc74b4b15a | ||
|
|
8dd8137c38 | ||
|
|
1388e5b276 | ||
|
|
6f5465c917 | ||
|
|
bb02acc2ed | ||
|
|
80a4389377 | ||
|
|
ef097719ea | ||
|
|
0c90c59795 | ||
|
|
18a7cfc7cf | ||
|
|
088356cb2f | ||
|
|
52db24b2bc | ||
|
|
650b253843 | ||
|
|
7781254e01 | ||
|
|
fa226d773c | ||
|
|
1cc83505c5 | ||
|
|
2d97fe86fd | ||
|
|
3239866f4a | ||
|
|
ebab1ffca8 | ||
|
|
f705e9abdb | ||
|
|
d6f576102e | ||
|
|
0f587e9931 | ||
|
|
48be689a73 | ||
|
|
d727e0ff23 | ||
|
|
37aeda6fb3 | ||
|
|
bba2f0a3a0 | ||
|
|
fe14fb1c40 | ||
|
|
88d1ab421a | ||
|
|
edf495b38e | ||
|
|
ba69beafac | ||
|
|
c16fcaf2fb | ||
|
|
7e99f67592 | ||
|
|
d5f929d407 | ||
|
|
c5b215b5e6 | ||
|
|
0774b2c6e3 | ||
|
|
493359b758 | ||
|
|
23ba9e5dfa | ||
|
|
792fc34016 | ||
|
|
c4a08d1899 | ||
|
|
50fb1e6e0c | ||
|
|
6bd0527a50 | ||
|
|
1aa9d40b24 | ||
|
|
a1da9b9fe8 | ||
|
|
c80cdf2db2 | ||
|
|
3197d0fac9 | ||
|
|
78e43ce8ff | ||
|
|
fe23e19323 | ||
|
|
f374310119 | ||
|
|
7bfff37f01 | ||
|
|
26fba6fc94 | ||
|
|
c592202345 | ||
|
|
0917f4dc76 | ||
|
|
0f792833c2 | ||
|
|
b62e063df5 | ||
|
|
e6b0612f91 | ||
|
|
2eb3328afc | ||
|
|
81849520cd | ||
|
|
fc2191f137 | ||
|
|
6fb362c87a | ||
|
|
46ab1d0cbe | ||
|
|
f54a5b303b | ||
|
|
2cc361387c | ||
|
|
e6d1289f4a | ||
|
|
16c77b4ba2 | ||
|
|
1587a5ea9b | ||
|
|
4ab2cf7450 | ||
|
|
172f103c1e | ||
|
|
6ada985ff3 | ||
|
|
2e12257803 | ||
|
|
1db962716a | ||
|
|
9096955fba | ||
|
|
e9d404415a | ||
|
|
d9df62bfcd | ||
|
|
adac9a17f0 | ||
|
|
3b4b157369 | ||
|
|
5c332d70d7 | ||
|
|
91247f50d7 | ||
|
|
f443673450 | ||
|
|
8e6233353f | ||
|
|
e5a5da16ed | ||
|
|
ebe427bbf3 | ||
|
|
7e3a513d88 | ||
|
|
57f64ebbf8 | ||
|
|
c8d997cb5f | ||
|
|
61b8a8def5 | ||
|
|
6990c5bde9 | ||
|
|
27e822abfd | ||
|
|
21ba496083 | ||
|
|
c6e2dcabae | ||
|
|
e1197fcc3d | ||
|
|
1854429e40 | ||
|
|
cece227f95 | ||
|
|
e83077c617 | ||
|
|
fd33cc9c8b | ||
|
|
8637438cee | ||
|
|
ee97f37cb4 | ||
|
|
68ef3a0466 | ||
|
|
cda1934606 | ||
|
|
5b883180e6 | ||
|
|
135d0336d5 | ||
|
|
cc6c647f00 | ||
|
|
a1aef9825a | ||
|
|
ece99a890c | ||
|
|
169c2530e4 | ||
|
|
c894a6e2ce | ||
|
|
187c2ac344 | ||
|
|
f06c0d2c05 | ||
|
|
975be86ccc | ||
|
|
1c0adb410d | ||
|
|
32b529f038 | ||
|
|
46cce832fd | ||
|
|
98a1045bea | ||
|
|
8426663631 | ||
|
|
a0675d707f | ||
|
|
9cf0a97aa9 | ||
|
|
3dec8a4caf | ||
|
|
2cb52c5a91 | ||
|
|
04f3bfc596 | ||
|
|
c67daa9a97 | ||
|
|
2ca8e86f83 | ||
|
|
e419eda5e2 | ||
|
|
2116af766a | ||
|
|
8036635251 | ||
|
|
c442b5de9d | ||
|
|
da4587fcd7 | ||
|
|
86a3ec0f8d | ||
|
|
7122d747cf | ||
|
|
69fe4b9eb6 | ||
|
|
385fb345bf | ||
|
|
f983d00e77 | ||
|
|
78bb152a63 | ||
|
|
4d6ff4c5e5 | ||
|
|
9bb5087ad1 | ||
|
|
d29e40a047 | ||
|
|
b10366f296 | ||
|
|
139d065594 | ||
|
|
0d73c39bb7 | ||
|
|
7f01adced9 | ||
|
|
3bad20352c | ||
|
|
cb3bf6493d | ||
|
|
57503e2165 | ||
|
|
b3abe014f2 | ||
|
|
80f3220fea | ||
|
|
fc2040a750 | ||
|
|
d55f240991 | ||
|
|
4f961a706d | ||
|
|
ac203e6c3c | ||
|
|
9141f0b79f | ||
|
|
d57eab87e8 | ||
|
|
bb901beb68 | ||
|
|
fa00c56c17 | ||
|
|
5359c479bc | ||
|
|
20107b77c0 | ||
|
|
5e71eef267 | ||
|
|
472531dc72 | ||
|
|
046f238826 | ||
|
|
9bf06f6963 | ||
|
|
357336d254 | ||
|
|
d4a6c3c58a | ||
|
|
8976e0f567 | ||
|
|
6dca1eb950 | ||
|
|
f8d82ff039 | ||
|
|
9e9e49224f | ||
|
|
8b53f4e022 | ||
|
|
8c87a62308 | ||
|
|
478cb5cf12 | ||
|
|
94f70bd861 | ||
|
|
9b4f0970fe | ||
|
|
869028a66d | ||
|
|
6f92a7f664 | ||
|
|
6a61b6b17e | ||
|
|
a4bf7cdf9e | ||
|
|
9471a5ffe9 | ||
|
|
24c5214ae8 | ||
|
|
2f7097d1b1 | ||
|
|
28369ecb5d | ||
|
|
b92f064e9b | ||
|
|
98f19578aa |
+1
-1
@@ -1 +1 @@
|
||||
3.4.90
|
||||
3.5.4
|
||||
|
||||
+115
-62
@@ -1,14 +1,8 @@
|
||||
# Travis defines and exports CC and CXX *after* we have defined our
|
||||
# environment variables via 'env'. So, do not use 'env' to define them.
|
||||
# Instead, put their definitions in MATRIX_EVAL, which we eval after the
|
||||
# definitions from Travis.
|
||||
language: cpp
|
||||
version: ~> 1.0
|
||||
|
||||
env:
|
||||
global:
|
||||
# ICC serial number.
|
||||
# See https://github.com/nemequ/icc-travis.
|
||||
secure: B3manbbi0anCAGDJTdAa9TlodzRHeiYD87FKmFzS877dPm8Cm0BDvtUhKBUpBvP8+nbHOWFGrgDmLugSZjTGU+mAxtuQpamUFHvinu0BIk3qtjlqouwvbtIqUu8iiZ3Uqu+xKeAANKRy0YVZGLlEb9F3N119tJ/Fxp1p9bXL1qph+CZ25OFbUgZ2s4F+/AyHMUxJlNXKFe3Qean65hC6edhU3zoaKzr/g/wtbhRmcyWbkOa1dJqzr2yKotcPvrnApGhDzgMKFtohg/t7xfMADDVv6sGS5XNpt25Z+MUCmLg4Z9eD7u109jvRV1eu/jgVafqsthWEhXbuMiFgFhKBKGCNZ0dACIfKZSkFZI6FdM7ovJ6aNhSlxZ2169Ybd22rN1UTHeCQWySPcVVOg5taLVpqe+E8Xhnv4hBO5NrzElWwCMLxIdPUSwVStYvtDr8ZytHWzfot50vSnFKIFpTOr9hP4+AJMVmmqJfaJo2MLBft/q2xkztrMv3lQSj3m4+ma9kPDwXIu9uCutjlnhc00jNx9qegi5VfpAjxcG1R+pX4T20az6ByHk/7LPQsANkT31RJq/jAeD9LEuMOy8miha83q4QuvbFaqPK3PY0el/O1LZaXqLsV2aQ0uqH8YX0l4r5NzHdhb+3lYgvpMBO5ytr/EWJiEyNYV518050IUDE=
|
||||
# If the language is set to C or C++, Travis defines and exports CC
|
||||
# and CXX *after* we have defined our environment variables via 'env'.
|
||||
language: minimal
|
||||
|
||||
# Run in two steps:
|
||||
# 1. Build the tarball
|
||||
@@ -73,21 +67,22 @@ jobs:
|
||||
## First. ##
|
||||
## ------- ##
|
||||
|
||||
# Start with three completely different environments, to get
|
||||
# errors asap.
|
||||
# Start with three completely different environments, to get errors asap.
|
||||
|
||||
- name: "GCC 9 -O3"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
addons: &gcc9
|
||||
apt:
|
||||
sources:
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
packages: g++-9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- 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.
|
||||
@@ -108,7 +103,8 @@ jobs:
|
||||
- libc++abi-9-dev
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- MATRIX_EVAL="CC='clang-9 -fsanitize=address' CXX='clang++-9 -fsanitize=address -stdlib=libc++'"
|
||||
- CC='clang-9 -fsanitize=address'
|
||||
- CXX='clang++-9 -fsanitize=address -stdlib=libc++'
|
||||
- PART=1
|
||||
|
||||
- name: "Clang 9 libc++ and ASAN part 2"
|
||||
@@ -118,26 +114,69 @@ jobs:
|
||||
addons: *clang9
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- MATRIX_EVAL="CC='clang-9 -fsanitize=address' CXX='clang++-9 -fsanitize=address -stdlib=libc++'"
|
||||
- CC='clang-9 -fsanitize=address'
|
||||
- CXX='clang++-9 -fsanitize=address -stdlib=libc++'
|
||||
- PART=2
|
||||
|
||||
# Currently no longer works (https://github.com/nemequ/icc-travis/issues/15).
|
||||
# - name: "ICC"
|
||||
# stage: check
|
||||
# # We need the build-aux/install-icc.sh script.
|
||||
# git:
|
||||
# clone: true
|
||||
# submodules: false
|
||||
# depth: 1
|
||||
# os: linux
|
||||
# dist: xenial
|
||||
# env:
|
||||
# # ICC's warnings are often very wrong (e.g., it thinks foo ?
|
||||
# # "bar" : "baz" is char* instead of const char*), so don't try
|
||||
# # to work around the, and obviously, don't die on them.
|
||||
# - MATRIX_EVAL="CC=icc && CXX=icpc"
|
||||
# - MAKE_ARGS='WERROR_CFLAGS= WERROR_CXXFLAGS='
|
||||
- name: "ICC"
|
||||
stage: check
|
||||
os: linux
|
||||
compiler: icc
|
||||
env:
|
||||
- CC=icc
|
||||
- CXX=icpc
|
||||
install:
|
||||
- source /opt/intel/inteloneapi/compiler/latest/env/vars.sh
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'deb https://apt.repos.intel.com/oneapi all main'
|
||||
key_url: 'https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB'
|
||||
packages:
|
||||
- intel-oneapi-icc
|
||||
|
||||
## ------- ##
|
||||
## First. ##
|
||||
## ------- ##
|
||||
|
||||
# Start with three completely different environments, to get
|
||||
# errors asap.
|
||||
|
||||
- name: "ARM64: GCC 9 -O3 part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
arch: arm64
|
||||
dist: bionic
|
||||
addons: *gcc9
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
- PART=1
|
||||
|
||||
- name: "PPC64le: GCC 9 part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
arch: ppc64le
|
||||
dist: bionic
|
||||
addons: *gcc9
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CONFIGUREFLAGS='CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
- PART=1
|
||||
|
||||
- name: "s390x: GCC 9 part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
arch: s390x
|
||||
dist: bionic
|
||||
addons: *gcc9
|
||||
env:
|
||||
- CC=gcc-9
|
||||
- CXX=g++-9
|
||||
- CONFIGUREFLAGS='CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
- PART=1
|
||||
|
||||
## ----- ##
|
||||
## GCC. ##
|
||||
@@ -150,7 +189,8 @@ jobs:
|
||||
apt:
|
||||
packages: g++-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
|
||||
- CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||
- CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||
- CONFIGUREFLAGS='CFLAGS=-O1 CXXFLAGS=-O1'
|
||||
- PART=1
|
||||
|
||||
@@ -162,7 +202,8 @@ jobs:
|
||||
apt:
|
||||
packages: g++-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
- CC=gcc-8
|
||||
- CXX=g++-8
|
||||
|
||||
- name: "GCC 7"
|
||||
stage: check
|
||||
@@ -172,7 +213,8 @@ jobs:
|
||||
apt:
|
||||
packages: g++-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
- CC=gcc-7
|
||||
- CXX=g++-7
|
||||
|
||||
- name: "GCC 6"
|
||||
stage: check
|
||||
@@ -183,7 +225,8 @@ jobs:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
||||
- CC=gcc-6
|
||||
- CXX=g++-6
|
||||
|
||||
- name: "GCC 5"
|
||||
stage: check
|
||||
@@ -194,7 +237,8 @@ jobs:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-5
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
||||
- CC=gcc-5
|
||||
- CXX=g++-5
|
||||
|
||||
- name: "GCC 4.9"
|
||||
stage: check
|
||||
@@ -205,7 +249,8 @@ jobs:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
|
||||
- CC=gcc-4.9
|
||||
- CXX=g++-4.9
|
||||
|
||||
- name: "GCC 4.8"
|
||||
stage: check
|
||||
@@ -216,7 +261,8 @@ jobs:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
|
||||
- CC=gcc-4.8
|
||||
- CXX=g++-4.8
|
||||
|
||||
- name: "GCC 4.7"
|
||||
stage: check
|
||||
@@ -227,7 +273,8 @@ jobs:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
|
||||
- CC=gcc-4.7
|
||||
- CXX=g++-4.7
|
||||
|
||||
- name: "GCC 4.6"
|
||||
stage: check
|
||||
@@ -238,7 +285,8 @@ jobs:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.6 && CXX=g++-4.6"
|
||||
- CC=gcc-4.6
|
||||
- CXX=g++-4.6
|
||||
|
||||
## ------- ##
|
||||
## Clang. ##
|
||||
@@ -255,7 +303,8 @@ jobs:
|
||||
- libc++-8-dev
|
||||
- libc++abi-8-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-8 && CXX='clang++-8 -stdlib=libc++'"
|
||||
- CC=clang-8
|
||||
- CXX='clang++-8 -stdlib=libc++'
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
|
||||
- name: "Clang 7"
|
||||
@@ -269,7 +318,8 @@ jobs:
|
||||
- libc++-7-dev
|
||||
- libc++abi-7-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-7 && CXX='clang++-7 -stdlib=libc++'"
|
||||
- CC=clang-7
|
||||
- CXX='clang++-7 -stdlib=libc++'
|
||||
|
||||
- name: "Clang 6 and libc++"
|
||||
stage: check
|
||||
@@ -284,7 +334,8 @@ jobs:
|
||||
- clang-6.0
|
||||
- libc++-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-6.0 && CXX='clang++-6.0 -stdlib=libc++'"
|
||||
- CC=clang-6.0
|
||||
- CXX='clang++-6.0 -stdlib=libc++'
|
||||
|
||||
- name: "Clang 5"
|
||||
stage: check
|
||||
@@ -297,7 +348,8 @@ jobs:
|
||||
- clang-5.0
|
||||
- libc++-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
|
||||
- CC='clang-5.0'
|
||||
- CXX='clang++-5.0'
|
||||
|
||||
- name: "Clang 4"
|
||||
stage: check
|
||||
@@ -308,7 +360,8 @@ jobs:
|
||||
sources: llvm-toolchain-xenial-4.0
|
||||
packages: clang-4.0
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
|
||||
- CC=clang-4.0
|
||||
- CXX=clang++-4.0
|
||||
|
||||
- name: "Clang 3.9"
|
||||
stage: check
|
||||
@@ -319,7 +372,8 @@ jobs:
|
||||
sources: llvm-toolchain-xenial-3.9
|
||||
packages: clang-3.9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
|
||||
- CC=clang-3.9
|
||||
- CXX=clang++-3.9
|
||||
|
||||
- name: "Clang 3.8"
|
||||
stage: check
|
||||
@@ -332,7 +386,8 @@ jobs:
|
||||
- llvm-toolchain-precise-3.8
|
||||
packages: clang-3.8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
||||
- CC=clang-3.8
|
||||
- CXX=clang++-3.8
|
||||
|
||||
- name: "CLang 3.7"
|
||||
stage: check
|
||||
@@ -345,7 +400,8 @@ jobs:
|
||||
- llvm-toolchain-precise-3.7
|
||||
packages: clang-3.7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
|
||||
- CC=clang-3.7
|
||||
- CXX=clang++-3.7
|
||||
|
||||
- name: "Clang 3.6"
|
||||
stage: check
|
||||
@@ -358,7 +414,8 @@ jobs:
|
||||
- llvm-toolchain-precise-3.6
|
||||
packages: clang-3.6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
|
||||
- CC=clang-3.6
|
||||
- CXX=clang++-3.6
|
||||
|
||||
- name: "Clang 3.5"
|
||||
stage: check
|
||||
@@ -371,7 +428,8 @@ jobs:
|
||||
- llvm-toolchain-precise-3.5
|
||||
packages: clang-3.5
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
|
||||
- CC=clang-3.5
|
||||
- CXX=clang++-3.5
|
||||
|
||||
- name: "Clang 3.4"
|
||||
stage: check
|
||||
@@ -384,7 +442,8 @@ jobs:
|
||||
env:
|
||||
# No versioned name installed, but beware that Travis installs
|
||||
# a more modern clang earlier in the default PATH.
|
||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
||||
- CC=/usr/bin/clang
|
||||
- CXX=/usr/bin/clang++
|
||||
|
||||
- name: "Clang 3.3"
|
||||
stage: check
|
||||
@@ -396,7 +455,8 @@ jobs:
|
||||
packages: clang-3.3
|
||||
env:
|
||||
# See comment for 3.4.
|
||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
||||
- CC=/usr/bin/clang
|
||||
- CXX=/usr/bin/clang++
|
||||
|
||||
## From https://docs.gitlab.com/ce/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor.
|
||||
## Applies to Travis too. Applied to all the 'script's (of all the jobs).
|
||||
@@ -414,20 +474,16 @@ before_script:
|
||||
|
||||
# Applies only to the jobs that don't have a 'script', i.e., applies to all the 'check' jobs, but not the 'dist' one.
|
||||
script:
|
||||
- eval "$MATRIX_EVAL"
|
||||
# Beware not too leak $SSH_PRIVATE_KEY.
|
||||
# - env
|
||||
- sudo apt-get install -qq doxygen flex m4
|
||||
# Install and activate ICC.
|
||||
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
|
||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||
# Install and activate dmd.
|
||||
- mkdir -p ~/dlang && wget https://dlang.org/install.sh -O ~/dlang/install.sh
|
||||
- source $(source ~/dlang/install.sh dmd -a)
|
||||
- source $(source ~/dlang/install.sh dmd -a) || true
|
||||
|
||||
- $CC --version
|
||||
- $CXX --version
|
||||
- dmd --version
|
||||
- dmd --version || true
|
||||
- doxygen --version
|
||||
- flex --version
|
||||
- ld --version
|
||||
@@ -452,6 +508,3 @@ script:
|
||||
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat test-suite.log && cat tests/testsuite.log && false; }; fi
|
||||
- if test ${PART-2} = 2; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||
|
||||
after_script:
|
||||
- uninstall_intel_software || true
|
||||
|
||||
@@ -24,7 +24,7 @@ and nasty bugs.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1998-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
+1
-1
@@ -26733,7 +26733,7 @@
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1987-1988, 1991-2015, 2018-2019 Free Software
|
||||
Copyright (C) 1987-1988, 1991-2015, 2018-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
# Copyright (C) 2001-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2015, 2018-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
|
||||
@@ -42,7 +42,7 @@ dependencies = $(BISON_IN) $(src_bison_SOURCES) $(dist_skeletons_DATA)
|
||||
BISON = $(top_builddir)/tests/bison
|
||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||
YACC = $(BISON) -o y.tab.c
|
||||
AM_YFLAGS_WITH_LINES = --defines -Werror -Wall --report=all
|
||||
AM_YFLAGS_WITH_LINES = --defines -Werror -Wall,dangling-alias --report=all
|
||||
AM_YFLAGS = $(AM_YFLAGS_WITH_LINES) --no-lines
|
||||
|
||||
# Initialization before completion by local.mk's.
|
||||
|
||||
@@ -1,8 +1,335 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.4.91 (2019-11-20) [beta]
|
||||
* Noteworthy changes in release 3.5.90 (2020-04-18) [beta]
|
||||
|
||||
** New Features
|
||||
** Backward incompatible changes
|
||||
|
||||
TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
|
||||
|
||||
The YYERROR_VERBOSE macro is no longer supported; the parsers that still
|
||||
depend on it will now produce Yacc-like error messages (just "syntax
|
||||
error"). It was superseded by the "%error-verbose" directive in Bison
|
||||
1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that support
|
||||
for YYERROR_VERBOSE would be removed. Note that since Bison 3.0
|
||||
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
||||
parse.error verbose".
|
||||
|
||||
** New features
|
||||
|
||||
*** Improved syntax error messages
|
||||
|
||||
Two new values for the %define parse.error variable offer more control to
|
||||
the user. Available in all the skeletons (C, C++, Java).
|
||||
|
||||
**** %define parse.error detailed
|
||||
|
||||
The behavior of "%define parse.error detailed" is closely resembling that
|
||||
of "%define parse.error verbose" with a few exceptions. First, it is safe
|
||||
to use non-ASCII characters in token aliases (with 'verbose', the result
|
||||
depends on the locale with which bison was run). Second, a yysymbol_name
|
||||
function is exposed to the user, instead of the yytnamerr function and the
|
||||
yytname table. Third, token internationalization is supported (see
|
||||
below).
|
||||
|
||||
**** %define parse.error custom
|
||||
|
||||
With this directive, the user forges and emits the syntax error message
|
||||
herself by defining the yyreport_syntax_error function. A new type,
|
||||
yypcontext_t, captures the circumstances of the error, and provides the
|
||||
user with functions to get details, such as yypcontext_expected_tokens to
|
||||
get the list of expected token kinds.
|
||||
|
||||
A possible implementation of yyreport_syntax_error is:
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
**** Token aliases internationalization
|
||||
|
||||
When the %define variable parse.error is set to `custom` or `detailed`,
|
||||
one may specify which token aliases are to be translated using _(). For
|
||||
instance
|
||||
|
||||
%token
|
||||
PLUS "+"
|
||||
MINUS "-"
|
||||
<double>
|
||||
NUM _("double precision number")
|
||||
<symrec*>
|
||||
FUN _("function")
|
||||
VAR _("variable")
|
||||
|
||||
In that case the user must define _() and N_(), and yysymbol_name returns
|
||||
the translated symbol (i.e., it returns '_("variable")' rather that
|
||||
'"variable"'). In Java, the user must provide an i18n() function.
|
||||
|
||||
*** List of expected tokens (yacc.c)
|
||||
|
||||
Push parsers may invoke yypstate_expected_tokens at any point during
|
||||
parsing (including even before submitting the first token) to get the list
|
||||
of possible tokens. This feature can be used to propose autocompletion
|
||||
(see below the "bistromathic" example).
|
||||
|
||||
It makes little sense to use this feature without enabling LAC (lookahead
|
||||
correction).
|
||||
|
||||
*** Deep overhaul of the symbol and token kinds
|
||||
|
||||
To avoid the confusion with types in programming languages, we now refer
|
||||
to token and symbol "kinds" instead of token and symbol "types". The
|
||||
documentation and error messages have been revised.
|
||||
|
||||
All the skeletons have been updated to use dedicated enum types rather
|
||||
than integral types. Special symbols are now regular citizens, instead of
|
||||
being declared in ad hoc ways.
|
||||
|
||||
**** Token kinds
|
||||
|
||||
The "token kind" is what is returned by the scanner, e.g., PLUS, NUMBER,
|
||||
LPAREN, etc. While backward compatibility is of course ensured, users are
|
||||
nonetheless invited to replace their uses of "enum yytokentype" by
|
||||
"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
|
||||
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"
|
||||
rather than "$undefined".
|
||||
|
||||
Therefore in most cases it is now useless to define the end-of-line token
|
||||
as follows:
|
||||
|
||||
%token T_EOF 0 "end of file"
|
||||
|
||||
Rather simply use "YYEOF" in your scanner.
|
||||
|
||||
**** Symbol kinds
|
||||
|
||||
The "symbol kinds" is what the parser actually uses. (Unless the
|
||||
api.token.raw %define variable is used, the symbol kind of a terminal
|
||||
differs from the corresponding token kind.)
|
||||
|
||||
They are now exposed as a enum, "yysymbol_kind_t".
|
||||
|
||||
This allows users to tailor the error messages the way they want, or to
|
||||
process some symbols in a specific way in autocompletion (see the
|
||||
bistromathic example below).
|
||||
|
||||
*** Modernize display of explanatory statements in diagnostics
|
||||
|
||||
Since Bison 2.7, output was indented four spaces for explanatory
|
||||
statements. For example:
|
||||
|
||||
input.y:2.7-13: error: %type redeclaration for exp
|
||||
input.y:1.7-11: previous declaration
|
||||
|
||||
Since the introduction of caret-diagnostics, it became less clear. This
|
||||
indentation has been removed and submessages are displayed similarly as in
|
||||
GCC:
|
||||
|
||||
input.y:2.7-13: error: %type redeclaration for exp
|
||||
2 | %type <float> exp
|
||||
| ^~~~~~~
|
||||
input.y:1.7-11: note: previous declaration
|
||||
1 | %type <int> exp
|
||||
| ^~~~~
|
||||
|
||||
Contributed by Victor Morales Cayuela.
|
||||
|
||||
*** C++
|
||||
|
||||
The token and symbol kinds are yy::parser::token_kind_type and
|
||||
yy::parser::symbol_kind_type.
|
||||
|
||||
The symbol_type::kind() member function allows to get the kind of a
|
||||
symbol. This can be used to write unit tests for scanners, e.g.,
|
||||
|
||||
yy::parser::symbol_type t = make_NUMBER ("123");
|
||||
assert (t.kind () == yy::parser::symbol_kind::S_NUMBER);
|
||||
assert (t.value.as<int> () == 123);
|
||||
|
||||
** Documentation
|
||||
|
||||
*** User Manual
|
||||
|
||||
In order to avoid ambiguities with "type" as in "typing", we now refer to
|
||||
the "token kind" (e.g., `PLUS`, `NUMBER`, etc.) rather than the "token
|
||||
type". We now also refer to the "symbol type" (e.g., `PLUS`, `expr`,
|
||||
etc.).
|
||||
|
||||
*** Examples
|
||||
|
||||
There are now two examples in examples/java: a very simple calculator, and
|
||||
one that tracks locations to provide accurate error messages.
|
||||
|
||||
The lexcalc example (a simple example in C based on Flex and Bison) now
|
||||
also demonstrates location tracking.
|
||||
|
||||
|
||||
A new C example, bistromathic, is a fully featured interactive calculator
|
||||
using many Bison features: pure interface, push parser, autocompletion
|
||||
based on the current parser state (using yypstate_expected_tokens),
|
||||
location tracking, internationalized custom error messages, lookahead
|
||||
correction, rich debug traces, etc.
|
||||
|
||||
It shows how to depend on the symbol kinds to tailor autocompletion. For
|
||||
instance it recognizes the symbol kind "VARIABLE" to propose
|
||||
autocompletion on the existing variables, rather than of the word
|
||||
"variable".
|
||||
|
||||
* Noteworthy changes in release 3.5.4 (2020-04-05) [stable]
|
||||
|
||||
** WARNING: Future backward-incompatibilities!
|
||||
|
||||
TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
|
||||
|
||||
Bison 3.6 will no longer support the YYERROR_VERBOSE macro; the parsers
|
||||
that still depend on it will produce Yacc-like error messages (just
|
||||
"syntax error"). It was superseded by the "%error-verbose" directive in
|
||||
Bison 1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that
|
||||
support for YYERROR_VERBOSE would be removed. Note that since Bison 3.0
|
||||
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
||||
parse.error verbose".
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Fix portability issues of the package itself on old compilers.
|
||||
|
||||
Fix api.token.raw support in Java.
|
||||
|
||||
* Noteworthy changes in release 3.5.3 (2020-03-08) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Error messages could quote lines containing zero-width characters (such as
|
||||
\005) with incorrect styling. Fixes for similar issues with unexpectedly
|
||||
short lines (e.g., the file was changed between parsing and diagnosing).
|
||||
|
||||
Several unlikely crashes found by fuzzing have been fixed.
|
||||
|
||||
* Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Portability issues and minor cosmetic issues.
|
||||
|
||||
The lalr1.cc skeleton properly rejects unsupported values for parse.lac
|
||||
(as yacc.c does).
|
||||
|
||||
* Noteworthy changes in release 3.5.1 (2020-01-19) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Portability fixes.
|
||||
|
||||
Fix compiler warnings.
|
||||
|
||||
* Noteworthy changes in release 3.5 (2019-12-11) [stable]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
Lone carriage-return characters (aka \r or ^M) in the grammar files are no
|
||||
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||
particular their locations.
|
||||
|
||||
In C++, line numbers and columns are now represented as 'int' not
|
||||
'unsigned', so that integer overflow on positions is easily checkable via
|
||||
'gcc -fsanitize=undefined' and the like. This affects the API for
|
||||
positions. The default position and location classes now expose
|
||||
'counter_type' (int), used to define line and column numbers.
|
||||
|
||||
** 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
|
||||
|
||||
*** Lookahead correction in C++
|
||||
|
||||
Contributed by Adrian Vogelsgesang.
|
||||
|
||||
The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
|
||||
%define variable parse.lac.
|
||||
|
||||
*** Variable api.token.raw: Optimized token numbers (all skeletons)
|
||||
|
||||
In the generated parsers, tokens have two numbers: the "external" token
|
||||
number as returned by yylex (which starts at 257), and the "internal"
|
||||
symbol number (which starts at 3). Each time yylex is called, a table
|
||||
lookup maps the external token number to the internal symbol number.
|
||||
|
||||
When the %define variable api.token.raw is set, tokens are assigned their
|
||||
internal number, which saves one table lookup per token, and also saves
|
||||
the generation of the mapping table.
|
||||
|
||||
The gain is typically moderate, but in extreme cases (very simple user
|
||||
actions), a 10% improvement can be observed.
|
||||
|
||||
*** Generated parsers use better types for states
|
||||
|
||||
Stacks now use the best integral type for state numbers, instead of always
|
||||
using 15 bits. As a result "small" parsers now have a smaller memory
|
||||
footprint (they use 8 bits), and there is support for large automata (16
|
||||
bits), and extra large (using int, i.e., typically 31 bits).
|
||||
|
||||
*** Generated parsers prefer signed integer types
|
||||
|
||||
Bison skeletons now prefer signed to unsigned integer types when either
|
||||
will do, as the signed types are less error-prone and allow for better
|
||||
checking with 'gcc -fsanitize=undefined'. Also, the types chosen are now
|
||||
portable to unusual machines where char, short and int are all the same
|
||||
width. On non-GNU platforms this may entail including <limits.h> and (if
|
||||
available) <stdint.h> to define integer types and constants.
|
||||
|
||||
*** A skeleton for the D programming language
|
||||
|
||||
For the last few releases, Bison has shipped a stealth experimental
|
||||
skeleton: lalr1.d. It was first contributed by Oliver Mangold, based on
|
||||
Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
|
||||
H. S. Teoh.
|
||||
|
||||
However, because nobody has committed to improving, testing, and
|
||||
documenting this skeleton, it is not clear that it will be supported in
|
||||
the future.
|
||||
|
||||
The lalr1.d skeleton *is functional*, and works well, as demonstrated in
|
||||
examples/d/calc.d. Please try it, enjoy it, and... commit to support it.
|
||||
|
||||
*** Debug traces in Java
|
||||
|
||||
The Java backend no longer emits code and data for parser tracing if the
|
||||
%define variable parse.trace is not defined.
|
||||
|
||||
** Diagnostics
|
||||
|
||||
*** New diagnostic: -Wdangling-alias
|
||||
|
||||
@@ -53,7 +380,7 @@ GNU Bison NEWS
|
||||
%%
|
||||
expr:
|
||||
|
||||
gives, with -Wyacc
|
||||
gives with -Wyacc
|
||||
|
||||
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
@@ -65,50 +392,9 @@ GNU Bison NEWS
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~~~~
|
||||
|
||||
* Noteworthy changes in release 3.4.90 (2019-10-29) [beta]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
Lone carriage-return characters (aka \r or ^M) in the grammar files are no
|
||||
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||
particular their locations.
|
||||
|
||||
In C++, line numbers and columns are now represented as 'int' not
|
||||
'unsigned', so that integer overflow on positions is easily checkable via
|
||||
'gcc -fsanitize=undefined' and the like. This affects the API for
|
||||
positions. The default position and location classes now expose
|
||||
'counter_type' (int), used to define line and column numbers.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||
|
||||
** New features
|
||||
|
||||
*** Lookahead correction in C++
|
||||
|
||||
Contributed by Adrian Vogelsgesang.
|
||||
|
||||
The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
|
||||
%define variable parse.lac.
|
||||
|
||||
*** Variable api.token.raw: Optimized token numbers (all skeletons)
|
||||
|
||||
In the generated parsers, tokens have two numbers: the "external" token
|
||||
number as returned by yylex (which starts at 257), and the "internal"
|
||||
symbol number (which starts at 3). Each time yylex is called, a table
|
||||
lookup maps the external token number to the internal symbol number.
|
||||
|
||||
When the %define variable api.token.raw is set, tokens are assigned their
|
||||
internal number, which saves one table lookup per token, and also saves
|
||||
the generation of the mapping table.
|
||||
|
||||
The gain is typically moderate, but in extreme cases (very simple user
|
||||
actions), a 10% improvement can be observed.
|
||||
|
||||
*** Diagnostics with insertion
|
||||
|
||||
The diagnostics now display suggestion below the underlined source.
|
||||
The diagnostics now display the suggestion below the underlined source.
|
||||
Replacement for undeclared symbols are now also suggested.
|
||||
|
||||
$ cat /tmp/foo.y
|
||||
@@ -149,26 +435,28 @@ GNU Bison NEWS
|
||||
1 | %token FOO …
|
||||
| ^~~
|
||||
|
||||
*** Debug traces in Java
|
||||
** Changes
|
||||
|
||||
The Java backend no longer emits code and data for parser tracing if the
|
||||
%define variable parse.trace is not defined.
|
||||
*** Debugging glr.c and glr.cc
|
||||
|
||||
*** Generated parsers prefer signed integer types
|
||||
The glr.c skeleton always had asserts to check its own behavior (not the
|
||||
user's). These assertions are now under the control of the parse.assert
|
||||
%define variable (disabled by default).
|
||||
|
||||
Bison skeletons now prefer signed to unsigned integer types when either
|
||||
will do, as the signed types are less error-prone and allow for better
|
||||
checking with 'gcc -fsanitize=undefined'. Also, the types chosen are now
|
||||
portable to unusual machines where char, short and int are all the same
|
||||
width. On non-GNU platforms this may entail including <limits.h> and (if
|
||||
available) <stdint.h> to define integer types and constants.
|
||||
*** Clean up
|
||||
|
||||
*** Generated parsers use better types for states
|
||||
Several new compiler warnings in the generated output have been avoided.
|
||||
Some unused features are no longer emitted. Cleaner generated code in
|
||||
general.
|
||||
|
||||
Stacks now use the best integral type for state numbers, instead of always
|
||||
using 15 bits. As a result "small" parsers now have a smaller memory
|
||||
footprint (they use 8 bits), and there is support for large automata (16
|
||||
bits), and extra large (using int, i.e., typically 31 bits).
|
||||
** Bug Fixes
|
||||
|
||||
Portability issues in the test suite.
|
||||
|
||||
In theory, parsers using %nonassoc could crash when reporting verbose
|
||||
error messages. This unlikely bug has been fixed.
|
||||
|
||||
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||
|
||||
* Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
|
||||
|
||||
@@ -3774,7 +4062,7 @@ Output file does not redefine const for C++.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1995-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Parser Generator.
|
||||
|
||||
@@ -3820,7 +4108,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
|
||||
LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
|
||||
LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
|
||||
LocalWords: noexcept constexpr ispell american deprecations backend
|
||||
LocalWords: noexcept constexpr ispell american deprecations backend Teoh
|
||||
LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
|
||||
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
|
||||
|
||||
Local Variables:
|
||||
ispell-dictionary: "american"
|
||||
|
||||
@@ -36,7 +36,7 @@ to the bison package.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2005, 2009-2015, 2018-2019 Free Software Foundation,
|
||||
Copyright (C) 2002, 2005, 2009-2015, 2018-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
This package contains the GNU Bison parser generator.
|
||||
GNU Bison is a general-purpose parser generator that converts an annotated
|
||||
context-free grammar into a deterministic LR or generalized LR (GLR) parser
|
||||
employing LALR(1) parser tables. Bison can also generate IELR(1) or
|
||||
canonical LR(1) parser tables. Once you are proficient with Bison, you can
|
||||
use it to develop a wide range of language parsers, from those used in
|
||||
simple desk calculators to complex programming languages.
|
||||
|
||||
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
||||
work with Bison with no change. Anyone familiar with Yacc should be able to
|
||||
use Bison with little trouble. You need to be fluent in C, C++ or Java
|
||||
programming in order to use Bison.
|
||||
|
||||
Bison and the parsers it generates are portable, they do not require any
|
||||
specific compilers.
|
||||
|
||||
GNU Bison's home page is https://gnu.org/software/bison/.
|
||||
|
||||
# Installation
|
||||
## Build from git
|
||||
@@ -9,8 +24,7 @@ Here are basic installation instructions for a repository checkout:
|
||||
|
||||
then proceed with the usual `configure && make` steps.
|
||||
|
||||
The file README-hacking.md contains all the needed information about
|
||||
building, modifying and checking Bison.
|
||||
The file README-hacking.md is about building, modifying and checking Bison.
|
||||
|
||||
## Build from tarball
|
||||
See the file INSTALL for generic compilation and installation instructions.
|
||||
@@ -18,13 +32,18 @@ See the file INSTALL for generic compilation and installation instructions.
|
||||
Bison requires GNU m4 1.4.6 or later. See
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
|
||||
|
||||
## Running a non installed bison
|
||||
Once you ran `make`, you might want to toy with this fresh bison before
|
||||
installing it. In that case, do not use `src/bison`: it would use the
|
||||
*installed* files (skeletons, etc.), not the local ones. Use `tests/bison`.
|
||||
|
||||
## Colored diagnostics
|
||||
As an experimental feature, diagnostics are now colored, controlled by the
|
||||
`--color` and `--style` options.
|
||||
|
||||
To use them, install the libtextstyle library before configuring Bison. It
|
||||
is available from https://alpha.gnu.org/gnu/gettext/, for instance
|
||||
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz.
|
||||
https://alpha.gnu.org/pub/gnu/gettext/libtextstyle-0.20.5.tar.gz.
|
||||
|
||||
The option --color supports the following arguments:
|
||||
- always, yes: Enable colors.
|
||||
@@ -81,23 +100,17 @@ that the range specifies every single year in that closed interval.
|
||||
|
||||
<!--
|
||||
|
||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2019 Free
|
||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2020 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||
|
||||
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/>.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
Local Variables:
|
||||
mode: markdown
|
||||
@@ -105,7 +118,8 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
||||
LocalWords: MERCHANTABILITY
|
||||
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american md
|
||||
LocalWords: MERCHANTABILITY GLR LALR IELR submodule init README src bw
|
||||
LocalWords: Relocatability symlinks symlink
|
||||
|
||||
-->
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ the problems you encounter.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
|
||||
Copyright (C) 2002, 2004, 2009-2015, 2018-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
+155
-197
@@ -5,7 +5,8 @@ Everything related to the development of Bison is on Savannah:
|
||||
http://savannah.gnu.org/projects/bison/.
|
||||
|
||||
|
||||
# Administrivia
|
||||
Administrivia
|
||||
=============
|
||||
|
||||
## If you incorporate a change from somebody on the net:
|
||||
First, if it is a large change, you must make sure they have signed the
|
||||
@@ -23,9 +24,11 @@ demonstrates the bug. Then fix the bug, re-run the test suite, and check
|
||||
everything in.
|
||||
|
||||
|
||||
# Hacking
|
||||
|
||||
## Visible changes
|
||||
Hacking
|
||||
=======
|
||||
|
||||
## Visible Changes
|
||||
Which include serious bug fixes, must be mentioned in NEWS.
|
||||
|
||||
## Translations
|
||||
@@ -34,15 +37,88 @@ 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.
|
||||
|
||||
## Horizontal tabs
|
||||
## 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.
|
||||
However, make files, ChangeLog, and some regular expressions require tabs.
|
||||
Also, test cases might need to contain tabs to check that Bison properly
|
||||
processes tabs in its input.
|
||||
|
||||
Prefer "res" as the name of the local variable that will be "return"ed by
|
||||
the function.
|
||||
|
||||
# Working from the repository
|
||||
### Bison
|
||||
Follow the GNU Coding Standards.
|
||||
|
||||
Don't reinvent the wheel: we use gnulib, which features many components.
|
||||
Actually, Bison has legacy code that we should replace with gnulib modules
|
||||
(e.g., many ad hoc implementations of lists).
|
||||
|
||||
### Skeletons
|
||||
We try to use the "typical" coding style for each language.
|
||||
|
||||
#### C/C++
|
||||
Follow the GNU Coding Standards.
|
||||
|
||||
The `glr.c` skeleton was implemented with `camlCase`. We are migrating it
|
||||
to `snake_case`. Because we are standardizing the code, it is currently
|
||||
inconsistent.
|
||||
|
||||
Use `YYFOO` and `yyfoo` for entities that are exposed to the user. They are
|
||||
part of our contract with the users wrt backward compatibility.
|
||||
|
||||
Use `YY_FOO` and `yy_foo` for private matters. Users should not use them,
|
||||
we are free to change them without fear of backward compatibility issues.
|
||||
|
||||
Use `*_t` for types, especially for `yy*_t` in which case we shouldn't worry
|
||||
about the C standard introducing such a name.
|
||||
|
||||
#### C++
|
||||
Follow the C++ Core Guidelines
|
||||
(http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). The Google
|
||||
ones may be interesting too
|
||||
(https://google.github.io/styleguide/cppguide.html).
|
||||
|
||||
Our enumerators, such as the kinds (symbol and token kinds), should be lower
|
||||
case, but it was too late to follow that track for token kinds, and symbol
|
||||
kind enumerators are made to be consistent with them.
|
||||
|
||||
Use `*_type` for type aliases. Use `foo_get()` and `foo_set(v)` for
|
||||
accessors, or simply `foo()` and `foo(v)`.
|
||||
|
||||
Use the `yy` prefix for private stuff, but there's no need for it in the
|
||||
public API. The `yy` prefix is already taken care of via the namespace.
|
||||
|
||||
#### Java
|
||||
We follow https://www.oracle.com/technetwork/java/codeconventions-150003.pdf
|
||||
and https://google.github.io/styleguide/javaguide.html. Unfortunately at
|
||||
some point some GNU Coding Style was installed in Java, but it's an error.
|
||||
So we should for instance stop putting spaces in function calls. Because we
|
||||
are standardizing the code, it is currently inconsistent.
|
||||
|
||||
Use a 2-space indentation (Google) rather than 4 (Oracle).
|
||||
|
||||
Don't use the "yy" prefix for public members: "getExpectedTokens", not
|
||||
"yyexpectedTokens" or "yygetExpectedTokens".
|
||||
|
||||
## Commit Messages
|
||||
Imitate the style we use. Use `git log` to get sources of inspiration.
|
||||
|
||||
If the changes have a small impact on Bison's generated parser, embed these
|
||||
changes in the commit itself. If the impact is large, first push all the
|
||||
changes except those about src/parse-gram.[ch], and then another commit
|
||||
named "regen" which is only about them.
|
||||
|
||||
## Debugging
|
||||
Bison supports tracing of its various steps, via the `--trace` option.
|
||||
Since it is not meant for the end user, it is not displayed by `bison
|
||||
--help`, nor is it documented in the manual. Instead, run `bison
|
||||
--trace=help`.
|
||||
|
||||
|
||||
|
||||
Working from the Repository
|
||||
===========================
|
||||
|
||||
These notes intend to help people working on the checked-out sources. These
|
||||
requirements do not apply when building from a distribution tarball.
|
||||
@@ -185,29 +261,61 @@ These files don't change very often in Autoconf, so it should be relatively
|
||||
straight-forward to examine the differences in order to decide whether to
|
||||
update.
|
||||
|
||||
# Test suite
|
||||
## Troubleshooting
|
||||
|
||||
Bison is self-hosted: its parser is generated by Bison. We don't force
|
||||
ourselves to use the previous release of Bison, we use the current git
|
||||
master for several reasons:
|
||||
- dogfooding: let Bison be its first user
|
||||
- monitoring: seeing the diff on the generated parsers with git is very
|
||||
helpful, as it allows to see easily the impact of the changes on a real
|
||||
case parser.
|
||||
|
||||
If you are unlucky the generated files, src/parse-gram.[ch], may be older
|
||||
than their source, src/parse-gram.y. And your current version of Bison
|
||||
might not be able to grok it. In that case, first refresh the generated
|
||||
files:
|
||||
|
||||
$ touch src/parse-gram.[ch]
|
||||
|
||||
Then proceed.
|
||||
|
||||
In case you wrecked your current copy of the parser, get back the previous
|
||||
version, compile bison, then force it to recreate the files:
|
||||
|
||||
$ git checkout HEAD^ src/parse-gram.[ch]
|
||||
$ make -C _build
|
||||
$ touch src/parse-gram.y
|
||||
$ make -C _build
|
||||
|
||||
|
||||
Test Suite
|
||||
==========
|
||||
|
||||
## make check
|
||||
Use liberally.
|
||||
Consume without moderation. It is composed of two kinds of tests: the
|
||||
examples, and the main test suite.
|
||||
|
||||
## Updating the expectations
|
||||
Sometimes some changes have a large impact on the test suite (e.g., when we
|
||||
added the `[-Wother]` part to all the warnings). Part of the update can be
|
||||
done with a crude tool: `build-aux/update-test`.
|
||||
### The Examples
|
||||
In examples/, there is a number of ready-to-use examples (see
|
||||
examples/README.md). These examples have small test suites run by `make
|
||||
check`. The test results are in local `*.log` files (e.g.,
|
||||
`$build/examples/c/calc/calc.log`).
|
||||
|
||||
Once you ran the test suite, and therefore have many testsuite.log files,
|
||||
run, from the source tree:
|
||||
### The Main Test Suite
|
||||
The main test suite, in tests/, is written on top of GNU Autotest, which is
|
||||
part of Autoconf. Run `info autoconf 'Using Autotest'` to read the
|
||||
documentation, not only about how to write tests, but also where are the
|
||||
logs, how to read them etc.
|
||||
|
||||
$ ./build-aux/update-test _build/tests/testsuite.dir/*/testsuite.log
|
||||
The main test suite generates a log for each test (e.g.,
|
||||
`$build/tests/testsuite.dir/004/testsuite.log` for test #4), and a main log
|
||||
file in `$build/tests/testsuite.log`. The latter is meant for end users: it
|
||||
contains lots of details that should help diagnosing issues, including build
|
||||
issues. The per-test logs are more convenient when working locally.
|
||||
|
||||
where `_build` would be your build tree. This will hopefully update most
|
||||
tests. Re-run the test suite. It might be interesting to run `update-test`
|
||||
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...
|
||||
|
||||
## TESTSUITEFLAGS
|
||||
To run just the test suite (not the tests related to the examples), run `make
|
||||
check-local`.
|
||||
#### TESTSUITEFLAGS
|
||||
To run just the main test suite, run `make check-local`.
|
||||
|
||||
The default is for make check-local to run all tests sequentially. This can
|
||||
be very time consuming when checking repeatedly or on slower setups. This
|
||||
@@ -230,6 +338,10 @@ with AT_KEYWORDS([[category]]). Categories include:
|
||||
- java, for java parsers
|
||||
- report, for automaton dumps
|
||||
|
||||
To get a list of all the tests (and their keywords for -k), run
|
||||
|
||||
$ ./tests/testsuite -l
|
||||
|
||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
||||
|
||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||
@@ -242,18 +354,21 @@ To rerun the tests that failed:
|
||||
|
||||
$ make recheck -j5
|
||||
|
||||
## Typical errors
|
||||
If the test suite shows failures such as the following one
|
||||
#### Updating the Expectations
|
||||
Sometimes some changes have a large impact on the test suite (e.g., when we
|
||||
added the `[-Wother]` part to all the warnings). Part of the update can be
|
||||
done with a crude tool: `build-aux/update-test`.
|
||||
|
||||
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
|
||||
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
|
||||
Once you ran the test suite, and therefore have many `testsuite.log` files,
|
||||
run, from the source tree:
|
||||
|
||||
it probably means that some file was compiled without
|
||||
`AT_DATA_SOURCE_PROLOGUE`. This error is due to the fact that our -I
|
||||
options pick up gnulib's replacement headers, such as getopt.h, and this
|
||||
will go wrong if config.h was not included first.
|
||||
$ ./build-aux/update-test $build/tests/testsuite.dir/*/testsuite.log
|
||||
|
||||
where `$build` would be your build tree. This will hopefully update most
|
||||
tests. Re-run the test suite. It might be interesting to run `update-test`
|
||||
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...
|
||||
|
||||
See tests/local.at for details.
|
||||
|
||||
## make maintainer-check-valgrind
|
||||
This target uses valgrind both to check bison, and the generated parsers.
|
||||
@@ -329,175 +444,16 @@ re-run the tests, run:
|
||||
./configure -C CC='gcc-mp-8 -fsanitize=undefined' CFLAGS='-ggdb'
|
||||
make check
|
||||
|
||||
# Release Procedure
|
||||
This section needs to be updated to take into account features from gnulib.
|
||||
In particular, be sure to read README-release.
|
||||
|
||||
## Update the submodules. See above.
|
||||
|
||||
## Update maintainer tools, such as Autoconf. See above.
|
||||
|
||||
## Try to get the *.pot files to the Translation Project at least one
|
||||
week before a stable release, to give them time to translate them. Before
|
||||
generating the *.pot files, make sure that po/POTFILES.in and
|
||||
runtime-po/POTFILES.in list all files with translatable strings. This
|
||||
helps: `grep -l '\<_(' *`.
|
||||
|
||||
## Tests
|
||||
See above.
|
||||
|
||||
## Update the foreign files
|
||||
Running `./bootstrap` in the top level should update them all for you. This
|
||||
covers PO files too. Sometimes a PO file contains problems that causes it
|
||||
to be rejected by recent Gettext releases; please report these to the
|
||||
Translation Project.
|
||||
|
||||
## Update README
|
||||
Make sure the information in README is current. Most notably, make sure it
|
||||
recommends a version of GNU M4 that is compatible with the latest Bison
|
||||
sources.
|
||||
|
||||
## Check copyright years.
|
||||
We update years in copyright statements throughout Bison once at the start
|
||||
of every year by running `make update-copyright`. However, before a
|
||||
release, it's good to verify that it's actually been run. Besides the
|
||||
copyright statement for each Bison file, check the copyright statements that
|
||||
the skeletons insert into generated parsers, and check all occurrences of
|
||||
PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
||||
|
||||
## Update NEWS, commit and tag.
|
||||
See do-release-commit-and-tag in README-release. For a while, we used beta
|
||||
names such as `2.6_rc1`. Now that we use gnulib in the release procedure,
|
||||
we must use `2.5.90`, which has the additional benefit of being properly
|
||||
sorted in `git tag -l`.
|
||||
|
||||
## make alpha, beta, or stable
|
||||
See README-release.
|
||||
|
||||
## Upload
|
||||
There are two ways to upload the tarballs to the GNU servers: using gnupload
|
||||
(from gnulib), or by hand. Obviously prefer the former. But in either
|
||||
case, be sure to read the following paragraph.
|
||||
|
||||
### Setup
|
||||
You need `gnupg`.
|
||||
|
||||
Make sure your public key has been uploaded at least to keys.gnupg.net. You
|
||||
can upload it with:
|
||||
|
||||
gpg --keyserver keys.gnupg.net --send-keys F125BDF3
|
||||
|
||||
where F125BDF3 should be replaced with your key ID.
|
||||
|
||||
### Using gnupload
|
||||
You need `ncftp`.
|
||||
|
||||
At the end `make stable` (or alpha/beta) will display the procedure to run.
|
||||
Just copy and paste it in your shell.
|
||||
|
||||
### By hand
|
||||
|
||||
The generic GNU upload procedure is at
|
||||
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads.
|
||||
|
||||
Follow the instructions there to register your information so you're permitted
|
||||
to upload.
|
||||
|
||||
Here's a brief reminder of how to roll the tarballs and upload them:
|
||||
|
||||
### make distcheck
|
||||
### gpg -b bison-2.3b.tar.gz
|
||||
### In a file named `bison-2.3b.tar.gz.directive`, type:
|
||||
|
||||
version: 1.1
|
||||
directory: bison
|
||||
filename: bison-2.3b.tar.gz
|
||||
|
||||
### gpg --clearsign bison-2.3b.tar.gz.directive
|
||||
### ftp ftp-upload.gnu.org # Log in as anonymous.
|
||||
### cd /incoming/alpha # cd /incoming/ftp for full release.
|
||||
### put bison-2.3b.tar.gz # This can take a while.
|
||||
### put bison-2.3b.tar.gz.sig
|
||||
### put bison-2.3b.tar.gz.directive.asc
|
||||
### Repeat all these steps for bison-2.3b.tar.xz.
|
||||
|
||||
## Update Bison manual on www.gnu.org.
|
||||
|
||||
The instructions below are obsolete, and left in case one would like to run
|
||||
the commands by hand. Today, one just needs to run
|
||||
|
||||
$ make web-manual-update
|
||||
Release Procedure
|
||||
=================
|
||||
|
||||
See README-release.
|
||||
|
||||
### You need a non-anonymous checkout of the web pages directory.
|
||||
|
||||
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
|
||||
|
||||
### Get familiar with the instructions for web page maintainers.
|
||||
http://www.gnu.org/server/standards/readme_index.html
|
||||
http://www.gnu.org/server/standards/README.software.html
|
||||
especially the note about symlinks.
|
||||
|
||||
### Build the web pages.
|
||||
Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
|
||||
BISON_WWW_CHECKOUT refers to the web directory created above, do:
|
||||
|
||||
$ cd $BISON_CHECKOUT/doc
|
||||
$ make stamp-vti
|
||||
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
|
||||
bison "Bison - GNU parser generator"
|
||||
$ cd $BISON_WWW_CHECKOUT
|
||||
|
||||
Verify that the result looks sane.
|
||||
|
||||
### Commit the modified and the new files.
|
||||
|
||||
### Remove old files.
|
||||
Find the files which have not been overwritten (because they belonged to
|
||||
sections that have been removed or renamed):
|
||||
|
||||
$ cd manual/html_node
|
||||
$ ls -lt
|
||||
|
||||
Remove these files and commit their removal to CVS. For each of these
|
||||
files, add a line to the file .symlinks. This will ensure that hyperlinks
|
||||
to the removed files will redirect to the entire manual; this is better than
|
||||
a 404 error.
|
||||
|
||||
## Announce
|
||||
The "make release" command just created a template,
|
||||
`$HOME/announce-bison-X.Y`. Otherwise, to generate it, run:
|
||||
|
||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
||||
|
||||
where alpha can be replaced by `beta` or `table` and F125BDF3 should be
|
||||
replaced with your key ID.
|
||||
|
||||
Complete/fix the announcement file. The generated list of recipients
|
||||
(info-gnu@gnu.org, bison-announce@gnu.org, bug-bison@gnu.org,
|
||||
help-bison@gnu.org, bison-patches@gnu.org, and
|
||||
coordinator@translationproject.org) is appropriate for a stable release or a
|
||||
"serious beta". For any other release, drop at least info-gnu@gnu.org. For
|
||||
an example of how to fill out the rest of the template, search the mailing
|
||||
list archives for the most recent release announcement.
|
||||
|
||||
For a stable release, send the same announcement on the comp.compilers
|
||||
newsgroup by sending email to compilers@iecc.com. Do not make any Cc as the
|
||||
moderator will throw away anything cross-posted or Cc'ed. It really needs
|
||||
to be a separate message.
|
||||
|
||||
## Prepare NEWS
|
||||
So that developers don't accidentally add new items to the old NEWS entry,
|
||||
create a new empty entry in line 3 (without the two leading spaces):
|
||||
|
||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||
|
||||
Push these changes.
|
||||
|
||||
<!--
|
||||
|
||||
Copyright (C) 2002-2005, 2007-2015, 2018-2019 Free Software Foundation,
|
||||
Copyright (C) 2002-2005, 2007-2015, 2018-2020 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
@@ -526,9 +482,11 @@ LocalWords: submodule init cd distcheck ChangeLog valgrind sigreturn sudo
|
||||
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||
LocalWords: symlinks vti html lt POSIX Cc'ed Graphviz Texinfo autoconf jN
|
||||
LocalWords: automake autopoint graphviz texinfo PROG Wother parsers
|
||||
LocalWords: TESTSUITEFLAGS deprec struct gnulib's getopt config ggdb
|
||||
LocalWords: bitset fsanitize symlink CFLAGS MERCHANTABILITY ispell
|
||||
LocalWords: american
|
||||
LocalWords: automake autopoint graphviz texinfo PROG Wother parsers YYFOO
|
||||
LocalWords: TESTSUITEFLAGS deprec struct gnulib's getopt config ggdb yyfoo
|
||||
LocalWords: bitset fsanitize symlink CFLAGS MERCHANTABILITY ispell wrt YY
|
||||
LocalWords: american Administrivia camlCase yy accessors namespace src
|
||||
LocalWords: getExpectedTokens yyexpectedTokens yygetExpectedTokens
|
||||
LocalWords: regen dogfooding Autotest testsuite
|
||||
|
||||
-->
|
||||
|
||||
@@ -4,8 +4,10 @@ it is today without the invaluable help of these people:
|
||||
Aaro Koskinen [email protected]
|
||||
Аскар Сафин [email protected]
|
||||
Adam Sampson [email protected]
|
||||
Adrian Vogelsgesang [email protected]
|
||||
Ahcheong Lee [email protected]
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille akim@lrde.epita.fr
|
||||
Akim Demaille akim@gnu.org
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Alexandre Duret-Lutz [email protected]
|
||||
@@ -60,6 +62,8 @@ Enrico Scholz [email protected]
|
||||
Eric Blake [email protected]
|
||||
Eric S. Raymond [email protected]
|
||||
Étienne Renault [email protected]
|
||||
Evan Lavelle [email protected]
|
||||
Evan Nemerson [email protected]
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
Ferdinand Thiessen [email protected]
|
||||
@@ -79,6 +83,7 @@ Hans Åberg [email protected]
|
||||
Horst Von Brand [email protected]
|
||||
Jan Nieuwenhuizen [email protected]
|
||||
Jannick [email protected]
|
||||
Jeff Hammond [email protected]
|
||||
Jerry Quinn [email protected]
|
||||
Jesse Thilo [email protected]
|
||||
Jim Kent [email protected]
|
||||
@@ -128,6 +133,7 @@ Nick Bowler [email protected]
|
||||
Nicolas Bedon [email protected]
|
||||
Nicolas Burrus [email protected]
|
||||
Nicolas Tisserand [email protected]
|
||||
Nikki Valen [email protected]
|
||||
Noah Friedman [email protected]
|
||||
Odd Arild Olsen [email protected]
|
||||
Oleg Smolsky [email protected]
|
||||
@@ -205,8 +211,9 @@ Wwp [email protected]
|
||||
xolodho [email protected]
|
||||
Yuichiro Kaneko [email protected]
|
||||
Zack Weinberg [email protected]
|
||||
長田偉伸 [email protected]
|
||||
江 祖铭 [email protected]
|
||||
長田偉伸 [email protected]
|
||||
马俊 [email protected]
|
||||
|
||||
Many people are not named here because we lost track of them. We
|
||||
thank them! Please, help us keeping this list up to date.
|
||||
@@ -218,7 +225,7 @@ End:
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2000-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Parser Generator.
|
||||
|
||||
|
||||
@@ -1,61 +1,65 @@
|
||||
* Bison 3.5
|
||||
* Bison 3.6
|
||||
** Questions
|
||||
*** Java
|
||||
- Should i18n be part of the Lexer? Currently it's a static method of
|
||||
Lexer.
|
||||
|
||||
- is there a migration path that would allow to use TokenKinds in
|
||||
yylex?
|
||||
|
||||
*** D
|
||||
- is there a way to attach yysymbol_name to the enum itself? As we did
|
||||
in Java.
|
||||
|
||||
- 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
|
||||
|
||||
** 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).
|
||||
|
||||
** doc
|
||||
I feel its ugly to use the GNU style to declare functions in the doc. It
|
||||
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
|
||||
breaks.
|
||||
|
||||
Also, we seem to teach YYPRINT very early on, although it should be
|
||||
considered deprecated: %printer is superior.
|
||||
|
||||
** improve syntax errors (UTF-8, internationalization)
|
||||
Bison depends on the current locale. For instance:
|
||||
|
||||
%define parse.error verbose
|
||||
%code top {
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
void yyerror(const char* msg) { fprintf(stderr, "%s\n", msg); }
|
||||
int yylex() { return 0; }
|
||||
}
|
||||
%%
|
||||
exp: "↦" | "🎅🐃" | '\n'
|
||||
%%
|
||||
int main() { return yyparse(); }
|
||||
|
||||
gives different results with/without LC_ALL=C.
|
||||
|
||||
$ LC_ALL=C /opt/local/bin/bison /tmp/mangle.y -o ascii.c
|
||||
$ /opt/local/bin/bison /tmp/mangle.y -o utf8.c
|
||||
$ diff -u ascii.c utf8.c -I#line
|
||||
--- ascii.c 2019-01-12 08:15:35.878010093 +0100
|
||||
+++ utf8.c 2019-01-12 08:15:38.856495929 +0100
|
||||
@@ -415,9 +415,8 @@
|
||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||
static const char *const yytname[] =
|
||||
{
|
||||
- "$end", "error", "$undefined", "\"\\342\\206\\246\"",
|
||||
- "\"\\360\\237\\216\\205\\360\\237\\220\\203\"", "'\\n'", "$accept",
|
||||
- "exp", YY_NULLPTR
|
||||
+ "$end", "error", "$undefined", "\"↦\"", "\"🎅🐃\"", "'\\n'",
|
||||
+ "$accept", "exp", YY_NULLPTR
|
||||
};
|
||||
#endif
|
||||
|
||||
$ gcc ascii.c -o ascii && ./ascii
|
||||
syntax error, unexpected $end, expecting "\342\206\246" or "\360\237\216\205\360\237\220\203" or '\n'
|
||||
$ gcc utf8.c -o utf8 && ./utf8
|
||||
syntax error, unexpected $end, expecting ↦ or 🎅🐃 or '\n'
|
||||
|
||||
|
||||
While at it, we should stop using "$end" by default, in favor of "end of
|
||||
file", or "end of input", whatever. See how lalr1.java does that.
|
||||
** consistency
|
||||
token vs terminal, variable vs non terminal.
|
||||
|
||||
** api.token.raw
|
||||
Maybe we should exhibit the YYUNDEFTOK token. It could also be assigned a
|
||||
semantic value so that yyerror could be used to report invalid lexemes.
|
||||
See also the item "$undefined" below.
|
||||
The YYUNDEFTOK could be assigned a semantic value so that yyerror could be
|
||||
used to report invalid lexemes. See also the item "$undefined" below.
|
||||
|
||||
* Bison 3.6
|
||||
** push parsers
|
||||
Consider deprecating impure push parsers. They add a lot of complexity, for
|
||||
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.
|
||||
|
||||
** 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.
|
||||
|
||||
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).
|
||||
|
||||
* Bison 3.8
|
||||
** Unit rules / Injection rules (Akim Demaille)
|
||||
Maybe we could expand unit rules (or "injections", see
|
||||
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
|
||||
@@ -110,6 +114,16 @@ functions.
|
||||
states/nstates, rules/nrules, ..., ritem/nritems
|
||||
Fix the latter.
|
||||
|
||||
* Better error messages
|
||||
The users are not provided with enough tools to forge their error messages.
|
||||
See for instance "Is there an option to change the message produced by
|
||||
YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
|
||||
|
||||
See also
|
||||
https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
|
||||
https://research.swtch.com/yyerror
|
||||
http://gallium.inria.fr/~fpottier/publis/fpottier-reachability-cc2016.pdf
|
||||
|
||||
* Modernization
|
||||
Fix data/skeletons/yacc.c so that it defines YYPTRDIFF_T properly for modern
|
||||
and older C++ compilers. Currently the code defaults to defining it to
|
||||
@@ -119,10 +133,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.cc, lalr1.cc
|
||||
- ielr: C++ and Java
|
||||
- glr: Java
|
||||
- token constructors: Java and C
|
||||
- push parsers: glr.c, glr.cc, lalr1.cc
|
||||
- lac: D, Java
|
||||
- glr: D, Java
|
||||
- token constructors: Java, C, D
|
||||
|
||||
* Bugs
|
||||
** Autotest has quotation issues
|
||||
@@ -134,55 +148,12 @@ $ ./tests/testsuite -l | grep errors | sed q
|
||||
38: input.at:1730 errors
|
||||
|
||||
* Short term
|
||||
** Stop indentation in diagnostics
|
||||
Before Bison 2.7, we printed "flatly" the dependencies in long diagnostics:
|
||||
|
||||
input.y:2.7-12: %type redeclaration for exp
|
||||
input.y:1.7-12: previous declaration
|
||||
|
||||
In Bison 2.7, we indented them
|
||||
|
||||
input.y:2.7-12: error: %type redeclaration for exp
|
||||
input.y:1.7-12: previous declaration
|
||||
|
||||
Later we quoted the source in the diagnostics, and today we have:
|
||||
|
||||
/tmp/foo.y:1.12-14: warning: symbol FOO redeclared [-Wother]
|
||||
1 | %token FOO FOO
|
||||
| ^~~
|
||||
/tmp/foo.y:1.8-10: previous declaration
|
||||
1 | %token FOO FOO
|
||||
| ^~~
|
||||
|
||||
The indentation is no longer helping. We should probably get rid of it, or
|
||||
maybe keep it only when -fno-caret. GCC displays this as a "note":
|
||||
|
||||
$ g++-mp-9 -Wall /tmp/foo.c -c
|
||||
/tmp/foo.c:1:10: error: redefinition of 'int foo'
|
||||
1 | int foo, foo;
|
||||
| ^~~
|
||||
/tmp/foo.c:1:5: note: 'int foo' previously declared here
|
||||
1 | int foo, foo;
|
||||
| ^~~
|
||||
|
||||
Likewise for Clang, contrary to what I believed (because "note:" is written
|
||||
in black, so it doesn't show in my terminal :-)
|
||||
|
||||
$ clang++-mp-8.0 -Wall /tmp/foo.c -c
|
||||
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
|
||||
/tmp/foo.c:1:10: error: redefinition of 'foo'
|
||||
int foo, foo;
|
||||
^
|
||||
/tmp/foo.c:1:5: note: previous definition is here
|
||||
int foo, foo;
|
||||
^
|
||||
1 error generated.
|
||||
|
||||
See also the item "Complaint submessage indentation" below.
|
||||
** Get rid of YYPRINT and b4_toknum
|
||||
Besides yytoknum is wrong when api.token.raw is defined.
|
||||
|
||||
** Better design for diagnostics
|
||||
The current implementation of diagnostics is adhoc, it grew organically. It
|
||||
works as a series of calls to several functions, with dependency of the
|
||||
The current implementation of diagnostics is ad hoc, it grew organically.
|
||||
It works as a series of calls to several functions, with dependency of the
|
||||
latter calls on the former. For instance:
|
||||
|
||||
complain (&sym->location,
|
||||
@@ -214,20 +185,6 @@ page:
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
|
||||
|
||||
** consistency
|
||||
token vs terminal, variable vs non terminal.
|
||||
|
||||
** C++
|
||||
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
||||
itself uses int (for yylen for instance), yet stack is based on size_t.
|
||||
|
||||
Maybe locations should also move to ints.
|
||||
|
||||
Paul Eggert already covered most of this. But before publishing these
|
||||
changes, we need to ask our C++ users if they agree with that change, or if
|
||||
we need some migration path. Could be a %define variable, or simply
|
||||
%require "3.5".
|
||||
|
||||
** Graphviz display code thoughts
|
||||
The code for the --graph option is over two files: print_graph, and
|
||||
graphviz. This is because Bison used to also produce VCG graphs, but since
|
||||
@@ -311,52 +268,7 @@ It would be a very nice source of inspiration for the other languages.
|
||||
|
||||
Valentin Tolmer is working on this.
|
||||
|
||||
** YYERRCODE
|
||||
Defined to 256, but not used, not documented. Probably the token
|
||||
number for the error token, which POSIX wants to be 256, but which
|
||||
Bison might renumber if the user used number 256. Keep fix and doc?
|
||||
Throw away?
|
||||
|
||||
Also, why don't we output the token name of the error token in the
|
||||
output? It is explicitly skipped:
|
||||
|
||||
/* Skip error token and tokens without identifier. */
|
||||
if (sym != errtoken && id)
|
||||
|
||||
Of course there are issues with name spaces, but if we disable we have
|
||||
something which seems to be more simpler and more consistent instead
|
||||
of the special case YYERRCODE.
|
||||
|
||||
enum yytokentype {
|
||||
error = 256,
|
||||
// ...
|
||||
};
|
||||
|
||||
|
||||
We could (should?) also treat the case of the undef_token, which is
|
||||
numbered 257 for yylex, and 2 internal. Both appear for instance in
|
||||
toknum:
|
||||
|
||||
const unsigned short
|
||||
parser::yytoken_number_[] =
|
||||
{
|
||||
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
||||
|
||||
while here
|
||||
|
||||
enum yytokentype {
|
||||
TOK_EOF = 0,
|
||||
TOK_EQ = 258,
|
||||
|
||||
so both 256 and 257 are "mysterious".
|
||||
|
||||
const char*
|
||||
const parser::yytname_[] =
|
||||
{
|
||||
"\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
|
||||
|
||||
|
||||
** yychar == yyempty_
|
||||
** yychar == YYEMPTY
|
||||
The code in yyerrlab reads:
|
||||
|
||||
if (yychar <= YYEOF)
|
||||
@@ -388,14 +300,6 @@ We need trustworthy benchmarks for Bison, for all our backends. Akim has a
|
||||
few things scattered around; we need to put them in the repo, and make them
|
||||
more useful.
|
||||
|
||||
** yysyntax_error
|
||||
The code bw glr.c and yacc.c is really alike, we can certainly factor
|
||||
some parts.
|
||||
|
||||
This should be worked on when we also address the expected improvements for
|
||||
error generation (e.g., i18n).
|
||||
|
||||
|
||||
* Report
|
||||
|
||||
** Figures
|
||||
@@ -433,6 +337,11 @@ An Experimental Ambiguity Detection Tool ∗ Sylvain Schmitz
|
||||
LORIA, INRIA Nancy - Grand Est, Nancy, France
|
||||
|
||||
* Extensions
|
||||
** More languages?
|
||||
Well, only if there is really some demand for it.
|
||||
|
||||
https://github.com/scfc/bison-php/blob/master/data/lalr1.php
|
||||
|
||||
** Multiple start symbols
|
||||
Would be very useful when parsing closely related languages. The idea is to
|
||||
declare several start symbols, for instance
|
||||
@@ -455,15 +364,6 @@ happen with yy_start: stmt | expr). Then adjust the skeletons so that this
|
||||
initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the
|
||||
corresponding parse function.
|
||||
|
||||
** Better error messages
|
||||
The users are not provided with enough tools to forge their error messages.
|
||||
See for instance "Is there an option to change the message produced by
|
||||
YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
|
||||
|
||||
See also
|
||||
https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
|
||||
and https://research.swtch.com/yyerror.
|
||||
|
||||
** %include
|
||||
This is a popular demand. We already made many changes in the parser that
|
||||
should make this reasonably easy to implement.
|
||||
@@ -600,23 +500,6 @@ to bison. If you're interested, I'll work on a patch.
|
||||
* Better graphics
|
||||
Equip the parser with a means to create the (visual) parse tree.
|
||||
|
||||
* Complaint submessage indentation.
|
||||
We already have an implementation that works fairly well for named
|
||||
reference messages, but it would be nice to use it consistently for all
|
||||
submessages from Bison. For example, the "previous definition"
|
||||
submessage or the list of correct values for a %define variable might
|
||||
look better with indentation.
|
||||
|
||||
However, the current implementation makes the assumption that the
|
||||
location printed on the first line is not usually much shorter than the
|
||||
locations printed on the submessage lines that follow. That assumption
|
||||
may not hold true as often for some kinds of submessages especially if
|
||||
we ever support multiple grammar files.
|
||||
|
||||
Here's a proposal for how a new implementation might look:
|
||||
|
||||
http://lists.gnu.org/archive/html/bison-patches/2009-09/msg00086.html
|
||||
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
@@ -626,7 +509,7 @@ End:
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2019 Free Software
|
||||
Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2020 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2019-01-04.17; # UTC
|
||||
scriptversion=2020-04-13.15; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
# Copyright (C) 2003-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-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
|
||||
@@ -970,7 +970,7 @@ bootstrap_post_import_hook \
|
||||
# Uninitialized submodules are listed with an initial dash.
|
||||
if $use_git && git submodule | grep '^-' >/dev/null; then
|
||||
die "some git submodules are not initialized. " \
|
||||
"Run 'git submodule init' and bootstrap again."
|
||||
"Run 'git submodule update --init' and bootstrap again."
|
||||
fi
|
||||
|
||||
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2015, 2018-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
|
||||
@@ -37,6 +37,7 @@ gnulib_modules='
|
||||
obstack-printf
|
||||
perror progname
|
||||
quote quotearg
|
||||
readline
|
||||
readme-release
|
||||
realloc-posix
|
||||
relocatable-prog relocatable-script
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2015, 2018-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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2015, 2018-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
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
#! /usr/bin/env perl
|
||||
|
||||
# Generate a release announcement message.
|
||||
|
||||
# Copyright (C) 2007-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 <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Written by Akim Demaille.
|
||||
|
||||
use warnings;
|
||||
use 5.005;
|
||||
use strict;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2000-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2000-2015, 2018-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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Update b4_copyright invocations or b4_copyright_years definitions to
|
||||
# include the current year.
|
||||
|
||||
# Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2015, 2018-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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
|
||||
|
||||
# Copyright (C) 2010-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2010-2015, 2018-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
|
||||
|
||||
+20
-1
@@ -1,5 +1,24 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# Update expectations in an Autotest test suite.
|
||||
|
||||
# Copyright (C) 2019-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 <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Written by Akim Demaille.
|
||||
|
||||
# usage:
|
||||
#
|
||||
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
|
||||
@@ -83,7 +102,7 @@ def update(at_file, logfile):
|
||||
def process(logfile):
|
||||
log = contents(logfile)
|
||||
# Look for the file to update.
|
||||
m = re.search(r'^\d+\. ([-\w]+\.at):\d+: ', log, re.MULTILINE)
|
||||
m = re.search(r'^\d+\. ([\-\+\w]+\.at):\d+: ', log, re.MULTILINE)
|
||||
if not m:
|
||||
trace("no diff found:", logfile)
|
||||
return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## Customize maint.mk -*- makefile -*-
|
||||
## Copyright (C) 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2008-2015, 2018-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
|
||||
@@ -156,7 +156,7 @@ exclude = \
|
||||
$(call exclude, \
|
||||
bindtextdomain=^lib/main.c$$ \
|
||||
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
||||
po_check=(^po/POTFILES.in|.md)$$ \
|
||||
po_check=^(examples|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$$ \
|
||||
@@ -165,7 +165,7 @@ $(call exclude,
|
||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||
prohibit_strcmp=^doc/bison\.texi|examples|tests/local\.at$$ \
|
||||
prohibit_strcmp=^doc/bison\.texi|examples|tests \
|
||||
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^\.git|tests/input.at|Makefile$$ \
|
||||
require_config_h=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||
require_config_h_first=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||
|
||||
+44
-7
@@ -1,6 +1,6 @@
|
||||
# Configure template for GNU Bison. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2001-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2015, 2018-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
|
||||
@@ -26,8 +26,10 @@ m4_pattern_allow([^BISON_USE_NLS$])
|
||||
|
||||
AC_INIT([GNU Bison],
|
||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||
[[email protected]])
|
||||
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2019])
|
||||
[[email protected]],
|
||||
[],
|
||||
[https://www.gnu.org/software/bison/])
|
||||
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2020])
|
||||
AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
|
||||
[The copyright year for this package])
|
||||
|
||||
@@ -100,12 +102,41 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
# -Wno-tautological-constant-out-of-range-compare for Clang 3.3 and
|
||||
# 3.4 on GNU/Linux that choke on intprops.h's INT_MULTIPLY_WRAPV,
|
||||
# etc.
|
||||
warn_common='-Wall -Wextra -Wcast-align
|
||||
#
|
||||
# ICC: -wr188
|
||||
#
|
||||
# 1669 warnings warnings_default =
|
||||
# ../src/complain.c(318): error #188: enumerated type mixed with another type
|
||||
# 1670 Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||
# 1671 ^
|
||||
# 1672
|
||||
# 1673../src/complain.c(393): error #188: enumerated type mixed with another type
|
||||
# 1674 warnings w = 1 << wbit;
|
||||
# 1675 ^
|
||||
#
|
||||
# ICC: -wr3179
|
||||
#
|
||||
# char const *usefulness
|
||||
# = rule_useless_in_grammar_p (&rules[r]) ? "useless-in-grammar"
|
||||
# : rule_useless_in_parser_p (&rules[r]) ? "useless-in-parser"
|
||||
# : "useful";
|
||||
#
|
||||
# gives
|
||||
#
|
||||
# error #3179: deprecated conversion of string literal to char* (should be const char*)
|
||||
#
|
||||
# ICC: -wr2259 (that's in C, in spite of what the error messages which seems to be about C++).
|
||||
# error #2259: non-pointer conversion from "int" to "yybool={signed char}" may lose significant bits
|
||||
# yybool yynormal YY_ATTRIBUTE_UNUSED = yystackp->yysplitPoint == YY_NULLPTR;
|
||||
# ^
|
||||
warn_common='-Wall -Wextra
|
||||
-Wcast-align -Wchar-subscripts
|
||||
-fparse-all-comments -Wdocumentation
|
||||
-Wformat -Wimplicit-fallthrough -Wnull-dereference
|
||||
-Wno-sign-compare -Wno-tautological-constant-out-of-range-compare
|
||||
-Wpointer-arith -Wshadow
|
||||
-Wwrite-strings'
|
||||
-Wwrite-strings
|
||||
-wr188 -wr2259 -wr3179'
|
||||
warn_c='-Wbad-function-cast -Wstrict-prototypes'
|
||||
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
|
||||
-Wweak-vtables'
|
||||
@@ -151,8 +182,6 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
|
||||
# Warnings for the test suite, and maybe for bison if GCC is modern
|
||||
# enough.
|
||||
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
|
||||
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
|
||||
test $lv_cv_gcc_pragma_push_works = yes &&
|
||||
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
||||
|
||||
@@ -179,6 +208,14 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
[[if (sizeof (long) < sizeof (int)) return 1;]])])
|
||||
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
||||
[AC_LANG_PROGRAM([], [nullptr])])
|
||||
# Before GCC6, the pragmas don't work well enough to neutralize
|
||||
# this warning.
|
||||
gl_WARN_ADD([-Wuseless-cast], [WARN_CXXFLAGS],
|
||||
[AC_LANG_PROGRAM([], [
|
||||
#if defined __GNUC__ && ! defined __ICC && ! defined __clang__ && __GNUC__ < 6
|
||||
syntax error
|
||||
#endif
|
||||
])])
|
||||
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
||||
# Warnings for the test suite only.
|
||||
for i in $warn_tests;
|
||||
|
||||
+13
-6
@@ -83,18 +83,20 @@ field), where field can `has_id`, `id`, etc.: see
|
||||
|
||||
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||
|
||||
- `has_id`: 0 or 1.
|
||||
|
||||
- `has_id`: 0 or 1
|
||||
Whether the symbol has an id.
|
||||
|
||||
- `id`: string
|
||||
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
|
||||
defined as empty. Guaranteed to be usable as a C identifier.
|
||||
defined as empty. Guaranteed to be usable as a C identifier. This is
|
||||
used to define the token kind (i.e., the enum used by the return value of
|
||||
yylex).
|
||||
|
||||
- `tag`: string.
|
||||
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||
- `tag`: string
|
||||
A human representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||
|
||||
- `user_number`: integer
|
||||
The code associated to the `id`.
|
||||
The external number as used by yylex. Can be ASCII code when a character,
|
||||
some number chosen by bison, or some user number in the case of
|
||||
%token FOO <NUM>. Corresponds to yychar in yacc.c.
|
||||
@@ -102,7 +104,12 @@ The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||
- `is_token`: 0 or 1
|
||||
Whether this is a terminal symbol.
|
||||
|
||||
- `kind`: string
|
||||
The symbol kind, i.e., the enumerator of this symbol (token or nonterminal)
|
||||
which is mapping to its `number`.
|
||||
|
||||
- `number`: integer
|
||||
The code associated to the `kind`.
|
||||
The internal number (computed from the external number by yytranslate).
|
||||
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
||||
key in b4_symbol(NUM, FIELD).
|
||||
@@ -174,7 +181,7 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2002, 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Default styling rules for Bison when doing terminal output.
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2019-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
|
||||
@@ -29,3 +29,6 @@
|
||||
|
||||
/* "Sections" in traces (--trace). */
|
||||
.trace0 { color: green; }
|
||||
|
||||
.expected { color: green; }
|
||||
.unexpected { color: red; }
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2002, 2005-2015, 2018-2019 Free Software Foundation,
|
||||
## Copyright (C) 2002, 2005-2015, 2018-2020 Free Software Foundation,
|
||||
## Inc.
|
||||
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface Lexer
|
||||
* to the next token and prepares to return the semantic value
|
||||
* and beginning/ending positions of the token.
|
||||
* @return the token identifier corresponding to the next token. */
|
||||
YYTokenType yylex ();
|
||||
TokenKind yylex ();
|
||||
|
||||
/**
|
||||
* Entry point for error reporting. Emits an error
|
||||
@@ -39,7 +39,7 @@ public interface Lexer
|
||||
void yyerror (YYLocation loc, string s);
|
||||
}
|
||||
|
||||
- semantic types are handled by D usions (same as for C/C++ parsers)
|
||||
- semantic types are handled by D unions (same as for C/C++ parsers)
|
||||
|
||||
- the following (non-standard) %defines are supported:
|
||||
|
||||
|
||||
+93
-42
@@ -2,7 +2,7 @@
|
||||
|
||||
# Language-independent M4 Macros for Bison.
|
||||
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -192,7 +192,7 @@ m4_define([b4_error],
|
||||
# @warn(1@)
|
||||
# @warn(1@,2@)
|
||||
m4_define([b4_warn],
|
||||
[b4_error([[warn]], [], [], $@)])
|
||||
[b4_warn_at([], [], $@)])
|
||||
|
||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# ---------------------------------------------------
|
||||
@@ -210,7 +210,7 @@ m4_define([b4_warn_at],
|
||||
#
|
||||
# See b4_warn example.
|
||||
m4_define([b4_complain],
|
||||
[b4_error([[complain]], [], [], $@)])
|
||||
[b4_complain_at([], [], $@)])
|
||||
|
||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# -------------------------------------------------------
|
||||
@@ -226,8 +226,7 @@ m4_define([b4_complain_at],
|
||||
#
|
||||
# See b4_warn example.
|
||||
m4_define([b4_fatal],
|
||||
[b4_error([[fatal]], [], [], $@)dnl
|
||||
m4_exit(1)])
|
||||
[b4_fatal_at([], [], $@)])
|
||||
|
||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# ----------------------------------------------------
|
||||
@@ -385,37 +384,64 @@ m4_define([b4_glr_cc_if],
|
||||
## Symbols. ##
|
||||
## --------- ##
|
||||
|
||||
# For a description of the Symbol handling, see README.
|
||||
# For a description of the Symbol handling, see README.md.
|
||||
#
|
||||
# The following macros provide access to symbol related values.
|
||||
|
||||
# __b4_symbol(NUM, FIELD)
|
||||
# -----------------------
|
||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||
# undefined.
|
||||
# Fetch FIELD of symbol #NUM. Fail if undefined.
|
||||
m4_define([__b4_symbol],
|
||||
[m4_indir([b4_symbol($1, $2)])])
|
||||
|
||||
|
||||
# _b4_symbol(NUM, FIELD)
|
||||
# ----------------------
|
||||
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||
# undefined.
|
||||
# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md).
|
||||
# Fail if undefined.
|
||||
m4_define([_b4_symbol],
|
||||
[m4_ifdef([b4_symbol($1, number)],
|
||||
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
|
||||
[__b4_symbol([$1], [$2])])])
|
||||
|
||||
|
||||
# b4_symbol_token_kind(NUM)
|
||||
# -------------------------
|
||||
# The token kind of this symbol.
|
||||
m4_define([b4_symbol_token_kind],
|
||||
[b4_percent_define_get([api.token.prefix])dnl
|
||||
_b4_symbol([$1], [id])])
|
||||
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
# Build the name of the kind of this symbol. It must always exist,
|
||||
# otherwise some symbols might not be represented in the enum, which
|
||||
# might be compiled into too small a type to contain all the symbol
|
||||
# numbers.
|
||||
m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])])
|
||||
m4_define([b4_symbol_kind],
|
||||
[b4_percent_define_get([api.symbol.prefix])dnl
|
||||
m4_case([$1],
|
||||
[-2], [[YYEMPTY]],
|
||||
[0], [[YYEOF]],
|
||||
[1], [[YYERROR]],
|
||||
[2], [[YYUNDEF]],
|
||||
[m4_case(b4_symbol([$1], [tag]),
|
||||
[$accept], [[YYACCEPT]],
|
||||
[b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]),
|
||||
[m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])])
|
||||
|
||||
|
||||
# b4_symbol(NUM, FIELD)
|
||||
# ---------------------
|
||||
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||
# undefined. If FIELD = id, prepend the token prefix.
|
||||
# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined.
|
||||
#
|
||||
# If FIELD = id, prepend the token prefix.
|
||||
m4_define([b4_symbol],
|
||||
[m4_case([$2],
|
||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
||||
[_b4_symbol([$1], [id])])],
|
||||
[id], [b4_symbol_token_kind([$1])],
|
||||
[kind], [b4_symbol_kind([$1])],
|
||||
[_b4_symbol($@)])])
|
||||
|
||||
|
||||
@@ -438,9 +464,9 @@ m4_define([b4_symbol_tag_comment],
|
||||
])
|
||||
|
||||
|
||||
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||
# ----------------------------------
|
||||
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
||||
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
||||
# ------------------------------------
|
||||
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
||||
m4_define([b4_symbol_action],
|
||||
[b4_symbol_if([$1], [has_$2],
|
||||
[b4_dollar_pushdef([(*yyvaluep)],
|
||||
@@ -464,21 +490,21 @@ m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
|
||||
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
||||
|
||||
|
||||
# b4_symbol_actions(KIND, [TYPE = yytype])
|
||||
# ----------------------------------------
|
||||
# Emit the symbol actions for KIND ("printer" or "destructor").
|
||||
# Dispatch on TYPE.
|
||||
# b4_symbol_actions(ACTION, [KIND = yykind])
|
||||
# ------------------------------------------
|
||||
# Emit the symbol actions for ACTION ("destructor" or "printer").
|
||||
# Dispatch on KIND.
|
||||
m4_define([b4_symbol_actions],
|
||||
[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl
|
||||
m4_ifval(m4_defn([b4_actions_]),
|
||||
[switch (m4_default([$2], [yytype]))
|
||||
[switch (m4_default([$2], [yykind]))
|
||||
{
|
||||
m4_defn([b4_actions_])[]dnl
|
||||
default:
|
||||
break;
|
||||
}dnl
|
||||
],
|
||||
[YYUSE (m4_default([$2], [yytype]));])dnl
|
||||
[YYUSE (m4_default([$2], [yykind]));])dnl
|
||||
m4_popdef([b4_actions_])dnl
|
||||
])
|
||||
|
||||
@@ -508,13 +534,14 @@ m4_define([b4_symbol_map],
|
||||
|
||||
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
||||
# -------------------------------------------
|
||||
# Whether NUM denotes a token that has an exported definition (i.e.,
|
||||
# shows in enum yytokentype).
|
||||
# Whether NUM denotes a token kind that has an exported definition
|
||||
# (i.e., shows in enum yytokentype).
|
||||
m4_define([b4_token_visible_if],
|
||||
[b4_symbol_if([$1], [is_token],
|
||||
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
||||
[$3])])
|
||||
|
||||
|
||||
# b4_token_has_definition(NUM)
|
||||
# ----------------------------
|
||||
# 1 if NUM is visible, nothing otherwise.
|
||||
@@ -531,13 +558,27 @@ m4_define([b4_any_token_visible_if],
|
||||
|
||||
# b4_token_format(FORMAT, NUM)
|
||||
# ----------------------------
|
||||
# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER.
|
||||
m4_define([b4_token_format],
|
||||
[b4_token_visible_if([$2],
|
||||
[m4_quote(m4_format([$1],
|
||||
[b4_symbol([$2], [id])],
|
||||
[b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))]))])])
|
||||
[m4_format([[$1]],
|
||||
m4_expand(b4_symbol([$2], [id])),
|
||||
m4_expand(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])])
|
||||
|
||||
|
||||
# b4_last_enum_token
|
||||
# ------------------
|
||||
# The code of the last token visible token.
|
||||
m4_define([_b4_last_enum_token],
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_define([b4_last_enum_token], [$1])])])
|
||||
b4_symbol_foreach([_b4_last_enum_token])
|
||||
|
||||
# b4_last_symbol
|
||||
# --------------
|
||||
# The code of the last symbol.
|
||||
m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1))
|
||||
|
||||
## ------- ##
|
||||
## Types. ##
|
||||
## ------- ##
|
||||
@@ -604,7 +645,7 @@ m4_define([b4_sync_end], [ b4_comment([$2:$1])]
|
||||
# This generates dependencies on the Bison skeletons hence lots of
|
||||
# useless 'git diff'. This location is useless for the regular
|
||||
# user (who does not care about the skeletons) and is actually not
|
||||
# useful for Bison developpers too (I, Akim, never used this to locate
|
||||
# useful for Bison developers too (I, Akim, never used this to locate
|
||||
# the code in skeletons that generated output). So disable it
|
||||
# completely. If someone thinks this was actually useful, a %define
|
||||
# variable should be provided to control the level of verbosity of
|
||||
@@ -976,8 +1017,8 @@ m4_define([b4_percent_code_get],
|
||||
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
||||
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
||||
m4_ifdef(b4_macro_name,
|
||||
[b4_comment([m4_if([$#], [0], [[Unqualified %code]],
|
||||
[["%code ]$1["]])[ blocks.]])
|
||||
[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]],
|
||||
[[["%code ]$1[" blocks.]]]))
|
||||
b4_user_code([m4_indir(b4_macro_name)])])dnl
|
||||
m4_popdef([b4_macro_name])])
|
||||
|
||||
@@ -1017,21 +1058,23 @@ m4_define([b4_bison_locations_if],
|
||||
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
||||
|
||||
|
||||
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
|
||||
|
||||
# %define parse.error "(custom|detailed|simple|verbose)"
|
||||
# ------------------------------------------------------
|
||||
# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and
|
||||
# b4_error_verbose_flag.
|
||||
b4_percent_define_default([[parse.error]], [[simple]])
|
||||
b4_percent_define_check_values([[[[parse.error]],
|
||||
[[simple]], [[verbose]]]])
|
||||
m4_define([b4_error_verbose_flag],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]),
|
||||
[simple], [[0]],
|
||||
[verbose], [[1]])])
|
||||
b4_define_flag_if([error_verbose])
|
||||
[[custom]], [[detailed]], [[simple]], [[verbose]]]])
|
||||
|
||||
# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE)
|
||||
# ----------------------------------------------------------
|
||||
m4_define([b4_parse_error_case],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]), $@)])
|
||||
|
||||
# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE)
|
||||
# ------------------------------------------------------------------
|
||||
m4_define([b4_parse_error_bmatch],
|
||||
[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)])
|
||||
|
||||
# yytoken_table is needed to support verbose errors.
|
||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
||||
|
||||
|
||||
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
||||
@@ -1117,3 +1160,11 @@ b4_percent_define_ifdef([api.value.type],
|
||||
|
||||
# api.value.union.name.
|
||||
b4_percent_define_check_kind([api.value.union.name], [keyword])
|
||||
|
||||
# parse.error (custom|detailed) >< token-table.
|
||||
b4_token_table_if(
|
||||
[b4_parse_error_bmatch([custom\|detailed],
|
||||
[b4_complain_at(b4_percent_define_get_loc([parse.error]),
|
||||
[['%s' and '%s' cannot be used together]],
|
||||
[%token-table],
|
||||
[%define parse.error (custom|detailed)])])])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# C++ skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
+97
-81
@@ -2,7 +2,7 @@
|
||||
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-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
|
||||
@@ -22,6 +22,8 @@ b4_percent_define_ifdef([[api.value.union.name]],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
||||
[named %union is invalid in C++])])
|
||||
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
m4_include(b4_skeletonsdir/[c.m4])
|
||||
|
||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||
@@ -160,20 +162,42 @@ m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens as enums.
|
||||
# Output the definition of the token kinds.
|
||||
m4_define([b4_token_enums],
|
||||
[[enum yytokentype
|
||||
[[enum token_kind_type
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
};]dnl
|
||||
]b4_symbol([-2], [id])[ = -2,
|
||||
]b4_symbol_foreach([b4_token_enum])dnl
|
||||
[ };]dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[enum symbol_kind_type
|
||||
{
|
||||
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
|
||||
]b4_symbol_kind([-2])[ = -2,
|
||||
]b4_symbol_foreach([ b4_symbol_enum])dnl
|
||||
[ };]])
|
||||
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
@@ -231,23 +255,31 @@ m4_define([b4_public_types_declare],
|
||||
location_type location;])[
|
||||
};
|
||||
|
||||
/// Tokens.
|
||||
/// Token kinds.
|
||||
struct token
|
||||
{
|
||||
]b4_token_enums[
|
||||
/// Backward compatibility alias.
|
||||
typedef token_kind_type yytokentype;
|
||||
};
|
||||
|
||||
/// (External) token type, as returned by yylex.
|
||||
typedef token::yytokentype token_type;
|
||||
/// Token kind, as returned by yylex.
|
||||
typedef token::yytokentype token_kind_type;
|
||||
|
||||
/// Symbol type: an internal symbol number.
|
||||
typedef int symbol_number_type;
|
||||
/// Backward compatibility alias.
|
||||
typedef token_kind_type token_type;
|
||||
|
||||
/// The symbol type number to denote an empty symbol.
|
||||
enum { empty_symbol = -2 };
|
||||
/// Symbol kinds.
|
||||
struct symbol_kind
|
||||
{
|
||||
]b4_declare_symbol_enum[
|
||||
};
|
||||
|
||||
/// Internal symbol number for tokens (subsumed by symbol_number_type).
|
||||
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
|
||||
/// (Internal) symbol kind.
|
||||
typedef symbol_kind::symbol_kind_type symbol_kind_type;
|
||||
|
||||
/// The number of tokens.
|
||||
static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS;
|
||||
]])
|
||||
|
||||
|
||||
@@ -258,8 +290,8 @@ m4_define([b4_public_types_declare],
|
||||
m4_define([b4_symbol_type_define],
|
||||
[[ /// A complete symbol.
|
||||
///
|
||||
/// Expects its Base type to provide access to the symbol type
|
||||
/// via type_get ().
|
||||
/// Expects its Base type to provide access to the symbol kind
|
||||
/// via kind ().
|
||||
///
|
||||
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
||||
template <typename Base>
|
||||
@@ -276,7 +308,14 @@ m4_define([b4_symbol_type_define],
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
basic_symbol (basic_symbol&& that);
|
||||
basic_symbol (basic_symbol&& that)
|
||||
: Base (std::move (that))
|
||||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||
, location (std::move (that.location))])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[std::move (that.value)])
|
||||
])[}
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
@@ -303,10 +342,10 @@ m4_define([b4_symbol_type_define],
|
||||
void clear ()
|
||||
{]b4_variant_if([[
|
||||
// User destructor.
|
||||
symbol_number_type yytype = this->type_get ();
|
||||
symbol_kind_type yykind = this->kind ();
|
||||
basic_symbol<Base>& yysym = *this;
|
||||
(void) yysym;
|
||||
switch (yytype)
|
||||
switch (yykind)
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||
[ default:
|
||||
@@ -314,10 +353,13 @@ m4_define([b4_symbol_type_define],
|
||||
}
|
||||
|
||||
// Type destructor.
|
||||
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
|
||||
]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
/// Backward compatibility.
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
||||
|
||||
/// Whether empty.
|
||||
bool empty () const YY_NOEXCEPT;
|
||||
|
||||
@@ -351,8 +393,8 @@ m4_define([b4_symbol_type_define],
|
||||
/// Copy constructor.
|
||||
by_type (const by_type& that);
|
||||
|
||||
/// The symbol type as needed by the constructor.
|
||||
typedef token_type kind_type;
|
||||
/// The symbol kind as needed by the constructor.
|
||||
typedef token_kind_type kind_type;
|
||||
|
||||
/// Constructor from (external) token numbers.
|
||||
by_type (kind_type t);
|
||||
@@ -360,20 +402,16 @@ m4_define([b4_symbol_type_define],
|
||||
/// Record that this symbol is empty.
|
||||
void clear ();
|
||||
|
||||
/// Steal the symbol type from \a that.
|
||||
/// Steal the symbol kind from \a that.
|
||||
void move (by_type& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a type).
|
||||
/// \a empty when empty.
|
||||
symbol_number_type type_get () const YY_NOEXCEPT;
|
||||
symbol_kind_type kind () const YY_NOEXCEPT;
|
||||
|
||||
/// The token.
|
||||
token_type token () const YY_NOEXCEPT;
|
||||
|
||||
/// The symbol type.
|
||||
/// \a empty_symbol when empty.
|
||||
/// An int, not token_number_type, to be able to store empty_symbol.
|
||||
int type;
|
||||
/// The symbol kind.
|
||||
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||
symbol_kind_type type;
|
||||
};
|
||||
|
||||
/// "External" symbols: returned by the scanner.
|
||||
@@ -396,25 +434,13 @@ m4_define([b4_symbol_type_define],
|
||||
# Provide the implementation needed by the public types.
|
||||
m4_define([b4_public_types_define],
|
||||
[[ // basic_symbol.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
|
||||
: Base (std::move (that))
|
||||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||
, location (std::move (that.location))])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->type_get ()], [value], [move],
|
||||
[std::move (that.value)])
|
||||
])[}
|
||||
#endif
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||
: Base (that)
|
||||
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||
, location (that.location)])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->type_get ()], [value], [copy],
|
||||
b4_symbol_variant([this->kind ()], [value], [copy],
|
||||
[YY_MOVE (that.value)])
|
||||
])[}
|
||||
|
||||
@@ -439,13 +465,20 @@ m4_define([b4_public_types_define],
|
||||
, location (YY_MOVE (l))])[
|
||||
{]b4_variant_if([[
|
||||
(void) v;
|
||||
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind ();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
bool
|
||||
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
||||
{
|
||||
return Base::type_get () == empty_symbol;
|
||||
return this->kind () == symbol_kind::]b4_symbol_prefix[YYEMPTY;
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
@@ -453,7 +486,7 @@ m4_define([b4_public_types_define],
|
||||
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
||||
{
|
||||
super_type::move (s);
|
||||
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
||||
]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[YY_MOVE (s.value)])],
|
||||
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
||||
location = YY_MOVE (s.location);])[
|
||||
@@ -461,7 +494,7 @@ m4_define([b4_public_types_define],
|
||||
|
||||
// by_type.
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type ()
|
||||
: type (empty_symbol)
|
||||
: type (symbol_kind::]b4_symbol_prefix[YYEMPTY)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
@@ -476,14 +509,14 @@ m4_define([b4_public_types_define],
|
||||
: type (that.type)
|
||||
{}
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t)
|
||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_kind_type t)
|
||||
: type (yytranslate_ (t))
|
||||
{}
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_type::clear ()
|
||||
{
|
||||
type = empty_symbol;
|
||||
type = symbol_kind::]b4_symbol_prefix[YYEMPTY;
|
||||
}
|
||||
|
||||
]b4_inline([$1])[void
|
||||
@@ -493,27 +526,12 @@ m4_define([b4_public_types_define],
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
]b4_inline([$1])[int
|
||||
]b4_parser_class[::by_type::type_get () const YY_NOEXCEPT
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_type::kind () const YY_NOEXCEPT
|
||||
{
|
||||
return type;
|
||||
}
|
||||
]b4_token_ctor_if([[
|
||||
]b4_inline([$1])b4_parser_class[::token_type
|
||||
]b4_parser_class[::by_type::token () const YY_NOEXCEPT
|
||||
{
|
||||
// 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])[
|
||||
yytoken_number_[] =
|
||||
{
|
||||
]b4_toknum[
|
||||
};
|
||||
return token_type (yytoken_number_[type]);
|
||||
}
|
||||
]])[]dnl
|
||||
])
|
||||
]])
|
||||
|
||||
|
||||
# b4_token_constructor_define
|
||||
@@ -528,29 +546,27 @@ m4_define([b4_token_constructor_define], [])
|
||||
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
||||
# sometimes in the cc file.
|
||||
m4_define([b4_yytranslate_define],
|
||||
[ b4_inline([$1])b4_parser_class[::token_number_type
|
||||
]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type],
|
||||
[int])[ t)
|
||||
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::yytranslate_ (int t)
|
||||
{
|
||||
]b4_api_token_raw_if(
|
||||
[[ return static_cast<yy::parser::token_number_type> (t);]],
|
||||
[[ return static_cast<symbol_kind_type> (t);]],
|
||||
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
// TOKEN-NUM as returned by yylex.
|
||||
static
|
||||
const token_number_type
|
||||
const ]b4_int_type_for([b4_translate])[
|
||||
translate_table[] =
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
const int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
const token_number_type undef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
if (static_cast<int> (t) <= yyeof_)
|
||||
return yyeof_;
|
||||
else if (static_cast<int> (t) <= user_token_number_max_)
|
||||
return translate_table[t];
|
||||
if (t <= 0)
|
||||
return symbol_kind::]b4_symbol_prefix[YYEOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
return YY_CAST (symbol_kind_type, translate_table[t]);
|
||||
else
|
||||
return undef_token_;]])[
|
||||
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Common code for C-like languages (C, C++, Java, etc.)
|
||||
|
||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2015, 2018-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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# C skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
+120
-75
@@ -2,7 +2,7 @@
|
||||
|
||||
# C M4 Macros for Bison.
|
||||
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -101,6 +101,7 @@ m4_define_default([b4_prefix], [b4_api_prefix])
|
||||
b4_percent_define_default([[api.value.union.name]],
|
||||
[b4_api_PREFIX[][STYPE]])
|
||||
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
|
||||
|
||||
## ------------------------ ##
|
||||
## Pure/impure interfaces. ##
|
||||
@@ -129,6 +130,13 @@ m4_define([b4_user_args],
|
||||
[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_user_formals
|
||||
# ---------------
|
||||
# The possible parse-params formal arguments preceded by a comma.
|
||||
m4_define([b4_user_formals],
|
||||
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
||||
@@ -327,11 +335,11 @@ m4_define([b4_attribute_define],
|
||||
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#else
|
||||
# define YY_INITIAL_VALUE(Value) Value
|
||||
@@ -343,6 +351,18 @@ m4_define([b4_attribute_define],
|
||||
#ifndef YY_INITIAL_VALUE
|
||||
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
|
||||
# define YY_IGNORE_USELESS_CAST_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
|
||||
# define YY_IGNORE_USELESS_CAST_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#endif
|
||||
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
|
||||
# define YY_IGNORE_USELESS_CAST_BEGIN
|
||||
# define YY_IGNORE_USELESS_CAST_END
|
||||
#endif
|
||||
]])
|
||||
|
||||
|
||||
@@ -406,9 +426,22 @@ static const b4_int_type_for([$2]) yy$1[[]] =
|
||||
])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
# Because C enums are not scoped, because tokens are exposed in the
|
||||
# header, and because these tokens are common to all the parsers, we
|
||||
# need to make sure their names don't collide: use the api.prefix.
|
||||
# YYEOF is special, since the user may give it a different name.
|
||||
m4_define([b4_symbol(-2, id)], [b4_api_PREFIX[][EMPTY]])
|
||||
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(2, id)], [b4_api_PREFIX[][UNDEF]])
|
||||
|
||||
|
||||
# b4_token_define(TOKEN-NUM)
|
||||
# --------------------------
|
||||
@@ -420,7 +453,7 @@ m4_define([b4_token_define],
|
||||
# ----------------
|
||||
# Output the definition of the tokens.
|
||||
m4_define([b4_token_defines],
|
||||
[b4_any_token_visible_if([/* Tokens. */
|
||||
[b4_any_token_visible_if([/* Token kinds. */
|
||||
m4_join([
|
||||
], b4_symbol_map([b4_token_define]))
|
||||
])])
|
||||
@@ -430,34 +463,81 @@ m4_join([
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_format([%s = %s], [$1])])
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s = %s%s%s]],
|
||||
b4_symbol([$1], [id]),
|
||||
b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])),
|
||||
m4_if([$1], b4_last_enum_token, [], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])])
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
# The definition of the token kinds.
|
||||
m4_define([b4_token_enums],
|
||||
[b4_any_token_visible_if([[/* Token type. */
|
||||
[b4_any_token_visible_if([[/* Token kinds. */
|
||||
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||
# define ]b4_api_PREFIX[TOKENTYPE
|
||||
enum ]b4_api_prefix[tokentype
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
};
|
||||
]b4_symbol([-2], [id])[ = -2,
|
||||
]b4_symbol_foreach([b4_token_enum])dnl
|
||||
[ };
|
||||
typedef enum ]b4_api_prefix[tokentype ]b4_api_prefix[token_kind_t;
|
||||
#endif
|
||||
]])])
|
||||
|
||||
|
||||
# b4_token_enums_defines
|
||||
# ----------------------
|
||||
# Output the definition of the tokens (if there are any) as enums and,
|
||||
# The definition of the tokens (if there are any) as enums and,
|
||||
# if POSIX Yacc is enabled, as #defines.
|
||||
m4_define([b4_token_enums_defines],
|
||||
[b4_token_enums[]b4_yacc_if([b4_token_defines])])
|
||||
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[N_($1)]])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-40s %s],
|
||||
m4_format([[%s = %s%s%s]],
|
||||
b4_symbol([$1], [kind]),
|
||||
[$1],
|
||||
m4_if([$1], b4_last_symbol, [], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[/* Symbol kind. */
|
||||
enum yysymbol_kind_t
|
||||
{
|
||||
]b4_symbol_kind([-2])[ = -2,
|
||||
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||
[};
|
||||
typedef enum yysymbol_kind_t yysymbol_kind_t;
|
||||
]])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
@@ -481,15 +561,6 @@ m4_define([b4_symbol_value],
|
||||
## ---------------------- ##
|
||||
|
||||
|
||||
# b4_function_define(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# -----------------------------------------------------------
|
||||
# Declare the function NAME in C.
|
||||
m4_define([b4_function_define],
|
||||
[$2
|
||||
$1 (b4_formals(m4_shift2($@)))[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_formals([DECL1, NAME1], ...)
|
||||
# -------------------------------
|
||||
# The formal arguments of a C function definition.
|
||||
@@ -503,21 +574,6 @@ m4_define([b4_formal],
|
||||
|
||||
|
||||
|
||||
## ----------------------- ##
|
||||
## Declaring C functions. ##
|
||||
## ----------------------- ##
|
||||
|
||||
|
||||
# b4_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ------------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_function_declare],
|
||||
[$2 $1 (b4_formals(m4_shift2($@)));[]dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Calling C functions. ##
|
||||
## --------------------- ##
|
||||
@@ -581,18 +637,15 @@ m4_define_default([b4_yydestruct_define],
|
||||
| Release the memory associated to this symbol. |
|
||||
`-----------------------------------------------*/
|
||||
|
||||
]b4_function_define([yydestruct],
|
||||
[static void],
|
||||
[[const char *yymsg], [yymsg]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE *yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yydestruct (const char *yymsg,
|
||||
yysymbol_kind_t yykind, YYSTYPE *yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
||||
[ if (!yymsg)
|
||||
yymsg = "Deleting";
|
||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
|
||||
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
]b4_symbol_actions([destructor])[
|
||||
@@ -610,13 +663,10 @@ m4_define_default([b4_yy_symbol_print_define],
|
||||
| Print this symbol's value on YYO. |
|
||||
`-----------------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_value_print],
|
||||
[static void],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yy_symbol_value_print (FILE *yyo,
|
||||
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
FILE *yyoutput = yyo;
|
||||
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
||||
@@ -625,8 +675,8 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
dnl glr.c does not feature yytoknum.
|
||||
m4_if(b4_skeleton, ["yacc.c"],
|
||||
[[# ifdef YYPRINT
|
||||
if (yytype < YYNTOKENS)
|
||||
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
||||
if (yykind < YYNTOKENS)
|
||||
YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
|
||||
# endif
|
||||
]])dnl
|
||||
b4_percent_code_get([[pre-printer]])dnl
|
||||
@@ -641,21 +691,18 @@ b4_percent_code_get([[post-printer]])dnl
|
||||
| Print this symbol on YYO. |
|
||||
`---------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yy_symbol_print (FILE *yyo,
|
||||
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
YYFPRINTF (yyo, "%s %s (",
|
||||
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
|
||||
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
|
||||
|
||||
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
|
||||
YYFPRINTF (yyo, ": ");
|
||||
])dnl
|
||||
[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
|
||||
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
|
||||
b4_locations_if([, yylocationp])[]b4_user_args[);
|
||||
YYFPRINTF (yyo, ")");
|
||||
}]dnl
|
||||
@@ -681,11 +728,11 @@ m4_define([b4_symbol_type_register],
|
||||
[m4_define([b4_symbol($1, type_tag)],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[b4_symbol([$1], [id])],
|
||||
[yytype_[]b4_symbol([$1], [number])])])dnl
|
||||
[yykind_[]b4_symbol([$1], [number])])])dnl
|
||||
m4_append([b4_union_members],
|
||||
m4_expand([
|
||||
b4_symbol_tag_comment([$1])dnl
|
||||
b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]))
|
||||
m4_expand([m4_format([ %-40s %s],
|
||||
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
||||
[b4_symbol_tag_comment([$1])])]))
|
||||
])
|
||||
|
||||
|
||||
@@ -924,10 +971,8 @@ m4_define([b4_yy_location_print_define],
|
||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||
|
||||
YY_ATTRIBUTE_UNUSED
|
||||
]b4_function_define([yy_location_print_],
|
||||
[static int],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[YYLTYPE const * const yylocp], [yylocp]])[
|
||||
static int
|
||||
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
||||
{
|
||||
int res = 0;
|
||||
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# D skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
|
||||
+46
-12
@@ -2,7 +2,7 @@
|
||||
|
||||
# D language support for Bison
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
@@ -148,9 +148,9 @@ private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
||||
])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
@@ -159,19 +159,53 @@ m4_define([b4_token_enum],
|
||||
[b4_token_format([ %s = %s,
|
||||
], [$1])])
|
||||
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[/* Tokens. */
|
||||
public enum YYTokenType {
|
||||
|
||||
/** Token returned by the scanner to signal the end of its input. */
|
||||
EOF = 0,
|
||||
b4_symbol_foreach([b4_token_enum])
|
||||
[/* Token kinds. */
|
||||
public enum TokenKind {
|
||||
]b4_symbol_kind([-2])[ = -2,
|
||||
b4_symbol_foreach([b4_token_enum])dnl
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s = %s,]],
|
||||
b4_symbol([$1], [kind]),
|
||||
[$1]),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ /* Symbol kinds. */
|
||||
public enum SymbolKind
|
||||
{
|
||||
]b4_symbol_kind([-2])[ = -2, /* No symbol. */
|
||||
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||
[ };
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
# b4-case(ID, CODE)
|
||||
# -----------------
|
||||
m4_define([b4_case], [ case $1:
|
||||
|
||||
+524
-425
File diff suppressed because it is too large
Load Diff
+61
-56
@@ -1,6 +1,6 @@
|
||||
# C++ GLR skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018-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
|
||||
@@ -66,30 +66,29 @@ m4_defn([b4_parse_param]))],
|
||||
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
||||
])
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
m4_append([b4_declare_symbol_enum],
|
||||
[[typedef symbol_kind_type yysymbol_kind_t;
|
||||
]])
|
||||
|
||||
|
||||
# b4_yy_symbol_print_define
|
||||
# -------------------------
|
||||
# Bypass the default implementation to generate the "yy_symbol_print"
|
||||
# and "yy_symbol_value_print" functions.
|
||||
m4_define([b4_yy_symbol_print_define],
|
||||
[[
|
||||
/*--------------------.
|
||||
[[/*--------------------.
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *], []],
|
||||
[[int yytype], [yytype]],
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep],
|
||||
[yyvaluep]][]dnl
|
||||
b4_locations_if([,
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||
[yylocationp]]]),
|
||||
b4_parse_param)[
|
||||
static void
|
||||
yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken,
|
||||
const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep]b4_locations_if([[,
|
||||
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[);
|
||||
[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([, yylocationp])[);
|
||||
}
|
||||
]])[
|
||||
|
||||
@@ -101,45 +100,30 @@ m4_defn([b4_initial_action])]))])[
|
||||
# Hijack the post prologue to declare yyerror.
|
||||
]m4_append([b4_post_prologue],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
b4_function_declare([yyerror],
|
||||
[static void],b4_locations_if([
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||
[yylocationp]],])
|
||||
b4_parse_param,
|
||||
[[const char* msg], [msg]])])[
|
||||
[static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg);]])[
|
||||
|
||||
|
||||
#undef yynerrs
|
||||
#undef yychar
|
||||
#undef yylval]b4_locations_if([
|
||||
#undef yylloc])
|
||||
|
||||
m4_if(b4_prefix, [yy], [],
|
||||
[[/* Substitute the variable and function names. */
|
||||
#define yyparse ]b4_prefix[parse
|
||||
#define yylex ]b4_prefix[lex
|
||||
#define yyerror ]b4_prefix[error
|
||||
#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
|
||||
#define yylval ]b4_prefix[lval
|
||||
#define yychar ]b4_prefix[char
|
||||
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
||||
#define yylloc ]b4_prefix[lloc]])]))
|
||||
]b4_percent_define_flag_if([[global_tokens_and_yystype]], [],
|
||||
[m4_define([b4_pre_epilogue],
|
||||
[[/* The user is using the C++ token kind, not the C one. */
|
||||
#undef ]b4_symbol(0, [id])
|
||||
])])[
|
||||
|
||||
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||
# functions etc.).
|
||||
m4_append([b4_epilogue],
|
||||
]m4_append([b4_epilogue],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
[
|
||||
/*------------------.
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
|
||||
]b4_function_define([yyerror],
|
||||
[static void],b4_locations_if([
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||
[yylocationp]],])
|
||||
b4_parse_param,
|
||||
[[const char* msg], [msg]])[
|
||||
static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
||||
@@ -181,7 +165,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
`--------------------*/
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_value_print_ (int yytype,
|
||||
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[)
|
||||
{]b4_locations_if([[
|
||||
@@ -195,14 +179,14 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_print_ (int yytype,
|
||||
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[)
|
||||
{
|
||||
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yytname[yytype] << " ("]b4_locations_if([[
|
||||
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yytname[yykind] << " ("]b4_locations_if([[
|
||||
<< *yylocationp << ": "]])[;
|
||||
yy_symbol_value_print_ (yytype, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
||||
yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
||||
*yycdebug_ << ')';
|
||||
}
|
||||
|
||||
@@ -265,6 +249,13 @@ b4_percent_code_get([[requires]])[
|
||||
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
|
||||
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
||||
// -pedantic reports as being a C++11 extension.
|
||||
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
|
||||
&& defined __clang__ && 4 <= __clang_major__
|
||||
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
||||
#endif
|
||||
|
||||
// Whether we are compiled with exception support.
|
||||
#ifndef YY_EXCEPTIONS
|
||||
# if defined __GNUC__ && !defined __EXCEPTIONS
|
||||
@@ -321,17 +312,17 @@ b4_percent_code_get([[requires]])[
|
||||
# if ]b4_api_PREFIX[DEBUG
|
||||
public:
|
||||
/// \brief Report a symbol value on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_value_print_ (int yytype,
|
||||
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[);
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_print_ (int yytype,
|
||||
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[);
|
||||
private:
|
||||
@@ -344,8 +335,16 @@ b4_percent_code_get([[requires]])[
|
||||
|
||||
]dnl Redirections for glr.c.
|
||||
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
[b4_token_defines])
|
||||
[
|
||||
[b4_token_defines
|
||||
])[
|
||||
]b4_namespace_close[
|
||||
|
||||
]dnl Map the name used in c.m4 to the one used in c++.m4.
|
||||
[#undef ]b4_symbol(-2, [id])[
|
||||
#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])[
|
||||
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
||||
#endif
|
||||
@@ -353,7 +352,13 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
||||
#endif
|
||||
|
||||
]b4_namespace_close[
|
||||
]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
|
||||
]])[
|
||||
]b4_percent_code_get([[provides]])[
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
])
|
||||
@@ -361,7 +366,7 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_spec_header_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
[2002-2015, 2018-2019])[
|
||||
[2002-2015, 2018-2020])[
|
||||
// C++ GLR parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Java skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2007, 2009-2015, 2018-2019 Free Software Foundation,
|
||||
# Copyright (C) 2007, 2009-2015, 2018-2020 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
+138
-12
@@ -2,7 +2,7 @@
|
||||
|
||||
# Java language support for Bison
|
||||
|
||||
# Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2015, 2018-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
|
||||
@@ -106,10 +106,13 @@ m4_define([b4_null], [null])
|
||||
|
||||
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
||||
# -------------------------------------------------------
|
||||
# We use intermediate functions (e.g., yypact_init) to work around the
|
||||
# 64KB limit for JVM methods. See
|
||||
# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.
|
||||
m4_define([b4_typed_parser_table_define],
|
||||
[m4_ifval([$4], [b4_comment([$4])
|
||||
])dnl
|
||||
[private static final ]$1[ yy$2_[] = yy$2_init();
|
||||
[private static final ]$1[[] yy$2_ = yy$2_init();
|
||||
private static final ]$1[[] yy$2_init()
|
||||
{
|
||||
return new ]$1[[]
|
||||
@@ -125,9 +128,10 @@ m4_define([b4_integral_parser_table_define],
|
||||
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NUM)
|
||||
# ------------------------
|
||||
@@ -141,24 +145,129 @@ m4_define([b4_token_enum],
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[b4_any_token_visible_if([/* Tokens. */
|
||||
[b4_any_token_visible_if([ /* Token kinds. */
|
||||
b4_symbol_foreach([b4_token_enum])])])
|
||||
|
||||
# b4-case(ID, CODE)
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s(%s)%s]],
|
||||
b4_symbol([$1], [kind]),
|
||||
[$1],
|
||||
m4_if([$1], b4_last_symbol, [[;]], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ public enum SymbolKind
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_enum])[
|
||||
|
||||
private final int yycode_;
|
||||
|
||||
SymbolKind (int n) {
|
||||
this.yycode_ = n;
|
||||
}
|
||||
|
||||
private static final SymbolKind[] values_ = {
|
||||
]m4_map_args_sep([b4_symbol_kind(], [)], [,
|
||||
], b4_symbol_numbers)[
|
||||
};
|
||||
|
||||
static final SymbolKind get(int code) {
|
||||
return values_[code];
|
||||
}
|
||||
|
||||
public final int getCode() {
|
||||
return this.yycode_;
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[simple\|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. */
|
||||
private static String yytnamerr_(String yystr)
|
||||
{
|
||||
if (yystr.charAt (0) == '"')
|
||||
{
|
||||
StringBuffer yyr = new StringBuffer();
|
||||
strip_quotes: for (int i = 1; i < yystr.length(); i++)
|
||||
switch (yystr.charAt(i))
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
break strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (yystr.charAt(++i) != '\\')
|
||||
break strip_quotes;
|
||||
/* Fall through. */
|
||||
default:
|
||||
yyr.append(yystr.charAt(i));
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr.toString();
|
||||
}
|
||||
}
|
||||
return yystr;
|
||||
}
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||
|
||||
/* The user-facing name of this symbol. */
|
||||
public final String getName() {
|
||||
return yytnamerr_(yytname_[yycode_]);
|
||||
}
|
||||
]],
|
||||
[custom\|detailed],
|
||||
[[ /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [names], [b4_symbol_names])[
|
||||
|
||||
/* The user-facing name of this symbol. */
|
||||
public final String getName() {
|
||||
return yynames_[yycode_];
|
||||
}]])[
|
||||
};
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
# b4_case(ID, CODE)
|
||||
# -----------------
|
||||
# We need to fool Java's stupid unreachable code detection.
|
||||
m4_define([b4_case], [ case $1:
|
||||
m4_define([b4_case],
|
||||
[ case $1:
|
||||
if (yyn == $1)
|
||||
$2;
|
||||
break;
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
# b4_predicate_case(LABEL, CONDITIONS)
|
||||
# ------------------------------------
|
||||
m4_define([b4_predicate_case], [ case $1:
|
||||
m4_define([b4_predicate_case],
|
||||
[ case $1:
|
||||
if (! ($2)) YYERROR;
|
||||
break;
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
## -------- ##
|
||||
@@ -183,6 +292,7 @@ b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
||||
|
||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
# b4_api_prefix, b4_api_PREFIX
|
||||
# ----------------------------
|
||||
@@ -222,6 +332,22 @@ m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[i18n($1)]])
|
||||
|
||||
|
||||
# b4_trans(STRING)
|
||||
# ----------------
|
||||
# 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_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||
# ----------------------------------------------
|
||||
# See README.
|
||||
@@ -361,4 +487,4 @@ m4_define([b4_var_decl],
|
||||
# -----------------------
|
||||
# Expand to either an empty string or "throws THROWS".
|
||||
m4_define([b4_maybe_throws],
|
||||
[m4_ifval($1, [throws $1])])
|
||||
[m4_ifval($1, [ throws $1])])
|
||||
|
||||
+259
-148
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018-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
|
||||
@@ -23,12 +23,22 @@ m4_define([b4_value_type_setup_variant])
|
||||
# Check the value of %define parse.lac, where LAC stands for lookahead
|
||||
# correction.
|
||||
b4_percent_define_default([[parse.lac]], [[none]])
|
||||
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]])
|
||||
b4_define_flag_if([lac])
|
||||
m4_define([b4_lac_flag],
|
||||
[m4_if(b4_percent_define_get([[parse.lac]]),
|
||||
[none], [[0]], [[1]])])
|
||||
|
||||
|
||||
# b4_tname_if(TNAME-NEEDED, TNAME-NOT-NEEDED)
|
||||
# -------------------------------------------
|
||||
m4_define([b4_tname_if],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]),
|
||||
[verbose], [$1],
|
||||
[b4_token_table_if([$1],
|
||||
[$2])])])
|
||||
|
||||
|
||||
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
||||
# --------------------------------------------------------------
|
||||
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
||||
@@ -143,7 +153,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
|
||||
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2015, 2018-2019])
|
||||
[2002-2015, 2018-2020])
|
||||
|
||||
m4_define([b4_parser_class],
|
||||
[b4_percent_define_get([[api.parser.class]])])
|
||||
@@ -225,7 +235,25 @@ m4_define([b4_shared_declarations],
|
||||
void error (const syntax_error& err);
|
||||
|
||||
]b4_token_constructor_define[
|
||||
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
|
||||
class context
|
||||
{
|
||||
public:
|
||||
context (const ]b4_parser_class[& yyparser, const symbol_type& yyla);
|
||||
const symbol_type& lookahead () const { return yyla_; }
|
||||
symbol_kind_type token () const { return yyla_.kind (); }]b4_locations_if([[
|
||||
const location_type& location () const { return yyla_.location; }
|
||||
]])[
|
||||
/// Put in YYARG at most YYARGN of the expected tokens, and return the
|
||||
/// number of tokens stored in YYARG. If YYARG is null, return the
|
||||
/// number of expected tokens (guaranteed to be less than YYNTOKENS).
|
||||
int expected_tokens (symbol_kind_type yyarg[], int yyargn) const;
|
||||
|
||||
private:
|
||||
const ]b4_parser_class[& yyparser_;
|
||||
const symbol_type& yyla_;
|
||||
};
|
||||
]])[
|
||||
private:
|
||||
/// This class is not copyable.
|
||||
]b4_parser_class[ (const ]b4_parser_class[&);
|
||||
@@ -233,10 +261,10 @@ m4_define([b4_shared_declarations],
|
||||
|
||||
/// Check the lookahead yytoken.
|
||||
/// \returns true iff the token will be eventually shifted.
|
||||
bool yy_lac_check_ (int yytoken) const;
|
||||
bool yy_lac_check_ (symbol_kind_type yytoken) const;
|
||||
/// Establish the initial context if no initial context currently exists.
|
||||
/// \returns true iff the token will be eventually shifted.
|
||||
bool yy_lac_establish_ (int yytoken);
|
||||
bool yy_lac_establish_ (symbol_kind_type yytoken);
|
||||
/// Discard any previous initial lookahead context because of event.
|
||||
/// \param event the event which caused the lookahead to be discarded.
|
||||
/// Only used for debbuging output.
|
||||
@@ -244,13 +272,19 @@ m4_define([b4_shared_declarations],
|
||||
|
||||
/// Stored state numbers (used for stacks).
|
||||
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ state_type;
|
||||
]b4_parse_error_bmatch(
|
||||
[custom], [[
|
||||
/// Report a syntax error
|
||||
/// \param yyctx the context in which the error occurred.
|
||||
void report_syntax_error (const context& yyctx) const;]],
|
||||
[detailed\|verbose], [[
|
||||
/// The arguments of the error message.
|
||||
int yy_syntax_error_arguments_ (const context& yyctx,
|
||||
symbol_kind_type yyarg[], int yyargn) const;
|
||||
|
||||
/// Generate an error message.
|
||||
/// \param yystate the state where the error occurred.
|
||||
/// \param yyla the lookahead token.
|
||||
virtual std::string yysyntax_error_ (state_type yystate,
|
||||
const symbol_type& yyla) const;
|
||||
|
||||
/// \param yyctx the context in which the error occurred.
|
||||
virtual std::string yysyntax_error_ (const context& yyctx) const;]])[
|
||||
/// Compute post-reduction state.
|
||||
/// \param yystate the current state
|
||||
/// \param yysym the nonterminal to push on the stack
|
||||
@@ -267,19 +301,33 @@ m4_define([b4_shared_declarations],
|
||||
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
|
||||
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
|
||||
|
||||
/// Convert a scanner token number \a t to a symbol number.
|
||||
static token_number_type yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t);
|
||||
/// Convert a scanner token kind \a t to a symbol kind.
|
||||
/// 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);
|
||||
]])[
|
||||
|
||||
// Tables.
|
||||
]b4_parser_tables_declare[]b4_error_verbose_if([
|
||||
|
||||
]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);])[
|
||||
static std::string yytnamerr_ (const char *n);
|
||||
|
||||
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
|
||||
]],
|
||||
[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.
|
||||
@@ -292,7 +340,7 @@ m4_define([b4_shared_declarations],
|
||||
/// Debug stream.
|
||||
std::ostream* yycdebug_;
|
||||
|
||||
/// \brief Display a symbol type, value and location.
|
||||
/// \brief Display a symbol kind, value and location.
|
||||
/// \param yyo The output stream.
|
||||
/// \param yysym The symbol.
|
||||
template <typename Base>
|
||||
@@ -313,7 +361,7 @@ m4_define([b4_shared_declarations],
|
||||
/// Default constructor.
|
||||
by_state () YY_NOEXCEPT;
|
||||
|
||||
/// The symbol type as needed by the constructor.
|
||||
/// The symbol kind as needed by the constructor.
|
||||
typedef state_type kind_type;
|
||||
|
||||
/// Constructor.
|
||||
@@ -325,15 +373,16 @@ m4_define([b4_shared_declarations],
|
||||
/// Record that this symbol is empty.
|
||||
void clear () YY_NOEXCEPT;
|
||||
|
||||
/// Steal the symbol type from \a that.
|
||||
/// Steal the symbol kind from \a that.
|
||||
void move (by_state& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a state).
|
||||
/// \a empty_symbol when empty.
|
||||
symbol_number_type type_get () const YY_NOEXCEPT;
|
||||
/// The symbol kind (corresponding to \a state).
|
||||
/// \a ]b4_symbol(-2, kind)[ when empty.
|
||||
symbol_kind_type kind () const YY_NOEXCEPT;
|
||||
|
||||
/// The state number used to denote an empty symbol.
|
||||
enum { empty_state = -1 };
|
||||
/// We use the initial state, as it does not have a value.
|
||||
enum { empty_state = 0 };
|
||||
|
||||
/// The state.
|
||||
/// \a empty when empty.
|
||||
@@ -400,13 +449,9 @@ m4_define([b4_shared_declarations],
|
||||
/// Constants.
|
||||
enum
|
||||
{
|
||||
yyeof_ = 0,
|
||||
yylast_ = ]b4_last[, ///< Last index in yytable_.
|
||||
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
|
||||
yyfinal_ = ]b4_final_state_number[, ///< Termination state number.
|
||||
yyterror_ = 1,
|
||||
yyerrcode_ = 256,
|
||||
yyntokens_ = ]b4_tokens_number[ ///< Number of tokens.
|
||||
yyfinal_ = ]b4_final_state_number[ ///< Termination state number.
|
||||
};
|
||||
|
||||
]b4_parse_param_vars[
|
||||
@@ -537,7 +582,29 @@ m4_if(b4_prefix, [yy], [],
|
||||
#define YYERROR goto yyerrorlab
|
||||
#define YYRECOVERING() (!!yyerrstatus_)
|
||||
|
||||
]b4_namespace_open[]b4_error_verbose_if([[
|
||||
]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
|
||||
@@ -598,7 +665,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
{}
|
||||
|
||||
/*---------------.
|
||||
| Symbol types. |
|
||||
| symbol kinds. |
|
||||
`---------------*/
|
||||
|
||||
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
|
||||
@@ -629,13 +696,13 @@ m4_if(b4_prefix, [yy], [],
|
||||
: state (s)
|
||||
{}
|
||||
|
||||
]b4_parser_class[::symbol_number_type
|
||||
]b4_parser_class[::by_state::type_get () const YY_NOEXCEPT
|
||||
]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_state::kind () const YY_NOEXCEPT
|
||||
{
|
||||
if (state == empty_state)
|
||||
return empty_symbol;
|
||||
return symbol_kind::]b4_symbol(-2, kind)[;
|
||||
else
|
||||
return yystos_[state];
|
||||
return YY_CAST (symbol_kind_type, yystos_[+state]);
|
||||
}
|
||||
|
||||
]b4_parser_class[::stack_symbol_type::stack_symbol_type ()
|
||||
@@ -644,7 +711,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
|
||||
: super_type (YY_MOVE (that.state)]b4_variant_if([], [, YY_MOVE (that.value)])b4_locations_if([, YY_MOVE (that.location)])[)
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([that.type_get ()],
|
||||
b4_symbol_variant([that.kind ()],
|
||||
[value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
// that is emptied.
|
||||
@@ -655,10 +722,10 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
|
||||
: super_type (s]b4_variant_if([], [, YY_MOVE (that.value)])[]b4_locations_if([, YY_MOVE (that.location)])[)
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([that.type_get ()],
|
||||
b4_symbol_variant([that.kind ()],
|
||||
[value], [move], [YY_MOVE (that.value)])])[
|
||||
// that is emptied.
|
||||
that.type = empty_symbol;
|
||||
that.type = symbol_kind::]b4_symbol(-2, kind)[;
|
||||
}
|
||||
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
@@ -666,7 +733,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class[::stack_symbol_type::operator= (const stack_symbol_type& that)
|
||||
{
|
||||
state = that.state;
|
||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
||||
]b4_variant_if([b4_symbol_variant([that.kind ()],
|
||||
[value], [copy], [that.value])],
|
||||
[[value = that.value;]])[]b4_locations_if([
|
||||
location = that.location;])[
|
||||
@@ -677,7 +744,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that)
|
||||
{
|
||||
state = that.state;
|
||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
||||
]b4_variant_if([b4_symbol_variant([that.kind ()],
|
||||
[value], [move], [that.value])],
|
||||
[[value = that.value;]])[]b4_locations_if([
|
||||
location = that.location;])[
|
||||
@@ -695,7 +762,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [
|
||||
|
||||
// User destructor.
|
||||
b4_symbol_actions([destructor], [yysym.type_get ()])])[
|
||||
b4_symbol_actions([destructor], [yysym.kind ()])])[
|
||||
}
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
@@ -706,15 +773,15 @@ m4_if(b4_prefix, [yy], [],
|
||||
{
|
||||
std::ostream& yyoutput = yyo;
|
||||
YYUSE (yyoutput);
|
||||
symbol_number_type yytype = yysym.type_get ();
|
||||
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 << (yytype < yyntokens_ ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
|
||||
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yykind] << " ("]b4_locations_if([
|
||||
<< yysym.location << ": "])[;
|
||||
]b4_symbol_actions([printer])[
|
||||
yyo << ')';
|
||||
@@ -776,11 +843,11 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class[::state_type
|
||||
]b4_parser_class[::yy_lr_goto_state_ (state_type yystate, int yysym)
|
||||
{
|
||||
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
|
||||
int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
|
||||
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
||||
return yytable_[yyr];
|
||||
else
|
||||
return yydefgoto_[yysym - yyntokens_];
|
||||
return yydefgoto_[yysym - YYNTOKENS];
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -848,6 +915,7 @@ b4_dollar_popdef])[]dnl
|
||||
`-----------------------------------------------*/
|
||||
yynewstate:
|
||||
YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
|
||||
YY_STACK_PRINT ();
|
||||
|
||||
// Accept?
|
||||
if (yystack_[0].state == yyfinal_)
|
||||
@@ -861,14 +929,14 @@ b4_dollar_popdef])[]dnl
|
||||
`-----------*/
|
||||
yybackup:
|
||||
// Try to take a decision without lookahead.
|
||||
yyn = yypact_[yystack_[0].state];
|
||||
yyn = yypact_[+yystack_[0].state];
|
||||
if (yy_pact_value_is_default_ (yyn))
|
||||
goto yydefault;
|
||||
|
||||
// Read a lookahead token.
|
||||
if (yyla.empty ())
|
||||
{
|
||||
YYCDEBUG << "Reading a token: ";
|
||||
YYCDEBUG << "Reading a token\n";
|
||||
#if YY_EXCEPTIONS
|
||||
try
|
||||
#endif // YY_EXCEPTIONS
|
||||
@@ -890,10 +958,10 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
/* If the proper action on seeing token YYLA.TYPE is to reduce or
|
||||
to detect an error, take that action. */
|
||||
yyn += yyla.type_get ();
|
||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
|
||||
yyn += yyla.kind ();
|
||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
|
||||
{]b4_lac_if([[
|
||||
if (!yy_lac_establish_ (yyla.type_get ()))
|
||||
if (!yy_lac_establish_ (yyla.kind ()))
|
||||
goto yyerrlab;]])[
|
||||
goto yydefault;
|
||||
}
|
||||
@@ -904,7 +972,7 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
goto yyerrlab;]b4_lac_if([[
|
||||
if (!yy_lac_establish_ (yyla.type_get ()))
|
||||
if (!yy_lac_establish_ (yyla.kind ()))
|
||||
goto yyerrlab;
|
||||
]])[
|
||||
yyn = -yyn;
|
||||
@@ -916,7 +984,7 @@ b4_dollar_popdef])[]dnl
|
||||
--yyerrstatus_;
|
||||
|
||||
// Shift the lookahead token.
|
||||
yypush_ ("Shifting", static_cast<state_type> (yyn), YY_MOVE (yyla));]b4_lac_if([[
|
||||
yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));]b4_lac_if([[
|
||||
yy_lac_discard_ ("shift");]])[
|
||||
goto yynewstate;
|
||||
|
||||
@@ -925,7 +993,7 @@ b4_dollar_popdef])[]dnl
|
||||
| yydefault -- do the default action for the current state. |
|
||||
`-----------------------------------------------------------*/
|
||||
yydefault:
|
||||
yyn = yydefact_[yystack_[0].state];
|
||||
yyn = yydefact_[+yystack_[0].state];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
goto yyreduce;
|
||||
@@ -986,7 +1054,6 @@ b4_dollar_popdef])[]dnl
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yylhs);
|
||||
yypop_ (yylen);
|
||||
yylen = 0;
|
||||
YY_STACK_PRINT ();
|
||||
|
||||
// Shift the result of the reduction.
|
||||
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
|
||||
@@ -1001,9 +1068,17 @@ b4_dollar_popdef])[]dnl
|
||||
// If not already recovering from an error, report this error.
|
||||
if (!yyerrstatus_)
|
||||
{
|
||||
++yynerrs_;
|
||||
error (]b4_join(b4_locations_if([yyla.location]),
|
||||
[[yysyntax_error_ (yystack_[0].state, yyla)]])[);
|
||||
++yynerrs_;]b4_parse_error_case(
|
||||
[simple], [[
|
||||
std::string msg = YY_("syntax error");
|
||||
error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]],
|
||||
[custom], [[
|
||||
context yyctx (*this, yyla);
|
||||
report_syntax_error (yyctx);]],
|
||||
[[
|
||||
context yyctx (*this, yyla);
|
||||
std::string msg = yysyntax_error_ (yyctx);
|
||||
error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]])[
|
||||
}
|
||||
|
||||
]b4_locations_if([[
|
||||
@@ -1014,7 +1089,7 @@ b4_dollar_popdef])[]dnl
|
||||
error, discard it. */
|
||||
|
||||
// Return failure if at end of input.
|
||||
if (yyla.type_get () == yyeof_)
|
||||
if (yyla.kind () == symbol_kind::]b4_symbol_prefix[YYEOF)
|
||||
YYABORT;
|
||||
else if (!yyla.empty ())
|
||||
{
|
||||
@@ -1040,6 +1115,7 @@ b4_dollar_popdef])[]dnl
|
||||
this YYERROR. */
|
||||
yypop_ (yylen);
|
||||
yylen = 0;
|
||||
YY_STACK_PRINT ();
|
||||
goto yyerrlab1;
|
||||
|
||||
|
||||
@@ -1048,38 +1124,40 @@ b4_dollar_popdef])[]dnl
|
||||
`-------------------------------------------------------------*/
|
||||
yyerrlab1:
|
||||
yyerrstatus_ = 3; // Each real token shifted decrements this.
|
||||
// Pop stack until we find a state that shifts the error token.
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[+yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += symbol_kind::]b4_symbol_prefix[YYERROR;
|
||||
if (0 <= yyn && yyn <= yylast_
|
||||
&& yycheck_[yyn] == symbol_kind::]b4_symbol_prefix[YYERROR)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Pop the current state because it cannot handle the error token.
|
||||
if (yystack_.size () == 1)
|
||||
YYABORT;
|
||||
]b4_locations_if([[
|
||||
yyerror_range[1].location = yystack_[0].location;]])[
|
||||
yy_destroy_ ("Error: popping", yystack_[0]);
|
||||
yypop_ ();
|
||||
YY_STACK_PRINT ();
|
||||
}
|
||||
{
|
||||
stack_symbol_type error_token;
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Pop the current state because it cannot handle the error token.
|
||||
if (yystack_.size () == 1)
|
||||
YYABORT;
|
||||
]b4_locations_if([[
|
||||
yyerror_range[1].location = yystack_[0].location;]])[
|
||||
yy_destroy_ ("Error: popping", yystack_[0]);
|
||||
yypop_ ();
|
||||
YY_STACK_PRINT ();
|
||||
}
|
||||
]b4_locations_if([[
|
||||
yyerror_range[2].location = yyla.location;
|
||||
YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
|
||||
|
||||
// Shift the error token.]b4_lac_if([[
|
||||
yy_lac_discard_ ("error recovery");]])[
|
||||
error_token.state = static_cast<state_type> (yyn);
|
||||
error_token.state = state_type (yyn);
|
||||
yypush_ ("Shifting", YY_MOVE (error_token));
|
||||
}
|
||||
goto yynewstate;
|
||||
@@ -1111,6 +1189,7 @@ b4_dollar_popdef])[]dnl
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYABORT or YYACCEPT. */
|
||||
yypop_ (yylen);
|
||||
YY_STACK_PRINT ();
|
||||
while (1 < yystack_.size ())
|
||||
{
|
||||
yy_destroy_ ("Cleanup: popping", yystack_[0]);
|
||||
@@ -1143,10 +1222,71 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
error (]b4_join(b4_locations_if([yyexc.location]),
|
||||
[[yyexc.what ()]])[);
|
||||
}]b4_lac_if([[
|
||||
}]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)
|
||||
, yyla_ (yyla)
|
||||
{}
|
||||
|
||||
int
|
||||
]b4_parser_class[::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const
|
||||
{
|
||||
// Actual number of expected tokens
|
||||
int yycount = 0;
|
||||
]b4_lac_if([[
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
// Execute LAC once. We don't care if it is successful, we
|
||||
// only do it for the sake of debugging output.
|
||||
if (!yyparser_.yy_lac_established_)
|
||||
yyparser_.yy_lac_check_ (yyla_.kind ());
|
||||
#endif
|
||||
|
||||
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
|
||||
&& yysym != symbol_kind::]b4_symbol_prefix[YYUNDEF
|
||||
&& yyparser_.yy_lac_check_ (yysym))
|
||||
{
|
||||
if (!yyarg)
|
||||
++yycount;
|
||||
else if (yycount == yyargn)
|
||||
return 0;
|
||||
else
|
||||
yyarg[yycount++] = yysym;
|
||||
}
|
||||
}]], [[
|
||||
int yyn = yypact_[+yyparser_.yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
// Stay within bounds of both yycheck and yytname.
|
||||
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
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (!yyarg)
|
||||
++yycount;
|
||||
else if (yycount == yyargn)
|
||||
return 0;
|
||||
else
|
||||
yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
|
||||
}
|
||||
}
|
||||
]])[
|
||||
return yycount;
|
||||
}
|
||||
|
||||
]])b4_lac_if([[
|
||||
bool
|
||||
]b4_parser_class[::yy_lac_check_ (int yytoken) const
|
||||
]b4_parser_class[::yy_lac_check_ (symbol_kind_type yytoken) const
|
||||
{
|
||||
// Logically, the yylac_stack's lifetime is confined to this function.
|
||||
// Clear it, to get rid of potential left-overs from previous call.
|
||||
@@ -1161,13 +1301,13 @@ b4_dollar_popdef])[]dnl
|
||||
state_type top_state = (yylac_stack_.empty ()
|
||||
? yystack_[lac_top].state
|
||||
: yylac_stack_.back ());
|
||||
int yyrule = yypact_[top_state];
|
||||
int yyrule = yypact_[+top_state];
|
||||
if (yy_pact_value_is_default_ (yyrule)
|
||||
|| (yyrule += yytoken) < 0 || yylast_ < yyrule
|
||||
|| yycheck_[yyrule] != yytoken)
|
||||
{
|
||||
// Use the default action.
|
||||
yyrule = yydefact_[top_state];
|
||||
yyrule = yydefact_[+top_state];
|
||||
if (yyrule == 0)
|
||||
{
|
||||
YYCDEBUG << " Err\n";
|
||||
@@ -1224,7 +1364,7 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
// Establish the initial context if no initial context currently exists.
|
||||
bool
|
||||
]b4_parser_class[::yy_lac_establish_ (int yytoken)
|
||||
]b4_parser_class[::yy_lac_establish_ (symbol_kind_type yytoken)
|
||||
{
|
||||
/* Establish the initial context for the current lookahead if no initial
|
||||
context is currently established.
|
||||
@@ -1282,22 +1422,12 @@ b4_dollar_popdef])[]dnl
|
||||
<< evt << '\n';
|
||||
yy_lac_established_ = false;
|
||||
}
|
||||
}]])[
|
||||
|
||||
// Generate an error message.
|
||||
std::string
|
||||
]b4_parser_class[::yysyntax_error_ (]dnl
|
||||
b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
[state_type, const symbol_type&])[) const
|
||||
{]b4_error_verbose_if([[
|
||||
// Number of reported tokens (one for the "unexpected", one per
|
||||
// "expected").
|
||||
std::ptrdiff_t yycount = 0;
|
||||
// Its maximum.
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
// Arguments of yyformat.
|
||||
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
||||
}]])b4_parse_error_bmatch([detailed\|verbose], [[
|
||||
|
||||
int
|
||||
]b4_parser_class[::yy_syntax_error_arguments_ (const context& yyctx,
|
||||
symbol_kind_type yyarg[], int yyargn) const
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- If this state is a consistent state with a default action, then
|
||||
the only way this function was invoked is if the default action
|
||||
@@ -1328,45 +1458,26 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
one exception: it will still contain any token that will not be
|
||||
accepted due to an error action in a later state.]])[
|
||||
*/
|
||||
if (!yyla.empty ())
|
||||
|
||||
if (!yyctx.lookahead ().empty ())
|
||||
{
|
||||
int yytoken = yyla.type_get ();
|
||||
yyarg[yycount++] = yytname_[yytoken];]b4_lac_if([[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
// Execute LAC once. We don't care if it is succesful, we
|
||||
// only do it for the sake of debugging output.
|
||||
if (!yy_lac_established_)
|
||||
yy_lac_check_ (yytoken);
|
||||
#endif]])[
|
||||
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{]b4_lac_if([[
|
||||
for (int yyx = 0; yyx < yyntokens_; ++yyx)
|
||||
if (yyx != yyterror_ && yy_lac_check_(yyx))
|
||||
{]], [[
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
// Stay within bounds of both yycheck and yytname.
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{]])[
|
||||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
||||
{
|
||||
yycount = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
yyarg[yycount++] = yytname_[yyx];
|
||||
}
|
||||
}
|
||||
if (yyarg)
|
||||
yyarg[0] = yyctx.token ();
|
||||
int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
|
||||
return yyn + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Generate an error message.
|
||||
std::string
|
||||
]b4_parser_class[::yysyntax_error_ (const context& yyctx) const
|
||||
{
|
||||
// Its maximum.
|
||||
enum { YYARGS_MAX = 5 };
|
||||
// Arguments of yyformat.
|
||||
symbol_kind_type yyarg[YYARGS_MAX];
|
||||
int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
|
||||
|
||||
char const* yyformat = YY_NULLPTR;
|
||||
switch (yycount)
|
||||
@@ -1391,14 +1502,15 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
for (char const* yyp = yyformat; *yyp; ++yyp)
|
||||
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
||||
{
|
||||
yyres += yytnamerr_ (yyarg[yyi++]);
|
||||
yyres += ]b4_parse_error_case([verbose],
|
||||
[[yytnamerr_ (yytname_[yyarg[yyi++]])]],
|
||||
[[symbol_name (yyarg[yyi++])]])[;
|
||||
++yyp;
|
||||
}
|
||||
else
|
||||
yyres += *yyp;
|
||||
return yyres;]], [[
|
||||
return YY_("syntax error");]])[
|
||||
}
|
||||
return yyres;
|
||||
}]])[
|
||||
|
||||
|
||||
const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class::yypact_ninf_ = b4_pact_ninf[;
|
||||
@@ -1407,19 +1519,19 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||
]b4_tname_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||
// YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
// First, the terminals, then, starting at \a yyntokens_, nonterminals.
|
||||
// First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
|
||||
const char*
|
||||
const ]b4_parser_class[::yytname_[] =
|
||||
{
|
||||
]b4_tname[
|
||||
};
|
||||
]b4_tname_if([], [[#endif]])[
|
||||
|
||||
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
|
||||
#if ]b4_api_PREFIX[DEBUG][
|
||||
]b4_integral_parser_table_define([rline], [b4_rline])[
|
||||
|
||||
// Print the state stack on the debug stream.
|
||||
void
|
||||
]b4_parser_class[::yystack_print_ ()
|
||||
{
|
||||
@@ -1432,7 +1544,6 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
*yycdebug_ << '\n';
|
||||
}
|
||||
|
||||
// Report on the debug stream that the rule \a yyrule is going to be reduced.
|
||||
void
|
||||
]b4_parser_class[::yy_reduce_print_ (int yyrule)
|
||||
{
|
||||
|
||||
+134
-134
@@ -1,6 +1,6 @@
|
||||
# D skeleton for Bison -*- autoconf -*-
|
||||
|
||||
# Copyright (C) 2007-2012, 2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2012, 2019-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
|
||||
@@ -20,7 +20,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])[
|
||||
[2007-2012, 2019-2020])[
|
||||
|
||||
]b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
||||
])[
|
||||
@@ -182,13 +182,12 @@ b4_user_union_members
|
||||
};],
|
||||
[m4_if(b4_tag_seen_flag, 0,
|
||||
[[private alias int YYSemanticType;]])])[
|
||||
]b4_token_enums(b4_tokens)[
|
||||
]b4_token_enums[
|
||||
]b4_parser_class_declaration[
|
||||
{
|
||||
]b4_identification[
|
||||
|
||||
/** True if verbose error messages are enabled. */
|
||||
public bool errorVerbose = ]b4_flag_value([error_verbose])[;
|
||||
]b4_declare_symbol_enum[
|
||||
|
||||
]b4_locations_if([[
|
||||
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
|
||||
@@ -264,6 +263,11 @@ b4_user_union_members
|
||||
public final void setDebugLevel(int level) { yydebug = level; }
|
||||
|
||||
protected final void yycdebug (string s) {
|
||||
if (0 < yydebug)
|
||||
yyDebugStream.write (s);
|
||||
}
|
||||
|
||||
protected final void yycdebugln (string s) {
|
||||
if (0 < yydebug)
|
||||
yyDebugStream.writeln (s);
|
||||
}
|
||||
@@ -338,7 +342,8 @@ b4_user_union_members
|
||||
}
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);]])[
|
||||
import std.conv : to;
|
||||
yy_symbol_print ("-> $$ =", to!SymbolKind (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystack.pop (yylen);
|
||||
yylen = 0;
|
||||
@@ -396,20 +401,21 @@ b4_user_union_members
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
private final void yy_symbol_print (string s, int yytype,
|
||||
private final void yy_symbol_print (string s, SymbolKind yykind,
|
||||
ref ]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
{
|
||||
if (0 < yydebug) {
|
||||
string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
|
||||
~ yytname_[yytype] ~ " ("]b4_locations_if([
|
||||
if (0 < yydebug)
|
||||
{
|
||||
string message = s ~ (yykind < yyntokens_ ? " token " : " nterm ")
|
||||
~ yytname_[yykind] ~ " ("]b4_locations_if([
|
||||
~ yylocationp.toString() ~ ": "])[;
|
||||
static if (__traits(compiles, message ~= yyvaluep.toString ()))
|
||||
message ~= yyvaluep.toString ();
|
||||
else
|
||||
message ~= format ("%s", &yyvaluep);
|
||||
message ~= ")";
|
||||
yycdebug (message);
|
||||
yycdebugln (message);
|
||||
}
|
||||
}
|
||||
]])[
|
||||
@@ -423,8 +429,8 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
public bool parse ()
|
||||
{
|
||||
/// Lookahead and lookahead in internal form.
|
||||
int yychar = yyempty_;
|
||||
int yytoken = 0;
|
||||
int yychar = TokenKind.YYEMPTY;
|
||||
SymbolKind yytoken = SymbolKind.]b4_symbol(-2, kind)[;
|
||||
|
||||
/* State. */
|
||||
int yyn = 0;
|
||||
@@ -447,9 +453,9 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
/// Semantic value of the lookahead.
|
||||
]b4_yystype[ yylval;
|
||||
|
||||
int yyresult;]b4_parse_trace_if([[
|
||||
bool yyresult;]b4_parse_trace_if([[
|
||||
|
||||
yycdebug ("Starting parse\n");]])[
|
||||
yycdebugln ("Starting parse");]])[
|
||||
yyerrstatus_ = 0;
|
||||
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
@@ -470,7 +476,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||
pushed when we come here. */
|
||||
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||
yycdebug (format("Entering state %d\n", yystate));
|
||||
yycdebugln (format("Entering state %d", yystate));
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
|
||||
@@ -487,9 +493,9 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
}
|
||||
|
||||
/* Read a lookahead token. */
|
||||
if (yychar == yyempty_)
|
||||
if (yychar == TokenKind.YYEMPTY)
|
||||
{]b4_parse_trace_if([[
|
||||
yycdebug ("Reading a token: ");]])[
|
||||
yycdebugln ("Reading a token");]])[
|
||||
yychar = yylex ();]b4_locations_if([[
|
||||
static if (yy_location_is_class) {
|
||||
yylloc = new ]b4_location_type[(yylexer.startPos, yylexer.endPos);
|
||||
@@ -501,8 +507,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Convert token to internal form. */
|
||||
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Next token is",
|
||||
yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||
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. */
|
||||
@@ -524,11 +529,10 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);]])[
|
||||
yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* Discard the token being shifted. */
|
||||
yychar = yyempty_;
|
||||
yychar = TokenKind.YYEMPTY;
|
||||
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
* status. */
|
||||
@@ -561,16 +565,16 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yystate = yystack.stateAt (0);
|
||||
break;
|
||||
|
||||
/*------------------------------------.
|
||||
| yyerrlab -- here on detecting error |
|
||||
`------------------------------------*/
|
||||
/*--------------------------------------.
|
||||
| yyerrlab -- here on detecting error. |
|
||||
`--------------------------------------*/
|
||||
case YYERRLAB:
|
||||
/* If not already recovering from an error, report this error. */
|
||||
if (yyerrstatus_ == 0)
|
||||
{
|
||||
++yynerrs_;
|
||||
if (yychar == yyempty_)
|
||||
yytoken = yyempty_;
|
||||
if (yychar == TokenKind.YYEMPTY)
|
||||
yytoken = SymbolKind.]b4_symbol(-2, kind)[;
|
||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||
}
|
||||
|
||||
@@ -580,14 +584,14 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
* error, discard it. */
|
||||
|
||||
if (yychar <= YYTokenType.EOF)
|
||||
if (yychar <= TokenKind.]b4_symbol(0, [id])[)
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == YYTokenType.EOF)
|
||||
if (yychar == TokenKind.]b4_symbol(0, [id])[)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
yychar = yyempty_;
|
||||
yychar = TokenKind.YYEMPTY;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token after shifting the error
|
||||
@@ -614,13 +618,14 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
case 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 (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
yyn += SymbolKind.]b4_symbol_prefix[YYERROR;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == SymbolKind.]b4_symbol_prefix[YYERROR)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -647,9 +652,8 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yystack.pop (2);])[
|
||||
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
import std.conv : to;
|
||||
yy_symbol_print ("Shifting", to!SymbolKind (yystos_[yyn]), yylval]b4_locations_if([, yyloc])[);]])[
|
||||
yystate = yyn;
|
||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||
label = YYNEWSTATE;
|
||||
@@ -657,88 +661,93 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Accept. */
|
||||
case YYACCEPT:
|
||||
return true;
|
||||
yyresult = true;
|
||||
label = YYRETURN;
|
||||
break;
|
||||
|
||||
/* Abort. */
|
||||
case YYABORT:
|
||||
return false;
|
||||
yyresult = false;
|
||||
label = YYRETURN;
|
||||
break;
|
||||
|
||||
case YYRETURN:]b4_parse_trace_if([[
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
return yyresult;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate an error message.
|
||||
private final string yysyntax_error (int yystate, int tok)
|
||||
{
|
||||
if (errorVerbose)
|
||||
private final string yysyntax_error (int yystate, SymbolKind tok)
|
||||
{]b4_parse_error_case([verbose], [[
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||
See
|
||||
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||
for details. YYERROR is fine as it does not invoke this
|
||||
function.
|
||||
- If this state is a consistent state with a default action,
|
||||
then the only way this function was invoked is if the
|
||||
default action is an error action. In that case, don't
|
||||
check for expected tokens because there are none.
|
||||
- The only way there can be no lookahead present (in tok) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this
|
||||
state is a consistent state with a default action. There
|
||||
might have been a previous inconsistent state, consistent
|
||||
state with a non-default action, or user semantic action
|
||||
that manipulated yychar. (However, yychar is currently out
|
||||
of scope during semantic actions.)
|
||||
- Of course, the expected token list depends on states to
|
||||
have correct lookahead information, and it depends on the
|
||||
parser not to perform extra reductions after fetching a
|
||||
lookahead from the scanner and before detecting a syntax
|
||||
error. Thus, state merging (from LALR or IELR) and default
|
||||
reductions corrupt the expected token list. However, the
|
||||
list is correct for canonical LR with one exception: it
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
if (tok != SymbolKind.]b4_symbol(-2, kind)[)
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||
See
|
||||
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||
for details. YYERROR is fine as it does not invoke this
|
||||
function.
|
||||
- If this state is a consistent state with a default action,
|
||||
then the only way this function was invoked is if the
|
||||
default action is an error action. In that case, don't
|
||||
check for expected tokens because there are none.
|
||||
- The only way there can be no lookahead present (in tok) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this
|
||||
state is a consistent state with a default action. There
|
||||
might have been a previous inconsistent state, consistent
|
||||
state with a non-default action, or user semantic action
|
||||
that manipulated yychar. (However, yychar is currently out
|
||||
of scope during semantic actions.)
|
||||
- Of course, the expected token list depends on states to
|
||||
have correct lookahead information, and it depends on the
|
||||
parser not to perform extra reductions after fetching a
|
||||
lookahead from the scanner and before detecting a syntax
|
||||
error. Thus, state merging (from LALR or IELR) and default
|
||||
reductions corrupt the expected token list. However, the
|
||||
list is correct for canonical LR with one exception: it
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
if (tok != yyempty_)
|
||||
// FIXME: This method of building the message is not compatible
|
||||
// with internationalization.
|
||||
string res = "syntax error, unexpected ";
|
||||
res ~= yytnamerr_ (yytname_[tok]);
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
// FIXME: This method of building the message is not compatible
|
||||
// with internationalization.
|
||||
string res = "syntax error, unexpected ";
|
||||
res ~= yytnamerr_ (yytname_[tok]);
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
-YYN actions for this state because they are default
|
||||
actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !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 != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||
res ~= yytnamerr_ (yytname_[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
-YYN actions for this state because they are default
|
||||
actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
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
|
||||
&& !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
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||
res ~= yytnamerr_ (yytname_[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}]])[
|
||||
return "syntax error";
|
||||
}
|
||||
|
||||
@@ -771,14 +780,6 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
||||
to YYLEX-NUM. */
|
||||
private static immutable ]b4_int_type_for([b4_toknum])[[]
|
||||
yytoken_number_ =
|
||||
@{
|
||||
]b4_toknum[
|
||||
@};
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||
private static immutable string[] yytname_ =
|
||||
@@ -802,48 +803,48 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
int yylno = yyrline_[yyrule];
|
||||
int yynrhs = yyr2_[yyrule];
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
yycdebug (format("Reducing stack by rule %d (line %d), ",
|
||||
yyrule - 1, yylno));
|
||||
yycdebugln (format("Reducing stack by rule %d (line %d):",
|
||||
yyrule - 1, yylno));
|
||||
|
||||
/* The symbols being reduced. */
|
||||
import std.conv : to;
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yy_symbol_print (format(" $%d =", yyi + 1),
|
||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||
to!SymbolKind (yystos_[yystack.stateAt(yynrhs - (yyi + 1))]),
|
||||
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}
|
||||
]])[
|
||||
|
||||
private static ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||
private static SymbolKind yytranslate_ (int t)
|
||||
{
|
||||
]b4_api_token_raw_if(
|
||||
[[ import std.conv : to;
|
||||
return to!byte (t);]],
|
||||
return to!SymbolKind (t);]],
|
||||
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
immutable ]b4_int_type_for([b4_translate])[[] translate_table =
|
||||
@{
|
||||
]b4_translate[
|
||||
@};
|
||||
|
||||
immutable int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
|
||||
if (t <= 0)
|
||||
return YYTokenType.EOF;
|
||||
else if (t <= yyuser_token_number_max_)
|
||||
return translate_table[t];
|
||||
return SymbolKind.]b4_symbol_prefix[YYEOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
{
|
||||
import std.conv : to;
|
||||
return to!SymbolKind (translate_table[t]);
|
||||
}
|
||||
else
|
||||
return yyundef_token_;]])[
|
||||
return SymbolKind.]b4_symbol_prefix[YYUNDEF;]])[
|
||||
}
|
||||
|
||||
private static immutable int yylast_ = ]b4_last[;
|
||||
private static immutable int yynnts_ = ]b4_nterms_number[;
|
||||
private static immutable int yyempty_ = -2;
|
||||
private static immutable int yyfinal_ = ]b4_final_state_number[;
|
||||
private static immutable int yyterror_ = 1;
|
||||
private static immutable int yyerrcode_ = 256;
|
||||
private static immutable int yyntokens_ = ]b4_tokens_number[;
|
||||
|
||||
private static immutable int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||
private static immutable int yyundef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
private final struct YYStackElement {
|
||||
int state;
|
||||
]b4_yystype[ value;]b4_locations_if(
|
||||
@@ -899,9 +900,8 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
stream.writeln ();
|
||||
}]])[
|
||||
}
|
||||
|
||||
/* User implementation code. */
|
||||
]b4_percent_code_get[
|
||||
}
|
||||
]b4_epilogue[]dnl
|
||||
]b4_percent_code_get([[epilogue]])[]dnl
|
||||
b4_epilogue[]dnl
|
||||
b4_output_end
|
||||
|
||||
+294
-244
@@ -1,6 +1,6 @@
|
||||
# Java skeleton for Bison -*- autoconf -*-
|
||||
|
||||
# Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2015, 2018-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
|
||||
@@ -49,13 +49,13 @@ b4_use_push_for_pull_if([
|
||||
b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
|
||||
[m4_define([b4_push_flag], [[1]])])])
|
||||
|
||||
# Define a macro to encapsulate the parse state variables.
|
||||
# This allows them to be defined either in parse() when doing
|
||||
# pull parsing, or as class instance variable when doing push parsing.
|
||||
# Define a macro to encapsulate the parse state variables. This
|
||||
# allows them to be defined either in parse() when doing pull parsing,
|
||||
# or as class instance variable when doing push parsing.
|
||||
m4_define([b4_define_state],[[
|
||||
/* Lookahead and lookahead in internal form. */
|
||||
int yychar = yyempty_;
|
||||
int yytoken = 0;
|
||||
int yychar = YYEMPTY_;
|
||||
SymbolKind yytoken = null;
|
||||
|
||||
/* State. */
|
||||
int yyn = 0;
|
||||
@@ -64,9 +64,8 @@ m4_define([b4_define_state],[[
|
||||
YYStack yystack = new YYStack ();
|
||||
int label = YYNEWSTATE;
|
||||
|
||||
/* Error handling. */
|
||||
int yynerrs_ = 0;
|
||||
]b4_locations_if([[/* The location where the error started. */
|
||||
]b4_locations_if([[
|
||||
/* The location where the error started. */
|
||||
]b4_location_type[ yyerrloc = null;
|
||||
|
||||
/* Location. */
|
||||
@@ -78,11 +77,12 @@ 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-2019])[
|
||||
[2007-2015, 2018-2020])[
|
||||
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
||||
]])[
|
||||
]b4_user_pre_prologue[
|
||||
]b4_user_post_prologue[
|
||||
import java.text.MessageFormat;
|
||||
]b4_percent_code_get([[imports]])[
|
||||
/**
|
||||
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
||||
@@ -91,8 +91,10 @@ m4_define([b4_define_state],[[
|
||||
*/
|
||||
]b4_parser_class_declaration[
|
||||
{
|
||||
]b4_identification[
|
||||
]b4_error_verbose_if([[
|
||||
]b4_identification[
|
||||
][
|
||||
]b4_parse_error_bmatch(
|
||||
[detailed\|verbose], [[
|
||||
/**
|
||||
* True if verbose error messages are enabled.
|
||||
*/
|
||||
@@ -109,9 +111,9 @@ m4_define([b4_define_state],[[
|
||||
*/
|
||||
public final void setErrorVerbose(boolean verbose)
|
||||
{ yyErrorVerbose = verbose; }
|
||||
]])
|
||||
]])[
|
||||
|
||||
b4_locations_if([[
|
||||
]b4_locations_if([[
|
||||
/**
|
||||
* A class defining a pair of positions. Positions, defined by the
|
||||
* <code>]b4_position_type[</code> class, denote a point in the input.
|
||||
@@ -161,9 +163,6 @@ b4_locations_if([[
|
||||
}
|
||||
}
|
||||
|
||||
]])[
|
||||
|
||||
]b4_locations_if([[
|
||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
||||
{
|
||||
if (0 < n)
|
||||
@@ -172,17 +171,19 @@ b4_locations_if([[
|
||||
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
||||
}]])[
|
||||
|
||||
]b4_declare_symbol_enum[
|
||||
|
||||
/**
|
||||
* Communication interface between the scanner and the Bison-generated
|
||||
* parser <tt>]b4_parser_class[</tt>.
|
||||
*/
|
||||
public interface Lexer {
|
||||
/** Token returned by the scanner to signal the end of its input. */
|
||||
public static final int EOF = 0;
|
||||
|
||||
]b4_token_enums[
|
||||
/** Deprecated, use b4_symbol(0, id) instead. */
|
||||
public static final int EOF = ]b4_symbol(0, id)[;
|
||||
|
||||
]b4_locations_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.
|
||||
*/
|
||||
@@ -206,17 +207,25 @@ b4_locations_if([[
|
||||
* ]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.
|
||||
*
|
||||
* ]b4_locations_if([[@@param loc The location of the element to which the
|
||||
*]b4_locations_if([[ @@param loc The location of the element to which the
|
||||
* error message is related]])[
|
||||
* @@param msg The string for the error message.
|
||||
*/
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom], [[
|
||||
/**
|
||||
* Build and emit a syntax error message.
|
||||
*/
|
||||
void reportSyntaxError (][Context yyctx);
|
||||
]])[
|
||||
}
|
||||
|
||||
]b4_lexer_if([[
|
||||
@@ -224,22 +233,23 @@ b4_locations_if([[
|
||||
]b4_percent_code_get([[lexer]])[
|
||||
}
|
||||
|
||||
]])[/**
|
||||
]])[
|
||||
/**
|
||||
* The object doing lexical analysis for us.
|
||||
*/
|
||||
private Lexer yylexer;
|
||||
|
||||
]b4_parse_param_vars[
|
||||
]b4_parse_param_vars[
|
||||
|
||||
]b4_lexer_if([[
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
*/
|
||||
public ]b4_parser_class (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
|
||||
public ]b4_parser_class (b4_parse_param_decl([b4_lex_param_decl])[)]b4_maybe_throws([b4_init_throws])[
|
||||
{
|
||||
]b4_percent_code_get([[init]])[
|
||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
||||
]b4_parse_param_cons[
|
||||
]b4_percent_code_get([[init]])[
|
||||
this.yylexer = new YYLexer (]b4_lex_param_call[);
|
||||
]b4_parse_param_cons[
|
||||
}
|
||||
]])[
|
||||
|
||||
@@ -247,11 +257,11 @@ b4_locations_if([[
|
||||
* Instantiates the Bison-generated parser.
|
||||
* @@param yylexer The scanner that will supply tokens to the parser.
|
||||
*/
|
||||
]b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
||||
]b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[)]b4_maybe_throws([b4_init_throws])[
|
||||
{
|
||||
]b4_percent_code_get([[init]])[
|
||||
]b4_percent_code_get([[init]])[
|
||||
this.yylexer = yylexer;
|
||||
]b4_parse_param_cons[
|
||||
]b4_parse_param_cons[
|
||||
}
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
@@ -266,7 +276,7 @@ b4_locations_if([[
|
||||
* Set the <tt>PrintStream</tt> on which the debug output is printed.
|
||||
* @@param s The stream that is used for debugging output.
|
||||
*/
|
||||
public final void setDebugStream(java.io.PrintStream s) { yyDebugStream = s; }
|
||||
public final void setDebugStream (java.io.PrintStream s) { yyDebugStream = s; }
|
||||
|
||||
private int yydebug = 0;
|
||||
|
||||
@@ -274,16 +284,23 @@ b4_locations_if([[
|
||||
* Answer the verbosity of the debugging output; 0 means that all kinds of
|
||||
* output from the parser are suppressed.
|
||||
*/
|
||||
public final int getDebugLevel() { return yydebug; }
|
||||
public final int getDebugLevel () { return yydebug; }
|
||||
|
||||
/**
|
||||
* Set the verbosity of the debugging output; 0 means that all kinds of
|
||||
* output from the parser are suppressed.
|
||||
* @@param level The verbosity level for debugging output.
|
||||
*/
|
||||
public final void setDebugLevel(int level) { yydebug = level; }
|
||||
public final void setDebugLevel (int level) { yydebug = level; }
|
||||
]])[
|
||||
|
||||
private int yynerrs = 0;
|
||||
|
||||
/**
|
||||
* The number of syntax errors so far.
|
||||
*/
|
||||
public final int getNumberOfErrors () { return yynerrs; }
|
||||
|
||||
/**
|
||||
* Print an error message via the lexer.
|
||||
*]b4_locations_if([[ Use a <code>null</code> location.]])[
|
||||
@@ -320,22 +337,20 @@ b4_locations_if([[
|
||||
}]])[
|
||||
|
||||
private final class YYStack {
|
||||
private int[] stateStack = new int[16];
|
||||
]b4_locations_if([[private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[
|
||||
private int[] stateStack = new int[16];]b4_locations_if([[
|
||||
private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[
|
||||
private ]b4_yystype[[] valueStack = new ]b4_yystype[[16];
|
||||
|
||||
public int size = 16;
|
||||
public int height = -1;
|
||||
|
||||
public final void push (int state, ]b4_yystype[ value]dnl
|
||||
b4_locations_if([, ]b4_location_type[ loc])[) {
|
||||
public final void push (int state, ]b4_yystype[ value]b4_locations_if([, ]b4_location_type[ loc])[) {
|
||||
height++;
|
||||
if (size == height)
|
||||
{
|
||||
int[] newStateStack = new int[size * 2];
|
||||
System.arraycopy (stateStack, 0, newStateStack, 0, height);
|
||||
stateStack = newStateStack;
|
||||
]b4_locations_if([[
|
||||
stateStack = newStateStack;]b4_locations_if([[
|
||||
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
|
||||
System.arraycopy (locStack, 0, newLocStack, 0, height);
|
||||
locStack = newLocStack;]])
|
||||
@@ -347,8 +362,8 @@ b4_locations_if([[
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
stateStack[height] = state;
|
||||
]b4_locations_if([[locStack[height] = loc;]])[
|
||||
stateStack[height] = state;]b4_locations_if([[
|
||||
locStack[height] = loc;]])[
|
||||
valueStack[height] = value;
|
||||
}
|
||||
|
||||
@@ -359,8 +374,8 @@ b4_locations_if([[
|
||||
public final void pop (int num) {
|
||||
// Avoid memory leaks... garbage collection is a white lie!
|
||||
if (0 < num) {
|
||||
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
|
||||
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
||||
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);]b4_locations_if([[
|
||||
java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
||||
}
|
||||
height -= num;
|
||||
}
|
||||
@@ -368,12 +383,13 @@ b4_locations_if([[
|
||||
public final int stateAt (int i) {
|
||||
return stateStack[height - i];
|
||||
}
|
||||
]b4_locations_if([[
|
||||
|
||||
]b4_locations_if([[public final ]b4_location_type[ locationAt (int i) {
|
||||
public final ]b4_location_type[ locationAt (int i) {
|
||||
return locStack[height - i];
|
||||
}
|
||||
|
||||
]])[public final ]b4_yystype[ valueAt (int i) {
|
||||
]])[
|
||||
public final ]b4_yystype[ valueAt (int i) {
|
||||
return valueStack[height - i];
|
||||
}
|
||||
|
||||
@@ -445,14 +461,14 @@ b4_locations_if([[
|
||||
*/
|
||||
private int yyLRGotoState (int yystate, int yysym)
|
||||
{
|
||||
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
|
||||
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
||||
int yyr = yypgoto_[yysym - YYNTOKENS_] + yystate;
|
||||
if (0 <= yyr && yyr <= YYLAST_ && yycheck_[yyr] == yystate)
|
||||
return yytable_[yyr];
|
||||
else
|
||||
return yydefgoto_[yysym - yyntokens_];
|
||||
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.
|
||||
@@ -460,8 +476,8 @@ b4_locations_if([[
|
||||
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);]])[
|
||||
|
||||
@@ -471,66 +487,29 @@ b4_locations_if([[
|
||||
default: break;
|
||||
}]b4_parse_trace_if([[
|
||||
|
||||
yySymbolPrint ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);]])[
|
||||
yySymbolPrint ("-> $$ =", SymbolKind.get (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
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])[);
|
||||
return YYNEWSTATE;
|
||||
}
|
||||
|
||||
]b4_error_verbose_if([[
|
||||
/* 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. */
|
||||
private final String yytnamerr_ (String yystr)
|
||||
{
|
||||
if (yystr.charAt (0) == '"')
|
||||
{
|
||||
StringBuffer yyr = new StringBuffer ();
|
||||
strip_quotes: for (int i = 1; i < yystr.length (); i++)
|
||||
switch (yystr.charAt (i))
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
break strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (yystr.charAt(++i) != '\\')
|
||||
break strip_quotes;
|
||||
/* Fall through. */
|
||||
default:
|
||||
yyr.append (yystr.charAt (i));
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr.toString ();
|
||||
}
|
||||
}
|
||||
else if (yystr.equals ("$end"))
|
||||
return "end of input";
|
||||
|
||||
return yystr;
|
||||
}
|
||||
]])[
|
||||
]b4_parse_trace_if([[
|
||||
/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
private void yySymbolPrint (String s, int yytype,
|
||||
]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, Object yylocationp])[)
|
||||
private void yySymbolPrint(String s, SymbolKind yykind,
|
||||
]b4_yystype[ yyvalue]b4_locations_if([, ]b4_location_type[ yylocation])[)
|
||||
{
|
||||
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
|
||||
+ yytname_[yytype] + " ("]b4_locations_if([
|
||||
+ yylocationp + ": "])[
|
||||
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
|
||||
yycdebug (s
|
||||
+ (yykind.getCode() < YYNTOKENS_ ? " token " : " nterm ")
|
||||
+ yykind.getName() + " ("]b4_locations_if([
|
||||
+ yylocation + ": "])[
|
||||
+ (yyvalue == null ? "(null)" : yyvalue.toString()) + ")");
|
||||
}]])[
|
||||
|
||||
]b4_push_if([],[[
|
||||
@@ -541,29 +520,29 @@ b4_locations_if([[
|
||||
* @@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
|
||||
*
|
||||
* @@param yylextoken current token
|
||||
* @@param yylexval current lval
|
||||
]b4_locations_if([ * @@param yylexloc current position])[
|
||||
* @@param yylexval current lval]b4_locations_if([[
|
||||
* @@param yylexloc current position]])[
|
||||
*
|
||||
* @@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])])])[
|
||||
{
|
||||
]b4_locations_if([/* @@$. */
|
||||
b4_location_type yyloc;])[
|
||||
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;]])[
|
||||
]b4_push_if([],[[
|
||||
]b4_define_state[]b4_parse_trace_if([[
|
||||
yycdebug ("Starting parse\n");]])[
|
||||
yycdebug ("Starting parse");]])[
|
||||
yyerrstatus_ = 0;
|
||||
yynerrs = 0;
|
||||
|
||||
/* Initialize the stack. */
|
||||
yystack.push (yystate, yylval ]b4_locations_if([, yylloc])[);
|
||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
||||
b4_user_initial_action
|
||||
@@ -579,7 +558,7 @@ b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef[]dnl
|
||||
])[]b4_parse_trace_if([[
|
||||
yycdebug ("Starting parse\n");]])[
|
||||
yycdebug ("Starting parse");]])[
|
||||
yyerrstatus_ = 0;
|
||||
} else
|
||||
label = YYGETTOKEN;
|
||||
@@ -592,12 +571,12 @@ b4_dollar_popdef[]dnl
|
||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||
pushed when we come here. */
|
||||
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||
yycdebug ("Entering state " + yystate + "\n");
|
||||
yycdebug ("Entering state " + yystate);
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
|
||||
/* Accept? */
|
||||
if (yystate == yyfinal_)
|
||||
if (yystate == YYFINAL_)
|
||||
]b4_push_if([{label = YYACCEPT; break;}],
|
||||
[return true;])[
|
||||
|
||||
@@ -612,17 +591,17 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
case YYGETTOKEN:])[
|
||||
/* Read a lookahead token. */
|
||||
if (yychar == yyempty_)
|
||||
if (yychar == YYEMPTY_)
|
||||
{
|
||||
]b4_push_if([[
|
||||
if (!push_token_consumed)
|
||||
return YYPUSH_MORE;]b4_parse_trace_if([[
|
||||
yycdebug ("Reading a token: ");]])[
|
||||
yycdebug ("Reading a token");]])[
|
||||
yychar = yylextoken;
|
||||
yylval = yylexval;]b4_locations_if([
|
||||
yylloc = yylexloc;])[
|
||||
push_token_consumed = false;]], [b4_parse_trace_if([[
|
||||
yycdebug ("Reading a token: ");]])[
|
||||
yycdebug ("Reading a token");]])[
|
||||
yychar = yylexer.yylex ();
|
||||
yylval = yylexer.getLVal ();]b4_locations_if([
|
||||
yylloc = new b4_location_type (yylexer.getStartPos (),
|
||||
@@ -637,8 +616,8 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* 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)
|
||||
yyn += yytoken.getCode ();
|
||||
if (yyn < 0 || YYLAST_ < yyn || yycheck_[yyn] != yytoken.getCode ())
|
||||
label = YYDEFAULT;
|
||||
|
||||
/* <= 0 means reduce or error. */
|
||||
@@ -660,7 +639,7 @@ b4_dollar_popdef[]dnl
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
]])[
|
||||
/* Discard the token being shifted. */
|
||||
yychar = yyempty_;
|
||||
yychar = YYEMPTY_;
|
||||
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
status. */
|
||||
@@ -700,26 +679,27 @@ b4_dollar_popdef[]dnl
|
||||
/* If not already recovering from an error, report this error. */
|
||||
if (yyerrstatus_ == 0)
|
||||
{
|
||||
++yynerrs_;
|
||||
if (yychar == yyempty_)
|
||||
yytoken = yyempty_;
|
||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||
++yynerrs;
|
||||
if (yychar == YYEMPTY_)
|
||||
yytoken = null;
|
||||
yyreportSyntaxError (new Context (yystack, yytoken]b4_locations_if([[, yylloc]])[));
|
||||
}
|
||||
|
||||
]b4_locations_if([yyerrloc = yylloc;])[
|
||||
]b4_locations_if([[
|
||||
yyerrloc = yylloc;]])[
|
||||
if (yyerrstatus_ == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
error, discard it. */
|
||||
|
||||
if (yychar <= Lexer.EOF)
|
||||
if (yychar <= Lexer.]b4_symbol(0, id)[)
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == Lexer.EOF)
|
||||
if (yychar == Lexer.]b4_symbol(0, id)[)
|
||||
]b4_push_if([{label = YYABORT; break;}], [return false;])[
|
||||
}
|
||||
else
|
||||
yychar = yyempty_;
|
||||
yychar = YYEMPTY_;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token after shifting the error
|
||||
@@ -730,8 +710,8 @@ b4_dollar_popdef[]dnl
|
||||
/*-------------------------------------------------.
|
||||
| errorlab -- error raised explicitly by YYERROR. |
|
||||
`-------------------------------------------------*/
|
||||
case YYERROR:
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
|
||||
case YYERROR:]b4_locations_if([[
|
||||
yyerrloc = yystack.locationAt (yylen - 1);]])[
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYERROR. */
|
||||
yystack.pop (yylen);
|
||||
@@ -746,13 +726,15 @@ b4_dollar_popdef[]dnl
|
||||
case 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 (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
yyn += SymbolKind.]b4_symbol_prefix[YYERROR.getCode ();
|
||||
if (0 <= yyn && yyn <= YYLAST_
|
||||
&& yycheck_[yyn] == SymbolKind.]b4_symbol_prefix[YYERROR.getCode ())
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -765,7 +747,8 @@ b4_dollar_popdef[]dnl
|
||||
if (yystack.height == 0)
|
||||
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
||||
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
|
||||
]b4_locations_if([[
|
||||
yyerrloc = yystack.locationAt (0);]])[
|
||||
yystack.pop ();
|
||||
yystate = yystack.stateAt (0);]b4_parse_trace_if([[
|
||||
if (0 < yydebug)
|
||||
@@ -773,18 +756,18 @@ b4_dollar_popdef[]dnl
|
||||
}
|
||||
|
||||
if (label == YYABORT)
|
||||
/* Leave the switch. */
|
||||
break;
|
||||
/* Leave the switch. */
|
||||
break;
|
||||
|
||||
]b4_locations_if([
|
||||
]b4_locations_if([[
|
||||
/* Muck with the stack to setup for yylloc. */
|
||||
yystack.push (0, null, yylloc);
|
||||
yystack.push (0, null, yyerrloc);
|
||||
yyloc = yylloc (yystack, 2);
|
||||
yystack.pop (2);])[
|
||||
yystack.pop (2);]])[
|
||||
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Shifting", yystos_[yyn],
|
||||
yySymbolPrint ("Shifting", SymbolKind.get (yystos_[yyn]),
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystate = yyn;
|
||||
@@ -809,11 +792,11 @@ b4_dollar_popdef[]dnl
|
||||
/**
|
||||
* (Re-)Initialize the state of the push parser.
|
||||
*/
|
||||
public void push_parse_initialize()
|
||||
public void push_parse_initialize ()
|
||||
{
|
||||
/* Lookahead and lookahead in internal form. */
|
||||
this.yychar = yyempty_;
|
||||
this.yytoken = 0;
|
||||
this.yychar = YYEMPTY_;
|
||||
this.yytoken = null;
|
||||
|
||||
/* State. */
|
||||
this.yyn = 0;
|
||||
@@ -823,10 +806,10 @@ b4_dollar_popdef[]dnl
|
||||
this.label = YYNEWSTATE;
|
||||
|
||||
/* Error handling. */
|
||||
this.yynerrs_ = 0;
|
||||
]b4_locations_if([/* The location where the error started. */
|
||||
this.yynerrs = 0;]b4_locations_if([[
|
||||
/* The location where the error started. */
|
||||
this.yyerrloc = null;
|
||||
this.yylloc = new b4_location_type (null, null);])[
|
||||
this.yylloc = new ]b4_location_type[ (null, null);]])[
|
||||
|
||||
/* Semantic value of the lookahead. */
|
||||
this.yylval = null;
|
||||
@@ -846,8 +829,7 @@ 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])])
|
||||
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));
|
||||
}
|
||||
@@ -862,7 +844,7 @@ b4_dollar_popdef[]dnl
|
||||
* @@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])])[
|
||||
{
|
||||
if (yylexer == null)
|
||||
throw new NullPointerException("Null Lexer");
|
||||
@@ -872,85 +854,167 @@ b4_dollar_popdef[]dnl
|
||||
]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);])[
|
||||
yylexer.getEndPos ());])[]b4_locations_if([[
|
||||
status = push_parse(token,lval,yyloc);]], [[
|
||||
status = push_parse(token,lval);]])[
|
||||
} while (status == YYPUSH_MORE);
|
||||
return (status == YYACCEPT);
|
||||
}
|
||||
]])[
|
||||
|
||||
// Generate an error message.
|
||||
private String yysyntax_error (int yystate, int tok)
|
||||
{]b4_error_verbose_if([[
|
||||
/**
|
||||
* Information needed to get the list of expected tokens and to forge
|
||||
* a syntax error diagnostic.
|
||||
*/
|
||||
public static final class Context
|
||||
{
|
||||
Context (YYStack stack, SymbolKind token]b4_locations_if([[, ]b4_location_type[ loc]])[)
|
||||
{
|
||||
yystack = stack;
|
||||
yytoken = token;]b4_locations_if([[
|
||||
yylocation = loc;]])[
|
||||
}
|
||||
|
||||
private YYStack yystack;
|
||||
|
||||
|
||||
/**
|
||||
* The symbol kind of the lookahead token.
|
||||
*/
|
||||
public final SymbolKind getToken ()
|
||||
{
|
||||
return yytoken;
|
||||
}
|
||||
|
||||
private SymbolKind yytoken;]b4_locations_if([[
|
||||
|
||||
/**
|
||||
* The location of the lookahead.
|
||||
*/
|
||||
public final ]b4_location_type[ getLocation ()
|
||||
{
|
||||
return yylocation;
|
||||
}
|
||||
|
||||
private ]b4_location_type[ yylocation;]])[
|
||||
static final int NTOKENS = ]b4_parser_class[.YYNTOKENS_;
|
||||
|
||||
/**
|
||||
* Put in YYARG at most YYARGN of the expected tokens given the
|
||||
* current YYCTX, and return the number of tokens stored in YYARG. If
|
||||
* YYARG is null, return the number of expected tokens (guaranteed to
|
||||
* be less than YYNTOKENS).
|
||||
*/
|
||||
int getExpectedTokens (SymbolKind yyarg[], int yyargn)
|
||||
{
|
||||
return getExpectedTokens (yyarg, 0, yyargn);
|
||||
}
|
||||
|
||||
int getExpectedTokens (SymbolKind yyarg[], int yyoffset, int yyargn)
|
||||
{
|
||||
int yycount = yyoffset;
|
||||
int yyn = yypact_[this.yystack.stateAt (0)];
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
-YYN actions for this state because they are default
|
||||
actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
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 ()
|
||||
&& !yyTableValueIsError (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (yyarg == null)
|
||||
yycount += 1;
|
||||
else if (yycount == yyargn)
|
||||
return 0; // FIXME: this is incorrect.
|
||||
else
|
||||
yyarg[yycount++] = SymbolKind.get (yyx);
|
||||
}
|
||||
}
|
||||
return yycount - yyoffset;
|
||||
}
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[detailed\|verbose], [[
|
||||
private int yysyntaxErrorArguments (Context yyctx, SymbolKind[] yyarg, int yyargn)
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- If this state is a consistent state with a default action,
|
||||
then the only way this function was invoked is if the
|
||||
default action is an error action. In that case, don't
|
||||
check for expected tokens because there are none.
|
||||
- The only way there can be no lookahead present (in tok) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this
|
||||
state is a consistent state with a default action. There
|
||||
might have been a previous inconsistent state, consistent
|
||||
state with a non-default action, or user semantic action
|
||||
that manipulated yychar. (However, yychar is currently out
|
||||
of scope during semantic actions.)
|
||||
- Of course, the expected token list depends on states to
|
||||
have correct lookahead information, and it depends on the
|
||||
parser not to perform extra reductions after fetching a
|
||||
lookahead from the scanner and before detecting a syntax
|
||||
error. Thus, state merging (from LALR or IELR) and default
|
||||
reductions corrupt the expected token list. However, the
|
||||
list is correct for canonical LR with one exception: it
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
int yycount = 0;
|
||||
if (yyctx.getToken () != null)
|
||||
{
|
||||
if (yyarg != null)
|
||||
yyarg[yycount] = yyctx.getToken ();
|
||||
yycount += 1;
|
||||
yycount += yyctx.getExpectedTokens (yyarg, 1, yyargn);
|
||||
}
|
||||
return yycount;
|
||||
}
|
||||
]])[
|
||||
|
||||
/**
|
||||
* Report a syntax error.
|
||||
*/
|
||||
private void yyreportSyntaxError (Context yyctx)
|
||||
{]b4_parse_error_bmatch(
|
||||
[custom], [[
|
||||
yylexer.reportSyntaxError (yyctx);]],
|
||||
[detailed\|verbose], [[
|
||||
if (yyErrorVerbose)
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- If this state is a consistent state with a default action,
|
||||
then the only way this function was invoked is if the
|
||||
default action is an error action. In that case, don't
|
||||
check for expected tokens because there are none.
|
||||
- The only way there can be no lookahead present (in tok) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this
|
||||
state is a consistent state with a default action. There
|
||||
might have been a previous inconsistent state, consistent
|
||||
state with a non-default action, or user semantic action
|
||||
that manipulated yychar. (However, yychar is currently out
|
||||
of scope during semantic actions.)
|
||||
- Of course, the expected token list depends on states to
|
||||
have correct lookahead information, and it depends on the
|
||||
parser not to perform extra reductions after fetching a
|
||||
lookahead from the scanner and before detecting a syntax
|
||||
error. Thus, state merging (from LALR or IELR) and default
|
||||
reductions corrupt the expected token list. However, the
|
||||
list is correct for canonical LR with one exception: it
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
if (tok != yyempty_)
|
||||
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)
|
||||
{
|
||||
/* FIXME: This method of building the message is not compatible
|
||||
with internationalization. */
|
||||
StringBuffer res =
|
||||
new StringBuffer ("syntax error, unexpected ");
|
||||
res.append (yytnamerr_ (yytname_[tok]));
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
-YYN actions for this state because they are default
|
||||
actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||
{
|
||||
res.append (count++ == 0 ? ", expecting " : " or ");
|
||||
res.append (yytnamerr_ (yytname_[x]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res.toString ();
|
||||
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));
|
||||
return;
|
||||
}
|
||||
]])[
|
||||
return "syntax error";
|
||||
yyerror (]b4_locations_if([[yyctx.yylocation, ]])["syntax error");]],
|
||||
[simple], [[
|
||||
yyerror (]b4_locations_if([[yyctx.yylocation, ]])["syntax error");]])[
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -975,14 +1039,7 @@ b4_dollar_popdef[]dnl
|
||||
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
||||
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
||||
|
||||
]b4_parser_tables_define[
|
||||
]b4_integral_parser_table_define([token_number], [b4_toknum],
|
||||
[[YYTOKEN_NUMBER[YYLEX-NUM] -- Internal symbol number corresponding
|
||||
to YYLEX-NUM.]])[
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||
]b4_parser_tables_define[
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
]b4_integral_parser_table_define([rline], [b4_rline],
|
||||
@@ -999,50 +1056,43 @@ b4_dollar_popdef[]dnl
|
||||
int yynrhs = yyr2_[yyrule];
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
yycdebug ("Reducing stack by rule " + (yyrule - 1)
|
||||
+ " (line " + yylno + "), ");
|
||||
+ " (line " + yylno + "):");
|
||||
|
||||
/* The symbols being reduced. */
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yySymbolPrint (" $" + (yyi + 1) + " =",
|
||||
yystos_[yystack.stateAt(yynrhs - (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
|
||||
as returned by yylex, with out-of-bounds checking. */
|
||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||
private static final SymbolKind yytranslate_ (int t)
|
||||
]b4_api_token_raw_if(dnl
|
||||
[[ {
|
||||
return t;
|
||||
return SymbolKind.get (t);
|
||||
}
|
||||
]],
|
||||
[[ {
|
||||
int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
if (t <= 0)
|
||||
return Lexer.EOF;
|
||||
else if (t <= yyuser_token_number_max_)
|
||||
return yytranslate_table_[t];
|
||||
return SymbolKind.]b4_symbol_prefix[YYEOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
return SymbolKind.get (yytranslate_table_[t]);
|
||||
else
|
||||
return yyundef_token_;
|
||||
return SymbolKind.]b4_symbol_prefix[YYUNDEF;
|
||||
}
|
||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||
]])[
|
||||
|
||||
private static final int yylast_ = ]b4_last[;
|
||||
private static final int yynnts_ = ]b4_nterms_number[;
|
||||
private static final int yyempty_ = -2;
|
||||
private static final int yyfinal_ = ]b4_final_state_number[;
|
||||
private static final int yyterror_ = 1;
|
||||
private static final int yyerrcode_ = 256;
|
||||
private static final int yyntokens_ = ]b4_tokens_number[;
|
||||
|
||||
private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||
private static final int yyundef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
/* User implementation code. */
|
||||
]b4_percent_code_get[]dnl
|
||||
private static final int YYLAST_ = ]b4_last[;
|
||||
private static final int YYEMPTY_ = -2;
|
||||
private static final int YYFINAL_ = ]b4_final_state_number[;
|
||||
private static final int YYNTOKENS_ = ]b4_tokens_number[;
|
||||
|
||||
]b4_percent_code_get[
|
||||
}
|
||||
|
||||
]b4_percent_code_get([[epilogue]])[]dnl
|
||||
b4_epilogue[]dnl
|
||||
b4_output_end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018-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
|
||||
@@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2015, 2018-2019])
|
||||
[2002-2015, 2018-2020])
|
||||
|
||||
|
||||
# b4_position_file
|
||||
|
||||
+5
-11
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018-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
|
||||
@@ -32,8 +32,8 @@ m4_define([b4_stack_define],
|
||||
{
|
||||
public:
|
||||
// Hide our reversed order.
|
||||
typedef typename S::reverse_iterator iterator;
|
||||
typedef typename S::const_reverse_iterator const_iterator;
|
||||
typedef typename S::iterator iterator;
|
||||
typedef typename S::const_iterator const_iterator;
|
||||
typedef typename S::size_type size_type;
|
||||
typedef typename std::ptrdiff_t index_type;
|
||||
|
||||
@@ -91,24 +91,18 @@ m4_define([b4_stack_define],
|
||||
return index_type (seq_.size ());
|
||||
}
|
||||
|
||||
std::ptrdiff_t
|
||||
ssize () const YY_NOEXCEPT
|
||||
{
|
||||
return std::ptrdiff_t (size ());
|
||||
}
|
||||
|
||||
/// Iterator on top of the stack (going downwards).
|
||||
const_iterator
|
||||
begin () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.rbegin ();
|
||||
return seq_.begin ();
|
||||
}
|
||||
|
||||
/// Bottom of the stack.
|
||||
const_iterator
|
||||
end () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.rend ();
|
||||
return seq_.end ();
|
||||
}
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
|
||||
+21
-21
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018-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
|
||||
@@ -72,9 +72,9 @@ m4_map([ b4_symbol_tag_comment], [$@])dnl
|
||||
# The needed includes for variants support.
|
||||
m4_define([b4_variant_includes],
|
||||
[b4_parse_assert_if([[#include <typeinfo>]])[
|
||||
#ifndef YYASSERT
|
||||
#ifndef YY_ASSERT
|
||||
# include <cassert>
|
||||
# define YYASSERT assert
|
||||
# define YY_ASSERT assert
|
||||
#endif
|
||||
]])
|
||||
|
||||
@@ -111,14 +111,14 @@ m4_define([b4_value_type_declare],
|
||||
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||
}
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
~semantic_type () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
])[}
|
||||
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
@@ -127,8 +127,8 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
emplace (U&&... u)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
||||
}
|
||||
@@ -138,8 +138,8 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
emplace ()
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T ();
|
||||
}
|
||||
@@ -149,8 +149,8 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
emplace (const T& t)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (t);
|
||||
}
|
||||
@@ -179,9 +179,9 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
as () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == typeid (T));
|
||||
YYASSERT (sizeof (T) <= size);])[
|
||||
YY_ASSERT (yytypeid_);
|
||||
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||
YY_ASSERT (sizeof (T) <= size);])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
@@ -190,9 +190,9 @@ m4_define([b4_value_type_declare],
|
||||
const T&
|
||||
as () const YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == typeid (T));
|
||||
YYASSERT (sizeof (T) <= size);])[
|
||||
YY_ASSERT (yytypeid_);
|
||||
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||
YY_ASSERT (sizeof (T) <= size);])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ m4_define([b4_value_type_declare],
|
||||
void
|
||||
swap (self_type& that) YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == *that.yytypeid_);])[
|
||||
YY_ASSERT (yytypeid_);
|
||||
YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
|
||||
std::swap (as<T> (), that.as<T> ());
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ m4_define([_b4_token_constructor_define],
|
||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||
b4_locations_if([std::move (l)]))[)
|
||||
{
|
||||
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
}
|
||||
#else
|
||||
symbol_type (]b4_join(
|
||||
@@ -413,7 +413,7 @@ m4_define([_b4_token_constructor_define],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l]))[)
|
||||
{
|
||||
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
}
|
||||
#endif
|
||||
]])])
|
||||
|
||||
+493
-325
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -3,7 +3,7 @@
|
||||
<!--
|
||||
bison.xsl - common templates for Bison XSLT.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!--
|
||||
xml2dot.xsl - transform Bison XML Report into DOT.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!--
|
||||
xml2text.xsl - transform Bison XML Report into plain text.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!--
|
||||
xml2html.xsl - transform Bison XML Report into XHTML.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
/bison.help
|
||||
/bison.html
|
||||
/bison.info
|
||||
/bison.info.bak
|
||||
/bison.log
|
||||
/bison.pdf
|
||||
/bison.ps
|
||||
|
||||
+368
-186
File diff suppressed because it is too large
Load Diff
+1394
-897
File diff suppressed because it is too large
Load Diff
+48
-47
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2001-2003, 2005-2015, 2018-2019 Free Software
|
||||
## Copyright (C) 2001-2003, 2005-2015, 2018-2020 Free Software
|
||||
## Foundation, Inc.
|
||||
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
@@ -20,36 +20,36 @@ AM_MAKEINFOFLAGS = \
|
||||
--set-customization-variable=AVOID_MENU_REDUNDANCY=true \
|
||||
--set-customization-variable=ICONS=true
|
||||
|
||||
info_TEXINFOS = doc/bison.texi
|
||||
doc_bison_TEXINFOS = \
|
||||
info_TEXINFOS = %D%/bison.texi
|
||||
%C%_bison_TEXINFOS = \
|
||||
$(CROSS_OPTIONS_TEXI) \
|
||||
doc/fdl.texi \
|
||||
doc/gpl-3.0.texi \
|
||||
doc/relocatable.texi
|
||||
%D%/fdl.texi \
|
||||
%D%/gpl-3.0.texi \
|
||||
%D%/relocatable.texi
|
||||
|
||||
# Cannot express dependencies directly on file names because of Automake.
|
||||
# Obfuscate with a variable.
|
||||
doc_bison = doc/bison
|
||||
$(doc_bison).dvi: $(FIGS_GV:.gv=.eps)
|
||||
$(doc_bison).info: $(FIGS_GV:.gv=.txt)
|
||||
$(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
||||
$(doc_bison).html: $(FIGS_GV:.gv=.svg)
|
||||
%C%_bison = %D%/bison
|
||||
$(%C%_bison).dvi: $(FIGS_GV:.gv=.eps)
|
||||
$(%C%_bison).info: $(FIGS_GV:.gv=.txt)
|
||||
$(%C%_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
||||
$(%C%_bison).html: $(FIGS_GV:.gv=.svg)
|
||||
|
||||
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
||||
CLEANDIRS += doc/bison.t2d
|
||||
TEXI2DVI = texi2dvi --build-dir=%D%/bison.t2d -I %D%
|
||||
CLEANDIRS += %D%/bison.t2d
|
||||
|
||||
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.tmp
|
||||
MOSTLYCLEANFILES += $(top_srcdir)/%D%/*.tmp
|
||||
|
||||
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
||||
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
|
||||
$(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
||||
CROSS_OPTIONS_TEXI = $(top_srcdir)/%D%/cross-options.texi
|
||||
$(CROSS_OPTIONS_TEXI): %D%/bison.help $(CROSS_OPTIONS_PL)
|
||||
# Create $@~ which is the previous contents. Don't use 'mv' here so
|
||||
# that even if we are interrupted, the file is still available for
|
||||
# diff in the next run. Note that $@ might not exist yet.
|
||||
$(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~
|
||||
$(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp
|
||||
$(AM_V_at)$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l \
|
||||
<$(top_srcdir)/doc/bison.help >$@.tmp
|
||||
<$(top_srcdir)/%D%/bison.help >$@.tmp
|
||||
$(AM_V_at)diff -u $@~ $@.tmp || true
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||
@@ -57,34 +57,34 @@ MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||
|
||||
# Fix Info's @code in @deftype
|
||||
# https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html
|
||||
all: $(srcdir)/$(doc_bison).info.bak
|
||||
$(srcdir)/$(doc_bison).info.bak: $(srcdir)/$(doc_bison).info
|
||||
all: $(srcdir)/$(%C%_bison).info.bak
|
||||
$(srcdir)/$(%C%_bison).info.bak: $(srcdir)/$(%C%_bison).info
|
||||
$(AM_V_GEN) $(PERL) -pi.bak -0777 \
|
||||
-e 's{(^ --.*\n(?: {10}.*\n)*)}' \
|
||||
-e '{' \
|
||||
-e ' $$def = $$1;' \
|
||||
-e ' $$def =~ s/‘|’//g;' \
|
||||
-e ' $$def;' \
|
||||
-e '}gem;' $(srcdir)/$(doc_bison).info
|
||||
-e '}gem;' $(srcdir)/$(%C%_bison).info
|
||||
@ touch $@
|
||||
EXTRA_DIST += $(srcdir)/$(doc_bison).info.bak
|
||||
MAINTAINERCLEANFILES += $(srcdir)/$(doc_bison).info.bak
|
||||
EXTRA_DIST += $(srcdir)/$(%C%_bison).info.bak
|
||||
MAINTAINERCLEANFILES += $(srcdir)/$(%C%_bison).info.bak
|
||||
|
||||
|
||||
## ---------- ##
|
||||
## Ref card. ##
|
||||
## ---------- ##
|
||||
|
||||
EXTRA_DIST += doc/refcard.tex
|
||||
CLEANFILES += doc/refcard.pdf
|
||||
EXTRA_DIST += %D%/refcard.tex
|
||||
CLEANFILES += %D%/refcard.pdf
|
||||
|
||||
doc/refcard.pdf: doc/refcard.tex
|
||||
$(AM_V_GEN) cd doc && pdftex $(abs_top_srcdir)/doc/refcard.tex
|
||||
%D%/refcard.pdf: %D%/refcard.tex
|
||||
$(AM_V_GEN) cd %D% && pdftex $(abs_top_srcdir)/%D%/refcard.tex
|
||||
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## doc/bison.help. ##
|
||||
## %D%/bison.help. ##
|
||||
## ---------------- ##
|
||||
|
||||
# Some of our targets (cross-options.texi, bison.1) use "bison --help".
|
||||
@@ -106,18 +106,19 @@ doc/refcard.pdf: doc/refcard.tex
|
||||
# compilations of cross-options.texi and bison.1. At the cost of
|
||||
# repeated builds of bison.help.
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
||||
EXTRA_DIST += $(top_srcdir)/%D%/bison.help
|
||||
if ! CROSS_COMPILING
|
||||
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
||||
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
||||
$(AM_V_GEN)LC_ALL=C tests/bison --version >doc/bison.help.tmp
|
||||
MAINTAINERCLEANFILES += $(top_srcdir)/%D%/bison.help
|
||||
$(top_srcdir)/%D%/bison.help: src/bison$(EXEEXT)
|
||||
$(AM_V_GEN)$(MKDIR_P) %D%
|
||||
$(AM_V_at) LC_ALL=C tests/bison --version >%D%/bison.help.tmp
|
||||
$(AM_V_at) LC_ALL=C tests/bison --help | \
|
||||
## Avoid depending on the path to Bison.
|
||||
sed -e 's,^Usage: .*/bison \[OPTION\],Usage: bison [OPTION],g' \
|
||||
## Avoid variations in the output depending on whether we are
|
||||
## on a glibc system.
|
||||
-e '/translation bugs/d' >>doc/bison.help.tmp
|
||||
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
||||
-e '/translation bugs/d' >>%D%/bison.help.tmp
|
||||
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change %D%/bison.help.tmp $@
|
||||
endif ! CROSS_COMPILING
|
||||
|
||||
|
||||
@@ -125,7 +126,7 @@ endif ! CROSS_COMPILING
|
||||
## Man Pages. ##
|
||||
## ----------- ##
|
||||
|
||||
dist_man_MANS = $(top_srcdir)/doc/bison.1
|
||||
dist_man_MANS = $(top_srcdir)/%D%/bison.1
|
||||
|
||||
EXTRA_DIST += $(dist_man_MANS:.1=.x)
|
||||
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
||||
@@ -136,12 +137,12 @@ remove_time_stamp = \
|
||||
|
||||
# Depend on configure to get version number changes.
|
||||
if ! CROSS_COMPILING
|
||||
MAN_DEPS = doc/bison.help doc/bison.x $(top_srcdir)/configure
|
||||
MAN_DEPS = %D%/bison.help %D%/bison.x $(top_srcdir)/configure
|
||||
endif
|
||||
|
||||
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
||||
$(top_srcdir)/%D%/bison.1: $(MAN_DEPS)
|
||||
$(AM_V_GEN)$(HELP2MAN) \
|
||||
--include=$(top_srcdir)/doc/bison.x \
|
||||
--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 \
|
||||
@@ -152,7 +153,7 @@ $(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
||||
$(AM_V_at)rm -f $@*.tmp
|
||||
|
||||
if ENABLE_YACC
|
||||
nodist_man_MANS = doc/yacc.1
|
||||
nodist_man_MANS = %D%/yacc.1
|
||||
endif
|
||||
|
||||
## ----------------------------- ##
|
||||
@@ -161,8 +162,8 @@ endif
|
||||
|
||||
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||
FIGS_GV = \
|
||||
doc/figs/example.gv \
|
||||
doc/figs/example-reduce.gv doc/figs/example-shift.gv
|
||||
%D%/figs/example.gv \
|
||||
%D%/figs/example-reduce.gv %D%/figs/example-shift.gv
|
||||
EXTRA_DIST += \
|
||||
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
|
||||
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||
@@ -193,8 +194,8 @@ DOXYGEN = doxygen
|
||||
|
||||
doc: html
|
||||
|
||||
html-local: doc/Doxyfile
|
||||
$(AM_V_GEN) $(DOXYGEN) doc/Doxyfile
|
||||
html-local: %D%/Doxyfile
|
||||
$(AM_V_GEN) $(DOXYGEN) %D%/Doxyfile
|
||||
|
||||
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
||||
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
||||
@@ -202,11 +203,11 @@ edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
||||
-e 's,@top_builddir\@,$(top_builddir),g' \
|
||||
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
||||
|
||||
EXTRA_DIST += doc/Doxyfile.in
|
||||
CLEANFILES += doc/Doxyfile
|
||||
EXTRA_DIST += %D%/Doxyfile.in
|
||||
CLEANFILES += %D%/Doxyfile
|
||||
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
||||
# configure, because the former is way faster than the latter.
|
||||
doc/Doxyfile: $(top_srcdir)/doc/Doxyfile.in
|
||||
$(AM_V_GEN) $(edit) $(top_srcdir)/doc/Doxyfile.in >doc/Doxyfile
|
||||
%D%/Doxyfile: $(top_srcdir)/%D%/Doxyfile.in
|
||||
$(AM_V_GEN) $(edit) $(top_srcdir)/%D%/Doxyfile.in >%D%/Doxyfile
|
||||
|
||||
CLEANDIRS += doc/html
|
||||
CLEANDIRS += %D%/html
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
\def\finalout{\overfullrule=0pt}
|
||||
%\finalout
|
||||
|
||||
% Copyright (c) 1998, 2001, 2009-2015, 2018-2019 Free Software
|
||||
% Copyright (c) 1998, 2001, 2009--2015, 2018--2020 Free Software
|
||||
% Foundation, Inc.
|
||||
%
|
||||
% This file is part of Bison.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ straightforward use of _build/src/bison would.)
|
||||
|
||||
--
|
||||
|
||||
Copyright (C) 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2009-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
+249
-174
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2006, 2008-2015, 2018-2019 Free Software Foundation,
|
||||
## Copyright (C) 2006, 2008-2015, 2018-2020 Free Software Foundation,
|
||||
## Inc.
|
||||
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -8,7 +8,7 @@ afterwards.
|
||||
## simple.yy - Simple example in C++14
|
||||
A very simple example in C++, based on variants and symbol constructors.
|
||||
Variants allow to use any C++ type as semantic value type, and symbol
|
||||
constructors ensure consistency between declared token type and effective
|
||||
constructors ensure consistency between declared token kind and effective
|
||||
semantic value.
|
||||
|
||||
Run as `./simple`.
|
||||
@@ -46,7 +46,7 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
@@ -55,5 +55,5 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy ispell american
|
||||
LocalWords: mfcalc calc parsers yy ispell american
|
||||
--->
|
||||
|
||||
@@ -36,22 +36,14 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
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/>.
|
||||
|
||||
# LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||
LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||
--->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2005-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2005-2015, 2018-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
|
||||
@@ -44,11 +44,18 @@ EOF
|
||||
run 0 9
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
1 +
|
||||
EOF
|
||||
run 1 'err: -:2.1: syntax error, unexpected end of file, expecting ( or identifier or number'
|
||||
|
||||
|
||||
# LAC finds many more tokens.
|
||||
cat >input <<EOF
|
||||
a := 1
|
||||
d := a + b * c
|
||||
EOF
|
||||
run 1 'err: -:3.1: syntax error, unexpected end of file, expecting ( or identifier or number'
|
||||
run 1 'err: -:3.1: syntax error, unexpected end of file'
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2019 Free Software
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2020 Free Software
|
||||
## Foundation, Inc.
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2018-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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2015, 2018-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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2015, 2018-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
|
||||
|
||||
+33
-5
@@ -28,7 +28,8 @@ 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, redux. This time using a scanner generated by Flex.
|
||||
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.
|
||||
@@ -37,6 +38,29 @@ 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
|
||||
All the previous examples are so called "pull parsers": the user invokes the
|
||||
parser once, which repeatedly calls the scanner until the input is drained.
|
||||
|
||||
This example demonstrates the "push parsers": the user calls the scanner to
|
||||
fetch the next token, passes it to the parser, and repeats the operation
|
||||
until the input is drained.
|
||||
|
||||
This example is a straightforward conversion of the 'calc' example to the
|
||||
push-parser model.
|
||||
|
||||
## bistromathic - all the bells and whistles
|
||||
This example demonstrates best practices when using Bison.
|
||||
- Its hand-written scanner tracks locations.
|
||||
- Its interface is pure.
|
||||
- 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 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.
|
||||
|
||||
<!---
|
||||
|
||||
@@ -45,7 +69,9 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
@@ -54,6 +80,8 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy rpcalc lexcalc redux reccalc ispell
|
||||
# LocalWords: reentrant tokenized american postfix
|
||||
--->
|
||||
LocalWords: mfcalc calc parsers yy rpcalc lexcalc redux reccalc ispell
|
||||
LocalWords: reentrant tokenized american postfix pushcalc bistromathic
|
||||
LocalWords: lookahead
|
||||
|
||||
-->
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BASE = bistromathic
|
||||
BISON = bison
|
||||
FLEX = flex
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
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 $@ $^
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type bistromathic expressions. Quit with ctrl-d."
|
||||
./$<
|
||||
|
||||
html: $(BASE).html
|
||||
%.html: %.xml
|
||||
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||
|
||||
CLEANFILES = \
|
||||
$(BASE) *.o \
|
||||
parse.[ch] parse.output parse.xml parse.html parse.gv \
|
||||
scan.c
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
@@ -0,0 +1,34 @@
|
||||
# bistromathic - all the bells and whistles
|
||||
This example demonstrates best practices when using Bison.
|
||||
- Its hand-written scanner tracks locations.
|
||||
- Its interface is pure.
|
||||
- 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 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.
|
||||
|
||||
<!---
|
||||
Local Variables:
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
LocalWords: bistromathic yyexpected lookahead ispell american
|
||||
LocalWords: MERCHANTABILITY
|
||||
|
||||
--->
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
#! /bin/sh
|
||||
|
||||
# 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/>.
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
EOF
|
||||
run 0 '> 1+2*3
|
||||
7
|
||||
> '
|
||||
|
||||
cat >input <<EOF
|
||||
(1+2) * 3
|
||||
EOF
|
||||
run 0 '> (1+2) * 3
|
||||
9
|
||||
> '
|
||||
run -noerr 0 '> (1+2) * 3
|
||||
9
|
||||
> ' -p
|
||||
|
||||
cat >input <<EOF
|
||||
a = 256
|
||||
sqrt (a)
|
||||
EOF
|
||||
run 0 '> a = 256
|
||||
256
|
||||
> sqrt (a)
|
||||
16
|
||||
> '
|
||||
|
||||
cat >input <<EOF
|
||||
a = .16
|
||||
b = 10 ^ 2
|
||||
sqrt (a * b)
|
||||
EOF
|
||||
run 0 '> a = .16
|
||||
0.16
|
||||
> b = 10 ^ 2
|
||||
100
|
||||
> sqrt (a * b)
|
||||
4
|
||||
> '
|
||||
|
||||
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 *'
|
||||
|
||||
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'
|
||||
|
||||
cat >input <<EOF
|
||||
1 / 0
|
||||
EOF
|
||||
run 0 '> 1 / 0
|
||||
> err: 1.1-5: error: division by zero'
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Completion. ##
|
||||
## ------------ ##
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
# 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
|
||||
> (1+
|
||||
> err: 1.4: syntax error: expected - or ( or double precision 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'
|
||||
|
||||
# Check the completion at the very beginning.
|
||||
sed -e 's/\\t/ /g' >input <<EOF
|
||||
e\t\t
|
||||
EOF
|
||||
run 0 '> e
|
||||
end of file exit exp ''
|
||||
> e
|
||||
0
|
||||
> err: '
|
||||
@@ -0,0 +1,34 @@
|
||||
## 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/>.
|
||||
|
||||
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
|
||||
|
||||
dist_bistromathic_DATA = %D%/parse.y %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/parse.[ch] %D%/parse.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
@@ -0,0 +1,486 @@
|
||||
%require "3.6"
|
||||
|
||||
%code top {
|
||||
#include <ctype.h> // isdigit
|
||||
#include <math.h> // cos, sin, etc.
|
||||
#include <stddef.h> // ptrdiff_t
|
||||
#include <stdio.h> // printf
|
||||
#include <stdlib.h> // calloc.
|
||||
#include <string.h> // strcmp
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
}
|
||||
|
||||
%code requires {
|
||||
// Function type.
|
||||
typedef double (func_t) (double);
|
||||
|
||||
// Data type for links in the chain of symbols.
|
||||
typedef struct symrec symrec;
|
||||
struct symrec
|
||||
{
|
||||
char *name; // name of symbol
|
||||
int type; // type of symbol: either VAR or FUN
|
||||
union
|
||||
{
|
||||
double var; // value of a VAR
|
||||
func_t *fun; // value of a FUN
|
||||
} value;
|
||||
symrec *next; // link field
|
||||
};
|
||||
|
||||
symrec *putsym (char const *name, int sym_type);
|
||||
symrec *getsym (char const *name);
|
||||
}
|
||||
|
||||
%code provides {
|
||||
int yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc);
|
||||
void yyerror (YYLTYPE *yylloc, char const *msg);
|
||||
}
|
||||
|
||||
%code {
|
||||
#define N_
|
||||
#define _
|
||||
|
||||
// Whether to quit.
|
||||
int done = 0;
|
||||
}
|
||||
|
||||
// Don't share global variables between the scanner and the parser.
|
||||
%define api.pure full
|
||||
|
||||
// Generate a push parser.
|
||||
%define api.push-pull push
|
||||
|
||||
// To avoid name clashes (e.g., with C's EOF) prefix token definitions
|
||||
// with TOK_ (e.g., TOK_EOF).
|
||||
%define api.token.prefix {TOK_}
|
||||
|
||||
// Customized syntax error messages (see yyreport_syntax_error).
|
||||
%define parse.error custom
|
||||
|
||||
// with locations.
|
||||
%locations
|
||||
|
||||
// and accurate list of expected tokens.
|
||||
%define parse.lac full
|
||||
|
||||
// Generate the parser description file (calc.output).
|
||||
%verbose
|
||||
|
||||
// Generate YYSTYPE from the types assigned to symbols.
|
||||
%define api.value.type union
|
||||
%token
|
||||
PLUS "+"
|
||||
MINUS "-"
|
||||
STAR "*"
|
||||
SLASH "/"
|
||||
CARET "^"
|
||||
LPAREN "("
|
||||
RPAREN ")"
|
||||
EQUAL "="
|
||||
EXIT "exit"
|
||||
<double>
|
||||
NUM _("double precision number")
|
||||
<symrec*>
|
||||
FUN _("function")
|
||||
VAR _("variable")
|
||||
|
||||
%nterm <double> exp
|
||||
|
||||
// Enable run-time traces (yydebug).
|
||||
%define parse.trace
|
||||
|
||||
// Formatting semantic values in debug traces.
|
||||
%printer { fprintf (yyo, "%s", $$->name); } VAR;
|
||||
%printer { fprintf (yyo, "%s()", $$->name); } FUN;
|
||||
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||
|
||||
|
||||
// Precedence (from lowest to highest) and associativity.
|
||||
%precedence "="
|
||||
%left "+" "-"
|
||||
%left "*" "/"
|
||||
%precedence NEG // negation--unary minus
|
||||
%right "^" // exponentiation
|
||||
|
||||
%% // The grammar follows.
|
||||
input:
|
||||
%empty
|
||||
| exp { printf ("%.10g\n", $exp); }
|
||||
| "exit" { done = 1; }
|
||||
;
|
||||
|
||||
exp:
|
||||
NUM
|
||||
| VAR { $$ = $VAR->value.var; }
|
||||
| VAR "=" exp { $$ = $3; $VAR->value.var = $3; }
|
||||
| FUN "(" exp ")" { $$ = $FUN->value.fun ($3); }
|
||||
| exp[l] "+" exp[r] { $$ = $l + $r; }
|
||||
| exp[l] "-" exp[r] { $$ = $l - $r; }
|
||||
| exp[l] "*" exp[r] { $$ = $l * $r; }
|
||||
| exp[l] "/" exp[r]
|
||||
{
|
||||
if ($r == 0)
|
||||
{
|
||||
yyerror (&@$, "error: division by zero");
|
||||
YYERROR;
|
||||
}
|
||||
else
|
||||
$$ = $l / $r;
|
||||
}
|
||||
| "-" exp %prec NEG { $$ = -$2; }
|
||||
| exp[l] "^" exp[r] { $$ = pow ($l, $r); }
|
||||
| "(" exp ")" { $$ = $2; }
|
||||
;
|
||||
|
||||
// End of grammar.
|
||||
%%
|
||||
|
||||
/*------------.
|
||||
| Functions. |
|
||||
`------------*/
|
||||
|
||||
struct init
|
||||
{
|
||||
char const *name;
|
||||
func_t *fun;
|
||||
};
|
||||
|
||||
static struct init const funs[] =
|
||||
{
|
||||
{ "atan", atan },
|
||||
{ "cos", cos },
|
||||
{ "exp", exp },
|
||||
{ "ln", log },
|
||||
{ "sin", sin },
|
||||
{ "sqrt", sqrt },
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
// The symbol table: a chain of 'struct symrec'.
|
||||
static symrec *sym_table;
|
||||
|
||||
// Put functions in table.
|
||||
static void
|
||||
init_table (void)
|
||||
{
|
||||
for (int i = 0; funs[i].name; i++)
|
||||
{
|
||||
symrec *ptr = putsym (funs[i].name, TOK_FUN);
|
||||
ptr->value.fun = funs[i].fun;
|
||||
}
|
||||
}
|
||||
|
||||
symrec *
|
||||
putsym (char const *name, int sym_type)
|
||||
{
|
||||
symrec *res = (symrec *) malloc (sizeof (symrec));
|
||||
res->name = strdup (name);
|
||||
res->type = sym_type;
|
||||
res->value.var = 0; // Set value to 0 even if fun.
|
||||
res->next = sym_table;
|
||||
sym_table = res;
|
||||
return res;
|
||||
}
|
||||
|
||||
symrec *
|
||||
getsym (char const *name)
|
||||
{
|
||||
for (symrec *p = sym_table; p; p = p->next)
|
||||
if (strcmp (p->name, name) == 0)
|
||||
return p;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// How many symbols are registered.
|
||||
int
|
||||
symbol_count (void)
|
||||
{
|
||||
int res = 0;
|
||||
for (symrec *p = sym_table; p; p = p->next)
|
||||
++res;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*----------.
|
||||
| Scanner. |
|
||||
`----------*/
|
||||
|
||||
int
|
||||
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
{
|
||||
int c;
|
||||
|
||||
// Ignore white space, get first nonwhite character.
|
||||
do {
|
||||
// Move the first position onto the last.
|
||||
yylloc->first_line = yylloc->last_line;
|
||||
yylloc->first_column = yylloc->last_column;
|
||||
|
||||
yylloc->last_column += 1;
|
||||
c = *((*line)++);
|
||||
} while (c == ' ' || c == '\t');
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '+': return TOK_PLUS;
|
||||
case '-': return TOK_MINUS;
|
||||
case '*': return TOK_STAR;
|
||||
case '/': return TOK_SLASH;
|
||||
case '^': return TOK_CARET;
|
||||
case '=': return TOK_EQUAL;
|
||||
case '(': return TOK_LPAREN;
|
||||
case ')': return TOK_RPAREN;
|
||||
|
||||
case '\0': return TOK_YYEOF;
|
||||
|
||||
// Numbers.
|
||||
case '.':
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
{
|
||||
int nchars = 0;
|
||||
sscanf (*line - 1, "%lf%n", &yylval->TOK_NUM, &nchars);
|
||||
*line += nchars - 1;
|
||||
yylloc->last_column += nchars - 1;
|
||||
return TOK_NUM;
|
||||
}
|
||||
|
||||
// Identifiers.
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||
case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||
case 'z':
|
||||
{
|
||||
int nchars = 0;
|
||||
char buf[100];
|
||||
sscanf (*line - 1, "%99[a-z]%n", buf, &nchars);
|
||||
*line += nchars - 1;
|
||||
yylloc->last_column += nchars - 1;
|
||||
if (strcmp (buf, "exit") == 0)
|
||||
return TOK_EXIT;
|
||||
else
|
||||
{
|
||||
symrec *s = getsym (buf);
|
||||
if (!s)
|
||||
s = putsym (buf, TOK_VAR);
|
||||
yylval->TOK_VAR = s;
|
||||
return s->type;
|
||||
}
|
||||
}
|
||||
|
||||
// Stray characters.
|
||||
default:
|
||||
yyerror (yylloc, "error: invalid character");
|
||||
return yylex (line, yylval, yylloc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------.
|
||||
| Parser. |
|
||||
`---------*/
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
// Called by yyparse on error.
|
||||
void yyerror (YYLTYPE *loc, char const *msg)
|
||||
{
|
||||
YY_LOCATION_PRINT (stderr, *loc);
|
||||
fprintf (stderr, ": %s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
/*-----------.
|
||||
| Readline. |
|
||||
`-----------*/
|
||||
|
||||
// Parse (and execute) this line.
|
||||
int process_line (YYLTYPE *lloc, const char *line)
|
||||
{
|
||||
yypstate *ps = yypstate_new ();
|
||||
int status = 0;
|
||||
do {
|
||||
YYSTYPE lval;
|
||||
status = yypush_parse (ps, yylex (&line, &lval, lloc), &lval, lloc);
|
||||
} while (status == YYPUSH_MORE);
|
||||
yypstate_delete (ps);
|
||||
lloc->last_line++;
|
||||
lloc->last_column = 1;
|
||||
return status;
|
||||
}
|
||||
|
||||
// Get the list of possible tokens after INPUT was read.
|
||||
int
|
||||
expected_tokens (const char *input,
|
||||
int *tokens, int ntokens)
|
||||
{
|
||||
YYDPRINTF ((stderr, "expected_tokens (\"%s\")", input));
|
||||
|
||||
// Parse the current state of the line.
|
||||
yypstate *ps = yypstate_new ();
|
||||
int status = 0;
|
||||
do {
|
||||
YYLTYPE lloc;
|
||||
YYSTYPE lval;
|
||||
int token = yylex (&input, &lval, &lloc);
|
||||
// Don't let the parse know when we reach the end of input.
|
||||
if (!token)
|
||||
break;
|
||||
status = yypush_parse (ps, token, &lval, &lloc);
|
||||
} while (status == YYPUSH_MORE);
|
||||
|
||||
// Then query for the accepted tokens at this point.
|
||||
int res = yypstate_expected_tokens (ps, tokens, ntokens);
|
||||
yypstate_delete (ps);
|
||||
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. */
|
||||
char **
|
||||
completion (const char *text, int start, int end)
|
||||
{
|
||||
YYDPRINTF ((stderr, "completion (\"%.*s[%.*s]%s\")\n",
|
||||
start, rl_line_buffer,
|
||||
end - start, rl_line_buffer + start,
|
||||
rl_line_buffer + end));
|
||||
|
||||
// Get list of token numbers.
|
||||
int tokens[YYNTOKENS];
|
||||
char *line = strndup (rl_line_buffer, start);
|
||||
int ntokens = expected_tokens (line, tokens, YYNTOKENS);
|
||||
free (line);
|
||||
|
||||
// Build MATCHES, the list of possible completions.
|
||||
const int len = strlen (text);
|
||||
// Need initial prefix and final NULL.
|
||||
char **matches = calloc (ntokens + symbol_count () + 2, sizeof *matches);
|
||||
int match = 1;
|
||||
for (int i = 0; i < ntokens; ++i)
|
||||
switch (tokens[i])
|
||||
{
|
||||
case YYSYMBOL_FUN:
|
||||
for (symrec *s = sym_table; s; s = s->next)
|
||||
if (s->type == TOK_FUN && strncmp (text, s->name, len) == 0)
|
||||
matches[match++] = strdup (s->name);
|
||||
break;
|
||||
case YYSYMBOL_VAR:
|
||||
for (symrec *s = sym_table; s; s = s->next)
|
||||
if (s->type == TOK_VAR && strncmp (text, s->name, len) == 0)
|
||||
matches[match++] = strdup (s->name);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
const char* token = yysymbol_name (tokens[i]);
|
||||
if (strncmp (text, token, len) == 0)
|
||||
matches[match++] = strdup (token);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the longest common prefix, and install it in matches[0], as
|
||||
// required by readline.
|
||||
if (match == 1)
|
||||
matches[0] = strdup (text);
|
||||
else
|
||||
{
|
||||
int lcplen = strlen (matches[1]);
|
||||
for (int i = 2; i < match && lcplen; ++i)
|
||||
for (int j = 0; j < lcplen; ++j)
|
||||
if (matches[1][j] != matches[i][j])
|
||||
lcplen = j;
|
||||
matches[0] = strndup (matches[1], lcplen);
|
||||
}
|
||||
|
||||
if (yydebug)
|
||||
{
|
||||
fprintf (stderr, "completion (\"%.*s[%.*s]%s\") = ",
|
||||
start, rl_line_buffer,
|
||||
end - start, rl_line_buffer + start,
|
||||
rl_line_buffer + end);
|
||||
for (int i = 1; matches[i]; ++i)
|
||||
fprintf (stderr, "%s%s",
|
||||
i == 1 ? "{" : ", ",
|
||||
matches[i]);
|
||||
fprintf (stderr, "}\n");
|
||||
}
|
||||
|
||||
// Don't fall back to proposing file names.
|
||||
rl_attempted_completion_over = 1;
|
||||
return matches;
|
||||
}
|
||||
|
||||
void init_readline (void)
|
||||
{
|
||||
// Allow conditional parsing of the ~/.inputrc file.
|
||||
rl_readline_name = "bistromathic";
|
||||
|
||||
// Tell the completer that we want a crack first.
|
||||
rl_attempted_completion_function = completion;
|
||||
|
||||
// The basic list of characters that signal a break between words
|
||||
// for the completer routine.
|
||||
rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(+-*/^)";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------.
|
||||
| Main. |
|
||||
`-------*/
|
||||
|
||||
int main (int argc, char const* argv[])
|
||||
{
|
||||
// Enable parse traces on option -p.
|
||||
if (argc == 2 && strcmp (argv[1], "-p") == 0)
|
||||
yydebug = 1;
|
||||
init_table ();
|
||||
init_readline ();
|
||||
YYLTYPE lloc = {1, 1, 1, 1};
|
||||
while (!done)
|
||||
{
|
||||
char *line = readline ("> ");
|
||||
if (!line)
|
||||
return 0;
|
||||
if (*line)
|
||||
add_history (line);
|
||||
process_line (&lloc, line);
|
||||
free (line);
|
||||
}
|
||||
}
|
||||
@@ -9,20 +9,15 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
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.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
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/>.
|
||||
--->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2019-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
|
||||
@@ -34,4 +34,10 @@ cat >input <<EOF
|
||||
(1+2) * 3
|
||||
EOF
|
||||
run 0 9
|
||||
# Check the traces.
|
||||
run -noerr 0 9 -p
|
||||
|
||||
cat >input <<EOF
|
||||
1++2
|
||||
EOF
|
||||
run 0 "err: syntax error, unexpected '+', expecting number or '('"
|
||||
|
||||
@@ -8,16 +8,22 @@
|
||||
}
|
||||
|
||||
%define api.header.include {"calc.h"}
|
||||
%define api.value.type union /* Generate YYSTYPE from these types: */
|
||||
|
||||
/* Generate YYSTYPE from the types used in %token and %type. */
|
||||
%define api.value.type union
|
||||
%token <double> NUM "number"
|
||||
%type <double> expr term fact
|
||||
|
||||
/* Generate the parser description file. */
|
||||
/* Generate the parser description file (calc.output). */
|
||||
%verbose
|
||||
|
||||
/* Nice error messages with details. */
|
||||
%define parse.error detailed
|
||||
|
||||
/* Enable run-time traces (yydebug). */
|
||||
%define parse.trace
|
||||
|
||||
/* Formatting semantic values. */
|
||||
/* Formatting semantic values in debug traces. */
|
||||
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||
|
||||
%% /* The grammar follows. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2019-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
|
||||
|
||||
@@ -3,26 +3,22 @@
|
||||
This directory contains lexcalc, the traditional example of using Flex and
|
||||
Bison to build a simple calculator.
|
||||
|
||||
It features detailed syntax errors with locations.
|
||||
|
||||
<!---
|
||||
Local Variables:
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
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/>.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
--->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
@@ -29,4 +29,9 @@ run -noerr 0 9 -p
|
||||
cat >input <<EOF
|
||||
(1+2) *
|
||||
EOF
|
||||
run 1 'err: syntax error, unexpected end-of-line, expecting ( or number'
|
||||
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number'
|
||||
|
||||
cat >input <<EOF
|
||||
1 / (2 - 2)
|
||||
EOF
|
||||
run 1 'err: 1.1-11: error: division by zero'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2018-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
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
{
|
||||
// Tell Flex the expected prototype of yylex.
|
||||
#define YY_DECL \
|
||||
enum yytokentype yylex (YYSTYPE* yylval, int *nerrs)
|
||||
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc, int *nerrs)
|
||||
YY_DECL;
|
||||
|
||||
void yyerror (int *nerrs, const char *msg);
|
||||
void yyerror (YYLTYPE *loc, int *nerrs, const char *msg);
|
||||
}
|
||||
|
||||
// Emitted on top of the implementation file.
|
||||
@@ -19,12 +19,27 @@
|
||||
#include <stdlib.h> // getenv.
|
||||
}
|
||||
|
||||
// Don't share global variables between the scanner and the parser.
|
||||
%define api.pure full
|
||||
|
||||
// To avoid name clashes (e.g., with C's EOF) prefix token definitions
|
||||
// with TOK_ (e.g., TOK_EOF).
|
||||
%define api.token.prefix {TOK_}
|
||||
|
||||
// %token and %type use genuine types (e.g., "%token <int>"). Let
|
||||
// %bison define YYSTYPE as a union of all these types.
|
||||
%define api.value.type union
|
||||
%define parse.error verbose
|
||||
|
||||
// Generate detailed error messages.
|
||||
%define parse.error detailed
|
||||
|
||||
// with locations.
|
||||
%locations
|
||||
|
||||
// Enable debug traces (see yydebug in main).
|
||||
%define parse.trace
|
||||
// Error count, exchanged between main, yyparse and yylex.
|
||||
|
||||
// Error count, exchanged between main, yyparse and yylex.
|
||||
%param {int *nerrs}
|
||||
|
||||
%token
|
||||
@@ -34,8 +49,7 @@
|
||||
SLASH "/"
|
||||
LPAREN "("
|
||||
RPAREN ")"
|
||||
EOL "end-of-line"
|
||||
EOF 0 "end-of-file"
|
||||
EOL "end of line"
|
||||
;
|
||||
|
||||
%token <int> NUM "number"
|
||||
@@ -66,7 +80,7 @@ exp:
|
||||
{
|
||||
if ($3 == 0)
|
||||
{
|
||||
yyerror (nerrs, "invalid division by zero");
|
||||
yyerror (&@$, nerrs, "error: division by zero");
|
||||
YYERROR;
|
||||
}
|
||||
else
|
||||
@@ -77,9 +91,11 @@ exp:
|
||||
;
|
||||
%%
|
||||
// Epilogue (C code).
|
||||
void yyerror (int *nerrs, const char *msg)
|
||||
|
||||
void yyerror (YYLTYPE *loc, int *nerrs, const char *msg)
|
||||
{
|
||||
fprintf (stderr, "%s\n", msg);
|
||||
YY_LOCATION_PRINT (stderr, *loc);
|
||||
fprintf (stderr, ": %s\n", msg);
|
||||
++*nerrs;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Prologue (directives). -*- C++ -*- */
|
||||
/* Prologue (directives). -*- C -*- */
|
||||
|
||||
/* Disable Flex features we don't need, to avoid warnings. */
|
||||
%option nodefault noinput nounput noyywrap
|
||||
@@ -9,9 +9,24 @@
|
||||
#include <stdlib.h> /* strtol */
|
||||
|
||||
#include "parse.h"
|
||||
|
||||
// Each time a rule is matched, advance the end cursor/position.
|
||||
#define YY_USER_ACTION \
|
||||
yylloc->last_column += yyleng;
|
||||
|
||||
// Move the first position onto the last.
|
||||
#define LOCATION_STEP() \
|
||||
do { \
|
||||
yylloc->first_line = yylloc->last_line; \
|
||||
yylloc->first_column = yylloc->last_column; \
|
||||
} while (0)
|
||||
%}
|
||||
|
||||
%%
|
||||
%{
|
||||
// Each time yylex is called, move the head position to the end one.
|
||||
LOCATION_STEP ();
|
||||
%}
|
||||
/* Rules. */
|
||||
|
||||
"+" return TOK_PLUS;
|
||||
@@ -27,18 +42,18 @@
|
||||
errno = 0;
|
||||
long n = strtol (yytext, NULL, 10);
|
||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||
yyerror (nerrs, "integer is out of range");
|
||||
yyerror (yylloc, nerrs, "integer is out of range");
|
||||
yylval->TOK_NUM = (int) n;
|
||||
return TOK_NUM;
|
||||
}
|
||||
|
||||
"\n" yylloc->last_line++; yylloc->last_column = 1; return TOK_EOL;
|
||||
|
||||
/* Ignore white spaces. */
|
||||
[ \t]+ continue;
|
||||
[ \t]+ LOCATION_STEP (); continue;
|
||||
|
||||
"\n" return TOK_EOL;
|
||||
. yyerror (yylloc, nerrs, "syntax error, invalid character"); continue;
|
||||
|
||||
. yyerror (nerrs, "syntax error, invalid character");
|
||||
|
||||
<<EOF>> return TOK_EOF;
|
||||
<<EOF>> return TOK_YYEOF;
|
||||
%%
|
||||
/* Epilogue (C code). */
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2018-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
|
||||
@@ -16,8 +16,10 @@
|
||||
cdir = $(docdir)/%D%
|
||||
dist_c_DATA = %D%/README.md
|
||||
|
||||
include %D%/bistromathic/local.mk
|
||||
include %D%/calc/local.mk
|
||||
include %D%/lexcalc/local.mk
|
||||
include %D%/mfcalc/local.mk
|
||||
include %D%/pushcalc/local.mk
|
||||
include %D%/reccalc/local.mk
|
||||
include %D%/rpcalc/local.mk
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2019 Free Software
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2020 Free Software
|
||||
## Foundation, Inc.
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2005-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2005-2015, 2018-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
|
||||
@@ -25,3 +25,15 @@ cat >input <<EOF
|
||||
EOF
|
||||
run 0 9
|
||||
run -noerr 0 9 -p
|
||||
|
||||
cat >input <<EOF
|
||||
a = 256
|
||||
sqrt (a)
|
||||
EOF
|
||||
run 0 '256
|
||||
16'
|
||||
|
||||
cat >input <<EOF
|
||||
16 == 12
|
||||
EOF
|
||||
run 0 'err: syntax error'
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BASE = calc
|
||||
BISON = bison
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
all: $(BASE)
|
||||
|
||||
%.c %.h %.xml %.gv: %.y
|
||||
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
$(BASE): $(BASE).o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||
./$<
|
||||
|
||||
html: $(BASE).html
|
||||
%.html: %.xml
|
||||
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||
|
||||
CLEANFILES = \
|
||||
$(BASE) *.o $(BASE).[ch] $(BASE).output $(BASE).xml $(BASE).html $(BASE).gv
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
@@ -0,0 +1,32 @@
|
||||
# pushcalc - push parser with Bison
|
||||
|
||||
This directory contains pushcalc, the traditional calculator, implemented as
|
||||
a push parser.
|
||||
|
||||
Traditionally Bison is used to create so called "pull parsers": the user
|
||||
invokes the parser once, which repeatedly calls (pulls) the scanner until
|
||||
the input is drained.
|
||||
|
||||
This example demonstrates the "push parsers": the user calls scanner to
|
||||
fetch the next token, passes (pushes) it to the parser, and repeats the
|
||||
operation until the input is drained.
|
||||
|
||||
This example is a straightforward conversion of the 'calc' example to the
|
||||
push-parser model.
|
||||
|
||||
<!---
|
||||
Local Variables:
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
--->
|
||||
@@ -0,0 +1,42 @@
|
||||
#! /bin/sh
|
||||
|
||||
# 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/>.
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
EOF
|
||||
run 0 7
|
||||
|
||||
cat >input <<EOF
|
||||
1 - 2 - 3
|
||||
EOF
|
||||
run 0 -4
|
||||
|
||||
cat >input <<EOF
|
||||
8 / 2 / 2
|
||||
EOF
|
||||
run 0 2
|
||||
|
||||
cat >input <<EOF
|
||||
(1+2) * 3
|
||||
EOF
|
||||
run 0 9
|
||||
run -noerr 0 9 -p
|
||||
|
||||
cat >input <<EOF
|
||||
1++2
|
||||
EOF
|
||||
run 0 "err: syntax error, unexpected '+', expecting number or '('"
|
||||
@@ -0,0 +1,114 @@
|
||||
%code top {
|
||||
#include <ctype.h> /* isdigit. */
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h> /* For printf, etc. */
|
||||
#include <string.h> /* strcmp. */
|
||||
}
|
||||
|
||||
%code {
|
||||
int yylex (YYSTYPE *yylval);
|
||||
void yyerror (char const *);
|
||||
}
|
||||
|
||||
%define api.header.include {"calc.h"}
|
||||
|
||||
/* Generate YYSTYPE from the types used in %token and %type. */
|
||||
%define api.value.type union
|
||||
%token <double> NUM "number"
|
||||
%type <double> expr term fact
|
||||
|
||||
/* Don't share global variables between the scanner and the parser. */
|
||||
%define api.pure full
|
||||
/* Generate a push parser. */
|
||||
%define api.push-pull push
|
||||
|
||||
/* Nice error messages with details. */
|
||||
%define parse.error detailed
|
||||
|
||||
/* Generate the parser description file (calc.output). */
|
||||
%verbose
|
||||
|
||||
/* Enable run-time traces (yydebug). */
|
||||
%define parse.trace
|
||||
|
||||
/* Formatting semantic values in debug traces. */
|
||||
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||
|
||||
%% /* The grammar follows. */
|
||||
input:
|
||||
%empty
|
||||
| input line
|
||||
;
|
||||
|
||||
line:
|
||||
'\n'
|
||||
| expr '\n' { printf ("%.10g\n", $1); }
|
||||
| error '\n' { yyerrok; }
|
||||
;
|
||||
|
||||
expr:
|
||||
expr '+' term { $$ = $1 + $3; }
|
||||
| expr '-' term { $$ = $1 - $3; }
|
||||
| term
|
||||
;
|
||||
|
||||
term:
|
||||
term '*' fact { $$ = $1 * $3; }
|
||||
| term '/' fact { $$ = $1 / $3; }
|
||||
| fact
|
||||
;
|
||||
|
||||
fact:
|
||||
"number"
|
||||
| '(' expr ')' { $$ = $expr; }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
int
|
||||
yylex (YYSTYPE *yylval)
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Ignore white space, get first nonwhite character. */
|
||||
while ((c = getchar ()) == ' ' || c == '\t')
|
||||
continue;
|
||||
|
||||
if (c == EOF)
|
||||
return 0;
|
||||
|
||||
/* Char starts a number => parse the number. */
|
||||
if (c == '.' || isdigit (c))
|
||||
{
|
||||
ungetc (c, stdin);
|
||||
scanf ("%lf", &yylval->NUM);
|
||||
return NUM;
|
||||
}
|
||||
|
||||
/* Any other character is a token by itself. */
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Called by yyparse on error. */
|
||||
void
|
||||
yyerror (char const *s)
|
||||
{
|
||||
fprintf (stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char const* argv[])
|
||||
{
|
||||
/* Enable parse traces on option -p. */
|
||||
for (int i = 1; i < argc; ++i)
|
||||
if (!strcmp (argv[i], "-p"))
|
||||
yydebug = 1;
|
||||
int status;
|
||||
yypstate *ps = yypstate_new ();
|
||||
do {
|
||||
YYSTYPE lval;
|
||||
status = yypush_parse (ps, yylex (&lval), &lval);
|
||||
} while (status == YYPUSH_MORE);
|
||||
yypstate_delete (ps);
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
## 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/>.
|
||||
|
||||
pushcalcdir = $(docdir)/%D%
|
||||
|
||||
## ------ ##
|
||||
## Calc. ##
|
||||
## ------ ##
|
||||
|
||||
check_PROGRAMS += %D%/calc
|
||||
TESTS += %D%/calc.test
|
||||
EXTRA_DIST += %D%/calc.test
|
||||
nodist_%C%_calc_SOURCES = %D%/calc.y
|
||||
%D%/calc.c: $(dependencies)
|
||||
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
|
||||
dist_pushcalc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/calc.[ch] %D%/calc.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
@@ -26,20 +26,13 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
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/>.
|
||||
--->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2019-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
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
// Emitted in the header file, before the definition of YYSTYPE.
|
||||
%code requires
|
||||
{
|
||||
#ifndef YY_TYPEDEF_YY_SCANNER_T
|
||||
# define YY_TYPEDEF_YY_SCANNER_T
|
||||
typedef void* yyscan_t;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Whether to print the intermediate results.
|
||||
@@ -22,7 +26,7 @@
|
||||
// Tell Flex the expected prototype of yylex.
|
||||
// The scanner argument must be named yyscanner.
|
||||
#define YY_DECL \
|
||||
enum yytokentype yylex (YYSTYPE* yylval, yyscan_t yyscanner, result *res)
|
||||
yytoken_kind_t yylex (YYSTYPE* yylval, yyscan_t yyscanner, result *res)
|
||||
YY_DECL;
|
||||
|
||||
void yyerror (yyscan_t scanner, result *res, const char *msg, ...);
|
||||
@@ -132,7 +136,6 @@ exp:
|
||||
|
||||
%%
|
||||
// Epilogue (C code).
|
||||
|
||||
#include "scan.h"
|
||||
|
||||
result
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
@@ -15,6 +15,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/>.
|
||||
|
||||
seq 0 >/dev/null || exit 77
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
EOF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Prologue (directives). -*- C++ -*- */
|
||||
/* Prologue (directives). -*- C -*- */
|
||||
|
||||
/* Disable Flex features we don't need, to avoid warnings. */
|
||||
%option nodefault noinput nounput noyywrap
|
||||
@@ -17,10 +17,14 @@
|
||||
|
||||
%%
|
||||
%{
|
||||
// Number of opened parentheses.
|
||||
int nesting = 0;
|
||||
// A buffer storing the text inside the outer parentheses.
|
||||
char *str = NULL;
|
||||
int size = 0;
|
||||
// Its allocated size.
|
||||
int capacity = 0;
|
||||
// Its used size.
|
||||
int size = 0;
|
||||
#define STR_APPEND() \
|
||||
do { \
|
||||
if (capacity < size + yyleng + 1) \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2019 Free Software
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2020 Free Software
|
||||
## Foundation, Inc.
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2005-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2005-2015, 2018-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
|
||||
|
||||
@@ -15,7 +15,7 @@ fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2018-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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user