mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 18:25:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b590ad0292 | ||
|
|
05e70adf22 | ||
|
|
7efe0b5da3 | ||
|
|
351e3630bb | ||
|
|
4fd1fc70e0 | ||
|
|
e02ce4c7f0 | ||
|
|
7cab285eda | ||
|
|
86efe28222 | ||
|
|
cf1446dc9e | ||
|
|
e93c40b33d | ||
|
|
eff6739124 | ||
|
|
5a0d7802f4 | ||
|
|
f1e0839c9e | ||
|
|
3bf429aed8 | ||
|
|
f8cadc731b | ||
|
|
bd7aebb8b0 | ||
|
|
ca8039e612 | ||
|
|
5d07f4f726 | ||
|
|
e605ad9679 | ||
|
|
50fac71d46 | ||
|
|
a8455b072a | ||
|
|
a9d6e16e0a | ||
|
|
bd0cf11e00 | ||
|
|
c8512e09e7 | ||
|
|
96f503e197 | ||
|
|
9912dd28ca | ||
|
|
22aaad0c45 | ||
|
|
a45ed4ecc1 | ||
|
|
fef272bdf3 | ||
|
|
d1f57a4ae5 | ||
|
|
5d5f12fb0d | ||
|
|
9f6013a0fd | ||
|
|
fad0f9231b | ||
|
|
81df326649 | ||
|
|
01c5b6ab0f | ||
|
|
c45f86d286 | ||
|
|
1664d1c5ed | ||
|
|
71758d854a | ||
|
|
3751d50e70 | ||
|
|
3f5e6905da | ||
|
|
719782e6ba | ||
|
|
ee175dfd00 | ||
|
|
f3110c9b9a | ||
|
|
18743948b5 | ||
|
|
849d91bc02 | ||
|
|
73a822e636 | ||
|
|
5b879c8980 | ||
|
|
8fd5f0d5a5 | ||
|
|
a4dce889a4 | ||
|
|
7c4b40de61 | ||
|
|
f9bba892bd | ||
|
|
facfd9c406 | ||
|
|
0308dfb039 | ||
|
|
9d8fc7fd3e | ||
|
|
b5515215c1 | ||
|
|
ab3dc5415c | ||
|
|
06f3245fa4 | ||
|
|
05d702422a | ||
|
|
121da2cbdb | ||
|
|
7a45fc35bf | ||
|
|
ae1e65a285 | ||
|
|
ba9db64745 | ||
|
|
b4b8666e4a | ||
|
|
0021bc3e28 | ||
|
|
4b0efdeb28 | ||
|
|
73917e9e6f | ||
|
|
ba29791773 | ||
|
|
a7842d1bc0 | ||
|
|
81a9580622 | ||
|
|
85f7c08036 | ||
|
|
098f5084a0 | ||
|
|
07a4b32f4d | ||
|
|
3ead69b1c1 | ||
|
|
42f0b949ec | ||
|
|
e7b709ab0b | ||
|
|
35068fbe66 | ||
|
|
16d34d8036 | ||
|
|
bfbd73f3e0 | ||
|
|
602f8e2a77 | ||
|
|
ace93397c1 | ||
|
|
d2192653db | ||
|
|
83a832618d | ||
|
|
0e0d7d2975 | ||
|
|
5abbc66fe4 | ||
|
|
bf338b7cd2 | ||
|
|
3967e46a2d | ||
|
|
b994c3bf78 | ||
|
|
03a13ce793 | ||
|
|
f5fc21240f | ||
|
|
ebddc0a0d2 | ||
|
|
8359341013 | ||
|
|
c7fe52e514 | ||
|
|
5cdbc97c9d | ||
|
|
9017924783 | ||
|
|
e3fdc37049 | ||
|
|
a99b4f45bb | ||
|
|
ea31f21fd8 | ||
|
|
2b0a9c69df | ||
|
|
c69944ff8b | ||
|
|
01898726e2 | ||
|
|
20a6c3175f | ||
|
|
45ef3d92a1 | ||
|
|
fa386893aa | ||
|
|
dc73dc4fb2 | ||
|
|
677a91aef2 | ||
|
|
dab2ee0f74 | ||
|
|
7f49dc7d1d | ||
|
|
5f26baa748 | ||
|
|
80752c0dc1 | ||
|
|
f8c9c7acae | ||
|
|
7d324cf00c | ||
|
|
98364385a6 | ||
|
|
b5197d5770 | ||
|
|
e9b69f8655 | ||
|
|
099339df0a | ||
|
|
8e4ca87228 | ||
|
|
72e2a94d5f | ||
|
|
059cb26ca2 | ||
|
|
c3d32f4a9a | ||
|
|
74484f42f3 | ||
|
|
6565b9a566 | ||
|
|
b8351d06f1 | ||
|
|
67521bc0e8 | ||
|
|
4fb70e4dd3 | ||
|
|
3ac6af879d | ||
|
|
f3d09f3108 | ||
|
|
1cb6c26b4f | ||
|
|
c164fc0822 | ||
|
|
25347d885c | ||
|
|
fa264a0687 | ||
|
|
5fe636c7ee | ||
|
|
50b8d4ba5a | ||
|
|
57d69b04b2 | ||
|
|
3e6a075f7f | ||
|
|
29b1da4e18 | ||
|
|
667588ee8a | ||
|
|
b122a71c83 | ||
|
|
1a0b3bf83b | ||
|
|
53bde230c6 | ||
|
|
fd3c17995e | ||
|
|
d13a7fdb0a | ||
|
|
a61a84ec6a | ||
|
|
394c1aa6f2 | ||
|
|
5281d09af7 | ||
|
|
0299b699bb | ||
|
|
cff8d06e51 | ||
|
|
45372aed4e | ||
|
|
b89b6517f2 | ||
|
|
cd45c269e2 | ||
|
|
44cad07704 | ||
|
|
f612071298 | ||
|
|
a7694cedf9 | ||
|
|
2fead9abdb | ||
|
|
d573ef0d69 | ||
|
|
6cdd3287dd | ||
|
|
2d60a624c9 | ||
|
|
5d4bd04588 | ||
|
|
47f92cb354 | ||
|
|
715fdcffbf | ||
|
|
153df66692 | ||
|
|
ce9d542a78 | ||
|
|
c66e591fa5 | ||
|
|
2495c49077 | ||
|
|
6c3b482891 | ||
|
|
5ec892c480 | ||
|
|
9188385b55 | ||
|
|
1bf3e2860b | ||
|
|
7d8d1c3f92 | ||
|
|
694c6234f9 | ||
|
|
13b70e2218 | ||
|
|
fa55bfa71f | ||
|
|
93d2986bba | ||
|
|
75964cf0df | ||
|
|
3c2b71cde6 | ||
|
|
37c6dbb8ad | ||
|
|
0883e6591f | ||
|
|
a538d0d8aa | ||
|
|
2645ee3519 | ||
|
|
ad15cd977a | ||
|
|
4e97614f5a | ||
|
|
82c36f0f0b | ||
|
|
ee1bcce627 | ||
|
|
8347aabe14 | ||
|
|
25bdc41ee0 | ||
|
|
57e3f5a80c | ||
|
|
8c3eae0d44 | ||
|
|
6fe281271c | ||
|
|
23a37cc1c5 | ||
|
|
eb1b04fa00 | ||
|
|
cdc252ace9 | ||
|
|
95b55cc5c4 | ||
|
|
e96d567a27 | ||
|
|
b62b690ccf | ||
|
|
7d687eaee3 | ||
|
|
a2ab59fa18 | ||
|
|
777226dd9f | ||
|
|
95e1b48e20 | ||
|
|
bb077f38f7 | ||
|
|
a6316700e8 | ||
|
|
795f7e32cc | ||
|
|
c721eb9e28 | ||
|
|
3aed6a21f5 | ||
|
|
b6d3f107fe | ||
|
|
704a04512c | ||
|
|
2586398fcc | ||
|
|
d9b37a62ff | ||
|
|
3d2bf2a8e3 | ||
|
|
a3ced22c06 | ||
|
|
a2b6281b39 | ||
|
|
cf4600ca45 | ||
|
|
8d64416e8c | ||
|
|
26859f6d61 | ||
|
|
f84a8e96d1 | ||
|
|
4247df921b | ||
|
|
9bdff3d271 | ||
|
|
d03b1a7e8c | ||
|
|
973c456f63 | ||
|
|
2d07940325 | ||
|
|
13cdb2d397 | ||
|
|
b2a3a302e6 | ||
|
|
8c4a1163ee | ||
|
|
cf4e3eecef | ||
|
|
2eaa7ed946 | ||
|
|
e198269f40 | ||
|
|
6181f05630 | ||
|
|
a4ba0d21a1 | ||
|
|
5d0764d23b | ||
|
|
41ded58286 | ||
|
|
5649888686 | ||
|
|
e40a3eed34 | ||
|
|
6537a59c98 | ||
|
|
154bc7ddac | ||
|
|
a990213582 | ||
|
|
9dfd46a5d5 | ||
|
|
984d8cc72c | ||
|
|
896b2f75c5 | ||
|
|
3ce67fa673 | ||
|
|
889dea0275 | ||
|
|
ab3ec56ffe | ||
|
|
c8da23c372 | ||
|
|
69720f1231 | ||
|
|
100f8696c7 | ||
|
|
8c6b06df1f | ||
|
|
6d9aafc5ad | ||
|
|
878dc0a172 | ||
|
|
a874011e37 | ||
|
|
3eb9042a30 | ||
|
|
aa5de5728c | ||
|
|
21eeee46e9 | ||
|
|
db025a6fb7 | ||
|
|
ca822faeec | ||
|
|
ae915ab8e7 | ||
|
|
27630864e7 | ||
|
|
857be0e10f | ||
|
|
bbfa419b89 | ||
|
|
b7613423ce | ||
|
|
49dc1b5bf1 | ||
|
|
f475105c2f | ||
|
|
a60a9e3071 | ||
|
|
c53d599df4 | ||
|
|
9458250968 | ||
|
|
8cbc235723 | ||
|
|
9a377eb0a8 | ||
|
|
09aa05d89c | ||
|
|
2b7dca1c86 | ||
|
|
3367d8dd5c | ||
|
|
8da0cef821 | ||
|
|
fb1e27cf47 | ||
|
|
65fa634cdc | ||
|
|
7c64b1f4ff | ||
|
|
9611baf855 | ||
|
|
2559f4cec5 | ||
|
|
d4fbda2a94 | ||
|
|
84dcd7991b | ||
|
|
50910389c9 | ||
|
|
6cc69f4d14 | ||
|
|
46532a9d3b | ||
|
|
5603f0bdf2 | ||
|
|
ce99bc67b8 | ||
|
|
9ff76cdda8 | ||
|
|
84744e5f63 | ||
|
|
09bc1b99c9 | ||
|
|
f19ecae3b2 | ||
|
|
e3257f88e2 | ||
|
|
b4ea71a8b2 | ||
|
|
c85418ba07 | ||
|
|
0e38617ad7 | ||
|
|
493182f70e | ||
|
|
ed2c9a69d3 | ||
|
|
333bcd2ee3 | ||
|
|
04705b9370 | ||
|
|
79331541ae | ||
|
|
d6fb1813ee | ||
|
|
7194099027 | ||
|
|
171b6bacb9 | ||
|
|
e1c33f04d1 | ||
|
|
3c22b260b1 | ||
|
|
e5000890a4 | ||
|
|
ea0db44fed | ||
|
|
ec99c418a7 | ||
|
|
a807cfa6eb | ||
|
|
41c43ef3d7 | ||
|
|
1dac131ec4 | ||
|
|
9268d9aceb | ||
|
|
bb5603c2f0 | ||
|
|
2c29a70819 | ||
|
|
cf31256f9a | ||
|
|
7132650bba | ||
|
|
d908fb3f18 | ||
|
|
d023679818 | ||
|
|
d87c8ac79a | ||
|
|
a7e46f6e41 | ||
|
|
2d7e743802 | ||
|
|
50fb434689 | ||
|
|
b5d4eb8913 | ||
|
|
2116ad3a28 | ||
|
|
15233a3728 | ||
|
|
b476c143c0 |
+1
-1
@@ -1 +1 @@
|
||||
3.0.5
|
||||
3.2
|
||||
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
# 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
|
||||
|
||||
env:
|
||||
global:
|
||||
# ICC serial number.
|
||||
secure: ED3w6rzxuE6tVu3oyxha2MoGMRzRQCtinvr9uor1gw9TGKB80esTLx4KyX0xHemUdyQVarFDDQfVS5rf7jSDY8XiWIR6O+2Af9/30gb+8eyngyvACu7E28n+1XHmYWIEHsbvB9mic6C60FBj5sPcDnFWZeyttGL0WooSjYHiw1Egafwqbeu1mD3Aet9OI9VaLQvy0KcWAdVrYWSI9UWLvLM+xPVUjPFko4oS+dTlETzVnmn6JFbZX1OKONtfcvdoDRFBzs3iHm5dQUt/Fz+y/DtKSuvF3zvePHSgF6c8URbEPPjBdh87gkovSLyy+83fVeh4WMkF8b+dGZmikQv6kRsjKJdbQrS8tiMhZlORC5Gfmn4HXNgmapL+paUweakH7UZQHm6d5SZoBgCHNazfqMrywbZsZkGvZTDQIVG1Be7Lhh2BDFbPhPZNDvI9XYiqZP0QSb0BVfeO+AUSRcUPM7TvarxB74jYdfpTBu7sqJP6dSwhcDTEUhHmuLGjzsNm3uTZe8SUw/TGGx5uPTXNsCjJq6ClIOAIYXZTXLbBmIL/NBWCy0MUpD+9zsiknU7vzzq1RfgCCExhvYgosTjBLcX1kKI+eRSU5M44e+xCg4xx0m9WfafbKbhA20FfnWxCFIkZeVpkOOsexJ9zfe0SflVLxkd7vmci5SCBixLVbN0=
|
||||
|
||||
matrix:
|
||||
include:
|
||||
## ------- ##
|
||||
## First. ##
|
||||
## ------- ##
|
||||
|
||||
# Start with three completely different environments, to get
|
||||
# errors asap.
|
||||
|
||||
- name: "GCC 7 -O3"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
|
||||
|
||||
- name: "Clang 7 libc++ and ASAN"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-7
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang-7
|
||||
- libc++-7-dev
|
||||
- libc++abi-7-dev
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- MATRIX_EVAL="CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
|
||||
|
||||
- name: "ICC"
|
||||
os: linux
|
||||
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='
|
||||
|
||||
|
||||
## ----- ##
|
||||
## GCC. ##
|
||||
## ----- ##
|
||||
|
||||
#- name: "GCC 8 with sanitizers"
|
||||
# os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - ubuntu-toolchain-r-test
|
||||
# packages:
|
||||
# - g++-8
|
||||
# env:
|
||||
# # Can't use UBSAN: I get:
|
||||
# # configure:4951: gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer conftest.c
|
||||
# # /usr/bin/ld: unrecognized option '--push-state'
|
||||
# - MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
|
||||
|
||||
- name: "GCC 6"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
||||
|
||||
- name: "GCC 5"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-5
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
||||
|
||||
- name: "GCC 4.9"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
|
||||
|
||||
- name: "GCC 4.8"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
|
||||
|
||||
- name: "GCC 4.7"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
|
||||
|
||||
- name: "GCC 4.6"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.6 && CXX=g++-4.6"
|
||||
|
||||
## ------- ##
|
||||
## Clang. ##
|
||||
## ------- ##
|
||||
|
||||
- name: "Clang 6 -O3 and libc++"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libc++-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-6.0 && CXX='clang++-6.0 -stdlib=libc++'"
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
|
||||
- name: "Clang 5"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-5.0
|
||||
packages:
|
||||
- clang-5.0
|
||||
- libc++-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
|
||||
|
||||
- name: "Clang 4"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-4.0
|
||||
packages:
|
||||
- clang-4.0
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
|
||||
|
||||
- name: "Clang 3.9"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-3.9
|
||||
packages:
|
||||
- clang-3.9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
|
||||
|
||||
- name: "Clang 3.8"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
packages:
|
||||
- clang-3.8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
||||
|
||||
- name: "CLang 3.7"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
packages:
|
||||
- clang-3.7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
|
||||
|
||||
- name: "Clang 3.6"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
packages:
|
||||
- clang-3.6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
|
||||
|
||||
- name: "Clang 3.5"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
packages:
|
||||
- clang-3.5
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
|
||||
|
||||
- name: "Clang 3.4"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
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++'
|
||||
|
||||
- name: "Clang 3.3"
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
env:
|
||||
# See comment for 3.4.
|
||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
||||
|
||||
|
||||
before_install:
|
||||
- eval "$MATRIX_EVAL"
|
||||
- env
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq autoconf automake autopoint doxygen flex gettext graphviz help2man m4 texinfo
|
||||
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
|
||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||
- autoconf --version
|
||||
- automake --version
|
||||
- autopoint --version
|
||||
- $CC --version
|
||||
- $CXX --version
|
||||
- doxygen --version
|
||||
- flex --version
|
||||
- gettext --version
|
||||
- dot -V
|
||||
- help2man --version
|
||||
- m4 --version
|
||||
- makeinfo --version
|
||||
|
||||
script:
|
||||
- git show
|
||||
- git tag -l
|
||||
# For some reasons, sometimes the checkout does not have any tags,
|
||||
# so `git describe` fails, so bootstrap fails.
|
||||
- git describe || git tag v3.0 -m "Fake version 3.0."
|
||||
- git describe
|
||||
- ./bootstrap
|
||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
|
||||
- make -j2 $MAKE_ARGS
|
||||
- make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }
|
||||
- make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }
|
||||
- make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }
|
||||
|
||||
after_script:
|
||||
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
|
||||
+43
-43
@@ -3671,12 +3671,12 @@
|
||||
2009-02-25 Akim Demaille <[email protected]>
|
||||
|
||||
Copyright years.
|
||||
* data/glr.c: Add 2007 and 2008 here, consistenly with the comments.
|
||||
* data/glr.c: Add 2007 and 2008 here, consistently with the comments.
|
||||
|
||||
2009-02-25 Akim Demaille <[email protected]>
|
||||
|
||||
Style changes.
|
||||
* etc/bench.pl.in (generate_grammar_list): Consitently use
|
||||
* etc/bench.pl.in (generate_grammar_list): Consistently use
|
||||
location_type, not yy::location.
|
||||
|
||||
2009-02-25 Akim Demaille <[email protected]>
|
||||
@@ -3702,7 +3702,7 @@
|
||||
Remove trailing blanks.
|
||||
The epilogue has its own ending \n, no need to add another.
|
||||
|
||||
* data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputing the
|
||||
* data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputting the
|
||||
epilogue.
|
||||
* data/glr.cc: dnl when extending the epilogue.
|
||||
Remove stray "private:".
|
||||
@@ -3764,7 +3764,7 @@
|
||||
2008-12-11 Akim Demaille <[email protected]>
|
||||
|
||||
Pass the token type to yysyntax_error.
|
||||
* data/yacc.c (yysyntax_error): Take the transated token instead
|
||||
* data/yacc.c (yysyntax_error): Take the translated token instead
|
||||
of the raw number.
|
||||
Adjust callers.
|
||||
* TODO: Update.
|
||||
@@ -5019,7 +5019,7 @@
|
||||
|
||||
Now instead of monolithic tables, we define one macro per cell. For
|
||||
instance "b4_symbol(0, tag)" is a macro name which contents is
|
||||
self-decriptive. The macro "b4_symbol" provides easier access to
|
||||
self-descriptive. The macro "b4_symbol" provides easier access to
|
||||
these cells.
|
||||
|
||||
* src/output.c (type_names_output): Remove.
|
||||
@@ -5200,7 +5200,7 @@
|
||||
|
||||
2008-11-09 Akim Demaille <[email protected]>
|
||||
|
||||
Agregate yylval and yylloc.
|
||||
Aggregate yylval and yylloc.
|
||||
* data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
|
||||
(parser::yyla): this.
|
||||
|
||||
@@ -5815,7 +5815,7 @@
|
||||
of members. Document that token names are added as fields.
|
||||
Document constructors accurately. Remove error method.
|
||||
(Java Scanner Interface): Move note on %pure-parser to Java Bison
|
||||
Interface. Describe %code lexer and yylex accutately.
|
||||
Interface. Describe %code lexer and yylex accurately.
|
||||
Remove documentation that does not match the code.
|
||||
(Java Action Features): New.
|
||||
(Java Differences): Add reference. Add item on semantic values.
|
||||
@@ -6432,7 +6432,7 @@
|
||||
* djgpp/config.site: Copyright timestamp adjusted.
|
||||
* djgpp/config_h.sed: Copyright timestamp adjusted.
|
||||
* djgpp/djunpack.bat: Copyright timestamp adjusted.
|
||||
* djgpp/fnchnage.lst: Add filenames that are not 8.3 clean to the
|
||||
* djgpp/fnchange.lst: Add filenames that are not 8.3 clean to the
|
||||
filename translation list.
|
||||
* djgpp/subpipe.c (init_subpipe): Check the environment variables
|
||||
TMPDIR, TMP and TEMP, in that order, to determinate where the temp
|
||||
@@ -7588,7 +7588,7 @@
|
||||
2007-03-07 Juan Manuel Guerrero <[email protected]>
|
||||
|
||||
DJGPP spefic issue. Inhibit the use of disallowed characters for
|
||||
file name genertion on Win98, WinXP, etc. These are |<>":?*\
|
||||
file name generation on Win98, WinXP, etc. These are |<>":?*\
|
||||
and concern testsuite case 46.
|
||||
* Makefile.am: djgpp/testsuite.sed added to EXTRA_DIST
|
||||
* djgpp/testsuite.sed: Inhibit the use of disallowed characters.
|
||||
@@ -8796,7 +8796,7 @@
|
||||
2006-12-13 Paul Eggert <[email protected]>
|
||||
|
||||
* TODO: Add pointer to Sylvain Schmitz's work on static detection
|
||||
of potential ambiguities in GLR grammers.
|
||||
of potential ambiguities in GLR grammars.
|
||||
|
||||
2006-12-12 Joel E. Denny <[email protected]>
|
||||
|
||||
@@ -9059,7 +9059,7 @@
|
||||
* src/scan-gram.l (<SC_BRACED_CODE>): Use val->code for BRACED_CODE,
|
||||
which is "{...}" in the parser.
|
||||
* tests/Makefile.am (maintainer-check-valgrind): Set
|
||||
VALGRIND_OPTS='--leak-check=full --show-reacheable=yes' before invoking
|
||||
VALGRIND_OPTS='--leak-check=full --show-reachable=yes' before invoking
|
||||
Valgrind.
|
||||
* tests/calc.at (_AT_DATA_CALC_Y): fclose the FILE* so Valgrind doesn't
|
||||
complain.
|
||||
@@ -12349,7 +12349,7 @@
|
||||
* data/lalr1.cc: here.
|
||||
(location.hh): Include it after the user prologue, in case the
|
||||
filename type is defined by the user.
|
||||
Forward declation location and position before the pre-prologue.
|
||||
Forward declaration location and position before the pre-prologue.
|
||||
(yyresult_): Rename as...
|
||||
(yyresult): this, it's a local variable, not an attribute.
|
||||
* data/Makefile.am (dist_pkgdata_DATA): Adjust.
|
||||
@@ -12439,8 +12439,8 @@
|
||||
(Table of Symbols): Under YYSTACK_USE_ALLOCA, Don't claim that the
|
||||
user must declare alloca.
|
||||
|
||||
* HACKING (release): Forwarn the Translation Project about
|
||||
stable releses.
|
||||
* HACKING (release): Forewarn the Translation Project about
|
||||
stable releases.
|
||||
|
||||
2005-09-20 Akim Demaille <[email protected]>
|
||||
|
||||
@@ -13165,7 +13165,7 @@
|
||||
not GNU M4, and that it works with any POSIX-compatible Awk.
|
||||
* examples/calc++/Makefile.am (run_extexi): Remove; not used.
|
||||
($(calc_extracted)): Renamed from $(calc_sources_extracted),
|
||||
so that we also get calc++-parser.yy. Geneate it.
|
||||
so that we also get calc++-parser.yy. Generate it.
|
||||
Use $(AWK), not gawk, since any conforming Awk will do.
|
||||
Put comment before action, since older 'make' can't handle comment
|
||||
in action.
|
||||
@@ -13993,7 +13993,7 @@
|
||||
* src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc,
|
||||
to allocate kernel_base, kernel_items, kernel_size, since
|
||||
they needn't be initialized to 0.
|
||||
(allocate_storgae): Likewise, for shiftset, redset, shift_symbol.
|
||||
(allocate_storage): Likewise, for shiftset, redset, shift_symbol.
|
||||
* src/closure.c (new_closure): Likewise, for itemset.
|
||||
* src/derives.c (derives_compute): Likewise, for delts, derives, q.
|
||||
* src/lalr.c (set_goto_map): Likewise, for temp_map.
|
||||
@@ -14181,7 +14181,7 @@
|
||||
2004-10-05 Akim Demaille <[email protected]>
|
||||
|
||||
In Bison 1.875's yacc.c, YYLLOC_DEFAULT was called regardless
|
||||
whether the reducion was empty or not. This leaves room to
|
||||
whether the reduction was empty or not. This leaves room to
|
||||
improve the use of YYLLOC_DEFAULT in such a case.
|
||||
lalr1.cc is still experimental, so changing this is acceptable.
|
||||
And finally, there are probably not many users who changed the
|
||||
@@ -16524,7 +16524,7 @@
|
||||
(struct state): Renamed from struct state_s.
|
||||
(state): Renamed from state_t.
|
||||
(transitions): Renamed from transitions_t. Unused (and
|
||||
misspelled) transtion_s tag removed.
|
||||
misspelled) transition_s tag removed.
|
||||
(errs): Renamed from errs_t. Unused errs_s tag removed.
|
||||
(reductions): Renamed from reductions_t. Unused tag
|
||||
reductions_s removed.
|
||||
@@ -16612,9 +16612,9 @@
|
||||
|
||||
|
||||
Fix misspelling in names.
|
||||
* src/vcg.h (enum_alignment_e): Renamed from enum_alignement_e.
|
||||
* src/vcg.h (enum_alignment_e): Renamed from enum_alignment_e.
|
||||
* src/vcg_defaults.h (G_NODE_ALIGNMENT): Renamed from
|
||||
G_NODE_ALIGNEMENT.
|
||||
G_NODE_ALIGNMENT.
|
||||
|
||||
|
||||
* lib/timevar.c (timevar_report): Renamed from time_report,
|
||||
@@ -16866,7 +16866,7 @@
|
||||
* src/tables.c (conflict_row, pack_vector): Likewise.
|
||||
* src/vcg.c (get_color_str, get_textmode_str, get_shape_str,
|
||||
get_layoutalgorithm_str, get_decision_str, get_orientation_str,
|
||||
get_node_alignement_str, get_arrow_mode_str, get_crossing_type_str,
|
||||
get_node_alignment_str, get_arrow_mode_str, get_crossing_type_str,
|
||||
get_view_str, get_linestyle_str, get_arrowstyle_str): Likewise.
|
||||
|
||||
* lib/argmatch.h (ARRAY_CARDINALITY): Do not bother to #undef.
|
||||
@@ -17365,7 +17365,7 @@
|
||||
(scanner_last_string_free): Remove; not used.
|
||||
(percent_percent_count): Move decl to just before use.
|
||||
(SC_ESCAPED_CHARACTER): Return ID at unexpected end of file,
|
||||
not the (never otherwised-used) CHARACTER.
|
||||
not the (never otherwise-used) CHARACTER.
|
||||
|
||||
2002-11-07 Akim Demaille <[email protected]>
|
||||
|
||||
@@ -18052,7 +18052,7 @@
|
||||
suite using a GLR parser driven by LALR tables. It fails with -O2
|
||||
because `struct stat' gives two different answers on my machine:
|
||||
88 (definition of an auto var) and later 96 (memset on this var).
|
||||
Hence the stack is badly corrumpted. The headers inclusion is to
|
||||
Hence the stack is badly corrupted. The headers inclusion is to
|
||||
blame: if I move the awk.h inclusion before GLR's system header
|
||||
inclusion, the two struct stat have the same size.
|
||||
|
||||
@@ -18962,7 +18962,7 @@
|
||||
|
||||
2002-07-16 Akim Demaille <[email protected]>
|
||||
|
||||
* src/assoc.c, src/asssoc.h (assoc_t, assoc_to_string): New.
|
||||
* src/assoc.c, src/assoc.h (assoc_t, assoc_to_string): New.
|
||||
Adjust all former `associativity' dependencies.
|
||||
* src/symtab.c (symbol_new): Default associativity is `undef', not
|
||||
`right'.
|
||||
@@ -20105,7 +20105,7 @@
|
||||
|
||||
* data/bison.c++: Catch up with bison.simple:
|
||||
2002-05-24 Paul Hilfinger <[email protected]>
|
||||
and Paul Eggert <[email protected]>: `error' handing.
|
||||
and Paul Eggert <[email protected]>: `error' handling.
|
||||
2002-05-26 Akim Demaille <[email protected]>: stos_, token_number_,
|
||||
and popping traces.
|
||||
|
||||
@@ -20455,7 +20455,7 @@
|
||||
single characters while replacing `[' and `]' with quadrigraphs, to
|
||||
avoid troubles with M4 quotes.
|
||||
(copy_comment): Output characters with copy_character.
|
||||
(read_additionnal_code): Likewise.
|
||||
(read_additional_code): Likewise.
|
||||
(copy_string2): Likewise.
|
||||
(copy_definition): Likewise.
|
||||
|
||||
@@ -20638,7 +20638,7 @@
|
||||
* data/bison.simple, data/bison.c++: Adjust.
|
||||
* tests/torture.at (Big triangle): Move the limit from 254 to
|
||||
500.
|
||||
* tests/regression.at (Web2c Actions): Ajust.
|
||||
* tests/regression.at (Web2c Actions): Adjust.
|
||||
|
||||
Trying with bigger grammars shows various phenomena: at 3000 (28Mb
|
||||
of grammar file) bison is killed by my system, at 2000 (12Mb) bison
|
||||
@@ -20949,7 +20949,7 @@
|
||||
|
||||
2002-03-05 Robert Anisko <[email protected]>
|
||||
|
||||
* src/reader.c (read_additionnal_code): `c' should be an integer, not
|
||||
* src/reader.c (read_additional_code): `c' should be an integer, not
|
||||
a character.
|
||||
Reported by Nicolas Tisserand and Nicolas Burrus.
|
||||
|
||||
@@ -21070,7 +21070,7 @@
|
||||
|
||||
* src/L0.c, src/LR0.h (nstates): Be size_t.
|
||||
Adjust comparisons (signed vs unsigned).
|
||||
* src/conflics.c, src/lalr.c, src/lalr.h, src/output.c (LA): Now a
|
||||
* src/conflicts.c, src/lalr.c, src/lalr.h, src/output.c (LA): Now a
|
||||
bitset*.
|
||||
Adjust all dependencies.
|
||||
|
||||
@@ -22337,7 +22337,7 @@
|
||||
|
||||
* src/bison.simple: Remove #line just before %%epilogue. It
|
||||
is now handled in ...
|
||||
* src/reader.c (read_additionnal_code): Add the output of a
|
||||
* src/reader.c (read_additional_code): Add the output of a
|
||||
#line for the epilogue.
|
||||
|
||||
2001-12-10 Marc Autret <[email protected]>
|
||||
@@ -22797,7 +22797,7 @@
|
||||
on user names when possible.
|
||||
|
||||
(YYSTACK_USE_ALLOCA): Do not define; just use any existing defn.
|
||||
Simplify test for whather <alloca.h> exists.
|
||||
Simplify test for whether <alloca.h> exists.
|
||||
|
||||
(<stdlib.h>): Include if we will use malloc, and if standard C or C++.
|
||||
|
||||
@@ -23563,7 +23563,7 @@
|
||||
|
||||
2001-10-04 Akim Demaille <[email protected]>
|
||||
|
||||
* src/reader.c (parse_union_decl): Push the caracters in
|
||||
* src/reader.c (parse_union_decl): Push the characters in
|
||||
union_obstack, not attrs_obstack.
|
||||
|
||||
2001-10-04 Akim Demaille <[email protected]>
|
||||
@@ -23844,7 +23844,7 @@
|
||||
|
||||
* src/vcg.h (graph_s): color, textcolor, bordercolor are now
|
||||
enum color_e.
|
||||
* src/print_graph.c (print_graph): Initalize graph.layoutalgorithm
|
||||
* src/print_graph.c (print_graph): Initialize graph.layoutalgorithm
|
||||
to `normal'.
|
||||
* src/reader.c (parse_token_decl): Initialize token with tok_eof.
|
||||
* src/lex.h: Adjust prototype.
|
||||
@@ -23999,7 +23999,7 @@
|
||||
|
||||
* src/vcg.c: Remove includes of `complain.h' and `xalloc.h'.
|
||||
(get_xxxx_str): Use assert () instead of complain ().
|
||||
Remove return invokations in default cases.
|
||||
Remove return invocations in default cases.
|
||||
(get_decision_str): Modify default behaviour. Remove second argument.
|
||||
Echo modifications on calls.
|
||||
(output_graph): Fix.
|
||||
@@ -24030,7 +24030,7 @@
|
||||
informations about %union.
|
||||
(parse_union_decl): Copy the union_obstack in the muscle stype.
|
||||
* src/bison.simple: Add new #line directive.
|
||||
Add typdef %%stype YYSTYPE.
|
||||
Add typedef %%stype YYSTYPE.
|
||||
|
||||
2001-09-23 Pascal Bart <[email protected]>
|
||||
|
||||
@@ -24115,7 +24115,7 @@
|
||||
(parse_union_decl): Update.
|
||||
(parse_macro_decl): Rename parse_muscle_decl.
|
||||
Update to use renamed functions and variable.
|
||||
(read_declarations, copy_action, read_additionnal_code, : Updated
|
||||
(read_declarations, copy_action, read_additional_code, : Updated
|
||||
with correct variables and functions names.
|
||||
(packsymbols, reader): Likewise.
|
||||
|
||||
@@ -24196,7 +24196,7 @@
|
||||
|
||||
2001-08-31 Pascal Bart <[email protected]>, Marc Autret <[email protected]>
|
||||
|
||||
* src/reader.c (read_additionnal_code): Rename %%user_code to
|
||||
* src/reader.c (read_additional_code): Rename %%user_code to
|
||||
%%epilogue.
|
||||
* src/output.c (output): Rename %%declarations to %%prologue.
|
||||
* src/bison.simple: Echo modifications.
|
||||
@@ -24240,7 +24240,7 @@
|
||||
2001-08-29 Marc Autret <[email protected]>
|
||||
|
||||
* src/bison.simple: Add %%user_code directive at the end.
|
||||
* src/reader.c (read_additionnal_code): New.
|
||||
* src/reader.c (read_additional_code): New.
|
||||
(reader): Use it.
|
||||
* src/output.c (output_program): Remove.
|
||||
(output): Update.
|
||||
@@ -24303,7 +24303,7 @@
|
||||
(readgram): Disable a piece of code that was writing a default
|
||||
definition for 'YYSTYPE'.
|
||||
(reader_output_yylsp): Remove.
|
||||
(packsymbols): Output token defintions to a macro.
|
||||
(packsymbols): Output token definitions to a macro.
|
||||
(copy_definition): Disable C output.
|
||||
|
||||
* src/reader.c (parse_macro_decl): New function used to parse macro
|
||||
@@ -24641,7 +24641,7 @@
|
||||
|
||||
2001-07-08 Pascal Bart <[email protected]>
|
||||
|
||||
* src/bison.simple (yyparse): Suppress warning `comparaison
|
||||
* src/bison.simple (yyparse): Suppress warning `comparison
|
||||
between signed and unsigned'.
|
||||
|
||||
2001-07-05 Pascal Bart <[email protected]>
|
||||
@@ -25128,7 +25128,7 @@
|
||||
* tests/calc.m4: Test it.
|
||||
|
||||
For regularity of the names, replace each
|
||||
(nolineflag, toknumflag, rawtokenumflag, noparserflag): with...
|
||||
(nolineflag, toknumflag, rawtoknumflag, noparserflag): with...
|
||||
(no_lineflag, token_tableflag, rawflag, no_parserflag): this.
|
||||
In addition replace each `flag' with `_flag'.
|
||||
|
||||
@@ -25731,7 +25731,7 @@
|
||||
|
||||
* src/getargs.c, src/Makefile.am, src/reader.c, src/version.c:
|
||||
Have configure build version string instead of relying on ANSI string
|
||||
concatentation.
|
||||
concatenation.
|
||||
|
||||
1999-06-14 Jesse Thilo <[email protected]>
|
||||
|
||||
@@ -25741,7 +25741,7 @@
|
||||
|
||||
* acconfig.h, configure.in:
|
||||
Have configure build version string instead of relying on ANSI string
|
||||
concatentation.
|
||||
concatenation.
|
||||
|
||||
1999-06-08 Jesse Thilo <[email protected]>
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
|
||||
# instead of "-Ilib" avoids infinite recursions on #include_next.
|
||||
AM_CPPFLAGS = -I. -I./lib -I$(top_srcdir) -I$(top_srcdir)/lib
|
||||
BUILT_SOURCES =
|
||||
CLEANDIRS =
|
||||
CLEANFILES =
|
||||
DISTCLEANFILES =
|
||||
EXTRA_DIST += $(dist_TESTS)
|
||||
@@ -64,6 +65,9 @@ include lib/local.mk
|
||||
include src/local.mk
|
||||
include tests/local.mk
|
||||
|
||||
clean-local:
|
||||
rm -rf $(CLEANDIRS)
|
||||
|
||||
# See comments in build-aux/git-version-gen. However, we make .version depend
|
||||
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
|
||||
# working copy (for example, when you run autoreconf && make). Allowing these
|
||||
|
||||
@@ -1,5 +1,178 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.2.1 (2018-11-09) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Several portability issues have been fixed in the build system, in the
|
||||
test suite, and in the generated parsers in C++.
|
||||
|
||||
* Noteworthy changes in release 3.2 (2018-10-29) [stable]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
Support for DJGPP, which have been unmaintained and untested for years, is
|
||||
obsolete. Unless there is activity to revive it, it will be removed.
|
||||
|
||||
** Changes
|
||||
|
||||
%printers should use yyo rather than yyoutput to denote the output stream.
|
||||
|
||||
Variant-based symbols in C++ should use emplace() rather than build().
|
||||
|
||||
In C++ parsers, parser::operator() is now a synonym for the parser::parse.
|
||||
|
||||
** Documentation
|
||||
|
||||
A new section, "A Simple C++ Example", is a tutorial for parsers in C++.
|
||||
|
||||
A comment in the generated code now emphasizes that users should not
|
||||
depend upon non-documented implementation details, such as macros starting
|
||||
with YY_.
|
||||
|
||||
** New features
|
||||
|
||||
*** C++: Support for move semantics (lalr1.cc)
|
||||
|
||||
The lalr1.cc skeleton now fully supports C++ move semantics, while
|
||||
maintaining compatibility with C++98. You may now store move-only types
|
||||
when using Bison's variants. For instance:
|
||||
|
||||
%code {
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
}
|
||||
|
||||
%skeleton "lalr1.cc"
|
||||
%define api.value.type variant
|
||||
|
||||
%%
|
||||
|
||||
%token <int> INT "int";
|
||||
%type <std::unique_ptr<int>> int;
|
||||
%type <std::vector<std::unique_ptr<int>>> list;
|
||||
|
||||
list:
|
||||
%empty {}
|
||||
| list int { $$ = std::move($1); $$.emplace_back(std::move($2)); }
|
||||
|
||||
int: "int" { $$ = std::make_unique<int>($1); }
|
||||
|
||||
*** C++: Implicit move of right-hand side values (lalr1.cc)
|
||||
|
||||
In modern C++ (C++11 and later), you should always use 'std::move' with
|
||||
the values of the right-hand side symbols ($1, $2, etc.), as they will be
|
||||
popped from the stack anyway. Using 'std::move' is mandatory for
|
||||
move-only types such as unique_ptr, and it provides a significant speedup
|
||||
for large types such as std::string, or std::vector, etc.
|
||||
|
||||
If '%define api.value.automove' is set, every occurrence '$n' is replaced
|
||||
by 'std::move ($n)'. The second rule in the previous grammar can be
|
||||
simplified to:
|
||||
|
||||
list: list int { $$ = $1; $$.emplace_back($2); }
|
||||
|
||||
With automove enabled, the semantic values are no longer lvalues, so do
|
||||
not use the swap idiom:
|
||||
|
||||
list: list int { std::swap($$, $1); $$.emplace_back($2); }
|
||||
|
||||
This idiom is anyway obsolete: it is preferable to move than to swap.
|
||||
|
||||
A warning is issued when automove is enabled, and a value is used several
|
||||
times.
|
||||
|
||||
input.yy:16.31-32: warning: multiple occurrences of $2 with api.value.automove enabled [-Wother]
|
||||
exp: "twice" exp { $$ = $2 + $2; }
|
||||
^^
|
||||
|
||||
Enabling api.value.automove does not require support for modern C++. The
|
||||
generated code is valid C++98/03, but will use copies instead of moves.
|
||||
|
||||
The new examples/c++/variant-11.yy shows these features in action.
|
||||
|
||||
*** C++: The implicit default semantic action is always run
|
||||
|
||||
When variants are enabled, the default action was not run, so
|
||||
|
||||
exp: "number"
|
||||
|
||||
was equivalent to
|
||||
|
||||
exp: "number" {}
|
||||
|
||||
It now behaves like in all the other cases, as
|
||||
|
||||
exp: "number" { $$ = $1; }
|
||||
|
||||
possibly using std::move if automove is enabled.
|
||||
|
||||
We do not expect backward compatibility issues. However, beware of
|
||||
forward compatibility issues: if you rely on default actions with
|
||||
variants, be sure to '%require "3.2"' to avoid older versions of Bison to
|
||||
generate incorrect parsers.
|
||||
|
||||
*** C++: Renaming location.hh
|
||||
|
||||
When both %defines and %locations are enabled, Bison generates a
|
||||
location.hh file. If you don't use locations outside of the parser, you
|
||||
may avoid its creation with:
|
||||
|
||||
%define api.location.file none
|
||||
|
||||
However this file is useful if, for instance, your parser builds an AST
|
||||
decorated with locations: you may use Bison's location independently of
|
||||
Bison's parser. You can now give it another name, for instance:
|
||||
|
||||
%define api.location.file "my-location.hh"
|
||||
|
||||
This name can have directory components, and even be absolute. The name
|
||||
under which the location file is included is controlled by
|
||||
api.location.include.
|
||||
|
||||
This way it is possible to have several parsers share the same location
|
||||
file.
|
||||
|
||||
For instance, in src/foo/parser.hh, generate the include/ast/loc.hh file:
|
||||
|
||||
%locations
|
||||
%define api.namespace {foo}
|
||||
%define api.location.file "include/ast/loc.hh"
|
||||
%define api.location.include {<ast/loc.hh>}
|
||||
|
||||
and use it in src/bar/parser.hh:
|
||||
|
||||
%locations
|
||||
%define api.namespace {bar}
|
||||
%code requires {#include <ast/loc.hh>}
|
||||
%define api.location.type {bar::location}
|
||||
|
||||
Absolute file names are supported, so in your Makefile, passing the flag
|
||||
-Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"' to bison is
|
||||
safe.
|
||||
|
||||
*** C++: stack.hh and position.hh are deprecated
|
||||
|
||||
When asked to generate a header file (%defines), the lalr1.cc skeleton
|
||||
generates a stack.hh file. This file had no interest for users; it is now
|
||||
made useless: its content is included in the parser definition. It is
|
||||
still generated for backward compatibility.
|
||||
|
||||
When in addition to %defines, location support is requested (%locations),
|
||||
the file position.hh is also generated. It is now also useless: its
|
||||
content is now included in location.hh.
|
||||
|
||||
These files are no longer generated when your grammar file requires at
|
||||
least Bison 3.2 (%require "3.2").
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Portability issues on MinGW and VS2015.
|
||||
|
||||
Portability issues in the test suite.
|
||||
|
||||
Portability/warning issues with Flex.
|
||||
|
||||
* Noteworthy changes in release 3.1 (2018-08-27) [stable]
|
||||
|
||||
** Backward incompatible changes
|
||||
@@ -698,9 +871,9 @@ GNU Bison NEWS
|
||||
fixed, and introducing tokens with any of %token, %left, %right,
|
||||
%precedence, or %nonassoc yields the same result.
|
||||
|
||||
When mixing declarations of tokens with a litteral character (e.g., 'a')
|
||||
or with an identifier (e.g., B) in a precedence declaration, Bison
|
||||
numbered the litteral characters first. For example
|
||||
When mixing declarations of tokens with a literal character (e.g., 'a') or
|
||||
with an identifier (e.g., B) in a precedence declaration, Bison numbered
|
||||
the literal characters first. For example
|
||||
|
||||
%right A B 'c' 'd'
|
||||
|
||||
@@ -1021,7 +1194,7 @@ GNU Bison NEWS
|
||||
Although introduced more than four years ago, XML and Graphviz reports
|
||||
were not properly documented.
|
||||
|
||||
The translation of mid-rule actions is now described.
|
||||
The translation of midrule actions is now described.
|
||||
|
||||
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
|
||||
|
||||
@@ -2017,16 +2190,16 @@ GNU Bison NEWS
|
||||
The prologue alternatives are experimental. More user feedback will help to
|
||||
determine whether they should become permanent features.
|
||||
|
||||
** Revised warning: unset or unused mid-rule values
|
||||
** Revised warning: unset or unused midrule values
|
||||
|
||||
Since Bison 2.2, Bison has warned about mid-rule values that are set but not
|
||||
Since Bison 2.2, Bison has warned about midrule values that are set but not
|
||||
used within any of the actions of the parent rule. For example, Bison warns
|
||||
about unused $2 in:
|
||||
|
||||
exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
|
||||
|
||||
Now, Bison also warns about mid-rule values that are used but not set. For
|
||||
example, Bison warns about unset $$ in the mid-rule action in:
|
||||
Now, Bison also warns about midrule values that are used but not set. For
|
||||
example, Bison warns about unset $$ in the midrule action in:
|
||||
|
||||
exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
|
||||
|
||||
@@ -2052,7 +2225,7 @@ GNU Bison NEWS
|
||||
|
||||
Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
|
||||
"<*>" and "<>" combined achieve the same effect with one exception: Bison no
|
||||
longer applies any %destructor to a mid-rule value if that mid-rule value is
|
||||
longer applies any %destructor to a midrule value if that midrule value is
|
||||
not actually ever referenced using either $$ or $n in a semantic action.
|
||||
|
||||
The default %destructor's and %printer's are experimental. More user
|
||||
@@ -2230,7 +2403,7 @@ GNU Bison NEWS
|
||||
| exp "+" exp { $$ = $1; (void) $3; }
|
||||
;
|
||||
|
||||
If there are mid-rule actions, the warning is issued if no action
|
||||
If there are midrule actions, the warning is issued if no action
|
||||
uses it. The following triggers no warning: $1 and $3 are used.
|
||||
|
||||
exp: exp { push ($1); } '+' exp { push ($3); sum (); };
|
||||
@@ -2505,13 +2678,13 @@ GNU Bison NEWS
|
||||
|
||||
typed: ... untyped;
|
||||
|
||||
** Values of mid-rule actions
|
||||
** Values of midrule actions
|
||||
The following code:
|
||||
|
||||
foo: { ... } { $$ = $1; } ...
|
||||
|
||||
was incorrectly rejected: $1 is defined in the second mid-rule
|
||||
action, and is equal to the $$ of the first mid-rule action.
|
||||
was incorrectly rejected: $1 is defined in the second midrule
|
||||
action, and is equal to the $$ of the first midrule action.
|
||||
|
||||
* Changes in version 1.50, 2002-10-04:
|
||||
|
||||
@@ -2647,7 +2820,7 @@ GNU Bison NEWS
|
||||
|
||||
** Type clashes
|
||||
Previous versions don't complain when there is a type clash on
|
||||
the default action if the rule has a mid-rule action, such as in:
|
||||
the default action if the rule has a midrule action, such as in:
|
||||
|
||||
%type <foo> bar
|
||||
%%
|
||||
@@ -2958,7 +3131,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
LocalWords: Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
|
||||
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
||||
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
||||
LocalWords: Alexandre MERCHANTABILITY yytype
|
||||
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
|
||||
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir
|
||||
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles outout PROG
|
||||
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
|
||||
@@ -10,7 +10,7 @@ Bison requires GNU m4 1.4.6 or later. See:
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
|
||||
|
||||
** Internationalization
|
||||
Bison supports two catalogues: one for Bison itself (i.e., for the
|
||||
Bison supports two catalogs: one for Bison itself (i.e., for the
|
||||
maintainer-side parser generation), and one for the generated parsers
|
||||
(i.e., for the user-side parser execution). The requirements between
|
||||
both differ: bison needs ngettext, the generated parsers do not. To
|
||||
@@ -29,9 +29,9 @@ If you have questions about using Bison and the documentation does
|
||||
not answer them, please send mail to <[email protected]>.
|
||||
|
||||
* Bug reports
|
||||
Please send bug reports to <[email protected]>. Please include the
|
||||
version number from 'bison --version', and a complete, self-contained
|
||||
test case in each bug report.
|
||||
Please send bug reports to <[email protected]>. Be sure to include the
|
||||
version number from 'bison --version', and a complete, self-contained test
|
||||
case in each bug report.
|
||||
|
||||
* Copyright statements
|
||||
For any copyright year range specified as YYYY-ZZZZ in this package,
|
||||
@@ -42,12 +42,13 @@ note that the range specifies every single year in that closed interval.
|
||||
Local Variables:
|
||||
mode: outline
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
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
|
||||
@@ -61,3 +62,6 @@ 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: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
||||
# LocalWords: MERCHANTABILITY
|
||||
|
||||
+14
-14
@@ -190,12 +190,15 @@ Use liberally.
|
||||
|
||||
** TESTSUITEFLAGS
|
||||
|
||||
The default is for make check to run all tests sequentially. This can be
|
||||
very time consumming when checking repeatedly or on slower setups. This can
|
||||
be sped up in two ways:
|
||||
To run just the testsuite (not the tests related to the examples), 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
|
||||
can be sped up in two ways:
|
||||
|
||||
Using -j, in a make-like fashion, for example:
|
||||
$ make check TESTSUITEFLAGS='-j8'
|
||||
$ make check-local TESTSUITEFLAGS='-j8'
|
||||
|
||||
Running only the tests of a certain category, as specified in the AT files
|
||||
with AT_KEYWORDS([[category]]). Categories include:
|
||||
@@ -206,7 +209,7 @@ with AT_KEYWORDS([[category]]). Categories include:
|
||||
- report, for automaton dumps
|
||||
|
||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
||||
$ make check TESTSUITEFLAGS='-k c++'
|
||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||
|
||||
Both can be combined.
|
||||
|
||||
@@ -259,24 +262,21 @@ release:
|
||||
- runs the parsers under Valgrind.
|
||||
- runs the test suite with G++ as C compiler...
|
||||
|
||||
- run "make maintainer-push-check", which runs "make maintainer-check" while
|
||||
- run "make maintainer-check-push", which runs "make maintainer-check" while
|
||||
activating the push implementation and its pull interface wrappers in many
|
||||
test cases that were originally written to exercise only the pull
|
||||
implementation. This makes certain the push implementation can perform
|
||||
every task the pull implementation can.
|
||||
|
||||
- run "make maintainer-xml-check", which runs "make maintainer-check" while
|
||||
- run "make maintainer-check-xml", which runs "make maintainer-check" while
|
||||
checking Bison's XML automaton report for every working grammar passed to
|
||||
Bison in the test suite. The check just diffs the output of Bison's
|
||||
included XSLT style sheets with the output of --report=all and --graph.
|
||||
|
||||
- running "make maintainer-release-check" takes care of running
|
||||
maintainer-check, maintainer-push-check and maintainer-xml-check.
|
||||
- running "make maintainer-check-release" takes care of running
|
||||
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
||||
|
||||
- Change tests/atlocal/CFLAGS to add your preferred options. For instance,
|
||||
"-traditional" to check that the parsers are K&R. Note that it does not
|
||||
make sense for glr.c, which should be ANSI, but currently is actually GNU
|
||||
C, nor for lalr1.cc.
|
||||
- Change tests/atlocal/CFLAGS to add your preferred options.
|
||||
|
||||
- Test with a very recent version of GCC for both C and C++. Testing with
|
||||
older versions that are still in use is nice too.
|
||||
@@ -294,7 +294,7 @@ In particular, be sure to read README-release.
|
||||
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 '\<_(' *
|
||||
helps: grep -l '\<_(' *.
|
||||
|
||||
** Tests
|
||||
See above.
|
||||
|
||||
@@ -3,11 +3,13 @@ it is today without the invaluable help of these people:
|
||||
|
||||
Aaro Koskinen [email protected]
|
||||
Аскар Сафин [email protected]
|
||||
Adam Sampson [email protected]
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille [email protected]
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Alexandre Duret-Lutz [email protected]
|
||||
Andre da Costa Barros [email protected]
|
||||
Andreas Schwab [email protected]
|
||||
Andrew Suffield [email protected]
|
||||
Angelo Borsotti [email protected]
|
||||
@@ -42,6 +44,7 @@ David J. MacKenzie [email protected]
|
||||
David Kastrup [email protected]
|
||||
David Michael [email protected]
|
||||
Dengke Du [email protected]
|
||||
Denis Excoffier [email protected]
|
||||
Dennis Clarke [email protected]
|
||||
Derek Clegg [email protected]
|
||||
Derek M. Jones [email protected]
|
||||
@@ -51,6 +54,7 @@ Didier Godefroy [email protected]
|
||||
Efi Fogel [email protected]
|
||||
Enrico Scholz [email protected]
|
||||
Eric Blake [email protected]
|
||||
Étienne Renault [email protected]
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
Ferdinand Thiessen [email protected]
|
||||
@@ -66,6 +70,7 @@ Goran Uddeborg [email protected]
|
||||
Guido Trentalancia [email protected]
|
||||
H. Merijn Brand [email protected]
|
||||
Hans Åberg [email protected]
|
||||
Horst Von Brand [email protected]
|
||||
Jan Nieuwenhuizen [email protected]
|
||||
Jannick [email protected]
|
||||
Jerry Quinn [email protected]
|
||||
@@ -77,10 +82,12 @@ Johan van Selst [email protected]
|
||||
John Horigan [email protected]
|
||||
Jonathan Fabrizio [email protected]
|
||||
Jonathan Nieder [email protected]
|
||||
Josh Soref [email protected]
|
||||
Juan Manuel Guerrero [email protected]
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne [email protected]
|
||||
Ken Moffat [email protected]
|
||||
Kiyoshi Kanazawa [email protected]
|
||||
Laurent Mascherpa [email protected]
|
||||
Lie Yan [email protected]
|
||||
Magnus Fromreide [email protected]
|
||||
@@ -101,6 +108,7 @@ Michel d'Hooge [email protected]
|
||||
Michiel De Wilde [email protected]
|
||||
Mickael Labau [email protected]
|
||||
Mike Castle [email protected]
|
||||
Mike Frysinger [email protected]
|
||||
Mike Sullivan [email protected]
|
||||
Nate Guerin [email protected]
|
||||
Neil Booth [email protected]
|
||||
@@ -145,6 +153,7 @@ Sebastian Setzer [email protected]
|
||||
Sebastien Fricker [email protected]
|
||||
Sergei Steshenko [email protected]
|
||||
Shura [email protected]
|
||||
Simon Sobisch [email protected]
|
||||
Stefano Lattarini [email protected]
|
||||
Stephen Cameron [email protected]
|
||||
Steve Murphy [email protected]
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
* Short term
|
||||
** yacc.c
|
||||
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
|
||||
than duplicating it.
|
||||
|
||||
** 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.
|
||||
|
||||
** C
|
||||
Introduce state_type rather than spreading yytype_int16 everywhere?
|
||||
|
||||
** glr.c
|
||||
yyspaceLeft should probably be a pointer diff.
|
||||
|
||||
** 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
|
||||
@@ -196,6 +212,31 @@ DeRemer and Penello: they already provide the algorithm.
|
||||
|
||||
|
||||
* Extensions
|
||||
** Multiple start symbols
|
||||
Would be very useful when parsing closely related languages.
|
||||
|
||||
** 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.
|
||||
|
||||
Bruce Mardle <[email protected]>
|
||||
https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
|
||||
|
||||
** Push parsers
|
||||
There is demand for push parsers in Java and C++. And GLR I guess.
|
||||
|
||||
** Generate code instead of tables
|
||||
This is certainly quite a lot of work. See
|
||||
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.4539.
|
||||
|
||||
** $-1
|
||||
We should find a means to provide an access to values deep in the
|
||||
@@ -231,6 +272,10 @@ XML output for GNU Bison and gcc
|
||||
XML output for GNU Bison
|
||||
http://yaxx.sourceforge.net/
|
||||
|
||||
** Counterexample generation
|
||||
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
|
||||
http://www.cs.cornell.edu/andru/papers/cupex/
|
||||
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules, i.e., transform
|
||||
|
||||
@@ -365,6 +410,7 @@ Here's a proposal for how a new implementation might look:
|
||||
Local Variables:
|
||||
mode: outline
|
||||
coding: utf-8
|
||||
fill-column: 76
|
||||
End:
|
||||
|
||||
-----
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2018-07-25.07; # UTC
|
||||
scriptversion=2018-10-13.05; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
@@ -162,18 +162,11 @@ bootstrap_post_import_hook() { :; }
|
||||
# Override it via your own definition in bootstrap.conf.
|
||||
bootstrap_epilogue() { :; }
|
||||
|
||||
# The command to download all .po files for a specified domain into
|
||||
# a specified directory. Fill in the first %s is the domain name, and
|
||||
# the second with the destination directory. Use rsync's -L and -r
|
||||
# options because the latest/%s directory and the .po files within are
|
||||
# all symlinks.
|
||||
# The command to download all .po files for a specified domain into a
|
||||
# specified directory. Fill in the first %s with the destination
|
||||
# directory and the second with the domain name.
|
||||
po_download_command_format=\
|
||||
"rsync --include '*.po' --exclude '*' -Lrtvz \
|
||||
'translationproject.org::tp/latest/%s/' '%s'"
|
||||
|
||||
# Fallback for downloading .po files (if rsync fails).
|
||||
po_download_command_format2=\
|
||||
"wget --mirror -nd -q -np -A.po -P '%s' \
|
||||
"wget --mirror --level=1 -nd -q -A.po -P '%s' \
|
||||
https://translationproject.org/latest/%s/"
|
||||
|
||||
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
||||
@@ -741,10 +734,7 @@ download_po_files() {
|
||||
subdir=$1
|
||||
domain=$2
|
||||
echo "$me: getting translations into $subdir for $domain..."
|
||||
cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
|
||||
eval "$cmd" && return
|
||||
# Fallback to HTTPS.
|
||||
cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
|
||||
cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ gnulib_modules='
|
||||
readme-release
|
||||
realloc-posix
|
||||
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
||||
timevar
|
||||
unistd unistd-safer unlink unlocked-io
|
||||
update-copyright unsetenv verify
|
||||
warnings
|
||||
|
||||
@@ -15,6 +15,19 @@
|
||||
|
||||
# Valgrind suppression file for Bison.
|
||||
|
||||
# Travis Trusty, 2018-09-07.
|
||||
{
|
||||
libstdcxx_init
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
|
||||
fun:call_init.part.0
|
||||
fun:call_init
|
||||
fun:_dl_init
|
||||
obj:/lib/x86_64-linux-gnu/ld-2.19.so
|
||||
}
|
||||
|
||||
# Linux prague 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015
|
||||
# x86_64 GNU/Linux
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ while (<STDIN>)
|
||||
$arg =~ s/^=//;
|
||||
$arg = lc ($arg);
|
||||
my $dir_arg = $arg;
|
||||
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
|
||||
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
|
||||
# put each word in @var, to build @var{name}[=@var{value}], not
|
||||
# @var{name[=value]}].
|
||||
$arg =~ s/(\w+)/\@var{$1}/g;
|
||||
|
||||
Executable
+234
@@ -0,0 +1,234 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Install Intel Parallel Studio on Travis CI
|
||||
# https://github.com/nemequ/icc-travis
|
||||
#
|
||||
# Originally written for Squash <https://github.com/quixdb/squash> by
|
||||
# Evan Nemerson. For documentation, bug reports, support requests,
|
||||
# etc. please use <https://github.com/nemequ/icc-travis>.
|
||||
#
|
||||
# To the extent possible under law, the author(s) of this script have
|
||||
# waived all copyright and related or neighboring rights to this work.
|
||||
# See <https://creativecommons.org/publicdomain/zero/1.0/> for
|
||||
# details.
|
||||
|
||||
# Tools - Not very useful in non-interactive mode.
|
||||
COMPONENTS_VTUNE="intel-vtune-amplifier-xe-2016-cli__x86_64;intel-vtune-amplifier-xe-2016-common__noarch;intel-vtune-amplifier-xe-2016-cli-common__noarch;intel-vtune-amplifier-xe-2016-collector-64linux__x86_64;intel-vtune-amplifier-xe-2016-sep__noarch;intel-vtune-amplifier-xe-2016-gui-common__noarch;intel-vtune-amplifier-xe-2016-gui__x86_64;intel-vtune-amplifier-xe-2016-common-pset__noarch"
|
||||
COMPONENTS_INSPECTOR="intel-inspector-xe-2016-cli__x86_64;intel-inspector-xe-2016-cli-common__noarch;intel-inspector-xe-2016-gui-common__noarch;intel-inspector-xe-2016-gui__x86_64;intel-inspector-xe-2016-cli-pset__noarch"
|
||||
COMPONENTS_ADVISOR="intel-advisor-xe-2016-cli__x86_64;intel-advisor-xe-2016-cli-common__noarch;intel-advisor-xe-2016-gui-common__noarch;intel-advisor-xe-2016-gui__x86_64;intel-advisor-xe-2016-cli-pset__noarch"
|
||||
COMPONENTS_GDB="intel-gdb-gt__x86_64;intel-gdb-gt-src__noarch;intel-gdb-gt-libelfdwarf__x86_64;intel-gdb-gt-devel__x86_64;intel-gdb-gt-common__noarch;intel-gdb-ps-cdt__x86_64;intel-gdb-ps-cdt-source__x86_64;intel-gdb-ps-mic__x86_64;intel-gdb-ps-mpm__x86_64;intel-gdb__x86_64;intel-gdb-source__noarch;intel-gdb-python-source__noarch;intel-gdb-common__noarch;intel-gdb-ps-common__noarch"
|
||||
|
||||
# Parallel libraries
|
||||
COMPONENTS_MPI="intel-mpi-rt-core__x86_64;intel-mpi-rt-mic__x86_64;intel-mpi-sdk-core__x86_64;intel-mpi-sdk-mic__x86_64;intel-mpi-psxe__x86_64;intel-mpi-rt-psxe__x86_64"
|
||||
COMPONENTS_TBB="intel-tbb-libs__noarch;intel-mkl-ps-tbb__x86_64;intel-mkl-ps-tbb-devel__x86_64;intel-mkl-ps-tbb-mic__x86_64;intel-mkl-ps-tbb-mic-devel__x86_64;intel-tbb-source__noarch;intel-tbb-devel__noarch;intel-tbb-common__noarch;intel-tbb-ps-common__noarch;intel-tbb-psxe__noarch"
|
||||
COMPONENTS_MKL="intel-mkl__x86_64;intel-mkl-ps__x86_64;intel-mkl-common__noarch;intel-mkl-ps-common__noarch;intel-mkl-devel__x86_64;intel-mkl-ps-mic-devel__x86_64;intel-mkl-ps-f95-devel__x86_64;intel-mkl-gnu-devel__x86_64;intel-mkl-ps-gnu-devel__x86_64;intel-mkl-ps-pgi-devel__x86_64;intel-mkl-sp2dp-devel__x86_64;intel-mkl-ps-cluster-devel__x86_64;intel-mkl-ps-cluster-common__noarch;intel-mkl-ps-f95-common__noarch;intel-mkl-ps-cluster__x86_64;intel-mkl-gnu__x86_64;intel-mkl-ps-gnu__x86_64;intel-mkl-ps-pgi__x86_64;intel-mkl-sp2dp__x86_64;intel-mkl-ps-mic__x86_64;intel-mkl-ps-tbb__x86_64;intel-mkl-ps-tbb-devel__x86_64;intel-mkl-ps-tbb-mic__x86_64;intel-mkl-ps-tbb-mic-devel__x86_64;intel-mkl-psxe__noarch"
|
||||
COMPONENTS_IPP="intel-ipp-l-common__noarch;intel-ipp-l-ps-common__noarch;intel-ipp-l-st__x86_64;intel-ipp-l-mt__x86_64;intel-ipp-l-st-devel__x86_64;intel-ipp-l-ps-st-devel__x86_64;intel-ipp-l-mt-devel__x86_64;intel-ipp-psxe__noarch"
|
||||
COMPONENTS_IPP_CRYPTO="intel-crypto-ipp-st-devel__x86_64;intel-crypto-ipp-ps-st-devel__x86_64;intel-crypto-ipp-st__x86_64;intel-crypto-ipp-mt-devel__x86_64;intel-crypto-ipp-mt__x86_64;intel-crypto-ipp-ss-st-devel__x86_64;intel-crypto-ipp-common__noarch"
|
||||
COMPONENTS_DAAL="intel-daal__x86_64;intel-daal-common__noarch"
|
||||
|
||||
# Compilers
|
||||
COMPONENTS_OPENMP="intel-openmp-l-all__x86_64;intel-openmp-l-ps-mic__x86_64;intel-openmp-l-ps__x86_64;intel-openmp-l-ps-ss__x86_64;intel-openmp-l-all-devel__x86_64;intel-openmp-l-ps-mic-devel__x86_64;intel-openmp-l-ps-devel__x86_64;intel-openmp-l-ps-ss-devel__x86_64"
|
||||
COMPONENTS_COMPILER_COMMON="intel-comp-l-all-vars__noarch;intel-comp-l-all-common;intel-comp-l-ps-common;intel-comp-l-all-devel;intel-comp-l-ps-ss-devel;intel-comp-l-ps-ss-wrapper;intel-comp-l-all-devel;intel-comp-l-ps-devel__x86_64;intel-comp-l-ps-ss-devel__x86_64;intel-psf-intel__x86_64;intel-icsxe-pset;intel-ipsf__noarch;intel-ccompxe__noarch;${COMPONENTS_OPENMP}"
|
||||
COMPONENTS_IFORT="intel-ifort-l-ps__x86_64;intel-ifort-l-ps-vars__noarch;intel-ifort-l-ps-common__noarch;intel-ifort-l-ps-devel__x86_64;${COMPONENTS_COMPILER_COMMON}"
|
||||
COMPONENTS_ICC="intel-icc-l-all__x86_64;intel-icc-l-ps-ss__x86_64;intel-icc-l-all-vars__noarch;intel-icc-l-all-common__noarch;intel-icc-l-ps-common__noarch;intel-icc-l-all-devel__x86_64;intel-icc-l-ps-devel__x86_64;intel-icc-l-ps-ss-devel__x86_64;${COMPONENTS_COMPILER_COMMON}"
|
||||
|
||||
DESTINATION="${HOME}/intel"
|
||||
TEMPORARY_FILES="/tmp"
|
||||
PHONE_INTEL="no"
|
||||
COMPONENTS=""
|
||||
|
||||
add_components() {
|
||||
if [ ! -z "${COMPONENTS}" ]; then
|
||||
COMPONENTS="${COMPONENTS};$1"
|
||||
else
|
||||
COMPONENTS="$1"
|
||||
fi
|
||||
}
|
||||
|
||||
while [ $# != 0 ]; do
|
||||
case "$1" in
|
||||
"--dest")
|
||||
DESTINATION="$(realpath "$2")"; shift
|
||||
;;
|
||||
"--tmpdir")
|
||||
TEMPORARY_FILES="$2"; shift
|
||||
;;
|
||||
"--components")
|
||||
shift
|
||||
OLD_IFS="${IFS}"
|
||||
IFS=","
|
||||
for component in $1; do
|
||||
case "$component" in
|
||||
"icc")
|
||||
add_components "${COMPONENTS_ICC}"
|
||||
;;
|
||||
"mpi")
|
||||
add_components "${COMPONENTS_MPI}"
|
||||
;;
|
||||
"vtune")
|
||||
add_components "${COMPONENTS_VTUNE}"
|
||||
;;
|
||||
"inspector")
|
||||
add_components "${COMPONENTS_INSPECTOR}"
|
||||
;;
|
||||
"advisor")
|
||||
add_components "${COMPONENTS_ADVISOR}"
|
||||
;;
|
||||
"tbb")
|
||||
add_components "${COMPONENTS_TBB}"
|
||||
;;
|
||||
"ifort")
|
||||
add_components "${COMPONENTS_IFORT}"
|
||||
;;
|
||||
"mkl")
|
||||
add_components "${COMPONENTS_MKL}"
|
||||
;;
|
||||
"openmp")
|
||||
# Noop, here for compatability. OpenMP is installed with icc and ifort now.
|
||||
;;
|
||||
"ipp")
|
||||
add_components "${COMPONENTS_IPP}"
|
||||
;;
|
||||
"ipp-crypto")
|
||||
add_components "${COMPONENTS_IPP_CRYPTO}"
|
||||
;;
|
||||
"gdb")
|
||||
add_components "${COMPONENTS_GDB}"
|
||||
;;
|
||||
"daal")
|
||||
add_components "${COMPONENTS_DAAL}"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown component '$component'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
IFS="${OLD_IFS}"
|
||||
;;
|
||||
*)
|
||||
echo "Unrecognized argument '$1'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "${COMPONENTS}" ]; then
|
||||
COMPONENTS="${COMPONENTS_ICC}"
|
||||
fi
|
||||
|
||||
INSTALLER_SCRIPT="parallel_studio_xe_2016_update3_online.sh"
|
||||
INSTALLER="${TEMPORARY_FILES}/${INSTALLER_SCRIPT}"
|
||||
INSTALLER_URL="http://registrationcenter-download.intel.com/akdlm/irc_nas/9061/${INSTALLER_SCRIPT}"
|
||||
SILENT_CFG="${TEMPORARY_FILES}/silent.cfg"
|
||||
SUCCESS_INDICATOR="${TEMPORARY_FILES}/icc-travis-success"
|
||||
|
||||
if [ ! -e "${TEMPORARY_FILES}" ]; then
|
||||
echo "${TEMPORARY_FILES} does not exist, creating..."
|
||||
mkdir -p "${TEMPORARY_FILES}" || (sudo mkdir -p "${TEMPORARY_FILES}" && sudo chown -R "${USER}:${USER}" "${TEMPORARY_FILES}")
|
||||
fi
|
||||
|
||||
if [ ! -e "${DESTINATION}" ]; then
|
||||
echo "${DESTINATION} does not exist, creating..."
|
||||
mkdir -p "${DESTINATION}" || (sudo mkdir -p "${DESTINATION}" && sudo chown -R "${USER}:${USER}" "${DESTINATION}")
|
||||
fi
|
||||
|
||||
if [ ! -e "${INSTALLER}" ]; then
|
||||
wget -O "${INSTALLER}" "${INSTALLER_URL}" || exit 1
|
||||
fi
|
||||
chmod u+x "${INSTALLER}"
|
||||
|
||||
# See https://software.intel.com/en-us/articles/intel-composer-xe-2015-silent-installation-guide
|
||||
echo "# Generated silent configuration file" > "${SILENT_CFG}"
|
||||
echo "ACCEPT_EULA=accept" >> "${SILENT_CFG}"
|
||||
echo "INSTALL_MODE=NONRPM" >> "${SILENT_CFG}"
|
||||
echo "CONTINUE_WITH_OPTIONAL_ERROR=yes" >> "${SILENT_CFG}"
|
||||
echo "PSET_INSTALL_DIR=${DESTINATION}" >> "${SILENT_CFG}"
|
||||
echo "CONTINUE_WITH_INSTALLDIR_OVERWRITE=yes" >> "${SILENT_CFG}"
|
||||
echo "COMPONENTS=${COMPONENTS}" >> "${SILENT_CFG}"
|
||||
echo "PSET_MODE=install" >> "${SILENT_CFG}"
|
||||
echo "PHONEHOME_SEND_USAGE_DATA=${PHONE_INTEL}" >> "${SILENT_CFG}"
|
||||
if [ "x" != "x${INTEL_SERIAL_NUMBER}" ]; then
|
||||
echo "ACTIVATION_SERIAL_NUMBER=${INTEL_SERIAL_NUMBER}" >> "${SILENT_CFG}"
|
||||
echo "ACTIVATION_TYPE=serial_number" >> "${SILENT_CFG}"
|
||||
else
|
||||
echo "ACTIVATION_TYPE=trial_lic" >> "${SILENT_CFG}"
|
||||
fi
|
||||
|
||||
attempt=1;
|
||||
while [ $attempt -le 3 ]; do
|
||||
if [ ! -e "${TEMPORARY_FILES}/parallel-studio-install-data" ]; then
|
||||
mkdir -p "${TEMPORARY_FILES}/parallel-studio-install-data" || (sudo mkdir -p "${TEMPORARY_FILES}/parallel-studio-install-data" && sudo chown -R "${USER}:${USER}" "${TEMPORARY_FILES}")
|
||||
fi
|
||||
|
||||
("${INSTALLER}" \
|
||||
-t "${TEMPORARY_FILES}/parallel-studio-install-data" \
|
||||
-s "${SILENT_CFG}" \
|
||||
--cli-mode \
|
||||
--user-mode && \
|
||||
touch "${SUCCESS_INDICATOR}") &
|
||||
|
||||
# So Travis doesn't die in case of a long download/installation.
|
||||
#
|
||||
# NOTE: a watched script never terminates.
|
||||
elapsed=0;
|
||||
while kill -0 $! 2>/dev/null; do
|
||||
sleep 1
|
||||
elapsed=$(expr $elapsed + 1)
|
||||
if [ $(expr $elapsed % 60) -eq 0 ]; then
|
||||
mins_elapsed=$(expr $elapsed / 60)
|
||||
if [ $mins_elapsed = 1 ]; then
|
||||
minute_string="minute"
|
||||
else
|
||||
minute_string="minutes"
|
||||
fi
|
||||
echo "Still running... (about $(expr $elapsed / 60) ${minute_string} so far)."
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -e "${SUCCESS_INDICATOR}" ]; then
|
||||
echo "Installation failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${DESTINATION}/bin/compilervars.sh" ]; then
|
||||
# Sometimes the installer returns successfully without actually
|
||||
# installing anything. Let's try again…
|
||||
echo "Installation attempt #${attempt} completed, but unable to find compilervars.sh."
|
||||
find "${DESTINATION}"
|
||||
else
|
||||
break
|
||||
fi
|
||||
|
||||
rm -vrf "${TEMPORARY_FILES}/parallel-studio-install-data"
|
||||
echo "Trying again..."
|
||||
|
||||
attempt=$(expr $attempt + 1)
|
||||
done
|
||||
|
||||
if [ ! -e "${DESTINATION}/bin/compilervars.sh" ]; then
|
||||
echo "Installation failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Apparently the installer drops the license file in a location it
|
||||
# doesn't know to check.
|
||||
ln -s "${DESTINATION}"/licenses ~/Licenses
|
||||
|
||||
# Add configuration information to ~/.bashrc. Unfortunately this will
|
||||
# not be picked up automatically by Travis, so you'll still need to
|
||||
# source ~/.bashrc in your .travis.yml
|
||||
#
|
||||
# Container-based builds include a `[ -z "$PS1" ] && return` near the
|
||||
# beginning of the file, so appending won't work, we'll need to
|
||||
# prepend.
|
||||
echo "export INTEL_INSTALL_PATH=\"${DESTINATION}\"" >> ~/.bashrc-intel
|
||||
echo ". \"\${INTEL_INSTALL_PATH}/bin/compilervars.sh\" intel64" >> ~/.bashrc-intel
|
||||
echo "export LD_LIBRARY_PATH=\"\${INTEL_INSTALL_PATH}/ism/bin/intel64:\${INTEL_INSTALL_PATH}/lib/intel64_lin:\$LD_LIBRARY_PATH\"" >> ~/.bashrc-intel
|
||||
echo "export PATH=\"\${INTEL_INSTALL_PATH}/bin:\$PATH\"" >> ~/.bashrc-intel
|
||||
echo "function uninstall_intel_software {" >> ~/.bashrc-intel
|
||||
echo " find \"\${INTEL_INSTALL_PATH}\" -name 'uninstall.sh' -not -path '*/ism/uninstall.sh' -exec {} -s \;" >> ~/.bashrc-intel
|
||||
echo "}" >> ~/.bashrc-intel
|
||||
cat ~/.bashrc >> ~/.bashrc-intel
|
||||
mv ~/.bashrc-intel ~/.bashrc
|
||||
+14
-14
@@ -1,17 +1,17 @@
|
||||
# Copyright (C) 2000-2015, 2018 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/>.
|
||||
## Copyright (C) 2000-2015, 2018 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/>.
|
||||
|
||||
EXTRA_DIST += \
|
||||
build-aux/Darwin.valgrind \
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright (C) 2008-2015, 2018 Free Software Foundation, Inc.
|
||||
## Customize maint.mk -*- makefile -*-
|
||||
## Copyright (C) 2008-2015, 2018 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 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.
|
||||
## 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/>.
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Update version, then recompile so that tests/bison --version be
|
||||
# up-to-date, then compile our parser again with our up-to-date bison.
|
||||
@@ -26,11 +26,11 @@ regen: _version
|
||||
manual_title = The Yacc-compatible Parser Generator
|
||||
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
||||
|
||||
# It's useful to run maintainer-*check* targets during development, but we
|
||||
# It's useful to run maintainer-check* targets during development, but we
|
||||
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
||||
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
|
||||
# override the _is-dist-target from GNUmakefile so that maintainer-check*
|
||||
# targets are filtered out.
|
||||
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
|
||||
_is-dist-target = $(filter-out %clean maintainer-check%, \
|
||||
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
||||
|
||||
url_dir_list = \
|
||||
@@ -158,24 +158,21 @@ sc_space_before_open_paren:
|
||||
|
||||
exclude = \
|
||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||
$(call exclude, \
|
||||
bindtextdomain=^lib/main.c$$ \
|
||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||
program_name=^lib/main.c$$ \
|
||||
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
||||
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||
prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \
|
||||
prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \
|
||||
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||
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|tests/local\.at$$ \
|
||||
prohibit_tab_based_indentation=\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
|
||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
||||
space_before_open_paren=^(data/|djgpp/) \
|
||||
two_space_separator_in_usage=^(bootstrap) \
|
||||
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
||||
$(call exclude, \
|
||||
bindtextdomain=^lib/main.c$$ \
|
||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||
program_name=^lib/main.c$$ \
|
||||
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||
prohibit_always_true_header_tests=^djgpp/subpipe.h$$ \
|
||||
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|tests/local\.at$$ \
|
||||
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
|
||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
||||
space_before_open_paren=^(data/|djgpp/) \
|
||||
two_space_separator_in_usage=^(bootstrap|build-aux/install-icc.sh) \
|
||||
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
||||
)
|
||||
|
||||
+28
-13
@@ -21,7 +21,8 @@
|
||||
# better to avoid a typo in the 'configure --help' entry for the YACC
|
||||
# environment variable.
|
||||
AC_PREREQ([2.68])
|
||||
m4_pattern_forbid([^gl_[A-Z]])
|
||||
m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
|
||||
m4_pattern_allow([^BISON_USE_NLS$])
|
||||
|
||||
AC_INIT([GNU Bison],
|
||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||
@@ -70,6 +71,18 @@ AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
|
||||
[lv_cv_gcc_pragma_push_works=no])
|
||||
CFLAGS=$save_CFLAGS])
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
gl_WARN_ADD([-fno-exceptions], [NO_EXCEPTIONS_CXXFLAGS])
|
||||
BISON_CXXSTD([98])
|
||||
BISON_CXXSTD([03])
|
||||
BISON_CXXSTD([11])
|
||||
BISON_CXXSTD([14])
|
||||
BISON_CXXSTD([17])
|
||||
BISON_CXXSTD([2a])
|
||||
AM_CONDITIONAL([ENABLE_CXX11], [test x"$CXX11_CXXFLAGS" != x])
|
||||
AM_CONDITIONAL([ENABLE_CXX14], [test x"$CXX14_CXXFLAGS" != x])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
AC_ARG_ENABLE([gcc-warnings],
|
||||
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended).
|
||||
Also, issue synclines from the examples/ to
|
||||
@@ -81,7 +94,8 @@ AC_ARG_ENABLE([gcc-warnings],
|
||||
[enable_gcc_warnings=no])
|
||||
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
||||
if test "$enable_gcc_warnings" = yes; then
|
||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align -Wdocumentation
|
||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
|
||||
-fparse-all-comments -Wdocumentation
|
||||
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
|
||||
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
||||
warn_cxx='-Wnoexcept'
|
||||
@@ -94,7 +108,9 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
# -Wno-keyword-macro: We use the "#define private public" dirty
|
||||
# trick in the test suite to check some private implementation
|
||||
# details for lalr1.cc.
|
||||
warn_tests='-Wundef -pedantic -Wdeprecated -Wsign-compare -fno-color-diagnostics
|
||||
warn_tests='-Wundef -pedantic -Wconversion
|
||||
-Wdeprecated -Wsign-compare -Wsign-conversion
|
||||
-fno-color-diagnostics
|
||||
-Wno-keyword-macro'
|
||||
|
||||
AC_LANG_PUSH([C])
|
||||
@@ -124,7 +140,7 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
||||
|
||||
# Warnings for the test suite only.
|
||||
for i in $warn_tests;
|
||||
for i in $warn_tests -Wincompatible-pointer-types;
|
||||
do
|
||||
gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
|
||||
done
|
||||
@@ -146,17 +162,15 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
do
|
||||
gl_WARN_ADD([$i], [WARN_CXXFLAGS_TEST])
|
||||
done
|
||||
# Clang++ 3.2+ reject C code generated by Flex.
|
||||
gl_WARN_ADD([-Wno-null-conversion], [FLEX_SCANNER_CXXFLAGS])
|
||||
# So does G++ 4.8...
|
||||
gl_WARN_ADD([-Wno-sign-compare], [FLEX_SCANNER_CXXFLAGS])
|
||||
# ... possiby in std=c++11 mode.
|
||||
gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
|
||||
# Too many compilers complain about Flex generated code.
|
||||
gl_WARN_ADD([-Wno-error], [FLEX_SCANNER_CXXFLAGS])
|
||||
# Clang++ deprecates compiling C.
|
||||
gl_WARN_ADD([-Wno-deprecated], [WNO_DEPRECATED_CXXFLAGS])
|
||||
CXXFLAGS=$save_CXXFLAGS
|
||||
gl_WARN_ADD([-fno-exceptions], [CXXFLAGS_NO_EXCEPTIONS])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
|
||||
BISON_TEST_FOR_WORKING_C_COMPILER
|
||||
BISON_C_COMPILER_POSIXLY_CORRECT
|
||||
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
||||
@@ -204,7 +218,6 @@ gl_INIT
|
||||
# Checks for library functions.
|
||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||
AM_WITH_DMALLOC
|
||||
BISON_PREREQ_TIMEVAR
|
||||
|
||||
# Gettext.
|
||||
# We use gnulib, which is only guaranteed to work properly with the
|
||||
@@ -243,6 +256,8 @@ case $VALGRIND:$uname in
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
AC_MSG_CHECKING([Valgrind suppression file])
|
||||
AC_MSG_RESULT([$suppfile])
|
||||
|
||||
# Whether we cannot run the compiled bison.
|
||||
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
||||
@@ -251,7 +266,7 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||
# Needed by tests/atlocal.in.
|
||||
AC_SUBST([GCC])
|
||||
|
||||
gt_JAVACOMP([1.3], [1.4])
|
||||
gt_JAVACOMP([1.7], [1.7])
|
||||
gt_JAVAEXEC
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
|
||||
+103
-42
@@ -22,12 +22,17 @@
|
||||
## Identification. ##
|
||||
## ---------------- ##
|
||||
|
||||
# b4_generated_by
|
||||
# ---------------
|
||||
m4_define([b4_generated_by],
|
||||
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
||||
])
|
||||
|
||||
# b4_copyright(TITLE, [YEARS])
|
||||
# ----------------------------
|
||||
# If YEARS are not defined, use b4_copyright_years.
|
||||
m4_define([b4_copyright],
|
||||
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
||||
|
||||
[b4_generated_by
|
||||
b4_comment([$1
|
||||
|
||||
]m4_dquote(m4_text_wrap([Copyright (C)
|
||||
@@ -58,26 +63,49 @@ Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison.])])
|
||||
version 2.2 of Bison.])
|
||||
])
|
||||
|
||||
|
||||
# b4_disclaimer
|
||||
# -------------
|
||||
# Issue a warning about private implementation details.
|
||||
m4_define([b4_disclaimer],
|
||||
[b4_comment([Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them.])
|
||||
])
|
||||
|
||||
|
||||
|
||||
# b4_required_version_if(VERSION, IF_NEWER, IF_OLDER)
|
||||
# ---------------------------------------------------
|
||||
# If the version %require'd by the user is VERSION (or newer) expand
|
||||
# IF_NEWER, otherwise IF_OLDER. VERSION should be an integer, e.g.,
|
||||
# 302 for 3.2.
|
||||
m4_define([b4_required_version_if],
|
||||
[m4_if(m4_eval($1 <= b4_required_version),
|
||||
[1], [$2], [$3])])
|
||||
|
||||
|
||||
## -------- ##
|
||||
## Output. ##
|
||||
## -------- ##
|
||||
|
||||
# b4_output_begin(FILE)
|
||||
# ---------------------
|
||||
# b4_output_begin(FILE1, FILE2)
|
||||
# -----------------------------
|
||||
# Enable output, i.e., send to diversion 0, expand after "#", and
|
||||
# generate the tag to output into FILE. Must be followed by EOL.
|
||||
# FILE is FILE1 concatenated to FILE2. FILE2 can be empty, or be
|
||||
# absolute: do the right thing.
|
||||
m4_define([b4_output_begin],
|
||||
[m4_changecom()
|
||||
m4_divert_push(0)dnl
|
||||
@output(m4_unquote([$1])@)@dnl
|
||||
@output(m4_unquote([$1])@,m4_unquote([$2])@)@dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_output_end()
|
||||
# ---------------
|
||||
# b4_output_end
|
||||
# -------------
|
||||
# Output nothing, restore # as comment character (no expansions after #).
|
||||
m4_define([b4_output_end],
|
||||
[m4_divert_pop(0)
|
||||
@@ -389,11 +417,11 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||
#
|
||||
# The following macros provide access to these values.
|
||||
|
||||
# b4_symbol_(NUM, FIELD)
|
||||
# _b4_symbol(NUM, FIELD)
|
||||
# ----------------------
|
||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||
# undefined.
|
||||
m4_define([b4_symbol_],
|
||||
m4_define([_b4_symbol],
|
||||
[m4_indir([b4_symbol($1, $2)])])
|
||||
|
||||
|
||||
@@ -404,8 +432,8 @@ m4_define([b4_symbol_],
|
||||
m4_define([b4_symbol],
|
||||
[m4_case([$2],
|
||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
||||
[b4_symbol_([$1], [id])])],
|
||||
[b4_symbol_($@)])])
|
||||
[_b4_symbol([$1], [id])])],
|
||||
[_b4_symbol($@)])])
|
||||
|
||||
|
||||
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
||||
@@ -443,7 +471,7 @@ m4_define([b4_symbol_action],
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[m4_dquote(b4_symbol([$1], [type]))]),
|
||||
[(*yylocationp)])dnl
|
||||
b4_symbol_case_([$1])[]dnl
|
||||
_b4_symbol_case([$1])[]dnl
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
@@ -478,10 +506,10 @@ m4_ifval(m4_defn([b4_actions_]),
|
||||
m4_popdef([b4_actions_])dnl
|
||||
])
|
||||
|
||||
# b4_symbol_case_(SYMBOL-NUM)
|
||||
# _b4_symbol_case(SYMBOL-NUM)
|
||||
# ---------------------------
|
||||
# Issue a "case NUM" for SYMBOL-NUM.
|
||||
m4_define([b4_symbol_case_],
|
||||
m4_define([_b4_symbol_case],
|
||||
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
||||
])
|
||||
|
||||
@@ -536,16 +564,16 @@ m4_define([b4_token_format],
|
||||
## Types. ##
|
||||
## ------- ##
|
||||
|
||||
# b4_type_action_(NUMS)
|
||||
# _b4_type_action(NUMS)
|
||||
# ---------------------
|
||||
# Run actions for the symbol NUMS that all have the same type-name.
|
||||
# Skip NUMS that have no type-name.
|
||||
#
|
||||
# To specify the action to run, define b4_dollar_dollar(NUMBER,
|
||||
# TAG, TYPE).
|
||||
m4_define([b4_type_action_],
|
||||
m4_define([_b4_type_action],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[m4_map([ b4_symbol_case_], [$@])[]dnl
|
||||
[m4_map([ _b4_symbol_case], [$@])[]dnl
|
||||
b4_dollar_dollar([b4_symbol([$1], [number])],
|
||||
[b4_symbol([$1], [tag])],
|
||||
[b4_symbol([$1], [type])]);
|
||||
@@ -601,13 +629,15 @@ m4_define([b4_user_code],
|
||||
b4_syncline([@oline@], [@ofile@])])
|
||||
|
||||
|
||||
# b4_define_user_code(MACRO)
|
||||
# --------------------------
|
||||
# From b4_MACRO, build b4_user_MACRO that includes the synclines.
|
||||
# b4_define_user_code(MACRO, COMMENT)
|
||||
# -----------------------------------
|
||||
# From b4_MACRO, if defined, build b4_user_MACRO that includes the synclines.
|
||||
m4_define([b4_define_user_code],
|
||||
[m4_define([b4_user_$1],
|
||||
[b4_user_code([b4_$1])])])
|
||||
|
||||
[m4_ifdef([b4_$1],
|
||||
[m4_ifval([$2],
|
||||
[b4_comment([$2])
|
||||
])b4_user_code([b4_$1])])])])
|
||||
|
||||
# b4_user_actions
|
||||
# b4_user_initial_action
|
||||
@@ -617,9 +647,9 @@ m4_define([b4_define_user_code],
|
||||
# ----------------------
|
||||
# Macros that issue user code, ending with synclines.
|
||||
b4_define_user_code([actions])
|
||||
b4_define_user_code([initial_action])
|
||||
b4_define_user_code([post_prologue])
|
||||
b4_define_user_code([pre_prologue])
|
||||
b4_define_user_code([initial_action], [User initialization code.])
|
||||
b4_define_user_code([post_prologue], [Second part of user prologue.])
|
||||
b4_define_user_code([pre_prologue], [First part of user prologue.])
|
||||
b4_define_user_code([union_members])
|
||||
|
||||
|
||||
@@ -701,7 +731,7 @@ m4_define([b4_percent_define_use],
|
||||
# b4_percent_define_get([[foo]])
|
||||
m4_define([b4_percent_define_get],
|
||||
[b4_percent_define_use([$1])dnl
|
||||
b4_percent_define_ifdef_([$1],
|
||||
_b4_percent_define_ifdef([$1],
|
||||
[m4_indir([b4_percent_define(]$1[)])],
|
||||
[$2])])
|
||||
|
||||
@@ -710,7 +740,7 @@ b4_percent_define_ifdef_([$1],
|
||||
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
||||
# if the %define variable VARIABLE is undefined, complain fatally since that's
|
||||
# a Bison or skeleton error. Otherwise, return its definition location in a
|
||||
# form approriate for the first two arguments of b4_warn_at, b4_complain_at, or
|
||||
# form appropriate for the first two arguments of b4_warn_at, b4_complain_at, or
|
||||
# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no
|
||||
# reason to suspect that the user-supplied value has yet influenced the output.
|
||||
#
|
||||
@@ -755,15 +785,15 @@ m4_define([b4_percent_define_get_syncline],
|
||||
[m4_indir([b4_percent_define_syncline(]$1[)])],
|
||||
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
||||
|
||||
# b4_percent_define_ifdef_(VARIABLE, IF-TRUE, [IF-FALSE])
|
||||
# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
|
||||
# ------------------------------------------------------
|
||||
# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
|
||||
# IF-FALSE. Don't record usage of VARIABLE.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# b4_percent_define_ifdef_([[foo]], [[it's defined]], [[it's undefined]])
|
||||
m4_define([b4_percent_define_ifdef_],
|
||||
# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||
m4_define([_b4_percent_define_ifdef],
|
||||
[m4_ifdef([b4_percent_define(]$1[)],
|
||||
[$2],
|
||||
[$3])])
|
||||
@@ -779,11 +809,44 @@ m4_define([b4_percent_define_ifdef_],
|
||||
#
|
||||
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||
m4_define([b4_percent_define_ifdef],
|
||||
[b4_percent_define_ifdef_([$1],
|
||||
[_b4_percent_define_ifdef([$1],
|
||||
[b4_percent_define_use([$1])$2],
|
||||
[$3])])
|
||||
|
||||
|
||||
# b4_percent_define_check_file_complain(VARIABLE)
|
||||
# -----------------------------------------------
|
||||
# Warn about %define variable VARIABLE having an incorrect
|
||||
# value.
|
||||
m4_define([b4_percent_define_check_file_complain],
|
||||
[b4_complain_at(b4_percent_define_get_loc([$1]),
|
||||
[[%%define variable '%s' requires 'none' or '"..."' values]],
|
||||
[$1])])
|
||||
|
||||
|
||||
# b4_percent_define_check_file(MACRO, VARIABLE, DEFAULT)
|
||||
# ------------------------------------------------------
|
||||
# If the %define variable VARIABLE:
|
||||
# - is undefined, then if DEFAULT is non-empty, define MACRO to DEFAULT
|
||||
# - is a string, define MACRO to its value
|
||||
# - is the keyword 'none', do nothing
|
||||
# - otherwise, warn about the incorrect value.
|
||||
m4_define([b4_percent_define_check_file],
|
||||
[b4_percent_define_ifdef([$2],
|
||||
[m4_case(b4_percent_define_get_kind([$2]),
|
||||
[string],
|
||||
[m4_define([$1], b4_percent_define_get([$2]))],
|
||||
[keyword],
|
||||
[m4_if(b4_percent_define_get([$2]), [none], [],
|
||||
[b4_percent_define_check_file_complain([$2])])],
|
||||
[b4_percent_define_check_file_complain([$2])])
|
||||
],
|
||||
[m4_ifval([$3],
|
||||
[m4_define([$1], [$3])])])
|
||||
])
|
||||
|
||||
|
||||
|
||||
## --------- ##
|
||||
## Options. ##
|
||||
## --------- ##
|
||||
@@ -824,7 +887,7 @@ m4_define([b4_percent_define_flag_if],
|
||||
#
|
||||
# b4_percent_define_default([[foo]], [[default value]])
|
||||
m4_define([b4_percent_define_default],
|
||||
[b4_percent_define_ifdef_([$1], [],
|
||||
[_b4_percent_define_ifdef([$1], [],
|
||||
[m4_define([b4_percent_define(]$1[)], [$2])dnl
|
||||
m4_define([b4_percent_define_kind(]$1[)],
|
||||
[m4_default([$3], [keyword])])dnl
|
||||
@@ -839,26 +902,26 @@ m4_define([b4_percent_define_default],
|
||||
# Define b4_NAME_if that executes its $1 or $2 depending whether
|
||||
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
|
||||
# to '_'.
|
||||
m4_define([b4_percent_define_if_define_],
|
||||
m4_define([_b4_percent_define_if_define],
|
||||
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
||||
[b4_percent_define_flag_if(m4_default([$2], [$1]),
|
||||
[$3], [$4])])])
|
||||
m4_define([b4_percent_define_if_define],
|
||||
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
|
||||
b4_percent_define_if_define_([$1], [$2], $[1], $[2])])
|
||||
_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
|
||||
|
||||
|
||||
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
|
||||
# ---------------------------------------------------------------------
|
||||
m4_define([b4_percent_define_check_kind],
|
||||
[b4_percent_define_ifdef_([$1],
|
||||
[_b4_percent_define_ifdef([$1],
|
||||
[m4_if(b4_percent_define_get_kind([$1]), [$2], [],
|
||||
[b4_error([m4_default([$3], [complain])],
|
||||
b4_percent_define_get_loc([$1]),
|
||||
[m4_case([$2],
|
||||
[code], [[%%define variable '%s' requires '{...}' values]],
|
||||
[code], [[%%define variable '%s' requires '{...}' values]],
|
||||
[keyword], [[%%define variable '%s' requires keyword values]],
|
||||
[string], [[%%define variable '%s' requires '"..."' values]])],
|
||||
[string], [[%%define variable '%s' requires '"..."' values]])],
|
||||
[$1])])])dnl
|
||||
])
|
||||
|
||||
@@ -884,7 +947,7 @@ m4_define([b4_percent_define_check_values],
|
||||
[_b4_percent_define_check_values(b4_sublist)])])
|
||||
|
||||
m4_define([_b4_percent_define_check_values],
|
||||
[b4_percent_define_ifdef_([$1],
|
||||
[_b4_percent_define_ifdef([$1],
|
||||
[b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl
|
||||
m4_pushdef([b4_good_value], [0])dnl
|
||||
m4_if($#, 1, [],
|
||||
@@ -946,7 +1009,7 @@ m4_define([b4_percent_code_ifdef],
|
||||
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
|
||||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
||||
# ----------------------------------------------
|
||||
# ----------------------------------------------------------
|
||||
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||
b4_percent_define_if_define([parse.assert])
|
||||
@@ -1011,8 +1074,6 @@ b4_check_user_names_wrap([[code]], [[qualifier]])
|
||||
## ---------------- ##
|
||||
|
||||
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
||||
m4_define_default([b4_pre_prologue], [])
|
||||
m4_define_default([b4_post_prologue], [])
|
||||
m4_define_default([b4_epilogue], [])
|
||||
m4_define_default([b4_parse_param], [])
|
||||
|
||||
|
||||
+72
-39
@@ -24,11 +24,20 @@ b4_percent_define_ifdef([[api.value.union.name]],
|
||||
|
||||
m4_include(b4_pkgdatadir/[c.m4])
|
||||
|
||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
|
||||
|
||||
|
||||
## ----- ##
|
||||
## C++. ##
|
||||
## ----- ##
|
||||
|
||||
# b4_comment(TEXT, [PREFIX])
|
||||
# --------------------------
|
||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment],
|
||||
[b4_comment_([$1], [$2// ], [$2// ])])
|
||||
[_b4_comment([$1], [$2// ], [$2// ])])
|
||||
|
||||
|
||||
# b4_inline(hh|cc)
|
||||
# ----------------
|
||||
@@ -40,12 +49,26 @@ m4_define([b4_inline],
|
||||
]],
|
||||
[m4_fatal([$0: invalid argument: $1])])])
|
||||
|
||||
## -------- ##
|
||||
## Checks. ##
|
||||
## -------- ##
|
||||
|
||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
|
||||
# b4_cxx_portability
|
||||
# ------------------
|
||||
m4_define([b4_cxx_portability],
|
||||
[// Support move semantics when possible.
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
# define YY_MOVE std::move
|
||||
# define YY_MOVE_OR_COPY move
|
||||
# define YY_MOVE_REF(Type) Type&&
|
||||
# define YY_RVREF(Type) Type&&
|
||||
# define YY_COPY(Type) Type
|
||||
#else
|
||||
# define YY_MOVE
|
||||
# define YY_MOVE_OR_COPY copy
|
||||
# define YY_MOVE_REF(Type) Type&
|
||||
# define YY_RVREF(Type) const Type&
|
||||
# define YY_COPY(Type) const Type&
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
@@ -88,7 +111,7 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
||||
[[namespace reference is empty]])])
|
||||
|
||||
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
||||
# invalid b4_namepsace_ref that would be converted to a valid
|
||||
# invalid b4_namespace_ref that would be converted to a valid
|
||||
# b4_namespace_open. The problem is that Bison doesn't always output
|
||||
# b4_namespace_ref to uncommented code but should reserve the ability to do so
|
||||
# in future releases without risking breaking any existing user grammars.
|
||||
@@ -192,11 +215,18 @@ m4_define([b4_public_types_declare],
|
||||
|
||||
/// Internal symbol number for tokens (subsumed by symbol_number_type).
|
||||
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
|
||||
]])
|
||||
|
||||
/// A complete symbol.
|
||||
|
||||
# b4_symbol_type_declare
|
||||
# ----------------------
|
||||
# Define symbol_type, the external type for symbols used for symbol
|
||||
# constructors.
|
||||
m4_define([b4_symbol_type_declare],
|
||||
[[ /// A complete symbol.
|
||||
///
|
||||
/// Expects its Base type to provide access to the symbol type
|
||||
/// via type_get().
|
||||
/// via type_get ().
|
||||
///
|
||||
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
||||
template <typename Base>
|
||||
@@ -208,19 +238,20 @@ m4_define([b4_public_types_declare],
|
||||
/// Default constructor.
|
||||
basic_symbol ();
|
||||
|
||||
/// Copy constructor.
|
||||
basic_symbol (const basic_symbol& other);
|
||||
/// Move or copy constructor.
|
||||
basic_symbol (YY_RVREF (basic_symbol) other);
|
||||
|
||||
]b4_variant_if([[
|
||||
/// Constructor for valueless symbols, and symbols from each type.
|
||||
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
||||
/// Constructor for valueless symbols.
|
||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
||||
const location_type& l])[);]])[
|
||||
YY_MOVE_REF (location_type) l])[);
|
||||
|
||||
/// Constructor for symbols with semantic value.
|
||||
basic_symbol (typename Base::kind_type t,
|
||||
const semantic_type& v]b4_locations_if([,
|
||||
const location_type& l])[);
|
||||
YY_RVREF (semantic_type) v]b4_locations_if([,
|
||||
YY_RVREF (location_type) l])[);]])[
|
||||
|
||||
/// Destroy the symbol.
|
||||
~basic_symbol ();
|
||||
@@ -241,8 +272,10 @@ m4_define([b4_public_types_declare],
|
||||
location_type location;])[
|
||||
|
||||
private:
|
||||
#if !defined __cplusplus || __cplusplus < 201103L
|
||||
/// Assignment operator.
|
||||
basic_symbol& operator= (const basic_symbol& other);
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Type access provider for token (enum) based symbols.
|
||||
@@ -281,8 +314,7 @@ m4_define([b4_public_types_declare],
|
||||
|
||||
/// "External" symbols: returned by the scanner.
|
||||
typedef basic_symbol<by_type> symbol_type;
|
||||
|
||||
]b4_symbol_constructor_declare])
|
||||
]])
|
||||
|
||||
|
||||
# b4_public_types_define(hh|cc)
|
||||
@@ -302,27 +334,15 @@ m4_define([b4_public_types_define],
|
||||
{}
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
|
||||
: Base (other)
|
||||
, value (]b4_variant_if([], [other.value])[)]b4_locations_if([
|
||||
, location (other.location)])[
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (YY_RVREF (basic_symbol) other)
|
||||
: Base (YY_MOVE (other))
|
||||
, value (]b4_variant_if([], [YY_MOVE (other.value)]))b4_locations_if([
|
||||
, location (YY_MOVE (other.location))])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([other.type_get ()], [value], [copy],
|
||||
[other.value])])[
|
||||
b4_symbol_variant([other.type_get ()], [value], [YY_MOVE_OR_COPY],
|
||||
[YY_MOVE (other.value)])])[
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
[const semantic_type& v],
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
: Base (t)
|
||||
, value (]b4_variant_if([], [v])[)]b4_locations_if([
|
||||
, location (l)])[
|
||||
{]b4_variant_if([[
|
||||
(void) v;
|
||||
]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[}
|
||||
|
||||
]b4_variant_if([[
|
||||
// Implementation of basic_symbol constructor for each type.
|
||||
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
||||
@@ -330,11 +350,23 @@ m4_define([b4_public_types_define],
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value ()]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}]])[
|
||||
{}
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
[YY_RVREF (semantic_type) v],
|
||||
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([
|
||||
, location (YY_MOVE (l))])[
|
||||
{]b4_variant_if([[
|
||||
(void) v;
|
||||
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
||||
@@ -375,9 +407,9 @@ m4_define([b4_public_types_define],
|
||||
{
|
||||
super_type::move (s);
|
||||
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
||||
[s.value])],
|
||||
[value = s.value;])[]b4_locations_if([
|
||||
location = s.location;])[
|
||||
[YY_MOVE (s.value)])],
|
||||
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
||||
location = YY_MOVE (s.location);])[
|
||||
}
|
||||
|
||||
// by_type.
|
||||
@@ -426,6 +458,7 @@ m4_define([b4_public_types_define],
|
||||
return static_cast<token_type> (yytoken_number_[type]);
|
||||
}
|
||||
]])[]dnl
|
||||
|
||||
b4_symbol_constructor_define])
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -17,14 +17,14 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# b4_comment_(TEXT, OPEN, CONTINUE, END)
|
||||
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
||||
# --------------------------------------
|
||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||
# Avoid adding indentation to the first line, as the indentation comes
|
||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||
#
|
||||
# Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment_],
|
||||
m4_define([_b4_comment],
|
||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
||||
\(.\)], [
|
||||
$3\1])$4])
|
||||
@@ -34,17 +34,17 @@ $3\1])$4])
|
||||
# --------------------------
|
||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment],
|
||||
[b4_comment_([$1], [$2/* ], [$2 ], [ */])])
|
||||
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
|
||||
|
||||
|
||||
|
||||
|
||||
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
|
||||
# _b4_dollar_dollar(VALUE, FIELD, DEFAULT-FIELD)
|
||||
# ----------------------------------------------
|
||||
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
||||
# pointer.
|
||||
m4_define([b4_dollar_dollar_],
|
||||
m4_define([_b4_dollar_dollar],
|
||||
[b4_symbol_value([$1],
|
||||
m4_if([$2], [[]],
|
||||
[[$3]], [[$2]]))])
|
||||
@@ -56,7 +56,7 @@ m4_define([b4_dollar_dollar_],
|
||||
# and b4_at_dollar for LOCATION.
|
||||
m4_define([b4_dollar_pushdef],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
|
||||
[_b4_dollar_dollar([$1], m4_dquote($][1), [$2])])dnl
|
||||
m4_pushdef([b4_at_dollar], [$3])dnl
|
||||
])
|
||||
m4_define([b4_dollar_popdef],
|
||||
|
||||
@@ -204,11 +204,12 @@ m4_define([b4_table_value_equals],
|
||||
## Compiler issues. ##
|
||||
## ----------------- ##
|
||||
|
||||
# b4_attribute_define
|
||||
# -------------------
|
||||
# Provide portable compiler "attributes".
|
||||
# b4_attribute_define([noreturn])
|
||||
# -------------------------------
|
||||
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
||||
# _Noreturn.
|
||||
m4_define([b4_attribute_define],
|
||||
[#ifndef YY_ATTRIBUTE
|
||||
[[#ifndef YY_ATTRIBUTE
|
||||
# if (defined __GNUC__ \
|
||||
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|
||||
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
|
||||
@@ -226,16 +227,23 @@ m4_define([b4_attribute_define],
|
||||
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
|
||||
#endif
|
||||
|
||||
#if !defined _Noreturn \
|
||||
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
|
||||
# if defined _MSC_VER && 1200 <= _MSC_VER
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
|
||||
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
||||
#if ! defined _Noreturn
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
# define _Noreturn [[noreturn]]
|
||||
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
|
||||
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|
||||
|| 0x5110 <= __SUNPRO_C)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif defined _MSC_VER && 1200 <= _MSC_VER
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Suppress unused-variable warnings by "using" E. */
|
||||
]])[/* Suppress unused-variable warnings by "using" E. */
|
||||
#if ! defined lint || defined __GNUC__
|
||||
# define YYUSE(E) ((void) (E))
|
||||
#else
|
||||
@@ -260,24 +268,26 @@ m4_define([b4_attribute_define],
|
||||
#ifndef YY_INITIAL_VALUE
|
||||
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
||||
#endif
|
||||
])
|
||||
|
||||
|
||||
## ---------##
|
||||
## Values. ##
|
||||
## ---------##
|
||||
]])
|
||||
|
||||
|
||||
# b4_null_define
|
||||
# --------------
|
||||
# Portability issues: define a YY_NULLPTR appropriate for the current
|
||||
# language (C, C++98, or C++11).
|
||||
#
|
||||
# In C++ pre C++11 it is standard practice to use 0 (not NULL) for the
|
||||
# null pointer. In C, prefer ((void*)0) to avoid having to include stdlib.h.
|
||||
m4_define([b4_null_define],
|
||||
[# ifndef YY_NULLPTR
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
# define YY_NULLPTR nullptr
|
||||
# if defined __cplusplus
|
||||
# if 201103L <= __cplusplus
|
||||
# define YY_NULLPTR nullptr
|
||||
# else
|
||||
# define YY_NULLPTR 0
|
||||
# endif
|
||||
# else
|
||||
# define YY_NULLPTR 0
|
||||
# define YY_NULLPTR ((void*)0)
|
||||
# endif
|
||||
# endif[]dnl
|
||||
])
|
||||
@@ -288,6 +298,12 @@ m4_define([b4_null_define],
|
||||
# Return a null pointer constant.
|
||||
m4_define([b4_null], [YY_NULLPTR])
|
||||
|
||||
|
||||
|
||||
## ---------##
|
||||
## Values. ##
|
||||
## ---------##
|
||||
|
||||
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
||||
# -------------------------------------------------------------
|
||||
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
||||
@@ -361,7 +377,7 @@ m4_define([b4_token_enums_defines],
|
||||
# ----------------------------
|
||||
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
|
||||
# TYPE if TYPE is given, otherwise just return VAL. The result can be
|
||||
# used safetly, it is put in parens to avoid nasty precedence issues.
|
||||
# used safely, it is put in parens to avoid nasty precedence issues.
|
||||
# TYPE is *not* put in braces, provide some if needed.
|
||||
m4_define([b4_symbol_value],
|
||||
[($1[]m4_ifval([$2], [.$2]))])
|
||||
@@ -498,54 +514,54 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
# Define the "yy_symbol_print" function.
|
||||
m4_define_default([b4_yy_symbol_print_define],
|
||||
[[
|
||||
/*----------------------------------------.
|
||||
| Print this symbol's value on YYOUTPUT. |
|
||||
`----------------------------------------*/
|
||||
/*-----------------------------------.
|
||||
| Print this symbol's value on YYO. |
|
||||
`-----------------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_value_print],
|
||||
[static void],
|
||||
[[FILE *yyoutput], [yyoutput]],
|
||||
[[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]))[
|
||||
{
|
||||
FILE *yyo = yyoutput;
|
||||
]b4_parse_param_use([yyo], [yylocationp])dnl
|
||||
FILE *yyoutput = yyo;
|
||||
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
||||
[ if (!yyvaluep)
|
||||
return;]
|
||||
dnl glr.c does not feature yytoknum.
|
||||
m4_if(b4_skeleton, ["yacc.c"],
|
||||
[[# ifdef YYPRINT
|
||||
if (yytype < YYNTOKENS)
|
||||
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
||||
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
||||
# endif
|
||||
]])dnl
|
||||
b4_symbol_actions([printer])[
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
/*---------------------------.
|
||||
| Print this symbol on YYO. |
|
||||
`---------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *yyoutput], [yyoutput]],
|
||||
[[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]))[
|
||||
{
|
||||
YYFPRINTF (yyoutput, "%s %s (",
|
||||
YYFPRINTF (yyo, "%s %s (",
|
||||
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
|
||||
|
||||
]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
YYFPRINTF (yyoutput, ": ");
|
||||
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
|
||||
YYFPRINTF (yyo, ": ");
|
||||
])dnl
|
||||
[ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl
|
||||
[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
|
||||
b4_locations_if([, yylocationp])[]b4_user_args[);
|
||||
YYFPRINTF (yyoutput, ")");
|
||||
YYFPRINTF (yyo, ")");
|
||||
}]dnl
|
||||
])
|
||||
|
||||
@@ -807,11 +823,11 @@ m4_define([b4_yy_location_print_define],
|
||||
|
||||
YY_ATTRIBUTE_UNUSED
|
||||
]b4_function_define([yy_location_print_],
|
||||
[static unsigned],
|
||||
[static int],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[YYLTYPE const * const yylocp], [yylocp]])[
|
||||
{
|
||||
unsigned res = 0;
|
||||
int res = 0;
|
||||
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||
if (0 <= yylocp->first_line)
|
||||
{
|
||||
|
||||
+45
-42
@@ -199,11 +199,10 @@ m4_if(b4_skeleton, ["glr.c"],
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||
[2002-2015, 2018])[
|
||||
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]b4_output_end()
|
||||
]b4_output_end
|
||||
])])
|
||||
|
||||
|
||||
@@ -214,12 +213,12 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
||||
[2002-2015, 2018])[
|
||||
|
||||
/* C GLR parser skeleton written by Paul Hilfinger. */
|
||||
|
||||
]b4_identification
|
||||
]b4_disclaimer[
|
||||
]b4_identification[
|
||||
|
||||
b4_percent_code_get([[top]])[
|
||||
]b4_percent_code_get([[top]])[
|
||||
]m4_if(b4_api_prefix, [yy], [],
|
||||
[[/* Substitute the type names. */
|
||||
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
||||
@@ -236,7 +235,6 @@ b4_percent_code_get([[top]])[
|
||||
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
||||
#define yylloc ]b4_prefix[lloc]])]))[
|
||||
|
||||
/* First part of user declarations. */
|
||||
]b4_user_pre_prologue[
|
||||
|
||||
]b4_null_define[
|
||||
@@ -259,9 +257,8 @@ b4_percent_code_get([[top]])[
|
||||
static YYSTYPE yyval_default;]b4_locations_if([[
|
||||
static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
]b4_user_post_prologue
|
||||
b4_percent_code_get[]dnl
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
[#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -292,22 +289,29 @@ b4_percent_code_get[]dnl
|
||||
#define YYSIZEMAX ((size_t) -1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef bool yybool;
|
||||
typedef bool yybool;
|
||||
# define yytrue true
|
||||
# define yyfalse false
|
||||
#else
|
||||
typedef unsigned char yybool;
|
||||
/* When we move to stdbool, get rid of the various casts to yybool. */
|
||||
typedef unsigned char yybool;
|
||||
# define yytrue 1
|
||||
# define yyfalse 0
|
||||
#endif
|
||||
#define yytrue 1
|
||||
#define yyfalse 0
|
||||
|
||||
#ifndef YYSETJMP
|
||||
# include <setjmp.h>
|
||||
# define YYJMP_BUF jmp_buf
|
||||
# define YYSETJMP(Env) setjmp (Env)
|
||||
/* Pacify clang. */
|
||||
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
|
||||
/* Pacify Clang and ICC. */
|
||||
# define YYLONGJMP(Env, Val) \
|
||||
do { \
|
||||
longjmp (Env, Val); \
|
||||
YYASSERT (0); \
|
||||
} while (yyfalse)
|
||||
#endif
|
||||
|
||||
]b4_attribute_define[
|
||||
]b4_attribute_define([noreturn])[
|
||||
|
||||
#ifndef YYASSERT
|
||||
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
|
||||
@@ -597,7 +601,7 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
if (! yyres)
|
||||
return strlen (yystr);
|
||||
|
||||
return yystpcpy (yyres, yystr) - yyres;
|
||||
return (size_t) (yystpcpy (yyres, yystr) - yyres);
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -776,11 +780,11 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
||||
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
||||
* yyerr for YYERROR, yyabort for YYABORT. */
|
||||
static YYRESULTTAG
|
||||
yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
|
||||
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
||||
yyGLRStack* yystackp,
|
||||
YYSTYPE* yyvalp]b4_locuser_formals[)
|
||||
{
|
||||
yybool yynormal YY_ATTRIBUTE_UNUSED = (yystackp->yysplitPoint == YY_NULLPTR);
|
||||
yybool yynormal YY_ATTRIBUTE_UNUSED = (yybool) (yystackp->yysplitPoint == YY_NULLPTR);
|
||||
int yylow;
|
||||
]b4_parse_param_use([yyvalp], [yylocp])dnl
|
||||
[ YYUSE (yyrhslen);
|
||||
@@ -797,7 +801,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
|
||||
# undef yyclearin
|
||||
# define yyclearin (yychar = YYEMPTY)
|
||||
# undef YYFILL
|
||||
# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
|
||||
# define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
|
||||
# undef YYBACKUP
|
||||
# define YYBACKUP(Token, Value) \
|
||||
return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
|
||||
@@ -814,7 +818,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
|
||||
]])[
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_user_actions[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -900,7 +904,7 @@ yylhsNonterm (yyRuleNum yyrule)
|
||||
static inline yybool
|
||||
yyisDefaultedState (yyStateNum yystate)
|
||||
{
|
||||
return yypact_value_is_default (yypact[yystate]);
|
||||
return (yybool) yypact_value_is_default (yypact[yystate]);
|
||||
}
|
||||
|
||||
/** The default reduction for YYSTATE, assuming it has one. */
|
||||
@@ -926,7 +930,7 @@ yygetLRActions (yyStateNum yystate, int yytoken,
|
||||
int* yyaction, const short** yyconflicts)
|
||||
{
|
||||
int yyindex = yypact[yystate] + yytoken;
|
||||
if (yypact_value_is_default (yypact[yystate])
|
||||
if (yyisDefaultedState (yystate)
|
||||
|| yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
|
||||
{
|
||||
*yyaction = -yydefact[yystate];
|
||||
@@ -961,13 +965,13 @@ yyLRgotoState (yyStateNum yystate, yySymbol yysym)
|
||||
static inline yybool
|
||||
yyisShiftAction (int yyaction)
|
||||
{
|
||||
return 0 < yyaction;
|
||||
return (yybool) (0 < yyaction);
|
||||
}
|
||||
|
||||
static inline yybool
|
||||
yyisErrorAction (int yyaction)
|
||||
{
|
||||
return yyaction == 0;
|
||||
return (yybool) (yyaction == 0);
|
||||
}
|
||||
|
||||
/* GLRStates */
|
||||
@@ -1077,7 +1081,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
|
||||
yyGLRStackItem* yyp0, *yyp1;
|
||||
size_t yynewSize;
|
||||
size_t yyn;
|
||||
size_t yysize = yystackp->yynextFree - yystackp->yyitems;
|
||||
size_t yysize = (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
if (YYMAXDEPTH - YYHEADROOM < yysize)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yynewSize = 2*yysize;
|
||||
@@ -1260,7 +1264,7 @@ do { \
|
||||
`----------------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
yyRuleNum yyrule]b4_user_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
||||
@@ -1277,8 +1281,8 @@ yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||
yy_symbol_print (stderr,
|
||||
yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
|
||||
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
|
||||
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval]b4_locations_if([,
|
||||
&]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||
b4_user_args[);
|
||||
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
|
||||
YYFPRINTF (stderr, " (unresolved)");
|
||||
@@ -1305,9 +1309,9 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
||||
YYASSERT (yyk == 0);
|
||||
yystackp->yynextFree -= yynrhs;
|
||||
yystackp->yyspaceLeft += yynrhs;
|
||||
yystackp->yyspaceLeft += (size_t) yynrhs;
|
||||
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
||||
YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
|
||||
YY_REDUCE_PRINT ((yytrue, yyrhs, yyk, yyrule]b4_user_args[));
|
||||
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
|
||||
yyvalp]b4_locuser_args[);
|
||||
}
|
||||
@@ -1328,7 +1332,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
}
|
||||
yyupdateSplit (yystackp, yys);
|
||||
yystackp->yytops.yystates[yyk] = yys;
|
||||
YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
|
||||
YY_REDUCE_PRINT ((yyfalse, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
|
||||
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
||||
yystackp, yyvalp]b4_locuser_args[);
|
||||
}
|
||||
@@ -1424,11 +1428,9 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
}
|
||||
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
|
||||
{
|
||||
yyGLRState** yynewStates;
|
||||
yyGLRState** yynewStates = YY_NULLPTR;
|
||||
yybool* yynewLookaheadNeeds;
|
||||
|
||||
yynewStates = YY_NULLPTR;
|
||||
|
||||
if (yystackp->yytops.yycapacity
|
||||
> (YYSIZEMAX / (2 * sizeof yynewStates[0])))
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1856,9 +1858,9 @@ yycompressStack (yyGLRStack* yystackp)
|
||||
yyr = yyp, yyp = yyq, yyq = yyp->yypred)
|
||||
yyp->yypred = yyr;
|
||||
|
||||
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
|
||||
yystackp->yyspaceLeft += (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
|
||||
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
|
||||
yystackp->yyspaceLeft -= (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
yystackp->yysplitPoint = YY_NULLPTR;
|
||||
yystackp->yylastDeleted = YY_NULLPTR;
|
||||
|
||||
@@ -2062,7 +2064,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
yyarg[yycount++] = yytokenName (yyx);
|
||||
{
|
||||
size_t yysz = yysize + yytnamerr (YY_NULLPTR, yytokenName (yyx));
|
||||
yysize_overflow |= yysz < yysize;
|
||||
if (yysz < yysize)
|
||||
yysize_overflow = yytrue;
|
||||
yysize = yysz;
|
||||
}
|
||||
}
|
||||
@@ -2087,7 +2090,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
|
||||
{
|
||||
size_t yysz = yysize + strlen (yyformat);
|
||||
yysize_overflow |= yysz < yysize;
|
||||
if (yysz < yysize)
|
||||
yysize_overflow = yytrue;
|
||||
yysize = yysz;
|
||||
}
|
||||
|
||||
@@ -2260,7 +2264,6 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
yylloc = yyloc_default;])[
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef])[]dnl
|
||||
[
|
||||
@@ -2352,7 +2355,7 @@ b4_dollar_popdef])[]dnl
|
||||
size_t yys;
|
||||
|
||||
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
||||
yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
|
||||
yystackp->yytops.yylookaheadNeeds[yys] = (yybool) (yychar != YYEMPTY);
|
||||
|
||||
/* yyprocessOneStack returns one of three things:
|
||||
|
||||
@@ -2573,4 +2576,4 @@ m4_if(b4_prefix, [yy], [],
|
||||
#define yylloc ]b4_prefix[lloc]])])[
|
||||
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end()
|
||||
b4_output_end
|
||||
|
||||
+29
-16
@@ -44,7 +44,7 @@
|
||||
# filename member).
|
||||
|
||||
# We require a pure interface.
|
||||
m4_define([b4_pure_flag], [1])
|
||||
m4_define([b4_pure_flag], [1])
|
||||
|
||||
m4_include(b4_pkgdatadir/[c++.m4])
|
||||
b4_bison_locations_if([m4_include(b4_pkgdatadir/[location.cc])])
|
||||
@@ -166,6 +166,12 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class_name[::operator() ()
|
||||
{
|
||||
return parse ();
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class_name[::parse ()
|
||||
{
|
||||
@@ -184,9 +190,9 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
{]b4_locations_if([[
|
||||
YYUSE (yylocationp);]])[
|
||||
YYUSE (yyvaluep);
|
||||
std::ostream& yyoutput = debug_stream ();
|
||||
std::ostream& yyo = yyoutput;
|
||||
YYUSE (yyo);
|
||||
std::ostream& yyo = debug_stream ();
|
||||
std::ostream& yyoutput = yyo;
|
||||
YYUSE (yyoutput);
|
||||
]b4_symbol_actions([printer])[
|
||||
}
|
||||
|
||||
@@ -234,25 +240,28 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
b4_namespace_close
|
||||
])
|
||||
|
||||
# b4_shared_declarations
|
||||
# ----------------------
|
||||
# Declaration that might either go into the header (if --defines)
|
||||
# or open coded in the parser body.
|
||||
|
||||
# b4_shared_declarations(hh|cc)
|
||||
# -----------------------------
|
||||
# Declaration that might either go into the header (if --defines, $1 = hh)
|
||||
# or in the implementation file.
|
||||
m4_define([b4_shared_declarations],
|
||||
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
b4_percent_code_get([[requires]])[
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <iostream>]b4_defines_if([
|
||||
b4_bison_locations_if([[#include "location.hh"]])])[
|
||||
|
||||
]m4_ifdef([b4_location_file],
|
||||
[[# include ]b4_location_include])[
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
]b4_YYDEBUG_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_defines_if([],
|
||||
[b4_bison_locations_if([b4_position_define
|
||||
b4_location_define])])[
|
||||
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||
[b4_location_define])])[
|
||||
|
||||
/// A Bison parser.
|
||||
class ]b4_parser_class_name[
|
||||
@@ -264,6 +273,10 @@ b4_location_define])])[
|
||||
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
||||
virtual ~]b4_parser_class_name[ ();
|
||||
|
||||
/// Parse. An alias for parse ().
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
int operator() ();
|
||||
|
||||
/// Parse.
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
virtual int parse ();
|
||||
@@ -330,13 +343,13 @@ b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
[2002-2015, 2018])[
|
||||
|
||||
// C++ GLR parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]b4_output_end()])
|
||||
]b4_output_end])
|
||||
|
||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||
# arguments include the parser itself.
|
||||
|
||||
+100
-63
@@ -20,6 +20,7 @@ m4_include(b4_pkgdatadir/[c++.m4])
|
||||
# api.value.type=variant is valid.
|
||||
m4_define([b4_value_type_setup_variant])
|
||||
|
||||
|
||||
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
||||
# --------------------------------------------------------------
|
||||
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
||||
@@ -83,9 +84,14 @@ m4_define([b4_rhs_state],
|
||||
# --------------------------------------
|
||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||
# symbols on RHS.
|
||||
m4_define([b4_rhs_value],
|
||||
m4_define([_b4_rhs_value],
|
||||
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
|
||||
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_percent_define_ifdef([api.value.automove],
|
||||
[YY_MOVE (_b4_rhs_value($@))],
|
||||
[_b4_rhs_value($@)])])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# ---------------------------------
|
||||
@@ -106,7 +112,7 @@ b4_dollar_pushdef([yysym.value],
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[m4_dquote(b4_symbol([$1], [type]))]),
|
||||
[yysym.location])dnl
|
||||
b4_symbol_case_([$1])
|
||||
_b4_symbol_case([$1])
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
@@ -142,10 +148,11 @@ b4_bison_locations_if([# Backward compatibility.
|
||||
m4_include(b4_pkgdatadir/[stack.hh])
|
||||
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
|
||||
|
||||
|
||||
# b4_shared_declarations(hh|cc)
|
||||
# -----------------------------
|
||||
# Declaration that might either go into the header (if --defines, $1 = hh)
|
||||
# or open coded in the parser body.
|
||||
# or in the implementation file.
|
||||
m4_define([b4_shared_declarations],
|
||||
[b4_percent_code_get([[requires]])[
|
||||
]b4_parse_assert_if([# include <cassert>])[
|
||||
@@ -153,21 +160,23 @@ m4_define([b4_shared_declarations],
|
||||
# include <iostream>
|
||||
# include <stdexcept>
|
||||
# include <string>
|
||||
# include <vector>]b4_defines_if([[
|
||||
# include "stack.hh"
|
||||
]b4_bison_locations_if([[# include "location.hh"]])])[
|
||||
# include <vector>
|
||||
|
||||
]b4_cxx_portability[
|
||||
]m4_ifdef([b4_location_include],
|
||||
[[# include ]b4_location_include])[
|
||||
]b4_variant_if([b4_variant_includes])[
|
||||
|
||||
]b4_attribute_define[
|
||||
]b4_null_define[
|
||||
|
||||
]b4_YYDEBUG_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
|
||||
]b4_defines_if([],
|
||||
[b4_stack_define
|
||||
b4_bison_locations_if([b4_position_define
|
||||
b4_location_define])])[
|
||||
]b4_stack_define[
|
||||
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||
[b4_location_define])])[
|
||||
|
||||
]b4_variant_if([b4_variant_define])[
|
||||
|
||||
@@ -176,10 +185,15 @@ b4_location_define])])[
|
||||
{
|
||||
public:
|
||||
]b4_public_types_declare[
|
||||
]b4_symbol_type_declare[
|
||||
/// Build a parser object.
|
||||
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
||||
virtual ~]b4_parser_class_name[ ();
|
||||
|
||||
/// Parse. An alias for parse ().
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
int operator() ();
|
||||
|
||||
/// Parse.
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
virtual int parse ();
|
||||
@@ -206,6 +220,8 @@ b4_location_define])])[
|
||||
/// Report a syntax error.
|
||||
void error (const syntax_error& err);
|
||||
|
||||
]b4_symbol_constructor_declare[
|
||||
|
||||
private:
|
||||
/// This class is not copyable.
|
||||
]b4_parser_class_name[ (const ]b4_parser_class_name[&);
|
||||
@@ -256,8 +272,9 @@ b4_location_define])])[
|
||||
/// Print the state stack on the debug stream.
|
||||
virtual void yystack_print_ ();
|
||||
|
||||
// Debugging.
|
||||
/// Debugging level.
|
||||
int yydebug_;
|
||||
/// Debug stream.
|
||||
std::ostream* yycdebug_;
|
||||
|
||||
/// \brief Display a symbol type, value and location.
|
||||
@@ -315,12 +332,15 @@ b4_location_define])])[
|
||||
typedef basic_symbol<by_state> super_type;
|
||||
/// Construct an empty symbol.
|
||||
stack_symbol_type ();
|
||||
/// Copy construct (for efficiency).
|
||||
stack_symbol_type (const stack_symbol_type& that);
|
||||
/// Move or copy construction.
|
||||
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
|
||||
/// Steal the contents from \a sym to build this.
|
||||
stack_symbol_type (state_type s, symbol_type& sym);
|
||||
/// Assignment, needed by push_back.
|
||||
stack_symbol_type& operator= (const stack_symbol_type& that);
|
||||
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||
#if !defined __cplusplus || __cplusplus < 201103L
|
||||
/// Assignment, needed by push_back by some old implementations.
|
||||
/// Moves the contents of that.
|
||||
stack_symbol_type& operator= (stack_symbol_type& that);
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Stack type.
|
||||
@@ -332,20 +352,20 @@ b4_location_define])])[
|
||||
/// Push a new state on the stack.
|
||||
/// \param m a debug message to display
|
||||
/// if null, no trace is output.
|
||||
/// \param s the symbol
|
||||
/// \param sym the symbol
|
||||
/// \warning the contents of \a s.value is stolen.
|
||||
void yypush_ (const char* m, stack_symbol_type& s);
|
||||
void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
|
||||
|
||||
/// Push a new look ahead token on the state on the stack.
|
||||
/// \param m a debug message to display
|
||||
/// if null, no trace is output.
|
||||
/// \param s the state
|
||||
/// \param sym the symbol (for its value and location).
|
||||
/// \warning the contents of \a s.value is stolen.
|
||||
void yypush_ (const char* m, state_type s, symbol_type& sym);
|
||||
/// \warning the contents of \a sym.value is stolen.
|
||||
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||
|
||||
/// Pop \a n symbols the three stacks.
|
||||
void yypop_ (unsigned n = 1);
|
||||
/// Pop \a n symbols from the stack.
|
||||
void yypop_ (int n = 1);
|
||||
|
||||
/// Constants.
|
||||
enum
|
||||
@@ -377,6 +397,10 @@ b4_location_define])])[
|
||||
]b4_percent_code_get([[provides]])[
|
||||
]])
|
||||
|
||||
## -------------- ##
|
||||
## Output files. ##
|
||||
## -------------- ##
|
||||
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
|
||||
@@ -388,30 +412,28 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
|
||||
|
||||
// C++ LALR(1) parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations(hh)[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])
|
||||
b4_output_end()
|
||||
b4_output_end
|
||||
])
|
||||
|
||||
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
|
||||
b4_percent_code_get([[top]])[]dnl
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])[
|
||||
]b4_disclaimer[
|
||||
]b4_percent_code_get([[top]])[]dnl
|
||||
m4_if(b4_prefix, [yy], [],
|
||||
[
|
||||
// Take the name prefix into account.
|
||||
#define yylex b4_prefix[]lex])[
|
||||
[#]define yylex b4_prefix[]lex])[
|
||||
|
||||
// First part of user declarations.
|
||||
]b4_user_pre_prologue[
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
||||
[b4_shared_declarations([cc])])[
|
||||
|
||||
// User implementation prologue.
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[
|
||||
|
||||
@@ -585,34 +607,40 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
|
||||
{}
|
||||
|
||||
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
|
||||
: super_type (that.state]b4_locations_if([, that.location])[)
|
||||
{
|
||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
||||
[value], [copy], [that.value])],
|
||||
[[value = that.value;]])[
|
||||
}
|
||||
|
||||
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
|
||||
: super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, that.location])[)
|
||||
]b4_parser_class_name[::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 ()],
|
||||
[value], [move], [that.value])])[
|
||||
[value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
// that is emptied.
|
||||
that.state = empty_state;
|
||||
#endif
|
||||
}
|
||||
|
||||
]b4_parser_class_name[::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 ()],
|
||||
[value], [move], [YY_MOVE (that.value)])])[
|
||||
// that is emptied.
|
||||
that.type = empty_symbol;
|
||||
}
|
||||
|
||||
#if !defined __cplusplus || __cplusplus < 201103L
|
||||
]b4_parser_class_name[::stack_symbol_type&
|
||||
]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that)
|
||||
]b4_parser_class_name[::stack_symbol_type::operator= (stack_symbol_type& that)
|
||||
{
|
||||
state = that.state;
|
||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
||||
[value], [copy], [that.value])],
|
||||
[value], [move], [that.value])],
|
||||
[[value = that.value;]])[]b4_locations_if([
|
||||
location = that.location;])[
|
||||
// that is emptied.
|
||||
that.state = empty_state;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template <typename Base>
|
||||
void
|
||||
@@ -647,22 +675,26 @@ m4_if(b4_prefix, [yy], [],
|
||||
#endif
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym)
|
||||
{
|
||||
stack_symbol_type t (s, sym);
|
||||
yypush_ (m, t);
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
|
||||
]b4_parser_class_name[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
|
||||
{
|
||||
if (m)
|
||||
YY_SYMBOL_PRINT (m, s);
|
||||
yystack_.push (s);
|
||||
YY_SYMBOL_PRINT (m, sym);
|
||||
yystack_.push (YY_MOVE (sym));
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::yypop_ (unsigned n)
|
||||
]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
|
||||
{
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
yypush_ (m, stack_symbol_type (s, std::move (sym)));
|
||||
#else
|
||||
stack_symbol_type ss (s, sym);
|
||||
yypush_ (m, ss);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::yypop_ (int n)
|
||||
{
|
||||
yystack_.pop (n);
|
||||
}
|
||||
@@ -716,6 +748,12 @@ m4_if(b4_prefix, [yy], [],
|
||||
return yyvalue == yytable_ninf_;
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class_name[::operator() ()
|
||||
{
|
||||
return parse ();
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class_name[::parse ()
|
||||
{
|
||||
@@ -745,7 +783,6 @@ m4_if(b4_prefix, [yy], [],
|
||||
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
|
||||
// User initialization code.
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef])[]dnl
|
||||
|
||||
@@ -754,7 +791,7 @@ b4_dollar_popdef])[]dnl
|
||||
location values to have been already stored, initialize these
|
||||
stacks with a primary value. */
|
||||
yystack_.clear ();
|
||||
yypush_ (YY_NULLPTR, 0, yyla);
|
||||
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
|
||||
|
||||
// A new symbol was pushed on the stack.
|
||||
yynewstate:
|
||||
@@ -816,7 +853,7 @@ b4_dollar_popdef])[]dnl
|
||||
--yyerrstatus_;
|
||||
|
||||
// Shift the lookahead token.
|
||||
yypush_ ("Shifting", yyn, yyla);
|
||||
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
|
||||
goto yynewstate;
|
||||
|
||||
/*-----------------------------------------------------------.
|
||||
@@ -839,7 +876,7 @@ b4_dollar_popdef])[]dnl
|
||||
/* Variants are always initialized to an empty instance of the
|
||||
correct type. The default '$$ = $1' action is NOT applied
|
||||
when using variants. */
|
||||
b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])], [
|
||||
b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [emplace])], [
|
||||
/* If YYLEN is nonzero, implement the default value of the
|
||||
action: '$$ = $1'. Otherwise, use the top of the stack.
|
||||
|
||||
@@ -885,7 +922,7 @@ b4_dollar_popdef])[]dnl
|
||||
YY_STACK_PRINT ();
|
||||
|
||||
// Shift the result of the reduction.
|
||||
yypush_ (YY_NULLPTR, yylhs);
|
||||
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
|
||||
}
|
||||
goto yynewstate;
|
||||
|
||||
@@ -974,7 +1011,7 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
// Shift the error token.
|
||||
error_token.state = yyn;
|
||||
yypush_ ("Shifting", error_token);
|
||||
yypush_ ("Shifting", YY_MOVE (error_token));
|
||||
}
|
||||
goto yynewstate;
|
||||
|
||||
@@ -1180,7 +1217,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
|
||||
]b4_namespace_close[
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end()
|
||||
b4_output_end
|
||||
|
||||
|
||||
m4_popdef([b4_copyright_years])dnl
|
||||
|
||||
+9
-12
@@ -82,15 +82,14 @@ m4_define([b4_define_state],[[
|
||||
]b4_yystype[ yylval = null;
|
||||
]])
|
||||
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2015, 2018])
|
||||
|
||||
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
|
||||
])[/* First part of user declarations. */
|
||||
]b4_user_pre_prologue
|
||||
b4_user_post_prologue
|
||||
b4_percent_code_get([[imports]])
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2015, 2018])[
|
||||
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
||||
]])[
|
||||
]b4_user_pre_prologue[
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get([[imports]])
|
||||
[/**
|
||||
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
||||
*
|
||||
@@ -586,7 +585,6 @@ b4_define_state])[
|
||||
yystack.push (yystate, yylval ]b4_locations_if([, yylloc])[);
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef[]dnl
|
||||
])[
|
||||
@@ -597,7 +595,6 @@ b4_dollar_popdef[]dnl
|
||||
push_parse_initialize ();
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef[]dnl
|
||||
])[
|
||||
@@ -1068,4 +1065,4 @@ b4_percent_code_get[]dnl
|
||||
}
|
||||
|
||||
b4_epilogue[]dnl
|
||||
b4_output_end()
|
||||
b4_output_end
|
||||
|
||||
+69
-40
@@ -18,11 +18,48 @@
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2015, 2018])
|
||||
|
||||
# b4_position_define
|
||||
|
||||
# b4_position_file
|
||||
# ----------------
|
||||
# Name of the file containing the position class, if we want this file.
|
||||
b4_defines_if([b4_required_version_if([302], [],
|
||||
[m4_define([b4_position_file], [position.hh])])])])
|
||||
|
||||
|
||||
# b4_location_file
|
||||
# ----------------
|
||||
# Name of the file containing the position/location class,
|
||||
# if we want this file.
|
||||
b4_percent_define_check_file([b4_location_file],
|
||||
[[api.location.file]],
|
||||
b4_defines_if([[location.hh]]))
|
||||
|
||||
# b4_location_include
|
||||
# -------------------
|
||||
# If location.hh is to be generated, the name under which should it be
|
||||
# included.
|
||||
#
|
||||
# b4_location_path
|
||||
# ----------------
|
||||
# The path to use for the CPP guard.
|
||||
m4_ifdef([b4_location_file],
|
||||
[m4_define([b4_location_include],
|
||||
[b4_percent_define_get([[api.location.include]],
|
||||
["b4_location_file"])])
|
||||
m4_define([b4_location_path],
|
||||
b4_percent_define_get([[api.location.include]],
|
||||
["b4_dir_prefix[]b4_location_file"]))
|
||||
m4_define([b4_location_path],
|
||||
m4_substr(m4_defn([b4_location_path]), 1, m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
|
||||
])
|
||||
|
||||
|
||||
|
||||
# b4_location_define
|
||||
# ------------------
|
||||
# Define class position.
|
||||
m4_define([b4_position_define],
|
||||
[[ /// Abstract a position.
|
||||
# Define the position and location classes.
|
||||
m4_define([b4_location_define],
|
||||
[[ /// A point in a source file.
|
||||
class position
|
||||
{
|
||||
public:]m4_ifdef([b4_location_constructors], [[
|
||||
@@ -73,10 +110,11 @@ m4_define([b4_position_define],
|
||||
unsigned column;
|
||||
|
||||
private:
|
||||
/// Compute max(min, lhs+rhs).
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
||||
{
|
||||
return static_cast<unsigned>(std::max(min, static_cast<int>(lhs) + rhs));
|
||||
return static_cast<unsigned> (std::max (min,
|
||||
static_cast<int> (lhs) + rhs));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -139,13 +177,8 @@ m4_define([b4_position_define],
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
# b4_location_define
|
||||
# ------------------
|
||||
m4_define([b4_location_define],
|
||||
[[ /// Abstract a location.
|
||||
/// Two points in a source file.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
@@ -287,16 +320,31 @@ m4_define([b4_location_define],
|
||||
]])
|
||||
|
||||
|
||||
b4_defines_if([
|
||||
b4_output_begin([b4_dir_prefix[]position.hh])
|
||||
b4_copyright([Positions for Bison parsers in C++])[
|
||||
m4_ifdef([b4_position_file], [[
|
||||
]b4_output_begin([b4_dir_prefix], [b4_position_file])[
|
||||
]b4_generated_by[
|
||||
// Starting with Bison 3.2, this file is useless: the structure it
|
||||
// used to define is now defined in "]b4_location_file[".
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add 'require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system
|
||||
// 3. if you used to include it, include "]b4_location_file[" instead.
|
||||
|
||||
#include ]b4_location_include[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
m4_ifdef([b4_location_file], [[
|
||||
]b4_output_begin([b4_dir_prefix], [b4_location_file])[
|
||||
]b4_copyright([Locations for Bison parsers in C++])[
|
||||
/**
|
||||
** \file ]b4_dir_prefix[position.hh
|
||||
** Define the ]b4_namespace_ref[::position class.
|
||||
** \file ]b4_location_path[
|
||||
** Define the ]b4_namespace_ref[::location class.
|
||||
*/
|
||||
|
||||
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
||||
]b4_cpp_guard_open([b4_location_path])[
|
||||
|
||||
# include <algorithm> // std::max
|
||||
# include <iostream>
|
||||
@@ -304,31 +352,12 @@ b4_copyright([Positions for Bison parsers in C++])[
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_position_define[
|
||||
]b4_namespace_close[
|
||||
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
||||
b4_output_end()
|
||||
|
||||
|
||||
b4_output_begin([b4_dir_prefix[]location.hh])
|
||||
b4_copyright([Locations for Bison parsers in C++])[
|
||||
|
||||
/**
|
||||
** \file ]b4_dir_prefix[location.hh
|
||||
** Define the ]b4_namespace_ref[::location class.
|
||||
*/
|
||||
|
||||
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
|
||||
|
||||
# include "position.hh"
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_location_define[
|
||||
]b4_namespace_close[
|
||||
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
||||
b4_output_end()
|
||||
])
|
||||
]b4_cpp_guard_close([b4_location_path])[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
m4_popdef([b4_copyright_years])
|
||||
|
||||
+48
-42
@@ -15,14 +15,19 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2015, 2018])
|
||||
|
||||
# b4_stack_file
|
||||
# -------------
|
||||
# Name of the file containing the stack class, if we want this file.
|
||||
b4_defines_if([b4_required_version_if([302], [],
|
||||
[m4_define([b4_stack_file], [stack.hh])])])
|
||||
|
||||
|
||||
# b4_stack_define
|
||||
# ---------------
|
||||
m4_define([b4_stack_define],
|
||||
[[ /// A stack with random access from its top.
|
||||
template <class T, class S = std::vector<T> >
|
||||
template <typename T, typename S = std::vector<T> >
|
||||
class stack
|
||||
{
|
||||
public:
|
||||
@@ -31,12 +36,7 @@ m4_define([b4_stack_define],
|
||||
typedef typename S::const_reverse_iterator const_iterator;
|
||||
typedef typename S::size_type size_type;
|
||||
|
||||
stack ()
|
||||
{
|
||||
seq_.reserve (200);
|
||||
}
|
||||
|
||||
stack (size_type n)
|
||||
stack (size_type n = 200)
|
||||
: seq_ (n)
|
||||
{}
|
||||
|
||||
@@ -46,7 +46,16 @@ m4_define([b4_stack_define],
|
||||
T&
|
||||
operator[] (size_type i)
|
||||
{
|
||||
return seq_[seq_.size () - 1 - i];
|
||||
return seq_[size () - 1 - i];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
T&
|
||||
operator[] (int i)
|
||||
{
|
||||
return operator[] (size_type (i));
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
@@ -55,23 +64,32 @@ m4_define([b4_stack_define],
|
||||
const T&
|
||||
operator[] (size_type i) const
|
||||
{
|
||||
return seq_[seq_.size () - 1 - i];
|
||||
return seq_[size () - 1 - i];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
const T&
|
||||
operator[] (int i) const
|
||||
{
|
||||
return operator[] (size_type (i));
|
||||
}
|
||||
|
||||
/// Steal the contents of \a t.
|
||||
///
|
||||
/// Close to move-semantics.
|
||||
void
|
||||
push (T& t)
|
||||
push (YY_MOVE_REF (T) t)
|
||||
{
|
||||
seq_.push_back (T());
|
||||
seq_.push_back (T ());
|
||||
operator[](0).move (t);
|
||||
}
|
||||
|
||||
void
|
||||
pop (size_type n = 1)
|
||||
pop (int n = 1)
|
||||
{
|
||||
for (; n; --n)
|
||||
for (; 0 < n; --n)
|
||||
seq_.pop_back ();
|
||||
}
|
||||
|
||||
@@ -107,47 +125,35 @@ m4_define([b4_stack_define],
|
||||
};
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
template <class T, class S = stack<T> >
|
||||
template <typename T, typename S = stack<T> >
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
typedef typename S::size_type size_type;
|
||||
slice (const S& stack, size_type range)
|
||||
slice (const S& stack, int range)
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (size_type i) const
|
||||
operator[] (int i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const S& stack_;
|
||||
size_type range_;
|
||||
int range_;
|
||||
};
|
||||
]])
|
||||
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_dir_prefix[]stack.hh])
|
||||
b4_copyright([Stack handling for Bison parsers in C++])[
|
||||
|
||||
/**
|
||||
** \file ]b4_dir_prefix[stack.hh
|
||||
** Define the ]b4_namespace_ref[::stack class.
|
||||
*/
|
||||
|
||||
]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
|
||||
|
||||
# include <vector>
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_stack_define[
|
||||
]b4_namespace_close[
|
||||
|
||||
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
||||
b4_output_end()
|
||||
])
|
||||
|
||||
m4_popdef([b4_copyright_years])
|
||||
m4_ifdef([b4_stack_file],
|
||||
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
||||
]b4_generated_by[
|
||||
// Starting with Bison 3.2, this file is useless: the structure it
|
||||
// used to define is now defined with the parser itself.
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add 'require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system.
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
+85
-39
@@ -29,7 +29,7 @@ m4_define([b4_symbol_variant],
|
||||
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
||||
switch ($1)
|
||||
{
|
||||
b4_type_foreach([b4_type_action_])[]dnl
|
||||
b4_type_foreach([_b4_type_action])[]dnl
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -55,15 +55,15 @@ dummy[]_b4_char_sizeof_counter])
|
||||
# ---------------------------
|
||||
# To be mapped on the list of type names to produce:
|
||||
#
|
||||
# char dummy1[sizeof(type_name_1)];
|
||||
# char dummy2[sizeof(type_name_2)];
|
||||
# char dummy1[sizeof (type_name_1)];
|
||||
# char dummy2[sizeof (type_name_2)];
|
||||
#
|
||||
# for defined type names.
|
||||
m4_define([b4_char_sizeof],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[
|
||||
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
||||
char _b4_char_sizeof_dummy@{sizeof(b4_symbol([$1], [type]))@};
|
||||
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
|
||||
])])
|
||||
|
||||
|
||||
@@ -101,11 +101,11 @@ m4_define([b4_variant_define],
|
||||
|
||||
/// Construct and fill.
|
||||
template <typename T>
|
||||
variant (const T& t)]b4_parse_assert_if([
|
||||
variant (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
new (yyas_<T> ()) T (t);
|
||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||
}
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
@@ -117,7 +117,7 @@ m4_define([b4_variant_define],
|
||||
/// Instantiate an empty \a T in here.
|
||||
template <typename T>
|
||||
T&
|
||||
build ()
|
||||
emplace ()
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
@@ -125,16 +125,47 @@ m4_define([b4_variant_define],
|
||||
return *new (yyas_<T> ()) T ();
|
||||
}
|
||||
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T, typename U>
|
||||
T&
|
||||
emplace (U&& u)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (std::forward <U>(u));
|
||||
}
|
||||
# else
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T>
|
||||
T&
|
||||
build (const T& t)
|
||||
emplace (const T& t)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (t);
|
||||
}
|
||||
# endif
|
||||
|
||||
/// Instantiate an empty \a T in here.
|
||||
/// Obsolete, use emplace.
|
||||
template <typename T>
|
||||
T&
|
||||
build ()
|
||||
{
|
||||
return emplace<T> ();
|
||||
}
|
||||
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
/// Obsolete, use emplace.
|
||||
template <typename T>
|
||||
T&
|
||||
build (const T& t)
|
||||
{
|
||||
return emplace<T> (t);
|
||||
}
|
||||
|
||||
/// Accessor to a built \a T.
|
||||
template <typename T>
|
||||
@@ -163,7 +194,7 @@ m4_define([b4_variant_define],
|
||||
/// Both variants must be built beforehand, because swapping the actual
|
||||
/// data requires reading it (with as()), and this is not possible on
|
||||
/// unconstructed variants: it would require some dynamic testing, which
|
||||
/// should not be the variant's responsability.
|
||||
/// should not be the variant's responsibility.
|
||||
/// Swapping between built and (possibly) non-built is done with
|
||||
/// variant::move ().
|
||||
template <typename T>
|
||||
@@ -182,17 +213,32 @@ m4_define([b4_variant_define],
|
||||
void
|
||||
move (self_type& other)
|
||||
{
|
||||
build<T> ();
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
emplace<T> (std::move (other.as<T> ()));
|
||||
# else
|
||||
emplace<T> ();
|
||||
swap<T> (other);
|
||||
# endif
|
||||
other.destroy<T> ();
|
||||
}
|
||||
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
/// Move the content of \a other to this.
|
||||
template <typename T>
|
||||
void
|
||||
move (self_type&& other)
|
||||
{
|
||||
emplace<T> (std::move (other.as<T> ()));
|
||||
other.destroy<T> ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Copy the content of \a other to this.
|
||||
template <typename T>
|
||||
void
|
||||
copy (const self_type& other)
|
||||
{
|
||||
build<T> (other.as<T> ());
|
||||
emplace<T> (other.as<T> ());
|
||||
}
|
||||
|
||||
/// Destroy the stored \a T.
|
||||
@@ -206,7 +252,7 @@ m4_define([b4_variant_define],
|
||||
|
||||
private:
|
||||
/// Prohibit blind copies.
|
||||
self_type& operator=(const self_type&);
|
||||
self_type& operator= (const self_type&);
|
||||
variant (const self_type&);
|
||||
|
||||
/// Accessor to raw memory as \a T.
|
||||
@@ -255,7 +301,7 @@ m4_define([b4_value_type_declare],
|
||||
{]b4_type_foreach([b4_char_sizeof])[};
|
||||
|
||||
/// Symbol semantic values.
|
||||
typedef variant<sizeof(union_type)> semantic_type;][]dnl
|
||||
typedef variant<sizeof (union_type)> semantic_type;][]dnl
|
||||
])
|
||||
|
||||
|
||||
@@ -283,18 +329,18 @@ m4_define([b4_symbol_value_template],
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_symbol_constructor_declare_(SYMBOL-NUMBER)
|
||||
# _b4_symbol_constructor_declare(SYMBOL-NUMBER)
|
||||
# ---------------------------------------------
|
||||
# Declare the overloaded version of make_symbol for the (common) type of
|
||||
# these SYMBOL-NUMBERS. Use at class-level.
|
||||
m4_define([b4_symbol_constructor_declare_],
|
||||
m4_define([_b4_symbol_constructor_declare],
|
||||
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
||||
[ static inline
|
||||
[ static
|
||||
symbol_type
|
||||
make_[]b4_symbol_([$1], [id]) (dnl
|
||||
make_[]_b4_symbol([$1], [id]) (dnl
|
||||
b4_join(b4_symbol_if([$1], [has_type],
|
||||
[const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l])));
|
||||
[YY_COPY (b4_symbol([$1], [type])) v]),
|
||||
b4_locations_if([YY_COPY (location_type) l])));
|
||||
|
||||
])])])
|
||||
|
||||
@@ -305,24 +351,25 @@ b4_join(b4_symbol_if([$1], [has_type],
|
||||
# Use at class-level.
|
||||
m4_define([b4_symbol_constructor_declare],
|
||||
[ // Symbol constructors declarations.
|
||||
b4_symbol_foreach([b4_symbol_constructor_declare_])])
|
||||
b4_symbol_foreach([_b4_symbol_constructor_declare])])
|
||||
|
||||
|
||||
|
||||
# b4_symbol_constructor_define_(SYMBOL-NUMBER)
|
||||
# _b4_symbol_constructor_define(SYMBOL-NUMBER)
|
||||
# --------------------------------------------
|
||||
# Define symbol constructor for this SYMBOL-NUMBER.
|
||||
m4_define([b4_symbol_constructor_define_],
|
||||
m4_define([_b4_symbol_constructor_define],
|
||||
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
||||
[ b4_parser_class_name::symbol_type
|
||||
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
|
||||
[ inline
|
||||
b4_parser_class_name::symbol_type
|
||||
b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl
|
||||
b4_join(b4_symbol_if([$1], [has_type],
|
||||
[const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l])))
|
||||
[YY_COPY (b4_symbol([$1], [type])) v]),
|
||||
b4_locations_if([YY_COPY (location_type) l])))
|
||||
{
|
||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l])));
|
||||
b4_symbol_if([$1], [has_type], [YY_MOVE (v)]),
|
||||
b4_locations_if([YY_MOVE (l)])));
|
||||
}
|
||||
|
||||
])])])
|
||||
@@ -332,27 +379,26 @@ b4_join(b4_symbol_if([$1], [has_type],
|
||||
# -----------------------------------
|
||||
# Generate a constructor declaration for basic_symbol from given type.
|
||||
m4_define([b4_basic_symbol_constructor_declare],
|
||||
[[
|
||||
basic_symbol (]b4_join(
|
||||
[[ basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
|
||||
b4_locations_if([const location_type& l]))[);
|
||||
b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type])) v]),
|
||||
b4_locations_if([YY_RVREF (location_type) l]))[);
|
||||
]])
|
||||
|
||||
# b4_basic_symbol_constructor_define
|
||||
# ----------------------------------
|
||||
# Generate a constructor implementation for basic_symbol from given type.
|
||||
m4_define([b4_basic_symbol_constructor_define],
|
||||
[[
|
||||
template <typename Base>
|
||||
[[ template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type])) v]),
|
||||
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||
, value (v)])[]b4_locations_if([
|
||||
, location (l)])[
|
||||
, value (YY_MOVE (v))])[]b4_locations_if([
|
||||
, location (YY_MOVE (l))])[
|
||||
{}
|
||||
|
||||
]])
|
||||
|
||||
# b4_symbol_constructor_define
|
||||
@@ -360,4 +406,4 @@ m4_define([b4_basic_symbol_constructor_define],
|
||||
# Define the overloaded versions of make_symbol for all the value types.
|
||||
m4_define([b4_symbol_constructor_define],
|
||||
[ // Implementation of make_symbol for each symbol type.
|
||||
b4_symbol_foreach([b4_symbol_constructor_define_])])
|
||||
b4_symbol_foreach([_b4_symbol_constructor_define])])
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<xsl:param name="staten"/>
|
||||
<xsl:for-each select='reduction'>
|
||||
<!-- These variables are needed because the current context can't be
|
||||
refered to directly in XPath expressions. -->
|
||||
referred to directly in XPath expressions. -->
|
||||
<xsl:variable name="rul">
|
||||
<xsl:value-of select="@rule"/>
|
||||
</xsl:variable>
|
||||
@@ -95,7 +95,7 @@
|
||||
<xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
|
||||
<xsl:variable name="rule">
|
||||
<xsl:choose>
|
||||
<!-- The acceptation state is refered to as 'accept' in the XML, but
|
||||
<!-- The acceptation state is referred to as 'accept' in the XML, but
|
||||
just as '0' in the DOT. -->
|
||||
<xsl:when test="@rule='accept'">
|
||||
<xsl:text>0</xsl:text>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
<title>
|
||||
<xsl:value-of select="bison-xml-report/filename"/>
|
||||
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
||||
|
||||
+42
-49
@@ -237,11 +237,11 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
||||
YYSIZE_T yyes_capacity;]])])
|
||||
|
||||
|
||||
# b4_declare_yyparse_push_
|
||||
# _b4_declare_yyparse_push
|
||||
# ------------------------
|
||||
# Declaration of yyparse (and dependencies) when using the push parser
|
||||
# (including in pull mode).
|
||||
m4_define([b4_declare_yyparse_push_],
|
||||
m4_define([_b4_declare_yyparse_push],
|
||||
[[#ifndef YYPUSH_MORE_DEFINED
|
||||
# define YYPUSH_MORE_DEFINED
|
||||
enum { YYPUSH_MORE = 4 };
|
||||
@@ -265,18 +265,18 @@ b4_function_declare([b4_prefix[pstate_delete]], [[void]],
|
||||
[[b4_prefix[pstate *ps]], [[ps]]])dnl
|
||||
])
|
||||
|
||||
# b4_declare_yyparse_
|
||||
# _b4_declare_yyparse
|
||||
# -------------------
|
||||
# When not the push parser.
|
||||
m4_define([b4_declare_yyparse_],
|
||||
m4_define([_b4_declare_yyparse],
|
||||
[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)])
|
||||
|
||||
|
||||
# b4_declare_yyparse
|
||||
# ------------------
|
||||
m4_define([b4_declare_yyparse],
|
||||
[b4_push_if([b4_declare_yyparse_push_],
|
||||
[b4_declare_yyparse_])[]dnl
|
||||
[b4_push_if([_b4_declare_yyparse_push],
|
||||
[_b4_declare_yyparse])[]dnl
|
||||
])
|
||||
|
||||
|
||||
@@ -299,9 +299,8 @@ m4_define([b4_shared_declarations],
|
||||
## Output files. ##
|
||||
## -------------- ##
|
||||
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||
simplifying the original so-called "semantic" parser. */
|
||||
|
||||
@@ -312,8 +311,9 @@ b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||
define necessary library symbols; they are noted "INFRINGES ON
|
||||
USER NAME SPACE" below. */
|
||||
|
||||
]b4_identification
|
||||
b4_percent_code_get([[top]])[]dnl
|
||||
]b4_disclaimer[
|
||||
]b4_identification[
|
||||
]b4_percent_code_get([[top]])[]dnl
|
||||
m4_if(b4_api_prefix, [yy], [],
|
||||
[[/* Substitute the type names. */
|
||||
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
||||
@@ -335,9 +335,7 @@ m4_if(b4_api_prefix, [yy], [],
|
||||
#define yychar ]b4_prefix[char]b4_locations_if([[
|
||||
#define yylloc ]b4_prefix[lloc]])]))[
|
||||
|
||||
/* Copy the first part of user declarations. */
|
||||
]b4_user_pre_prologue[
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
/* Enabling verbose error messages. */
|
||||
@@ -354,9 +352,8 @@ m4_if(b4_api_prefix, [yy], [],
|
||||
]])dnl
|
||||
b4_shared_declarations[
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
]b4_user_post_prologue
|
||||
b4_percent_code_get[]dnl
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
[#ifdef short
|
||||
# undef short
|
||||
@@ -791,7 +788,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
|
||||
yytype_int16 **yytop, yytype_int16 *yytop_empty)
|
||||
{
|
||||
YYSIZE_T yysize_old =
|
||||
*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
|
||||
(YYSIZE_T) (*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1);
|
||||
YYSIZE_T yysize_new = yysize_old + yyadd;
|
||||
if (*yycapacity < yysize_new)
|
||||
{
|
||||
@@ -957,7 +954,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
YYDPRINTF ((stderr, " R%d", yyrule - 1));
|
||||
if (yyesp != yyes_prev)
|
||||
{
|
||||
YYSIZE_T yysize = yyesp - *yyes + 1;
|
||||
YYSIZE_T yysize = (YYSIZE_T) (yyesp - *yyes + 1);
|
||||
if (yylen < yysize)
|
||||
{
|
||||
yyesp -= yylen;
|
||||
@@ -973,15 +970,14 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
yyesp = yyes_prev -= yylen;
|
||||
}
|
||||
{
|
||||
int yystate;
|
||||
yytype_int16 yystate;
|
||||
{
|
||||
int yylhs = yyr1[yyrule] - YYNTOKENS;
|
||||
yystate = yypgoto[yylhs] + *yyesp;
|
||||
if (yystate < 0 || YYLAST < yystate
|
||||
|| yycheck[yystate] != *yyesp)
|
||||
yystate = yydefgoto[yylhs];
|
||||
else
|
||||
yystate = yytable[yystate];
|
||||
const int yylhs = yyr1[yyrule] - YYNTOKENS;
|
||||
const int yyi = yypgoto[yylhs] + *yyesp;
|
||||
yystate = ((yytype_int16)
|
||||
(0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
|
||||
? yytable[yyi]
|
||||
: yydefgoto[yylhs]));
|
||||
}
|
||||
if (yyesp == yyes_prev)
|
||||
{
|
||||
@@ -1001,7 +997,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
}
|
||||
*++yyesp = yystate;
|
||||
}
|
||||
YYDPRINTF ((stderr, " G%d", yystate));
|
||||
YYDPRINTF ((stderr, " G%d", (int) yystate));
|
||||
}
|
||||
}
|
||||
}]])[
|
||||
@@ -1089,7 +1085,7 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
if (! yyres)
|
||||
return yystrlen (yystr);
|
||||
|
||||
return yystpcpy (yyres, yystr) - yyres;
|
||||
return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -1433,7 +1429,6 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
|
||||
[b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef[]dnl
|
||||
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
|
||||
@@ -1451,12 +1446,12 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
|
||||
yyssp++;
|
||||
|
||||
yysetstate:
|
||||
*yyssp = yystate;
|
||||
*yyssp = (yytype_int16) yystate;
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
{
|
||||
/* Get the current used size of the three stacks, in elements. */
|
||||
YYSIZE_T yysize = yyssp - yyss + 1;
|
||||
YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
|
||||
|
||||
#ifdef yyoverflow
|
||||
{
|
||||
@@ -1476,10 +1471,9 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
|
||||
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
|
||||
&yyls1, yysize * sizeof (*yylsp),])[
|
||||
&yystacksize);
|
||||
]b4_locations_if([
|
||||
yyls = yyls1;])[
|
||||
yyss = yyss1;
|
||||
yyvs = yyvs1;
|
||||
yyvs = yyvs1;]b4_locations_if([
|
||||
yyls = yyls1;])[
|
||||
}
|
||||
#else /* no yyoverflow */
|
||||
# ifndef YYSTACK_RELOCATE
|
||||
@@ -1653,7 +1647,7 @@ yyreduce:
|
||||
int yychar_backup = yychar;
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_user_actions[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}
|
||||
if (yychar_backup != yychar)
|
||||
@@ -1687,14 +1681,13 @@ yyreduce:
|
||||
/* Now 'shift' the result of the reduction. Determine what state
|
||||
that goes to, based on the state we popped back to and the rule
|
||||
number reduced by. */
|
||||
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
|
||||
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTOKENS];
|
||||
{
|
||||
const int yylhs = yyr1[yyn] - YYNTOKENS;
|
||||
const int yyi = yypgoto[yylhs] + *yyssp;
|
||||
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
|
||||
? yytable[yyi]
|
||||
: yydefgoto[yylhs]);
|
||||
}
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
@@ -1908,12 +1901,12 @@ yypushreturn:]])[
|
||||
return yyresult;
|
||||
}
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end()
|
||||
b4_output_end
|
||||
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])[
|
||||
b4_defines_if([[
|
||||
]b4_output_begin([b4_spec_defines_file])[
|
||||
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_shared_declarations[
|
||||
]b4_output_end()
|
||||
])# b4_defines_if
|
||||
]b4_output_end[
|
||||
]])# b4_defines_if
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
=======================
|
||||
|
||||
The DJGPP port of Bison offers LFN and SFN support depending on which
|
||||
OS it is running. If LFN support is available or not is determinated at
|
||||
OS it is running. If LFN support is available or not is determined at
|
||||
run time. If LFN support is available (DOS session under Win9X, Win2K,
|
||||
WinXP, etc.) the standard posix file name extensions will be used.
|
||||
These are: y.tab.c, y.tab.c++, y.tab.h, y.output, etc. If only SFN
|
||||
|
||||
+5
-5
@@ -80,10 +80,10 @@ goto NextArgument
|
||||
if "%1" == "no-dep" goto NextArgument
|
||||
if "%1" == "no-DEP" goto NextArgument
|
||||
if "%1" == "NO-DEP" goto NextArgument
|
||||
if "%1" == "dep" goto DependecyTraking
|
||||
if "%1" == "DEP" goto DependecyTraking
|
||||
if "%1" == "dep" goto DependecyTracking
|
||||
if "%1" == "DEP" goto DependecyTracking
|
||||
goto LibiconvPrefixOption
|
||||
:DependecyTraking
|
||||
:DependecyTracking
|
||||
if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
|
||||
if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
|
||||
if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
|
||||
@@ -290,7 +290,7 @@ if errorlevel 1 goto SedError2
|
||||
mv -f config.hin %XSRC%/lib/config.hin
|
||||
|
||||
|
||||
Rem Fixing ilicit testsuite file name.
|
||||
Rem Fixing illicit testsuite file name.
|
||||
test -f %XSRC%/tests/c++.at
|
||||
if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.at
|
||||
|
||||
@@ -300,7 +300,7 @@ sed -f %XSRC%/djgpp/testsuite.sed %XSRC%/tests/testsuite.org > testsuite.tmp
|
||||
if errorlevel 1 goto SedError3
|
||||
mv -f ./testsuite.tmp %XSRC%/tests/testsuite
|
||||
|
||||
Rem Fixing ilicit calc++ file names in the calc++ directory.
|
||||
Rem Fixing illicit calc++ file names in the calc++ directory.
|
||||
test -d %XSRC%/examples/calc++
|
||||
if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
|
||||
test -d %XSRC%/examples/calcxx
|
||||
|
||||
+12
-10
@@ -1,25 +1,28 @@
|
||||
# Do not ignore these. The release procedure (web-manual-update)
|
||||
# works in the src tree (even when run from the build tree) and leaves
|
||||
# these files around. Since they take precedence over the files in
|
||||
# the build tree, locally built manuals use obsolete auxiliary files.
|
||||
#
|
||||
# So don't hide them, give the maintainer a chance to clean them.
|
||||
#/bison.aux
|
||||
#/bison.cp
|
||||
#/bison.cps
|
||||
#/bison.toc
|
||||
|
||||
/*~
|
||||
/.dirstamp
|
||||
/bison.1
|
||||
/bison.aux
|
||||
/bison.cp
|
||||
/bison.cps
|
||||
/bison.dvi
|
||||
/bison.fn
|
||||
/bison.help
|
||||
/bison.html
|
||||
/bison.info
|
||||
/bison.ky
|
||||
/bison.log
|
||||
/bison.pdf
|
||||
/bison.pg
|
||||
/bison.ps
|
||||
/bison.toc
|
||||
/bison.tp
|
||||
/bison.vr
|
||||
/cross-options.texi
|
||||
/fdl.texi
|
||||
/gendocs_template
|
||||
/gendocs_template_min
|
||||
/gpl-3.0.texi
|
||||
/refcard.dvi
|
||||
/refcard.log
|
||||
@@ -27,4 +30,3 @@
|
||||
/stamp-vti
|
||||
/version.texi
|
||||
/yacc.1
|
||||
/gendocs_template_min
|
||||
|
||||
+1
-1
@@ -1405,7 +1405,7 @@ EXT_LINKS_IN_WINDOW = NO
|
||||
|
||||
FORMULA_FONTSIZE = 10
|
||||
|
||||
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
|
||||
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
|
||||
# generated for formulas are transparent PNGs. Transparent PNGs are not
|
||||
# supported properly for IE 6.0, but are supported on all modern browsers.
|
||||
#
|
||||
|
||||
+825
-340
File diff suppressed because it is too large
Load Diff
+19
-18
@@ -30,11 +30,9 @@ $(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
||||
$(doc_bison).html: $(FIGS_GV:.gv=.png)
|
||||
|
||||
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
||||
CLEANDIRS = doc/bison.t2d
|
||||
clean-local:
|
||||
rm -rf $(CLEANDIRS)
|
||||
CLEANDIRS += doc/bison.t2d
|
||||
|
||||
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
|
||||
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.tmp
|
||||
|
||||
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
||||
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
|
||||
@@ -44,8 +42,8 @@ $(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
||||
# 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)src/bison$(EXEEXT) --help | \
|
||||
$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
||||
$(AM_V_at)$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l \
|
||||
<$(top_srcdir)/doc/bison.help >$@.tmp
|
||||
$(AM_V_at)diff -u $@~ $@.tmp || true
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||
@@ -66,9 +64,9 @@ doc/refcard.pdf: doc/refcard.tex
|
||||
## doc/bison.help. ##
|
||||
## ---------------- ##
|
||||
|
||||
# Some of our targets (cross-option.texi, bison.1) use "bison --help".
|
||||
# Some of our targets (cross-options.texi, bison.1) use "bison --help".
|
||||
# Since we want to ship the generated file to avoid additional
|
||||
# requirements over the user environment, we used not depend on
|
||||
# requirements over the user environment, we used to not depend on
|
||||
# src/bison itself, but on src/getargs.c and other files. Yet, we
|
||||
# need "bison --help" to work to make help2man happy, so we used to
|
||||
# include "make src/bison" in the commands. Then we may have a
|
||||
@@ -82,15 +80,18 @@ doc/refcard.pdf: doc/refcard.tex
|
||||
# bison.help, which contains --version then --help. This file can
|
||||
# depend on bison, which ensures its correctness. But update it
|
||||
# *only* if needed (content changes). This way, we avoid useless
|
||||
# compilations of cross-option.texi and bison.1. At the cost of
|
||||
# compilations of cross-options.texi and bison.1. At the cost of
|
||||
# repeated builds of bison.help.
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
||||
if ! CROSS_COMPILING
|
||||
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
||||
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
||||
$(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
||||
$(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp
|
||||
$(AM_V_GEN)LC_ALL=C src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
||||
$(AM_V_at) LC_ALL=C src/bison$(EXEEXT) --help | \
|
||||
## Avoid variations in the output depending on whether we are
|
||||
## on a glibc system.
|
||||
sed '/translation bugs/d' >>doc/bison.help.tmp
|
||||
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
||||
endif ! CROSS_COMPILING
|
||||
|
||||
@@ -116,14 +117,14 @@ endif
|
||||
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
||||
$(AM_V_GEN)$(HELP2MAN) \
|
||||
--include=$(top_srcdir)/doc/bison.x \
|
||||
--output=$@.t src/bison$(EXEEXT)
|
||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
|
||||
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
|
||||
touch $@; \
|
||||
else \
|
||||
mv $@.t $@; \
|
||||
--output=$@.tmp src/bison$(EXEEXT)
|
||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.tmp 2>/dev/null && \
|
||||
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
|
||||
touch $@; \
|
||||
else \
|
||||
mv $@.tmp $@; \
|
||||
fi
|
||||
$(AM_V_at)rm -f $@*.t
|
||||
$(AM_V_at)rm -f $@*.tmp
|
||||
|
||||
if ENABLE_YACC
|
||||
nodist_man_MANS = doc/yacc.1
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ will generate eight different cases.
|
||||
|
||||
=item B<-b>, B<--bench>
|
||||
|
||||
Predefined benches, that is, combimation between a grammar and a I<directives>
|
||||
Predefined benches, that is, combination between a grammar and a I<directives>
|
||||
request.
|
||||
|
||||
=over 4
|
||||
|
||||
+38
-24
@@ -1,40 +1,54 @@
|
||||
This directory contains examples of Bison grammar files.
|
||||
|
||||
* mfcalc
|
||||
A C example of a multi-function calculator. Extracted from the
|
||||
documentation.
|
||||
Most of them come from the documentation, which should be installed together
|
||||
with Bison. The URLs are provided for convenience.
|
||||
|
||||
* calc++
|
||||
A C++ version of the canonical example for parsers: a calculator. Also uses
|
||||
Flex for the scanner. Extracted from the documentation.
|
||||
|
||||
* variant.yy
|
||||
A C++ example that uses variants (they allow to use any C++ type as semantic
|
||||
value type) and symbol constructors (they ensure consistency between
|
||||
declared token type and effective semantic value).
|
||||
* Examples in C
|
||||
|
||||
** rpcalc - Reverse Polish Notation Calculator
|
||||
The first example is that of a simple double-precision Reverse Polish
|
||||
Notation calculator (a calculator using postfix operators). This example
|
||||
provides a good starting point, since operator precedence is not an issue.
|
||||
|
||||
Extracted from the documentation: "Reverse Polish Notation Calculator"
|
||||
https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
|
||||
|
||||
** mfcalc - Multi-Function Calculator
|
||||
A more complete C example: a multi-function calculator.
|
||||
|
||||
Extracted from the documentation: "Multi-Function Calculator: mfcalc".
|
||||
https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
|
||||
|
||||
|
||||
|
||||
* Examples in C++
|
||||
|
||||
** c++ - A directory of simple C++ examples
|
||||
|
||||
** calc++ - A Complete C++ Example
|
||||
A fully featured C++ version of the canonical example for parsers: a
|
||||
calculator. Also uses Flex for the scanner.
|
||||
|
||||
Extracted from the documentation: "A Complete C++ Example".
|
||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
||||
|
||||
|
||||
-----
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018 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.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BISON = bison
|
||||
CXX = g++
|
||||
CXXFLAGS =
|
||||
PROGS = simple variant variant-11
|
||||
|
||||
simple: CXXFLAGS = -std=c++14
|
||||
variant-11: CXXFLAGS = -std=c++11
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
%.cc %.hh: %.yy
|
||||
$(BISON) $(BISONFLAGS) -o $*.cc $<
|
||||
|
||||
%: %.cc
|
||||
$(CXX) $(CXXFLAGS) -o$@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS:=.cc) $(PROGS)
|
||||
@@ -0,0 +1,47 @@
|
||||
This directory contains examples of Bison grammar files in C++.
|
||||
|
||||
* Examples in C++
|
||||
|
||||
You can run `make` to compile these examples. And `make clean` to tidy
|
||||
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
|
||||
semantic value.
|
||||
|
||||
Run as `./simple`.
|
||||
|
||||
Extracted from the documentation: "A Simple C++ Example".
|
||||
https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html
|
||||
|
||||
** variant.yy - Self-contained example in C++98
|
||||
A variation of simple.yy, in C++98.
|
||||
|
||||
Run as `./variant`.
|
||||
|
||||
** variant-11.yy - Self-contained example in modern C++
|
||||
Another variation of simple.yy, closely related to the previous one, but
|
||||
exhibiting support for C++11's move semantics.
|
||||
|
||||
Run as `./variant` or `./variant NUMBER`.
|
||||
|
||||
-----
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018 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.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy ispell american
|
||||
@@ -0,0 +1,70 @@
|
||||
## Copyright (C) 2018 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/>.
|
||||
|
||||
cxxdir = $(examplesdir)/c++
|
||||
|
||||
## -------- ##
|
||||
## Simple. ##
|
||||
## -------- ##
|
||||
|
||||
BUILT_SOURCES += $(simple_sources)
|
||||
CLEANFILES += %D%/simple.[ch] %D%/simple.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
cxx_DATA = $(simple_extracted)
|
||||
|
||||
simple_extracted = %D%/simple.yy
|
||||
simple_sources = $(simple_extracted)
|
||||
extracted += $(simple_extracted)
|
||||
|
||||
if ENABLE_CXX14
|
||||
check_PROGRAMS += %D%/simple
|
||||
nodist_%C%_simple_SOURCES = $(simple_sources)
|
||||
|
||||
%C%_simple_CXXFLAGS = $(CXX11_CXXFLAGS)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_simple_CPPFLAGS = -I$(top_builddir)
|
||||
TESTS += %D%/simple.test
|
||||
%D%/simple.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
||||
endif
|
||||
EXTRA_DIST += %D%/simple.test
|
||||
|
||||
|
||||
## ---------- ##
|
||||
## Variants. ##
|
||||
## ---------- ##
|
||||
|
||||
if ENABLE_CXX
|
||||
check_PROGRAMS += %D%/variant
|
||||
nodist_%C%_variant_SOURCES = %D%/variant.yy
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_variant_CPPFLAGS = -I$(top_builddir)
|
||||
TESTS += %D%/variant.test
|
||||
%D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
||||
endif
|
||||
EXTRA_DIST += %D%/variant.test
|
||||
|
||||
if ENABLE_CXX11
|
||||
check_PROGRAMS += %D%/variant-11
|
||||
nodist_%C%_variant_11_SOURCES = %D%/variant-11.yy
|
||||
%C%_variant_11_CXXFLAGS = $(CXX11_CXXFLAGS)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
|
||||
TESTS += %D%/variant-11.test
|
||||
%D%/variant-11.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
||||
endif
|
||||
EXTRA_DIST += %D%/variant-11.test
|
||||
|
||||
dist_cxx_DATA = %D%/README %D%/Makefile %D%/variant.yy %D%/variant-11.yy
|
||||
CLEANFILES += %D%/simple.output %D%/variant.output %D%/variant-11.output
|
||||
@@ -0,0 +1,4 @@
|
||||
#! /bin/sh
|
||||
|
||||
: >input
|
||||
run 0 "{I have three numbers for you., 1, 2, 3, And that's all!}"
|
||||
@@ -0,0 +1,21 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018 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/>.
|
||||
|
||||
: >input
|
||||
run 0 "{I have numbers for you., 1, 2, 3, And that's all!}" 4
|
||||
|
||||
run 0 "{I have numbers for you., 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, And that's all!}" 1000
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
Copyright (C) 2008-2015, 2018 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/>.
|
||||
*/
|
||||
|
||||
%require "3.2"
|
||||
%debug
|
||||
%language "c++"
|
||||
%define api.token.constructor
|
||||
%define api.value.type variant
|
||||
%define api.value.automove
|
||||
%define api.location.file none
|
||||
%define parse.assert
|
||||
%locations
|
||||
|
||||
%code requires // *.hh
|
||||
{
|
||||
#include <memory> // std::unique_ptr
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using string_uptr = std::unique_ptr<std::string>;
|
||||
using string_uptrs = std::vector<string_uptr>;
|
||||
}
|
||||
|
||||
%code // *.cc
|
||||
{
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
namespace yy
|
||||
{
|
||||
// Prototype of the yylex function providing subsequent tokens.
|
||||
static parser::symbol_type yylex ();
|
||||
|
||||
// Print a vector of strings.
|
||||
std::ostream&
|
||||
operator<< (std::ostream& o, const string_uptrs& ss)
|
||||
{
|
||||
o << '{';
|
||||
const char *sep = "";
|
||||
for (const auto& s: ss)
|
||||
{
|
||||
o << sep << *s;
|
||||
sep = ", ";
|
||||
}
|
||||
return o << '}';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
string_uptr
|
||||
make_string_uptr (Args&&... args)
|
||||
{
|
||||
// std::make_unique is C++14.
|
||||
return string_uptr (new std::string{std::forward<Args> (args)...});
|
||||
}
|
||||
}
|
||||
|
||||
%token <string_uptr> TEXT;
|
||||
%token <int> NUMBER;
|
||||
%printer { yyo << '(' << &$$ << ") " << $$; } <*>;
|
||||
%printer { yyo << *$$; } <string_uptr>;
|
||||
%token END_OF_FILE 0;
|
||||
|
||||
%type <string_uptr> item;
|
||||
%type <string_uptrs> list;
|
||||
|
||||
%%
|
||||
|
||||
result:
|
||||
list { std::cout << $1 << '\n'; }
|
||||
;
|
||||
|
||||
list:
|
||||
%empty { /* Generates an empty string list */ }
|
||||
| list item { $$ = $1; $$.emplace_back ($2); }
|
||||
;
|
||||
|
||||
item:
|
||||
TEXT
|
||||
| NUMBER { $$ = make_string_uptr (std::to_string ($1)); }
|
||||
;
|
||||
%%
|
||||
|
||||
// The last number return by the scanner is max - 1.
|
||||
int max = 4;
|
||||
|
||||
namespace yy
|
||||
{
|
||||
// The yylex function providing subsequent tokens:
|
||||
// TEXT "I have three numbers for you."
|
||||
// NUMBER 1
|
||||
// NUMBER 2
|
||||
// NUMBER ...
|
||||
// NUMBER max - 1
|
||||
// TEXT "And that's all!"
|
||||
// END_OF_FILE
|
||||
|
||||
static
|
||||
parser::symbol_type
|
||||
yylex ()
|
||||
{
|
||||
static int count = 0;
|
||||
const int stage = count;
|
||||
++count;
|
||||
auto loc = parser::location_type{nullptr, unsigned (stage + 1), unsigned (stage + 1)};
|
||||
if (stage == 0)
|
||||
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
||||
else if (stage < max)
|
||||
return parser::make_NUMBER (stage, std::move (loc));
|
||||
else if (stage == max)
|
||||
return parser::make_TEXT (make_string_uptr ("And that's all!"), std::move (loc));
|
||||
else
|
||||
return parser::make_END_OF_FILE (std::move (loc));
|
||||
}
|
||||
|
||||
// Mandatory error function
|
||||
void
|
||||
parser::error (const parser::location_type& loc, const std::string& msg)
|
||||
{
|
||||
std::cerr << loc << ": " << msg << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
if (2 <= argc && isdigit (*argv[1]))
|
||||
max = strtol (argv[1], nullptr, 10);
|
||||
auto&& p = yy::parser{};
|
||||
p.set_debug_level (!!getenv ("YYDEBUG"));
|
||||
return p.parse ();
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// End:
|
||||
@@ -15,11 +15,12 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
%require "3.2"
|
||||
%debug
|
||||
%language "c++"
|
||||
%defines
|
||||
%define api.token.constructor
|
||||
%define api.value.type variant
|
||||
%define api.location.file none
|
||||
%define parse.assert
|
||||
%locations
|
||||
|
||||
@@ -37,22 +38,18 @@ typedef std::vector<std::string> strings_type;
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
// Prototype of the yylex function providing subsequent tokens.
|
||||
namespace yy
|
||||
{
|
||||
// Prototype of the yylex function providing subsequent tokens.
|
||||
static parser::symbol_type yylex ();
|
||||
}
|
||||
|
||||
// Printing a vector of strings.
|
||||
// Koening look up will look into std, since that's an std::vector.
|
||||
namespace std
|
||||
{
|
||||
// Print a vector of strings.
|
||||
std::ostream&
|
||||
operator<< (std::ostream& o, const strings_type& ss)
|
||||
{
|
||||
o << '{';
|
||||
const char *sep = "";
|
||||
for (strings_type::const_iterator i = ss.begin(), end = ss.end();
|
||||
for (strings_type::const_iterator i = ss.begin (), end = ss.end ();
|
||||
i != end; ++i)
|
||||
{
|
||||
o << sep << *i;
|
||||
@@ -62,10 +59,10 @@ typedef std::vector<std::string> strings_type;
|
||||
}
|
||||
}
|
||||
|
||||
// Conversion to string.
|
||||
// Convert to string.
|
||||
template <typename T>
|
||||
std::string
|
||||
string_cast (const T& t)
|
||||
to_string (const T& t)
|
||||
{
|
||||
std::ostringstream o;
|
||||
o << t;
|
||||
@@ -93,13 +90,20 @@ list:
|
||||
;
|
||||
|
||||
item:
|
||||
TEXT { std::swap ($$, $1); }
|
||||
| NUMBER { $$ = string_cast ($1); }
|
||||
TEXT
|
||||
| NUMBER { $$ = to_string ($1); }
|
||||
;
|
||||
%%
|
||||
|
||||
namespace yy
|
||||
{
|
||||
// Use nullptr with pre-C++11.
|
||||
#if !defined __cplusplus || __cplusplus < 201103L
|
||||
# define NULLPTR 0
|
||||
#else
|
||||
# define NULLPTR nullptr
|
||||
#endif
|
||||
|
||||
// The yylex function providing subsequent tokens:
|
||||
// TEXT "I have three numbers for you."
|
||||
// NUMBER 1
|
||||
@@ -112,9 +116,10 @@ namespace yy
|
||||
parser::symbol_type
|
||||
yylex ()
|
||||
{
|
||||
static int stage = -1;
|
||||
++stage;
|
||||
parser::location_type loc(YY_NULLPTR, stage + 1, stage + 1);
|
||||
static int count = 0;
|
||||
const int stage = count;
|
||||
++count;
|
||||
parser::location_type loc (NULLPTR, unsigned (stage + 1), unsigned (stage + 1));
|
||||
switch (stage)
|
||||
{
|
||||
case 0:
|
||||
@@ -29,6 +29,7 @@ the scanner's.
|
||||
Local Variables:
|
||||
mode: outline
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
@@ -48,4 +49,4 @@ 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: mfcalc calc parsers yy MERCHANTABILITY
|
||||
# LocalWords: mfcalc calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||
|
||||
@@ -19,7 +19,8 @@ cat >input <<EOF
|
||||
toto := 1
|
||||
toto
|
||||
EOF
|
||||
run 0 1 -s
|
||||
run 0 1
|
||||
run -noerr 0 1 -s
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
@@ -30,7 +31,7 @@ d := a + b * c
|
||||
d
|
||||
EOF
|
||||
run 0 7
|
||||
run 0 7 -p
|
||||
run -noerr 0 7 -p
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
@@ -47,4 +48,11 @@ cat >input <<EOF
|
||||
a := 1
|
||||
d := a + b * c
|
||||
EOF
|
||||
run 1 ''
|
||||
run 1 'err: -:3.1: syntax error, unexpected end of file, expecting ( or identifier or number'
|
||||
|
||||
|
||||
cat >input <<EOF
|
||||
a := 072101108108111044032119111114108100033
|
||||
a
|
||||
EOF
|
||||
run 1 'err: -:1.6-44: integer is out of range: 072101108108111044032119111114108100033'
|
||||
|
||||
+26
-28
@@ -1,18 +1,18 @@
|
||||
# Copyright (C) 2005-2006, 2008-2015, 2018 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/>.
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018 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/>.
|
||||
|
||||
## ------------------- ##
|
||||
## Parser generation. ##
|
||||
@@ -36,7 +36,7 @@ CLEANFILES += \
|
||||
%D%/parser.output \
|
||||
%D%/parser.stamp \
|
||||
%D%/scanner.cc
|
||||
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
## -------------------- ##
|
||||
## Building & testing. ##
|
||||
@@ -57,24 +57,22 @@ extracted += $(calcxx_extracted)
|
||||
calcxx_sources_generated = \
|
||||
%D%/parser.cc \
|
||||
%D%/parser.hh \
|
||||
%D%/location.hh \
|
||||
%D%/position.hh \
|
||||
%D%/stack.hh
|
||||
%D%/location.hh
|
||||
calcxx_sources = \
|
||||
$(calcxx_sources_extracted) \
|
||||
$(calcxx_sources_generated)
|
||||
|
||||
if FLEX_CXX_WORKS
|
||||
check_PROGRAMS += %D%/calc++
|
||||
nodist_%C%_calc___SOURCES = \
|
||||
$(calcxx_sources)
|
||||
|
||||
%C%_calc___CPPFLAGS = -I$(top_builddir)/%D%
|
||||
%C%_calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
|
||||
dist_TESTS += %D%/calc++.test
|
||||
else
|
||||
if ENABLE_CXX
|
||||
check_PROGRAMS += %D%/calc++
|
||||
nodist_%C%_calc___SOURCES = $(calcxx_sources)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_calc___CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
%C%_calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
|
||||
TESTS += %D%/calc++.test
|
||||
endif ENABLE_CXX
|
||||
endif FLEX_CXX_WORKS
|
||||
EXTRA_DIST += %D%/calc++.test
|
||||
endif
|
||||
|
||||
|
||||
## ------------ ##
|
||||
|
||||
+19
-2
@@ -32,9 +32,24 @@
|
||||
# output before block 2, even if the latter appears before). The same
|
||||
# number may be used several time, in which case the order of
|
||||
# appearance is used.
|
||||
#
|
||||
# Use @ignore for code to extract that must not be part of the
|
||||
# documentation. For instance:
|
||||
#
|
||||
# @ignore
|
||||
# @comment file: calc++/scanner.ll
|
||||
# @example
|
||||
# // Work around an incompatibility in Flex.
|
||||
# # undef yywrap
|
||||
# # define yywrap() 1
|
||||
# @end example
|
||||
# @end ignore
|
||||
|
||||
use strict;
|
||||
|
||||
use File::Basename qw(dirname);
|
||||
use File::Path qw(make_path);
|
||||
|
||||
# Whether we generate synclines.
|
||||
my $synclines = 0;
|
||||
|
||||
@@ -80,7 +95,9 @@ sub file_wanted ($)
|
||||
undef
|
||||
}
|
||||
|
||||
|
||||
# process ($in)
|
||||
# -------------
|
||||
# Read input file $in, and generate the outputs.
|
||||
sub process ($)
|
||||
{
|
||||
my ($in) = @_;
|
||||
@@ -140,7 +157,7 @@ sub process ($)
|
||||
# Output the files.
|
||||
for my $file (keys %file)
|
||||
{
|
||||
# No spurious end of line: use printf.
|
||||
make_path (dirname ($file));
|
||||
my $o = new IO::File(">$file")
|
||||
or die "$file: cannot create: $?";
|
||||
print $o $file{$file}{$_}
|
||||
|
||||
+43
-21
@@ -1,17 +1,17 @@
|
||||
# Copyright (C) 2005, 2008-2015, 2018 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/>.
|
||||
## Copyright (C) 2005, 2008-2015, 2018 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/>.
|
||||
|
||||
dist_noinst_SCRIPTS = %D%/extexi %D%/test
|
||||
TEST_LOG_COMPILER = $(top_srcdir)/%D%/test
|
||||
@@ -30,9 +30,11 @@ EXTEXIFLAGS = --synclines
|
||||
endif
|
||||
extract = VERSION="$(VERSION)" $(PERL) $(extexi) $(EXTEXIFLAGS) $(doc) --
|
||||
extracted =
|
||||
CLEANFILES += $(extracted) %D%/extracted.stamp
|
||||
EXTRA_DIST += $(extracted)
|
||||
MAINTAINERCLEANFILES += $(extracted) %D%/extracted.stamp
|
||||
%D%/extracted.stamp: $(doc) $(extexi)
|
||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||
$(AM_V_at)$(MKDIR_P) %D%
|
||||
$(AM_V_at)touch $@.tmp
|
||||
$(AM_V_at)$(extract) $(extracted)
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
@@ -41,19 +43,39 @@ $(extracted): %D%/extracted.stamp
|
||||
@test -f $@ || rm -f %D%/extracted.stamp
|
||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/extracted.stamp
|
||||
|
||||
|
||||
## ------ ##
|
||||
## Dist. ##
|
||||
## ------ ##
|
||||
|
||||
# Ship the stamp file, otherwise it will be recreated, which is what
|
||||
# we want to avoid.
|
||||
EXTRA_DIST += %D%/extracted.stamp
|
||||
|
||||
# Suppress the #lines from the examples when rolling the tarball, so
|
||||
# that regular users have readable examples even before installing
|
||||
# Bison.
|
||||
dist-hook: examples-unline
|
||||
.PHONY: examples-unline
|
||||
examples-unline:
|
||||
for e in $(extracted); \
|
||||
do \
|
||||
e=$(distdir)/$$e; \
|
||||
sed -e '/#line/d' $$e >$$e.tmp; \
|
||||
mv -f $$e.tmp $$e; \
|
||||
done
|
||||
|
||||
|
||||
## ---------- ##
|
||||
## Examples. ##
|
||||
## ---------- ##
|
||||
|
||||
examplesdir = $(docdir)/examples
|
||||
dist_examples_DATA = %D%/README %D%/variant.yy
|
||||
|
||||
check_PROGRAMS += %D%/variant
|
||||
nodist_%C%_variant_SOURCES = %D%/variant.yy
|
||||
%C%_variant_CPPFLAGS = -I$(top_builddir)
|
||||
dist_TESTS += %D%/variant.test
|
||||
dist_examples_DATA = %D%/README
|
||||
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
include %D%/calc++/local.mk
|
||||
include %D%/c++/local.mk
|
||||
include %D%/mfcalc/local.mk
|
||||
include %D%/rpcalc/local.mk
|
||||
|
||||
+18
-16
@@ -1,18 +1,18 @@
|
||||
# Copyright (C) 2005-2006, 2008-2015, 2018 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/>.
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018 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/>.
|
||||
|
||||
## -------------------- ##
|
||||
## Building & testing. ##
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
BUILT_SOURCES += $(mfcalc_sources)
|
||||
CLEANFILES += %D%/mfcalc.[ch] %D%/mfcalc.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
mfcalc_extracted = %D%/calc.h %D%/mfcalc.y
|
||||
mfcalc_sources = $(mfcalc_extracted)
|
||||
@@ -27,7 +28,8 @@ extracted += $(mfcalc_extracted)
|
||||
|
||||
check_PROGRAMS += %D%/mfcalc
|
||||
nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
|
||||
%C%_mfcalc_CPPFLAGS = -I$(top_builddir)/%D%
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
%C%_mfcalc_LDADD = -lm
|
||||
|
||||
dist_TESTS += %D%/mfcalc.test
|
||||
|
||||
@@ -24,4 +24,4 @@ cat >input <<EOF
|
||||
(1+2) * 3
|
||||
EOF
|
||||
run 0 9
|
||||
run 0 9 -p
|
||||
run -noerr 0 9 -p
|
||||
|
||||
+17
-15
@@ -1,18 +1,18 @@
|
||||
# Copyright (C) 2005-2006, 2008-2015, 2018 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/>.
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018 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/>.
|
||||
|
||||
## -------------------- ##
|
||||
## Building & testing. ##
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
BUILT_SOURCES += $(rpcalc_sources)
|
||||
CLEANFILES += %D%/rpcalc.[ch] %D%/rpcalc.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
rpcalc_extracted = %D%/rpcalc.y
|
||||
rpcalc_sources = $(rpcalc_extracted)
|
||||
@@ -27,6 +28,7 @@ extracted += $(rpcalc_extracted)
|
||||
|
||||
check_PROGRAMS += %D%/rpcalc
|
||||
nodist_%C%_rpcalc_SOURCES = $(rpcalc_sources)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_rpcalc_CPPFLAGS = -I$(top_builddir)/%D%
|
||||
%C%_rpcalc_LDADD = -lm
|
||||
|
||||
|
||||
+21
-14
@@ -15,7 +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/>.
|
||||
|
||||
me=`basename $1 .test`
|
||||
me=$(basename "$1" .test)
|
||||
medir=$(basename "$(dirname "$1")")
|
||||
|
||||
# Number of the current test.
|
||||
number=1
|
||||
@@ -23,11 +24,11 @@ number=1
|
||||
# Exit status of this script.
|
||||
exit=true
|
||||
|
||||
# top_buiddir.
|
||||
cwd=`pwd`
|
||||
# top_builddir.
|
||||
cwd=$(pwd)
|
||||
|
||||
# The exercised program.
|
||||
for p in $cwd/examples/$me/$me $cwd/examples/$me
|
||||
for p in "$cwd/examples/$medir/$me" "$cwd/examples/$me"
|
||||
do
|
||||
if test -x "$p"; then
|
||||
prog=$p
|
||||
@@ -44,7 +45,7 @@ fi
|
||||
# -------
|
||||
cleanup ()
|
||||
{
|
||||
local status=$?
|
||||
status=$?
|
||||
if test -z "$DEBUG"; then
|
||||
cd $cwd
|
||||
rm -rf $$.dir
|
||||
@@ -55,21 +56,27 @@ trap cleanup 0 1 2 13 15
|
||||
mkdir $$.dir
|
||||
cd $$.dir
|
||||
|
||||
# run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
|
||||
# ---------------------------------------------------------
|
||||
# run [-noerr] EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
|
||||
# ------------------------------------------------------------------
|
||||
# -noerr: ignore stderr, otherwise merge it into effective output.
|
||||
run ()
|
||||
{
|
||||
noerr=false
|
||||
case $1 in
|
||||
(-noerr) noerr=true; shift;;
|
||||
esac
|
||||
|
||||
# Expected exit status.
|
||||
local sta_exp=$1
|
||||
sta_exp=$1
|
||||
shift
|
||||
# Expected output.
|
||||
local out_exp=$1
|
||||
out_exp=$1
|
||||
shift
|
||||
# Effective exit status.
|
||||
local sta_eff=0
|
||||
$prog "$@" - <input >out_eff || sta_eff=$?
|
||||
# Effective output.
|
||||
local out_eff=`cat out_eff`
|
||||
sta_eff=0
|
||||
$prog "$@" - <input >out_eff 2>err_eff || sta_eff=$?
|
||||
# Combine effective output and error streams.
|
||||
out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff)
|
||||
if test $sta_eff -eq $sta_exp; then
|
||||
if test "$out_eff" = "$out_exp"; then
|
||||
echo "$me: PASS: $number"
|
||||
@@ -81,7 +88,7 @@ run ()
|
||||
echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)"
|
||||
exit=false
|
||||
fi
|
||||
number=`expr $number + 1`
|
||||
number=$(expr $number + 1)
|
||||
}
|
||||
|
||||
# We have cd'd one level deeper.
|
||||
|
||||
+1
-1
Submodule gnulib updated: a05181f4bd...a79f2a2871
@@ -273,3 +273,19 @@
|
||||
/xstrndup.h
|
||||
/stat-time.c
|
||||
/stat-time.h
|
||||
/timevar.c
|
||||
/timevar.h
|
||||
/sys_time.in.h
|
||||
/sys_times.in.h
|
||||
/gethrxtime.c
|
||||
/gethrxtime.h
|
||||
/getrusage.c
|
||||
/gettime.c
|
||||
/gettimeofday.c
|
||||
/localtime-buffer.c
|
||||
/localtime-buffer.h
|
||||
/sys_resource.in.h
|
||||
/timespec.c
|
||||
/timespec.h
|
||||
/xtime.c
|
||||
/xtime.h
|
||||
|
||||
+68
-124
@@ -35,33 +35,28 @@
|
||||
static bitset_bindex
|
||||
abitset_resize (bitset src, bitset_bindex size)
|
||||
{
|
||||
/* These bitsets have a fixed size. */
|
||||
if (BITSET_SIZE_ (src) != size)
|
||||
abort ();
|
||||
/* These bitsets have a fixed size. */
|
||||
if (BITSET_SIZE_ (src) != size)
|
||||
abort ();
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static bitset_bindex
|
||||
abitset_small_list (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex size;
|
||||
bitset_word word;
|
||||
|
||||
word = ABITSET_WORDS (src)[0];
|
||||
bitset_word word = ABITSET_WORDS (src)[0];
|
||||
|
||||
/* Short circuit common case. */
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
size = BITSET_SIZE_ (src);
|
||||
bitno = *next;
|
||||
bitset_windex size = BITSET_SIZE_ (src);
|
||||
bitset_bindex bitno = *next;
|
||||
if (bitno >= size)
|
||||
return 0;
|
||||
|
||||
@@ -70,6 +65,7 @@ abitset_small_list (bitset src, bitset_bindex *list,
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
bitset_bindex count;
|
||||
if (num >= BITSET_WORD_BITS)
|
||||
{
|
||||
for (count = 0; word; bitno++)
|
||||
@@ -142,36 +138,27 @@ static bitset_bindex
|
||||
abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex rbitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
unsigned bitcnt;
|
||||
bitset_bindex bitoff;
|
||||
bitset_bindex rbitno = *next;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_bindex n_bits = BITSET_SIZE_ (src);
|
||||
|
||||
rbitno = *next;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
if (rbitno >= n_bits)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
bitset_bindex count = 0;
|
||||
|
||||
bitno = n_bits - (rbitno + 1);
|
||||
bitset_bindex bitno = n_bits - (rbitno + 1);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
unsigned bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
|
||||
|
||||
do
|
||||
{
|
||||
bitset_word word;
|
||||
|
||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
for (; word; bitcnt--)
|
||||
{
|
||||
if (word & BITSET_MSB)
|
||||
@@ -196,23 +183,20 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static bitset_bindex
|
||||
abitset_list (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
bitset_bindex bitoff;
|
||||
bitset_windex size = src->b.csize;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word word;
|
||||
|
||||
bitno = *next;
|
||||
bitset_bindex bitno = *next;
|
||||
|
||||
count = 0;
|
||||
bitset_bindex count = 0;
|
||||
if (!bitno)
|
||||
{
|
||||
/* Many bitsets are zero, so make this common case fast. */
|
||||
@@ -242,7 +226,7 @@ abitset_list (bitset src, bitset_bindex *list,
|
||||
on the previous call to this function. */
|
||||
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
word = srcp[windex] >> bitno;
|
||||
bitset_word word = srcp[windex] >> bitno;
|
||||
for (bitno = bitoff + bitno; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
@@ -263,7 +247,8 @@ abitset_list (bitset src, bitset_bindex *list,
|
||||
|
||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||
{
|
||||
if (!(word = srcp[windex]))
|
||||
bitset_word word = srcp[windex];
|
||||
if (!word)
|
||||
continue;
|
||||
|
||||
if ((count + BITSET_WORD_BITS) < num)
|
||||
@@ -302,9 +287,7 @@ abitset_list (bitset src, bitset_bindex *list,
|
||||
static inline void
|
||||
abitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned last_bit;
|
||||
|
||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||
if (last_bit)
|
||||
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||
((bitset_word) 1 << last_bit) - 1;
|
||||
@@ -315,9 +298,7 @@ static void
|
||||
abitset_ones (bitset dst)
|
||||
{
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
size_t bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
size_t bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
|
||||
memset (dstp, -1, bytes);
|
||||
abitset_unused_clear (dst);
|
||||
@@ -328,9 +309,7 @@ static void
|
||||
abitset_zero (bitset dst)
|
||||
{
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
size_t bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
size_t bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
|
||||
memset (dstp, 0, bytes);
|
||||
}
|
||||
@@ -339,13 +318,11 @@ abitset_zero (bitset dst)
|
||||
static bool
|
||||
abitset_empty_p (bitset dst)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
|
||||
for (i = 0; i < dst->b.csize; i++)
|
||||
for (bitset_windex i = 0; i < dst->b.csize; i++)
|
||||
if (dstp[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -355,10 +332,9 @@ abitset_copy1 (bitset dst, bitset src)
|
||||
{
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
if (srcp == dstp)
|
||||
return;
|
||||
return;
|
||||
bitset_windex size = dst->b.csize;
|
||||
memcpy (dstp, srcp, sizeof (bitset_word) * size);
|
||||
}
|
||||
|
||||
@@ -366,13 +342,12 @@ abitset_copy1 (bitset dst, bitset src)
|
||||
static void
|
||||
abitset_not (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
abitset_unused_clear (dst);
|
||||
}
|
||||
|
||||
@@ -380,14 +355,13 @@ abitset_not (bitset dst, bitset src)
|
||||
static bool
|
||||
abitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ != *dstp++)
|
||||
return false;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
if (*srcp++ != *dstp++)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -395,14 +369,13 @@ abitset_equal_p (bitset dst, bitset src)
|
||||
static bool
|
||||
abitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return false;
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++, srcp++)
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -410,15 +383,13 @@ abitset_subset_p (bitset dst, bitset src)
|
||||
static bool
|
||||
abitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return false;
|
||||
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -426,31 +397,28 @@ abitset_disjoint_p (bitset dst, bitset src)
|
||||
static void
|
||||
abitset_and (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ & *src2p++;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ & *src2p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
@@ -464,31 +432,28 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
abitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ & ~(*src2p++);
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ & ~(*src2p++);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
@@ -502,28 +467,26 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
abitset_or (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ | *src2p++;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ | *src2p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ | *src2p++;
|
||||
|
||||
@@ -540,28 +503,26 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
abitset_xor (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ ^ *src2p++;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ ^ *src2p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||
|
||||
@@ -578,22 +539,20 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
@@ -601,10 +560,9 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
@@ -618,22 +576,20 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
static void
|
||||
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
@@ -641,10 +597,9 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
@@ -658,22 +613,20 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
static void
|
||||
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||
for (bitset_windex i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
@@ -681,10 +634,9 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
@@ -699,9 +651,9 @@ static void
|
||||
abitset_copy (bitset dst, bitset src)
|
||||
{
|
||||
if (BITSET_COMPATIBLE_ (dst, src))
|
||||
abitset_copy1 (dst, src);
|
||||
abitset_copy1 (dst, src);
|
||||
else
|
||||
bitset_copy_ (dst, src);
|
||||
bitset_copy_ (dst, src);
|
||||
}
|
||||
|
||||
|
||||
@@ -784,14 +736,12 @@ struct bitset_vtable abitset_vtable = {
|
||||
size_t
|
||||
abitset_bytes (bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex size;
|
||||
size_t bytes;
|
||||
size_t header_size = offsetof (union bitset_union, a.words);
|
||||
struct bitset_align_struct { char a; union bitset_union b; };
|
||||
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
||||
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
bytes = header_size + size * sizeof (bitset_word);
|
||||
bitset_windex size = ABITSET_N_WORDS (n_bits);
|
||||
size_t bytes = header_size + size * sizeof (bitset_word);
|
||||
|
||||
/* Align the size properly for a vector of abitset objects. */
|
||||
if (header_size % bitset_alignment != 0
|
||||
@@ -808,19 +758,13 @@ abitset_bytes (bitset_bindex n_bits)
|
||||
bitset
|
||||
abitset_init (bitset bset, bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
bitset_windex size = ABITSET_N_WORDS (n_bits);
|
||||
BITSET_NBITS_ (bset) = n_bits;
|
||||
|
||||
/* Use optimized routines if bitset fits within a single word.
|
||||
There is probably little merit if using caching since
|
||||
the small bitset will always fit in the cache. */
|
||||
if (size == 1)
|
||||
bset->b.vtable = &abitset_small_vtable;
|
||||
else
|
||||
bset->b.vtable = &abitset_vtable;
|
||||
|
||||
bset->b.vtable = size == 1 ? &abitset_small_vtable : &abitset_vtable;
|
||||
bset->b.cindex = 0;
|
||||
bset->b.csize = size;
|
||||
bset->b.cdata = ABITSET_WORDS (bset);
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t abitset_bytes (bitset_bindex);
|
||||
size_t abitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset abitset_init (bitset, bitset_bindex);
|
||||
bitset abitset_init (bitset, bitset_bindex);
|
||||
|
||||
#endif
|
||||
|
||||
+21
-13
@@ -21,12 +21,20 @@
|
||||
#ifndef _BBITSET_H
|
||||
#define _BBITSET_H
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
|
||||
/* Currently we support five flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
|
||||
Memory for bit array and bitset structure allocated
|
||||
@@ -281,24 +289,24 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
||||
|
||||
/* Private functions for bitset implementations. */
|
||||
|
||||
extern bool bitset_toggle_ (bitset, bitset_bindex);
|
||||
bool bitset_toggle_ (bitset, bitset_bindex);
|
||||
|
||||
extern bitset_bindex bitset_count_ (bitset);
|
||||
bitset_bindex bitset_count_ (bitset);
|
||||
|
||||
extern bitset_bindex bitset_size_ (bitset);
|
||||
bitset_bindex bitset_size_ (bitset);
|
||||
|
||||
extern bool bitset_copy_ (bitset, bitset);
|
||||
bool bitset_copy_ (bitset, bitset);
|
||||
|
||||
extern void bitset_and_or_ (bitset, bitset, bitset, bitset);
|
||||
void bitset_and_or_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern void bitset_andn_or_ (bitset, bitset, bitset, bitset);
|
||||
void bitset_andn_or_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern void bitset_or_and_ (bitset, bitset, bitset, bitset);
|
||||
void bitset_or_and_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
|
||||
bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
#endif /* _BBITSET_H */
|
||||
|
||||
+33
-57
@@ -24,12 +24,14 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "obstack.h"
|
||||
|
||||
#include "abitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "vbitset.h"
|
||||
#include "bitset_stats.h"
|
||||
#include "obstack.h"
|
||||
|
||||
const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
|
||||
|
||||
@@ -39,8 +41,6 @@ const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
|
||||
size_t
|
||||
bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
|
||||
{
|
||||
size_t bytes;
|
||||
|
||||
if (bitset_stats_enabled)
|
||||
return bitset_stats_bytes ();
|
||||
|
||||
@@ -50,23 +50,17 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
|
||||
abort ();
|
||||
|
||||
case BITSET_ARRAY:
|
||||
bytes = abitset_bytes (n_bits);
|
||||
break;
|
||||
return abitset_bytes (n_bits);
|
||||
|
||||
case BITSET_LIST:
|
||||
bytes = lbitset_bytes (n_bits);
|
||||
break;
|
||||
return lbitset_bytes (n_bits);
|
||||
|
||||
case BITSET_TABLE:
|
||||
bytes = ebitset_bytes (n_bits);
|
||||
break;
|
||||
return ebitset_bytes (n_bits);
|
||||
|
||||
case BITSET_VARRAY:
|
||||
bytes = vbitset_bytes (n_bits);
|
||||
break;
|
||||
return vbitset_bytes (n_bits);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,12 +128,9 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
|
||||
bitset
|
||||
bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
||||
{
|
||||
size_t bytes;
|
||||
bitset bset;
|
||||
size_t bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bset = xcalloc (1, bytes);
|
||||
bitset bset = xcalloc (1, bytes);
|
||||
|
||||
/* The cache is disabled until some elements are allocated. If we
|
||||
have variable length arrays, then we may need to allocate a dummy
|
||||
@@ -154,12 +145,9 @@ bitset
|
||||
bitset_obstack_alloc (struct obstack *bobstack,
|
||||
bitset_bindex n_bits, enum bitset_type type)
|
||||
{
|
||||
size_t bytes;
|
||||
bitset bset;
|
||||
size_t bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bset = obstack_alloc (bobstack, bytes);
|
||||
bitset bset = obstack_alloc (bobstack, bytes);
|
||||
memset (bset, 0, bytes);
|
||||
|
||||
return bitset_init (bset, n_bits, type);
|
||||
@@ -171,9 +159,7 @@ bitset_obstack_alloc (struct obstack *bobstack,
|
||||
bitset
|
||||
bitset_create (bitset_bindex n_bits, unsigned attr)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
type = bitset_type_choose (n_bits, attr);
|
||||
enum bitset_type type = bitset_type_choose (n_bits, attr);
|
||||
|
||||
return bitset_alloc (n_bits, type);
|
||||
}
|
||||
@@ -200,11 +186,9 @@ bitset_obstack_free (bitset bset)
|
||||
enum bitset_type
|
||||
bitset_type_get (bitset bset)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
type = BITSET_TYPE_ (bset);
|
||||
enum bitset_type type = BITSET_TYPE_ (bset);
|
||||
if (type != BITSET_STATS)
|
||||
return type;
|
||||
return type;
|
||||
|
||||
return bitset_stats_type_get (bset);
|
||||
}
|
||||
@@ -214,9 +198,7 @@ bitset_type_get (bitset bset)
|
||||
const char *
|
||||
bitset_type_name_get (bitset bset)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
type = bitset_type_get (bset);
|
||||
enum bitset_type type = bitset_type_get (bset);
|
||||
|
||||
return bitset_type_names[type];
|
||||
}
|
||||
@@ -227,9 +209,8 @@ bitset_type_name_get (bitset bset)
|
||||
bitset_bindex
|
||||
bitset_next (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset_bindex val;
|
||||
bitset_bindex next = bitno;
|
||||
|
||||
bitset_bindex val;
|
||||
if (!bitset_list (src, &val, 1, &next))
|
||||
return BITSET_BINDEX_MAX;
|
||||
return val;
|
||||
@@ -240,7 +221,7 @@ bitset_next (bitset src, bitset_bindex bitno)
|
||||
extern bool
|
||||
bitset_compatible_p (bitset bset1, bitset bset2)
|
||||
{
|
||||
return BITSET_COMPATIBLE_ (bset1, bset2);
|
||||
return BITSET_COMPATIBLE_ (bset1, bset2);
|
||||
}
|
||||
|
||||
|
||||
@@ -249,9 +230,8 @@ bitset_compatible_p (bitset bset1, bitset bset2)
|
||||
bitset_bindex
|
||||
bitset_prev (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset_bindex val;
|
||||
bitset_bindex next = bitno;
|
||||
|
||||
bitset_bindex val;
|
||||
if (!bitset_list_reverse (src, &val, 1, &next))
|
||||
return BITSET_BINDEX_MAX;
|
||||
return val;
|
||||
@@ -291,15 +271,13 @@ bitset_only_set_p (bitset src, bitset_bindex bitno)
|
||||
static void
|
||||
bitset_print (FILE *file, bitset bset, bool verbose)
|
||||
{
|
||||
unsigned pos;
|
||||
bitset_bindex i;
|
||||
bitset_iterator iter;
|
||||
|
||||
if (verbose)
|
||||
fprintf (file, "n_bits = %lu, set = {",
|
||||
(unsigned long) bitset_size (bset));
|
||||
|
||||
pos = 30;
|
||||
unsigned pos = 30;
|
||||
bitset_bindex i;
|
||||
bitset_iterator iter;
|
||||
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||
{
|
||||
if (pos > 70)
|
||||
@@ -310,7 +288,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
|
||||
|
||||
fprintf (file, "%lu ", (unsigned long) i);
|
||||
pos += 1 + (i >= 10) + (i >= 100);
|
||||
};
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
fprintf (file, "}\n");
|
||||
@@ -357,7 +335,7 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
|
||||
bitset_bindex
|
||||
bitset_size_ (bitset src)
|
||||
{
|
||||
return BITSET_NBITS_ (src);
|
||||
return BITSET_NBITS_ (src);
|
||||
}
|
||||
|
||||
|
||||
@@ -366,18 +344,18 @@ bitset_bindex
|
||||
bitset_count_ (bitset src)
|
||||
{
|
||||
bitset_bindex list[BITSET_LIST_SIZE];
|
||||
bitset_bindex next;
|
||||
bitset_bindex num;
|
||||
bitset_bindex count;
|
||||
bitset_bindex count = 0;
|
||||
|
||||
/* This could be greatly sped up by adding a count method for each
|
||||
bitset implementation that uses a direct technique (based on
|
||||
masks) for counting the number of bits set in a word. */
|
||||
|
||||
next = 0;
|
||||
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
|
||||
count += num)
|
||||
continue;
|
||||
{
|
||||
bitset_bindex next = 0;
|
||||
bitset_bindex num;
|
||||
while ((num = bitset_list (src, list, BITSET_LIST_SIZE, &next)))
|
||||
count += num;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -398,7 +376,7 @@ bitset_copy_ (bitset dst, bitset src)
|
||||
BITSET_FOR_EACH (iter, src, i, 0)
|
||||
{
|
||||
bitset_set (dst, i);
|
||||
};
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -411,13 +389,11 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
||||
enum bitset_ops op)
|
||||
{
|
||||
bool changed = false;
|
||||
bool stats_enabled_save;
|
||||
bitset tmp;
|
||||
|
||||
/* Create temporary bitset. */
|
||||
stats_enabled_save = bitset_stats_enabled;
|
||||
bool stats_enabled_save = bitset_stats_enabled;
|
||||
bitset_stats_enabled = false;
|
||||
tmp = bitset_alloc (0, bitset_type_get (dst));
|
||||
bitset tmp = bitset_alloc (0, bitset_type_get (dst));
|
||||
bitset_stats_enabled = stats_enabled_save;
|
||||
|
||||
switch (op)
|
||||
|
||||
+30
-35
@@ -24,14 +24,14 @@
|
||||
/* This file is the public interface to the bitset abstract data type.
|
||||
Only use the functions and macros defined in this file. */
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "obstack.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "obstack.h"
|
||||
|
||||
/* Attributes used to select a bitset implementation. */
|
||||
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
||||
BITSET_VARIABLE = 2, /* Bitset size variable. */
|
||||
@@ -83,7 +83,6 @@ union bitset_union
|
||||
struct bbitset_struct b;
|
||||
bitset_windex size; /* Allocated size of array. */
|
||||
} v;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -99,37 +98,37 @@ typedef struct
|
||||
|
||||
|
||||
/* Return bytes required for bitset of desired type and size. */
|
||||
extern size_t bitset_bytes (enum bitset_type, bitset_bindex);
|
||||
size_t bitset_bytes (enum bitset_type, bitset_bindex);
|
||||
|
||||
/* Initialise a bitset with desired type and size. */
|
||||
extern bitset bitset_init (bitset, bitset_bindex, enum bitset_type);
|
||||
bitset bitset_init (bitset, bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Select an implementation type based on the desired bitset size
|
||||
and attributes. */
|
||||
extern enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
|
||||
enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
|
||||
|
||||
/* Create a bitset of desired type and size. The bitset is zeroed. */
|
||||
extern bitset bitset_alloc (bitset_bindex, enum bitset_type);
|
||||
bitset bitset_alloc (bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Free bitset. */
|
||||
extern void bitset_free (bitset);
|
||||
void bitset_free (bitset);
|
||||
|
||||
/* Create a bitset of desired type and size using an obstack. The
|
||||
bitset is zeroed. */
|
||||
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
||||
bitset_bindex, enum bitset_type);
|
||||
bitset bitset_obstack_alloc (struct obstack *bobstack,
|
||||
bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Free bitset allocated on obstack. */
|
||||
extern void bitset_obstack_free (bitset);
|
||||
void bitset_obstack_free (bitset);
|
||||
|
||||
/* Create a bitset of desired size and attributes. The bitset is zeroed. */
|
||||
extern bitset bitset_create (bitset_bindex, bitset_attrs);
|
||||
bitset bitset_create (bitset_bindex, bitset_attrs);
|
||||
|
||||
/* Return bitset type. */
|
||||
extern enum bitset_type bitset_type_get (bitset);
|
||||
enum bitset_type bitset_type_get (bitset);
|
||||
|
||||
/* Return bitset type name. */
|
||||
extern const char *bitset_type_name_get (bitset);
|
||||
const char *bitset_type_name_get (bitset);
|
||||
|
||||
|
||||
/* Set bit BITNO in bitset BSET. */
|
||||
@@ -181,7 +180,7 @@ bitset_test (bitset bset, bitset_bindex bitno)
|
||||
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
|
||||
|
||||
/* Change size of bitset. */
|
||||
extern void bitset_resize (bitset, bitset_bindex);
|
||||
void bitset_resize (bitset, bitset_bindex);
|
||||
|
||||
/* Return number of bits set in bitset SRC. */
|
||||
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
|
||||
@@ -281,25 +280,25 @@ extern void bitset_resize (bitset, bitset_bindex);
|
||||
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Return true if both bitsets are of the same type and size. */
|
||||
extern bool bitset_compatible_p (bitset bset1, bitset bset2);
|
||||
bool bitset_compatible_p (bitset bset1, bitset bset2);
|
||||
|
||||
/* Find next set bit from the given bit index. */
|
||||
extern bitset_bindex bitset_next (bitset, bitset_bindex);
|
||||
bitset_bindex bitset_next (bitset, bitset_bindex);
|
||||
|
||||
/* Find previous set bit from the given bit index. */
|
||||
extern bitset_bindex bitset_prev (bitset, bitset_bindex);
|
||||
bitset_bindex bitset_prev (bitset, bitset_bindex);
|
||||
|
||||
/* Find first set bit. */
|
||||
extern bitset_bindex bitset_first (bitset);
|
||||
bitset_bindex bitset_first (bitset);
|
||||
|
||||
/* Find last set bit. */
|
||||
extern bitset_bindex bitset_last (bitset);
|
||||
bitset_bindex bitset_last (bitset);
|
||||
|
||||
/* Return nonzero if this is the only set bit. */
|
||||
extern bool bitset_only_set_p (bitset, bitset_bindex);
|
||||
bool bitset_only_set_p (bitset, bitset_bindex);
|
||||
|
||||
/* Dump bitset. */
|
||||
extern void bitset_dump (FILE *, bitset);
|
||||
void bitset_dump (FILE *, bitset);
|
||||
|
||||
/* Loop over all elements of BSET, starting with MIN, setting INDEX
|
||||
to the index of each set bit. For example, the following will print
|
||||
@@ -309,9 +308,7 @@ extern void bitset_dump (FILE *, bitset);
|
||||
bitset_iterator iter;
|
||||
|
||||
BITSET_FOR_EACH (iter, src, i, 0)
|
||||
{
|
||||
printf ("%lu ", (unsigned long) i);
|
||||
};
|
||||
printf ("%lu ", (unsigned long) i);
|
||||
*/
|
||||
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
|
||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||
@@ -331,9 +328,7 @@ extern void bitset_dump (FILE *, bitset);
|
||||
bitset_iterator iter;
|
||||
|
||||
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
|
||||
{
|
||||
printf ("%lu ", (unsigned long) i);
|
||||
};
|
||||
printf ("%lu ", (unsigned long) i);
|
||||
*/
|
||||
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
|
||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||
@@ -368,13 +363,13 @@ extern void bitset_dump (FILE *, bitset);
|
||||
|
||||
|
||||
/* Release any memory tied up with bitsets. */
|
||||
extern void bitset_release_memory (void);
|
||||
void bitset_release_memory (void);
|
||||
|
||||
/* Enable bitset stats gathering. */
|
||||
extern void bitset_stats_enable (void);
|
||||
void bitset_stats_enable (void);
|
||||
|
||||
/* Disable bitset stats gathering. */
|
||||
extern void bitset_stats_disable (void);
|
||||
void bitset_stats_disable (void);
|
||||
|
||||
/* Read bitset stats file of accummulated stats. */
|
||||
void bitset_stats_read (const char *file_name);
|
||||
@@ -383,12 +378,12 @@ void bitset_stats_read (const char *file_name);
|
||||
void bitset_stats_write (const char *file_name);
|
||||
|
||||
/* Dump bitset stats. */
|
||||
extern void bitset_stats_dump (FILE *);
|
||||
void bitset_stats_dump (FILE *);
|
||||
|
||||
/* Function to debug bitset from debugger. */
|
||||
extern void debug_bitset (bitset);
|
||||
void debug_bitset (bitset);
|
||||
|
||||
/* Function to debug bitset stats from debugger. */
|
||||
extern void debug_bitset_stats (void);
|
||||
void debug_bitset_stats (void);
|
||||
|
||||
#endif /* _BITSET_H */
|
||||
|
||||
+84
-82
@@ -29,18 +29,19 @@
|
||||
|
||||
#include "bitset_stats.h"
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "abitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "vbitset.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(Msgid) gettext (Msgid)
|
||||
|
||||
#include "abitset.h"
|
||||
#include "bbitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "vbitset.h"
|
||||
|
||||
/* Configuration macros. */
|
||||
#define BITSET_STATS_FILE "bitset.dat"
|
||||
#define BITSET_LOG_COUNT_BINS 10
|
||||
@@ -108,18 +109,15 @@ static void
|
||||
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
||||
unsigned n_bins, unsigned *bins)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned total;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
unsigned total = 0;
|
||||
for (unsigned i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < n_bins; i++)
|
||||
for (unsigned i = 0; i < n_bins; i++)
|
||||
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
||||
i * 100.0 / n_bins,
|
||||
(i + 1) * 100.0 / n_bins, bins[i],
|
||||
@@ -132,37 +130,39 @@ static void
|
||||
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
||||
unsigned n_bins, unsigned *bins)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned total;
|
||||
unsigned max_width;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
unsigned total = 0;
|
||||
for (unsigned i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
/* Determine number of useful bins. */
|
||||
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
||||
continue;
|
||||
n_bins = i;
|
||||
{
|
||||
unsigned i;
|
||||
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
||||
continue;
|
||||
n_bins = i;
|
||||
}
|
||||
|
||||
/* 2 * ceil (log10 (2) * (N - 1)) + 1. */
|
||||
max_width = 2 * (unsigned) (0.30103 * (n_bins - 1) + 0.9999) + 1;
|
||||
unsigned max_width = 2 * (unsigned) (0.30103 * (n_bins - 1) + 0.9999) + 1;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < 2; i++)
|
||||
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < 2; i++)
|
||||
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||
|
||||
for (; i < n_bins; i++)
|
||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||
max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1),
|
||||
1UL << (i - 1),
|
||||
(1UL << i) - 1,
|
||||
bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
for (; i < n_bins; i++)
|
||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||
max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1),
|
||||
1UL << (i - 1),
|
||||
(1UL << i) - 1,
|
||||
bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,6 @@ bitset_stats_print_1 (FILE *file, const char *name,
|
||||
static void
|
||||
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
@@ -215,7 +213,7 @@ bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
||||
if (bitset_stats_info->runs > 1)
|
||||
fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
|
||||
|
||||
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||
for (int i = 0; i < BITSET_TYPE_NUM; i++)
|
||||
bitset_stats_print_1 (file, bitset_type_names[i],
|
||||
&bitset_stats_info->types[i]);
|
||||
}
|
||||
@@ -242,15 +240,13 @@ bitset_stats_disable (void)
|
||||
void
|
||||
bitset_stats_read (const char *file_name)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!file_name)
|
||||
file_name = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (file_name, "r");
|
||||
FILE *file = fopen (file_name, "r");
|
||||
if (file)
|
||||
{
|
||||
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
@@ -272,15 +268,13 @@ bitset_stats_read (const char *file_name)
|
||||
void
|
||||
bitset_stats_write (const char *file_name)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!file_name)
|
||||
file_name = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (file_name, "w");
|
||||
FILE *file = fopen (file_name, "w");
|
||||
if (file)
|
||||
{
|
||||
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
@@ -352,7 +346,7 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
|
||||
static bool
|
||||
bitset_stats_toggle (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
||||
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
@@ -378,7 +372,7 @@ bitset_stats_test (bitset src, bitset_bindex bitno)
|
||||
static bitset_bindex
|
||||
bitset_stats_resize (bitset src, bitset_bindex size)
|
||||
{
|
||||
return BITSET_RESIZE_ (src->s.bset, size);
|
||||
return BITSET_RESIZE_ (src->s.bset, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -573,35 +567,40 @@ static bitset_bindex
|
||||
bitset_stats_list (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex count;
|
||||
bitset_bindex tmp;
|
||||
bitset_bindex size;
|
||||
bitset_bindex i;
|
||||
|
||||
count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
||||
bitset_bindex count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
||||
|
||||
BITSET_STATS_LISTS_INC (bset->s.bset);
|
||||
|
||||
/* Log histogram of number of set bits. */
|
||||
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_COUNT_BINS)
|
||||
i = BITSET_LOG_COUNT_BINS - 1;
|
||||
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
|
||||
{
|
||||
bitset_bindex i;
|
||||
bitset_bindex tmp;
|
||||
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_COUNT_BINS)
|
||||
i = BITSET_LOG_COUNT_BINS - 1;
|
||||
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
|
||||
}
|
||||
|
||||
/* Log histogram of number of bits in set. */
|
||||
size = BITSET_SIZE_ (bset->s.bset);
|
||||
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_SIZE_BINS)
|
||||
i = BITSET_LOG_SIZE_BINS - 1;
|
||||
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
|
||||
bitset_bindex size = BITSET_SIZE_ (bset->s.bset);
|
||||
{
|
||||
bitset_bindex i;
|
||||
bitset_bindex tmp;
|
||||
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_SIZE_BINS)
|
||||
i = BITSET_LOG_SIZE_BINS - 1;
|
||||
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
|
||||
}
|
||||
|
||||
/* Histogram of fraction of bits set. */
|
||||
i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
|
||||
if (i >= BITSET_DENSITY_BINS)
|
||||
i = BITSET_DENSITY_BINS - 1;
|
||||
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
|
||||
{
|
||||
bitset_bindex i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
|
||||
if (i >= BITSET_DENSITY_BINS)
|
||||
i = BITSET_DENSITY_BINS - 1;
|
||||
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -663,7 +662,7 @@ struct bitset_vtable bitset_stats_vtable = {
|
||||
enum bitset_type
|
||||
bitset_stats_type_get (bitset bset)
|
||||
{
|
||||
return BITSET_TYPE_ (bset->s.bset);
|
||||
return BITSET_TYPE_ (bset->s.bset);
|
||||
}
|
||||
|
||||
|
||||
@@ -677,9 +676,6 @@ bitset_stats_bytes (void)
|
||||
bitset
|
||||
bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||
{
|
||||
size_t bytes;
|
||||
bitset sbset;
|
||||
|
||||
bset->b.vtable = &bitset_stats_vtable;
|
||||
|
||||
/* Disable cache. */
|
||||
@@ -697,32 +693,38 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||
abort ();
|
||||
|
||||
case BITSET_ARRAY:
|
||||
bytes = abitset_bytes (n_bits);
|
||||
sbset = xcalloc (1, bytes);
|
||||
abitset_init (sbset, n_bits);
|
||||
{
|
||||
size_t bytes = abitset_bytes (n_bits);
|
||||
bset->s.bset = xcalloc (1, bytes);
|
||||
abitset_init (bset->s.bset, n_bits);
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_LIST:
|
||||
bytes = lbitset_bytes (n_bits);
|
||||
sbset = xcalloc (1, bytes);
|
||||
lbitset_init (sbset, n_bits);
|
||||
{
|
||||
size_t bytes = lbitset_bytes (n_bits);
|
||||
bset->s.bset = xcalloc (1, bytes);
|
||||
lbitset_init (bset->s.bset, n_bits);
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_TABLE:
|
||||
bytes = ebitset_bytes (n_bits);
|
||||
sbset = xcalloc (1, bytes);
|
||||
ebitset_init (sbset, n_bits);
|
||||
{
|
||||
size_t bytes = ebitset_bytes (n_bits);
|
||||
bset->s.bset = xcalloc (1, bytes);
|
||||
ebitset_init (bset->s.bset, n_bits);
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_VARRAY:
|
||||
bytes = vbitset_bytes (n_bits);
|
||||
sbset = xcalloc (1, bytes);
|
||||
vbitset_init (sbset, n_bits);
|
||||
{
|
||||
size_t bytes = vbitset_bytes (n_bits);
|
||||
bset->s.bset = xcalloc (1, bytes);
|
||||
vbitset_init (bset->s.bset, n_bits);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
bset->s.bset = sbset;
|
||||
|
||||
BITSET_STATS_ALLOCS_INC (type);
|
||||
|
||||
return bset;
|
||||
|
||||
+3
-3
@@ -25,10 +25,10 @@
|
||||
|
||||
extern bool bitset_stats_enabled;
|
||||
|
||||
extern enum bitset_type bitset_stats_type_get (bitset);
|
||||
enum bitset_type bitset_stats_type_get (bitset);
|
||||
|
||||
extern size_t bitset_stats_bytes (void);
|
||||
size_t bitset_stats_bytes (void);
|
||||
|
||||
extern bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
|
||||
bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
|
||||
|
||||
#endif
|
||||
|
||||
+6
-7
@@ -29,7 +29,6 @@
|
||||
void
|
||||
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||
{
|
||||
bitset_bindex i, j;
|
||||
bitset_bindex hsize = bitset_size (bset[0]);
|
||||
|
||||
/* Title. */
|
||||
@@ -37,32 +36,32 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||
|
||||
/* Column numbers. */
|
||||
fputs (" ", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||
putc (i / 10 ? '0' + i / 10 : ' ', out);
|
||||
putc ('\n', out);
|
||||
fputs (" ", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||
fprintf (out, "%d", (int) (i % 10));
|
||||
putc ('\n', out);
|
||||
|
||||
/* Bar. */
|
||||
fputs (" .", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||
putc ('-', out);
|
||||
fputs (".\n", out);
|
||||
|
||||
/* Contents. */
|
||||
for (i = 0; bset[i]; ++i)
|
||||
for (bitset_bindex i = 0; bset[i]; ++i)
|
||||
{
|
||||
fprintf (out, "%2lu|", (unsigned long) i);
|
||||
for (j = 0; j < hsize; ++j)
|
||||
for (bitset_bindex j = 0; j < hsize; ++j)
|
||||
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
|
||||
fputs ("|\n", out);
|
||||
}
|
||||
|
||||
/* Bar. */
|
||||
fputs (" `", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||
putc ('-', out);
|
||||
fputs ("'\n", out);
|
||||
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@
|
||||
#include "bitsetv.h"
|
||||
|
||||
/* Dump vector of bitsets as a matrix. */
|
||||
extern void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
|
||||
void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
|
||||
|
||||
#endif /* _BITSETV_H */
|
||||
|
||||
+14
-35
@@ -29,23 +29,19 @@ bitset *
|
||||
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||
enum bitset_type type)
|
||||
{
|
||||
size_t vector_bytes;
|
||||
size_t bytes;
|
||||
bitset *bsetv;
|
||||
bitset_bindex i;
|
||||
|
||||
/* Determine number of bytes for each set. */
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
size_t bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
/* If size calculation overflows, memory is exhausted. */
|
||||
if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
|
||||
xalloc_die ();
|
||||
|
||||
/* Allocate vector table at head of bitset array. */
|
||||
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
|
||||
size_t vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
|
||||
vector_bytes -= vector_bytes % bytes;
|
||||
bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
|
||||
bitset *bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
|
||||
|
||||
bitset_bindex i = 0;
|
||||
for (i = 0; i < n_vecs; i++)
|
||||
{
|
||||
bsetv[i] = (bitset) (void *) ((char *) bsetv + vector_bytes + i * bytes);
|
||||
@@ -64,9 +60,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||
bitset *
|
||||
bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
type = bitset_type_choose (n_bits, attr);
|
||||
enum bitset_type type = bitset_type_choose (n_bits, attr);
|
||||
return bitsetv_alloc (n_vecs, n_bits, type);
|
||||
}
|
||||
|
||||
@@ -75,10 +69,8 @@ bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
|
||||
void
|
||||
bitsetv_free (bitsetv bsetv)
|
||||
{
|
||||
bitset_bindex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
BITSET_FREE_ (bsetv[i]);
|
||||
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||
BITSET_FREE_ (bsetv[i]);
|
||||
free (bsetv);
|
||||
}
|
||||
|
||||
@@ -87,9 +79,7 @@ bitsetv_free (bitsetv bsetv)
|
||||
void
|
||||
bitsetv_zero (bitsetv bsetv)
|
||||
{
|
||||
bitset_bindex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||
bitset_zero (bsetv[i]);
|
||||
}
|
||||
|
||||
@@ -98,9 +88,7 @@ bitsetv_zero (bitsetv bsetv)
|
||||
void
|
||||
bitsetv_ones (bitsetv bsetv)
|
||||
{
|
||||
bitset_bindex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||
bitset_ones (bsetv[i]);
|
||||
}
|
||||
|
||||
@@ -110,11 +98,8 @@ bitsetv_ones (bitsetv bsetv)
|
||||
void
|
||||
bitsetv_transitive_closure (bitsetv bsetv)
|
||||
{
|
||||
bitset_bindex i;
|
||||
bitset_bindex j;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (j = 0; bsetv[j]; j++)
|
||||
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||
for (bitset_bindex j = 0; bsetv[j]; j++)
|
||||
if (bitset_test (bsetv[j], i))
|
||||
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
||||
}
|
||||
@@ -127,10 +112,8 @@ bitsetv_transitive_closure (bitsetv bsetv)
|
||||
void
|
||||
bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
||||
{
|
||||
bitset_bindex i;
|
||||
|
||||
bitsetv_transitive_closure (bsetv);
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||
bitset_set (bsetv[i], i);
|
||||
}
|
||||
|
||||
@@ -141,10 +124,8 @@ void
|
||||
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||
bitsetv bsetv)
|
||||
{
|
||||
bitset_windex i;
|
||||
|
||||
fprintf (file, "%s\n", title);
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (bitset_windex i = 0; bsetv[i]; i++)
|
||||
{
|
||||
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
|
||||
bitset_dump (file, bsetv[i]);
|
||||
@@ -157,9 +138,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||
void
|
||||
debug_bitsetv (bitsetv bsetv)
|
||||
{
|
||||
bitset_windex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (bitset_windex i = 0; bsetv[i]; i++)
|
||||
{
|
||||
fprintf (stderr, "%lu: ", (unsigned long) i);
|
||||
debug_bitset (bsetv[i]);
|
||||
|
||||
+9
-9
@@ -27,35 +27,35 @@ typedef bitset * bitsetv;
|
||||
|
||||
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
|
||||
type TYPE. */
|
||||
extern bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
|
||||
bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
|
||||
attribute hints specified by ATTR. */
|
||||
extern bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned);
|
||||
bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned);
|
||||
|
||||
/* Free vector of bitsets. */
|
||||
extern void bitsetv_free (bitsetv);
|
||||
void bitsetv_free (bitsetv);
|
||||
|
||||
/* Zero vector of bitsets. */
|
||||
extern void bitsetv_zero (bitsetv);
|
||||
void bitsetv_zero (bitsetv);
|
||||
|
||||
/* Set vector of bitsets. */
|
||||
extern void bitsetv_ones (bitsetv);
|
||||
void bitsetv_ones (bitsetv);
|
||||
|
||||
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||
be the transitive closure of what was given. */
|
||||
extern void bitsetv_transitive_closure (bitsetv);
|
||||
void bitsetv_transitive_closure (bitsetv);
|
||||
|
||||
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||
be the reflexive transitive closure of what was given. This is
|
||||
the same as transitive closure but with all bits on the diagonal
|
||||
of the bit matrix set. */
|
||||
extern void bitsetv_reflexive_transitive_closure (bitsetv);
|
||||
void bitsetv_reflexive_transitive_closure (bitsetv);
|
||||
|
||||
/* Dump vector of bitsets. */
|
||||
extern void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
|
||||
void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
|
||||
|
||||
/* Function to debug vector of bitsets from debugger. */
|
||||
extern void debug_bitsetv (bitsetv);
|
||||
void debug_bitsetv (bitsetv);
|
||||
|
||||
#endif /* _BITSETV_H */
|
||||
|
||||
+121
-254
@@ -22,10 +22,11 @@
|
||||
|
||||
#include "ebitset.h"
|
||||
|
||||
#include "obstack.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "obstack.h"
|
||||
|
||||
/* This file implements expandable bitsets. These bitsets can be of
|
||||
arbitrary length and are more efficient than arrays of bits for
|
||||
large sparse sets.
|
||||
@@ -73,7 +74,7 @@ typedef ebitset_elt *ebitset_elts;
|
||||
/* Number of elements to initially allocate. */
|
||||
|
||||
#ifndef EBITSET_INITIAL_SIZE
|
||||
#define EBITSET_INITIAL_SIZE 2
|
||||
# define EBITSET_INITIAL_SIZE 2
|
||||
#endif
|
||||
|
||||
|
||||
@@ -123,19 +124,14 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
||||
static bitset_bindex
|
||||
ebitset_resize (bitset src, bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex oldsize;
|
||||
bitset_windex newsize;
|
||||
|
||||
if (n_bits == BITSET_NBITS_ (src))
|
||||
return n_bits;
|
||||
|
||||
oldsize = EBITSET_SIZE (src);
|
||||
newsize = EBITSET_N_ELTS (n_bits);
|
||||
bitset_windex oldsize = EBITSET_SIZE (src);
|
||||
bitset_windex newsize = EBITSET_N_ELTS (n_bits);
|
||||
|
||||
if (oldsize < newsize)
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
/* The bitset needs to grow. If we already have enough memory
|
||||
allocated, then just zero what we need. */
|
||||
if (newsize > EBITSET_ASIZE (src))
|
||||
@@ -145,11 +141,7 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
|
||||
grow the bitset 25% larger than requested to reduce
|
||||
number of reallocations. */
|
||||
|
||||
if (oldsize == 0)
|
||||
size = newsize;
|
||||
else
|
||||
size = newsize + newsize / 4;
|
||||
|
||||
bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4;
|
||||
EBITSET_ELTS (src)
|
||||
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
|
||||
EBITSET_ASIZE (src) = size;
|
||||
@@ -234,9 +226,7 @@ ebitset_elt_alloc (void)
|
||||
static inline ebitset_elt *
|
||||
ebitset_elt_calloc (void)
|
||||
{
|
||||
ebitset_elt *elt;
|
||||
|
||||
elt = ebitset_elt_alloc ();
|
||||
ebitset_elt *elt = ebitset_elt_alloc ();
|
||||
memset (EBITSET_WORDS (elt), 0, sizeof (EBITSET_WORDS (elt)));
|
||||
return elt;
|
||||
}
|
||||
@@ -254,12 +244,8 @@ ebitset_elt_free (ebitset_elt *elt)
|
||||
static inline void
|
||||
ebitset_elt_remove (bitset bset, bitset_windex eindex)
|
||||
{
|
||||
ebitset_elts *elts;
|
||||
ebitset_elt *elt;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
|
||||
elt = elts[eindex];
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
ebitset_elt *elt = elts[eindex];
|
||||
|
||||
elts[eindex] = 0;
|
||||
ebitset_elt_free (elt);
|
||||
@@ -270,9 +256,7 @@ ebitset_elt_remove (bitset bset, bitset_windex eindex)
|
||||
static inline void
|
||||
ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
|
||||
{
|
||||
ebitset_elts *elts;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
/* Assume that the elts entry not allocated. */
|
||||
elts[eindex] = elt;
|
||||
}
|
||||
@@ -282,12 +266,9 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
|
||||
static inline bool
|
||||
ebitset_elt_zero_p (ebitset_elt *elt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
for (int i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if (EBITSET_WORDS (elt)[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -296,24 +277,18 @@ static ebitset_elt *
|
||||
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||
enum ebitset_find_mode mode)
|
||||
{
|
||||
ebitset_elt *elt;
|
||||
bitset_windex size;
|
||||
bitset_windex eindex;
|
||||
ebitset_elts *elts;
|
||||
bitset_windex eindex = bindex / EBITSET_ELT_BITS;
|
||||
|
||||
eindex = bindex / EBITSET_ELT_BITS;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
size = EBITSET_SIZE (bset);
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
bitset_windex size = EBITSET_SIZE (bset);
|
||||
|
||||
if (eindex < size)
|
||||
{
|
||||
if ((elt = elts[eindex]))
|
||||
ebitset_elt *elt = elts[eindex];
|
||||
if (elt)
|
||||
{
|
||||
if (EBITSET_WORDS (elt) == bset->b.cdata)
|
||||
return elt;
|
||||
|
||||
EBITSET_CACHE_SET (bset, eindex);
|
||||
if (EBITSET_WORDS (elt) != bset->b.cdata)
|
||||
EBITSET_CACHE_SET (bset, eindex);
|
||||
return elt;
|
||||
}
|
||||
}
|
||||
@@ -333,10 +308,12 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||
ebitset_resize (bset, bindex);
|
||||
|
||||
/* Create a new element. */
|
||||
elt = ebitset_elt_calloc ();
|
||||
ebitset_elt_add (bset, elt, eindex);
|
||||
EBITSET_CACHE_SET (bset, eindex);
|
||||
return elt;
|
||||
{
|
||||
ebitset_elt *elt = ebitset_elt_calloc ();
|
||||
ebitset_elt_add (bset, elt, eindex);
|
||||
EBITSET_CACHE_SET (bset, eindex);
|
||||
return elt;
|
||||
}
|
||||
|
||||
case EBITSET_SUBST:
|
||||
return &ebitset_zero_elts[0];
|
||||
@@ -348,15 +325,12 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||
static inline bitset_windex
|
||||
ebitset_weed (bitset bset)
|
||||
{
|
||||
ebitset_elts *elts;
|
||||
bitset_windex j;
|
||||
bitset_windex count;
|
||||
|
||||
if (EBITSET_ZERO_P (bset))
|
||||
return 0;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
count = 0;
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
bitset_windex count = 0;
|
||||
bitset_windex j;
|
||||
for (j = 0; j < EBITSET_SIZE (bset); j++)
|
||||
{
|
||||
ebitset_elt *elt = elts[j];
|
||||
@@ -391,17 +365,13 @@ ebitset_weed (bitset bset)
|
||||
static inline void
|
||||
ebitset_zero (bitset bset)
|
||||
{
|
||||
ebitset_elts *elts;
|
||||
bitset_windex j;
|
||||
|
||||
if (EBITSET_ZERO_P (bset))
|
||||
return;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
for (j = 0; j < EBITSET_SIZE (bset); j++)
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
for (bitset_windex j = 0; j < EBITSET_SIZE (bset); j++)
|
||||
{
|
||||
ebitset_elt *elt = elts[j];
|
||||
|
||||
if (elt)
|
||||
ebitset_elt_remove (bset, j);
|
||||
}
|
||||
@@ -415,10 +385,6 @@ ebitset_zero (bitset bset)
|
||||
static inline bool
|
||||
ebitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
ebitset_elts *selts;
|
||||
ebitset_elts *delts;
|
||||
bitset_windex j;
|
||||
|
||||
if (src == dst)
|
||||
return true;
|
||||
|
||||
@@ -428,12 +394,11 @@ ebitset_equal_p (bitset dst, bitset src)
|
||||
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
|
||||
return false;
|
||||
|
||||
selts = EBITSET_ELTS (src);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||
|
||||
for (j = 0; j < EBITSET_SIZE (src); j++)
|
||||
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
|
||||
{
|
||||
unsigned i;
|
||||
ebitset_elt *selt = selts[j];
|
||||
ebitset_elt *delt = delts[j];
|
||||
|
||||
@@ -442,7 +407,7 @@ ebitset_equal_p (bitset dst, bitset src)
|
||||
if ((selt && !delt) || (!selt && delt))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
||||
return false;
|
||||
}
|
||||
@@ -454,10 +419,6 @@ ebitset_equal_p (bitset dst, bitset src)
|
||||
static inline void
|
||||
ebitset_copy_ (bitset dst, bitset src)
|
||||
{
|
||||
ebitset_elts *selts;
|
||||
ebitset_elts *delts;
|
||||
bitset_windex j;
|
||||
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
@@ -466,17 +427,14 @@ ebitset_copy_ (bitset dst, bitset src)
|
||||
if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src))
|
||||
ebitset_resize (dst, BITSET_NBITS_ (src));
|
||||
|
||||
selts = EBITSET_ELTS (src);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
for (j = 0; j < EBITSET_SIZE (src); j++)
|
||||
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
|
||||
{
|
||||
ebitset_elt *selt = selts[j];
|
||||
|
||||
if (selt)
|
||||
{
|
||||
ebitset_elt *tmp;
|
||||
|
||||
tmp = ebitset_elt_alloc ();
|
||||
ebitset_elt *tmp = ebitset_elt_alloc ();
|
||||
delts[j] = tmp;
|
||||
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
||||
sizeof (EBITSET_WORDS (selt)));
|
||||
@@ -567,60 +525,41 @@ static bitset_bindex
|
||||
ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex n_bits;
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex rbitno;
|
||||
unsigned bcount;
|
||||
bitset_bindex boffset;
|
||||
bitset_windex windex;
|
||||
bitset_windex eindex;
|
||||
bitset_windex woffset;
|
||||
bitset_bindex count;
|
||||
bitset_windex size;
|
||||
ebitset_elts *elts;
|
||||
|
||||
if (EBITSET_ZERO_P (bset))
|
||||
return 0;
|
||||
|
||||
size = EBITSET_SIZE (bset);
|
||||
n_bits = size * EBITSET_ELT_BITS;
|
||||
rbitno = *next;
|
||||
bitset_windex size = EBITSET_SIZE (bset);
|
||||
bitset_bindex n_bits = size * EBITSET_ELT_BITS;
|
||||
bitset_bindex rbitno = *next;
|
||||
|
||||
if (rbitno >= n_bits)
|
||||
return 0;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
|
||||
bitno = n_bits - (rbitno + 1);
|
||||
bitset_bindex bitno = n_bits - (rbitno + 1);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
eindex = bitno / EBITSET_ELT_BITS;
|
||||
woffset = windex - eindex * EBITSET_ELT_WORDS;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
|
||||
bitset_windex woffset = windex - eindex * EBITSET_ELT_WORDS;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
count = 0;
|
||||
bcount = bitno % BITSET_WORD_BITS;
|
||||
boffset = windex * BITSET_WORD_BITS;
|
||||
bitset_bindex count = 0;
|
||||
unsigned bcount = bitno % BITSET_WORD_BITS;
|
||||
bitset_bindex boffset = windex * BITSET_WORD_BITS;
|
||||
|
||||
do
|
||||
{
|
||||
ebitset_elt *elt;
|
||||
bitset_word *srcp;
|
||||
|
||||
elt = elts[eindex];
|
||||
ebitset_elt *elt = elts[eindex];
|
||||
if (elt)
|
||||
{
|
||||
srcp = EBITSET_WORDS (elt);
|
||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||
|
||||
do
|
||||
{
|
||||
bitset_word word;
|
||||
|
||||
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||
|
||||
for (; word; bcount--)
|
||||
for (bitset_word word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||
word; bcount--)
|
||||
{
|
||||
if (word & BITSET_MSB)
|
||||
{
|
||||
@@ -656,41 +595,32 @@ static bitset_bindex
|
||||
ebitset_list (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_windex windex;
|
||||
bitset_windex eindex;
|
||||
bitset_bindex count;
|
||||
bitset_windex size;
|
||||
ebitset_elt *elt;
|
||||
bitset_word word;
|
||||
ebitset_elts *elts;
|
||||
|
||||
if (EBITSET_ZERO_P (bset))
|
||||
return 0;
|
||||
|
||||
bitno = *next;
|
||||
count = 0;
|
||||
bitset_bindex bitno = *next;
|
||||
bitset_bindex count = 0;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
size = EBITSET_SIZE (bset);
|
||||
eindex = bitno / EBITSET_ELT_BITS;
|
||||
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||
bitset_windex size = EBITSET_SIZE (bset);
|
||||
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
|
||||
|
||||
if (bitno % EBITSET_ELT_BITS)
|
||||
{
|
||||
/* We need to start within an element. This is not very common. */
|
||||
|
||||
elt = elts[eindex];
|
||||
ebitset_elt *elt = elts[eindex];
|
||||
if (elt)
|
||||
{
|
||||
bitset_windex woffset;
|
||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
woffset = eindex * EBITSET_ELT_WORDS;
|
||||
|
||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
||||
{
|
||||
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
|
||||
bitset_word word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
|
||||
|
||||
for (; word; bitno++)
|
||||
{
|
||||
@@ -718,22 +648,21 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
|
||||
for (; eindex < size; eindex++)
|
||||
{
|
||||
int i;
|
||||
bitset_word *srcp;
|
||||
|
||||
elt = elts[eindex];
|
||||
ebitset_elt *elt = elts[eindex];
|
||||
if (!elt)
|
||||
continue;
|
||||
|
||||
srcp = EBITSET_WORDS (elt);
|
||||
windex = eindex * EBITSET_ELT_WORDS;
|
||||
bitset_windex windex = eindex * EBITSET_ELT_WORDS;
|
||||
|
||||
if ((count + EBITSET_ELT_BITS) < num)
|
||||
{
|
||||
/* The coast is clear, plant boot! */
|
||||
|
||||
#if EBITSET_ELT_WORDS == 2
|
||||
word = srcp[0];
|
||||
bitset_word word = srcp[0];
|
||||
if (word)
|
||||
{
|
||||
if (!(word & 0xffff))
|
||||
@@ -774,7 +703,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
windex++;
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
#else
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||
for (int i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||
{
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
|
||||
@@ -806,11 +735,11 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
/* Tread more carefully since we need to check
|
||||
if array overflows. */
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||
for (int i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||
{
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
|
||||
for (word = srcp[i]; word; bitno++)
|
||||
for (bitset_word word = srcp[i]; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
@@ -836,31 +765,22 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
static inline void
|
||||
ebitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned last_bit;
|
||||
bitset_bindex n_bits;
|
||||
|
||||
n_bits = BITSET_NBITS_ (dst);
|
||||
last_bit = n_bits % EBITSET_ELT_BITS;
|
||||
bitset_bindex n_bits = BITSET_NBITS_ (dst);
|
||||
unsigned last_bit = n_bits % EBITSET_ELT_BITS;
|
||||
|
||||
if (last_bit)
|
||||
{
|
||||
bitset_windex eindex;
|
||||
ebitset_elts *elts;
|
||||
ebitset_elt *elt;
|
||||
ebitset_elts *elts = EBITSET_ELTS (dst);
|
||||
|
||||
elts = EBITSET_ELTS (dst);
|
||||
bitset_windex eindex = n_bits / EBITSET_ELT_BITS;
|
||||
|
||||
eindex = n_bits / EBITSET_ELT_BITS;
|
||||
|
||||
elt = elts[eindex];
|
||||
ebitset_elt *elt = elts[eindex];
|
||||
if (elt)
|
||||
{
|
||||
bitset_windex windex;
|
||||
bitset_windex woffset;
|
||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||
|
||||
windex = n_bits / BITSET_WORD_BITS;
|
||||
woffset = eindex * EBITSET_ELT_WORDS;
|
||||
bitset_windex windex = n_bits / BITSET_WORD_BITS;
|
||||
bitset_windex woffset = eindex * EBITSET_ELT_WORDS;
|
||||
|
||||
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
||||
windex++;
|
||||
@@ -874,14 +794,11 @@ ebitset_unused_clear (bitset dst)
|
||||
static void
|
||||
ebitset_ones (bitset dst)
|
||||
{
|
||||
bitset_windex j;
|
||||
ebitset_elt *elt;
|
||||
|
||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
||||
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
|
||||
{
|
||||
/* Create new elements if they cannot be found. Perhaps
|
||||
we should just add pointers to a ones element? */
|
||||
elt =
|
||||
ebitset_elt *elt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
||||
}
|
||||
@@ -893,14 +810,11 @@ ebitset_ones (bitset dst)
|
||||
static bool
|
||||
ebitset_empty_p (bitset dst)
|
||||
{
|
||||
ebitset_elts *elts;
|
||||
bitset_windex j;
|
||||
|
||||
if (EBITSET_ZERO_P (dst))
|
||||
return 1;
|
||||
|
||||
elts = EBITSET_ELTS (dst);
|
||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
||||
ebitset_elts *elts = EBITSET_ELTS (dst);
|
||||
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
|
||||
{
|
||||
ebitset_elt *elt = elts[j];
|
||||
|
||||
@@ -923,23 +837,18 @@ ebitset_empty_p (bitset dst)
|
||||
static void
|
||||
ebitset_not (bitset dst, bitset src)
|
||||
{
|
||||
unsigned i;
|
||||
ebitset_elt *selt;
|
||||
ebitset_elt *delt;
|
||||
bitset_windex j;
|
||||
|
||||
ebitset_resize (dst, BITSET_NBITS_ (src));
|
||||
|
||||
for (j = 0; j < EBITSET_SIZE (src); j++)
|
||||
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
|
||||
{
|
||||
/* Create new elements for dst if they cannot be found
|
||||
or substitute zero elements if src elements not found. */
|
||||
selt =
|
||||
ebitset_elt *selt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
||||
delt =
|
||||
ebitset_elt *delt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
|
||||
}
|
||||
EBITSET_NONZERO_SET (dst);
|
||||
@@ -951,26 +860,16 @@ ebitset_not (bitset dst, bitset src)
|
||||
static bool
|
||||
ebitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex j;
|
||||
ebitset_elts *selts;
|
||||
ebitset_elts *delts;
|
||||
bitset_windex ssize;
|
||||
bitset_windex dsize;
|
||||
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||
|
||||
selts = EBITSET_ELTS (src);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
bitset_windex ssize = EBITSET_SIZE (src);
|
||||
bitset_windex dsize = EBITSET_SIZE (dst);
|
||||
|
||||
ssize = EBITSET_SIZE (src);
|
||||
dsize = EBITSET_SIZE (dst);
|
||||
|
||||
for (j = 0; j < ssize; j++)
|
||||
for (bitset_windex j = 0; j < ssize; j++)
|
||||
{
|
||||
unsigned i;
|
||||
ebitset_elt *selt;
|
||||
ebitset_elt *delt;
|
||||
|
||||
selt = j < ssize ? selts[j] : 0;
|
||||
delt = j < dsize ? delts[j] : 0;
|
||||
ebitset_elt *selt = j < ssize ? selts[j] : 0;
|
||||
ebitset_elt *delt = j < dsize ? delts[j] : 0;
|
||||
|
||||
if (!selt && !delt)
|
||||
continue;
|
||||
@@ -980,7 +879,7 @@ ebitset_subset_p (bitset dst, bitset src)
|
||||
if (!delt)
|
||||
delt = &ebitset_zero_elts[0];
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if (EBITSET_WORDS (delt)[i]
|
||||
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
||||
return false;
|
||||
@@ -993,31 +892,21 @@ ebitset_subset_p (bitset dst, bitset src)
|
||||
static bool
|
||||
ebitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex j;
|
||||
ebitset_elts *selts;
|
||||
ebitset_elts *delts;
|
||||
bitset_windex ssize;
|
||||
bitset_windex dsize;
|
||||
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||
|
||||
selts = EBITSET_ELTS (src);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
bitset_windex ssize = EBITSET_SIZE (src);
|
||||
bitset_windex dsize = EBITSET_SIZE (dst);
|
||||
|
||||
ssize = EBITSET_SIZE (src);
|
||||
dsize = EBITSET_SIZE (dst);
|
||||
|
||||
for (j = 0; j < ssize; j++)
|
||||
for (bitset_windex j = 0; j < ssize; j++)
|
||||
{
|
||||
unsigned i;
|
||||
ebitset_elt *selt;
|
||||
ebitset_elt *delt;
|
||||
|
||||
selt = j < ssize ? selts[j] : 0;
|
||||
delt = j < dsize ? delts[j] : 0;
|
||||
ebitset_elt *selt = j < ssize ? selts[j] : 0;
|
||||
ebitset_elt *delt = j < dsize ? delts[j] : 0;
|
||||
|
||||
if (!selt || !delt)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
||||
return false;
|
||||
}
|
||||
@@ -1029,42 +918,27 @@ ebitset_disjoint_p (bitset dst, bitset src)
|
||||
static bool
|
||||
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
{
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
bitset_windex size;
|
||||
ebitset_elts *selts1;
|
||||
ebitset_elts *selts2;
|
||||
ebitset_elts *delts;
|
||||
bitset_word *srcp1;
|
||||
bitset_word *srcp2;
|
||||
bitset_word *dstp;
|
||||
bool changed = false;
|
||||
unsigned i;
|
||||
bitset_windex j;
|
||||
|
||||
ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
|
||||
|
||||
ssize1 = EBITSET_SIZE (src1);
|
||||
ssize2 = EBITSET_SIZE (src2);
|
||||
dsize = EBITSET_SIZE (dst);
|
||||
size = ssize1;
|
||||
bitset_windex ssize1 = EBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = EBITSET_SIZE (src2);
|
||||
bitset_windex dsize = EBITSET_SIZE (dst);
|
||||
bitset_windex size = ssize1;
|
||||
if (size < ssize2)
|
||||
size = ssize2;
|
||||
|
||||
selts1 = EBITSET_ELTS (src1);
|
||||
selts2 = EBITSET_ELTS (src2);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
ebitset_elts *selts1 = EBITSET_ELTS (src1);
|
||||
ebitset_elts *selts2 = EBITSET_ELTS (src2);
|
||||
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||
|
||||
bitset_windex j = 0;
|
||||
for (j = 0; j < size; j++)
|
||||
{
|
||||
ebitset_elt *selt1;
|
||||
ebitset_elt *selt2;
|
||||
ebitset_elt *delt;
|
||||
|
||||
selt1 = j < ssize1 ? selts1[j] : 0;
|
||||
selt2 = j < ssize2 ? selts2[j] : 0;
|
||||
delt = j < dsize ? delts[j] : 0;
|
||||
ebitset_elt *selt1 = j < ssize1 ? selts1[j] : 0;
|
||||
ebitset_elt *selt2 = j < ssize2 ? selts2[j] : 0;
|
||||
ebitset_elt *delt = j < dsize ? delts[j] : 0;
|
||||
|
||||
if (!selt1 && !selt2)
|
||||
{
|
||||
@@ -1085,16 +959,16 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
else
|
||||
delts[j] = 0;
|
||||
|
||||
srcp1 = EBITSET_WORDS (selt1);
|
||||
srcp2 = EBITSET_WORDS (selt2);
|
||||
dstp = EBITSET_WORDS (delt);
|
||||
bitset_word *srcp1 = EBITSET_WORDS (selt1);
|
||||
bitset_word *srcp2 = EBITSET_WORDS (selt2);
|
||||
bitset_word *dstp = EBITSET_WORDS (delt);
|
||||
switch (op)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
|
||||
case BITSET_OP_OR:
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||
|
||||
@@ -1107,7 +981,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_AND:
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||
|
||||
@@ -1120,7 +994,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_XOR:
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||
|
||||
@@ -1133,7 +1007,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_ANDN:
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||
|
||||
@@ -1159,12 +1033,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
/* If we have elements of DST left over, free them all. */
|
||||
for (; j < dsize; j++)
|
||||
{
|
||||
ebitset_elt *delt;
|
||||
|
||||
changed = true;
|
||||
|
||||
delt = delts[j];
|
||||
|
||||
ebitset_elt *delt = delts[j];
|
||||
if (delt)
|
||||
ebitset_elt_remove (dst, j);
|
||||
}
|
||||
@@ -1177,19 +1048,17 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
static bool
|
||||
ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bool changed;
|
||||
|
||||
if (EBITSET_ZERO_P (src2))
|
||||
{
|
||||
ebitset_weed (dst);
|
||||
changed = EBITSET_ZERO_P (dst);
|
||||
bool changed = EBITSET_ZERO_P (dst);
|
||||
ebitset_zero (dst);
|
||||
return changed;
|
||||
}
|
||||
else if (EBITSET_ZERO_P (src1))
|
||||
{
|
||||
ebitset_weed (dst);
|
||||
changed = EBITSET_ZERO_P (dst);
|
||||
bool changed = EBITSET_ZERO_P (dst);
|
||||
ebitset_zero (dst);
|
||||
return changed;
|
||||
}
|
||||
@@ -1207,8 +1076,6 @@ ebitset_and (bitset dst, bitset src1, bitset src2)
|
||||
static bool
|
||||
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bool changed;
|
||||
|
||||
if (EBITSET_ZERO_P (src2))
|
||||
{
|
||||
return ebitset_copy_cmp (dst, src1);
|
||||
@@ -1216,7 +1083,7 @@ ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
else if (EBITSET_ZERO_P (src1))
|
||||
{
|
||||
ebitset_weed (dst);
|
||||
changed = EBITSET_ZERO_P (dst);
|
||||
bool changed = EBITSET_ZERO_P (dst);
|
||||
ebitset_zero (dst);
|
||||
return changed;
|
||||
}
|
||||
@@ -1279,9 +1146,9 @@ static void
|
||||
ebitset_copy (bitset dst, bitset src)
|
||||
{
|
||||
if (BITSET_COMPATIBLE_ (dst, src))
|
||||
ebitset_copy_ (dst, src);
|
||||
ebitset_copy_ (dst, src);
|
||||
else
|
||||
bitset_copy_ (dst, src);
|
||||
bitset_copy_ (dst, src);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -23,10 +23,10 @@
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t ebitset_bytes (bitset_bindex);
|
||||
size_t ebitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset ebitset_init (bitset, bitset_bindex);
|
||||
bitset ebitset_init (bitset, bitset_bindex);
|
||||
|
||||
extern void ebitset_release_memory (void);
|
||||
void ebitset_release_memory (void);
|
||||
|
||||
#endif
|
||||
|
||||
+107
-181
@@ -22,12 +22,13 @@
|
||||
|
||||
#include "lbitset.h"
|
||||
|
||||
#include "obstack.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "obstack.h"
|
||||
|
||||
/* This file implements linked-list bitsets. These bitsets can be of
|
||||
arbitrary length and are more efficient than arrays of bits for
|
||||
large sparse sets.
|
||||
@@ -108,21 +109,21 @@ lbitset_elt_alloc (void)
|
||||
/* Let particular systems override the size of a chunk. */
|
||||
|
||||
#ifndef OBSTACK_CHUNK_SIZE
|
||||
#define OBSTACK_CHUNK_SIZE 0
|
||||
# define OBSTACK_CHUNK_SIZE 0
|
||||
#endif
|
||||
|
||||
/* Let them override the alloc and free routines too. */
|
||||
|
||||
#ifndef OBSTACK_CHUNK_ALLOC
|
||||
#define OBSTACK_CHUNK_ALLOC xmalloc
|
||||
# define OBSTACK_CHUNK_ALLOC xmalloc
|
||||
#endif
|
||||
|
||||
#ifndef OBSTACK_CHUNK_FREE
|
||||
#define OBSTACK_CHUNK_FREE free
|
||||
# define OBSTACK_CHUNK_FREE free
|
||||
#endif
|
||||
|
||||
#if ! defined __GNUC__ || __GNUC__ < 2
|
||||
#define __alignof__(type) 0
|
||||
# define __alignof__(type) 0
|
||||
#endif
|
||||
|
||||
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||
@@ -145,9 +146,7 @@ lbitset_elt_alloc (void)
|
||||
static inline lbitset_elt *
|
||||
lbitset_elt_calloc (void)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
|
||||
elt = lbitset_elt_alloc ();
|
||||
lbitset_elt *elt = lbitset_elt_alloc ();
|
||||
memset (elt->words, 0, sizeof (elt->words));
|
||||
return elt;
|
||||
}
|
||||
@@ -210,8 +209,6 @@ lbitset_elt_unlink (bitset bset, lbitset_elt *elt)
|
||||
static inline void
|
||||
lbitset_prune (bitset bset, lbitset_elt *elt)
|
||||
{
|
||||
lbitset_elt *next;
|
||||
|
||||
if (!elt)
|
||||
return;
|
||||
|
||||
@@ -230,6 +227,7 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
|
||||
bset->b.csize = 0;
|
||||
}
|
||||
|
||||
lbitset_elt *next;
|
||||
for (; elt; elt = next)
|
||||
{
|
||||
next = elt->next;
|
||||
@@ -242,12 +240,9 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
|
||||
static inline bool
|
||||
lbitset_elt_zero_p (lbitset_elt *elt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
if (elt->words[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -257,13 +252,8 @@ static inline void
|
||||
lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
||||
{
|
||||
bitset_windex windex = elt->index;
|
||||
lbitset_elt *ptr;
|
||||
lbitset_elt *current;
|
||||
|
||||
if (bset->b.csize)
|
||||
current = LBITSET_CURRENT (bset);
|
||||
else
|
||||
current = LBITSET_HEAD (bset);
|
||||
lbitset_elt *current = bset->b.csize ? LBITSET_CURRENT (bset) : LBITSET_HEAD (bset);
|
||||
|
||||
/* If this is the first and only element, add it in. */
|
||||
if (LBITSET_HEAD (bset) == 0)
|
||||
@@ -277,6 +267,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
||||
somewhere before the current element. */
|
||||
else if (windex < bset->b.cindex)
|
||||
{
|
||||
lbitset_elt *ptr;
|
||||
for (ptr = current;
|
||||
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
||||
continue;
|
||||
@@ -294,6 +285,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
||||
/* Otherwise, it must go somewhere after the current element. */
|
||||
else
|
||||
{
|
||||
lbitset_elt *ptr;
|
||||
for (ptr = current;
|
||||
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
||||
continue;
|
||||
@@ -319,7 +311,6 @@ static lbitset_elt *
|
||||
lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||
enum lbitset_find_mode mode)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
lbitset_elt *current;
|
||||
|
||||
if (bset->b.csize)
|
||||
@@ -336,6 +327,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||
|
||||
if (current)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
if (windex < bset->b.cindex)
|
||||
{
|
||||
for (elt = current;
|
||||
@@ -371,8 +363,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||
|
||||
case LBITSET_CREATE:
|
||||
windex -= windex % LBITSET_ELT_WORDS;
|
||||
|
||||
elt = lbitset_elt_calloc ();
|
||||
lbitset_elt *elt = lbitset_elt_calloc ();
|
||||
elt->index = windex;
|
||||
lbitset_elt_link (bset, elt);
|
||||
return elt;
|
||||
@@ -387,10 +378,8 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||
static inline void
|
||||
lbitset_weed (bitset bset)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
lbitset_elt *next;
|
||||
|
||||
for (elt = LBITSET_HEAD (bset); elt; elt = next)
|
||||
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt; elt = next)
|
||||
{
|
||||
next = elt->next;
|
||||
if (lbitset_elt_zero_p (elt))
|
||||
@@ -403,9 +392,7 @@ lbitset_weed (bitset bset)
|
||||
static void
|
||||
lbitset_zero (bitset bset)
|
||||
{
|
||||
lbitset_elt *head;
|
||||
|
||||
head = LBITSET_HEAD (bset);
|
||||
lbitset_elt *head = LBITSET_HEAD (bset);
|
||||
if (!head)
|
||||
return;
|
||||
|
||||
@@ -418,22 +405,20 @@ lbitset_zero (bitset bset)
|
||||
static inline bool
|
||||
lbitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
lbitset_elt *delt;
|
||||
int j;
|
||||
|
||||
if (src == dst)
|
||||
return true;
|
||||
|
||||
lbitset_weed (src);
|
||||
lbitset_weed (dst);
|
||||
lbitset_elt *selt;
|
||||
lbitset_elt *delt;
|
||||
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
||||
selt && delt; selt = selt->next, delt = delt->next)
|
||||
{
|
||||
if (selt->index != delt->index)
|
||||
return false;
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
for (int j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
if (delt->words[j] != selt->words[j])
|
||||
return false;
|
||||
}
|
||||
@@ -445,22 +430,18 @@ lbitset_equal_p (bitset dst, bitset src)
|
||||
static inline void
|
||||
lbitset_copy (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
lbitset_elt *head;
|
||||
lbitset_elt *prev;
|
||||
lbitset_elt *tmp;
|
||||
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
lbitset_zero (dst);
|
||||
|
||||
head = LBITSET_HEAD (src);
|
||||
lbitset_elt *head = LBITSET_HEAD (src);
|
||||
if (!head)
|
||||
return;
|
||||
|
||||
prev = 0;
|
||||
for (elt = head; elt; elt = elt->next)
|
||||
lbitset_elt *prev = 0;
|
||||
lbitset_elt *tmp;
|
||||
for (lbitset_elt *elt = head; elt; elt = elt->next)
|
||||
{
|
||||
tmp = lbitset_elt_alloc ();
|
||||
tmp->index = elt->index;
|
||||
@@ -507,10 +488,10 @@ lbitset_copy_cmp (bitset dst, bitset src)
|
||||
static bitset_bindex
|
||||
lbitset_resize (bitset src, bitset_bindex size)
|
||||
{
|
||||
BITSET_NBITS_ (src) = size;
|
||||
BITSET_NBITS_ (src) = size;
|
||||
|
||||
/* Need to prune any excess bits. FIXME. */
|
||||
return size;
|
||||
/* Need to prune any excess bits. FIXME. */
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
@@ -569,29 +550,19 @@ static bitset_bindex
|
||||
lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex rbitno;
|
||||
bitset_bindex bitno;
|
||||
unsigned bcount;
|
||||
bitset_bindex boffset;
|
||||
bitset_windex windex;
|
||||
bitset_bindex count;
|
||||
lbitset_elt *elt;
|
||||
bitset_word word;
|
||||
bitset_bindex n_bits;
|
||||
|
||||
elt = LBITSET_TAIL (bset);
|
||||
lbitset_elt *elt = LBITSET_TAIL (bset);
|
||||
if (!elt)
|
||||
return 0;
|
||||
|
||||
n_bits = (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
|
||||
rbitno = *next;
|
||||
bitset_bindex n_bits = (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
|
||||
bitset_bindex rbitno = *next;
|
||||
|
||||
if (rbitno >= n_bits)
|
||||
return 0;
|
||||
|
||||
bitno = n_bits - (rbitno + 1);
|
||||
bitset_bindex bitno = n_bits - (rbitno + 1);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
|
||||
/* Skip back to starting element. */
|
||||
for (; elt && elt->index > windex; elt = elt->prev)
|
||||
@@ -600,6 +571,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||
if (!elt)
|
||||
return 0;
|
||||
|
||||
unsigned bcount;
|
||||
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
||||
{
|
||||
/* We are trying to start in no-mans land so start
|
||||
@@ -612,8 +584,8 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||
bcount = bitno % BITSET_WORD_BITS;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
boffset = windex * BITSET_WORD_BITS;
|
||||
bitset_bindex count = 0;
|
||||
bitset_bindex boffset = windex * BITSET_WORD_BITS;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
@@ -626,7 +598,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||
windex--, boffset -= BITSET_WORD_BITS,
|
||||
bcount = BITSET_WORD_BITS - 1)
|
||||
{
|
||||
word =
|
||||
bitset_word word =
|
||||
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
||||
|
||||
for (; word; bcount--)
|
||||
@@ -658,25 +630,21 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static bitset_bindex
|
||||
lbitset_list (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_windex windex;
|
||||
bitset_bindex count;
|
||||
lbitset_elt *elt;
|
||||
lbitset_elt *head;
|
||||
bitset_word word;
|
||||
|
||||
head = LBITSET_HEAD (bset);
|
||||
lbitset_elt *head = LBITSET_HEAD (bset);
|
||||
if (!head)
|
||||
return 0;
|
||||
|
||||
bitno = *next;
|
||||
count = 0;
|
||||
bitset_windex windex;
|
||||
lbitset_elt *elt;
|
||||
|
||||
bitset_bindex bitno = *next;
|
||||
bitset_bindex count = 0;
|
||||
|
||||
if (!bitno)
|
||||
{
|
||||
@@ -713,7 +681,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
||||
|
||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
||||
{
|
||||
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
|
||||
bitset_word word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
|
||||
|
||||
for (; word; bitno++)
|
||||
{
|
||||
@@ -746,7 +714,6 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
||||
|
||||
while (elt)
|
||||
{
|
||||
int i;
|
||||
bitset_word *srcp = elt->words;
|
||||
|
||||
if ((count + LBITSET_ELT_BITS) < num)
|
||||
@@ -754,7 +721,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
||||
/* The coast is clear, plant boot! */
|
||||
|
||||
#if LBITSET_ELT_WORDS == 2
|
||||
word = srcp[0];
|
||||
bitset_word word = srcp[0];
|
||||
if (word)
|
||||
{
|
||||
if (!(word & 0xffff))
|
||||
@@ -795,9 +762,9 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
||||
windex++;
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
#else
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
{
|
||||
word = srcp[i];
|
||||
bitset_word word = srcp[i];
|
||||
if (word)
|
||||
{
|
||||
if (!(word & 0xffff))
|
||||
@@ -827,9 +794,9 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
||||
/* Tread more carefully since we need to check
|
||||
if array overflows. */
|
||||
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
{
|
||||
for (word = srcp[i]; word; bitno++)
|
||||
for (bitset_word word = srcp[i]; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
@@ -870,12 +837,12 @@ lbitset_empty_p (bitset dst)
|
||||
{
|
||||
next = elt->next;
|
||||
if (!lbitset_elt_zero_p (elt))
|
||||
return 0;
|
||||
return false;
|
||||
/* Weed as we go. */
|
||||
lbitset_elt_unlink (dst, elt);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -883,21 +850,14 @@ lbitset_empty_p (bitset dst)
|
||||
static inline void
|
||||
lbitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned last_bit;
|
||||
bitset_bindex n_bits;
|
||||
|
||||
n_bits = BITSET_SIZE_ (dst);
|
||||
last_bit = n_bits % LBITSET_ELT_BITS;
|
||||
bitset_bindex n_bits = BITSET_SIZE_ (dst);
|
||||
unsigned last_bit = n_bits % LBITSET_ELT_BITS;
|
||||
|
||||
if (last_bit)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
bitset_windex windex;
|
||||
bitset_word *srcp;
|
||||
|
||||
elt = LBITSET_TAIL (dst);
|
||||
srcp = elt->words;
|
||||
windex = n_bits / BITSET_WORD_BITS;
|
||||
lbitset_elt *elt = LBITSET_TAIL (dst);
|
||||
bitset_word *srcp = elt->words;
|
||||
bitset_windex windex = n_bits / BITSET_WORD_BITS;
|
||||
|
||||
srcp[windex - elt->index] &= ((bitset_word) 1 << last_bit) - 1;
|
||||
windex++;
|
||||
@@ -911,21 +871,18 @@ lbitset_unused_clear (bitset dst)
|
||||
static void
|
||||
lbitset_ones (bitset dst)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_windex windex;
|
||||
lbitset_elt *elt;
|
||||
|
||||
/* This is a decidedly unfriendly operation for a linked list
|
||||
bitset! It makes a sparse bitset become dense. An alternative
|
||||
is to have a flag that indicates that the bitset stores the
|
||||
complement of what it indicates. */
|
||||
bitset! It makes a sparse bitset become dense. An alternative
|
||||
is to have a flag that indicates that the bitset stores the
|
||||
complement of what it indicates. */
|
||||
|
||||
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||
bitset_windex windex
|
||||
= (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||
|
||||
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||
for (bitset_windex i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||
{
|
||||
/* Create new elements if they cannot be found. */
|
||||
elt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||
lbitset_elt *elt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||
memset (elt->words, -1, sizeof (elt->words));
|
||||
}
|
||||
|
||||
@@ -936,27 +893,21 @@ lbitset_ones (bitset dst)
|
||||
static void
|
||||
lbitset_not (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
lbitset_elt *delt;
|
||||
bitset_windex i;
|
||||
unsigned j;
|
||||
bitset_windex windex;
|
||||
bitset_windex windex
|
||||
= (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||
|
||||
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||
|
||||
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||
for (bitset_windex i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||
{
|
||||
/* Create new elements for dst if they cannot be found
|
||||
or substitute zero elements if src elements not found. */
|
||||
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
||||
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||
lbitset_elt *selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
||||
lbitset_elt *delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
for (unsigned j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
delt->words[j] = ~selt->words[j];
|
||||
}
|
||||
lbitset_unused_clear (dst);
|
||||
lbitset_weed (dst);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -964,11 +915,7 @@ lbitset_not (bitset dst, bitset src)
|
||||
static bool
|
||||
lbitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
lbitset_elt *delt;
|
||||
unsigned j;
|
||||
|
||||
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
||||
for (lbitset_elt *selt = LBITSET_HEAD (src), *delt = LBITSET_HEAD (dst);
|
||||
selt || delt; selt = selt->next, delt = delt->next)
|
||||
{
|
||||
if (!selt)
|
||||
@@ -989,7 +936,7 @@ lbitset_subset_p (bitset dst, bitset src)
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
for (unsigned j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
||||
return false;
|
||||
}
|
||||
@@ -1001,11 +948,7 @@ lbitset_subset_p (bitset dst, bitset src)
|
||||
static bool
|
||||
lbitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
lbitset_elt *delt;
|
||||
unsigned j;
|
||||
|
||||
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
||||
for (lbitset_elt *selt = LBITSET_HEAD (src), *delt = LBITSET_HEAD (dst);
|
||||
selt && delt; selt = selt->next, delt = delt->next)
|
||||
{
|
||||
if (selt->index != delt->index)
|
||||
@@ -1025,7 +968,7 @@ lbitset_disjoint_p (bitset dst, bitset src)
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
for (unsigned j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
if (selt->words[j] & delt->words[j])
|
||||
return false;
|
||||
}
|
||||
@@ -1039,26 +982,20 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
lbitset_elt *delt = LBITSET_HEAD (dst);
|
||||
bitset_windex windex1;
|
||||
bitset_windex windex2;
|
||||
bitset_windex windex;
|
||||
lbitset_elt *stmp1;
|
||||
lbitset_elt *stmp2;
|
||||
lbitset_elt *dtmp;
|
||||
bitset_word *srcp1;
|
||||
bitset_word *srcp2;
|
||||
bitset_word *dstp;
|
||||
bool changed = false;
|
||||
unsigned i;
|
||||
|
||||
LBITSET_HEAD (dst) = 0;
|
||||
dst->b.csize = 0;
|
||||
|
||||
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||
bitset_windex windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||
bitset_windex windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||
|
||||
while (selt1 || selt2)
|
||||
{
|
||||
bitset_windex windex;
|
||||
lbitset_elt *stmp1;
|
||||
lbitset_elt *stmp2;
|
||||
|
||||
/* Figure out whether we need to substitute zero elements for
|
||||
missing links. */
|
||||
if (windex1 == windex2)
|
||||
@@ -1090,6 +1027,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
/* Find the appropriate element from DST. Begin by discarding
|
||||
elements that we've skipped. */
|
||||
lbitset_elt *dtmp;
|
||||
while (delt && delt->index < windex)
|
||||
{
|
||||
changed = true;
|
||||
@@ -1107,16 +1045,16 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
/* Do the operation, and if any bits are set, link it into the
|
||||
linked list. */
|
||||
srcp1 = stmp1->words;
|
||||
srcp2 = stmp2->words;
|
||||
dstp = dtmp->words;
|
||||
bitset_word *srcp1 = stmp1->words;
|
||||
bitset_word *srcp2 = stmp2->words;
|
||||
bitset_word *dstp = dtmp->words;
|
||||
switch (op)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
|
||||
case BITSET_OP_OR:
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||
|
||||
@@ -1129,7 +1067,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_AND:
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||
|
||||
@@ -1142,7 +1080,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_XOR:
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||
|
||||
@@ -1155,7 +1093,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_ANDN:
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||
|
||||
@@ -1196,23 +1134,23 @@ lbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
bool changed;
|
||||
|
||||
if (!selt2)
|
||||
{
|
||||
lbitset_weed (dst);
|
||||
changed = !LBITSET_HEAD (dst);
|
||||
bool changed = !LBITSET_HEAD (dst);
|
||||
lbitset_zero (dst);
|
||||
return changed;
|
||||
}
|
||||
else if (!selt1)
|
||||
{
|
||||
lbitset_weed (dst);
|
||||
changed = !LBITSET_HEAD (dst);
|
||||
bool changed = !LBITSET_HEAD (dst);
|
||||
lbitset_zero (dst);
|
||||
return changed;
|
||||
}
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
|
||||
else
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
|
||||
}
|
||||
|
||||
|
||||
@@ -1228,7 +1166,6 @@ lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
bool changed;
|
||||
|
||||
if (!selt2)
|
||||
{
|
||||
@@ -1237,11 +1174,12 @@ lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
else if (!selt1)
|
||||
{
|
||||
lbitset_weed (dst);
|
||||
changed = !LBITSET_HEAD (dst);
|
||||
bool changed = !LBITSET_HEAD (dst);
|
||||
lbitset_zero (dst);
|
||||
return changed;
|
||||
}
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
|
||||
else
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
|
||||
}
|
||||
|
||||
|
||||
@@ -1259,14 +1197,11 @@ lbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
|
||||
if (!selt2)
|
||||
{
|
||||
return lbitset_copy_cmp (dst, src1);
|
||||
}
|
||||
return lbitset_copy_cmp (dst, src1);
|
||||
else if (!selt1)
|
||||
{
|
||||
return lbitset_copy_cmp (dst, src2);
|
||||
}
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
|
||||
return lbitset_copy_cmp (dst, src2);
|
||||
else
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
|
||||
}
|
||||
|
||||
|
||||
@@ -1284,14 +1219,11 @@ lbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
|
||||
if (!selt2)
|
||||
{
|
||||
return lbitset_copy_cmp (dst, src1);
|
||||
}
|
||||
return lbitset_copy_cmp (dst, src1);
|
||||
else if (!selt1)
|
||||
{
|
||||
return lbitset_copy_cmp (dst, src2);
|
||||
}
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
|
||||
return lbitset_copy_cmp (dst, src2);
|
||||
else
|
||||
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -1375,24 +1307,18 @@ lbitset_release_memory (void)
|
||||
void
|
||||
debug_lbitset (bitset bset)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
unsigned i;
|
||||
|
||||
if (!bset)
|
||||
return;
|
||||
|
||||
for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
|
||||
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt; elt = elt->next)
|
||||
{
|
||||
fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
{
|
||||
unsigned j;
|
||||
bitset_word word;
|
||||
|
||||
word = elt->words[i];
|
||||
bitset_word word = elt->words[i];
|
||||
|
||||
fprintf (stderr, " Word %u:", i);
|
||||
for (j = 0; j < LBITSET_WORD_BITS; j++)
|
||||
for (unsigned j = 0; j < LBITSET_WORD_BITS; j++)
|
||||
if ((word & ((bitset_word) 1 << j)))
|
||||
fprintf (stderr, " %u", j);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
+3
-3
@@ -23,10 +23,10 @@
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t lbitset_bytes (bitset_bindex);
|
||||
size_t lbitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset lbitset_init (bitset, bitset_bindex);
|
||||
bitset lbitset_init (bitset, bitset_bindex);
|
||||
|
||||
extern void lbitset_release_memory (void);
|
||||
void lbitset_release_memory (void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* Fake libiberty.h for Bison.
|
||||
|
||||
Copyright (C) 2002-2004, 2009-2015, 2018 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/>. */
|
||||
|
||||
|
||||
/* Bison depends on libiberty's implementation of bitsets, which
|
||||
requires a 'libiberty.h' file. This file provides the minimum
|
||||
services. */
|
||||
|
||||
#ifndef BISON_LIBIBERTY_H_
|
||||
# define BISON_LIBIBERTY_H_ 1
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
|
||||
# include "xalloc.h"
|
||||
|
||||
#endif /* ! BISON_LIBIBERTY_H_ */
|
||||
+20
-25
@@ -1,17 +1,17 @@
|
||||
# Copyright (C) 2001-2015, 2018 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/>.
|
||||
## Copyright (C) 2001-2015, 2018 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/>.
|
||||
|
||||
include lib/gnulib.mk
|
||||
|
||||
@@ -30,7 +30,6 @@ lib_libbison_a_SOURCES += \
|
||||
lib/ebitset.h \
|
||||
lib/lbitset.c \
|
||||
lib/lbitset.h \
|
||||
lib/libiberty.h \
|
||||
lib/vbitset.c \
|
||||
lib/vbitset.h
|
||||
|
||||
@@ -39,20 +38,16 @@ lib_libbison_a_SOURCES += \
|
||||
lib/bitsetv-print.h \
|
||||
lib/bitsetv-print.c
|
||||
|
||||
# timevars, stolen from GCC.
|
||||
lib_libbison_a_SOURCES += \
|
||||
lib/timevar.h \
|
||||
lib/timevar.c \
|
||||
lib/timevar.def
|
||||
|
||||
# Non-gnulib sources in Bison's internal library.
|
||||
lib_libbison_a_SOURCES += \
|
||||
lib/get-errno.h \
|
||||
lib/get-errno.c
|
||||
lib/get-errno.c \
|
||||
lib/path-join.h \
|
||||
lib/path-join.c
|
||||
|
||||
# The Yacc compatibility library.
|
||||
if ENABLE_YACC
|
||||
lib_LIBRARIES = lib/liby.a
|
||||
EXTRA_LIBRARIES = lib/liby.a
|
||||
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c
|
||||
lib_LIBRARIES = lib/liby.a
|
||||
EXTRA_LIBRARIES = lib/liby.a
|
||||
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* Concatenate path components.
|
||||
Copyright (C) 2018 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 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 <[email protected]>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "path-join.h"
|
||||
|
||||
#include <concat-filename.h> /* xconcatenated_filename */
|
||||
#include <filename.h> /* IS_ABSOLUTE_PATH */
|
||||
#include <xalloc.h> /* xstrdup */
|
||||
|
||||
char *
|
||||
xpath_join (const char *path1, const char *path2)
|
||||
{
|
||||
if (!path2 || !*path2)
|
||||
return xstrdup (path1);
|
||||
else if (IS_ABSOLUTE_PATH (path2))
|
||||
return xstrdup (path2);
|
||||
else
|
||||
return xconcatenated_filename (path1, path2, NULL);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Concatenate path components.
|
||||
Copyright (C) 2018 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 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 <[email protected]>. */
|
||||
|
||||
#ifndef _PATH_JOIN_H
|
||||
# define _PATH_JOIN_H
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
/* Concatenate two paths together. PATH2 may be null, or empty, or
|
||||
absolute: do what is right. Return a freshly allocated
|
||||
filename. */
|
||||
char *
|
||||
xpath_join (const char *path1, const char *path2);
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* _PATH_JOIN_H */
|
||||
-565
@@ -1,565 +0,0 @@
|
||||
/* Timing variables for measuring compiler performance.
|
||||
|
||||
Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
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/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if IN_GCC
|
||||
|
||||
#include "system.h"
|
||||
#include "intl.h"
|
||||
#include "rtl.h"
|
||||
|
||||
#else
|
||||
|
||||
/* This source file is taken from the GCC source code, with slight
|
||||
modifications that are under control of the IN_GCC preprocessor
|
||||
variable. The !IN_GCC part of this file is specific to Bison. */
|
||||
|
||||
# include "../src/system.h"
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
int timevar_report = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOCK_T
|
||||
typedef int clock_t;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_TMS
|
||||
struct tms
|
||||
{
|
||||
clock_t tms_utime;
|
||||
clock_t tms_stime;
|
||||
clock_t tms_cutime;
|
||||
clock_t tms_cstime;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
|
||||
extern int getrusage (int, struct rusage *);
|
||||
#endif
|
||||
#if defined HAVE_DECL_TIMES && !HAVE_DECL_TIMES
|
||||
extern clock_t times (struct tms *);
|
||||
#endif
|
||||
#if defined HAVE_DECL_CLOCK && !HAVE_DECL_CLOCK
|
||||
extern clock_t clock (void);
|
||||
#endif
|
||||
|
||||
#ifndef RUSAGE_SELF
|
||||
# define RUSAGE_SELF 0
|
||||
#endif
|
||||
|
||||
/* Calculation of scale factor to convert ticks to microseconds.
|
||||
We mustn't use CLOCKS_PER_SEC except with clock(). */
|
||||
#if HAVE_SYSCONF && defined _SC_CLK_TCK
|
||||
# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
|
||||
#else
|
||||
# ifdef CLK_TCK
|
||||
# define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
|
||||
# else
|
||||
# ifdef HZ
|
||||
# define TICKS_PER_SECOND HZ /* traditional UNIX */
|
||||
# else
|
||||
# define TICKS_PER_SECOND 100 /* often the correct value */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Prefer times to getrusage to clock (each gives successively less
|
||||
information). */
|
||||
#ifdef HAVE_TIMES
|
||||
# define USE_TIMES
|
||||
# define HAVE_USER_TIME
|
||||
# define HAVE_SYS_TIME
|
||||
# define HAVE_WALL_TIME
|
||||
#else
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
# define USE_GETRUSAGE
|
||||
# define HAVE_USER_TIME
|
||||
# define HAVE_SYS_TIME
|
||||
#else
|
||||
#ifdef HAVE_CLOCK
|
||||
# define USE_CLOCK
|
||||
# define HAVE_USER_TIME
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* libc is very likely to have snuck a call to sysconf() into one of
|
||||
the underlying constants, and that can be very slow, so we have to
|
||||
precompute them. Whose wonderful idea was it to make all those
|
||||
_constants_ variable at run time, anyway? */
|
||||
#ifdef USE_TIMES
|
||||
static float ticks_to_msec;
|
||||
#define TICKS_TO_MSEC (1.0 / TICKS_PER_SECOND)
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLOCK
|
||||
static float clocks_to_msec;
|
||||
#define CLOCKS_TO_MSEC (1.0 / CLOCKS_PER_SEC)
|
||||
#endif
|
||||
|
||||
#if IN_GCC
|
||||
#include "flags.h"
|
||||
#endif
|
||||
#include "timevar.h"
|
||||
|
||||
/* See timevar.h for an explanation of timing variables. */
|
||||
|
||||
/* This macro evaluates to nonzero if timing variables are enabled. */
|
||||
#define TIMEVAR_ENABLE (timevar_report)
|
||||
|
||||
/* A timing variable. */
|
||||
|
||||
struct timevar_def
|
||||
{
|
||||
/* Elapsed time for this variable. */
|
||||
struct timevar_time_def elapsed;
|
||||
|
||||
/* If this variable is timed independently of the timing stack,
|
||||
using timevar_start, this contains the start time. */
|
||||
struct timevar_time_def start_time;
|
||||
|
||||
/* The name of this timing variable. */
|
||||
const char *name;
|
||||
|
||||
/* Non-zero if this timing variable is running as a standalone
|
||||
timer. */
|
||||
unsigned standalone : 1;
|
||||
|
||||
/* Non-zero if this timing variable was ever started or pushed onto
|
||||
the timing stack. */
|
||||
unsigned used : 1;
|
||||
};
|
||||
|
||||
/* An element on the timing stack. Elapsed time is attributed to the
|
||||
topmost timing variable on the stack. */
|
||||
|
||||
struct timevar_stack_def
|
||||
{
|
||||
/* The timing variable at this stack level. */
|
||||
struct timevar_def *timevar;
|
||||
|
||||
/* The next lower timing variable context in the stack. */
|
||||
struct timevar_stack_def *next;
|
||||
};
|
||||
|
||||
/* Declared timing variables. Constructed from the contents of
|
||||
timevar.def. */
|
||||
static struct timevar_def timevars[TIMEVAR_LAST];
|
||||
|
||||
/* The top of the timing stack. */
|
||||
static struct timevar_stack_def *stack;
|
||||
|
||||
/* A list of unused (i.e. allocated and subsequently popped)
|
||||
timevar_stack_def instances. */
|
||||
static struct timevar_stack_def *unused_stack_instances;
|
||||
|
||||
/* The time at which the topmost element on the timing stack was
|
||||
pushed. Time elapsed since then is attributed to the topmost
|
||||
element. */
|
||||
static struct timevar_time_def start_time;
|
||||
|
||||
static void get_time (struct timevar_time_def *);
|
||||
static void timevar_accumulate (struct timevar_time_def *,
|
||||
struct timevar_time_def *,
|
||||
struct timevar_time_def *);
|
||||
|
||||
/* Fill the current times into TIME. The definition of this function
|
||||
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
|
||||
HAVE_WALL_TIME macros. */
|
||||
|
||||
static void
|
||||
get_time (now)
|
||||
struct timevar_time_def *now;
|
||||
{
|
||||
now->user = 0;
|
||||
now->sys = 0;
|
||||
now->wall = 0;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
{
|
||||
#ifdef USE_TIMES
|
||||
struct tms tms;
|
||||
now->wall = times (&tms) * ticks_to_msec;
|
||||
#if IN_GCC
|
||||
now->user = tms.tms_utime * ticks_to_msec;
|
||||
now->sys = tms.tms_stime * ticks_to_msec;
|
||||
#else
|
||||
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
|
||||
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_GETRUSAGE
|
||||
struct rusage rusage;
|
||||
#if IN_GCC
|
||||
getrusage (RUSAGE_SELF, &rusage);
|
||||
#else
|
||||
getrusage (RUSAGE_CHILDREN, &rusage);
|
||||
#endif
|
||||
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
now->user = clock () * clocks_to_msec;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the difference between STOP and START to TIMER. */
|
||||
|
||||
static void
|
||||
timevar_accumulate (timer, start, stop)
|
||||
struct timevar_time_def *timer;
|
||||
struct timevar_time_def *start;
|
||||
struct timevar_time_def *stop;
|
||||
{
|
||||
timer->user += stop->user - start->user;
|
||||
timer->sys += stop->sys - start->sys;
|
||||
timer->wall += stop->wall - start->wall;
|
||||
}
|
||||
|
||||
/* Initialize timing variables. */
|
||||
|
||||
void
|
||||
init_timevar ()
|
||||
{
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Zero all elapsed times. */
|
||||
memset ((void *) timevars, 0, sizeof (timevars));
|
||||
|
||||
/* Initialize the names of timing variables. */
|
||||
#define DEFTIMEVAR(identifier__, name__) \
|
||||
timevars[identifier__].name = name__;
|
||||
#include "timevar.def"
|
||||
#undef DEFTIMEVAR
|
||||
|
||||
#ifdef USE_TIMES
|
||||
ticks_to_msec = TICKS_TO_MSEC;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
clocks_to_msec = CLOCKS_TO_MSEC;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Push TIMEVAR onto the timing stack. No further elapsed time is
|
||||
attributed to the previous topmost timing variable on the stack;
|
||||
subsequent elapsed time is attributed to TIMEVAR, until it is
|
||||
popped or another element is pushed on top.
|
||||
|
||||
TIMEVAR cannot be running as a standalone timer. */
|
||||
|
||||
void
|
||||
timevar_push (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_stack_def *context;
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Mark this timing variable as used. */
|
||||
tv->used = 1;
|
||||
|
||||
/* Can't push a standalone timer. */
|
||||
if (tv->standalone)
|
||||
abort ();
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* If the stack isn't empty, attribute the current elapsed time to
|
||||
the old topmost element. */
|
||||
if (stack)
|
||||
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to
|
||||
TIMEVAR. */
|
||||
start_time = now;
|
||||
|
||||
/* See if we have a previously-allocated stack instance. If so,
|
||||
take it off the list. If not, malloc a new one. */
|
||||
if (unused_stack_instances != NULL)
|
||||
{
|
||||
context = unused_stack_instances;
|
||||
unused_stack_instances = unused_stack_instances->next;
|
||||
}
|
||||
else
|
||||
context = (struct timevar_stack_def *)
|
||||
xmalloc (sizeof (struct timevar_stack_def));
|
||||
|
||||
/* Fill it in and put it on the stack. */
|
||||
context->timevar = tv;
|
||||
context->next = stack;
|
||||
stack = context;
|
||||
}
|
||||
|
||||
/* Pop the topmost timing variable element off the timing stack. The
|
||||
popped variable must be TIMEVAR. Elapsed time since the that
|
||||
element was pushed on, or since it was last exposed on top of the
|
||||
stack when the element above it was popped off, is credited to that
|
||||
timing variable. */
|
||||
|
||||
void
|
||||
timevar_pop (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_time_def now;
|
||||
struct timevar_stack_def *popped = stack;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
if (&timevars[timevar] != stack->timevar)
|
||||
abort ();
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* Attribute the elapsed time to the element we're popping. */
|
||||
timevar_accumulate (&popped->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to the
|
||||
element just exposed on the stack. */
|
||||
start_time = now;
|
||||
|
||||
/* Take the item off the stack. */
|
||||
stack = stack->next;
|
||||
|
||||
/* Don't delete the stack element; instead, add it to the list of
|
||||
unused elements for later use. */
|
||||
popped->next = unused_stack_instances;
|
||||
unused_stack_instances = popped;
|
||||
}
|
||||
|
||||
/* Start timing TIMEVAR independently of the timing stack. Elapsed
|
||||
time until timevar_stop is called for the same timing variable is
|
||||
attributed to TIMEVAR. */
|
||||
|
||||
void
|
||||
timevar_start (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Mark this timing variable as used. */
|
||||
tv->used = 1;
|
||||
|
||||
/* Don't allow the same timing variable to be started more than
|
||||
once. */
|
||||
if (tv->standalone)
|
||||
abort ();
|
||||
tv->standalone = 1;
|
||||
|
||||
get_time (&tv->start_time);
|
||||
}
|
||||
|
||||
/* Stop timing TIMEVAR. Time elapsed since timevar_start was called
|
||||
is attributed to it. */
|
||||
|
||||
void
|
||||
timevar_stop (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* TIMEVAR must have been started via timevar_start. */
|
||||
if (!tv->standalone)
|
||||
abort ();
|
||||
|
||||
get_time (&now);
|
||||
timevar_accumulate (&tv->elapsed, &tv->start_time, &now);
|
||||
}
|
||||
|
||||
/* Fill the elapsed time for TIMEVAR into ELAPSED. Returns
|
||||
update-to-date information even if TIMEVAR is currently running. */
|
||||
|
||||
void
|
||||
timevar_get (timevar, elapsed)
|
||||
timevar_id_t timevar;
|
||||
struct timevar_time_def *elapsed;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_time_def now;
|
||||
|
||||
*elapsed = tv->elapsed;
|
||||
|
||||
/* Is TIMEVAR currently running as a standalone timer? */
|
||||
if (tv->standalone)
|
||||
{
|
||||
get_time (&now);
|
||||
timevar_accumulate (elapsed, &tv->start_time, &now);
|
||||
}
|
||||
/* Or is TIMEVAR at the top of the timer stack? */
|
||||
else if (stack->timevar == tv)
|
||||
{
|
||||
get_time (&now);
|
||||
timevar_accumulate (elapsed, &start_time, &now);
|
||||
}
|
||||
}
|
||||
|
||||
/* Summarize timing variables to FP. The timing variable TV_TOTAL has
|
||||
a special meaning -- it's considered to be the total elapsed time,
|
||||
for normalizing the others, and is displayed last. */
|
||||
|
||||
void
|
||||
timevar_print (fp)
|
||||
FILE *fp;
|
||||
{
|
||||
/* Only print stuff if we have some sort of time information. */
|
||||
#if defined HAVE_USER_TIME || defined HAVE_SYS_TIME || defined HAVE_WALL_TIME
|
||||
unsigned /* timevar_id_t */ id;
|
||||
struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed;
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Update timing information in case we're calling this from GDB. */
|
||||
|
||||
if (fp == 0)
|
||||
fp = stderr;
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* If the stack isn't empty, attribute the current elapsed time to
|
||||
the old topmost element. */
|
||||
if (stack)
|
||||
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to
|
||||
TIMEVAR. */
|
||||
start_time = now;
|
||||
|
||||
fputs (_("\nExecution times (seconds)\n"), fp);
|
||||
for (id = 0; id < (unsigned) TIMEVAR_LAST; ++id)
|
||||
{
|
||||
struct timevar_def *tv = &timevars[(timevar_id_t) id];
|
||||
const float tiny = 5e-3;
|
||||
|
||||
/* Don't print the total execution time here; that goes at the
|
||||
end. */
|
||||
if ((timevar_id_t) id == TV_TOTAL)
|
||||
continue;
|
||||
|
||||
/* Don't print timing variables that were never used. */
|
||||
if (!tv->used)
|
||||
continue;
|
||||
|
||||
/* Don't print timing variables if we're going to get a row of
|
||||
zeroes. */
|
||||
if (tv->elapsed.user < tiny
|
||||
&& tv->elapsed.sys < tiny
|
||||
&& tv->elapsed.wall < tiny)
|
||||
continue;
|
||||
|
||||
/* The timing variable name. */
|
||||
fprintf (fp, " %-22s:", tv->name);
|
||||
|
||||
#ifdef HAVE_USER_TIME
|
||||
/* Print user-mode time for this process. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
||||
tv->elapsed.user,
|
||||
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
||||
#endif /* HAVE_USER_TIME */
|
||||
|
||||
#ifdef HAVE_SYS_TIME
|
||||
/* Print system-mode time for this process. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
||||
tv->elapsed.sys,
|
||||
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
||||
#endif /* HAVE_SYS_TIME */
|
||||
|
||||
#ifdef HAVE_WALL_TIME
|
||||
/* Print wall clock time elapsed. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
||||
tv->elapsed.wall,
|
||||
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
||||
#endif /* HAVE_WALL_TIME */
|
||||
|
||||
putc ('\n', fp);
|
||||
}
|
||||
|
||||
/* Print total time. */
|
||||
fputs (_(" TOTAL :"), fp);
|
||||
#ifdef HAVE_USER_TIME
|
||||
fprintf (fp, "%7.2f ", total->user);
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME
|
||||
fprintf (fp, "%7.2f ", total->sys);
|
||||
#endif
|
||||
#ifdef HAVE_WALL_TIME
|
||||
fprintf (fp, "%7.2f\n", total->wall);
|
||||
#endif
|
||||
|
||||
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
||||
|| defined (HAVE_WALL_TIME) */
|
||||
}
|
||||
|
||||
/* Returns time (user + system) used so far by the compiler process,
|
||||
in microseconds. */
|
||||
|
||||
long
|
||||
get_run_time ()
|
||||
{
|
||||
struct timevar_time_def total_elapsed;
|
||||
timevar_get (TV_TOTAL, &total_elapsed);
|
||||
return total_elapsed.user + total_elapsed.sys;
|
||||
}
|
||||
|
||||
/* Prints a message to stderr stating that time elapsed in STR is
|
||||
TOTAL (given in microseconds). */
|
||||
|
||||
void
|
||||
print_time (str, total)
|
||||
const char *str;
|
||||
long total;
|
||||
{
|
||||
long all_time = get_run_time ();
|
||||
fprintf (stderr,
|
||||
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
||||
str, total / 1000000, total % 1000000,
|
||||
all_time == 0 ? 0
|
||||
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
||||
}
|
||||
+22
-22
@@ -28,35 +28,35 @@
|
||||
|
||||
DEFTIMEVAR (id, name)
|
||||
|
||||
where ID is the enumeral value used to identify the timing
|
||||
where ID is the enum value used to identify the timing
|
||||
variable, and NAME is a character string describing its purpose. */
|
||||
|
||||
/* The total execution time. */
|
||||
DEFTIMEVAR (TV_TOTAL , "total time")
|
||||
DEFTIMEVAR (tv_total , "total time")
|
||||
|
||||
/* Time spent in the reader. */
|
||||
DEFTIMEVAR (TV_READER , "reader")
|
||||
DEFTIMEVAR (TV_SCANNING , "scanner")
|
||||
DEFTIMEVAR (TV_PARSING , "parser")
|
||||
DEFTIMEVAR (tv_reader , "reader")
|
||||
DEFTIMEVAR (tv_scanning , "scanner")
|
||||
DEFTIMEVAR (tv_parsing , "parser")
|
||||
|
||||
/* Time spent handling the grammar. */
|
||||
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
|
||||
DEFTIMEVAR (TV_SETS , "computing the sets")
|
||||
DEFTIMEVAR (TV_LR0 , "LR(0)")
|
||||
DEFTIMEVAR (TV_LALR , "LALR(1)")
|
||||
DEFTIMEVAR (TV_IELR_PHASE1 , "IELR(1) Phase 1")
|
||||
DEFTIMEVAR (TV_IELR_PHASE2 , "IELR(1) Phase 2")
|
||||
DEFTIMEVAR (TV_IELR_PHASE3 , "IELR(1) Phase 3")
|
||||
DEFTIMEVAR (TV_IELR_PHASE4 , "IELR(1) Phase 4")
|
||||
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
|
||||
DEFTIMEVAR (tv_reduce , "reducing the grammar")
|
||||
DEFTIMEVAR (tv_sets , "computing the sets")
|
||||
DEFTIMEVAR (tv_lr0 , "LR(0)")
|
||||
DEFTIMEVAR (tv_lalr , "LALR(1)")
|
||||
DEFTIMEVAR (tv_ielr_phase1 , "IELR(1) Phase 1")
|
||||
DEFTIMEVAR (tv_ielr_phase2 , "IELR(1) Phase 2")
|
||||
DEFTIMEVAR (tv_ielr_phase3 , "IELR(1) Phase 3")
|
||||
DEFTIMEVAR (tv_ielr_phase4 , "IELR(1) Phase 4")
|
||||
DEFTIMEVAR (tv_conflicts , "conflicts")
|
||||
|
||||
/* Time spent outputing results. */
|
||||
DEFTIMEVAR (TV_REPORT , "outputing report")
|
||||
DEFTIMEVAR (TV_GRAPH , "outputing graph")
|
||||
DEFTIMEVAR (TV_XML , "outputing xml")
|
||||
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
|
||||
DEFTIMEVAR (TV_PARSER , "outputing parser")
|
||||
DEFTIMEVAR (TV_M4 , "running m4")
|
||||
/* Time spent outputting results. */
|
||||
DEFTIMEVAR (tv_report , "outputting report")
|
||||
DEFTIMEVAR (tv_graph , "outputting graph")
|
||||
DEFTIMEVAR (tv_xml , "outputting xml")
|
||||
DEFTIMEVAR (tv_actions , "parser action tables")
|
||||
DEFTIMEVAR (tv_parser , "outputting parser")
|
||||
DEFTIMEVAR (tv_m4 , "running m4")
|
||||
|
||||
/* Time spent by freeing the memory :). */
|
||||
DEFTIMEVAR (TV_FREE , "freeing")
|
||||
DEFTIMEVAR (tv_free , "freeing")
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/* Timing variables for measuring compiler performance.
|
||||
|
||||
Copyright (C) 2000, 2002, 2004, 2009-2015, 2018 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
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/>. */
|
||||
|
||||
#ifndef GCC_TIMEVAR_H
|
||||
#define GCC_TIMEVAR_H
|
||||
|
||||
/* Timing variables are used to measure elapsed time in various
|
||||
portions of the compiler. Each measures elapsed user, system, and
|
||||
wall-clock time, as appropriate to and supported by the host
|
||||
system.
|
||||
|
||||
Timing variables are defined using the DEFTIMEVAR macro in
|
||||
timevar.def. Each has an enumeral identifier, used when referring
|
||||
to the timing variable in code, and a character string name.
|
||||
|
||||
Timing variables can be used in two ways:
|
||||
|
||||
- On the timing stack, using timevar_push and timevar_pop.
|
||||
Timing variables may be pushed onto the stack; elapsed time is
|
||||
attributed to the topmost timing variable on the stack. When
|
||||
another variable is pushed on, the previous topmost variable is
|
||||
'paused' until the pushed variable is popped back off.
|
||||
|
||||
- As a standalone timer, using timevar_start and timevar_stop.
|
||||
All time elapsed between the two calls is attributed to the
|
||||
variable.
|
||||
*/
|
||||
|
||||
/* This structure stores the various varieties of time that can be
|
||||
measured. Times are stored in seconds. The time may be an
|
||||
absolute time or a time difference; in the former case, the time
|
||||
base is undefined, except that the difference between two times
|
||||
produces a valid time difference. */
|
||||
|
||||
struct timevar_time_def
|
||||
{
|
||||
/* User time in this process. */
|
||||
float user;
|
||||
|
||||
/* System time (if applicable for this host platform) in this
|
||||
process. */
|
||||
float sys;
|
||||
|
||||
/* Wall clock time. */
|
||||
float wall;
|
||||
};
|
||||
|
||||
/* An enumeration of timing variable identifiers. Constructed from
|
||||
the contents of timevar.def. */
|
||||
|
||||
#define DEFTIMEVAR(identifier__, name__) \
|
||||
identifier__,
|
||||
typedef enum
|
||||
{
|
||||
#include "timevar.def"
|
||||
TIMEVAR_LAST
|
||||
}
|
||||
timevar_id_t;
|
||||
#undef DEFTIMEVAR
|
||||
|
||||
extern void init_timevar (void);
|
||||
extern void timevar_push (timevar_id_t);
|
||||
extern void timevar_pop (timevar_id_t);
|
||||
extern void timevar_start (timevar_id_t);
|
||||
extern void timevar_stop (timevar_id_t);
|
||||
extern void timevar_get (timevar_id_t, struct timevar_time_def *);
|
||||
extern void timevar_print (FILE *);
|
||||
|
||||
/* Provided for backward compatibility. */
|
||||
extern long get_run_time (void);
|
||||
extern void print_time (const char *, long);
|
||||
|
||||
extern int timevar_report;
|
||||
|
||||
#endif /* ! GCC_TIMEVAR_H */
|
||||
+181
-334
@@ -56,19 +56,14 @@ static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
|
||||
static bitset_bindex
|
||||
vbitset_resize (bitset src, bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex oldsize;
|
||||
bitset_windex newsize;
|
||||
|
||||
if (n_bits == BITSET_NBITS_ (src))
|
||||
return n_bits;
|
||||
|
||||
oldsize = VBITSET_SIZE (src);
|
||||
newsize = VBITSET_N_WORDS (n_bits);
|
||||
bitset_windex oldsize = VBITSET_SIZE (src);
|
||||
bitset_windex newsize = VBITSET_N_WORDS (n_bits);
|
||||
|
||||
if (oldsize < newsize)
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
/* The bitset needs to grow. If we already have enough memory
|
||||
allocated, then just zero what we need. */
|
||||
if (newsize > VBITSET_ASIZE (src))
|
||||
@@ -78,11 +73,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
|
||||
grow the bitset 25% larger than requested to reduce
|
||||
number of reallocations. */
|
||||
|
||||
if (oldsize == 0)
|
||||
size = newsize;
|
||||
else
|
||||
size = newsize + newsize / 4;
|
||||
|
||||
bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4;
|
||||
VBITSET_WORDS (src)
|
||||
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
|
||||
VBITSET_ASIZE (src) = size;
|
||||
@@ -115,9 +106,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
static void
|
||||
vbitset_set (dst, bitno)
|
||||
bitset dst;
|
||||
bitset_bindex bitno;
|
||||
vbitset_set (bitset dst, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
|
||||
@@ -134,9 +123,7 @@ vbitset_set (dst, bitno)
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
static void
|
||||
vbitset_reset (dst, bitno)
|
||||
bitset dst ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
vbitset_reset (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* We must be accessing outside the cache so the bit is
|
||||
zero anyway. */
|
||||
@@ -145,13 +132,12 @@ vbitset_reset (dst, bitno)
|
||||
|
||||
/* Test bit BITNO in bitset SRC. */
|
||||
static bool
|
||||
vbitset_test (src, bitno)
|
||||
bitset src ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
vbitset_test (bitset src ATTRIBUTE_UNUSED,
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* We must be accessing outside the cache so the bit is
|
||||
zero anyway. */
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,22 +146,13 @@ vbitset_test (src, bitno)
|
||||
actual number of bits found and with *NEXT indicating where search
|
||||
stopped. */
|
||||
static bitset_bindex
|
||||
vbitset_list_reverse (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
vbitset_list_reverse (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex rbitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
unsigned bitcnt;
|
||||
bitset_bindex bitoff;
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_bindex n_bits = BITSET_SIZE_ (src);
|
||||
|
||||
rbitno = *next;
|
||||
bitset_bindex rbitno = *next;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
@@ -183,19 +160,17 @@ vbitset_list_reverse (src, list, num, next)
|
||||
if (rbitno >= n_bits)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
bitset_bindex count = 0;
|
||||
|
||||
bitno = n_bits - (rbitno + 1);
|
||||
bitset_bindex bitno = n_bits - (rbitno + 1);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
unsigned bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
|
||||
|
||||
do
|
||||
{
|
||||
bitset_word word;
|
||||
|
||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
for (; word; bitcnt--)
|
||||
{
|
||||
if (word & BITSET_MSB)
|
||||
@@ -220,26 +195,21 @@ vbitset_list_reverse (src, list, num, next)
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static bitset_bindex
|
||||
vbitset_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
vbitset_list (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
bitset_bindex bitoff;
|
||||
bitset_windex size = VBITSET_SIZE (src);
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_bindex bitno = *next;
|
||||
bitset_bindex count = 0;
|
||||
|
||||
bitset_windex windex;
|
||||
bitset_bindex bitoff;
|
||||
bitset_word word;
|
||||
|
||||
bitno = *next;
|
||||
|
||||
count = 0;
|
||||
if (!bitno)
|
||||
{
|
||||
/* Many bitsets are zero, so make this common case fast. */
|
||||
@@ -327,12 +297,9 @@ vbitset_list (src, list, num, next)
|
||||
|
||||
/* Ensure that any unused bits within the last word are clear. */
|
||||
static inline void
|
||||
vbitset_unused_clear (dst)
|
||||
bitset dst;
|
||||
vbitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned last_bit;
|
||||
|
||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||
if (last_bit)
|
||||
VBITSET_WORDS (dst)[VBITSET_SIZE (dst) - 1] &=
|
||||
((bitset_word) 1 << last_bit) - 1;
|
||||
@@ -343,9 +310,7 @@ static void
|
||||
vbitset_ones (bitset dst)
|
||||
{
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
unsigned bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
||||
unsigned bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
||||
|
||||
memset (dstp, -1, bytes);
|
||||
vbitset_unused_clear (dst);
|
||||
@@ -356,9 +321,7 @@ static void
|
||||
vbitset_zero (bitset dst)
|
||||
{
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
unsigned bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
||||
unsigned bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
||||
|
||||
memset (dstp, 0, bytes);
|
||||
}
|
||||
@@ -367,34 +330,27 @@ vbitset_zero (bitset dst)
|
||||
static bool
|
||||
vbitset_empty_p (bitset dst)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
|
||||
for (i = 0; i < VBITSET_SIZE (dst); i++)
|
||||
for (unsigned i = 0; i < VBITSET_SIZE (dst); i++)
|
||||
if (dstp[i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
vbitset_copy1 (bitset dst, bitset src)
|
||||
{
|
||||
bitset_word *srcp;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize;
|
||||
bitset_windex dsize;
|
||||
|
||||
if (src == dst)
|
||||
return;
|
||||
return;
|
||||
|
||||
vbitset_resize (dst, BITSET_SIZE_ (src));
|
||||
|
||||
srcp = VBITSET_WORDS (src);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
ssize = VBITSET_SIZE (src);
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex ssize = VBITSET_SIZE (src);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
|
||||
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
||||
|
||||
@@ -406,21 +362,15 @@ vbitset_copy1 (bitset dst, bitset src)
|
||||
static void
|
||||
vbitset_not (bitset dst, bitset src)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *srcp;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize;
|
||||
bitset_windex dsize;
|
||||
|
||||
vbitset_resize (dst, BITSET_SIZE_ (src));
|
||||
|
||||
srcp = VBITSET_WORDS (src);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
ssize = VBITSET_SIZE (src);
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex ssize = VBITSET_SIZE (src);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < ssize; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
for (unsigned i = 0; i < ssize; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
|
||||
vbitset_unused_clear (dst);
|
||||
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
||||
@@ -431,96 +381,87 @@ vbitset_not (bitset dst, bitset src)
|
||||
static bool
|
||||
vbitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex ssize = VBITSET_SIZE (src);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize, dsize); i++)
|
||||
if (*srcp++ != *dstp++)
|
||||
return 0;
|
||||
if (*srcp++ != *dstp++)
|
||||
return false;
|
||||
|
||||
if (ssize > dsize)
|
||||
{
|
||||
for (; i < ssize; i++)
|
||||
if (*srcp++)
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; i < dsize; i++)
|
||||
if (*dstp++)
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
vbitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex ssize = VBITSET_SIZE (src);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return 0;
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return 0;
|
||||
|
||||
if (ssize > dsize)
|
||||
{
|
||||
for (; i < ssize; i++)
|
||||
if (*srcp++)
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
vbitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *srcp = VBITSET_WORDS (src);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex ssize = VBITSET_SIZE (src);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < min (ssize, dsize); i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return 0;
|
||||
for (unsigned i = 0; i < min (ssize, dsize); i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
vbitset_and (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||
*dstp++ = *src1p++ & *src2p++;
|
||||
for (unsigned i = 0; i < min (ssize1, ssize2); i++)
|
||||
*dstp++ = *src1p++ & *src2p++;
|
||||
|
||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - min (ssize1, ssize2)));
|
||||
}
|
||||
@@ -529,31 +470,24 @@ vbitset_and (bitset dst, bitset src1, bitset src2)
|
||||
static bool
|
||||
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
bool changed = false;
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -568,7 +502,7 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
if (*dstp != 0)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = 0;
|
||||
}
|
||||
}
|
||||
@@ -582,25 +516,18 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
vbitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||
*dstp++ = *src1p++ & ~(*src2p++);
|
||||
*dstp++ = *src1p++ & ~(*src2p++);
|
||||
|
||||
if (ssize2 > ssize1)
|
||||
{
|
||||
@@ -622,31 +549,24 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
static bool
|
||||
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
bool changed = false;
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +577,7 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
if (*dstp != 0)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = 0;
|
||||
}
|
||||
}
|
||||
@@ -672,7 +592,7 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -687,25 +607,18 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
vbitset_or (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||
*dstp++ = *src1p++ | *src2p++;
|
||||
*dstp++ = *src1p++ | *src2p++;
|
||||
|
||||
if (ssize2 > ssize1)
|
||||
{
|
||||
@@ -723,31 +636,25 @@ vbitset_or (bitset dst, bitset src1, bitset src2)
|
||||
static bool
|
||||
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
bool changed = false;
|
||||
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ | *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -764,7 +671,7 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -778,25 +685,18 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
vbitset_xor (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||
*dstp++ = *src1p++ ^ *src2p++;
|
||||
*dstp++ = *src1p++ ^ *src2p++;
|
||||
|
||||
if (ssize2 > ssize1)
|
||||
{
|
||||
@@ -814,31 +714,24 @@ vbitset_xor (bitset dst, bitset src1, bitset src2)
|
||||
static bool
|
||||
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex ssize1;
|
||||
bitset_windex ssize2;
|
||||
bitset_windex dsize;
|
||||
|
||||
bool changed = false;
|
||||
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||
|
||||
dsize = VBITSET_SIZE (dst);
|
||||
ssize1 = VBITSET_SIZE (src1);
|
||||
ssize2 = VBITSET_SIZE (src2);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -855,7 +748,7 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -872,13 +765,6 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
static void
|
||||
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *src3p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex size;
|
||||
|
||||
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||
{
|
||||
@@ -888,47 +774,40 @@ vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
src3p = VBITSET_WORDS (src3);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
size = VBITSET_SIZE (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex size = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *src3p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex size;
|
||||
|
||||
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||
return bitset_and_or_cmp_ (dst, src1, src2, src3);
|
||||
|
||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
src3p = VBITSET_WORDS (src3);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
size = VBITSET_SIZE (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex size = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
bool changed = false;
|
||||
for (unsigned i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -939,13 +818,6 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
static void
|
||||
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *src3p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex size;
|
||||
|
||||
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||
{
|
||||
@@ -955,47 +827,40 @@ vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
src3p = VBITSET_WORDS (src3);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
size = VBITSET_SIZE (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex size = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *src3p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex size;
|
||||
|
||||
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||
return bitset_andn_or_cmp_ (dst, src1, src2, src3);
|
||||
|
||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
src3p = VBITSET_WORDS (src3);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
size = VBITSET_SIZE (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex size = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
bool changed = false;
|
||||
for (unsigned i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1006,13 +871,6 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
static void
|
||||
vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
unsigned i;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *src3p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex size;
|
||||
|
||||
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||
{
|
||||
@@ -1022,47 +880,41 @@ vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
src3p = VBITSET_WORDS (src3);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
size = VBITSET_SIZE (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex size = VBITSET_SIZE (dst);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
unsigned i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p;
|
||||
bitset_word *src2p;
|
||||
bitset_word *src3p;
|
||||
bitset_word *dstp;
|
||||
bitset_windex size;
|
||||
|
||||
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||
return bitset_or_and_cmp_ (dst, src1, src2, src3);
|
||||
|
||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||
|
||||
src1p = VBITSET_WORDS (src1);
|
||||
src2p = VBITSET_WORDS (src2);
|
||||
src3p = VBITSET_WORDS (src3);
|
||||
dstp = VBITSET_WORDS (dst);
|
||||
size = VBITSET_SIZE (dst);
|
||||
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||
bitset_windex size = VBITSET_SIZE (dst);
|
||||
|
||||
unsigned i;
|
||||
bool changed = false;
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1074,9 +926,9 @@ static void
|
||||
vbitset_copy (bitset dst, bitset src)
|
||||
{
|
||||
if (BITSET_COMPATIBLE_ (dst, src))
|
||||
vbitset_copy1 (dst, src);
|
||||
vbitset_copy1 (dst, src);
|
||||
else
|
||||
bitset_copy_ (dst, src);
|
||||
bitset_copy_ (dst, src);
|
||||
}
|
||||
|
||||
|
||||
@@ -1119,22 +971,17 @@ struct bitset_vtable vbitset_vtable = {
|
||||
|
||||
|
||||
size_t
|
||||
vbitset_bytes (n_bits)
|
||||
bitset_bindex n_bits ATTRIBUTE_UNUSED;
|
||||
vbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return sizeof (struct vbitset_struct);
|
||||
}
|
||||
|
||||
|
||||
bitset
|
||||
vbitset_init (bset, n_bits)
|
||||
bitset bset;
|
||||
bitset_bindex n_bits;
|
||||
vbitset_init (bitset bset, bitset_bindex n_bits)
|
||||
{
|
||||
bset->b.vtable = &vbitset_vtable;
|
||||
|
||||
bset->b.cindex = 0;
|
||||
|
||||
VBITSET_SIZE (bset) = 0;
|
||||
vbitset_resize (bset, n_bits);
|
||||
return bset;
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t vbitset_bytes (bitset_bindex);
|
||||
size_t vbitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset vbitset_init (bitset, bitset_bindex);
|
||||
bitset vbitset_init (bitset, bitset_bindex);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -179,3 +179,14 @@
|
||||
/xstrndup.m4
|
||||
/host-cpu-c-abi.m4
|
||||
/stat-time.m4
|
||||
/sys_time_h.m4
|
||||
/sys_times_h.m4
|
||||
/sh-filename.m4
|
||||
/clock_time.m4
|
||||
/gethrxtime.m4
|
||||
/getrusage.m4
|
||||
/gettime.m4
|
||||
/gettimeofday.m4
|
||||
/localtime-buffer.m4
|
||||
/sys_resource_h.m4
|
||||
/timespec.m4
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# bison-check-compile-flag.m4
|
||||
|
||||
# serial 1
|
||||
|
||||
# Copyright (C) 2018 Free Software Foundation, # Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
|
||||
|
||||
# BISON_CHECK_COMPILER_FLAG(FLAG,
|
||||
# [ACTION-SUCCESS], [ACTION-FAILURE],
|
||||
# [EXTRA-FLAGS])
|
||||
# -------------------------------------------------------------
|
||||
|
||||
# Based on Autoconf Macro Archive's AX_CHECK_COMPILE_FLAG, but using
|
||||
# AC_LINK_IFELSE, not just AC_COMPILE_IFELSE to capture failures such
|
||||
# as:
|
||||
#
|
||||
# ./c++.at:401: $PREPARSER ./list
|
||||
# stderr:
|
||||
# ./list: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
|
||||
#
|
||||
# because we thought '-stdlib=c++' works, as it passes with AC_COMPILE_IFELSE.
|
||||
#
|
||||
# Not using AX_CHECK_LINK_FLAG, because its message is inappropriate:
|
||||
#
|
||||
# checking whether the linker accepts -std=c++11... yes
|
||||
# checking whether the linker accepts -std=c++14... yes
|
||||
# checking whether the linker accepts -std=c++17... no
|
||||
AC_DEFUN([BISON_CHECK_COMPILER_FLAG],
|
||||
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
|
||||
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||
AC_LINK_IFELSE([m4_default([$5], [AC_LANG_PROGRAM()])],
|
||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||
[AS_VAR_SET(CACHEVAR,[no])])
|
||||
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [$2], [$3])
|
||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||
])dnl BISON_CHECK_COMPILER_FLAGS
|
||||
@@ -0,0 +1,161 @@
|
||||
# bison-cxx-std.m4 serial 1
|
||||
|
||||
# Copyright (C) 2018 Free Software Foundation, # Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
m4_define([_BISON_CXXSTD_98_snippet],
|
||||
[#include <vector>
|
||||
|
||||
typedef std::vector<int> ints;
|
||||
])
|
||||
|
||||
m4_define([_BISON_CXXSTD_03_snippet],
|
||||
[])
|
||||
|
||||
m4_define([_BISON_CXXSTD_11_snippet],
|
||||
[#include <algorithm>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
// C++11
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
using right_angle_brackets = check<check<bool>>;
|
||||
|
||||
auto f = std::make_shared<std::string>("shared_ptr");
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);
|
||||
|
||||
auto d = a;
|
||||
|
||||
// Some versions of libstdc++ do not support std::set::emplace.
|
||||
void foo()
|
||||
{
|
||||
std::set<int> is;
|
||||
is.emplace(42);
|
||||
}
|
||||
|
||||
// Clang++ 3.5, for a while, was unable to process properly
|
||||
// the for-loop because its variable, r, is a typedef...
|
||||
// It failed as follows:
|
||||
//
|
||||
// error: unexpected ':' in nested name specifier; did you mean '::'?
|
||||
// for (auto r: std::set<int>{1, 2})
|
||||
// ^
|
||||
// ::
|
||||
using r = std::set<int>;
|
||||
void bar()
|
||||
{
|
||||
for (int r: std::set<int>{1, 2})
|
||||
continue;
|
||||
}
|
||||
])
|
||||
|
||||
m4_define([_BISON_CXXSTD_14_snippet],
|
||||
[ // C++14
|
||||
void mismatch()
|
||||
{
|
||||
using ints = std::vector<int>;
|
||||
auto v1 = ints{1, 2, 3};
|
||||
auto v2 = ints{1, 2};
|
||||
std::mismatch(std::begin(v1), std::end(v1),
|
||||
std::begin(v2), std::end(v2));
|
||||
}
|
||||
])
|
||||
|
||||
m4_define([_BISON_CXXSTD_17_snippet],
|
||||
[ // C++17
|
||||
namespace ns1::ns2::ns3 {}
|
||||
|
||||
#include <optional>
|
||||
auto opt_string = std::optional<std::string>{};
|
||||
auto out = std::ostringstream{};
|
||||
])
|
||||
|
||||
m4_define([_BISON_CXXSTD_2A_snippet],
|
||||
[ // C++2A
|
||||
])
|
||||
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody(98)],
|
||||
[AC_LANG_PROGRAM([
|
||||
_BISON_CXXSTD_98_snippet
|
||||
])])
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody(03)],
|
||||
[AC_LANG_PROGRAM([
|
||||
_BISON_CXXSTD_98_snippet
|
||||
_BISON_CXXSTD_03_snippet
|
||||
])])
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody(11)],
|
||||
[AC_LANG_PROGRAM([
|
||||
_BISON_CXXSTD_98_snippet
|
||||
_BISON_CXXSTD_03_snippet
|
||||
_BISON_CXXSTD_11_snippet
|
||||
])])
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody(14)],
|
||||
[AC_LANG_PROGRAM([
|
||||
_BISON_CXXSTD_98_snippet
|
||||
_BISON_CXXSTD_03_snippet
|
||||
_BISON_CXXSTD_11_snippet
|
||||
_BISON_CXXSTD_14_snippet
|
||||
])])
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody(17)],
|
||||
[AC_LANG_PROGRAM([
|
||||
_BISON_CXXSTD_98_snippet
|
||||
_BISON_CXXSTD_03_snippet
|
||||
_BISON_CXXSTD_11_snippet
|
||||
_BISON_CXXSTD_14_snippet
|
||||
_BISON_CXXSTD_17_snippet
|
||||
])])
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody(2a)],
|
||||
[AC_LANG_PROGRAM([
|
||||
_BISON_CXXSTD_98_snippet
|
||||
_BISON_CXXSTD_03_snippet
|
||||
_BISON_CXXSTD_11_snippet
|
||||
_BISON_CXXSTD_14_snippet
|
||||
_BISON_CXXSTD_17_snippet
|
||||
_BISON_CXXSTD_2A_snippet
|
||||
])])
|
||||
|
||||
|
||||
m4_define([_BISON_CXXSTD_testbody],
|
||||
[m4_ifdef([$0($1)],
|
||||
[m4_indir([$0($1)], m4_shift2($@))],
|
||||
[m4_fatal([$0: unknown C++ standard: $1])])])
|
||||
|
||||
|
||||
# BISON_CXXSTD(STD)
|
||||
# -----------------
|
||||
# Check whether the C++ compiler support STD (11, 98, 2a, etc.).
|
||||
# If it does, AC_SUBST 'CXX<STD>_CXXFLAGS' to the corresponding flags.
|
||||
AC_DEFUN([BISON_CXXSTD],
|
||||
[AC_REQUIRE([AC_PROG_CXX])
|
||||
AC_LANG_PUSH([C++])
|
||||
for f in '-std=c++$1' '-std=c++$1 -stdlib=libc++'
|
||||
do
|
||||
BISON_CHECK_COMPILER_FLAG([$f],
|
||||
[AC_SUBST(m4_toupper([CXX$1_CXXFLAGS]), [$f]) break],
|
||||
[], [],
|
||||
[_BISON_CXXSTD_testbody($1)])
|
||||
done
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
@@ -50,14 +50,12 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
|
||||
AC_LANG_POP([C++])])
|
||||
|
||||
case $bison_cv_cxx_works in
|
||||
yes)
|
||||
BISON_CXX_WORKS=':';;
|
||||
no | cross)
|
||||
BISON_CXX_WORKS='exit 77';;
|
||||
yes) BISON_CXX_WORKS=':';;
|
||||
no | cross) BISON_CXX_WORKS='false';;
|
||||
esac
|
||||
|
||||
AC_SUBST([BISON_CXX_WORKS])
|
||||
AM_CONDITIONAL(BISON_CXX_WORKS, test $bison_cv_cxx_works = yes)
|
||||
AM_CONDITIONAL([ENABLE_CXX], [test $bison_cv_cxx_works = yes])
|
||||
])
|
||||
|
||||
# BISON_CXX_COMPILER_POSIXLY_CORRECT
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
# -*- Autoconf -*-
|
||||
# Checks required to run `timevar', a time tracker.
|
||||
#
|
||||
# Copyright (C) 2002-2003, 2009-2015, 2018 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/>.
|
||||
|
||||
# serial 2
|
||||
|
||||
AC_DEFUN([BISON_PREREQ_TIMEVAR],
|
||||
[AC_CHECK_HEADERS([sys/time.h sys/times.h])
|
||||
AC_CHECK_HEADERS([sys/resource.h],,,
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
])
|
||||
AC_CHECK_FUNCS([times])
|
||||
|
||||
AC_CHECK_DECLS([getrusage, times, clock, sysconf], [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#if HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_CHECK_TYPES([clock_t, struct tms], [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#if HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
])
|
||||
])
|
||||
+60
-85
@@ -168,10 +168,9 @@ AnnotationList__compute_conflicted_tokens (bitset shift_tokens,
|
||||
bitset conflicted_tokens = bitset_create (ntokens, BITSET_FIXED);
|
||||
bitset conflicted_tokens_rule = bitset_create (ntokens, BITSET_FIXED);
|
||||
bitset tokens = bitset_create (ntokens, BITSET_FIXED);
|
||||
int i;
|
||||
|
||||
bitset_copy (tokens, shift_tokens);
|
||||
for (i = 0; i < reds->num; ++i)
|
||||
for (int i = 0; i < reds->num; ++i)
|
||||
{
|
||||
bitset_and (conflicted_tokens_rule, tokens, reds->lookahead_tokens[i]);
|
||||
bitset_or (conflicted_tokens,
|
||||
@@ -215,20 +214,17 @@ AnnotationList__compute_lhs_contributions (state *s, rule *the_rule,
|
||||
}
|
||||
|
||||
static void
|
||||
AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
|
||||
bitsetv follow_kernel_items,
|
||||
bitsetv always_follows,
|
||||
state ***predecessors,
|
||||
bitset **item_lookahead_sets,
|
||||
AnnotationList
|
||||
**annotation_lists,
|
||||
AnnotationIndex
|
||||
*annotation_counts,
|
||||
struct obstack
|
||||
*annotations_obstackp)
|
||||
AnnotationList__computePredecessorAnnotations (
|
||||
AnnotationList *self, state *s,
|
||||
bitsetv follow_kernel_items,
|
||||
bitsetv always_follows,
|
||||
state ***predecessors,
|
||||
bitset **item_lookahead_sets,
|
||||
AnnotationList **annotation_lists,
|
||||
AnnotationIndex *annotation_counts,
|
||||
struct obstack *annotations_obstackp)
|
||||
{
|
||||
state **predecessor;
|
||||
for (predecessor = predecessors[s->number]; *predecessor; ++predecessor)
|
||||
for (state **predecessor = predecessors[s->number]; *predecessor; ++predecessor)
|
||||
{
|
||||
AnnotationList *annotation_node =
|
||||
AnnotationList__alloc_on_obstack (
|
||||
@@ -237,8 +233,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
|
||||
bool potential_contribution = false;
|
||||
bitset *lookaheads = NULL;
|
||||
{
|
||||
ContributionIndex ci;
|
||||
for (ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
|
||||
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
|
||||
{
|
||||
symbol_number contribution_token =
|
||||
InadequacyList__getContributionToken (self->inadequacyNode, ci)
|
||||
@@ -274,12 +269,12 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
|
||||
if (item_number_is_rule_number (ritem[s->items[self_item]
|
||||
- 2]))
|
||||
{
|
||||
Sbitset items;
|
||||
unsigned rulei;
|
||||
for (rulei = s->items[self_item];
|
||||
!item_number_is_rule_number (ritem[rulei]);
|
||||
++rulei)
|
||||
;
|
||||
continue;
|
||||
Sbitset items;
|
||||
if (AnnotationList__compute_lhs_contributions (
|
||||
*predecessor,
|
||||
&rules[item_number_as_rule_number (ritem[rulei])],
|
||||
@@ -334,10 +329,9 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
|
||||
potential_contribution = true;
|
||||
if (!lookaheads)
|
||||
{
|
||||
size_t j;
|
||||
lookaheads = xnmalloc ((*predecessor)->nitems,
|
||||
sizeof *lookaheads);
|
||||
for (j = 0; j < (*predecessor)->nitems; ++j)
|
||||
for (size_t j = 0; j < (*predecessor)->nitems; ++j)
|
||||
lookaheads[j] = NULL;
|
||||
}
|
||||
if (!lookaheads[i])
|
||||
@@ -377,8 +371,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
|
||||
annotation_node = NULL;
|
||||
}
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (*predecessor)->nitems; ++i)
|
||||
for (size_t i = 0; i < (*predecessor)->nitems; ++i)
|
||||
if (lookaheads[i])
|
||||
bitset_free (lookaheads[i]);
|
||||
free (lookaheads);
|
||||
@@ -416,23 +409,19 @@ AnnotationList__compute_from_inadequacies (
|
||||
struct obstack *annotations_obstackp,
|
||||
InadequacyListNodeCount *inadequacy_list_node_count)
|
||||
{
|
||||
bitsetv all_lookaheads;
|
||||
bitset shift_tokens;
|
||||
bitset conflicted_tokens;
|
||||
bitset_iterator biter_conflict;
|
||||
bitset_bindex conflicted_token;
|
||||
|
||||
/* Return an empty list if s->lookahead_tokens = NULL. */
|
||||
if (s->consistent)
|
||||
return;
|
||||
|
||||
all_lookaheads = bitsetv_create (s->nitems, ntokens, BITSET_FIXED);
|
||||
bitsetv all_lookaheads = bitsetv_create (s->nitems, ntokens, BITSET_FIXED);
|
||||
bitsetv_ones (all_lookaheads);
|
||||
shift_tokens = AnnotationList__compute_shift_tokens (s->transitions);
|
||||
conflicted_tokens =
|
||||
bitset shift_tokens = AnnotationList__compute_shift_tokens (s->transitions);
|
||||
bitset conflicted_tokens =
|
||||
AnnotationList__compute_conflicted_tokens (shift_tokens, s->reductions);
|
||||
|
||||
/* Add an inadequacy annotation for each conflicted_token. */
|
||||
bitset_iterator biter_conflict;
|
||||
bitset_bindex conflicted_token;
|
||||
BITSET_FOR_EACH (biter_conflict, conflicted_tokens, conflicted_token, 0)
|
||||
{
|
||||
AnnotationList *annotation_node;
|
||||
@@ -444,8 +433,7 @@ AnnotationList__compute_from_inadequacies (
|
||||
|
||||
/* Allocate the annotation node. */
|
||||
{
|
||||
int rule_i;
|
||||
for (rule_i = 0; rule_i < s->reductions->num; ++rule_i)
|
||||
for (int rule_i = 0; rule_i < s->reductions->num; ++rule_i)
|
||||
if (bitset_test (s->reductions->lookahead_tokens[rule_i],
|
||||
conflicted_token))
|
||||
++contribution_count;
|
||||
@@ -461,8 +449,7 @@ AnnotationList__compute_from_inadequacies (
|
||||
{
|
||||
ContributionIndex ci = 0;
|
||||
int item_i = 0;
|
||||
int rule_i;
|
||||
for (rule_i = 0; rule_i < s->reductions->num; ++rule_i)
|
||||
for (int rule_i = 0; rule_i < s->reductions->num; ++rule_i)
|
||||
{
|
||||
rule *the_rule = s->reductions->rules[rule_i];
|
||||
if (bitset_test (s->reductions->lookahead_tokens[rule_i],
|
||||
@@ -584,27 +571,20 @@ AnnotationList__debug (AnnotationList const *self, size_t nitems, int spaces)
|
||||
AnnotationIndex ai;
|
||||
for (a = self, ai = 0; a; a = a->next, ++ai)
|
||||
{
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < spaces; ++j)
|
||||
putc (' ', stderr);
|
||||
}
|
||||
for (int j = 0; j < spaces; ++j)
|
||||
putc (' ', stderr);
|
||||
fprintf (stderr, "Annotation %d (manifesting state %d):\n",
|
||||
ai, a->inadequacyNode->manifestingState->number);
|
||||
{
|
||||
ContributionIndex ci;
|
||||
bitset_bindex rulei = 0; /* init suppresses compiler warning */
|
||||
rulei = bitset_first (a->inadequacyNode->inadequacy.conflict.actions);
|
||||
for (ci = 0; ci < a->inadequacyNode->contributionCount; ++ci)
|
||||
bitset_bindex rulei
|
||||
= bitset_first (a->inadequacyNode->inadequacy.conflict.actions);
|
||||
for (ContributionIndex ci = 0; ci < a->inadequacyNode->contributionCount; ++ci)
|
||||
{
|
||||
symbol_number token =
|
||||
InadequacyList__getContributionToken (a->inadequacyNode, ci)
|
||||
->content->number;
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < spaces+2; ++j)
|
||||
putc (' ', stderr);
|
||||
}
|
||||
for (int j = 0; j < spaces+2; ++j)
|
||||
putc (' ', stderr);
|
||||
if (ci == InadequacyList__getShiftContributionIndex (
|
||||
a->inadequacyNode))
|
||||
fprintf (stderr, "Contributes shift of token %d.\n", token);
|
||||
@@ -639,20 +619,17 @@ AnnotationList__computeLookaheadFilter (AnnotationList const *self,
|
||||
{
|
||||
bitsetv_zero (lookahead_filter);
|
||||
for (; self; self = self->next)
|
||||
{
|
||||
ContributionIndex ci;
|
||||
for (ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
|
||||
if (!AnnotationList__isContributionAlways (self, ci))
|
||||
{
|
||||
Sbitset__Index item;
|
||||
Sbitset biter;
|
||||
symbol_number token =
|
||||
InadequacyList__getContributionToken (self->inadequacyNode, ci)
|
||||
->content->number;
|
||||
SBITSET__FOR_EACH (self->contributions[ci], nitems, biter, item)
|
||||
bitset_set (lookahead_filter[item], token);
|
||||
}
|
||||
}
|
||||
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
|
||||
if (!AnnotationList__isContributionAlways (self, ci))
|
||||
{
|
||||
symbol_number token =
|
||||
InadequacyList__getContributionToken (self->inadequacyNode, ci)
|
||||
->content->number;
|
||||
Sbitset__Index item;
|
||||
Sbitset biter;
|
||||
SBITSET__FOR_EACH (self->contributions[ci], nitems, biter, item)
|
||||
bitset_set (lookahead_filter[item], token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -699,11 +676,10 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
|
||||
size_t nitems, bitset *lookaheads,
|
||||
bool require_split_stable)
|
||||
{
|
||||
symbol *token;
|
||||
ContributionIndex const ci_shift =
|
||||
InadequacyList__getShiftContributionIndex (self->inadequacyNode);
|
||||
|
||||
token = self->inadequacyNode->inadequacy.conflict.token;
|
||||
symbol *token = self->inadequacyNode->inadequacy.conflict.token;
|
||||
|
||||
/* S/R conflict. */
|
||||
if (ci_shift != ContributionIndex__none)
|
||||
@@ -711,9 +687,6 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
|
||||
bool find_stable_domination_over_shift = false;
|
||||
bool find_stable_error_action_domination = false;
|
||||
{
|
||||
ContributionIndex ci;
|
||||
int actioni;
|
||||
ContributionIndex ci_rr_dominator = ContributionIndex__none;
|
||||
int shift_precedence = token->content->prec;
|
||||
|
||||
/* If the token has no precedence set, shift is always chosen. */
|
||||
@@ -723,11 +696,16 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
|
||||
/* Figure out which reductions contribute, which of those would
|
||||
dominate in a R/R comparison, and whether any reduction dominates
|
||||
the shift so that the R/R comparison is actually needed. */
|
||||
for (ci = 0, actioni = bitset_first (self->inadequacyNode->inadequacy
|
||||
.conflict.actions);
|
||||
ContributionIndex ci_rr_dominator = ContributionIndex__none;
|
||||
int actioni;
|
||||
ContributionIndex ci;
|
||||
for (ci = 0,
|
||||
actioni = bitset_first (self->inadequacyNode->inadequacy
|
||||
.conflict.actions);
|
||||
ci < self->inadequacyNode->contributionCount;
|
||||
++ci, actioni = bitset_next (self->inadequacyNode->inadequacy
|
||||
.conflict.actions, actioni+1))
|
||||
++ci,
|
||||
actioni = bitset_next (self->inadequacyNode->inadequacy
|
||||
.conflict.actions, actioni+1))
|
||||
{
|
||||
int reduce_precedence = 0;
|
||||
if (ci == ci_shift)
|
||||
@@ -796,17 +774,14 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
|
||||
|
||||
/* R/R conflict, so the reduction with the lowest rule number dominates.
|
||||
Fortunately, contributions are sorted by rule number. */
|
||||
{
|
||||
ContributionIndex ci;
|
||||
for (ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
|
||||
if (AnnotationList__stateMakesContribution (self, nitems, ci,
|
||||
lookaheads))
|
||||
{
|
||||
if (require_split_stable
|
||||
&& !AnnotationList__isContributionAlways (self, ci))
|
||||
return ContributionIndex__none;
|
||||
return ci;
|
||||
}
|
||||
}
|
||||
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
|
||||
if (AnnotationList__stateMakesContribution (self, nitems, ci,
|
||||
lookaheads))
|
||||
{
|
||||
if (require_split_stable
|
||||
&& !AnnotationList__isContributionAlways (self, ci))
|
||||
return ContributionIndex__none;
|
||||
return ci;
|
||||
}
|
||||
return ContributionIndex__none;
|
||||
}
|
||||
|
||||
@@ -89,10 +89,6 @@ static item_number *kernel_items;
|
||||
static void
|
||||
allocate_itemsets (void)
|
||||
{
|
||||
symbol_number i;
|
||||
rule_number r;
|
||||
item_number *rhsp;
|
||||
|
||||
/* Count the number of occurrences of all the symbols in RITEMS.
|
||||
Note that useless productions (hence useless nonterminals) are
|
||||
browsed too, hence we need to allocate room for _all_ the
|
||||
@@ -101,8 +97,8 @@ allocate_itemsets (void)
|
||||
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
||||
sizeof *symbol_count);
|
||||
|
||||
for (r = 0; r < nrules; ++r)
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||
for (rule_number r = 0; r < nrules; ++r)
|
||||
for (item_number *rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||
{
|
||||
count++;
|
||||
symbol_count[*rhsp]++;
|
||||
@@ -118,7 +114,7 @@ allocate_itemsets (void)
|
||||
kernel_items = xnmalloc (count, sizeof *kernel_items);
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < nsyms; i++)
|
||||
for (symbol_number i = 0; i < nsyms; i++)
|
||||
{
|
||||
kernel_base[i] = kernel_items + count;
|
||||
count += symbol_count[i];
|
||||
@@ -174,8 +170,6 @@ free_storage (void)
|
||||
static void
|
||||
new_itemsets (state *s)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering new_itemsets, state = %d\n", s->number);
|
||||
|
||||
@@ -183,7 +177,7 @@ new_itemsets (state *s)
|
||||
|
||||
nshifts = 0;
|
||||
|
||||
for (i = 0; i < nitemset; ++i)
|
||||
for (size_t i = 0; i < nitemset; ++i)
|
||||
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
||||
{
|
||||
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
||||
@@ -209,13 +203,11 @@ new_itemsets (state *s)
|
||||
static state *
|
||||
get_state (symbol_number sym, size_t core_size, item_number *core)
|
||||
{
|
||||
state *s;
|
||||
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
||||
sym, symbols[sym]->tag);
|
||||
|
||||
s = state_hash_lookup (core_size, core);
|
||||
state *s = state_hash_lookup (core_size, core);
|
||||
if (!s)
|
||||
s = state_list_append (sym, core_size, core);
|
||||
|
||||
@@ -235,25 +227,23 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
|
||||
static void
|
||||
append_states (state *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering append_states, state = %d\n", s->number);
|
||||
|
||||
/* First sort shift_symbol into increasing order. */
|
||||
|
||||
for (i = 1; i < nshifts; i++)
|
||||
for (int i = 1; i < nshifts; i++)
|
||||
{
|
||||
symbol_number sym = shift_symbol[i];
|
||||
int j;
|
||||
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
|
||||
const symbol_number sym = shift_symbol[i];
|
||||
int j = i;
|
||||
for (; 0 < j && sym < shift_symbol[j - 1]; j--)
|
||||
shift_symbol[j] = shift_symbol[j - 1];
|
||||
shift_symbol[j] = sym;
|
||||
}
|
||||
|
||||
for (i = 0; i < nshifts; i++)
|
||||
for (int i = 0; i < nshifts; i++)
|
||||
{
|
||||
symbol_number sym = shift_symbol[i];
|
||||
const symbol_number sym = shift_symbol[i];
|
||||
shiftset[i] = get_state (sym, kernel_size[sym], kernel_base[sym]);
|
||||
}
|
||||
}
|
||||
@@ -269,10 +259,9 @@ static void
|
||||
save_reductions (state *s)
|
||||
{
|
||||
int count = 0;
|
||||
size_t i;
|
||||
|
||||
/* Find and count the active items that represent ends of rules. */
|
||||
for (i = 0; i < nitemset; ++i)
|
||||
for (size_t i = 0; i < nitemset; ++i)
|
||||
{
|
||||
item_number item = ritem[itemset[i]];
|
||||
if (item_number_is_rule_number (item))
|
||||
@@ -334,17 +323,16 @@ set_states (void)
|
||||
void
|
||||
generate_states (void)
|
||||
{
|
||||
item_number initial_core = 0;
|
||||
state_list *list = NULL;
|
||||
allocate_storage ();
|
||||
new_closure (nritems);
|
||||
|
||||
/* Create the initial state. The 0 at the lhs is the index of the
|
||||
item of this initial rule. */
|
||||
item_number initial_core = 0;
|
||||
state_list_append (0, 1, &initial_core);
|
||||
|
||||
/* States are queued when they are created; process them all. */
|
||||
for (list = first_state; list; list = list->next)
|
||||
for (state_list *list = first_state; list; list = list->next)
|
||||
{
|
||||
state *s = list->state;
|
||||
if (trace_flag & trace_automaton)
|
||||
|
||||
+6
-11
@@ -83,7 +83,7 @@ static const char * const warnings_args[] =
|
||||
0
|
||||
};
|
||||
|
||||
static const int warnings_types[] =
|
||||
static const warnings warnings_types[] =
|
||||
{
|
||||
Wnone,
|
||||
Wmidrule_values,
|
||||
@@ -114,8 +114,7 @@ warning_argmatch (char const *arg, size_t no, size_t err)
|
||||
no = !no;
|
||||
}
|
||||
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
for (size_t b = 0; b < warnings_size; ++b)
|
||||
if (value & 1 << b)
|
||||
{
|
||||
if (err && no)
|
||||
@@ -176,8 +175,7 @@ complain_init (void)
|
||||
warnings warnings_default =
|
||||
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
for (size_t b = 0; b < warnings_size; ++b)
|
||||
{
|
||||
warnings_flag[b] = (1 << b & warnings_default
|
||||
? severity_warning
|
||||
@@ -204,8 +202,7 @@ warning_severity (warnings flags)
|
||||
{
|
||||
/* Diagnostics about warnings. */
|
||||
severity res = severity_disabled;
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
for (size_t b = 0; b < warnings_size; ++b)
|
||||
if (flags & 1 << b)
|
||||
{
|
||||
res = res < warnings_flag[b] ? warnings_flag[b] : res;
|
||||
@@ -225,8 +222,7 @@ warning_severity (warnings flags)
|
||||
bool
|
||||
warning_is_unset (warnings flags)
|
||||
{
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
for (size_t b = 0; b < warnings_size; ++b)
|
||||
if (flags & 1 << b && warnings_flag[b] != severity_unset)
|
||||
return false;
|
||||
return true;
|
||||
@@ -238,8 +234,7 @@ static void
|
||||
warnings_print_categories (warnings warn_flags, FILE *f)
|
||||
{
|
||||
/* Display only the first match, the second is "-Wall". */
|
||||
size_t i;
|
||||
for (i = 0; warnings_args[i]; ++i)
|
||||
for (size_t i = 0; warnings_args[i]; ++i)
|
||||
if (warn_flags & warnings_types[i])
|
||||
{
|
||||
severity s = warning_severity (warnings_types[i]);
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ static void
|
||||
compute_exts_from_src (const char *ext)
|
||||
{
|
||||
/* We use this function when the user specifies `-o' or `--output',
|
||||
so the extenions must be computed unconditionally from the file name
|
||||
so the extensions must be computed unconditionally from the file name
|
||||
given by this option. */
|
||||
src_extension = xstrdup (ext);
|
||||
header_extension = xstrdup (ext);
|
||||
|
||||
+26
-14
@@ -27,6 +27,32 @@
|
||||
+ (YY_FLEX_MINOR_VERSION) * 1000 \
|
||||
+ (YY_FLEX_SUBMINOR_VERSION))
|
||||
|
||||
// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC
|
||||
// 6.4.0 and 7.3.0).
|
||||
//
|
||||
// ./src/scan-skel.c: In function 'skel_restart':
|
||||
// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference]
|
||||
// b->yy_fill_buffer = 1;
|
||||
// ~~~~~~~~~~~~~~~~~~^~~
|
||||
// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference]
|
||||
// b->yy_input_file = file;
|
||||
// ~~~~~~~~~~~~~~~~~^~~~~~
|
||||
#if defined __GNUC__ && ! defined __clang__ && 6 <= __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wnull-dereference"
|
||||
#endif
|
||||
|
||||
// Old versions of Flex (2.5.35) generate an incomplete documentation comment.
|
||||
//
|
||||
// In file included from src/scan-code-c.c:3:
|
||||
// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command
|
||||
// [-Werror,-Wdocumentation]
|
||||
// * @param line_number
|
||||
// ~~~~~~~~~~~~~~~~~^
|
||||
// 1 error generated.
|
||||
#if FLEX_VERSION <= 20060000 && defined __clang__
|
||||
# pragma clang diagnostic ignored "-Wdocumentation"
|
||||
#endif
|
||||
|
||||
/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
|
||||
#if FLEX_VERSION <= 2005031
|
||||
int FLEX_PREFIX (get_lineno) (void);
|
||||
@@ -44,20 +70,6 @@ int FLEX_PREFIX (lex_destroy) (void);
|
||||
|
||||
#define last_string FLEX_PREFIX (last_string)
|
||||
|
||||
// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC
|
||||
// 7.3.0).
|
||||
//
|
||||
// ./src/scan-skel.c: In function 'skel_restart':
|
||||
// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference]
|
||||
// b->yy_fill_buffer = 1;
|
||||
// ~~~~~~~~~~~~~~~~~~^~~
|
||||
// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference]
|
||||
// b->yy_input_file = file;
|
||||
// ~~~~~~~~~~~~~~~~~^~~~~~
|
||||
#if defined __GNUC__ && 7 <= __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wnull-dereference"
|
||||
#endif
|
||||
|
||||
/* It seems to be a nice "feature" of Flex that one cannot use yytext,
|
||||
yyleng etc. when a prefix is given, since there is no longer a
|
||||
#define, but rather the token is actually changed in the output.
|
||||
|
||||
+9
-6
@@ -51,8 +51,9 @@ int report_flag = report_none;
|
||||
int trace_flag = trace_none;
|
||||
|
||||
static struct bison_language const valid_languages[] = {
|
||||
{ "c", "c-skel.m4", ".c", ".h", true },
|
||||
{ "c++", "c++-skel.m4", ".cc", ".hh", true },
|
||||
/* lang, skeleton, ext, hdr, add_tab */
|
||||
{ "c", "c-skel.m4", ".c", ".h", true },
|
||||
{ "c++", "c++-skel.m4", ".cc", ".hh", true },
|
||||
{ "java", "java-skel.m4", ".java", ".java", false },
|
||||
{ "", "", "", "", false }
|
||||
};
|
||||
@@ -127,7 +128,7 @@ flags_argmatch (const char *opt,
|
||||
|
||||
/** Decode a set of sub arguments.
|
||||
*
|
||||
* \param FlagName the flag familly to update.
|
||||
* \param FlagName the flag family to update.
|
||||
* \param Args the effective sub arguments to decode.
|
||||
* \param All the "all" value.
|
||||
*
|
||||
@@ -360,6 +361,8 @@ FEATURE is a list of comma separated words that can include:\n\
|
||||
fputs (_("General help using GNU software: "
|
||||
"<http://www.gnu.org/gethelp/>.\n"),
|
||||
stdout);
|
||||
|
||||
#if (defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__
|
||||
/* Don't output this redundant message for English locales.
|
||||
Note we still output for 'C' so that it gets included in the
|
||||
man page. */
|
||||
@@ -372,6 +375,7 @@ FEATURE is a list of comma separated words that can include:\n\
|
||||
email address. */
|
||||
fputs (_("Report translation bugs to "
|
||||
"<http://translationproject.org/team/>.\n"), stdout);
|
||||
#endif
|
||||
fputs (_("For complete documentation, run: info bison.\n"), stdout);
|
||||
}
|
||||
|
||||
@@ -429,8 +433,7 @@ language_argmatch (char const *arg, int prio, location loc)
|
||||
|
||||
if (prio < language_prio)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; valid_languages[i].language[0]; i++)
|
||||
for (int i = 0; valid_languages[i].language[0]; ++i)
|
||||
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
||||
{
|
||||
language_prio = prio;
|
||||
@@ -721,7 +724,7 @@ getargs (int argc, char *argv[])
|
||||
if (argc - optind != 1)
|
||||
{
|
||||
if (argc - optind < 1)
|
||||
error (0, 0, _("%s: missing operand"), quotearg_colon (argv[argc - 1]));
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
+25
-39
@@ -46,6 +46,8 @@ symbol_number *token_translations = NULL;
|
||||
|
||||
int max_user_token_number = 256;
|
||||
|
||||
int required_version = 0;
|
||||
|
||||
bool
|
||||
rule_useful_in_grammar_p (rule const *r)
|
||||
{
|
||||
@@ -84,8 +86,7 @@ size_t
|
||||
rule_rhs_length (rule const *r)
|
||||
{
|
||||
size_t res = 0;
|
||||
item_number *rhsp;
|
||||
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
||||
for (item_number *rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
||||
++res;
|
||||
return res;
|
||||
}
|
||||
@@ -94,11 +95,8 @@ void
|
||||
rule_rhs_print (rule const *r, FILE *out)
|
||||
{
|
||||
if (0 <= *r->rhs)
|
||||
{
|
||||
item_number *rp;
|
||||
for (rp = r->rhs; *rp >= 0; rp++)
|
||||
fprintf (out, " %s", symbols[*rp]->tag);
|
||||
}
|
||||
for (item_number *rp = r->rhs; *rp >= 0; rp++)
|
||||
fprintf (out, " %s", symbols[*rp]->tag);
|
||||
else
|
||||
fputs (" %empty", out);
|
||||
}
|
||||
@@ -108,9 +106,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
||||
{
|
||||
if (*r->rhs >= 0)
|
||||
{
|
||||
item_number *rp;
|
||||
xml_puts (out, level, "<rhs>");
|
||||
for (rp = r->rhs; *rp >= 0; rp++)
|
||||
for (item_number *rp = r->rhs; *rp >= 0; rp++)
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[*rp]->tag));
|
||||
xml_puts (out, level, "</rhs>");
|
||||
@@ -126,9 +123,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
||||
void
|
||||
ritem_print (FILE *out)
|
||||
{
|
||||
unsigned i;
|
||||
fputs ("RITEM\n", out);
|
||||
for (i = 0; i < nritems; ++i)
|
||||
for (unsigned i = 0; i < nritems; ++i)
|
||||
if (ritem[i] >= 0)
|
||||
fprintf (out, " %s", symbols[ritem[i]]->tag);
|
||||
else
|
||||
@@ -140,9 +136,7 @@ size_t
|
||||
ritem_longest_rhs (void)
|
||||
{
|
||||
int max = 0;
|
||||
rule_number r;
|
||||
|
||||
for (r = 0; r < nrules; ++r)
|
||||
for (rule_number r = 0; r < nrules; ++r)
|
||||
{
|
||||
int length = rule_rhs_length (&rules[r]);
|
||||
if (length > max)
|
||||
@@ -156,12 +150,11 @@ void
|
||||
grammar_rules_partial_print (FILE *out, const char *title,
|
||||
rule_filter filter)
|
||||
{
|
||||
rule_number r;
|
||||
bool first = true;
|
||||
sym_content *previous_lhs = NULL;
|
||||
|
||||
/* rule # : LHS -> RHS */
|
||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
if (filter && !filter (&rules[r]))
|
||||
continue;
|
||||
@@ -188,10 +181,9 @@ grammar_rules_print (FILE *out)
|
||||
void
|
||||
grammar_rules_print_xml (FILE *out, int level)
|
||||
{
|
||||
rule_number r;
|
||||
bool first = true;
|
||||
|
||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
if (first)
|
||||
xml_puts (out, level + 1, "<rules>");
|
||||
@@ -233,10 +225,9 @@ grammar_dump (FILE *out, const char *title)
|
||||
|
||||
fprintf (out, "Variables\n---------\n\n");
|
||||
{
|
||||
symbol_number i;
|
||||
fprintf (out, "Value Sprec Sassoc Tag\n");
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
for (symbol_number i = ntokens; i < nsyms; i++)
|
||||
fprintf (out, "%5d %5d %5d %s\n",
|
||||
i,
|
||||
symbols[i]->content->prec, symbols[i]->content->assoc,
|
||||
@@ -246,18 +237,16 @@ grammar_dump (FILE *out, const char *title)
|
||||
|
||||
fprintf (out, "Rules\n-----\n\n");
|
||||
{
|
||||
rule_number i;
|
||||
fprintf (out,
|
||||
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
|
||||
" -> Rhs (Ritem range) [Num]\n");
|
||||
for (i = 0; i < nrules + nuseless_productions; i++)
|
||||
for (rule_number i = 0; i < nrules + nuseless_productions; i++)
|
||||
{
|
||||
rule const *rule_i = &rules[i];
|
||||
item_number *rp = NULL;
|
||||
unsigned rhs_itemno = rule_i->rhs - ritem;
|
||||
unsigned rhs_count = 0;
|
||||
unsigned const rhs_itemno = rule_i->rhs - ritem;
|
||||
/* Find the last RHS index in ritems. */
|
||||
for (rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
unsigned rhs_count = 0;
|
||||
for (item_number *rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
++rhs_count;
|
||||
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
||||
i,
|
||||
@@ -268,31 +257,28 @@ grammar_dump (FILE *out, const char *title)
|
||||
rhs_itemno + rhs_count - 1,
|
||||
rule_i->lhs->number);
|
||||
/* Dumped the RHS. */
|
||||
for (rp = rule_i->rhs; *rp >= 0; rp++)
|
||||
for (item_number *rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
fprintf (out, " %3d", *rp);
|
||||
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
|
||||
fprintf (out, " [%d]\n",
|
||||
item_number_as_rule_number (rule_i->rhs[rhs_count+1]));
|
||||
}
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
|
||||
fprintf (out, "Rules interpreted\n-----------------\n\n");
|
||||
{
|
||||
rule_number r;
|
||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
fprintf (out, "%-5d %s:", r, rules[r].lhs->symbol->tag);
|
||||
rule_rhs_print (&rules[r], out);
|
||||
fprintf (out, "\n");
|
||||
}
|
||||
}
|
||||
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
fprintf (out, "%-5d %s:", r, rules[r].lhs->symbol->tag);
|
||||
rule_rhs_print (&rules[r], out);
|
||||
fprintf (out, "\n");
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
}
|
||||
|
||||
void
|
||||
grammar_rules_useless_report (const char *message)
|
||||
{
|
||||
rule_number r;
|
||||
for (r = 0; r < nrules ; ++r)
|
||||
for (rule_number r = 0; r < nrules ; ++r)
|
||||
/* Don't complain about rules whose LHS is useless, we already
|
||||
complained about it. */
|
||||
if (!reduce_nonterminal_useless_in_grammar (rules[r].lhs)
|
||||
|
||||
@@ -271,4 +271,8 @@ void grammar_rules_useless_report (const char *message);
|
||||
/* Free the packed grammar. */
|
||||
void grammar_free (void);
|
||||
|
||||
/* The version %required by the grammar file, as an int (100 * major +
|
||||
minor). 0 if unspecified. */
|
||||
extern int required_version;
|
||||
|
||||
#endif /* !GRAM_H_ */
|
||||
|
||||
+31
-36
@@ -87,12 +87,14 @@ escape (char const *name)
|
||||
static void
|
||||
no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
|
||||
{
|
||||
int n;
|
||||
*no_reduce_set = bitset_create (ntokens, BITSET_FIXED);
|
||||
bitset_zero (*no_reduce_set);
|
||||
FOR_EACH_SHIFT (s->transitions, n)
|
||||
bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n));
|
||||
for (n = 0; n < s->errs->num; ++n)
|
||||
{
|
||||
int n;
|
||||
FOR_EACH_SHIFT (s->transitions, n)
|
||||
bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n));
|
||||
}
|
||||
for (int n = 0; n < s->errs->num; ++n)
|
||||
if (s->errs->symbols[n])
|
||||
bitset_set (*no_reduce_set, s->errs->symbols[n]->content->number);
|
||||
}
|
||||
@@ -145,11 +147,9 @@ conclude_red (struct obstack *out, int source, rule_number ruleno,
|
||||
static bool
|
||||
print_token (struct obstack *out, bool first, char const *tok)
|
||||
{
|
||||
char const *q = escape (tok);
|
||||
|
||||
if (! first)
|
||||
obstack_sgrow (out, ", ");
|
||||
obstack_sgrow (out, q);
|
||||
obstack_sgrow (out, escape (tok));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,8 +157,7 @@ void
|
||||
output_red (state const *s, reductions const *reds, FILE *fout)
|
||||
{
|
||||
bitset no_reduce_set;
|
||||
int j;
|
||||
int source = s->number;
|
||||
no_reduce_bitset_init (s, &no_reduce_set);
|
||||
|
||||
/* Two obstacks are needed: one for the enabled reductions, and one
|
||||
for the disabled reductions, because in the end we want two
|
||||
@@ -166,42 +165,38 @@ output_red (state const *s, reductions const *reds, FILE *fout)
|
||||
be printed. */
|
||||
struct obstack dout;
|
||||
struct obstack eout;
|
||||
|
||||
no_reduce_bitset_init (s, &no_reduce_set);
|
||||
obstack_init (&dout);
|
||||
obstack_init (&eout);
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
const int source = s->number;
|
||||
for (int j = 0; j < reds->num; ++j)
|
||||
{
|
||||
bool defaulted = false;
|
||||
rule *default_reduction =
|
||||
yydefact[s->number]
|
||||
? &rules[yydefact[s->number] - 1]
|
||||
: NULL;
|
||||
|
||||
bool defaulted = default_reduction && default_reduction == reds->rules[j];
|
||||
|
||||
/* Build the lookahead tokens lists, one for enabled transitions
|
||||
and one for disabled transitions. */
|
||||
bool firstd = true;
|
||||
bool firste = true;
|
||||
rule_number ruleno = reds->rules[j]->number;
|
||||
rule *default_reduction = NULL;
|
||||
|
||||
if (yydefact[s->number] != 0)
|
||||
default_reduction = &rules[yydefact[s->number] - 1];
|
||||
|
||||
/* Build the lookahead tokens lists, one for enabled transitions and one
|
||||
for disabled transistions. */
|
||||
if (default_reduction && default_reduction == reds->rules[j])
|
||||
defaulted = true;
|
||||
if (reds->lookahead_tokens)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (bitset_test (no_reduce_set, i))
|
||||
firstd = print_token (&dout, firstd, symbols[i]->tag);
|
||||
else
|
||||
{
|
||||
if (! defaulted)
|
||||
firste = print_token (&eout, firste, symbols[i]->tag);
|
||||
bitset_set (no_reduce_set, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ntokens; i++)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (bitset_test (no_reduce_set, i))
|
||||
firstd = print_token (&dout, firstd, symbols[i]->tag);
|
||||
else
|
||||
{
|
||||
if (! defaulted)
|
||||
firste = print_token (&eout, firste, symbols[i]->tag);
|
||||
bitset_set (no_reduce_set, i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Do the actual output. */
|
||||
conclude_red (&dout, source, ruleno, false, firstd, fout);
|
||||
|
||||
+14
-14
@@ -929,7 +929,7 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows,
|
||||
* compatibility or, if <tt>annotation_lists = NULL</tt>, the canonical
|
||||
* LR(1) state compatibility test was used.
|
||||
* - If <tt>annotation_lists = NULL</tt>, reduction lookahead sets were
|
||||
* computed in all states. TV_IELR_PHASE4 was pushed while they were
|
||||
* computed in all states. tv_ielr_phase4 was pushed while they were
|
||||
* computed from item lookahead sets.
|
||||
*/
|
||||
static void
|
||||
@@ -1004,7 +1004,7 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows,
|
||||
lookahead sets. */
|
||||
if (!annotation_lists)
|
||||
{
|
||||
timevar_push (TV_IELR_PHASE4);
|
||||
timevar_push (tv_ielr_phase4);
|
||||
initialize_LA ();
|
||||
for (state_list *node = first_state; node; node = node->next)
|
||||
if (!node->state->consistent)
|
||||
@@ -1037,7 +1037,7 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows,
|
||||
}
|
||||
}
|
||||
}
|
||||
timevar_pop (TV_IELR_PHASE4);
|
||||
timevar_pop (tv_ielr_phase4);
|
||||
}
|
||||
|
||||
/* Free state list. */
|
||||
@@ -1080,7 +1080,7 @@ ielr (void)
|
||||
}
|
||||
|
||||
/* Phase 0: LALR(1). */
|
||||
timevar_push (TV_LALR);
|
||||
timevar_push (tv_lalr);
|
||||
if (lr_type == LR_TYPE__CANONICAL_LR)
|
||||
set_goto_map ();
|
||||
else
|
||||
@@ -1088,10 +1088,10 @@ ielr (void)
|
||||
if (lr_type == LR_TYPE__LALR)
|
||||
{
|
||||
bitsetv_free (goto_follows);
|
||||
timevar_pop (TV_LALR);
|
||||
timevar_pop (tv_lalr);
|
||||
return;
|
||||
}
|
||||
timevar_pop (TV_LALR);
|
||||
timevar_pop (tv_lalr);
|
||||
|
||||
{
|
||||
bitsetv follow_kernel_items;
|
||||
@@ -1104,14 +1104,14 @@ ielr (void)
|
||||
{
|
||||
/* Phase 1: Compute Auxiliary Tables. */
|
||||
state ***predecessors;
|
||||
timevar_push (TV_IELR_PHASE1);
|
||||
timevar_push (tv_ielr_phase1);
|
||||
ielr_compute_auxiliary_tables (
|
||||
&follow_kernel_items, &always_follows,
|
||||
lr_type == LR_TYPE__CANONICAL_LR ? NULL : &predecessors);
|
||||
timevar_pop (TV_IELR_PHASE1);
|
||||
timevar_pop (tv_ielr_phase1);
|
||||
|
||||
/* Phase 2: Compute Annotations. */
|
||||
timevar_push (TV_IELR_PHASE2);
|
||||
timevar_push (tv_ielr_phase2);
|
||||
if (lr_type != LR_TYPE__CANONICAL_LR)
|
||||
{
|
||||
obstack_init (&annotations_obstack);
|
||||
@@ -1125,11 +1125,11 @@ ielr (void)
|
||||
bitsetv_free (goto_follows);
|
||||
lalr_free ();
|
||||
}
|
||||
timevar_pop (TV_IELR_PHASE2);
|
||||
timevar_pop (tv_ielr_phase2);
|
||||
}
|
||||
|
||||
/* Phase 3: Split States. */
|
||||
timevar_push (TV_IELR_PHASE3);
|
||||
timevar_push (tv_ielr_phase3);
|
||||
{
|
||||
state_number nstates_lr0 = nstates;
|
||||
ielr_split_states (follow_kernel_items, always_follows,
|
||||
@@ -1144,11 +1144,11 @@ ielr (void)
|
||||
free (annotation_lists);
|
||||
bitsetv_free (follow_kernel_items);
|
||||
bitsetv_free (always_follows);
|
||||
timevar_pop (TV_IELR_PHASE3);
|
||||
timevar_pop (tv_ielr_phase3);
|
||||
}
|
||||
|
||||
/* Phase 4: Compute Reduction Lookaheads. */
|
||||
timevar_push (TV_IELR_PHASE4);
|
||||
timevar_push (tv_ielr_phase4);
|
||||
free (goto_map);
|
||||
free (from_state);
|
||||
free (to_state);
|
||||
@@ -1163,5 +1163,5 @@ ielr (void)
|
||||
lalr ();
|
||||
bitsetv_free (goto_follows);
|
||||
}
|
||||
timevar_pop (TV_IELR_PHASE4);
|
||||
timevar_pop (tv_ielr_phase4);
|
||||
}
|
||||
|
||||
+33
-17
@@ -1,19 +1,17 @@
|
||||
# Copyright (C) 2001-2015, 2018 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/>.
|
||||
|
||||
LDADD = lib/libbison.a $(LIBINTL)
|
||||
## Copyright (C) 2001-2015, 2018 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/>.
|
||||
|
||||
bin_PROGRAMS = src/bison
|
||||
# Prettify Automake-computed names of compiled objects.
|
||||
@@ -106,16 +104,34 @@ BUILT_SOURCES += \
|
||||
src/scan-gram.c \
|
||||
src/scan-skel.c
|
||||
|
||||
# Although conceptually most of these guys would make more sense in the
|
||||
# definition of libbison, beware that they might expand as flags such as
|
||||
# `-lm`. Keep them here. Or use a Libtool convenience library.
|
||||
src_bison_LDADD = \
|
||||
$(ISNAND_LIBM) \
|
||||
$(ISNANF_LIBM) \
|
||||
$(ISNANL_LIBM) \
|
||||
$(LDEXPL_LIBM) \
|
||||
$(LDEXP_LIBM) \
|
||||
$(LIBINTL) \
|
||||
$(LIBTHREAD) \
|
||||
$(LIB_CLOCK_GETTIME) \
|
||||
$(LIB_GETHRXTIME) \
|
||||
lib/libbison.a
|
||||
|
||||
|
||||
|
||||
|
||||
## ------ ##
|
||||
## yacc. ##
|
||||
## ------ ##
|
||||
|
||||
if ENABLE_YACC
|
||||
bin_SCRIPTS = src/yacc
|
||||
bin_SCRIPTS = src/yacc
|
||||
endif
|
||||
EXTRA_SCRIPTS = src/yacc
|
||||
MOSTLYCLEANFILES += src/yacc
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
src/yacc:
|
||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ location_print (location loc, FILE *out)
|
||||
}
|
||||
|
||||
|
||||
/* Persistant data used by location_caret to avoid reopening and rereading the
|
||||
/* Persistent data used by location_caret to avoid reopening and rereading the
|
||||
same file all over for each error. */
|
||||
struct caret_info
|
||||
{
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ void location_compute (location *loc,
|
||||
Warning: uses quotearg's slot 3. */
|
||||
unsigned location_print (location loc, FILE *out);
|
||||
|
||||
/* Free any allocated ressources and close any open file handles that are
|
||||
/* Free any allocated resources and close any open file handles that are
|
||||
left-over by the usage of location_caret. */
|
||||
void cleanup_caret (void);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user