mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-14 05:05:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.1.90
|
||||||
|
|||||||
+293
@@ -0,0 +1,293 @@
|
|||||||
|
# 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:
|
||||||
|
## ----- ##
|
||||||
|
## 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 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: "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 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: "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++'
|
||||||
|
|
||||||
|
## ----- ##
|
||||||
|
## ICC. ##
|
||||||
|
## ----- ##
|
||||||
|
- 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='
|
||||||
|
|
||||||
|
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]>
|
2009-02-25 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
Copyright years.
|
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]>
|
2009-02-25 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
Style changes.
|
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.
|
location_type, not yy::location.
|
||||||
|
|
||||||
2009-02-25 Akim Demaille <[email protected]>
|
2009-02-25 Akim Demaille <[email protected]>
|
||||||
@@ -3702,7 +3702,7 @@
|
|||||||
Remove trailing blanks.
|
Remove trailing blanks.
|
||||||
The epilogue has its own ending \n, no need to add another.
|
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.
|
epilogue.
|
||||||
* data/glr.cc: dnl when extending the epilogue.
|
* data/glr.cc: dnl when extending the epilogue.
|
||||||
Remove stray "private:".
|
Remove stray "private:".
|
||||||
@@ -3764,7 +3764,7 @@
|
|||||||
2008-12-11 Akim Demaille <[email protected]>
|
2008-12-11 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
Pass the token type to yysyntax_error.
|
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.
|
of the raw number.
|
||||||
Adjust callers.
|
Adjust callers.
|
||||||
* TODO: Update.
|
* TODO: Update.
|
||||||
@@ -5019,7 +5019,7 @@
|
|||||||
|
|
||||||
Now instead of monolithic tables, we define one macro per cell. For
|
Now instead of monolithic tables, we define one macro per cell. For
|
||||||
instance "b4_symbol(0, tag)" is a macro name which contents is
|
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.
|
these cells.
|
||||||
|
|
||||||
* src/output.c (type_names_output): Remove.
|
* src/output.c (type_names_output): Remove.
|
||||||
@@ -5200,7 +5200,7 @@
|
|||||||
|
|
||||||
2008-11-09 Akim Demaille <[email protected]>
|
2008-11-09 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
Agregate yylval and yylloc.
|
Aggregate yylval and yylloc.
|
||||||
* data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
|
* data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
|
||||||
(parser::yyla): this.
|
(parser::yyla): this.
|
||||||
|
|
||||||
@@ -5815,7 +5815,7 @@
|
|||||||
of members. Document that token names are added as fields.
|
of members. Document that token names are added as fields.
|
||||||
Document constructors accurately. Remove error method.
|
Document constructors accurately. Remove error method.
|
||||||
(Java Scanner Interface): Move note on %pure-parser to Java Bison
|
(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.
|
Remove documentation that does not match the code.
|
||||||
(Java Action Features): New.
|
(Java Action Features): New.
|
||||||
(Java Differences): Add reference. Add item on semantic values.
|
(Java Differences): Add reference. Add item on semantic values.
|
||||||
@@ -6432,7 +6432,7 @@
|
|||||||
* djgpp/config.site: Copyright timestamp adjusted.
|
* djgpp/config.site: Copyright timestamp adjusted.
|
||||||
* djgpp/config_h.sed: Copyright timestamp adjusted.
|
* djgpp/config_h.sed: Copyright timestamp adjusted.
|
||||||
* djgpp/djunpack.bat: 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.
|
filename translation list.
|
||||||
* djgpp/subpipe.c (init_subpipe): Check the environment variables
|
* djgpp/subpipe.c (init_subpipe): Check the environment variables
|
||||||
TMPDIR, TMP and TEMP, in that order, to determinate where the temp
|
TMPDIR, TMP and TEMP, in that order, to determinate where the temp
|
||||||
@@ -7588,7 +7588,7 @@
|
|||||||
2007-03-07 Juan Manuel Guerrero <[email protected]>
|
2007-03-07 Juan Manuel Guerrero <[email protected]>
|
||||||
|
|
||||||
DJGPP spefic issue. Inhibit the use of disallowed characters for
|
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.
|
and concern testsuite case 46.
|
||||||
* Makefile.am: djgpp/testsuite.sed added to EXTRA_DIST
|
* Makefile.am: djgpp/testsuite.sed added to EXTRA_DIST
|
||||||
* djgpp/testsuite.sed: Inhibit the use of disallowed characters.
|
* djgpp/testsuite.sed: Inhibit the use of disallowed characters.
|
||||||
@@ -8796,7 +8796,7 @@
|
|||||||
2006-12-13 Paul Eggert <[email protected]>
|
2006-12-13 Paul Eggert <[email protected]>
|
||||||
|
|
||||||
* TODO: Add pointer to Sylvain Schmitz's work on static detection
|
* 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]>
|
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,
|
* src/scan-gram.l (<SC_BRACED_CODE>): Use val->code for BRACED_CODE,
|
||||||
which is "{...}" in the parser.
|
which is "{...}" in the parser.
|
||||||
* tests/Makefile.am (maintainer-check-valgrind): Set
|
* 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.
|
Valgrind.
|
||||||
* tests/calc.at (_AT_DATA_CALC_Y): fclose the FILE* so Valgrind doesn't
|
* tests/calc.at (_AT_DATA_CALC_Y): fclose the FILE* so Valgrind doesn't
|
||||||
complain.
|
complain.
|
||||||
@@ -12349,7 +12349,7 @@
|
|||||||
* data/lalr1.cc: here.
|
* data/lalr1.cc: here.
|
||||||
(location.hh): Include it after the user prologue, in case the
|
(location.hh): Include it after the user prologue, in case the
|
||||||
filename type is defined by the user.
|
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_): Rename as...
|
||||||
(yyresult): this, it's a local variable, not an attribute.
|
(yyresult): this, it's a local variable, not an attribute.
|
||||||
* data/Makefile.am (dist_pkgdata_DATA): Adjust.
|
* data/Makefile.am (dist_pkgdata_DATA): Adjust.
|
||||||
@@ -12439,8 +12439,8 @@
|
|||||||
(Table of Symbols): Under YYSTACK_USE_ALLOCA, Don't claim that the
|
(Table of Symbols): Under YYSTACK_USE_ALLOCA, Don't claim that the
|
||||||
user must declare alloca.
|
user must declare alloca.
|
||||||
|
|
||||||
* HACKING (release): Forwarn the Translation Project about
|
* HACKING (release): Forewarn the Translation Project about
|
||||||
stable releses.
|
stable releases.
|
||||||
|
|
||||||
2005-09-20 Akim Demaille <[email protected]>
|
2005-09-20 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
@@ -13165,7 +13165,7 @@
|
|||||||
not GNU M4, and that it works with any POSIX-compatible Awk.
|
not GNU M4, and that it works with any POSIX-compatible Awk.
|
||||||
* examples/calc++/Makefile.am (run_extexi): Remove; not used.
|
* examples/calc++/Makefile.am (run_extexi): Remove; not used.
|
||||||
($(calc_extracted)): Renamed from $(calc_sources_extracted),
|
($(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.
|
Use $(AWK), not gawk, since any conforming Awk will do.
|
||||||
Put comment before action, since older 'make' can't handle comment
|
Put comment before action, since older 'make' can't handle comment
|
||||||
in action.
|
in action.
|
||||||
@@ -13993,7 +13993,7 @@
|
|||||||
* src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc,
|
* src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc,
|
||||||
to allocate kernel_base, kernel_items, kernel_size, since
|
to allocate kernel_base, kernel_items, kernel_size, since
|
||||||
they needn't be initialized to 0.
|
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/closure.c (new_closure): Likewise, for itemset.
|
||||||
* src/derives.c (derives_compute): Likewise, for delts, derives, q.
|
* src/derives.c (derives_compute): Likewise, for delts, derives, q.
|
||||||
* src/lalr.c (set_goto_map): Likewise, for temp_map.
|
* src/lalr.c (set_goto_map): Likewise, for temp_map.
|
||||||
@@ -14181,7 +14181,7 @@
|
|||||||
2004-10-05 Akim Demaille <[email protected]>
|
2004-10-05 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
In Bison 1.875's yacc.c, YYLLOC_DEFAULT was called regardless
|
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.
|
improve the use of YYLLOC_DEFAULT in such a case.
|
||||||
lalr1.cc is still experimental, so changing this is acceptable.
|
lalr1.cc is still experimental, so changing this is acceptable.
|
||||||
And finally, there are probably not many users who changed the
|
And finally, there are probably not many users who changed the
|
||||||
@@ -16524,7 +16524,7 @@
|
|||||||
(struct state): Renamed from struct state_s.
|
(struct state): Renamed from struct state_s.
|
||||||
(state): Renamed from state_t.
|
(state): Renamed from state_t.
|
||||||
(transitions): Renamed from transitions_t. Unused (and
|
(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.
|
(errs): Renamed from errs_t. Unused errs_s tag removed.
|
||||||
(reductions): Renamed from reductions_t. Unused tag
|
(reductions): Renamed from reductions_t. Unused tag
|
||||||
reductions_s removed.
|
reductions_s removed.
|
||||||
@@ -16612,9 +16612,9 @@
|
|||||||
|
|
||||||
|
|
||||||
Fix misspelling in names.
|
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
|
* src/vcg_defaults.h (G_NODE_ALIGNMENT): Renamed from
|
||||||
G_NODE_ALIGNEMENT.
|
G_NODE_ALIGNMENT.
|
||||||
|
|
||||||
|
|
||||||
* lib/timevar.c (timevar_report): Renamed from time_report,
|
* lib/timevar.c (timevar_report): Renamed from time_report,
|
||||||
@@ -16866,7 +16866,7 @@
|
|||||||
* src/tables.c (conflict_row, pack_vector): Likewise.
|
* src/tables.c (conflict_row, pack_vector): Likewise.
|
||||||
* src/vcg.c (get_color_str, get_textmode_str, get_shape_str,
|
* src/vcg.c (get_color_str, get_textmode_str, get_shape_str,
|
||||||
get_layoutalgorithm_str, get_decision_str, get_orientation_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.
|
get_view_str, get_linestyle_str, get_arrowstyle_str): Likewise.
|
||||||
|
|
||||||
* lib/argmatch.h (ARRAY_CARDINALITY): Do not bother to #undef.
|
* lib/argmatch.h (ARRAY_CARDINALITY): Do not bother to #undef.
|
||||||
@@ -17365,7 +17365,7 @@
|
|||||||
(scanner_last_string_free): Remove; not used.
|
(scanner_last_string_free): Remove; not used.
|
||||||
(percent_percent_count): Move decl to just before use.
|
(percent_percent_count): Move decl to just before use.
|
||||||
(SC_ESCAPED_CHARACTER): Return ID at unexpected end of file,
|
(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]>
|
2002-11-07 Akim Demaille <[email protected]>
|
||||||
|
|
||||||
@@ -18052,7 +18052,7 @@
|
|||||||
suite using a GLR parser driven by LALR tables. It fails with -O2
|
suite using a GLR parser driven by LALR tables. It fails with -O2
|
||||||
because `struct stat' gives two different answers on my machine:
|
because `struct stat' gives two different answers on my machine:
|
||||||
88 (definition of an auto var) and later 96 (memset on this var).
|
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
|
blame: if I move the awk.h inclusion before GLR's system header
|
||||||
inclusion, the two struct stat have the same size.
|
inclusion, the two struct stat have the same size.
|
||||||
|
|
||||||
@@ -18962,7 +18962,7 @@
|
|||||||
|
|
||||||
2002-07-16 Akim Demaille <[email protected]>
|
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.
|
Adjust all former `associativity' dependencies.
|
||||||
* src/symtab.c (symbol_new): Default associativity is `undef', not
|
* src/symtab.c (symbol_new): Default associativity is `undef', not
|
||||||
`right'.
|
`right'.
|
||||||
@@ -20105,7 +20105,7 @@
|
|||||||
|
|
||||||
* data/bison.c++: Catch up with bison.simple:
|
* data/bison.c++: Catch up with bison.simple:
|
||||||
2002-05-24 Paul Hilfinger <[email protected]>
|
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_,
|
2002-05-26 Akim Demaille <[email protected]>: stos_, token_number_,
|
||||||
and popping traces.
|
and popping traces.
|
||||||
|
|
||||||
@@ -20455,7 +20455,7 @@
|
|||||||
single characters while replacing `[' and `]' with quadrigraphs, to
|
single characters while replacing `[' and `]' with quadrigraphs, to
|
||||||
avoid troubles with M4 quotes.
|
avoid troubles with M4 quotes.
|
||||||
(copy_comment): Output characters with copy_character.
|
(copy_comment): Output characters with copy_character.
|
||||||
(read_additionnal_code): Likewise.
|
(read_additional_code): Likewise.
|
||||||
(copy_string2): Likewise.
|
(copy_string2): Likewise.
|
||||||
(copy_definition): Likewise.
|
(copy_definition): Likewise.
|
||||||
|
|
||||||
@@ -20638,7 +20638,7 @@
|
|||||||
* data/bison.simple, data/bison.c++: Adjust.
|
* data/bison.simple, data/bison.c++: Adjust.
|
||||||
* tests/torture.at (Big triangle): Move the limit from 254 to
|
* tests/torture.at (Big triangle): Move the limit from 254 to
|
||||||
500.
|
500.
|
||||||
* tests/regression.at (Web2c Actions): Ajust.
|
* tests/regression.at (Web2c Actions): Adjust.
|
||||||
|
|
||||||
Trying with bigger grammars shows various phenomena: at 3000 (28Mb
|
Trying with bigger grammars shows various phenomena: at 3000 (28Mb
|
||||||
of grammar file) bison is killed by my system, at 2000 (12Mb) bison
|
of grammar file) bison is killed by my system, at 2000 (12Mb) bison
|
||||||
@@ -20949,7 +20949,7 @@
|
|||||||
|
|
||||||
2002-03-05 Robert Anisko <[email protected]>
|
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.
|
a character.
|
||||||
Reported by Nicolas Tisserand and Nicolas Burrus.
|
Reported by Nicolas Tisserand and Nicolas Burrus.
|
||||||
|
|
||||||
@@ -21070,7 +21070,7 @@
|
|||||||
|
|
||||||
* src/L0.c, src/LR0.h (nstates): Be size_t.
|
* src/L0.c, src/LR0.h (nstates): Be size_t.
|
||||||
Adjust comparisons (signed vs unsigned).
|
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*.
|
bitset*.
|
||||||
Adjust all dependencies.
|
Adjust all dependencies.
|
||||||
|
|
||||||
@@ -22337,7 +22337,7 @@
|
|||||||
|
|
||||||
* src/bison.simple: Remove #line just before %%epilogue. It
|
* src/bison.simple: Remove #line just before %%epilogue. It
|
||||||
is now handled in ...
|
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.
|
#line for the epilogue.
|
||||||
|
|
||||||
2001-12-10 Marc Autret <[email protected]>
|
2001-12-10 Marc Autret <[email protected]>
|
||||||
@@ -22797,7 +22797,7 @@
|
|||||||
on user names when possible.
|
on user names when possible.
|
||||||
|
|
||||||
(YYSTACK_USE_ALLOCA): Do not define; just use any existing defn.
|
(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++.
|
(<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]>
|
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.
|
union_obstack, not attrs_obstack.
|
||||||
|
|
||||||
2001-10-04 Akim Demaille <[email protected]>
|
2001-10-04 Akim Demaille <[email protected]>
|
||||||
@@ -23844,7 +23844,7 @@
|
|||||||
|
|
||||||
* src/vcg.h (graph_s): color, textcolor, bordercolor are now
|
* src/vcg.h (graph_s): color, textcolor, bordercolor are now
|
||||||
enum color_e.
|
enum color_e.
|
||||||
* src/print_graph.c (print_graph): Initalize graph.layoutalgorithm
|
* src/print_graph.c (print_graph): Initialize graph.layoutalgorithm
|
||||||
to `normal'.
|
to `normal'.
|
||||||
* src/reader.c (parse_token_decl): Initialize token with tok_eof.
|
* src/reader.c (parse_token_decl): Initialize token with tok_eof.
|
||||||
* src/lex.h: Adjust prototype.
|
* src/lex.h: Adjust prototype.
|
||||||
@@ -23999,7 +23999,7 @@
|
|||||||
|
|
||||||
* src/vcg.c: Remove includes of `complain.h' and `xalloc.h'.
|
* src/vcg.c: Remove includes of `complain.h' and `xalloc.h'.
|
||||||
(get_xxxx_str): Use assert () instead of complain ().
|
(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.
|
(get_decision_str): Modify default behaviour. Remove second argument.
|
||||||
Echo modifications on calls.
|
Echo modifications on calls.
|
||||||
(output_graph): Fix.
|
(output_graph): Fix.
|
||||||
@@ -24030,7 +24030,7 @@
|
|||||||
informations about %union.
|
informations about %union.
|
||||||
(parse_union_decl): Copy the union_obstack in the muscle stype.
|
(parse_union_decl): Copy the union_obstack in the muscle stype.
|
||||||
* src/bison.simple: Add new #line directive.
|
* src/bison.simple: Add new #line directive.
|
||||||
Add typdef %%stype YYSTYPE.
|
Add typedef %%stype YYSTYPE.
|
||||||
|
|
||||||
2001-09-23 Pascal Bart <[email protected]>
|
2001-09-23 Pascal Bart <[email protected]>
|
||||||
|
|
||||||
@@ -24115,7 +24115,7 @@
|
|||||||
(parse_union_decl): Update.
|
(parse_union_decl): Update.
|
||||||
(parse_macro_decl): Rename parse_muscle_decl.
|
(parse_macro_decl): Rename parse_muscle_decl.
|
||||||
Update to use renamed functions and variable.
|
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.
|
with correct variables and functions names.
|
||||||
(packsymbols, reader): Likewise.
|
(packsymbols, reader): Likewise.
|
||||||
|
|
||||||
@@ -24196,7 +24196,7 @@
|
|||||||
|
|
||||||
2001-08-31 Pascal Bart <[email protected]>, Marc Autret <[email protected]>
|
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.
|
%%epilogue.
|
||||||
* src/output.c (output): Rename %%declarations to %%prologue.
|
* src/output.c (output): Rename %%declarations to %%prologue.
|
||||||
* src/bison.simple: Echo modifications.
|
* src/bison.simple: Echo modifications.
|
||||||
@@ -24240,7 +24240,7 @@
|
|||||||
2001-08-29 Marc Autret <[email protected]>
|
2001-08-29 Marc Autret <[email protected]>
|
||||||
|
|
||||||
* src/bison.simple: Add %%user_code directive at the end.
|
* 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.
|
(reader): Use it.
|
||||||
* src/output.c (output_program): Remove.
|
* src/output.c (output_program): Remove.
|
||||||
(output): Update.
|
(output): Update.
|
||||||
@@ -24303,7 +24303,7 @@
|
|||||||
(readgram): Disable a piece of code that was writing a default
|
(readgram): Disable a piece of code that was writing a default
|
||||||
definition for 'YYSTYPE'.
|
definition for 'YYSTYPE'.
|
||||||
(reader_output_yylsp): Remove.
|
(reader_output_yylsp): Remove.
|
||||||
(packsymbols): Output token defintions to a macro.
|
(packsymbols): Output token definitions to a macro.
|
||||||
(copy_definition): Disable C output.
|
(copy_definition): Disable C output.
|
||||||
|
|
||||||
* src/reader.c (parse_macro_decl): New function used to parse macro
|
* src/reader.c (parse_macro_decl): New function used to parse macro
|
||||||
@@ -24641,7 +24641,7 @@
|
|||||||
|
|
||||||
2001-07-08 Pascal Bart <[email protected]>
|
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'.
|
between signed and unsigned'.
|
||||||
|
|
||||||
2001-07-05 Pascal Bart <[email protected]>
|
2001-07-05 Pascal Bart <[email protected]>
|
||||||
@@ -25128,7 +25128,7 @@
|
|||||||
* tests/calc.m4: Test it.
|
* tests/calc.m4: Test it.
|
||||||
|
|
||||||
For regularity of the names, replace each
|
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.
|
(no_lineflag, token_tableflag, rawflag, no_parserflag): this.
|
||||||
In addition replace each `flag' with `_flag'.
|
In addition replace each `flag' with `_flag'.
|
||||||
|
|
||||||
@@ -25731,7 +25731,7 @@
|
|||||||
|
|
||||||
* src/getargs.c, src/Makefile.am, src/reader.c, src/version.c:
|
* src/getargs.c, src/Makefile.am, src/reader.c, src/version.c:
|
||||||
Have configure build version string instead of relying on ANSI string
|
Have configure build version string instead of relying on ANSI string
|
||||||
concatentation.
|
concatenation.
|
||||||
|
|
||||||
1999-06-14 Jesse Thilo <[email protected]>
|
1999-06-14 Jesse Thilo <[email protected]>
|
||||||
|
|
||||||
@@ -25741,7 +25741,7 @@
|
|||||||
|
|
||||||
* acconfig.h, configure.in:
|
* acconfig.h, configure.in:
|
||||||
Have configure build version string instead of relying on ANSI string
|
Have configure build version string instead of relying on ANSI string
|
||||||
concatentation.
|
concatenation.
|
||||||
|
|
||||||
1999-06-08 Jesse Thilo <[email protected]>
|
1999-06-08 Jesse Thilo <[email protected]>
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
|
|||||||
# instead of "-Ilib" avoids infinite recursions on #include_next.
|
# instead of "-Ilib" avoids infinite recursions on #include_next.
|
||||||
AM_CPPFLAGS = -I. -I./lib -I$(top_srcdir) -I$(top_srcdir)/lib
|
AM_CPPFLAGS = -I. -I./lib -I$(top_srcdir) -I$(top_srcdir)/lib
|
||||||
BUILT_SOURCES =
|
BUILT_SOURCES =
|
||||||
|
CLEANDIRS =
|
||||||
CLEANFILES =
|
CLEANFILES =
|
||||||
DISTCLEANFILES =
|
DISTCLEANFILES =
|
||||||
EXTRA_DIST += $(dist_TESTS)
|
EXTRA_DIST += $(dist_TESTS)
|
||||||
@@ -64,6 +65,9 @@ include lib/local.mk
|
|||||||
include src/local.mk
|
include src/local.mk
|
||||||
include tests/local.mk
|
include tests/local.mk
|
||||||
|
|
||||||
|
clean-local:
|
||||||
|
rm -rf $(CLEANDIRS)
|
||||||
|
|
||||||
# See comments in build-aux/git-version-gen. However, we make .version depend
|
# 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
|
# 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
|
# working copy (for example, when you run autoreconf && make). Allowing these
|
||||||
|
|||||||
@@ -1,5 +1,161 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.1.91 (2018-10-18) [beta]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
With modern C++, the parser stack failed to grow properly.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.1.90 (2018-10-17) [beta]
|
||||||
|
|
||||||
|
** 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.
|
||||||
|
|
||||||
|
** 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/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]
|
* Noteworthy changes in release 3.1 (2018-08-27) [stable]
|
||||||
|
|
||||||
** Backward incompatible changes
|
** Backward incompatible changes
|
||||||
@@ -698,9 +854,9 @@ GNU Bison NEWS
|
|||||||
fixed, and introducing tokens with any of %token, %left, %right,
|
fixed, and introducing tokens with any of %token, %left, %right,
|
||||||
%precedence, or %nonassoc yields the same result.
|
%precedence, or %nonassoc yields the same result.
|
||||||
|
|
||||||
When mixing declarations of tokens with a litteral character (e.g., 'a')
|
When mixing declarations of tokens with a literal character (e.g., 'a') or
|
||||||
or with an identifier (e.g., B) in a precedence declaration, Bison
|
with an identifier (e.g., B) in a precedence declaration, Bison numbered
|
||||||
numbered the litteral characters first. For example
|
the literal characters first. For example
|
||||||
|
|
||||||
%right A B 'c' 'd'
|
%right A B 'c' 'd'
|
||||||
|
|
||||||
@@ -1021,7 +1177,7 @@ GNU Bison NEWS
|
|||||||
Although introduced more than four years ago, XML and Graphviz reports
|
Although introduced more than four years ago, XML and Graphviz reports
|
||||||
were not properly documented.
|
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]
|
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
|
||||||
|
|
||||||
@@ -2017,16 +2173,16 @@ GNU Bison NEWS
|
|||||||
The prologue alternatives are experimental. More user feedback will help to
|
The prologue alternatives are experimental. More user feedback will help to
|
||||||
determine whether they should become permanent features.
|
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
|
used within any of the actions of the parent rule. For example, Bison warns
|
||||||
about unused $2 in:
|
about unused $2 in:
|
||||||
|
|
||||||
exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
|
exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
|
||||||
|
|
||||||
Now, Bison also warns about mid-rule values that are used but not set. For
|
Now, Bison also warns about midrule values that are used but not set. For
|
||||||
example, Bison warns about unset $$ in the mid-rule action in:
|
example, Bison warns about unset $$ in the midrule action in:
|
||||||
|
|
||||||
exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
|
exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
|
||||||
|
|
||||||
@@ -2052,7 +2208,7 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
|
Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
|
||||||
"<*>" and "<>" combined achieve the same effect with one exception: Bison no
|
"<*>" 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.
|
not actually ever referenced using either $$ or $n in a semantic action.
|
||||||
|
|
||||||
The default %destructor's and %printer's are experimental. More user
|
The default %destructor's and %printer's are experimental. More user
|
||||||
@@ -2230,7 +2386,7 @@ GNU Bison NEWS
|
|||||||
| exp "+" exp { $$ = $1; (void) $3; }
|
| 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.
|
uses it. The following triggers no warning: $1 and $3 are used.
|
||||||
|
|
||||||
exp: exp { push ($1); } '+' exp { push ($3); sum (); };
|
exp: exp { push ($1); } '+' exp { push ($3); sum (); };
|
||||||
@@ -2505,13 +2661,13 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
typed: ... untyped;
|
typed: ... untyped;
|
||||||
|
|
||||||
** Values of mid-rule actions
|
** Values of midrule actions
|
||||||
The following code:
|
The following code:
|
||||||
|
|
||||||
foo: { ... } { $$ = $1; } ...
|
foo: { ... } { $$ = $1; } ...
|
||||||
|
|
||||||
was incorrectly rejected: $1 is defined in the second mid-rule
|
was incorrectly rejected: $1 is defined in the second midrule
|
||||||
action, and is equal to the $$ of the first mid-rule action.
|
action, and is equal to the $$ of the first midrule action.
|
||||||
|
|
||||||
* Changes in version 1.50, 2002-10-04:
|
* Changes in version 1.50, 2002-10-04:
|
||||||
|
|
||||||
@@ -2647,7 +2803,7 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
** Type clashes
|
** Type clashes
|
||||||
Previous versions don't complain when there is a type clash on
|
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
|
%type <foo> bar
|
||||||
%%
|
%%
|
||||||
@@ -2958,7 +3114,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
|
LocalWords: Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
|
||||||
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
||||||
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
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:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ End:
|
|||||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software
|
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software
|
||||||
Foundation, Inc.
|
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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+14
-14
@@ -190,12 +190,15 @@ Use liberally.
|
|||||||
|
|
||||||
** TESTSUITEFLAGS
|
** TESTSUITEFLAGS
|
||||||
|
|
||||||
The default is for make check to run all tests sequentially. This can be
|
To run just the testsuite (not the tests related to the examples), run `make
|
||||||
very time consumming when checking repeatedly or on slower setups. This can
|
check-local`.
|
||||||
be sped up in two ways:
|
|
||||||
|
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:
|
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
|
Running only the tests of a certain category, as specified in the AT files
|
||||||
with AT_KEYWORDS([[category]]). Categories include:
|
with AT_KEYWORDS([[category]]). Categories include:
|
||||||
@@ -206,7 +209,7 @@ with AT_KEYWORDS([[category]]). Categories include:
|
|||||||
- report, for automaton dumps
|
- report, for automaton dumps
|
||||||
|
|
||||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
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.
|
Both can be combined.
|
||||||
|
|
||||||
@@ -259,24 +262,21 @@ release:
|
|||||||
- runs the parsers under Valgrind.
|
- runs the parsers under Valgrind.
|
||||||
- runs the test suite with G++ as C compiler...
|
- 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
|
activating the push implementation and its pull interface wrappers in many
|
||||||
test cases that were originally written to exercise only the pull
|
test cases that were originally written to exercise only the pull
|
||||||
implementation. This makes certain the push implementation can perform
|
implementation. This makes certain the push implementation can perform
|
||||||
every task the pull implementation can.
|
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
|
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
|
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.
|
included XSLT style sheets with the output of --report=all and --graph.
|
||||||
|
|
||||||
- running "make maintainer-release-check" takes care of running
|
- running "make maintainer-check-release" takes care of running
|
||||||
maintainer-check, maintainer-push-check and maintainer-xml-check.
|
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
||||||
|
|
||||||
- Change tests/atlocal/CFLAGS to add your preferred options. For instance,
|
- Change tests/atlocal/CFLAGS to add your preferred options.
|
||||||
"-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.
|
|
||||||
|
|
||||||
- Test with a very recent version of GCC for both C and C++. Testing with
|
- 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.
|
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
|
week before a stable release, to give them time to translate them. Before
|
||||||
generating the *.pot files, make sure that po/POTFILES.in and
|
generating the *.pot files, make sure that po/POTFILES.in and
|
||||||
runtime-po/POTFILES.in list all files with translatable strings. This
|
runtime-po/POTFILES.in list all files with translatable strings. This
|
||||||
helps: grep -l '\<_(' *
|
helps: grep -l '\<_(' *.
|
||||||
|
|
||||||
** Tests
|
** Tests
|
||||||
See above.
|
See above.
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ Didier Godefroy [email protected]
|
|||||||
Efi Fogel [email protected]
|
Efi Fogel [email protected]
|
||||||
Enrico Scholz [email protected]
|
Enrico Scholz [email protected]
|
||||||
Eric Blake [email protected]
|
Eric Blake [email protected]
|
||||||
|
Étienne Renault [email protected]
|
||||||
Evgeny Stambulchik [email protected]
|
Evgeny Stambulchik [email protected]
|
||||||
Fabrice Bauzac [email protected]
|
Fabrice Bauzac [email protected]
|
||||||
Ferdinand Thiessen [email protected]
|
Ferdinand Thiessen [email protected]
|
||||||
@@ -77,6 +78,7 @@ Johan van Selst [email protected]
|
|||||||
John Horigan [email protected]
|
John Horigan [email protected]
|
||||||
Jonathan Fabrizio [email protected]
|
Jonathan Fabrizio [email protected]
|
||||||
Jonathan Nieder [email protected]
|
Jonathan Nieder [email protected]
|
||||||
|
Josh Soref [email protected]
|
||||||
Juan Manuel Guerrero [email protected]
|
Juan Manuel Guerrero [email protected]
|
||||||
Kees Zeelenberg [email protected]
|
Kees Zeelenberg [email protected]
|
||||||
Keith Browne [email protected]
|
Keith Browne [email protected]
|
||||||
@@ -145,6 +147,7 @@ Sebastian Setzer [email protected]
|
|||||||
Sebastien Fricker [email protected]
|
Sebastien Fricker [email protected]
|
||||||
Sergei Steshenko [email protected]
|
Sergei Steshenko [email protected]
|
||||||
Shura [email protected]
|
Shura [email protected]
|
||||||
|
Simon Sobisch [email protected]
|
||||||
Stefano Lattarini [email protected]
|
Stefano Lattarini [email protected]
|
||||||
Stephen Cameron [email protected]
|
Stephen Cameron [email protected]
|
||||||
Steve Murphy [email protected]
|
Steve Murphy [email protected]
|
||||||
|
|||||||
@@ -196,6 +196,24 @@ DeRemer and Penello: they already provide the algorithm.
|
|||||||
|
|
||||||
|
|
||||||
* Extensions
|
* 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.
|
||||||
|
|
||||||
|
** %include
|
||||||
|
This is a popular demand. We already made many changes in the parser that
|
||||||
|
should make this reasonably easy to implement.
|
||||||
|
|
||||||
|
** 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
|
** $-1
|
||||||
We should find a means to provide an access to values deep in the
|
We should find a means to provide an access to values deep in the
|
||||||
@@ -231,6 +249,10 @@ XML output for GNU Bison and gcc
|
|||||||
XML output for GNU Bison
|
XML output for GNU Bison
|
||||||
http://yaxx.sourceforge.net/
|
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
|
* Unit rules
|
||||||
Maybe we could expand unit rules, i.e., transform
|
Maybe we could expand unit rules, i.e., transform
|
||||||
|
|
||||||
@@ -365,6 +387,7 @@ Here's a proposal for how a new implementation might look:
|
|||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
coding: utf-8
|
coding: utf-8
|
||||||
|
fill-column: 76
|
||||||
End:
|
End:
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2018-07-25.07; # UTC
|
scriptversion=2018-10-13.05; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
@@ -162,18 +162,11 @@ bootstrap_post_import_hook() { :; }
|
|||||||
# Override it via your own definition in bootstrap.conf.
|
# Override it via your own definition in bootstrap.conf.
|
||||||
bootstrap_epilogue() { :; }
|
bootstrap_epilogue() { :; }
|
||||||
|
|
||||||
# The command to download all .po files for a specified domain into
|
# The command to download all .po files for a specified domain into a
|
||||||
# a specified directory. Fill in the first %s is the domain name, and
|
# specified directory. Fill in the first %s with the destination
|
||||||
# the second with the destination directory. Use rsync's -L and -r
|
# directory and the second with the domain name.
|
||||||
# options because the latest/%s directory and the .po files within are
|
|
||||||
# all symlinks.
|
|
||||||
po_download_command_format=\
|
po_download_command_format=\
|
||||||
"rsync --include '*.po' --exclude '*' -Lrtvz \
|
"wget --mirror --level=1 -nd -q -A.po -P '%s' \
|
||||||
'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' \
|
|
||||||
https://translationproject.org/latest/%s/"
|
https://translationproject.org/latest/%s/"
|
||||||
|
|
||||||
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
||||||
@@ -741,10 +734,7 @@ download_po_files() {
|
|||||||
subdir=$1
|
subdir=$1
|
||||||
domain=$2
|
domain=$2
|
||||||
echo "$me: getting translations into $subdir for $domain..."
|
echo "$me: getting translations into $subdir for $domain..."
|
||||||
cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
|
cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
|
||||||
eval "$cmd" && return
|
|
||||||
# Fallback to HTTPS.
|
|
||||||
cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
|
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ gnulib_modules='
|
|||||||
readme-release
|
readme-release
|
||||||
realloc-posix
|
realloc-posix
|
||||||
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
||||||
|
timevar
|
||||||
unistd unistd-safer unlink unlocked-io
|
unistd unistd-safer unlink unlocked-io
|
||||||
update-copyright unsetenv verify
|
update-copyright unsetenv verify
|
||||||
warnings
|
warnings
|
||||||
|
|||||||
@@ -15,6 +15,19 @@
|
|||||||
|
|
||||||
# Valgrind suppression file for Bison.
|
# 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
|
# Linux prague 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015
|
||||||
# x86_64 GNU/Linux
|
# x86_64 GNU/Linux
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ while (<STDIN>)
|
|||||||
$arg =~ s/^=//;
|
$arg =~ s/^=//;
|
||||||
$arg = lc ($arg);
|
$arg = lc ($arg);
|
||||||
my $dir_arg = $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
|
# put each word in @var, to build @var{name}[=@var{value}], not
|
||||||
# @var{name[=value]}].
|
# @var{name[=value]}].
|
||||||
$arg =~ s/(\w+)/\@var{$1}/g;
|
$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
|
||||||
@@ -26,11 +26,11 @@ regen: _version
|
|||||||
manual_title = The Yacc-compatible Parser Generator
|
manual_title = The Yacc-compatible Parser Generator
|
||||||
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
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,
|
# 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.
|
# 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)))
|
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
||||||
|
|
||||||
url_dir_list = \
|
url_dir_list = \
|
||||||
@@ -158,24 +158,24 @@ sc_space_before_open_paren:
|
|||||||
|
|
||||||
exclude = \
|
exclude = \
|
||||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
$(call exclude, \
|
$(call exclude, \
|
||||||
bindtextdomain=^lib/main.c$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||||
program_name=^lib/main.c$$ \
|
program_name=^lib/main.c$$ \
|
||||||
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
||||||
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
||||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||||
prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \
|
prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \
|
||||||
prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \
|
prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \
|
||||||
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||||
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
|
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
|
||||||
prohibit_tab_based_indentation=\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
|
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
|
||||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
||||||
space_before_open_paren=^(data/|djgpp/) \
|
space_before_open_paren=^(data/|djgpp/) \
|
||||||
two_space_separator_in_usage=^(bootstrap) \
|
two_space_separator_in_usage=^(bootstrap|build-aux/install-icc.sh) \
|
||||||
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
||||||
)
|
)
|
||||||
|
|||||||
+22
-6
@@ -21,7 +21,8 @@
|
|||||||
# better to avoid a typo in the 'configure --help' entry for the YACC
|
# better to avoid a typo in the 'configure --help' entry for the YACC
|
||||||
# environment variable.
|
# environment variable.
|
||||||
AC_PREREQ([2.68])
|
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],
|
AC_INIT([GNU Bison],
|
||||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||||
@@ -70,6 +71,17 @@ AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
|
|||||||
[lv_cv_gcc_pragma_push_works=no])
|
[lv_cv_gcc_pragma_push_works=no])
|
||||||
CFLAGS=$save_CFLAGS])
|
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])
|
||||||
|
AC_LANG_POP([C++])
|
||||||
|
|
||||||
AC_ARG_ENABLE([gcc-warnings],
|
AC_ARG_ENABLE([gcc-warnings],
|
||||||
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended).
|
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended).
|
||||||
Also, issue synclines from the examples/ to
|
Also, issue synclines from the examples/ to
|
||||||
@@ -81,7 +93,8 @@ AC_ARG_ENABLE([gcc-warnings],
|
|||||||
[enable_gcc_warnings=no])
|
[enable_gcc_warnings=no])
|
||||||
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
||||||
if test "$enable_gcc_warnings" = yes; then
|
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'
|
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
|
||||||
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
||||||
warn_cxx='-Wnoexcept'
|
warn_cxx='-Wnoexcept'
|
||||||
@@ -150,13 +163,15 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
gl_WARN_ADD([-Wno-null-conversion], [FLEX_SCANNER_CXXFLAGS])
|
gl_WARN_ADD([-Wno-null-conversion], [FLEX_SCANNER_CXXFLAGS])
|
||||||
# So does G++ 4.8...
|
# So does G++ 4.8...
|
||||||
gl_WARN_ADD([-Wno-sign-compare], [FLEX_SCANNER_CXXFLAGS])
|
gl_WARN_ADD([-Wno-sign-compare], [FLEX_SCANNER_CXXFLAGS])
|
||||||
# ... possiby in std=c++11 mode.
|
# ... possibly in std=c++11 mode.
|
||||||
gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
|
gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
|
||||||
CXXFLAGS=$save_CXXFLAGS
|
CXXFLAGS=$save_CXXFLAGS
|
||||||
gl_WARN_ADD([-fno-exceptions], [CXXFLAGS_NO_EXCEPTIONS])
|
# Clang++ deprecates compiling C.
|
||||||
|
gl_WARN_ADD([-Wno-deprecated], [WNO_DEPRECATED_CXXFLAGS])
|
||||||
AC_LANG_POP([C++])
|
AC_LANG_POP([C++])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
BISON_TEST_FOR_WORKING_C_COMPILER
|
BISON_TEST_FOR_WORKING_C_COMPILER
|
||||||
BISON_C_COMPILER_POSIXLY_CORRECT
|
BISON_C_COMPILER_POSIXLY_CORRECT
|
||||||
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
||||||
@@ -204,7 +219,6 @@ gl_INIT
|
|||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||||
AM_WITH_DMALLOC
|
AM_WITH_DMALLOC
|
||||||
BISON_PREREQ_TIMEVAR
|
|
||||||
|
|
||||||
# Gettext.
|
# Gettext.
|
||||||
# We use gnulib, which is only guaranteed to work properly with the
|
# We use gnulib, which is only guaranteed to work properly with the
|
||||||
@@ -243,6 +257,8 @@ case $VALGRIND:$uname in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
AC_MSG_CHECKING([Valgrind suppression file])
|
||||||
|
AC_MSG_RESULT([$suppfile])
|
||||||
|
|
||||||
# Whether we cannot run the compiled bison.
|
# Whether we cannot run the compiled bison.
|
||||||
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
||||||
@@ -251,7 +267,7 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
|||||||
# Needed by tests/atlocal.in.
|
# Needed by tests/atlocal.in.
|
||||||
AC_SUBST([GCC])
|
AC_SUBST([GCC])
|
||||||
|
|
||||||
gt_JAVACOMP([1.3], [1.4])
|
gt_JAVACOMP([1.7], [1.7])
|
||||||
gt_JAVAEXEC
|
gt_JAVAEXEC
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
|
|||||||
+74
-29
@@ -61,23 +61,35 @@ This special exception was added by the Free Software Foundation in
|
|||||||
version 2.2 of Bison.])])
|
version 2.2 of Bison.])])
|
||||||
|
|
||||||
|
|
||||||
|
# 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. ##
|
## Output. ##
|
||||||
## -------- ##
|
## -------- ##
|
||||||
|
|
||||||
# b4_output_begin(FILE)
|
# b4_output_begin(FILE1, FILE2)
|
||||||
# ---------------------
|
# -----------------------------
|
||||||
# Enable output, i.e., send to diversion 0, expand after "#", and
|
# Enable output, i.e., send to diversion 0, expand after "#", and
|
||||||
# generate the tag to output into FILE. Must be followed by EOL.
|
# 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_define([b4_output_begin],
|
||||||
[m4_changecom()
|
[m4_changecom()
|
||||||
m4_divert_push(0)dnl
|
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 #).
|
# Output nothing, restore # as comment character (no expansions after #).
|
||||||
m4_define([b4_output_end],
|
m4_define([b4_output_end],
|
||||||
[m4_divert_pop(0)
|
[m4_divert_pop(0)
|
||||||
@@ -389,11 +401,11 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
|||||||
#
|
#
|
||||||
# The following macros provide access to these values.
|
# 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
|
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||||
# undefined.
|
# undefined.
|
||||||
m4_define([b4_symbol_],
|
m4_define([_b4_symbol],
|
||||||
[m4_indir([b4_symbol($1, $2)])])
|
[m4_indir([b4_symbol($1, $2)])])
|
||||||
|
|
||||||
|
|
||||||
@@ -404,8 +416,8 @@ m4_define([b4_symbol_],
|
|||||||
m4_define([b4_symbol],
|
m4_define([b4_symbol],
|
||||||
[m4_case([$2],
|
[m4_case([$2],
|
||||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
||||||
[b4_symbol_([$1], [id])])],
|
[_b4_symbol([$1], [id])])],
|
||||||
[b4_symbol_($@)])])
|
[_b4_symbol($@)])])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
||||||
@@ -443,7 +455,7 @@ m4_define([b4_symbol_action],
|
|||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[m4_dquote(b4_symbol([$1], [type]))]),
|
[m4_dquote(b4_symbol([$1], [type]))]),
|
||||||
[(*yylocationp)])dnl
|
[(*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_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||||
b4_symbol([$1], [$2])
|
b4_symbol([$1], [$2])
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])
|
||||||
@@ -478,10 +490,10 @@ m4_ifval(m4_defn([b4_actions_]),
|
|||||||
m4_popdef([b4_actions_])dnl
|
m4_popdef([b4_actions_])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_symbol_case_(SYMBOL-NUM)
|
# _b4_symbol_case(SYMBOL-NUM)
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# Issue a "case NUM" for 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])])
|
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -536,16 +548,16 @@ m4_define([b4_token_format],
|
|||||||
## Types. ##
|
## Types. ##
|
||||||
## ------- ##
|
## ------- ##
|
||||||
|
|
||||||
# b4_type_action_(NUMS)
|
# _b4_type_action(NUMS)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Run actions for the symbol NUMS that all have the same type-name.
|
# Run actions for the symbol NUMS that all have the same type-name.
|
||||||
# Skip NUMS that have no type-name.
|
# Skip NUMS that have no type-name.
|
||||||
#
|
#
|
||||||
# To specify the action to run, define b4_dollar_dollar(NUMBER,
|
# To specify the action to run, define b4_dollar_dollar(NUMBER,
|
||||||
# TAG, TYPE).
|
# TAG, TYPE).
|
||||||
m4_define([b4_type_action_],
|
m4_define([_b4_type_action],
|
||||||
[b4_symbol_if([$1], [has_type],
|
[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_dollar_dollar([b4_symbol([$1], [number])],
|
||||||
[b4_symbol([$1], [tag])],
|
[b4_symbol([$1], [tag])],
|
||||||
[b4_symbol([$1], [type])]);
|
[b4_symbol([$1], [type])]);
|
||||||
@@ -701,7 +713,7 @@ m4_define([b4_percent_define_use],
|
|||||||
# b4_percent_define_get([[foo]])
|
# b4_percent_define_get([[foo]])
|
||||||
m4_define([b4_percent_define_get],
|
m4_define([b4_percent_define_get],
|
||||||
[b4_percent_define_use([$1])dnl
|
[b4_percent_define_use([$1])dnl
|
||||||
b4_percent_define_ifdef_([$1],
|
_b4_percent_define_ifdef([$1],
|
||||||
[m4_indir([b4_percent_define(]$1[)])],
|
[m4_indir([b4_percent_define(]$1[)])],
|
||||||
[$2])])
|
[$2])])
|
||||||
|
|
||||||
@@ -710,7 +722,7 @@ b4_percent_define_ifdef_([$1],
|
|||||||
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
# 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
|
# if the %define variable VARIABLE is undefined, complain fatally since that's
|
||||||
# a Bison or skeleton error. Otherwise, return its definition location in a
|
# 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
|
# 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.
|
# reason to suspect that the user-supplied value has yet influenced the output.
|
||||||
#
|
#
|
||||||
@@ -755,15 +767,15 @@ m4_define([b4_percent_define_get_syncline],
|
|||||||
[m4_indir([b4_percent_define_syncline(]$1[)])],
|
[m4_indir([b4_percent_define_syncline(]$1[)])],
|
||||||
[b4_fatal([[$0: undefined %%define variable '%s']], [$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 the %define variable VARIABLE is defined, expand IF-TRUE, else expand
|
||||||
# IF-FALSE. Don't record usage of VARIABLE.
|
# IF-FALSE. Don't record usage of VARIABLE.
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
#
|
#
|
||||||
# b4_percent_define_ifdef_([[foo]], [[it's defined]], [[it's undefined]])
|
# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||||
m4_define([b4_percent_define_ifdef_],
|
m4_define([_b4_percent_define_ifdef],
|
||||||
[m4_ifdef([b4_percent_define(]$1[)],
|
[m4_ifdef([b4_percent_define(]$1[)],
|
||||||
[$2],
|
[$2],
|
||||||
[$3])])
|
[$3])])
|
||||||
@@ -779,11 +791,44 @@ m4_define([b4_percent_define_ifdef_],
|
|||||||
#
|
#
|
||||||
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||||
m4_define([b4_percent_define_ifdef],
|
m4_define([b4_percent_define_ifdef],
|
||||||
[b4_percent_define_ifdef_([$1],
|
[_b4_percent_define_ifdef([$1],
|
||||||
[b4_percent_define_use([$1])$2],
|
[b4_percent_define_use([$1])$2],
|
||||||
[$3])])
|
[$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. ##
|
## Options. ##
|
||||||
## --------- ##
|
## --------- ##
|
||||||
@@ -824,7 +869,7 @@ m4_define([b4_percent_define_flag_if],
|
|||||||
#
|
#
|
||||||
# b4_percent_define_default([[foo]], [[default value]])
|
# b4_percent_define_default([[foo]], [[default value]])
|
||||||
m4_define([b4_percent_define_default],
|
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(]$1[)], [$2])dnl
|
||||||
m4_define([b4_percent_define_kind(]$1[)],
|
m4_define([b4_percent_define_kind(]$1[)],
|
||||||
[m4_default([$3], [keyword])])dnl
|
[m4_default([$3], [keyword])])dnl
|
||||||
@@ -839,26 +884,26 @@ m4_define([b4_percent_define_default],
|
|||||||
# Define b4_NAME_if that executes its $1 or $2 depending whether
|
# Define b4_NAME_if that executes its $1 or $2 depending whether
|
||||||
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
|
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
|
||||||
# to '_'.
|
# to '_'.
|
||||||
m4_define([b4_percent_define_if_define_],
|
m4_define([_b4_percent_define_if_define],
|
||||||
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
||||||
[b4_percent_define_flag_if(m4_default([$2], [$1]),
|
[b4_percent_define_flag_if(m4_default([$2], [$1]),
|
||||||
[$3], [$4])])])
|
[$3], [$4])])])
|
||||||
m4_define([b4_percent_define_if_define],
|
m4_define([b4_percent_define_if_define],
|
||||||
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
|
[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])
|
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
m4_define([b4_percent_define_check_kind],
|
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], [],
|
[m4_if(b4_percent_define_get_kind([$1]), [$2], [],
|
||||||
[b4_error([m4_default([$3], [complain])],
|
[b4_error([m4_default([$3], [complain])],
|
||||||
b4_percent_define_get_loc([$1]),
|
b4_percent_define_get_loc([$1]),
|
||||||
[m4_case([$2],
|
[m4_case([$2],
|
||||||
[code], [[%%define variable '%s' requires '{...}' values]],
|
[code], [[%%define variable '%s' requires '{...}' values]],
|
||||||
[keyword], [[%%define variable '%s' requires keyword values]],
|
[keyword], [[%%define variable '%s' requires keyword values]],
|
||||||
[string], [[%%define variable '%s' requires '"..."' values]])],
|
[string], [[%%define variable '%s' requires '"..."' values]])],
|
||||||
[$1])])])dnl
|
[$1])])])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -884,7 +929,7 @@ m4_define([b4_percent_define_check_values],
|
|||||||
[_b4_percent_define_check_values(b4_sublist)])])
|
[_b4_percent_define_check_values(b4_sublist)])])
|
||||||
|
|
||||||
m4_define([_b4_percent_define_check_values],
|
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
|
[b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl
|
||||||
m4_pushdef([b4_good_value], [0])dnl
|
m4_pushdef([b4_good_value], [0])dnl
|
||||||
m4_if($#, 1, [],
|
m4_if($#, 1, [],
|
||||||
@@ -946,7 +991,7 @@ m4_define([b4_percent_code_ifdef],
|
|||||||
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
|
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
|
||||||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [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_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([token_ctor], [api.token.constructor])
|
||||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||||
b4_percent_define_if_define([parse.assert])
|
b4_percent_define_if_define([parse.assert])
|
||||||
|
|||||||
+72
-39
@@ -24,11 +24,20 @@ b4_percent_define_ifdef([[api.value.union.name]],
|
|||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
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])
|
# b4_comment(TEXT, [PREFIX])
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||||
m4_define([b4_comment],
|
m4_define([b4_comment],
|
||||||
[b4_comment_([$1], [$2// ], [$2// ])])
|
[_b4_comment([$1], [$2// ], [$2// ])])
|
||||||
|
|
||||||
|
|
||||||
# b4_inline(hh|cc)
|
# b4_inline(hh|cc)
|
||||||
# ----------------
|
# ----------------
|
||||||
@@ -40,12 +49,26 @@ m4_define([b4_inline],
|
|||||||
]],
|
]],
|
||||||
[m4_fatal([$0: invalid argument: $1])])])
|
[m4_fatal([$0: invalid argument: $1])])])
|
||||||
|
|
||||||
## -------- ##
|
|
||||||
## Checks. ##
|
|
||||||
## -------- ##
|
|
||||||
|
|
||||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
# b4_cxx_portability
|
||||||
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
|
# ------------------
|
||||||
|
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. ##
|
## Default values. ##
|
||||||
@@ -88,7 +111,7 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
|||||||
[[namespace reference is empty]])])
|
[[namespace reference is empty]])])
|
||||||
|
|
||||||
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
# 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_open. The problem is that Bison doesn't always output
|
||||||
# b4_namespace_ref to uncommented code but should reserve the ability to do so
|
# b4_namespace_ref to uncommented code but should reserve the ability to do so
|
||||||
# in future releases without risking breaking any existing user grammars.
|
# 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).
|
/// Internal symbol number for tokens (subsumed by symbol_number_type).
|
||||||
typedef ]b4_int_type_for([b4_translate])[ token_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
|
/// 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])[.
|
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
@@ -208,19 +238,20 @@ m4_define([b4_public_types_declare],
|
|||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
basic_symbol ();
|
basic_symbol ();
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Move or copy constructor.
|
||||||
basic_symbol (const basic_symbol& other);
|
basic_symbol (YY_RVREF (basic_symbol) other);
|
||||||
|
|
||||||
]b4_variant_if([[
|
]b4_variant_if([[
|
||||||
/// Constructor for valueless symbols, and symbols from each type.
|
/// Constructor for valueless symbols, and symbols from each type.
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
||||||
/// Constructor for valueless symbols.
|
/// Constructor for valueless symbols.
|
||||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
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.
|
/// Constructor for symbols with semantic value.
|
||||||
basic_symbol (typename Base::kind_type t,
|
basic_symbol (typename Base::kind_type t,
|
||||||
const semantic_type& v]b4_locations_if([,
|
YY_RVREF (semantic_type) v]b4_locations_if([,
|
||||||
const location_type& l])[);
|
YY_RVREF (location_type) l])[);]])[
|
||||||
|
|
||||||
/// Destroy the symbol.
|
/// Destroy the symbol.
|
||||||
~basic_symbol ();
|
~basic_symbol ();
|
||||||
@@ -241,8 +272,10 @@ m4_define([b4_public_types_declare],
|
|||||||
location_type location;])[
|
location_type location;])[
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if defined __cplusplus && __cplusplus < 201103L
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
basic_symbol& operator= (const basic_symbol& other);
|
basic_symbol& operator= (const basic_symbol& other);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Type access provider for token (enum) based symbols.
|
/// Type access provider for token (enum) based symbols.
|
||||||
@@ -281,8 +314,7 @@ m4_define([b4_public_types_declare],
|
|||||||
|
|
||||||
/// "External" symbols: returned by the scanner.
|
/// "External" symbols: returned by the scanner.
|
||||||
typedef basic_symbol<by_type> symbol_type;
|
typedef basic_symbol<by_type> symbol_type;
|
||||||
|
]])
|
||||||
]b4_symbol_constructor_declare])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_public_types_define(hh|cc)
|
# b4_public_types_define(hh|cc)
|
||||||
@@ -302,27 +334,15 @@ m4_define([b4_public_types_define],
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (YY_RVREF (basic_symbol) other)
|
||||||
: Base (other)
|
: Base (YY_MOVE (other))
|
||||||
, value (]b4_variant_if([], [other.value])[)]b4_locations_if([
|
, value (]b4_variant_if([], [YY_MOVE (other.value)]))b4_locations_if([
|
||||||
, location (other.location)])[
|
, location (YY_MOVE (other.location))])[
|
||||||
{]b4_variant_if([
|
{]b4_variant_if([
|
||||||
b4_symbol_variant([other.type_get ()], [value], [copy],
|
b4_symbol_variant([other.type_get ()], [value], [YY_MOVE_OR_COPY],
|
||||||
[other.value])])[
|
[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([[
|
]b4_variant_if([[
|
||||||
// Implementation of basic_symbol constructor for each type.
|
// Implementation of basic_symbol constructor for each type.
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
||||||
@@ -330,11 +350,23 @@ m4_define([b4_public_types_define],
|
|||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||||
[typename Base::kind_type t],
|
[typename Base::kind_type t],
|
||||||
b4_locations_if([const location_type& l]))[)
|
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
||||||
: Base (t)
|
: Base (t)
|
||||||
, value ()]b4_locations_if([
|
, value ()]b4_locations_if([
|
||||||
, location (l)])[
|
, 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>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
||||||
@@ -375,9 +407,9 @@ m4_define([b4_public_types_define],
|
|||||||
{
|
{
|
||||||
super_type::move (s);
|
super_type::move (s);
|
||||||
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
||||||
[s.value])],
|
[YY_MOVE (s.value)])],
|
||||||
[value = s.value;])[]b4_locations_if([
|
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
||||||
location = s.location;])[
|
location = YY_MOVE (s.location);])[
|
||||||
}
|
}
|
||||||
|
|
||||||
// by_type.
|
// by_type.
|
||||||
@@ -426,6 +458,7 @@ m4_define([b4_public_types_define],
|
|||||||
return static_cast<token_type> (yytoken_number_[type]);
|
return static_cast<token_type> (yytoken_number_[type]);
|
||||||
}
|
}
|
||||||
]])[]dnl
|
]])[]dnl
|
||||||
|
|
||||||
b4_symbol_constructor_define])
|
b4_symbol_constructor_define])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -17,14 +17,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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.
|
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||||
# Avoid adding indentation to the first line, as the indentation comes
|
# Avoid adding indentation to the first line, as the indentation comes
|
||||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||||
#
|
#
|
||||||
# Prefix all the output lines with PREFIX.
|
# Prefix all the output lines with PREFIX.
|
||||||
m4_define([b4_comment_],
|
m4_define([_b4_comment],
|
||||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
||||||
\(.\)], [
|
\(.\)], [
|
||||||
$3\1])$4])
|
$3\1])$4])
|
||||||
@@ -34,17 +34,17 @@ $3\1])$4])
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||||
m4_define([b4_comment],
|
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",
|
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||||
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
||||||
# pointer.
|
# pointer.
|
||||||
m4_define([b4_dollar_dollar_],
|
m4_define([_b4_dollar_dollar],
|
||||||
[b4_symbol_value([$1],
|
[b4_symbol_value([$1],
|
||||||
m4_if([$2], [[]],
|
m4_if([$2], [[]],
|
||||||
[[$3]], [[$2]]))])
|
[[$3]], [[$2]]))])
|
||||||
@@ -56,7 +56,7 @@ m4_define([b4_dollar_dollar_],
|
|||||||
# and b4_at_dollar for LOCATION.
|
# and b4_at_dollar for LOCATION.
|
||||||
m4_define([b4_dollar_pushdef],
|
m4_define([b4_dollar_pushdef],
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
[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_pushdef([b4_at_dollar], [$3])dnl
|
||||||
])
|
])
|
||||||
m4_define([b4_dollar_popdef],
|
m4_define([b4_dollar_popdef],
|
||||||
|
|||||||
@@ -263,21 +263,23 @@ m4_define([b4_attribute_define],
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## ---------##
|
|
||||||
## Values. ##
|
|
||||||
## ---------##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_null_define
|
# b4_null_define
|
||||||
# --------------
|
# --------------
|
||||||
# Portability issues: define a YY_NULLPTR appropriate for the current
|
# Portability issues: define a YY_NULLPTR appropriate for the current
|
||||||
# language (C, C++98, or C++11).
|
# 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],
|
m4_define([b4_null_define],
|
||||||
[# ifndef YY_NULLPTR
|
[# ifndef YY_NULLPTR
|
||||||
# if defined __cplusplus && 201103L <= __cplusplus
|
# if defined __cplusplus
|
||||||
# define YY_NULLPTR nullptr
|
# if 201103L <= __cplusplus
|
||||||
|
# define YY_NULLPTR nullptr
|
||||||
|
# else
|
||||||
|
# define YY_NULLPTR 0
|
||||||
|
# endif
|
||||||
# else
|
# else
|
||||||
# define YY_NULLPTR 0
|
# define YY_NULLPTR ((void*)0)
|
||||||
# endif
|
# endif
|
||||||
# endif[]dnl
|
# endif[]dnl
|
||||||
])
|
])
|
||||||
@@ -288,6 +290,12 @@ m4_define([b4_null_define],
|
|||||||
# Return a null pointer constant.
|
# Return a null pointer constant.
|
||||||
m4_define([b4_null], [YY_NULLPTR])
|
m4_define([b4_null], [YY_NULLPTR])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ---------##
|
||||||
|
## Values. ##
|
||||||
|
## ---------##
|
||||||
|
|
||||||
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
||||||
@@ -361,7 +369,7 @@ m4_define([b4_token_enums_defines],
|
|||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
|
# 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
|
# 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.
|
# TYPE is *not* put in braces, provide some if needed.
|
||||||
m4_define([b4_symbol_value],
|
m4_define([b4_symbol_value],
|
||||||
[($1[]m4_ifval([$2], [.$2]))])
|
[($1[]m4_ifval([$2], [.$2]))])
|
||||||
|
|||||||
+16
-10
@@ -203,7 +203,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
|||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
]b4_output_end()
|
]b4_output_end
|
||||||
])])
|
])])
|
||||||
|
|
||||||
|
|
||||||
@@ -217,9 +217,9 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
|||||||
|
|
||||||
/* C GLR parser skeleton written by Paul Hilfinger. */
|
/* C GLR parser skeleton written by Paul Hilfinger. */
|
||||||
|
|
||||||
]b4_identification
|
]b4_identification[
|
||||||
|
|
||||||
b4_percent_code_get([[top]])[
|
]b4_percent_code_get([[top]])[
|
||||||
]m4_if(b4_api_prefix, [yy], [],
|
]m4_if(b4_api_prefix, [yy], [],
|
||||||
[[/* Substitute the type names. */
|
[[/* Substitute the type names. */
|
||||||
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
||||||
@@ -292,19 +292,25 @@ b4_percent_code_get[]dnl
|
|||||||
#define YYSIZEMAX ((size_t) -1)
|
#define YYSIZEMAX ((size_t) -1)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
typedef bool yybool;
|
typedef bool yybool;
|
||||||
|
# define yytrue true
|
||||||
|
# define yyfalse false
|
||||||
#else
|
#else
|
||||||
typedef unsigned char yybool;
|
typedef unsigned char yybool;
|
||||||
|
# define yytrue 1
|
||||||
|
# define yyfalse 0
|
||||||
#endif
|
#endif
|
||||||
#define yytrue 1
|
|
||||||
#define yyfalse 0
|
|
||||||
|
|
||||||
#ifndef YYSETJMP
|
#ifndef YYSETJMP
|
||||||
# include <setjmp.h>
|
# include <setjmp.h>
|
||||||
# define YYJMP_BUF jmp_buf
|
# define YYJMP_BUF jmp_buf
|
||||||
# define YYSETJMP(Env) setjmp (Env)
|
# define YYSETJMP(Env) setjmp (Env)
|
||||||
/* Pacify clang. */
|
/* Pacify Clang and ICC. */
|
||||||
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
|
# define YYLONGJMP(Env, Val) \
|
||||||
|
do { \
|
||||||
|
longjmp (Env, Val); \
|
||||||
|
YYASSERT (0); \
|
||||||
|
} while (yyfalse)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_attribute_define[
|
]b4_attribute_define[
|
||||||
@@ -2573,4 +2579,4 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
#define yylloc ]b4_prefix[lloc]])])[
|
#define yylloc ]b4_prefix[lloc]])])[
|
||||||
|
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
b4_output_end()
|
b4_output_end
|
||||||
|
|||||||
+14
-11
@@ -234,25 +234,28 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
b4_namespace_close
|
b4_namespace_close
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_shared_declarations
|
|
||||||
# ----------------------
|
# b4_shared_declarations(hh|cc)
|
||||||
# Declaration that might either go into the header (if --defines)
|
# -----------------------------
|
||||||
# or open coded in the parser body.
|
# Declaration that might either go into the header (if --defines, $1 = hh)
|
||||||
|
# or in the implementation file.
|
||||||
m4_define([b4_shared_declarations],
|
m4_define([b4_shared_declarations],
|
||||||
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||||
b4_percent_code_get([[requires]])[
|
b4_percent_code_get([[requires]])[
|
||||||
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#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_YYDEBUG_define[
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
]b4_defines_if([],
|
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||||
[b4_bison_locations_if([b4_position_define
|
[b4_location_define])])[
|
||||||
b4_location_define])])[
|
|
||||||
|
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
class ]b4_parser_class_name[
|
class ]b4_parser_class_name[
|
||||||
@@ -336,7 +339,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]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
|
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||||
# arguments include the parser itself.
|
# arguments include the parser itself.
|
||||||
|
|||||||
+73
-51
@@ -20,6 +20,7 @@ m4_include(b4_pkgdatadir/[c++.m4])
|
|||||||
# api.value.type=variant is valid.
|
# api.value.type=variant is valid.
|
||||||
m4_define([b4_value_type_setup_variant])
|
m4_define([b4_value_type_setup_variant])
|
||||||
|
|
||||||
|
|
||||||
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
# 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
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([_b4_rhs_value],
|
||||||
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
|
[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)
|
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
@@ -106,7 +112,7 @@ b4_dollar_pushdef([yysym.value],
|
|||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[m4_dquote(b4_symbol([$1], [type]))]),
|
[m4_dquote(b4_symbol([$1], [type]))]),
|
||||||
[yysym.location])dnl
|
[yysym.location])dnl
|
||||||
b4_symbol_case_([$1])
|
_b4_symbol_case([$1])
|
||||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||||
b4_symbol([$1], [$2])
|
b4_symbol([$1], [$2])
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])
|
||||||
@@ -142,10 +148,11 @@ b4_bison_locations_if([# Backward compatibility.
|
|||||||
m4_include(b4_pkgdatadir/[stack.hh])
|
m4_include(b4_pkgdatadir/[stack.hh])
|
||||||
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
|
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
|
||||||
|
|
||||||
|
|
||||||
# b4_shared_declarations(hh|cc)
|
# b4_shared_declarations(hh|cc)
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Declaration that might either go into the header (if --defines, $1 = hh)
|
# 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],
|
m4_define([b4_shared_declarations],
|
||||||
[b4_percent_code_get([[requires]])[
|
[b4_percent_code_get([[requires]])[
|
||||||
]b4_parse_assert_if([# include <cassert>])[
|
]b4_parse_assert_if([# include <cassert>])[
|
||||||
@@ -153,21 +160,23 @@ m4_define([b4_shared_declarations],
|
|||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <stdexcept>
|
# include <stdexcept>
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <vector>]b4_defines_if([[
|
# include <vector>
|
||||||
# include "stack.hh"
|
|
||||||
]b4_bison_locations_if([[# include "location.hh"]])])[
|
]b4_cxx_portability[
|
||||||
|
]m4_ifdef([b4_location_include],
|
||||||
|
[[# include ]b4_location_include])[
|
||||||
]b4_variant_if([b4_variant_includes])[
|
]b4_variant_if([b4_variant_includes])[
|
||||||
|
|
||||||
]b4_attribute_define[
|
]b4_attribute_define[
|
||||||
]b4_null_define[
|
]b4_null_define[
|
||||||
|
|
||||||
]b4_YYDEBUG_define[
|
]b4_YYDEBUG_define[
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
|
|
||||||
]b4_defines_if([],
|
]b4_stack_define[
|
||||||
[b4_stack_define
|
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||||
b4_bison_locations_if([b4_position_define
|
[b4_location_define])])[
|
||||||
b4_location_define])])[
|
|
||||||
|
|
||||||
]b4_variant_if([b4_variant_define])[
|
]b4_variant_if([b4_variant_define])[
|
||||||
|
|
||||||
@@ -176,6 +185,7 @@ b4_location_define])])[
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
]b4_public_types_declare[
|
]b4_public_types_declare[
|
||||||
|
]b4_symbol_type_declare[
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
||||||
virtual ~]b4_parser_class_name[ ();
|
virtual ~]b4_parser_class_name[ ();
|
||||||
@@ -206,6 +216,8 @@ b4_location_define])])[
|
|||||||
/// Report a syntax error.
|
/// Report a syntax error.
|
||||||
void error (const syntax_error& err);
|
void error (const syntax_error& err);
|
||||||
|
|
||||||
|
]b4_symbol_constructor_declare[
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// This class is not copyable.
|
/// This class is not copyable.
|
||||||
]b4_parser_class_name[ (const ]b4_parser_class_name[&);
|
]b4_parser_class_name[ (const ]b4_parser_class_name[&);
|
||||||
@@ -315,12 +327,14 @@ b4_location_define])])[
|
|||||||
typedef basic_symbol<by_state> super_type;
|
typedef basic_symbol<by_state> super_type;
|
||||||
/// Construct an empty symbol.
|
/// Construct an empty symbol.
|
||||||
stack_symbol_type ();
|
stack_symbol_type ();
|
||||||
/// Copy construct (for efficiency).
|
/// Move or copy construction.
|
||||||
stack_symbol_type (const stack_symbol_type& that);
|
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
|
||||||
/// Steal the contents from \a sym to build this.
|
/// Steal the contents from \a sym to build this.
|
||||||
stack_symbol_type (state_type s, symbol_type& sym);
|
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||||
/// Assignment, needed by push_back.
|
#if defined __cplusplus && __cplusplus < 201103L
|
||||||
stack_symbol_type& operator= (const stack_symbol_type& that);
|
/// Assignment, needed by push_back by some old implementations.
|
||||||
|
stack_symbol_type& operator= (YY_MOVE_REF (stack_symbol_type) that);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Stack type.
|
/// Stack type.
|
||||||
@@ -332,17 +346,17 @@ b4_location_define])])[
|
|||||||
/// Push a new state on the stack.
|
/// Push a new state on the stack.
|
||||||
/// \param m a debug message to display
|
/// \param m a debug message to display
|
||||||
/// if null, no trace is output.
|
/// if null, no trace is output.
|
||||||
/// \param s the symbol
|
/// \param sym the symbol
|
||||||
/// \warning the contents of \a s.value is stolen.
|
/// \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.
|
/// Push a new look ahead token on the state on the stack.
|
||||||
/// \param m a debug message to display
|
/// \param m a debug message to display
|
||||||
/// if null, no trace is output.
|
/// if null, no trace is output.
|
||||||
/// \param s the state
|
/// \param s the state
|
||||||
/// \param sym the symbol (for its value and location).
|
/// \param sym the symbol (for its value and location).
|
||||||
/// \warning the contents of \a s.value is stolen.
|
/// \warning the contents of \a sym.value is stolen.
|
||||||
void yypush_ (const char* m, state_type s, symbol_type& sym);
|
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||||
|
|
||||||
/// Pop \a n symbols the three stacks.
|
/// Pop \a n symbols the three stacks.
|
||||||
void yypop_ (unsigned n = 1);
|
void yypop_ (unsigned n = 1);
|
||||||
@@ -391,7 +405,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
|
|||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_shared_declarations(hh)[
|
]b4_shared_declarations(hh)[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])
|
]b4_cpp_guard_close([b4_spec_defines_file])
|
||||||
b4_output_end()
|
b4_output_end
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -401,13 +415,11 @@ b4_percent_code_get([[top]])[]dnl
|
|||||||
m4_if(b4_prefix, [yy], [],
|
m4_if(b4_prefix, [yy], [],
|
||||||
[
|
[
|
||||||
// Take the name prefix into account.
|
// Take the name prefix into account.
|
||||||
#define yylex b4_prefix[]lex])[
|
[#]define yylex b4_prefix[]lex])[
|
||||||
|
|
||||||
// First part of user declarations.
|
// First part of user declarations.
|
||||||
]b4_user_pre_prologue[
|
]b4_user_pre_prologue[
|
||||||
|
|
||||||
]b4_null_define[
|
|
||||||
|
|
||||||
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
||||||
[b4_shared_declarations([cc])])[
|
[b4_shared_declarations([cc])])[
|
||||||
|
|
||||||
@@ -585,34 +597,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 ()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
|
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
|
||||||
: super_type (that.state]b4_locations_if([, that.location])[)
|
: 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], [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_variant_if([
|
{]b4_variant_if([
|
||||||
b4_symbol_variant([that.type_get ()],
|
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 is emptied.
|
||||||
that.type = empty_symbol;
|
that.type = empty_symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined __cplusplus && __cplusplus < 201103L
|
||||||
]b4_parser_class_name[::stack_symbol_type&
|
]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= (YY_MOVE_REF (stack_symbol_type) that)
|
||||||
{
|
{
|
||||||
state = that.state;
|
state = that.state;
|
||||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
||||||
[value], [copy], [that.value])],
|
[value], [move], [YY_MOVE (that.value)])],
|
||||||
[[value = that.value;]])[]b4_locations_if([
|
[[value = YY_MOVE (that.value);]])[]b4_locations_if([
|
||||||
location = that.location;])[
|
location = YY_MOVE (that.location);])[
|
||||||
|
// that is emptied.
|
||||||
|
that.state = empty_state;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
void
|
void
|
||||||
@@ -647,18 +665,22 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym)
|
]b4_parser_class_name[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
|
||||||
{
|
{
|
||||||
stack_symbol_type t (s, sym);
|
if (m)
|
||||||
yypush_ (m, t);
|
YY_SYMBOL_PRINT (m, sym);
|
||||||
|
yystack_.push (YY_MOVE (sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
|
]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
|
||||||
{
|
{
|
||||||
if (m)
|
#if defined __cplusplus && 201103L <= __cplusplus
|
||||||
YY_SYMBOL_PRINT (m, s);
|
yypush_ (m, stack_symbol_type (s, YY_MOVE (sym)));
|
||||||
yystack_.push (s);
|
#else
|
||||||
|
stack_symbol_type ss (s, sym);
|
||||||
|
yypush_ (m, ss);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -754,7 +776,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
location values to have been already stored, initialize these
|
location values to have been already stored, initialize these
|
||||||
stacks with a primary value. */
|
stacks with a primary value. */
|
||||||
yystack_.clear ();
|
yystack_.clear ();
|
||||||
yypush_ (YY_NULLPTR, 0, yyla);
|
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
|
||||||
|
|
||||||
// A new symbol was pushed on the stack.
|
// A new symbol was pushed on the stack.
|
||||||
yynewstate:
|
yynewstate:
|
||||||
@@ -816,7 +838,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
--yyerrstatus_;
|
--yyerrstatus_;
|
||||||
|
|
||||||
// Shift the lookahead token.
|
// Shift the lookahead token.
|
||||||
yypush_ ("Shifting", yyn, yyla);
|
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
/*-----------------------------------------------------------.
|
/*-----------------------------------------------------------.
|
||||||
@@ -885,7 +907,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
YY_STACK_PRINT ();
|
YY_STACK_PRINT ();
|
||||||
|
|
||||||
// Shift the result of the reduction.
|
// Shift the result of the reduction.
|
||||||
yypush_ (YY_NULLPTR, yylhs);
|
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
|
||||||
}
|
}
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
@@ -974,7 +996,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
|
|
||||||
// Shift the error token.
|
// Shift the error token.
|
||||||
error_token.state = yyn;
|
error_token.state = yyn;
|
||||||
yypush_ ("Shifting", error_token);
|
yypush_ ("Shifting", YY_MOVE (error_token));
|
||||||
}
|
}
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
@@ -1180,7 +1202,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
|||||||
]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
|
]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
b4_output_end()
|
b4_output_end
|
||||||
|
|
||||||
|
|
||||||
m4_popdef([b4_copyright_years])dnl
|
m4_popdef([b4_copyright_years])dnl
|
||||||
|
|||||||
+1
-1
@@ -1068,4 +1068,4 @@ b4_percent_code_get[]dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
b4_epilogue[]dnl
|
b4_epilogue[]dnl
|
||||||
b4_output_end()
|
b4_output_end
|
||||||
|
|||||||
+68
-39
@@ -18,10 +18,47 @@
|
|||||||
m4_pushdef([b4_copyright_years],
|
m4_pushdef([b4_copyright_years],
|
||||||
[2002-2015, 2018])
|
[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.
|
# Define the position and location classes.
|
||||||
m4_define([b4_position_define],
|
m4_define([b4_location_define],
|
||||||
[[ /// Abstract a position.
|
[[ /// Abstract a position.
|
||||||
class position
|
class position
|
||||||
{
|
{
|
||||||
@@ -73,10 +110,11 @@ m4_define([b4_position_define],
|
|||||||
unsigned column;
|
unsigned column;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Compute max(min, lhs+rhs).
|
/// Compute max (min, lhs+rhs).
|
||||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
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 << ':';
|
ostr << *pos.filename << ':';
|
||||||
return ostr << pos.line << '.' << pos.column;
|
return ostr << pos.line << '.' << pos.column;
|
||||||
}
|
}
|
||||||
]])
|
|
||||||
|
|
||||||
|
/// Abstract a location.
|
||||||
# b4_location_define
|
|
||||||
# ------------------
|
|
||||||
m4_define([b4_location_define],
|
|
||||||
[[ /// Abstract a location.
|
|
||||||
class location
|
class location
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -287,16 +320,31 @@ m4_define([b4_location_define],
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
b4_defines_if([
|
m4_ifdef([b4_position_file], [[
|
||||||
b4_output_begin([b4_dir_prefix[]position.hh])
|
]b4_output_begin([b4_dir_prefix], [b4_position_file])[
|
||||||
b4_copyright([Positions for Bison parsers in C++])[
|
// 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
|
** \file ]b4_location_path[
|
||||||
** Define the ]b4_namespace_ref[::position class.
|
** 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 <algorithm> // std::max
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
@@ -304,31 +352,12 @@ b4_copyright([Positions for Bison parsers in C++])[
|
|||||||
|
|
||||||
]b4_null_define[
|
]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_namespace_open[
|
||||||
]b4_location_define[
|
]b4_location_define[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
]b4_cpp_guard_close([b4_location_path])[
|
||||||
b4_output_end()
|
]b4_output_end[
|
||||||
])
|
]])
|
||||||
|
|
||||||
|
|
||||||
m4_popdef([b4_copyright_years])
|
m4_popdef([b4_copyright_years])
|
||||||
|
|||||||
+19
-26
@@ -15,8 +15,13 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
# b4_stack_define
|
||||||
# ---------------
|
# ---------------
|
||||||
@@ -62,9 +67,9 @@ m4_define([b4_stack_define],
|
|||||||
///
|
///
|
||||||
/// Close to move-semantics.
|
/// Close to move-semantics.
|
||||||
void
|
void
|
||||||
push (T& t)
|
push (YY_MOVE_REF (T) t)
|
||||||
{
|
{
|
||||||
seq_.push_back (T());
|
seq_.push_back (T ());
|
||||||
operator[](0).move (t);
|
operator[](0).move (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,25 +134,13 @@ m4_define([b4_stack_define],
|
|||||||
};
|
};
|
||||||
]])
|
]])
|
||||||
|
|
||||||
b4_defines_if(
|
m4_ifdef([b4_stack_file],
|
||||||
[b4_output_begin([b4_dir_prefix[]stack.hh])
|
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
||||||
b4_copyright([Stack handling for Bison parsers in C++])[
|
// Starting with Bison 3.2, this file is useless: the structure it
|
||||||
|
// used to define is now defined with the parser itself.
|
||||||
/**
|
//
|
||||||
** \file ]b4_dir_prefix[stack.hh
|
// To get rid of this file:
|
||||||
** Define the ]b4_namespace_ref[::stack class.
|
// 1. add 'require "3.2"' (or newer) to your grammar file
|
||||||
*/
|
// 2. remove references to this file from your build system.
|
||||||
|
]b4_output_end[
|
||||||
]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])
|
|
||||||
|
|||||||
+51
-35
@@ -29,7 +29,7 @@ m4_define([b4_symbol_variant],
|
|||||||
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
||||||
switch ($1)
|
switch ($1)
|
||||||
{
|
{
|
||||||
b4_type_foreach([b4_type_action_])[]dnl
|
b4_type_foreach([_b4_type_action])[]dnl
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -55,15 +55,15 @@ dummy[]_b4_char_sizeof_counter])
|
|||||||
# ---------------------------
|
# ---------------------------
|
||||||
# To be mapped on the list of type names to produce:
|
# To be mapped on the list of type names to produce:
|
||||||
#
|
#
|
||||||
# char dummy1[sizeof(type_name_1)];
|
# char dummy1[sizeof (type_name_1)];
|
||||||
# char dummy2[sizeof(type_name_2)];
|
# char dummy2[sizeof (type_name_2)];
|
||||||
#
|
#
|
||||||
# for defined type names.
|
# for defined type names.
|
||||||
m4_define([b4_char_sizeof],
|
m4_define([b4_char_sizeof],
|
||||||
[b4_symbol_if([$1], [has_type],
|
[b4_symbol_if([$1], [has_type],
|
||||||
[
|
[
|
||||||
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
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.
|
/// Construct and fill.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
variant (const T& t)]b4_parse_assert_if([
|
variant (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||||
: yytypeid_ (&typeid (T))])[
|
: yytypeid_ (&typeid (T))])[
|
||||||
{
|
{
|
||||||
YYASSERT (sizeof (T) <= S);
|
YYASSERT (sizeof (T) <= S);
|
||||||
new (yyas_<T> ()) T (t);
|
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destruction, allowed only if empty.
|
/// Destruction, allowed only if empty.
|
||||||
@@ -163,7 +163,7 @@ m4_define([b4_variant_define],
|
|||||||
/// Both variants must be built beforehand, because swapping the actual
|
/// Both variants must be built beforehand, because swapping the actual
|
||||||
/// data requires reading it (with as()), and this is not possible on
|
/// data requires reading it (with as()), and this is not possible on
|
||||||
/// unconstructed variants: it would require some dynamic testing, which
|
/// 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
|
/// Swapping between built and (possibly) non-built is done with
|
||||||
/// variant::move ().
|
/// variant::move ().
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -183,10 +183,26 @@ m4_define([b4_variant_define],
|
|||||||
move (self_type& other)
|
move (self_type& other)
|
||||||
{
|
{
|
||||||
build<T> ();
|
build<T> ();
|
||||||
|
# if defined __cplusplus && 201103L <= __cplusplus
|
||||||
|
as<T> () = YY_MOVE (other.as<T> ());
|
||||||
|
# else
|
||||||
swap<T> (other);
|
swap<T> (other);
|
||||||
|
# endif
|
||||||
other.destroy<T> ();
|
other.destroy<T> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if defined __cplusplus && 201103L <= __cplusplus
|
||||||
|
/// Move the content of \a other to this.
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
move (self_type&& other)
|
||||||
|
{
|
||||||
|
build<T> ();
|
||||||
|
as<T> () = YY_MOVE (other.as<T> ());
|
||||||
|
other.destroy<T> ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Copy the content of \a other to this.
|
/// Copy the content of \a other to this.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void
|
void
|
||||||
@@ -206,7 +222,7 @@ m4_define([b4_variant_define],
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prohibit blind copies.
|
/// Prohibit blind copies.
|
||||||
self_type& operator=(const self_type&);
|
self_type& operator= (const self_type&);
|
||||||
variant (const self_type&);
|
variant (const self_type&);
|
||||||
|
|
||||||
/// Accessor to raw memory as \a T.
|
/// Accessor to raw memory as \a T.
|
||||||
@@ -255,7 +271,7 @@ m4_define([b4_value_type_declare],
|
|||||||
{]b4_type_foreach([b4_char_sizeof])[};
|
{]b4_type_foreach([b4_char_sizeof])[};
|
||||||
|
|
||||||
/// Symbol semantic values.
|
/// Symbol semantic values.
|
||||||
typedef variant<sizeof(union_type)> semantic_type;][]dnl
|
typedef variant<sizeof (union_type)> semantic_type;][]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -283,18 +299,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
|
# Declare the overloaded version of make_symbol for the (common) type of
|
||||||
# these SYMBOL-NUMBERS. Use at class-level.
|
# 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],
|
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
||||||
[ static inline
|
[ static
|
||||||
symbol_type
|
symbol_type
|
||||||
make_[]b4_symbol_([$1], [id]) (dnl
|
make_[]_b4_symbol([$1], [id]) (dnl
|
||||||
b4_join(b4_symbol_if([$1], [has_type],
|
b4_join(b4_symbol_if([$1], [has_type],
|
||||||
[const b4_symbol([$1], [type])& v]),
|
[YY_COPY (b4_symbol([$1], [type])) v]),
|
||||||
b4_locations_if([const location_type& l])));
|
b4_locations_if([YY_COPY (location_type) l])));
|
||||||
|
|
||||||
])])])
|
])])])
|
||||||
|
|
||||||
@@ -305,24 +321,25 @@ b4_join(b4_symbol_if([$1], [has_type],
|
|||||||
# Use at class-level.
|
# Use at class-level.
|
||||||
m4_define([b4_symbol_constructor_declare],
|
m4_define([b4_symbol_constructor_declare],
|
||||||
[ // Symbol constructors declarations.
|
[ // 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.
|
# 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_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
||||||
[ b4_parser_class_name::symbol_type
|
[ inline
|
||||||
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
|
b4_parser_class_name::symbol_type
|
||||||
|
b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl
|
||||||
b4_join(b4_symbol_if([$1], [has_type],
|
b4_join(b4_symbol_if([$1], [has_type],
|
||||||
[const b4_symbol([$1], [type])& v]),
|
[YY_COPY (b4_symbol([$1], [type])) v]),
|
||||||
b4_locations_if([const location_type& l])))
|
b4_locations_if([YY_COPY (location_type) l])))
|
||||||
{
|
{
|
||||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||||
b4_symbol_if([$1], [has_type], [v]),
|
b4_symbol_if([$1], [has_type], [YY_MOVE (v)]),
|
||||||
b4_locations_if([l])));
|
b4_locations_if([YY_MOVE (l)])));
|
||||||
}
|
}
|
||||||
|
|
||||||
])])])
|
])])])
|
||||||
@@ -332,27 +349,26 @@ b4_join(b4_symbol_if([$1], [has_type],
|
|||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# Generate a constructor declaration for basic_symbol from given type.
|
# Generate a constructor declaration for basic_symbol from given type.
|
||||||
m4_define([b4_basic_symbol_constructor_declare],
|
m4_define([b4_basic_symbol_constructor_declare],
|
||||||
[[
|
[[ basic_symbol (]b4_join(
|
||||||
basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
[typename Base::kind_type t],
|
||||||
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
|
b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type])) v]),
|
||||||
b4_locations_if([const location_type& l]))[);
|
b4_locations_if([YY_RVREF (location_type) l]))[);
|
||||||
]])
|
]])
|
||||||
|
|
||||||
# b4_basic_symbol_constructor_define
|
# b4_basic_symbol_constructor_define
|
||||||
# ----------------------------------
|
# ----------------------------------
|
||||||
# Generate a constructor implementation for basic_symbol from given type.
|
# Generate a constructor implementation for basic_symbol from given type.
|
||||||
m4_define([b4_basic_symbol_constructor_define],
|
m4_define([b4_basic_symbol_constructor_define],
|
||||||
[[
|
[[ template <typename Base>
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||||
[typename Base::kind_type t],
|
[typename Base::kind_type t],
|
||||||
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
|
b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type])) v]),
|
||||||
b4_locations_if([const location_type& l]))[)
|
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||||
, value (v)])[]b4_locations_if([
|
, value (YY_MOVE (v))])[]b4_locations_if([
|
||||||
, location (l)])[
|
, location (YY_MOVE (l))])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
# b4_symbol_constructor_define
|
# b4_symbol_constructor_define
|
||||||
@@ -360,4 +376,4 @@ m4_define([b4_basic_symbol_constructor_define],
|
|||||||
# Define the overloaded versions of make_symbol for all the value types.
|
# Define the overloaded versions of make_symbol for all the value types.
|
||||||
m4_define([b4_symbol_constructor_define],
|
m4_define([b4_symbol_constructor_define],
|
||||||
[ // Implementation of make_symbol for each symbol type.
|
[ // Implementation of make_symbol for each symbol type.
|
||||||
b4_symbol_foreach([b4_symbol_constructor_define_])])
|
b4_symbol_foreach([_b4_symbol_constructor_define])])
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||||
<title>
|
<title>
|
||||||
<xsl:value-of select="bison-xml-report/filename"/>
|
<xsl:value-of select="bison-xml-report/filename"/>
|
||||||
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
||||||
|
|||||||
+8
-8
@@ -237,11 +237,11 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
|||||||
YYSIZE_T yyes_capacity;]])])
|
YYSIZE_T yyes_capacity;]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_declare_yyparse_push_
|
# _b4_declare_yyparse_push
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# Declaration of yyparse (and dependencies) when using the push parser
|
# Declaration of yyparse (and dependencies) when using the push parser
|
||||||
# (including in pull mode).
|
# (including in pull mode).
|
||||||
m4_define([b4_declare_yyparse_push_],
|
m4_define([_b4_declare_yyparse_push],
|
||||||
[[#ifndef YYPUSH_MORE_DEFINED
|
[[#ifndef YYPUSH_MORE_DEFINED
|
||||||
# define YYPUSH_MORE_DEFINED
|
# define YYPUSH_MORE_DEFINED
|
||||||
enum { YYPUSH_MORE = 4 };
|
enum { YYPUSH_MORE = 4 };
|
||||||
@@ -265,18 +265,18 @@ b4_function_declare([b4_prefix[pstate_delete]], [[void]],
|
|||||||
[[b4_prefix[pstate *ps]], [[ps]]])dnl
|
[[b4_prefix[pstate *ps]], [[ps]]])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_declare_yyparse_
|
# _b4_declare_yyparse
|
||||||
# -------------------
|
# -------------------
|
||||||
# When not the push parser.
|
# 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_function_declare(b4_prefix[parse], [int], b4_parse_param)])
|
||||||
|
|
||||||
|
|
||||||
# b4_declare_yyparse
|
# b4_declare_yyparse
|
||||||
# ------------------
|
# ------------------
|
||||||
m4_define([b4_declare_yyparse],
|
m4_define([b4_declare_yyparse],
|
||||||
[b4_push_if([b4_declare_yyparse_push_],
|
[b4_push_if([_b4_declare_yyparse_push],
|
||||||
[b4_declare_yyparse_])[]dnl
|
[_b4_declare_yyparse])[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -1908,12 +1908,12 @@ yypushreturn:]])[
|
|||||||
return yyresult;
|
return yyresult;
|
||||||
}
|
}
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
b4_output_end()
|
b4_output_end
|
||||||
|
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[b4_output_begin([b4_spec_defines_file])[
|
[b4_output_begin([b4_spec_defines_file])[
|
||||||
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||||
|
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_output_end()
|
]b4_output_end
|
||||||
])# b4_defines_if
|
])# 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
|
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,
|
run time. If LFN support is available (DOS session under Win9X, Win2K,
|
||||||
WinXP, etc.) the standard posix file name extensions will be used.
|
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
|
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" == "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 DependecyTracking
|
||||||
if "%1" == "DEP" goto DependecyTraking
|
if "%1" == "DEP" goto DependecyTracking
|
||||||
goto LibiconvPrefixOption
|
goto LibiconvPrefixOption
|
||||||
:DependecyTraking
|
:DependecyTracking
|
||||||
if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
|
if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
|
||||||
if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
|
if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
|
||||||
if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
|
if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
|
||||||
@@ -290,7 +290,7 @@ if errorlevel 1 goto SedError2
|
|||||||
mv -f config.hin %XSRC%/lib/config.hin
|
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
|
test -f %XSRC%/tests/c++.at
|
||||||
if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.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
|
if errorlevel 1 goto SedError3
|
||||||
mv -f ./testsuite.tmp %XSRC%/tests/testsuite
|
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++
|
test -d %XSRC%/examples/calc++
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
|
if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
|
||||||
test -d %XSRC%/examples/calcxx
|
test -d %XSRC%/examples/calcxx
|
||||||
|
|||||||
+1
-1
@@ -1405,7 +1405,7 @@ EXT_LINKS_IN_WINDOW = NO
|
|||||||
|
|
||||||
FORMULA_FONTSIZE = 10
|
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
|
# generated for formulas are transparent PNGs. Transparent PNGs are not
|
||||||
# supported properly for IE 6.0, but are supported on all modern browsers.
|
# supported properly for IE 6.0, but are supported on all modern browsers.
|
||||||
#
|
#
|
||||||
|
|||||||
+415
-198
File diff suppressed because it is too large
Load Diff
+1
-3
@@ -30,9 +30,7 @@ $(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
|||||||
$(doc_bison).html: $(FIGS_GV:.gv=.png)
|
$(doc_bison).html: $(FIGS_GV:.gv=.png)
|
||||||
|
|
||||||
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
||||||
CLEANDIRS = doc/bison.t2d
|
CLEANDIRS += doc/bison.t2d
|
||||||
clean-local:
|
|
||||||
rm -rf $(CLEANDIRS)
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
|
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ will generate eight different cases.
|
|||||||
|
|
||||||
=item B<-b>, B<--bench>
|
=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.
|
request.
|
||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|||||||
+45
-24
@@ -1,17 +1,46 @@
|
|||||||
This directory contains examples of Bison grammar files.
|
This directory contains examples of Bison grammar files.
|
||||||
|
|
||||||
* mfcalc
|
Most of them come from the documentation, which should be installed together
|
||||||
A C example of a multi-function calculator. Extracted from the
|
with Bison. The URLs are provided for convenience.
|
||||||
documentation.
|
|
||||||
|
|
||||||
* calc++
|
|
||||||
A C++ version of the canonical example for parsers: a calculator. Also uses
|
|
||||||
Flex for the scanner. Extracted from the documentation.
|
|
||||||
|
|
||||||
* variant.yy
|
* Examples in C
|
||||||
A C++ example that uses variants (they allow to use any C++ type as semantic
|
|
||||||
value type) and symbol constructors (they ensure consistency between
|
** rpcalc - Reverse Polish Notation Calculator
|
||||||
declared token type and effective semantic value).
|
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++
|
||||||
|
|
||||||
|
** variant.yy - Self-contained example in C++
|
||||||
|
A simple C++ example in a single file, 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.
|
||||||
|
|
||||||
|
** variant-11.yy - Self-contained example in modern C++
|
||||||
|
Another simple C++ example, closely related to the previous one, but
|
||||||
|
exhibiting support for C++11's move semantics.
|
||||||
|
|
||||||
|
** 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
|
||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@@ -22,19 +51,11 @@ End:
|
|||||||
|
|
||||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
Copyright (C) 2018 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
This program is free software: you can redistribute it and/or modify
|
any later version published by the Free Software Foundation; with no
|
||||||
it under the terms of the GNU General Public License as published by
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
(at your option) any later version.
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# LocalWords: mfcalc calc parsers yy
|
# LocalWords: mfcalc calc parsers yy
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ CLEANFILES += \
|
|||||||
%D%/parser.output \
|
%D%/parser.output \
|
||||||
%D%/parser.stamp \
|
%D%/parser.stamp \
|
||||||
%D%/scanner.cc
|
%D%/scanner.cc
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
|
|
||||||
## -------------------- ##
|
## -------------------- ##
|
||||||
## Building & testing. ##
|
## Building & testing. ##
|
||||||
|
|||||||
+19
-2
@@ -32,9 +32,24 @@
|
|||||||
# output before block 2, even if the latter appears before). The same
|
# output before block 2, even if the latter appears before). The same
|
||||||
# number may be used several time, in which case the order of
|
# number may be used several time, in which case the order of
|
||||||
# appearance is used.
|
# 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 strict;
|
||||||
|
|
||||||
|
use File::Basename qw(dirname);
|
||||||
|
use File::Path qw(make_path);
|
||||||
|
|
||||||
# Whether we generate synclines.
|
# Whether we generate synclines.
|
||||||
my $synclines = 0;
|
my $synclines = 0;
|
||||||
|
|
||||||
@@ -80,7 +95,9 @@ sub file_wanted ($)
|
|||||||
undef
|
undef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# process ($in)
|
||||||
|
# -------------
|
||||||
|
# Read input file $in, and generate the outputs.
|
||||||
sub process ($)
|
sub process ($)
|
||||||
{
|
{
|
||||||
my ($in) = @_;
|
my ($in) = @_;
|
||||||
@@ -140,7 +157,7 @@ sub process ($)
|
|||||||
# Output the files.
|
# Output the files.
|
||||||
for my $file (keys %file)
|
for my $file (keys %file)
|
||||||
{
|
{
|
||||||
# No spurious end of line: use printf.
|
make_path (dirname ($file));
|
||||||
my $o = new IO::File(">$file")
|
my $o = new IO::File(">$file")
|
||||||
or die "$file: cannot create: $?";
|
or die "$file: cannot create: $?";
|
||||||
print $o $file{$file}{$_}
|
print $o $file{$file}{$_}
|
||||||
|
|||||||
+15
-1
@@ -33,6 +33,7 @@ extracted =
|
|||||||
CLEANFILES += $(extracted) %D%/extracted.stamp
|
CLEANFILES += $(extracted) %D%/extracted.stamp
|
||||||
%D%/extracted.stamp: $(doc) $(extexi)
|
%D%/extracted.stamp: $(doc) $(extexi)
|
||||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||||
|
$(AM_V_at)$(MKDIR_P) %D%
|
||||||
$(AM_V_at)touch $@.tmp
|
$(AM_V_at)touch $@.tmp
|
||||||
$(AM_V_at)$(extract) $(extracted)
|
$(AM_V_at)$(extract) $(extracted)
|
||||||
$(AM_V_at)mv $@.tmp $@
|
$(AM_V_at)mv $@.tmp $@
|
||||||
@@ -45,14 +46,27 @@ $(extracted): %D%/extracted.stamp
|
|||||||
## Examples. ##
|
## Examples. ##
|
||||||
## ---------- ##
|
## ---------- ##
|
||||||
|
|
||||||
|
|
||||||
examplesdir = $(docdir)/examples
|
examplesdir = $(docdir)/examples
|
||||||
dist_examples_DATA = %D%/README %D%/variant.yy
|
dist_examples_DATA = %D%/README %D%/variant.yy %D%/variant-11.yy
|
||||||
|
|
||||||
check_PROGRAMS += %D%/variant
|
check_PROGRAMS += %D%/variant
|
||||||
nodist_%C%_variant_SOURCES = %D%/variant.yy
|
nodist_%C%_variant_SOURCES = %D%/variant.yy
|
||||||
%C%_variant_CPPFLAGS = -I$(top_builddir)
|
%C%_variant_CPPFLAGS = -I$(top_builddir)
|
||||||
dist_TESTS += %D%/variant.test
|
dist_TESTS += %D%/variant.test
|
||||||
|
%D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
||||||
|
|
||||||
|
if ENABLE_CXX11
|
||||||
|
check_PROGRAMS += %D%/variant-11
|
||||||
|
nodist_%C%_variant_11_SOURCES = %D%/variant-11.yy
|
||||||
|
%C%_variant_11_CXXFLAGS = $(CXX11_CXXFLAGS)
|
||||||
|
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
|
||||||
|
dist_TESTS += %D%/variant-11.test
|
||||||
|
%D%/variant-11.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CLEANFILES += %D%/variant.output %D%/variant-11.output
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
|
|
||||||
include %D%/calc++/local.mk
|
include %D%/calc++/local.mk
|
||||||
include %D%/mfcalc/local.mk
|
include %D%/mfcalc/local.mk
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
BUILT_SOURCES += $(mfcalc_sources)
|
BUILT_SOURCES += $(mfcalc_sources)
|
||||||
CLEANFILES += %D%/mfcalc.[ch] %D%/mfcalc.output
|
CLEANFILES += %D%/mfcalc.[ch] %D%/mfcalc.output
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
|
|
||||||
mfcalc_extracted = %D%/calc.h %D%/mfcalc.y
|
mfcalc_extracted = %D%/calc.h %D%/mfcalc.y
|
||||||
mfcalc_sources = $(mfcalc_extracted)
|
mfcalc_sources = $(mfcalc_extracted)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
BUILT_SOURCES += $(rpcalc_sources)
|
BUILT_SOURCES += $(rpcalc_sources)
|
||||||
CLEANFILES += %D%/rpcalc.[ch] %D%/rpcalc.output
|
CLEANFILES += %D%/rpcalc.[ch] %D%/rpcalc.output
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
|
|
||||||
rpcalc_extracted = %D%/rpcalc.y
|
rpcalc_extracted = %D%/rpcalc.y
|
||||||
rpcalc_sources = $(rpcalc_extracted)
|
rpcalc_sources = $(rpcalc_extracted)
|
||||||
|
|||||||
+4
-4
@@ -23,7 +23,7 @@ number=1
|
|||||||
# Exit status of this script.
|
# Exit status of this script.
|
||||||
exit=true
|
exit=true
|
||||||
|
|
||||||
# top_buiddir.
|
# top_builddir.
|
||||||
cwd=`pwd`
|
cwd=`pwd`
|
||||||
|
|
||||||
# The exercised program.
|
# The exercised program.
|
||||||
@@ -60,16 +60,16 @@ cd $$.dir
|
|||||||
run ()
|
run ()
|
||||||
{
|
{
|
||||||
# Expected exit status.
|
# Expected exit status.
|
||||||
local sta_exp=$1
|
local sta_exp="$1"
|
||||||
shift
|
shift
|
||||||
# Expected output.
|
# Expected output.
|
||||||
local out_exp=$1
|
local out_exp="$1"
|
||||||
shift
|
shift
|
||||||
# Effective exit status.
|
# Effective exit status.
|
||||||
local sta_eff=0
|
local sta_eff=0
|
||||||
$prog "$@" - <input >out_eff || sta_eff=$?
|
$prog "$@" - <input >out_eff || sta_eff=$?
|
||||||
# Effective output.
|
# Effective output.
|
||||||
local out_eff=`cat out_eff`
|
local out_eff="`cat out_eff`"
|
||||||
if test $sta_eff -eq $sta_exp; then
|
if test $sta_eff -eq $sta_exp; then
|
||||||
if test "$out_eff" = "$out_exp"; then
|
if test "$out_eff" = "$out_exp"; then
|
||||||
echo "$me: PASS: $number"
|
echo "$me: PASS: $number"
|
||||||
|
|||||||
@@ -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,161 @@
|
|||||||
|
/*
|
||||||
|
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)...});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to string.
|
||||||
|
template <typename T>
|
||||||
|
std::string
|
||||||
|
to_string (const T& t)
|
||||||
|
{
|
||||||
|
auto&& o = std::ostringstream{};
|
||||||
|
o << t;
|
||||||
|
return o.str ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%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 (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 3
|
||||||
|
// TEXT "And that's all!"
|
||||||
|
// END_OF_FILE
|
||||||
|
|
||||||
|
static
|
||||||
|
parser::symbol_type
|
||||||
|
yylex ()
|
||||||
|
{
|
||||||
|
static auto count = 0u;
|
||||||
|
auto stage = count;
|
||||||
|
++count;
|
||||||
|
auto loc = parser::location_type{nullptr, stage + 1, 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], YY_NULLPTR, 10);
|
||||||
|
auto&& p = yy::parser{};
|
||||||
|
p.set_debug_level (!!getenv ("YYDEBUG"));
|
||||||
|
return p.parse ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: C++
|
||||||
|
// End:
|
||||||
+10
-13
@@ -15,11 +15,12 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
%require "3.2"
|
||||||
%debug
|
%debug
|
||||||
%language "c++"
|
%language "c++"
|
||||||
%defines
|
|
||||||
%define api.token.constructor
|
%define api.token.constructor
|
||||||
%define api.value.type variant
|
%define api.value.type variant
|
||||||
|
%define api.location.file none
|
||||||
%define parse.assert
|
%define parse.assert
|
||||||
%locations
|
%locations
|
||||||
|
|
||||||
@@ -37,22 +38,18 @@ typedef std::vector<std::string> strings_type;
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Prototype of the yylex function providing subsequent tokens.
|
|
||||||
namespace yy
|
namespace yy
|
||||||
{
|
{
|
||||||
|
// Prototype of the yylex function providing subsequent tokens.
|
||||||
static parser::symbol_type yylex ();
|
static parser::symbol_type yylex ();
|
||||||
}
|
|
||||||
|
|
||||||
// Printing a vector of strings.
|
// Print a vector of strings.
|
||||||
// Koening look up will look into std, since that's an std::vector.
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<< (std::ostream& o, const strings_type& ss)
|
operator<< (std::ostream& o, const strings_type& ss)
|
||||||
{
|
{
|
||||||
o << '{';
|
o << '{';
|
||||||
const char *sep = "";
|
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)
|
i != end; ++i)
|
||||||
{
|
{
|
||||||
o << sep << *i;
|
o << sep << *i;
|
||||||
@@ -62,10 +59,10 @@ typedef std::vector<std::string> strings_type;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conversion to string.
|
// Convert to string.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::string
|
std::string
|
||||||
string_cast (const T& t)
|
to_string (const T& t)
|
||||||
{
|
{
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
o << t;
|
o << t;
|
||||||
@@ -93,8 +90,8 @@ list:
|
|||||||
;
|
;
|
||||||
|
|
||||||
item:
|
item:
|
||||||
TEXT { std::swap ($$, $1); }
|
TEXT
|
||||||
| NUMBER { $$ = string_cast ($1); }
|
| NUMBER { $$ = to_string ($1); }
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -114,7 +111,7 @@ namespace yy
|
|||||||
{
|
{
|
||||||
static int stage = -1;
|
static int stage = -1;
|
||||||
++stage;
|
++stage;
|
||||||
parser::location_type loc(YY_NULLPTR, stage + 1, stage + 1);
|
parser::location_type loc (YY_NULLPTR, stage + 1, stage + 1);
|
||||||
switch (stage)
|
switch (stage)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
+1
-1
Submodule gnulib updated: a05181f4bd...a79f2a2871
@@ -273,3 +273,19 @@
|
|||||||
/xstrndup.h
|
/xstrndup.h
|
||||||
/stat-time.c
|
/stat-time.c
|
||||||
/stat-time.h
|
/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
|
||||||
|
|||||||
+58
-101
@@ -36,10 +36,10 @@ static bitset_bindex
|
|||||||
abitset_resize (bitset src, bitset_bindex size)
|
abitset_resize (bitset src, bitset_bindex size)
|
||||||
{
|
{
|
||||||
/* These bitsets have a fixed size. */
|
/* These bitsets have a fixed size. */
|
||||||
if (BITSET_SIZE_ (src) != size)
|
if (BITSET_SIZE_ (src) != size)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find list of up to NUM bits set in BSET starting from and including
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
@@ -49,19 +49,14 @@ static bitset_bindex
|
|||||||
abitset_small_list (bitset src, bitset_bindex *list,
|
abitset_small_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_word word = ABITSET_WORDS (src)[0];
|
||||||
bitset_bindex count;
|
|
||||||
bitset_windex size;
|
|
||||||
bitset_word word;
|
|
||||||
|
|
||||||
word = ABITSET_WORDS (src)[0];
|
|
||||||
|
|
||||||
/* Short circuit common case. */
|
/* Short circuit common case. */
|
||||||
if (!word)
|
if (!word)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size = BITSET_SIZE_ (src);
|
bitset_windex size = BITSET_SIZE_ (src);
|
||||||
bitno = *next;
|
bitset_bindex bitno = *next;
|
||||||
if (bitno >= size)
|
if (bitno >= size)
|
||||||
return 0;
|
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
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
|
|
||||||
|
bitset_bindex count;
|
||||||
if (num >= BITSET_WORD_BITS)
|
if (num >= BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
for (count = 0; word; bitno++)
|
for (count = 0; word; bitno++)
|
||||||
@@ -142,16 +138,10 @@ static bitset_bindex
|
|||||||
abitset_list_reverse (bitset src, bitset_bindex *list,
|
abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
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 = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_bindex n_bits = BITSET_SIZE_ (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
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
@@ -159,19 +149,17 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
if (rbitno >= n_bits)
|
if (rbitno >= n_bits)
|
||||||
return 0;
|
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;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
bitcnt = bitno % BITSET_WORD_BITS;
|
unsigned bitcnt = bitno % BITSET_WORD_BITS;
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bitset_word word;
|
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
|
|
||||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
@@ -196,23 +184,21 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
|
|
||||||
|
|
||||||
/* Find list of up to NUM bits set in BSET starting from and including
|
/* 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
|
*NEXT and store in array LIST. Return with actual number of bits
|
||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_list (bitset src, bitset_bindex *list,
|
abitset_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
|
||||||
bitset_bindex count;
|
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
bitset_bindex bitoff;
|
bitset_bindex bitoff;
|
||||||
bitset_windex size = src->b.csize;
|
bitset_windex size = src->b.csize;
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
bitno = *next;
|
bitset_bindex bitno = *next;
|
||||||
|
|
||||||
count = 0;
|
bitset_bindex count = 0;
|
||||||
if (!bitno)
|
if (!bitno)
|
||||||
{
|
{
|
||||||
/* Many bitsets are zero, so make this common case fast. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
@@ -302,9 +288,7 @@ abitset_list (bitset src, bitset_bindex *list,
|
|||||||
static inline void
|
static inline void
|
||||||
abitset_unused_clear (bitset dst)
|
abitset_unused_clear (bitset dst)
|
||||||
{
|
{
|
||||||
unsigned last_bit;
|
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||||
|
|
||||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
|
||||||
if (last_bit)
|
if (last_bit)
|
||||||
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||||
((bitset_word) 1 << last_bit) - 1;
|
((bitset_word) 1 << last_bit) - 1;
|
||||||
@@ -315,9 +299,7 @@ static void
|
|||||||
abitset_ones (bitset dst)
|
abitset_ones (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
size_t bytes;
|
size_t bytes = sizeof (bitset_word) * dst->b.csize;
|
||||||
|
|
||||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
|
||||||
|
|
||||||
memset (dstp, -1, bytes);
|
memset (dstp, -1, bytes);
|
||||||
abitset_unused_clear (dst);
|
abitset_unused_clear (dst);
|
||||||
@@ -328,9 +310,7 @@ static void
|
|||||||
abitset_zero (bitset dst)
|
abitset_zero (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
size_t bytes;
|
size_t bytes = sizeof (bitset_word) * dst->b.csize;
|
||||||
|
|
||||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
|
||||||
|
|
||||||
memset (dstp, 0, bytes);
|
memset (dstp, 0, bytes);
|
||||||
}
|
}
|
||||||
@@ -339,10 +319,9 @@ abitset_zero (bitset dst)
|
|||||||
static bool
|
static bool
|
||||||
abitset_empty_p (bitset dst)
|
abitset_empty_p (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
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])
|
if (dstp[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -366,13 +345,12 @@ abitset_copy1 (bitset dst, bitset src)
|
|||||||
static void
|
static void
|
||||||
abitset_not (bitset dst, bitset src)
|
abitset_not (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = ~(*srcp++);
|
*dstp++ = ~(*srcp++);
|
||||||
abitset_unused_clear (dst);
|
abitset_unused_clear (dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,14 +358,13 @@ abitset_not (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
abitset_equal_p (bitset dst, bitset src)
|
abitset_equal_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,14 +372,13 @@ abitset_equal_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
abitset_subset_p (bitset dst, bitset src)
|
abitset_subset_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,14 +386,13 @@ abitset_subset_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
abitset_disjoint_p (bitset dst, bitset src)
|
abitset_disjoint_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -426,28 +401,26 @@ abitset_disjoint_p (bitset dst, bitset src)
|
|||||||
static void
|
static void
|
||||||
abitset_and (bitset dst, bitset src1, bitset src2)
|
abitset_and (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ & *src2p++;
|
*dstp++ = *src1p++ & *src2p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
@@ -464,28 +437,26 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_andn (bitset dst, bitset src1, bitset src2)
|
abitset_andn (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ & ~(*src2p++);
|
*dstp++ = *src1p++ & ~(*src2p++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
@@ -502,28 +473,26 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_or (bitset dst, bitset src1, bitset src2)
|
abitset_or (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ | *src2p++;
|
*dstp++ = *src1p++ | *src2p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
@@ -540,13 +509,12 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_xor (bitset dst, bitset src1, bitset src2)
|
abitset_xor (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ ^ *src2p++;
|
*dstp++ = *src1p++ ^ *src2p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,14 +522,13 @@ abitset_xor (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
@@ -578,22 +545,20 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
@@ -601,7 +566,7 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
@@ -618,22 +583,20 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
static void
|
static void
|
||||||
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
@@ -641,7 +604,7 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
@@ -658,22 +621,20 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
static void
|
static void
|
||||||
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
@@ -681,7 +642,7 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
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++;
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
@@ -699,9 +660,9 @@ static void
|
|||||||
abitset_copy (bitset dst, bitset src)
|
abitset_copy (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
if (BITSET_COMPATIBLE_ (dst, src))
|
if (BITSET_COMPATIBLE_ (dst, src))
|
||||||
abitset_copy1 (dst, src);
|
abitset_copy1 (dst, src);
|
||||||
else
|
else
|
||||||
bitset_copy_ (dst, src);
|
bitset_copy_ (dst, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -784,14 +745,12 @@ struct bitset_vtable abitset_vtable = {
|
|||||||
size_t
|
size_t
|
||||||
abitset_bytes (bitset_bindex n_bits)
|
abitset_bytes (bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
bitset_windex size;
|
|
||||||
size_t bytes;
|
|
||||||
size_t header_size = offsetof (union bitset_union, a.words);
|
size_t header_size = offsetof (union bitset_union, a.words);
|
||||||
struct bitset_align_struct { char a; union bitset_union b; };
|
struct bitset_align_struct { char a; union bitset_union b; };
|
||||||
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
||||||
|
|
||||||
size = ABITSET_N_WORDS (n_bits);
|
bitset_windex size = ABITSET_N_WORDS (n_bits);
|
||||||
bytes = header_size + size * sizeof (bitset_word);
|
size_t bytes = header_size + size * sizeof (bitset_word);
|
||||||
|
|
||||||
/* Align the size properly for a vector of abitset objects. */
|
/* Align the size properly for a vector of abitset objects. */
|
||||||
if (header_size % bitset_alignment != 0
|
if (header_size % bitset_alignment != 0
|
||||||
@@ -808,9 +767,7 @@ abitset_bytes (bitset_bindex n_bits)
|
|||||||
bitset
|
bitset
|
||||||
abitset_init (bitset bset, bitset_bindex n_bits)
|
abitset_init (bitset bset, bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
bitset_windex size;
|
bitset_windex size = ABITSET_N_WORDS (n_bits);
|
||||||
|
|
||||||
size = ABITSET_N_WORDS (n_bits);
|
|
||||||
BITSET_NBITS_ (bset) = n_bits;
|
BITSET_NBITS_ (bset) = n_bits;
|
||||||
|
|
||||||
/* Use optimized routines if bitset fits within a single word.
|
/* Use optimized routines if bitset fits within a single word.
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
#include "bitset.h"
|
#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
|
#endif
|
||||||
|
|||||||
+10
-10
@@ -281,24 +281,24 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
|||||||
|
|
||||||
/* Private functions for bitset implementations. */
|
/* 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 */
|
#endif /* _BBITSET_H */
|
||||||
|
|||||||
+16
-34
@@ -39,11 +39,10 @@ const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
|
|||||||
size_t
|
size_t
|
||||||
bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
|
bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
size_t bytes;
|
|
||||||
|
|
||||||
if (bitset_stats_enabled)
|
if (bitset_stats_enabled)
|
||||||
return bitset_stats_bytes ();
|
return bitset_stats_bytes ();
|
||||||
|
|
||||||
|
size_t bytes;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@@ -134,12 +133,9 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
|
|||||||
bitset
|
bitset
|
||||||
bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t bytes;
|
size_t bytes = bitset_bytes (type, n_bits);
|
||||||
bitset bset;
|
|
||||||
|
|
||||||
bytes = bitset_bytes (type, n_bits);
|
bitset bset = xcalloc (1, bytes);
|
||||||
|
|
||||||
bset = xcalloc (1, bytes);
|
|
||||||
|
|
||||||
/* The cache is disabled until some elements are allocated. If we
|
/* The cache is disabled until some elements are allocated. If we
|
||||||
have variable length arrays, then we may need to allocate a dummy
|
have variable length arrays, then we may need to allocate a dummy
|
||||||
@@ -154,12 +150,9 @@ bitset
|
|||||||
bitset_obstack_alloc (struct obstack *bobstack,
|
bitset_obstack_alloc (struct obstack *bobstack,
|
||||||
bitset_bindex n_bits, enum bitset_type type)
|
bitset_bindex n_bits, enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t bytes;
|
size_t bytes = bitset_bytes (type, n_bits);
|
||||||
bitset bset;
|
|
||||||
|
|
||||||
bytes = bitset_bytes (type, n_bits);
|
bitset bset = obstack_alloc (bobstack, bytes);
|
||||||
|
|
||||||
bset = obstack_alloc (bobstack, bytes);
|
|
||||||
memset (bset, 0, bytes);
|
memset (bset, 0, bytes);
|
||||||
|
|
||||||
return bitset_init (bset, n_bits, type);
|
return bitset_init (bset, n_bits, type);
|
||||||
@@ -171,9 +164,7 @@ bitset_obstack_alloc (struct obstack *bobstack,
|
|||||||
bitset
|
bitset
|
||||||
bitset_create (bitset_bindex n_bits, unsigned attr)
|
bitset_create (bitset_bindex n_bits, unsigned attr)
|
||||||
{
|
{
|
||||||
enum bitset_type type;
|
enum bitset_type type = bitset_type_choose (n_bits, attr);
|
||||||
|
|
||||||
type = bitset_type_choose (n_bits, attr);
|
|
||||||
|
|
||||||
return bitset_alloc (n_bits, type);
|
return bitset_alloc (n_bits, type);
|
||||||
}
|
}
|
||||||
@@ -200,9 +191,7 @@ bitset_obstack_free (bitset bset)
|
|||||||
enum bitset_type
|
enum bitset_type
|
||||||
bitset_type_get (bitset bset)
|
bitset_type_get (bitset bset)
|
||||||
{
|
{
|
||||||
enum bitset_type type;
|
enum bitset_type type = BITSET_TYPE_ (bset);
|
||||||
|
|
||||||
type = BITSET_TYPE_ (bset);
|
|
||||||
if (type != BITSET_STATS)
|
if (type != BITSET_STATS)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
@@ -214,9 +203,7 @@ bitset_type_get (bitset bset)
|
|||||||
const char *
|
const char *
|
||||||
bitset_type_name_get (bitset bset)
|
bitset_type_name_get (bitset bset)
|
||||||
{
|
{
|
||||||
enum bitset_type type;
|
enum bitset_type type = bitset_type_get (bset);
|
||||||
|
|
||||||
type = bitset_type_get (bset);
|
|
||||||
|
|
||||||
return bitset_type_names[type];
|
return bitset_type_names[type];
|
||||||
}
|
}
|
||||||
@@ -240,7 +227,7 @@ bitset_next (bitset src, bitset_bindex bitno)
|
|||||||
extern bool
|
extern bool
|
||||||
bitset_compatible_p (bitset bset1, bitset bset2)
|
bitset_compatible_p (bitset bset1, bitset bset2)
|
||||||
{
|
{
|
||||||
return BITSET_COMPATIBLE_ (bset1, bset2);
|
return BITSET_COMPATIBLE_ (bset1, bset2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -291,15 +278,13 @@ bitset_only_set_p (bitset src, bitset_bindex bitno)
|
|||||||
static void
|
static void
|
||||||
bitset_print (FILE *file, bitset bset, bool verbose)
|
bitset_print (FILE *file, bitset bset, bool verbose)
|
||||||
{
|
{
|
||||||
unsigned pos;
|
|
||||||
bitset_bindex i;
|
|
||||||
bitset_iterator iter;
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf (file, "n_bits = %lu, set = {",
|
fprintf (file, "n_bits = %lu, set = {",
|
||||||
(unsigned long) bitset_size (bset));
|
(unsigned long) bitset_size (bset));
|
||||||
|
|
||||||
pos = 30;
|
unsigned pos = 30;
|
||||||
|
bitset_bindex i;
|
||||||
|
bitset_iterator iter;
|
||||||
BITSET_FOR_EACH (iter, bset, i, 0)
|
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||||
{
|
{
|
||||||
if (pos > 70)
|
if (pos > 70)
|
||||||
@@ -357,7 +342,7 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
|
|||||||
bitset_bindex
|
bitset_bindex
|
||||||
bitset_size_ (bitset src)
|
bitset_size_ (bitset src)
|
||||||
{
|
{
|
||||||
return BITSET_NBITS_ (src);
|
return BITSET_NBITS_ (src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -366,7 +351,6 @@ bitset_bindex
|
|||||||
bitset_count_ (bitset src)
|
bitset_count_ (bitset src)
|
||||||
{
|
{
|
||||||
bitset_bindex list[BITSET_LIST_SIZE];
|
bitset_bindex list[BITSET_LIST_SIZE];
|
||||||
bitset_bindex next;
|
|
||||||
bitset_bindex num;
|
bitset_bindex num;
|
||||||
bitset_bindex count;
|
bitset_bindex count;
|
||||||
|
|
||||||
@@ -374,7 +358,7 @@ bitset_count_ (bitset src)
|
|||||||
bitset implementation that uses a direct technique (based on
|
bitset implementation that uses a direct technique (based on
|
||||||
masks) for counting the number of bits set in a word. */
|
masks) for counting the number of bits set in a word. */
|
||||||
|
|
||||||
next = 0;
|
bitset_bindex next = 0;
|
||||||
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
|
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
|
||||||
count += num)
|
count += num)
|
||||||
continue;
|
continue;
|
||||||
@@ -411,13 +395,11 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
|||||||
enum bitset_ops op)
|
enum bitset_ops op)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool stats_enabled_save;
|
|
||||||
bitset tmp;
|
|
||||||
|
|
||||||
/* Create temporary bitset. */
|
/* Create temporary bitset. */
|
||||||
stats_enabled_save = bitset_stats_enabled;
|
bool stats_enabled_save = bitset_stats_enabled;
|
||||||
bitset_stats_enabled = false;
|
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;
|
bitset_stats_enabled = stats_enabled_save;
|
||||||
|
|
||||||
switch (op)
|
switch (op)
|
||||||
|
|||||||
+25
-25
@@ -99,37 +99,37 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
/* Return bytes required for bitset of desired type and size. */
|
/* 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. */
|
/* 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
|
/* Select an implementation type based on the desired bitset size
|
||||||
and attributes. */
|
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. */
|
/* 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. */
|
/* Free bitset. */
|
||||||
extern void bitset_free (bitset);
|
void bitset_free (bitset);
|
||||||
|
|
||||||
/* Create a bitset of desired type and size using an obstack. The
|
/* Create a bitset of desired type and size using an obstack. The
|
||||||
bitset is zeroed. */
|
bitset is zeroed. */
|
||||||
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
bitset bitset_obstack_alloc (struct obstack *bobstack,
|
||||||
bitset_bindex, enum bitset_type);
|
bitset_bindex, enum bitset_type);
|
||||||
|
|
||||||
/* Free bitset allocated on obstack. */
|
/* 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. */
|
/* 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. */
|
/* Return bitset type. */
|
||||||
extern enum bitset_type bitset_type_get (bitset);
|
enum bitset_type bitset_type_get (bitset);
|
||||||
|
|
||||||
/* Return bitset type name. */
|
/* 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. */
|
/* Set bit BITNO in bitset BSET. */
|
||||||
@@ -181,7 +181,7 @@ bitset_test (bitset bset, bitset_bindex bitno)
|
|||||||
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
|
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
|
||||||
|
|
||||||
/* Change size of bitset. */
|
/* 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. */
|
/* Return number of bits set in bitset SRC. */
|
||||||
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
|
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
|
||||||
@@ -281,25 +281,25 @@ extern void bitset_resize (bitset, bitset_bindex);
|
|||||||
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
|
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
|
||||||
|
|
||||||
/* Return true if both bitsets are of the same type and size. */
|
/* 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. */
|
/* 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. */
|
/* 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. */
|
/* Find first set bit. */
|
||||||
extern bitset_bindex bitset_first (bitset);
|
bitset_bindex bitset_first (bitset);
|
||||||
|
|
||||||
/* Find last set bit. */
|
/* Find last set bit. */
|
||||||
extern bitset_bindex bitset_last (bitset);
|
bitset_bindex bitset_last (bitset);
|
||||||
|
|
||||||
/* Return nonzero if this is the only set bit. */
|
/* 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. */
|
/* Dump bitset. */
|
||||||
extern void bitset_dump (FILE *, bitset);
|
void bitset_dump (FILE *, bitset);
|
||||||
|
|
||||||
/* Loop over all elements of BSET, starting with MIN, setting INDEX
|
/* Loop over all elements of BSET, starting with MIN, setting INDEX
|
||||||
to the index of each set bit. For example, the following will print
|
to the index of each set bit. For example, the following will print
|
||||||
@@ -368,13 +368,13 @@ extern void bitset_dump (FILE *, bitset);
|
|||||||
|
|
||||||
|
|
||||||
/* Release any memory tied up with bitsets. */
|
/* Release any memory tied up with bitsets. */
|
||||||
extern void bitset_release_memory (void);
|
void bitset_release_memory (void);
|
||||||
|
|
||||||
/* Enable bitset stats gathering. */
|
/* Enable bitset stats gathering. */
|
||||||
extern void bitset_stats_enable (void);
|
void bitset_stats_enable (void);
|
||||||
|
|
||||||
/* Disable bitset stats gathering. */
|
/* Disable bitset stats gathering. */
|
||||||
extern void bitset_stats_disable (void);
|
void bitset_stats_disable (void);
|
||||||
|
|
||||||
/* Read bitset stats file of accummulated stats. */
|
/* Read bitset stats file of accummulated stats. */
|
||||||
void bitset_stats_read (const char *file_name);
|
void bitset_stats_read (const char *file_name);
|
||||||
@@ -383,12 +383,12 @@ void bitset_stats_read (const char *file_name);
|
|||||||
void bitset_stats_write (const char *file_name);
|
void bitset_stats_write (const char *file_name);
|
||||||
|
|
||||||
/* Dump bitset stats. */
|
/* Dump bitset stats. */
|
||||||
extern void bitset_stats_dump (FILE *);
|
void bitset_stats_dump (FILE *);
|
||||||
|
|
||||||
/* Function to debug bitset from debugger. */
|
/* Function to debug bitset from debugger. */
|
||||||
extern void debug_bitset (bitset);
|
void debug_bitset (bitset);
|
||||||
|
|
||||||
/* Function to debug bitset stats from debugger. */
|
/* Function to debug bitset stats from debugger. */
|
||||||
extern void debug_bitset_stats (void);
|
void debug_bitset_stats (void);
|
||||||
|
|
||||||
#endif /* _BITSET_H */
|
#endif /* _BITSET_H */
|
||||||
|
|||||||
+36
-45
@@ -108,18 +108,15 @@ static void
|
|||||||
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
||||||
unsigned n_bins, unsigned *bins)
|
unsigned n_bins, unsigned *bins)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned total = 0;
|
||||||
unsigned total;
|
for (unsigned i = 0; i < n_bins; i++)
|
||||||
|
|
||||||
total = 0;
|
|
||||||
for (i = 0; i < n_bins; i++)
|
|
||||||
total += bins[i];
|
total += bins[i];
|
||||||
|
|
||||||
if (!total)
|
if (!total)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf (file, "%s %s", name, msg);
|
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",
|
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
||||||
i * 100.0 / n_bins,
|
i * 100.0 / n_bins,
|
||||||
(i + 1) * 100.0 / n_bins, bins[i],
|
(i + 1) * 100.0 / n_bins, bins[i],
|
||||||
@@ -132,37 +129,39 @@ static void
|
|||||||
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
||||||
unsigned n_bins, unsigned *bins)
|
unsigned n_bins, unsigned *bins)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned total = 0;
|
||||||
unsigned total;
|
for (unsigned i = 0; i < n_bins; i++)
|
||||||
unsigned max_width;
|
|
||||||
|
|
||||||
total = 0;
|
|
||||||
for (i = 0; i < n_bins; i++)
|
|
||||||
total += bins[i];
|
total += bins[i];
|
||||||
|
|
||||||
if (!total)
|
if (!total)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Determine number of useful bins. */
|
/* Determine number of useful bins. */
|
||||||
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
{
|
||||||
continue;
|
unsigned i;
|
||||||
n_bins = i;
|
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
||||||
|
continue;
|
||||||
|
n_bins = i;
|
||||||
|
}
|
||||||
|
|
||||||
/* 2 * ceil (log10 (2) * (N - 1)) + 1. */
|
/* 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);
|
fprintf (file, "%s %s", name, msg);
|
||||||
for (i = 0; i < 2; i++)
|
{
|
||||||
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
unsigned i;
|
||||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
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++)
|
for (; i < n_bins; i++)
|
||||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||||
max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1),
|
max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1),
|
||||||
1UL << (i - 1),
|
1UL << (i - 1),
|
||||||
(1UL << i) - 1,
|
(1UL << i) - 1,
|
||||||
bins[i],
|
bins[i],
|
||||||
(100.0 * bins[i]) / total);
|
(100.0 * bins[i]) / total);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -205,8 +204,6 @@ bitset_stats_print_1 (FILE *file, const char *name,
|
|||||||
static void
|
static void
|
||||||
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!bitset_stats_info)
|
if (!bitset_stats_info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -215,7 +212,7 @@ bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
|||||||
if (bitset_stats_info->runs > 1)
|
if (bitset_stats_info->runs > 1)
|
||||||
fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
|
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_print_1 (file, bitset_type_names[i],
|
||||||
&bitset_stats_info->types[i]);
|
&bitset_stats_info->types[i]);
|
||||||
}
|
}
|
||||||
@@ -242,15 +239,13 @@ bitset_stats_disable (void)
|
|||||||
void
|
void
|
||||||
bitset_stats_read (const char *file_name)
|
bitset_stats_read (const char *file_name)
|
||||||
{
|
{
|
||||||
FILE *file;
|
|
||||||
|
|
||||||
if (!bitset_stats_info)
|
if (!bitset_stats_info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!file_name)
|
if (!file_name)
|
||||||
file_name = BITSET_STATS_FILE;
|
file_name = BITSET_STATS_FILE;
|
||||||
|
|
||||||
file = fopen (file_name, "r");
|
FILE *file = fopen (file_name, "r");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||||
@@ -272,15 +267,13 @@ bitset_stats_read (const char *file_name)
|
|||||||
void
|
void
|
||||||
bitset_stats_write (const char *file_name)
|
bitset_stats_write (const char *file_name)
|
||||||
{
|
{
|
||||||
FILE *file;
|
|
||||||
|
|
||||||
if (!bitset_stats_info)
|
if (!bitset_stats_info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!file_name)
|
if (!file_name)
|
||||||
file_name = BITSET_STATS_FILE;
|
file_name = BITSET_STATS_FILE;
|
||||||
|
|
||||||
file = fopen (file_name, "w");
|
FILE *file = fopen (file_name, "w");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||||
@@ -352,7 +345,7 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
|
|||||||
static bool
|
static bool
|
||||||
bitset_stats_toggle (bitset src, bitset_bindex bitno)
|
bitset_stats_toggle (bitset src, bitset_bindex bitno)
|
||||||
{
|
{
|
||||||
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -573,15 +566,14 @@ static bitset_bindex
|
|||||||
bitset_stats_list (bitset bset, bitset_bindex *list,
|
bitset_stats_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex count;
|
bitset_bindex count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
||||||
|
|
||||||
|
BITSET_STATS_LISTS_INC (bset->s.bset);
|
||||||
|
|
||||||
bitset_bindex tmp;
|
bitset_bindex tmp;
|
||||||
bitset_bindex size;
|
bitset_bindex size;
|
||||||
bitset_bindex i;
|
bitset_bindex i;
|
||||||
|
|
||||||
count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
|
||||||
|
|
||||||
BITSET_STATS_LISTS_INC (bset->s.bset);
|
|
||||||
|
|
||||||
/* Log histogram of number of set bits. */
|
/* Log histogram of number of set bits. */
|
||||||
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||||
continue;
|
continue;
|
||||||
@@ -663,7 +655,7 @@ struct bitset_vtable bitset_stats_vtable = {
|
|||||||
enum bitset_type
|
enum bitset_type
|
||||||
bitset_stats_type_get (bitset bset)
|
bitset_stats_type_get (bitset bset)
|
||||||
{
|
{
|
||||||
return BITSET_TYPE_ (bset->s.bset);
|
return BITSET_TYPE_ (bset->s.bset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -677,9 +669,6 @@ bitset_stats_bytes (void)
|
|||||||
bitset
|
bitset
|
||||||
bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t bytes;
|
|
||||||
bitset sbset;
|
|
||||||
|
|
||||||
bset->b.vtable = &bitset_stats_vtable;
|
bset->b.vtable = &bitset_stats_vtable;
|
||||||
|
|
||||||
/* Disable cache. */
|
/* Disable cache. */
|
||||||
@@ -691,6 +680,8 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
|||||||
|
|
||||||
/* Set up the actual bitset implementation that
|
/* Set up the actual bitset implementation that
|
||||||
we are a wrapper over. */
|
we are a wrapper over. */
|
||||||
|
size_t bytes;
|
||||||
|
bitset sbset;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
|||||||
+3
-3
@@ -25,10 +25,10 @@
|
|||||||
|
|
||||||
extern bool bitset_stats_enabled;
|
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
|
#endif
|
||||||
|
|||||||
+6
-7
@@ -29,7 +29,6 @@
|
|||||||
void
|
void
|
||||||
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||||
{
|
{
|
||||||
bitset_bindex i, j;
|
|
||||||
bitset_bindex hsize = bitset_size (bset[0]);
|
bitset_bindex hsize = bitset_size (bset[0]);
|
||||||
|
|
||||||
/* Title. */
|
/* Title. */
|
||||||
@@ -37,32 +36,32 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
|||||||
|
|
||||||
/* Column numbers. */
|
/* Column numbers. */
|
||||||
fputs (" ", out);
|
fputs (" ", out);
|
||||||
for (i = 0; i < hsize; ++i)
|
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||||
putc (i / 10 ? '0' + i / 10 : ' ', out);
|
putc (i / 10 ? '0' + i / 10 : ' ', out);
|
||||||
putc ('\n', out);
|
putc ('\n', out);
|
||||||
fputs (" ", out);
|
fputs (" ", out);
|
||||||
for (i = 0; i < hsize; ++i)
|
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||||
fprintf (out, "%d", (int) (i % 10));
|
fprintf (out, "%d", (int) (i % 10));
|
||||||
putc ('\n', out);
|
putc ('\n', out);
|
||||||
|
|
||||||
/* Bar. */
|
/* Bar. */
|
||||||
fputs (" .", out);
|
fputs (" .", out);
|
||||||
for (i = 0; i < hsize; ++i)
|
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||||
putc ('-', out);
|
putc ('-', out);
|
||||||
fputs (".\n", out);
|
fputs (".\n", out);
|
||||||
|
|
||||||
/* Contents. */
|
/* Contents. */
|
||||||
for (i = 0; bset[i]; ++i)
|
for (bitset_bindex i = 0; bset[i]; ++i)
|
||||||
{
|
{
|
||||||
fprintf (out, "%2lu|", (unsigned long) 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 (bitset_test (bset[i], j) ? "1" : " ", out);
|
||||||
fputs ("|\n", out);
|
fputs ("|\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bar. */
|
/* Bar. */
|
||||||
fputs (" `", out);
|
fputs (" `", out);
|
||||||
for (i = 0; i < hsize; ++i)
|
for (bitset_bindex i = 0; i < hsize; ++i)
|
||||||
putc ('-', out);
|
putc ('-', out);
|
||||||
fputs ("'\n", out);
|
fputs ("'\n", out);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,6 +24,6 @@
|
|||||||
#include "bitsetv.h"
|
#include "bitsetv.h"
|
||||||
|
|
||||||
/* Dump vector of bitsets as a matrix. */
|
/* 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 */
|
#endif /* _BITSETV_H */
|
||||||
|
|||||||
+14
-35
@@ -29,23 +29,19 @@ bitset *
|
|||||||
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||||
enum bitset_type type)
|
enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t vector_bytes;
|
|
||||||
size_t bytes;
|
|
||||||
bitset *bsetv;
|
|
||||||
bitset_bindex i;
|
|
||||||
|
|
||||||
/* Determine number of bytes for each set. */
|
/* 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 size calculation overflows, memory is exhausted. */
|
||||||
if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
|
if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
|
||||||
xalloc_die ();
|
xalloc_die ();
|
||||||
|
|
||||||
/* Allocate vector table at head of bitset array. */
|
/* 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;
|
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++)
|
for (i = 0; i < n_vecs; i++)
|
||||||
{
|
{
|
||||||
bsetv[i] = (bitset) (void *) ((char *) bsetv + vector_bytes + i * bytes);
|
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 *
|
bitset *
|
||||||
bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
|
bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
|
||||||
{
|
{
|
||||||
enum bitset_type type;
|
enum bitset_type type = bitset_type_choose (n_bits, attr);
|
||||||
|
|
||||||
type = bitset_type_choose (n_bits, attr);
|
|
||||||
return bitsetv_alloc (n_vecs, n_bits, type);
|
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
|
void
|
||||||
bitsetv_free (bitsetv bsetv)
|
bitsetv_free (bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_bindex i;
|
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||||
|
BITSET_FREE_ (bsetv[i]);
|
||||||
for (i = 0; bsetv[i]; i++)
|
|
||||||
BITSET_FREE_ (bsetv[i]);
|
|
||||||
free (bsetv);
|
free (bsetv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,9 +79,7 @@ bitsetv_free (bitsetv bsetv)
|
|||||||
void
|
void
|
||||||
bitsetv_zero (bitsetv bsetv)
|
bitsetv_zero (bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_bindex i;
|
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||||
|
|
||||||
for (i = 0; bsetv[i]; i++)
|
|
||||||
bitset_zero (bsetv[i]);
|
bitset_zero (bsetv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,9 +88,7 @@ bitsetv_zero (bitsetv bsetv)
|
|||||||
void
|
void
|
||||||
bitsetv_ones (bitsetv bsetv)
|
bitsetv_ones (bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_bindex i;
|
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||||
|
|
||||||
for (i = 0; bsetv[i]; i++)
|
|
||||||
bitset_ones (bsetv[i]);
|
bitset_ones (bsetv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +98,8 @@ bitsetv_ones (bitsetv bsetv)
|
|||||||
void
|
void
|
||||||
bitsetv_transitive_closure (bitsetv bsetv)
|
bitsetv_transitive_closure (bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_bindex i;
|
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||||
bitset_bindex j;
|
for (bitset_bindex j = 0; bsetv[j]; j++)
|
||||||
|
|
||||||
for (i = 0; bsetv[i]; i++)
|
|
||||||
for (j = 0; bsetv[j]; j++)
|
|
||||||
if (bitset_test (bsetv[j], i))
|
if (bitset_test (bsetv[j], i))
|
||||||
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
||||||
}
|
}
|
||||||
@@ -127,10 +112,8 @@ bitsetv_transitive_closure (bitsetv bsetv)
|
|||||||
void
|
void
|
||||||
bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_bindex i;
|
|
||||||
|
|
||||||
bitsetv_transitive_closure (bsetv);
|
bitsetv_transitive_closure (bsetv);
|
||||||
for (i = 0; bsetv[i]; i++)
|
for (bitset_bindex i = 0; bsetv[i]; i++)
|
||||||
bitset_set (bsetv[i], i);
|
bitset_set (bsetv[i], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,10 +124,8 @@ void
|
|||||||
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||||
bitsetv bsetv)
|
bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
|
|
||||||
fprintf (file, "%s\n", title);
|
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);
|
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
|
||||||
bitset_dump (file, bsetv[i]);
|
bitset_dump (file, bsetv[i]);
|
||||||
@@ -157,9 +138,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
|||||||
void
|
void
|
||||||
debug_bitsetv (bitsetv bsetv)
|
debug_bitsetv (bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
for (bitset_windex i = 0; bsetv[i]; i++)
|
||||||
|
|
||||||
for (i = 0; bsetv[i]; i++)
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%lu: ", (unsigned long) i);
|
fprintf (stderr, "%lu: ", (unsigned long) i);
|
||||||
debug_bitset (bsetv[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
|
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
|
||||||
type TYPE. */
|
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
|
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
|
||||||
attribute hints specified by ATTR. */
|
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. */
|
/* Free vector of bitsets. */
|
||||||
extern void bitsetv_free (bitsetv);
|
void bitsetv_free (bitsetv);
|
||||||
|
|
||||||
/* Zero vector of bitsets. */
|
/* Zero vector of bitsets. */
|
||||||
extern void bitsetv_zero (bitsetv);
|
void bitsetv_zero (bitsetv);
|
||||||
|
|
||||||
/* Set vector of bitsets. */
|
/* 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
|
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||||
be the transitive closure of what was given. */
|
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
|
/* 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
|
be the reflexive transitive closure of what was given. This is
|
||||||
the same as transitive closure but with all bits on the diagonal
|
the same as transitive closure but with all bits on the diagonal
|
||||||
of the bit matrix set. */
|
of the bit matrix set. */
|
||||||
extern void bitsetv_reflexive_transitive_closure (bitsetv);
|
void bitsetv_reflexive_transitive_closure (bitsetv);
|
||||||
|
|
||||||
/* Dump vector of bitsets. */
|
/* 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. */
|
/* Function to debug vector of bitsets from debugger. */
|
||||||
extern void debug_bitsetv (bitsetv);
|
void debug_bitsetv (bitsetv);
|
||||||
|
|
||||||
#endif /* _BITSETV_H */
|
#endif /* _BITSETV_H */
|
||||||
|
|||||||
+117
-242
@@ -123,14 +123,11 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
|||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
ebitset_resize (bitset src, bitset_bindex n_bits)
|
ebitset_resize (bitset src, bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
bitset_windex oldsize;
|
|
||||||
bitset_windex newsize;
|
|
||||||
|
|
||||||
if (n_bits == BITSET_NBITS_ (src))
|
if (n_bits == BITSET_NBITS_ (src))
|
||||||
return n_bits;
|
return n_bits;
|
||||||
|
|
||||||
oldsize = EBITSET_SIZE (src);
|
bitset_windex oldsize = EBITSET_SIZE (src);
|
||||||
newsize = EBITSET_N_ELTS (n_bits);
|
bitset_windex newsize = EBITSET_N_ELTS (n_bits);
|
||||||
|
|
||||||
if (oldsize < newsize)
|
if (oldsize < newsize)
|
||||||
{
|
{
|
||||||
@@ -234,9 +231,7 @@ ebitset_elt_alloc (void)
|
|||||||
static inline ebitset_elt *
|
static inline ebitset_elt *
|
||||||
ebitset_elt_calloc (void)
|
ebitset_elt_calloc (void)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt;
|
ebitset_elt *elt = ebitset_elt_alloc ();
|
||||||
|
|
||||||
elt = ebitset_elt_alloc ();
|
|
||||||
memset (EBITSET_WORDS (elt), 0, sizeof (EBITSET_WORDS (elt)));
|
memset (EBITSET_WORDS (elt), 0, sizeof (EBITSET_WORDS (elt)));
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
@@ -254,12 +249,8 @@ ebitset_elt_free (ebitset_elt *elt)
|
|||||||
static inline void
|
static inline void
|
||||||
ebitset_elt_remove (bitset bset, bitset_windex eindex)
|
ebitset_elt_remove (bitset bset, bitset_windex eindex)
|
||||||
{
|
{
|
||||||
ebitset_elts *elts;
|
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||||
ebitset_elt *elt;
|
ebitset_elt *elt = elts[eindex];
|
||||||
|
|
||||||
elts = EBITSET_ELTS (bset);
|
|
||||||
|
|
||||||
elt = elts[eindex];
|
|
||||||
|
|
||||||
elts[eindex] = 0;
|
elts[eindex] = 0;
|
||||||
ebitset_elt_free (elt);
|
ebitset_elt_free (elt);
|
||||||
@@ -270,9 +261,7 @@ ebitset_elt_remove (bitset bset, bitset_windex eindex)
|
|||||||
static inline void
|
static inline void
|
||||||
ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
|
ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
|
||||||
{
|
{
|
||||||
ebitset_elts *elts;
|
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||||
|
|
||||||
elts = EBITSET_ELTS (bset);
|
|
||||||
/* Assume that the elts entry not allocated. */
|
/* Assume that the elts entry not allocated. */
|
||||||
elts[eindex] = elt;
|
elts[eindex] = elt;
|
||||||
}
|
}
|
||||||
@@ -282,9 +271,7 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
|
|||||||
static inline bool
|
static inline bool
|
||||||
ebitset_elt_zero_p (ebitset_elt *elt)
|
ebitset_elt_zero_p (ebitset_elt *elt)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
|
||||||
if (EBITSET_WORDS (elt)[i])
|
if (EBITSET_WORDS (elt)[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -296,24 +283,18 @@ static ebitset_elt *
|
|||||||
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||||
enum ebitset_find_mode mode)
|
enum ebitset_find_mode mode)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt;
|
bitset_windex eindex = bindex / EBITSET_ELT_BITS;
|
||||||
bitset_windex size;
|
|
||||||
bitset_windex eindex;
|
|
||||||
ebitset_elts *elts;
|
|
||||||
|
|
||||||
eindex = bindex / EBITSET_ELT_BITS;
|
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||||
|
bitset_windex size = EBITSET_SIZE (bset);
|
||||||
elts = EBITSET_ELTS (bset);
|
|
||||||
size = EBITSET_SIZE (bset);
|
|
||||||
|
|
||||||
if (eindex < size)
|
if (eindex < size)
|
||||||
{
|
{
|
||||||
if ((elt = elts[eindex]))
|
ebitset_elt *elt = elts[eindex];
|
||||||
|
if (elt)
|
||||||
{
|
{
|
||||||
if (EBITSET_WORDS (elt) == bset->b.cdata)
|
if (EBITSET_WORDS (elt) != bset->b.cdata)
|
||||||
return elt;
|
EBITSET_CACHE_SET (bset, eindex);
|
||||||
|
|
||||||
EBITSET_CACHE_SET (bset, eindex);
|
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,10 +314,12 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
|||||||
ebitset_resize (bset, bindex);
|
ebitset_resize (bset, bindex);
|
||||||
|
|
||||||
/* Create a new element. */
|
/* Create a new element. */
|
||||||
elt = ebitset_elt_calloc ();
|
{
|
||||||
ebitset_elt_add (bset, elt, eindex);
|
ebitset_elt *elt = ebitset_elt_calloc ();
|
||||||
EBITSET_CACHE_SET (bset, eindex);
|
ebitset_elt_add (bset, elt, eindex);
|
||||||
return elt;
|
EBITSET_CACHE_SET (bset, eindex);
|
||||||
|
return elt;
|
||||||
|
}
|
||||||
|
|
||||||
case EBITSET_SUBST:
|
case EBITSET_SUBST:
|
||||||
return &ebitset_zero_elts[0];
|
return &ebitset_zero_elts[0];
|
||||||
@@ -348,15 +331,12 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
|||||||
static inline bitset_windex
|
static inline bitset_windex
|
||||||
ebitset_weed (bitset bset)
|
ebitset_weed (bitset bset)
|
||||||
{
|
{
|
||||||
ebitset_elts *elts;
|
|
||||||
bitset_windex j;
|
|
||||||
bitset_windex count;
|
|
||||||
|
|
||||||
if (EBITSET_ZERO_P (bset))
|
if (EBITSET_ZERO_P (bset))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
elts = EBITSET_ELTS (bset);
|
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||||
count = 0;
|
bitset_windex count = 0;
|
||||||
|
bitset_windex j;
|
||||||
for (j = 0; j < EBITSET_SIZE (bset); j++)
|
for (j = 0; j < EBITSET_SIZE (bset); j++)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
@@ -391,14 +371,11 @@ ebitset_weed (bitset bset)
|
|||||||
static inline void
|
static inline void
|
||||||
ebitset_zero (bitset bset)
|
ebitset_zero (bitset bset)
|
||||||
{
|
{
|
||||||
ebitset_elts *elts;
|
|
||||||
bitset_windex j;
|
|
||||||
|
|
||||||
if (EBITSET_ZERO_P (bset))
|
if (EBITSET_ZERO_P (bset))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
elts = EBITSET_ELTS (bset);
|
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||||
for (j = 0; j < EBITSET_SIZE (bset); j++)
|
for (bitset_windex j = 0; j < EBITSET_SIZE (bset); j++)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
@@ -415,10 +392,6 @@ ebitset_zero (bitset bset)
|
|||||||
static inline bool
|
static inline bool
|
||||||
ebitset_equal_p (bitset dst, bitset src)
|
ebitset_equal_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
ebitset_elts *selts;
|
|
||||||
ebitset_elts *delts;
|
|
||||||
bitset_windex j;
|
|
||||||
|
|
||||||
if (src == dst)
|
if (src == dst)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -428,12 +401,11 @@ ebitset_equal_p (bitset dst, bitset src)
|
|||||||
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
|
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
selts = EBITSET_ELTS (src);
|
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||||
delts = EBITSET_ELTS (dst);
|
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 *selt = selts[j];
|
||||||
ebitset_elt *delt = delts[j];
|
ebitset_elt *delt = delts[j];
|
||||||
|
|
||||||
@@ -442,7 +414,7 @@ ebitset_equal_p (bitset dst, bitset src)
|
|||||||
if ((selt && !delt) || (!selt && delt))
|
if ((selt && !delt) || (!selt && delt))
|
||||||
return false;
|
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])
|
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -454,10 +426,6 @@ ebitset_equal_p (bitset dst, bitset src)
|
|||||||
static inline void
|
static inline void
|
||||||
ebitset_copy_ (bitset dst, bitset src)
|
ebitset_copy_ (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
ebitset_elts *selts;
|
|
||||||
ebitset_elts *delts;
|
|
||||||
bitset_windex j;
|
|
||||||
|
|
||||||
if (src == dst)
|
if (src == dst)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -466,17 +434,15 @@ ebitset_copy_ (bitset dst, bitset src)
|
|||||||
if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src))
|
if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src))
|
||||||
ebitset_resize (dst, BITSET_NBITS_ (src));
|
ebitset_resize (dst, BITSET_NBITS_ (src));
|
||||||
|
|
||||||
selts = EBITSET_ELTS (src);
|
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||||
delts = EBITSET_ELTS (dst);
|
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||||
for (j = 0; j < EBITSET_SIZE (src); j++)
|
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
|
||||||
{
|
{
|
||||||
ebitset_elt *selt = selts[j];
|
ebitset_elt *selt = selts[j];
|
||||||
|
|
||||||
if (selt)
|
if (selt)
|
||||||
{
|
{
|
||||||
ebitset_elt *tmp;
|
ebitset_elt *tmp = ebitset_elt_alloc ();
|
||||||
|
|
||||||
tmp = ebitset_elt_alloc ();
|
|
||||||
delts[j] = tmp;
|
delts[j] = tmp;
|
||||||
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
||||||
sizeof (EBITSET_WORDS (selt)));
|
sizeof (EBITSET_WORDS (selt)));
|
||||||
@@ -567,60 +533,41 @@ static bitset_bindex
|
|||||||
ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
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))
|
if (EBITSET_ZERO_P (bset))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size = EBITSET_SIZE (bset);
|
bitset_windex size = EBITSET_SIZE (bset);
|
||||||
n_bits = size * EBITSET_ELT_BITS;
|
bitset_bindex n_bits = size * EBITSET_ELT_BITS;
|
||||||
rbitno = *next;
|
bitset_bindex rbitno = *next;
|
||||||
|
|
||||||
if (rbitno >= n_bits)
|
if (rbitno >= n_bits)
|
||||||
return 0;
|
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;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
eindex = bitno / EBITSET_ELT_BITS;
|
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
|
||||||
woffset = windex - eindex * EBITSET_ELT_WORDS;
|
bitset_windex woffset = windex - eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
|
bitset_bindex count = 0;
|
||||||
count = 0;
|
unsigned bcount = bitno % BITSET_WORD_BITS;
|
||||||
bcount = bitno % BITSET_WORD_BITS;
|
bitset_bindex boffset = windex * BITSET_WORD_BITS;
|
||||||
boffset = windex * BITSET_WORD_BITS;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ebitset_elt *elt;
|
ebitset_elt *elt = elts[eindex];
|
||||||
bitset_word *srcp;
|
|
||||||
|
|
||||||
elt = elts[eindex];
|
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bitset_word word;
|
for (bitset_word word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||||
|
word; bcount--)
|
||||||
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
|
||||||
|
|
||||||
for (; word; bcount--)
|
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
@@ -656,41 +603,32 @@ static bitset_bindex
|
|||||||
ebitset_list (bitset bset, bitset_bindex *list,
|
ebitset_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
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))
|
if (EBITSET_ZERO_P (bset))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bitno = *next;
|
bitset_bindex bitno = *next;
|
||||||
count = 0;
|
bitset_bindex count = 0;
|
||||||
|
|
||||||
elts = EBITSET_ELTS (bset);
|
ebitset_elts *elts = EBITSET_ELTS (bset);
|
||||||
size = EBITSET_SIZE (bset);
|
bitset_windex size = EBITSET_SIZE (bset);
|
||||||
eindex = bitno / EBITSET_ELT_BITS;
|
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
|
||||||
|
|
||||||
if (bitno % EBITSET_ELT_BITS)
|
if (bitno % EBITSET_ELT_BITS)
|
||||||
{
|
{
|
||||||
/* We need to start within an element. This is not very common. */
|
/* We need to start within an element. This is not very common. */
|
||||||
|
|
||||||
elt = elts[eindex];
|
ebitset_elt *elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
bitset_windex woffset;
|
bitset_windex woffset;
|
||||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
woffset = eindex * EBITSET_ELT_WORDS;
|
woffset = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
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++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
@@ -718,22 +656,21 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
for (; eindex < size; eindex++)
|
for (; eindex < size; eindex++)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
bitset_word *srcp;
|
bitset_word *srcp;
|
||||||
|
|
||||||
elt = elts[eindex];
|
ebitset_elt *elt = elts[eindex];
|
||||||
if (!elt)
|
if (!elt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
srcp = EBITSET_WORDS (elt);
|
srcp = EBITSET_WORDS (elt);
|
||||||
windex = eindex * EBITSET_ELT_WORDS;
|
bitset_windex windex = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
if ((count + EBITSET_ELT_BITS) < num)
|
if ((count + EBITSET_ELT_BITS) < num)
|
||||||
{
|
{
|
||||||
/* The coast is clear, plant boot! */
|
/* The coast is clear, plant boot! */
|
||||||
|
|
||||||
#if EBITSET_ELT_WORDS == 2
|
#if EBITSET_ELT_WORDS == 2
|
||||||
word = srcp[0];
|
bitset_word word = srcp[0];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
@@ -774,7 +711,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
#else
|
#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;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
@@ -806,11 +743,11 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
/* Tread more carefully since we need to check
|
/* Tread more carefully since we need to check
|
||||||
if array overflows. */
|
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;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
for (word = srcp[i]; word; bitno++)
|
for (bitset_word word = srcp[i]; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
@@ -836,31 +773,22 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
static inline void
|
static inline void
|
||||||
ebitset_unused_clear (bitset dst)
|
ebitset_unused_clear (bitset dst)
|
||||||
{
|
{
|
||||||
unsigned last_bit;
|
bitset_bindex n_bits = BITSET_NBITS_ (dst);
|
||||||
bitset_bindex n_bits;
|
unsigned last_bit = n_bits % EBITSET_ELT_BITS;
|
||||||
|
|
||||||
n_bits = BITSET_NBITS_ (dst);
|
|
||||||
last_bit = n_bits % EBITSET_ELT_BITS;
|
|
||||||
|
|
||||||
if (last_bit)
|
if (last_bit)
|
||||||
{
|
{
|
||||||
bitset_windex eindex;
|
ebitset_elts *elts = EBITSET_ELTS (dst);
|
||||||
ebitset_elts *elts;
|
|
||||||
ebitset_elt *elt;
|
|
||||||
|
|
||||||
elts = EBITSET_ELTS (dst);
|
bitset_windex eindex = n_bits / EBITSET_ELT_BITS;
|
||||||
|
|
||||||
eindex = n_bits / EBITSET_ELT_BITS;
|
ebitset_elt *elt = elts[eindex];
|
||||||
|
|
||||||
elt = elts[eindex];
|
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
bitset_windex windex;
|
|
||||||
bitset_windex woffset;
|
|
||||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
windex = n_bits / BITSET_WORD_BITS;
|
bitset_windex windex = n_bits / BITSET_WORD_BITS;
|
||||||
woffset = eindex * EBITSET_ELT_WORDS;
|
bitset_windex woffset = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
||||||
windex++;
|
windex++;
|
||||||
@@ -874,14 +802,11 @@ ebitset_unused_clear (bitset dst)
|
|||||||
static void
|
static void
|
||||||
ebitset_ones (bitset dst)
|
ebitset_ones (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_windex j;
|
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
|
||||||
ebitset_elt *elt;
|
|
||||||
|
|
||||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
|
||||||
{
|
{
|
||||||
/* Create new elements if they cannot be found. Perhaps
|
/* Create new elements if they cannot be found. Perhaps
|
||||||
we should just add pointers to a ones element? */
|
we should just add pointers to a ones element? */
|
||||||
elt =
|
ebitset_elt *elt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||||
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
||||||
}
|
}
|
||||||
@@ -893,14 +818,11 @@ ebitset_ones (bitset dst)
|
|||||||
static bool
|
static bool
|
||||||
ebitset_empty_p (bitset dst)
|
ebitset_empty_p (bitset dst)
|
||||||
{
|
{
|
||||||
ebitset_elts *elts;
|
|
||||||
bitset_windex j;
|
|
||||||
|
|
||||||
if (EBITSET_ZERO_P (dst))
|
if (EBITSET_ZERO_P (dst))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
elts = EBITSET_ELTS (dst);
|
ebitset_elts *elts = EBITSET_ELTS (dst);
|
||||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
@@ -923,23 +845,18 @@ ebitset_empty_p (bitset dst)
|
|||||||
static void
|
static void
|
||||||
ebitset_not (bitset dst, bitset src)
|
ebitset_not (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
ebitset_elt *selt;
|
|
||||||
ebitset_elt *delt;
|
|
||||||
bitset_windex j;
|
|
||||||
|
|
||||||
ebitset_resize (dst, BITSET_NBITS_ (src));
|
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
|
/* Create new elements for dst if they cannot be found
|
||||||
or substitute zero elements if src elements not found. */
|
or substitute zero elements if src elements not found. */
|
||||||
selt =
|
ebitset_elt *selt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
||||||
delt =
|
ebitset_elt *delt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
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_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
|
||||||
}
|
}
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
@@ -951,26 +868,16 @@ ebitset_not (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
ebitset_subset_p (bitset dst, bitset src)
|
ebitset_subset_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex j;
|
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||||
ebitset_elts *selts;
|
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||||
ebitset_elts *delts;
|
|
||||||
bitset_windex ssize;
|
|
||||||
bitset_windex dsize;
|
|
||||||
|
|
||||||
selts = EBITSET_ELTS (src);
|
bitset_windex ssize = EBITSET_SIZE (src);
|
||||||
delts = EBITSET_ELTS (dst);
|
bitset_windex dsize = EBITSET_SIZE (dst);
|
||||||
|
|
||||||
ssize = EBITSET_SIZE (src);
|
for (bitset_windex j = 0; j < ssize; j++)
|
||||||
dsize = EBITSET_SIZE (dst);
|
|
||||||
|
|
||||||
for (j = 0; j < ssize; j++)
|
|
||||||
{
|
{
|
||||||
unsigned i;
|
ebitset_elt *selt = j < ssize ? selts[j] : 0;
|
||||||
ebitset_elt *selt;
|
ebitset_elt *delt = j < dsize ? delts[j] : 0;
|
||||||
ebitset_elt *delt;
|
|
||||||
|
|
||||||
selt = j < ssize ? selts[j] : 0;
|
|
||||||
delt = j < dsize ? delts[j] : 0;
|
|
||||||
|
|
||||||
if (!selt && !delt)
|
if (!selt && !delt)
|
||||||
continue;
|
continue;
|
||||||
@@ -980,7 +887,7 @@ ebitset_subset_p (bitset dst, bitset src)
|
|||||||
if (!delt)
|
if (!delt)
|
||||||
delt = &ebitset_zero_elts[0];
|
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]
|
if (EBITSET_WORDS (delt)[i]
|
||||||
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
||||||
return false;
|
return false;
|
||||||
@@ -993,31 +900,21 @@ ebitset_subset_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
ebitset_disjoint_p (bitset dst, bitset src)
|
ebitset_disjoint_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex j;
|
ebitset_elts *selts = EBITSET_ELTS (src);
|
||||||
ebitset_elts *selts;
|
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||||
ebitset_elts *delts;
|
|
||||||
bitset_windex ssize;
|
|
||||||
bitset_windex dsize;
|
|
||||||
|
|
||||||
selts = EBITSET_ELTS (src);
|
bitset_windex ssize = EBITSET_SIZE (src);
|
||||||
delts = EBITSET_ELTS (dst);
|
bitset_windex dsize = EBITSET_SIZE (dst);
|
||||||
|
|
||||||
ssize = EBITSET_SIZE (src);
|
for (bitset_windex j = 0; j < ssize; j++)
|
||||||
dsize = EBITSET_SIZE (dst);
|
|
||||||
|
|
||||||
for (j = 0; j < ssize; j++)
|
|
||||||
{
|
{
|
||||||
unsigned i;
|
ebitset_elt *selt = j < ssize ? selts[j] : 0;
|
||||||
ebitset_elt *selt;
|
ebitset_elt *delt = j < dsize ? delts[j] : 0;
|
||||||
ebitset_elt *delt;
|
|
||||||
|
|
||||||
selt = j < ssize ? selts[j] : 0;
|
|
||||||
delt = j < dsize ? delts[j] : 0;
|
|
||||||
|
|
||||||
if (!selt || !delt)
|
if (!selt || !delt)
|
||||||
continue;
|
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]))
|
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1029,42 +926,27 @@ ebitset_disjoint_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
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;
|
bool changed = false;
|
||||||
unsigned i;
|
|
||||||
bitset_windex j;
|
|
||||||
|
|
||||||
ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
|
ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
|
||||||
|
|
||||||
ssize1 = EBITSET_SIZE (src1);
|
bitset_windex ssize1 = EBITSET_SIZE (src1);
|
||||||
ssize2 = EBITSET_SIZE (src2);
|
bitset_windex ssize2 = EBITSET_SIZE (src2);
|
||||||
dsize = EBITSET_SIZE (dst);
|
bitset_windex dsize = EBITSET_SIZE (dst);
|
||||||
size = ssize1;
|
bitset_windex size = ssize1;
|
||||||
if (size < ssize2)
|
if (size < ssize2)
|
||||||
size = ssize2;
|
size = ssize2;
|
||||||
|
|
||||||
selts1 = EBITSET_ELTS (src1);
|
ebitset_elts *selts1 = EBITSET_ELTS (src1);
|
||||||
selts2 = EBITSET_ELTS (src2);
|
ebitset_elts *selts2 = EBITSET_ELTS (src2);
|
||||||
delts = EBITSET_ELTS (dst);
|
ebitset_elts *delts = EBITSET_ELTS (dst);
|
||||||
|
|
||||||
|
bitset_windex j = 0;
|
||||||
for (j = 0; j < size; j++)
|
for (j = 0; j < size; j++)
|
||||||
{
|
{
|
||||||
ebitset_elt *selt1;
|
ebitset_elt *selt1 = j < ssize1 ? selts1[j] : 0;
|
||||||
ebitset_elt *selt2;
|
ebitset_elt *selt2 = j < ssize2 ? selts2[j] : 0;
|
||||||
ebitset_elt *delt;
|
ebitset_elt *delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
selt1 = j < ssize1 ? selts1[j] : 0;
|
|
||||||
selt2 = j < ssize2 ? selts2[j] : 0;
|
|
||||||
delt = j < dsize ? delts[j] : 0;
|
|
||||||
|
|
||||||
if (!selt1 && !selt2)
|
if (!selt1 && !selt2)
|
||||||
{
|
{
|
||||||
@@ -1085,16 +967,16 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
else
|
else
|
||||||
delts[j] = 0;
|
delts[j] = 0;
|
||||||
|
|
||||||
srcp1 = EBITSET_WORDS (selt1);
|
bitset_word *srcp1 = EBITSET_WORDS (selt1);
|
||||||
srcp2 = EBITSET_WORDS (selt2);
|
bitset_word *srcp2 = EBITSET_WORDS (selt2);
|
||||||
dstp = EBITSET_WORDS (delt);
|
bitset_word *dstp = EBITSET_WORDS (delt);
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case BITSET_OP_OR:
|
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++;
|
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||||
|
|
||||||
@@ -1107,7 +989,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_AND:
|
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++;
|
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||||
|
|
||||||
@@ -1120,7 +1002,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_XOR:
|
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++;
|
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||||
|
|
||||||
@@ -1133,7 +1015,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_ANDN:
|
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++);
|
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||||
|
|
||||||
@@ -1159,12 +1041,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. */
|
/* If we have elements of DST left over, free them all. */
|
||||||
for (; j < dsize; j++)
|
for (; j < dsize; j++)
|
||||||
{
|
{
|
||||||
ebitset_elt *delt;
|
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
delt = delts[j];
|
ebitset_elt *delt = delts[j];
|
||||||
|
|
||||||
if (delt)
|
if (delt)
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
@@ -1177,19 +1056,17 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
static bool
|
static bool
|
||||||
ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bool changed;
|
|
||||||
|
|
||||||
if (EBITSET_ZERO_P (src2))
|
if (EBITSET_ZERO_P (src2))
|
||||||
{
|
{
|
||||||
ebitset_weed (dst);
|
ebitset_weed (dst);
|
||||||
changed = EBITSET_ZERO_P (dst);
|
bool changed = EBITSET_ZERO_P (dst);
|
||||||
ebitset_zero (dst);
|
ebitset_zero (dst);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
else if (EBITSET_ZERO_P (src1))
|
else if (EBITSET_ZERO_P (src1))
|
||||||
{
|
{
|
||||||
ebitset_weed (dst);
|
ebitset_weed (dst);
|
||||||
changed = EBITSET_ZERO_P (dst);
|
bool changed = EBITSET_ZERO_P (dst);
|
||||||
ebitset_zero (dst);
|
ebitset_zero (dst);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -1207,8 +1084,6 @@ ebitset_and (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bool changed;
|
|
||||||
|
|
||||||
if (EBITSET_ZERO_P (src2))
|
if (EBITSET_ZERO_P (src2))
|
||||||
{
|
{
|
||||||
return ebitset_copy_cmp (dst, src1);
|
return ebitset_copy_cmp (dst, src1);
|
||||||
@@ -1216,7 +1091,7 @@ ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
else if (EBITSET_ZERO_P (src1))
|
else if (EBITSET_ZERO_P (src1))
|
||||||
{
|
{
|
||||||
ebitset_weed (dst);
|
ebitset_weed (dst);
|
||||||
changed = EBITSET_ZERO_P (dst);
|
bool changed = EBITSET_ZERO_P (dst);
|
||||||
ebitset_zero (dst);
|
ebitset_zero (dst);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -1279,9 +1154,9 @@ static void
|
|||||||
ebitset_copy (bitset dst, bitset src)
|
ebitset_copy (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
if (BITSET_COMPATIBLE_ (dst, src))
|
if (BITSET_COMPATIBLE_ (dst, src))
|
||||||
ebitset_copy_ (dst, src);
|
ebitset_copy_ (dst, src);
|
||||||
else
|
else
|
||||||
bitset_copy_ (dst, src);
|
bitset_copy_ (dst, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
#include "bitset.h"
|
#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
|
#endif
|
||||||
|
|||||||
+68
-123
@@ -145,9 +145,7 @@ lbitset_elt_alloc (void)
|
|||||||
static inline lbitset_elt *
|
static inline lbitset_elt *
|
||||||
lbitset_elt_calloc (void)
|
lbitset_elt_calloc (void)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
lbitset_elt *elt = lbitset_elt_alloc ();
|
||||||
|
|
||||||
elt = lbitset_elt_alloc ();
|
|
||||||
memset (elt->words, 0, sizeof (elt->words));
|
memset (elt->words, 0, sizeof (elt->words));
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
@@ -210,8 +208,6 @@ lbitset_elt_unlink (bitset bset, lbitset_elt *elt)
|
|||||||
static inline void
|
static inline void
|
||||||
lbitset_prune (bitset bset, lbitset_elt *elt)
|
lbitset_prune (bitset bset, lbitset_elt *elt)
|
||||||
{
|
{
|
||||||
lbitset_elt *next;
|
|
||||||
|
|
||||||
if (!elt)
|
if (!elt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -230,6 +226,7 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
|
|||||||
bset->b.csize = 0;
|
bset->b.csize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lbitset_elt *next;
|
||||||
for (; elt; elt = next)
|
for (; elt; elt = next)
|
||||||
{
|
{
|
||||||
next = elt->next;
|
next = elt->next;
|
||||||
@@ -242,9 +239,7 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
|
|||||||
static inline bool
|
static inline bool
|
||||||
lbitset_elt_zero_p (lbitset_elt *elt)
|
lbitset_elt_zero_p (lbitset_elt *elt)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
|
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
|
||||||
if (elt->words[i])
|
if (elt->words[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -257,9 +252,8 @@ static inline void
|
|||||||
lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
||||||
{
|
{
|
||||||
bitset_windex windex = elt->index;
|
bitset_windex windex = elt->index;
|
||||||
lbitset_elt *ptr;
|
|
||||||
lbitset_elt *current;
|
|
||||||
|
|
||||||
|
lbitset_elt *current;
|
||||||
if (bset->b.csize)
|
if (bset->b.csize)
|
||||||
current = LBITSET_CURRENT (bset);
|
current = LBITSET_CURRENT (bset);
|
||||||
else
|
else
|
||||||
@@ -277,6 +271,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
somewhere before the current element. */
|
somewhere before the current element. */
|
||||||
else if (windex < bset->b.cindex)
|
else if (windex < bset->b.cindex)
|
||||||
{
|
{
|
||||||
|
lbitset_elt *ptr;
|
||||||
for (ptr = current;
|
for (ptr = current;
|
||||||
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
||||||
continue;
|
continue;
|
||||||
@@ -294,6 +289,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
/* Otherwise, it must go somewhere after the current element. */
|
/* Otherwise, it must go somewhere after the current element. */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
lbitset_elt *ptr;
|
||||||
for (ptr = current;
|
for (ptr = current;
|
||||||
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
||||||
continue;
|
continue;
|
||||||
@@ -319,7 +315,6 @@ static lbitset_elt *
|
|||||||
lbitset_elt_find (bitset bset, bitset_windex windex,
|
lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||||
enum lbitset_find_mode mode)
|
enum lbitset_find_mode mode)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
|
||||||
lbitset_elt *current;
|
lbitset_elt *current;
|
||||||
|
|
||||||
if (bset->b.csize)
|
if (bset->b.csize)
|
||||||
@@ -336,6 +331,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
|
|
||||||
if (current)
|
if (current)
|
||||||
{
|
{
|
||||||
|
lbitset_elt *elt;
|
||||||
if (windex < bset->b.cindex)
|
if (windex < bset->b.cindex)
|
||||||
{
|
{
|
||||||
for (elt = current;
|
for (elt = current;
|
||||||
@@ -371,8 +367,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
|
|
||||||
case LBITSET_CREATE:
|
case LBITSET_CREATE:
|
||||||
windex -= windex % LBITSET_ELT_WORDS;
|
windex -= windex % LBITSET_ELT_WORDS;
|
||||||
|
lbitset_elt *elt = lbitset_elt_calloc ();
|
||||||
elt = lbitset_elt_calloc ();
|
|
||||||
elt->index = windex;
|
elt->index = windex;
|
||||||
lbitset_elt_link (bset, elt);
|
lbitset_elt_link (bset, elt);
|
||||||
return elt;
|
return elt;
|
||||||
@@ -387,10 +382,8 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
static inline void
|
static inline void
|
||||||
lbitset_weed (bitset bset)
|
lbitset_weed (bitset bset)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
|
||||||
lbitset_elt *next;
|
lbitset_elt *next;
|
||||||
|
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt; elt = next)
|
||||||
for (elt = LBITSET_HEAD (bset); elt; elt = next)
|
|
||||||
{
|
{
|
||||||
next = elt->next;
|
next = elt->next;
|
||||||
if (lbitset_elt_zero_p (elt))
|
if (lbitset_elt_zero_p (elt))
|
||||||
@@ -403,9 +396,7 @@ lbitset_weed (bitset bset)
|
|||||||
static void
|
static void
|
||||||
lbitset_zero (bitset bset)
|
lbitset_zero (bitset bset)
|
||||||
{
|
{
|
||||||
lbitset_elt *head;
|
lbitset_elt *head = LBITSET_HEAD (bset);
|
||||||
|
|
||||||
head = LBITSET_HEAD (bset);
|
|
||||||
if (!head)
|
if (!head)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -418,22 +409,20 @@ lbitset_zero (bitset bset)
|
|||||||
static inline bool
|
static inline bool
|
||||||
lbitset_equal_p (bitset dst, bitset src)
|
lbitset_equal_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
lbitset_elt *selt;
|
|
||||||
lbitset_elt *delt;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (src == dst)
|
if (src == dst)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
lbitset_weed (src);
|
lbitset_weed (src);
|
||||||
lbitset_weed (dst);
|
lbitset_weed (dst);
|
||||||
|
lbitset_elt *selt;
|
||||||
|
lbitset_elt *delt;
|
||||||
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
||||||
selt && delt; selt = selt->next, delt = delt->next)
|
selt && delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (selt->index != delt->index)
|
if (selt->index != delt->index)
|
||||||
return false;
|
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])
|
if (delt->words[j] != selt->words[j])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -445,22 +434,18 @@ lbitset_equal_p (bitset dst, bitset src)
|
|||||||
static inline void
|
static inline void
|
||||||
lbitset_copy (bitset dst, bitset src)
|
lbitset_copy (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
|
||||||
lbitset_elt *head;
|
|
||||||
lbitset_elt *prev;
|
|
||||||
lbitset_elt *tmp;
|
|
||||||
|
|
||||||
if (src == dst)
|
if (src == dst)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lbitset_zero (dst);
|
lbitset_zero (dst);
|
||||||
|
|
||||||
head = LBITSET_HEAD (src);
|
lbitset_elt *head = LBITSET_HEAD (src);
|
||||||
if (!head)
|
if (!head)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
prev = 0;
|
lbitset_elt *prev = 0;
|
||||||
for (elt = head; elt; elt = elt->next)
|
lbitset_elt *tmp;
|
||||||
|
for (lbitset_elt *elt = head; elt; elt = elt->next)
|
||||||
{
|
{
|
||||||
tmp = lbitset_elt_alloc ();
|
tmp = lbitset_elt_alloc ();
|
||||||
tmp->index = elt->index;
|
tmp->index = elt->index;
|
||||||
@@ -507,10 +492,10 @@ lbitset_copy_cmp (bitset dst, bitset src)
|
|||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
lbitset_resize (bitset src, bitset_bindex size)
|
lbitset_resize (bitset src, bitset_bindex size)
|
||||||
{
|
{
|
||||||
BITSET_NBITS_ (src) = size;
|
BITSET_NBITS_ (src) = size;
|
||||||
|
|
||||||
/* Need to prune any excess bits. FIXME. */
|
/* Need to prune any excess bits. FIXME. */
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set bit BITNO in bitset DST. */
|
/* Set bit BITNO in bitset DST. */
|
||||||
@@ -569,29 +554,19 @@ static bitset_bindex
|
|||||||
lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex rbitno;
|
lbitset_elt *elt = LBITSET_TAIL (bset);
|
||||||
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);
|
|
||||||
if (!elt)
|
if (!elt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
n_bits = (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
|
bitset_bindex n_bits = (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
|
||||||
rbitno = *next;
|
bitset_bindex rbitno = *next;
|
||||||
|
|
||||||
if (rbitno >= n_bits)
|
if (rbitno >= n_bits)
|
||||||
return 0;
|
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. */
|
/* Skip back to starting element. */
|
||||||
for (; elt && elt->index > windex; elt = elt->prev)
|
for (; elt && elt->index > windex; elt = elt->prev)
|
||||||
@@ -600,6 +575,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
if (!elt)
|
if (!elt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
unsigned bcount;
|
||||||
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
/* We are trying to start in no-mans land so start
|
/* We are trying to start in no-mans land so start
|
||||||
@@ -612,8 +588,8 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
bcount = bitno % BITSET_WORD_BITS;
|
bcount = bitno % BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 0;
|
bitset_bindex count = 0;
|
||||||
boffset = windex * BITSET_WORD_BITS;
|
bitset_bindex boffset = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
@@ -626,7 +602,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
windex--, boffset -= BITSET_WORD_BITS,
|
windex--, boffset -= BITSET_WORD_BITS,
|
||||||
bcount = BITSET_WORD_BITS - 1)
|
bcount = BITSET_WORD_BITS - 1)
|
||||||
{
|
{
|
||||||
word =
|
bitset_word word =
|
||||||
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
||||||
|
|
||||||
for (; word; bcount--)
|
for (; word; bcount--)
|
||||||
@@ -664,19 +640,16 @@ static bitset_bindex
|
|||||||
lbitset_list (bitset bset, bitset_bindex *list,
|
lbitset_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
lbitset_elt *head = LBITSET_HEAD (bset);
|
||||||
bitset_windex windex;
|
|
||||||
bitset_bindex count;
|
|
||||||
lbitset_elt *elt;
|
|
||||||
lbitset_elt *head;
|
|
||||||
bitset_word word;
|
|
||||||
|
|
||||||
head = LBITSET_HEAD (bset);
|
|
||||||
if (!head)
|
if (!head)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bitno = *next;
|
bitset_windex windex;
|
||||||
count = 0;
|
lbitset_elt *elt;
|
||||||
|
bitset_word word;
|
||||||
|
|
||||||
|
bitset_bindex bitno = *next;
|
||||||
|
bitset_bindex count = 0;
|
||||||
|
|
||||||
if (!bitno)
|
if (!bitno)
|
||||||
{
|
{
|
||||||
@@ -746,7 +719,6 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
while (elt)
|
while (elt)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
bitset_word *srcp = elt->words;
|
bitset_word *srcp = elt->words;
|
||||||
|
|
||||||
if ((count + LBITSET_ELT_BITS) < num)
|
if ((count + LBITSET_ELT_BITS) < num)
|
||||||
@@ -795,7 +767,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
word = srcp[i];
|
word = srcp[i];
|
||||||
if (word)
|
if (word)
|
||||||
@@ -827,7 +799,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
/* Tread more carefully since we need to check
|
/* Tread more carefully since we need to check
|
||||||
if array overflows. */
|
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 (word = srcp[i]; word; bitno++)
|
||||||
{
|
{
|
||||||
@@ -911,21 +883,18 @@ lbitset_unused_clear (bitset dst)
|
|||||||
static void
|
static void
|
||||||
lbitset_ones (bitset dst)
|
lbitset_ones (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_windex windex;
|
|
||||||
lbitset_elt *elt;
|
|
||||||
|
|
||||||
/* This is a decidedly unfriendly operation for a linked list
|
/* This is a decidedly unfriendly operation for a linked list
|
||||||
bitset! It makes a sparse bitset become dense. An alternative
|
bitset! It makes a sparse bitset become dense. An alternative
|
||||||
is to have a flag that indicates that the bitset stores the
|
is to have a flag that indicates that the bitset stores the
|
||||||
complement of what it indicates. */
|
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. */
|
/* 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));
|
memset (elt->words, -1, sizeof (elt->words));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,22 +905,17 @@ lbitset_ones (bitset dst)
|
|||||||
static void
|
static void
|
||||||
lbitset_not (bitset dst, bitset src)
|
lbitset_not (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
lbitset_elt *selt;
|
bitset_windex windex
|
||||||
lbitset_elt *delt;
|
= (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||||
bitset_windex i;
|
|
||||||
unsigned j;
|
|
||||||
bitset_windex windex;
|
|
||||||
|
|
||||||
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
for (bitset_windex i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||||
|
|
||||||
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
|
||||||
{
|
{
|
||||||
/* Create new elements for dst if they cannot be found
|
/* Create new elements for dst if they cannot be found
|
||||||
or substitute zero elements if src elements not found. */
|
or substitute zero elements if src elements not found. */
|
||||||
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
lbitset_elt *selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
||||||
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
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];
|
delt->words[j] = ~selt->words[j];
|
||||||
}
|
}
|
||||||
lbitset_unused_clear (dst);
|
lbitset_unused_clear (dst);
|
||||||
@@ -964,11 +928,7 @@ lbitset_not (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
lbitset_subset_p (bitset dst, bitset src)
|
lbitset_subset_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
lbitset_elt *selt;
|
for (lbitset_elt *selt = LBITSET_HEAD (src), *delt = LBITSET_HEAD (dst);
|
||||||
lbitset_elt *delt;
|
|
||||||
unsigned j;
|
|
||||||
|
|
||||||
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
|
||||||
selt || delt; selt = selt->next, delt = delt->next)
|
selt || delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (!selt)
|
if (!selt)
|
||||||
@@ -989,7 +949,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]))
|
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1001,11 +961,7 @@ lbitset_subset_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
lbitset_disjoint_p (bitset dst, bitset src)
|
lbitset_disjoint_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
lbitset_elt *selt;
|
for (lbitset_elt *selt = LBITSET_HEAD (src), *delt = LBITSET_HEAD (dst);
|
||||||
lbitset_elt *delt;
|
|
||||||
unsigned j;
|
|
||||||
|
|
||||||
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
|
|
||||||
selt && delt; selt = selt->next, delt = delt->next)
|
selt && delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (selt->index != delt->index)
|
if (selt->index != delt->index)
|
||||||
@@ -1025,7 +981,7 @@ lbitset_disjoint_p (bitset dst, bitset src)
|
|||||||
continue;
|
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])
|
if (selt->words[j] & delt->words[j])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1039,8 +995,6 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||||
lbitset_elt *delt = LBITSET_HEAD (dst);
|
lbitset_elt *delt = LBITSET_HEAD (dst);
|
||||||
bitset_windex windex1;
|
|
||||||
bitset_windex windex2;
|
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
lbitset_elt *stmp1;
|
lbitset_elt *stmp1;
|
||||||
lbitset_elt *stmp2;
|
lbitset_elt *stmp2;
|
||||||
@@ -1049,13 +1003,12 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
bitset_word *srcp2;
|
bitset_word *srcp2;
|
||||||
bitset_word *dstp;
|
bitset_word *dstp;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
LBITSET_HEAD (dst) = 0;
|
LBITSET_HEAD (dst) = 0;
|
||||||
dst->b.csize = 0;
|
dst->b.csize = 0;
|
||||||
|
|
||||||
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
bitset_windex windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||||
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
bitset_windex windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||||
|
|
||||||
while (selt1 || selt2)
|
while (selt1 || selt2)
|
||||||
{
|
{
|
||||||
@@ -1116,7 +1069,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case BITSET_OP_OR:
|
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++;
|
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||||
|
|
||||||
@@ -1129,7 +1082,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_AND:
|
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++;
|
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||||
|
|
||||||
@@ -1142,7 +1095,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_XOR:
|
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++;
|
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||||
|
|
||||||
@@ -1155,7 +1108,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_ANDN:
|
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++);
|
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||||
|
|
||||||
@@ -1196,19 +1149,18 @@ lbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
{
|
{
|
||||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||||
bool changed;
|
|
||||||
|
|
||||||
if (!selt2)
|
if (!selt2)
|
||||||
{
|
{
|
||||||
lbitset_weed (dst);
|
lbitset_weed (dst);
|
||||||
changed = !LBITSET_HEAD (dst);
|
bool changed = !LBITSET_HEAD (dst);
|
||||||
lbitset_zero (dst);
|
lbitset_zero (dst);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
else if (!selt1)
|
else if (!selt1)
|
||||||
{
|
{
|
||||||
lbitset_weed (dst);
|
lbitset_weed (dst);
|
||||||
changed = !LBITSET_HEAD (dst);
|
bool changed = !LBITSET_HEAD (dst);
|
||||||
lbitset_zero (dst);
|
lbitset_zero (dst);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -1228,7 +1180,6 @@ lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
{
|
{
|
||||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||||
bool changed;
|
|
||||||
|
|
||||||
if (!selt2)
|
if (!selt2)
|
||||||
{
|
{
|
||||||
@@ -1237,7 +1188,7 @@ lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
else if (!selt1)
|
else if (!selt1)
|
||||||
{
|
{
|
||||||
lbitset_weed (dst);
|
lbitset_weed (dst);
|
||||||
changed = !LBITSET_HEAD (dst);
|
bool changed = !LBITSET_HEAD (dst);
|
||||||
lbitset_zero (dst);
|
lbitset_zero (dst);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -1375,24 +1326,18 @@ lbitset_release_memory (void)
|
|||||||
void
|
void
|
||||||
debug_lbitset (bitset bset)
|
debug_lbitset (bitset bset)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
if (!bset)
|
if (!bset)
|
||||||
return;
|
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);
|
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 = elt->words[i];
|
||||||
bitset_word word;
|
|
||||||
|
|
||||||
word = elt->words[i];
|
|
||||||
|
|
||||||
fprintf (stderr, " Word %u:", 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)))
|
if ((word & ((bitset_word) 1 << j)))
|
||||||
fprintf (stderr, " %u", j);
|
fprintf (stderr, " %u", j);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
|||||||
+3
-3
@@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
#include "bitset.h"
|
#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
|
#endif
|
||||||
|
|||||||
+3
-7
@@ -39,16 +39,12 @@ lib_libbison_a_SOURCES += \
|
|||||||
lib/bitsetv-print.h \
|
lib/bitsetv-print.h \
|
||||||
lib/bitsetv-print.c
|
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.
|
# Non-gnulib sources in Bison's internal library.
|
||||||
lib_libbison_a_SOURCES += \
|
lib_libbison_a_SOURCES += \
|
||||||
lib/get-errno.h \
|
lib/get-errno.h \
|
||||||
lib/get-errno.c
|
lib/get-errno.c \
|
||||||
|
lib/path-join.h \
|
||||||
|
lib/path-join.c
|
||||||
|
|
||||||
# The Yacc compatibility library.
|
# The Yacc compatibility library.
|
||||||
if ENABLE_YACC
|
if ENABLE_YACC
|
||||||
|
|||||||
@@ -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)
|
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. */
|
variable, and NAME is a character string describing its purpose. */
|
||||||
|
|
||||||
/* The total execution time. */
|
/* The total execution time. */
|
||||||
DEFTIMEVAR (TV_TOTAL , "total time")
|
DEFTIMEVAR (tv_total , "total time")
|
||||||
|
|
||||||
/* Time spent in the reader. */
|
/* Time spent in the reader. */
|
||||||
DEFTIMEVAR (TV_READER , "reader")
|
DEFTIMEVAR (tv_reader , "reader")
|
||||||
DEFTIMEVAR (TV_SCANNING , "scanner")
|
DEFTIMEVAR (tv_scanning , "scanner")
|
||||||
DEFTIMEVAR (TV_PARSING , "parser")
|
DEFTIMEVAR (tv_parsing , "parser")
|
||||||
|
|
||||||
/* Time spent handling the grammar. */
|
/* Time spent handling the grammar. */
|
||||||
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
|
DEFTIMEVAR (tv_reduce , "reducing the grammar")
|
||||||
DEFTIMEVAR (TV_SETS , "computing the sets")
|
DEFTIMEVAR (tv_sets , "computing the sets")
|
||||||
DEFTIMEVAR (TV_LR0 , "LR(0)")
|
DEFTIMEVAR (tv_lr0 , "LR(0)")
|
||||||
DEFTIMEVAR (TV_LALR , "LALR(1)")
|
DEFTIMEVAR (tv_lalr , "LALR(1)")
|
||||||
DEFTIMEVAR (TV_IELR_PHASE1 , "IELR(1) Phase 1")
|
DEFTIMEVAR (tv_ielr_phase1 , "IELR(1) Phase 1")
|
||||||
DEFTIMEVAR (TV_IELR_PHASE2 , "IELR(1) Phase 2")
|
DEFTIMEVAR (tv_ielr_phase2 , "IELR(1) Phase 2")
|
||||||
DEFTIMEVAR (TV_IELR_PHASE3 , "IELR(1) Phase 3")
|
DEFTIMEVAR (tv_ielr_phase3 , "IELR(1) Phase 3")
|
||||||
DEFTIMEVAR (TV_IELR_PHASE4 , "IELR(1) Phase 4")
|
DEFTIMEVAR (tv_ielr_phase4 , "IELR(1) Phase 4")
|
||||||
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
|
DEFTIMEVAR (tv_conflicts , "conflicts")
|
||||||
|
|
||||||
/* Time spent outputing results. */
|
/* Time spent outputting results. */
|
||||||
DEFTIMEVAR (TV_REPORT , "outputing report")
|
DEFTIMEVAR (tv_report , "outputting report")
|
||||||
DEFTIMEVAR (TV_GRAPH , "outputing graph")
|
DEFTIMEVAR (tv_graph , "outputting graph")
|
||||||
DEFTIMEVAR (TV_XML , "outputing xml")
|
DEFTIMEVAR (tv_xml , "outputting xml")
|
||||||
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
|
DEFTIMEVAR (tv_actions , "parser action tables")
|
||||||
DEFTIMEVAR (TV_PARSER , "outputing parser")
|
DEFTIMEVAR (tv_parser , "outputting parser")
|
||||||
DEFTIMEVAR (TV_M4 , "running m4")
|
DEFTIMEVAR (tv_m4 , "running m4")
|
||||||
|
|
||||||
/* Time spent by freeing the memory :). */
|
/* 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 */
|
|
||||||
+121
-236
@@ -56,19 +56,14 @@ static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
|
|||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
vbitset_resize (bitset src, bitset_bindex n_bits)
|
vbitset_resize (bitset src, bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
bitset_windex oldsize;
|
|
||||||
bitset_windex newsize;
|
|
||||||
|
|
||||||
if (n_bits == BITSET_NBITS_ (src))
|
if (n_bits == BITSET_NBITS_ (src))
|
||||||
return n_bits;
|
return n_bits;
|
||||||
|
|
||||||
oldsize = VBITSET_SIZE (src);
|
bitset_windex oldsize = VBITSET_SIZE (src);
|
||||||
newsize = VBITSET_N_WORDS (n_bits);
|
bitset_windex newsize = VBITSET_N_WORDS (n_bits);
|
||||||
|
|
||||||
if (oldsize < newsize)
|
if (oldsize < newsize)
|
||||||
{
|
{
|
||||||
bitset_windex size;
|
|
||||||
|
|
||||||
/* The bitset needs to grow. If we already have enough memory
|
/* The bitset needs to grow. If we already have enough memory
|
||||||
allocated, then just zero what we need. */
|
allocated, then just zero what we need. */
|
||||||
if (newsize > VBITSET_ASIZE (src))
|
if (newsize > VBITSET_ASIZE (src))
|
||||||
@@ -78,6 +73,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
|
|||||||
grow the bitset 25% larger than requested to reduce
|
grow the bitset 25% larger than requested to reduce
|
||||||
number of reallocations. */
|
number of reallocations. */
|
||||||
|
|
||||||
|
bitset_windex size;
|
||||||
if (oldsize == 0)
|
if (oldsize == 0)
|
||||||
size = newsize;
|
size = newsize;
|
||||||
else
|
else
|
||||||
@@ -115,9 +111,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
|
|||||||
|
|
||||||
/* Set bit BITNO in bitset DST. */
|
/* Set bit BITNO in bitset DST. */
|
||||||
static void
|
static void
|
||||||
vbitset_set (dst, bitno)
|
vbitset_set (bitset dst, bitset_bindex bitno)
|
||||||
bitset dst;
|
|
||||||
bitset_bindex bitno;
|
|
||||||
{
|
{
|
||||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
|
||||||
@@ -134,9 +128,7 @@ vbitset_set (dst, bitno)
|
|||||||
|
|
||||||
/* Reset bit BITNO in bitset DST. */
|
/* Reset bit BITNO in bitset DST. */
|
||||||
static void
|
static void
|
||||||
vbitset_reset (dst, bitno)
|
vbitset_reset (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||||
bitset dst ATTRIBUTE_UNUSED;
|
|
||||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
|
||||||
{
|
{
|
||||||
/* We must be accessing outside the cache so the bit is
|
/* We must be accessing outside the cache so the bit is
|
||||||
zero anyway. */
|
zero anyway. */
|
||||||
@@ -145,9 +137,8 @@ vbitset_reset (dst, bitno)
|
|||||||
|
|
||||||
/* Test bit BITNO in bitset SRC. */
|
/* Test bit BITNO in bitset SRC. */
|
||||||
static bool
|
static bool
|
||||||
vbitset_test (src, bitno)
|
vbitset_test (bitset src ATTRIBUTE_UNUSED,
|
||||||
bitset src ATTRIBUTE_UNUSED;
|
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
|
||||||
{
|
{
|
||||||
/* We must be accessing outside the cache so the bit is
|
/* We must be accessing outside the cache so the bit is
|
||||||
zero anyway. */
|
zero anyway. */
|
||||||
@@ -160,22 +151,13 @@ vbitset_test (src, bitno)
|
|||||||
actual number of bits found and with *NEXT indicating where search
|
actual number of bits found and with *NEXT indicating where search
|
||||||
stopped. */
|
stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
vbitset_list_reverse (src, list, num, next)
|
vbitset_list_reverse (bitset src, bitset_bindex *list,
|
||||||
bitset src;
|
bitset_bindex num, bitset_bindex *next)
|
||||||
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_word *srcp = VBITSET_WORDS (src);
|
||||||
bitset_bindex n_bits = BITSET_SIZE_ (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
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
@@ -183,19 +165,17 @@ vbitset_list_reverse (src, list, num, next)
|
|||||||
if (rbitno >= n_bits)
|
if (rbitno >= n_bits)
|
||||||
return 0;
|
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;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
bitcnt = bitno % BITSET_WORD_BITS;
|
unsigned bitcnt = bitno % BITSET_WORD_BITS;
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bitset_word word;
|
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
|
|
||||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
@@ -220,26 +200,21 @@ vbitset_list_reverse (src, list, num, next)
|
|||||||
|
|
||||||
|
|
||||||
/* Find list of up to NUM bits set in BSET starting from and including
|
/* 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
|
*NEXT and store in array LIST. Return with actual number of bits
|
||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
vbitset_list (src, list, num, next)
|
vbitset_list (bitset src, bitset_bindex *list,
|
||||||
bitset src;
|
bitset_bindex num, bitset_bindex *next)
|
||||||
bitset_bindex *list;
|
|
||||||
bitset_bindex num;
|
|
||||||
bitset_bindex *next;
|
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
|
||||||
bitset_bindex count;
|
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
bitset_bindex bitoff;
|
bitset_bindex bitoff;
|
||||||
bitset_windex size = VBITSET_SIZE (src);
|
bitset_windex size = VBITSET_SIZE (src);
|
||||||
bitset_word *srcp = VBITSET_WORDS (src);
|
bitset_word *srcp = VBITSET_WORDS (src);
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
bitno = *next;
|
bitset_bindex bitno = *next;
|
||||||
|
|
||||||
count = 0;
|
bitset_bindex count = 0;
|
||||||
if (!bitno)
|
if (!bitno)
|
||||||
{
|
{
|
||||||
/* Many bitsets are zero, so make this common case fast. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
@@ -327,12 +302,9 @@ vbitset_list (src, list, num, next)
|
|||||||
|
|
||||||
/* Ensure that any unused bits within the last word are clear. */
|
/* Ensure that any unused bits within the last word are clear. */
|
||||||
static inline void
|
static inline void
|
||||||
vbitset_unused_clear (dst)
|
vbitset_unused_clear (bitset dst)
|
||||||
bitset dst;
|
|
||||||
{
|
{
|
||||||
unsigned last_bit;
|
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||||
|
|
||||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
|
||||||
if (last_bit)
|
if (last_bit)
|
||||||
VBITSET_WORDS (dst)[VBITSET_SIZE (dst) - 1] &=
|
VBITSET_WORDS (dst)[VBITSET_SIZE (dst) - 1] &=
|
||||||
((bitset_word) 1 << last_bit) - 1;
|
((bitset_word) 1 << last_bit) - 1;
|
||||||
@@ -343,9 +315,7 @@ static void
|
|||||||
vbitset_ones (bitset dst)
|
vbitset_ones (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
unsigned bytes;
|
unsigned bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
||||||
|
|
||||||
bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
|
||||||
|
|
||||||
memset (dstp, -1, bytes);
|
memset (dstp, -1, bytes);
|
||||||
vbitset_unused_clear (dst);
|
vbitset_unused_clear (dst);
|
||||||
@@ -356,9 +326,7 @@ static void
|
|||||||
vbitset_zero (bitset dst)
|
vbitset_zero (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
unsigned bytes;
|
unsigned bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
||||||
|
|
||||||
bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
|
|
||||||
|
|
||||||
memset (dstp, 0, bytes);
|
memset (dstp, 0, bytes);
|
||||||
}
|
}
|
||||||
@@ -367,10 +335,9 @@ vbitset_zero (bitset dst)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_empty_p (bitset dst)
|
vbitset_empty_p (bitset dst)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
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])
|
if (dstp[i])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -381,20 +348,15 @@ vbitset_empty_p (bitset dst)
|
|||||||
static void
|
static void
|
||||||
vbitset_copy1 (bitset dst, bitset src)
|
vbitset_copy1 (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_word *srcp;
|
|
||||||
bitset_word *dstp;
|
|
||||||
bitset_windex ssize;
|
|
||||||
bitset_windex dsize;
|
|
||||||
|
|
||||||
if (src == dst)
|
if (src == dst)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vbitset_resize (dst, BITSET_SIZE_ (src));
|
vbitset_resize (dst, BITSET_SIZE_ (src));
|
||||||
|
|
||||||
srcp = VBITSET_WORDS (src);
|
bitset_word *srcp = VBITSET_WORDS (src);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
ssize = VBITSET_SIZE (src);
|
bitset_windex ssize = VBITSET_SIZE (src);
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
||||||
|
|
||||||
@@ -406,21 +368,15 @@ vbitset_copy1 (bitset dst, bitset src)
|
|||||||
static void
|
static void
|
||||||
vbitset_not (bitset dst, bitset src)
|
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));
|
vbitset_resize (dst, BITSET_SIZE_ (src));
|
||||||
|
|
||||||
srcp = VBITSET_WORDS (src);
|
bitset_word *srcp = VBITSET_WORDS (src);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
ssize = VBITSET_SIZE (src);
|
bitset_windex ssize = VBITSET_SIZE (src);
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < ssize; i++)
|
for (unsigned i = 0; i < ssize; i++)
|
||||||
*dstp++ = ~(*srcp++);
|
*dstp++ = ~(*srcp++);
|
||||||
|
|
||||||
vbitset_unused_clear (dst);
|
vbitset_unused_clear (dst);
|
||||||
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
||||||
@@ -431,15 +387,15 @@ vbitset_not (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_equal_p (bitset dst, bitset src)
|
vbitset_equal_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
bitset_word *srcp = VBITSET_WORDS (src);
|
bitset_word *srcp = VBITSET_WORDS (src);
|
||||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
bitset_windex ssize = VBITSET_SIZE (src);
|
bitset_windex ssize = VBITSET_SIZE (src);
|
||||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize, dsize); i++)
|
for (i = 0; i < min (ssize, dsize); i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ssize > dsize)
|
if (ssize > dsize)
|
||||||
{
|
{
|
||||||
@@ -461,15 +417,15 @@ vbitset_equal_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_subset_p (bitset dst, bitset src)
|
vbitset_subset_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
bitset_word *srcp = VBITSET_WORDS (src);
|
bitset_word *srcp = VBITSET_WORDS (src);
|
||||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
bitset_windex ssize = VBITSET_SIZE (src);
|
bitset_windex ssize = VBITSET_SIZE (src);
|
||||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ssize > dsize)
|
if (ssize > dsize)
|
||||||
{
|
{
|
||||||
@@ -485,15 +441,14 @@ vbitset_subset_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_disjoint_p (bitset dst, bitset src)
|
vbitset_disjoint_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
bitset_word *srcp = VBITSET_WORDS (src);
|
bitset_word *srcp = VBITSET_WORDS (src);
|
||||||
bitset_word *dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
bitset_windex ssize = VBITSET_SIZE (src);
|
bitset_windex ssize = VBITSET_SIZE (src);
|
||||||
bitset_windex dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < min (ssize, dsize); i++)
|
for (unsigned i = 0; i < min (ssize, dsize); i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -502,25 +457,17 @@ vbitset_disjoint_p (bitset dst, bitset src)
|
|||||||
static void
|
static void
|
||||||
vbitset_and (bitset dst, bitset src1, bitset src2)
|
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
for (unsigned i = 0; i < min (ssize1, ssize2); i++)
|
||||||
*dstp++ = *src1p++ & *src2p++;
|
*dstp++ = *src1p++ & *src2p++;
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - min (ssize1, ssize2)));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - min (ssize1, ssize2)));
|
||||||
}
|
}
|
||||||
@@ -529,24 +476,17 @@ vbitset_and (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ & *src2p++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
@@ -582,25 +522,18 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
vbitset_andn (bitset dst, bitset src1, bitset src2)
|
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||||
*dstp++ = *src1p++ & ~(*src2p++);
|
*dstp++ = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
@@ -622,24 +555,17 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
@@ -687,25 +613,18 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
vbitset_or (bitset dst, bitset src1, bitset src2)
|
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||||
*dstp++ = *src1p++ | *src2p++;
|
*dstp++ = *src1p++ | *src2p++;
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
@@ -723,24 +642,18 @@ vbitset_or (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ | *src2p++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
@@ -778,25 +691,18 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
vbitset_xor (bitset dst, bitset src1, bitset src2)
|
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++)
|
for (i = 0; i < min (ssize1, ssize2); i++)
|
||||||
*dstp++ = *src1p++ ^ *src2p++;
|
*dstp++ = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
@@ -814,24 +720,17 @@ vbitset_xor (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
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)));
|
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
|
||||||
|
|
||||||
dsize = VBITSET_SIZE (dst);
|
bitset_windex dsize = VBITSET_SIZE (dst);
|
||||||
ssize1 = VBITSET_SIZE (src1);
|
bitset_windex ssize1 = VBITSET_SIZE (src1);
|
||||||
ssize2 = VBITSET_SIZE (src2);
|
bitset_windex ssize2 = VBITSET_SIZE (src2);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
@@ -872,7 +771,6 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
bitset_word *src1p;
|
bitset_word *src1p;
|
||||||
bitset_word *src2p;
|
bitset_word *src2p;
|
||||||
bitset_word *src3p;
|
bitset_word *src3p;
|
||||||
@@ -894,15 +792,14 @@ vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
dstp = VBITSET_WORDS (dst);
|
dstp = VBITSET_WORDS (dst);
|
||||||
size = VBITSET_SIZE (dst);
|
size = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (unsigned i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
bitset_word *src1p;
|
bitset_word *src1p;
|
||||||
bitset_word *src2p;
|
bitset_word *src2p;
|
||||||
@@ -922,7 +819,7 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
dstp = VBITSET_WORDS (dst);
|
dstp = VBITSET_WORDS (dst);
|
||||||
size = VBITSET_SIZE (dst);
|
size = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (unsigned i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
@@ -939,7 +836,6 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
static void
|
static void
|
||||||
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
bitset_word *src1p;
|
bitset_word *src1p;
|
||||||
bitset_word *src2p;
|
bitset_word *src2p;
|
||||||
bitset_word *src3p;
|
bitset_word *src3p;
|
||||||
@@ -961,15 +857,14 @@ vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
dstp = VBITSET_WORDS (dst);
|
dstp = VBITSET_WORDS (dst);
|
||||||
size = VBITSET_SIZE (dst);
|
size = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (unsigned i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
bitset_word *src1p;
|
bitset_word *src1p;
|
||||||
bitset_word *src2p;
|
bitset_word *src2p;
|
||||||
@@ -989,7 +884,7 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
dstp = VBITSET_WORDS (dst);
|
dstp = VBITSET_WORDS (dst);
|
||||||
size = VBITSET_SIZE (dst);
|
size = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (unsigned i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
@@ -1006,13 +901,6 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
static void
|
static void
|
||||||
vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
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)
|
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|
||||||
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
|
||||||
{
|
{
|
||||||
@@ -1022,14 +910,14 @@ vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
|
|
||||||
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
vbitset_resize (dst, BITSET_NBITS_ (src1));
|
||||||
|
|
||||||
src1p = VBITSET_WORDS (src1);
|
bitset_word *src1p = VBITSET_WORDS (src1);
|
||||||
src2p = VBITSET_WORDS (src2);
|
bitset_word *src2p = VBITSET_WORDS (src2);
|
||||||
src3p = VBITSET_WORDS (src3);
|
bitset_word *src3p = VBITSET_WORDS (src3);
|
||||||
dstp = VBITSET_WORDS (dst);
|
bitset_word *dstp = VBITSET_WORDS (dst);
|
||||||
size = VBITSET_SIZE (dst);
|
bitset_windex size = VBITSET_SIZE (dst);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (unsigned i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1119,17 +1007,14 @@ struct bitset_vtable vbitset_vtable = {
|
|||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
vbitset_bytes (n_bits)
|
vbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED)
|
||||||
bitset_bindex n_bits ATTRIBUTE_UNUSED;
|
|
||||||
{
|
{
|
||||||
return sizeof (struct vbitset_struct);
|
return sizeof (struct vbitset_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bitset
|
bitset
|
||||||
vbitset_init (bset, n_bits)
|
vbitset_init (bitset bset, bitset_bindex n_bits)
|
||||||
bitset bset;
|
|
||||||
bitset_bindex n_bits;
|
|
||||||
{
|
{
|
||||||
bset->b.vtable = &vbitset_vtable;
|
bset->b.vtable = &vbitset_vtable;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
#include "bitset.h"
|
#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
|
#endif
|
||||||
|
|||||||
@@ -179,3 +179,14 @@
|
|||||||
/xstrndup.m4
|
/xstrndup.m4
|
||||||
/host-cpu-c-abi.m4
|
/host-cpu-c-abi.m4
|
||||||
/stat-time.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++])
|
||||||
|
])
|
||||||
@@ -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
|
|
||||||
])
|
|
||||||
])
|
|
||||||
@@ -89,10 +89,6 @@ static item_number *kernel_items;
|
|||||||
static void
|
static void
|
||||||
allocate_itemsets (void)
|
allocate_itemsets (void)
|
||||||
{
|
{
|
||||||
symbol_number i;
|
|
||||||
rule_number r;
|
|
||||||
item_number *rhsp;
|
|
||||||
|
|
||||||
/* Count the number of occurrences of all the symbols in RITEMS.
|
/* Count the number of occurrences of all the symbols in RITEMS.
|
||||||
Note that useless productions (hence useless nonterminals) are
|
Note that useless productions (hence useless nonterminals) are
|
||||||
browsed too, hence we need to allocate room for _all_ the
|
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,
|
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
||||||
sizeof *symbol_count);
|
sizeof *symbol_count);
|
||||||
|
|
||||||
for (r = 0; r < nrules; ++r)
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
for (item_number *rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
symbol_count[*rhsp]++;
|
symbol_count[*rhsp]++;
|
||||||
@@ -118,7 +114,7 @@ allocate_itemsets (void)
|
|||||||
kernel_items = xnmalloc (count, sizeof *kernel_items);
|
kernel_items = xnmalloc (count, sizeof *kernel_items);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = 0; i < nsyms; i++)
|
for (symbol_number i = 0; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
kernel_base[i] = kernel_items + count;
|
kernel_base[i] = kernel_items + count;
|
||||||
count += symbol_count[i];
|
count += symbol_count[i];
|
||||||
@@ -174,8 +170,6 @@ free_storage (void)
|
|||||||
static void
|
static void
|
||||||
new_itemsets (state *s)
|
new_itemsets (state *s)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Entering new_itemsets, state = %d\n", s->number);
|
fprintf (stderr, "Entering new_itemsets, state = %d\n", s->number);
|
||||||
|
|
||||||
@@ -183,7 +177,7 @@ new_itemsets (state *s)
|
|||||||
|
|
||||||
nshifts = 0;
|
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]]))
|
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
||||||
{
|
{
|
||||||
symbol_number sym = item_number_as_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 *
|
static state *
|
||||||
get_state (symbol_number sym, size_t core_size, item_number *core)
|
get_state (symbol_number sym, size_t core_size, item_number *core)
|
||||||
{
|
{
|
||||||
state *s;
|
|
||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
||||||
sym, symbols[sym]->tag);
|
sym, symbols[sym]->tag);
|
||||||
|
|
||||||
s = state_hash_lookup (core_size, core);
|
state *s = state_hash_lookup (core_size, core);
|
||||||
if (!s)
|
if (!s)
|
||||||
s = state_list_append (sym, core_size, core);
|
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
|
static void
|
||||||
append_states (state *s)
|
append_states (state *s)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Entering append_states, state = %d\n", s->number);
|
fprintf (stderr, "Entering append_states, state = %d\n", s->number);
|
||||||
|
|
||||||
/* First sort shift_symbol into increasing order. */
|
/* 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];
|
const symbol_number sym = shift_symbol[i];
|
||||||
int j;
|
int j = i;
|
||||||
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
|
for (; 0 < j && sym < shift_symbol[j - 1]; j--)
|
||||||
shift_symbol[j] = shift_symbol[j - 1];
|
shift_symbol[j] = shift_symbol[j - 1];
|
||||||
shift_symbol[j] = sym;
|
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]);
|
shiftset[i] = get_state (sym, kernel_size[sym], kernel_base[sym]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,10 +259,9 @@ static void
|
|||||||
save_reductions (state *s)
|
save_reductions (state *s)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
/* Find and count the active items that represent ends of rules. */
|
/* 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]];
|
item_number item = ritem[itemset[i]];
|
||||||
if (item_number_is_rule_number (item))
|
if (item_number_is_rule_number (item))
|
||||||
@@ -334,17 +323,16 @@ set_states (void)
|
|||||||
void
|
void
|
||||||
generate_states (void)
|
generate_states (void)
|
||||||
{
|
{
|
||||||
item_number initial_core = 0;
|
|
||||||
state_list *list = NULL;
|
|
||||||
allocate_storage ();
|
allocate_storage ();
|
||||||
new_closure (nritems);
|
new_closure (nritems);
|
||||||
|
|
||||||
/* Create the initial state. The 0 at the lhs is the index of the
|
/* Create the initial state. The 0 at the lhs is the index of the
|
||||||
item of this initial rule. */
|
item of this initial rule. */
|
||||||
|
item_number initial_core = 0;
|
||||||
state_list_append (0, 1, &initial_core);
|
state_list_append (0, 1, &initial_core);
|
||||||
|
|
||||||
/* States are queued when they are created; process them all. */
|
/* 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;
|
state *s = list->state;
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
|
|||||||
+6
-11
@@ -83,7 +83,7 @@ static const char * const warnings_args[] =
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int warnings_types[] =
|
static const warnings warnings_types[] =
|
||||||
{
|
{
|
||||||
Wnone,
|
Wnone,
|
||||||
Wmidrule_values,
|
Wmidrule_values,
|
||||||
@@ -114,8 +114,7 @@ warning_argmatch (char const *arg, size_t no, size_t err)
|
|||||||
no = !no;
|
no = !no;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t b;
|
for (size_t b = 0; b < warnings_size; ++b)
|
||||||
for (b = 0; b < warnings_size; ++b)
|
|
||||||
if (value & 1 << b)
|
if (value & 1 << b)
|
||||||
{
|
{
|
||||||
if (err && no)
|
if (err && no)
|
||||||
@@ -176,8 +175,7 @@ complain_init (void)
|
|||||||
warnings warnings_default =
|
warnings warnings_default =
|
||||||
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||||
|
|
||||||
size_t b;
|
for (size_t b = 0; b < warnings_size; ++b)
|
||||||
for (b = 0; b < warnings_size; ++b)
|
|
||||||
{
|
{
|
||||||
warnings_flag[b] = (1 << b & warnings_default
|
warnings_flag[b] = (1 << b & warnings_default
|
||||||
? severity_warning
|
? severity_warning
|
||||||
@@ -204,8 +202,7 @@ warning_severity (warnings flags)
|
|||||||
{
|
{
|
||||||
/* Diagnostics about warnings. */
|
/* Diagnostics about warnings. */
|
||||||
severity res = severity_disabled;
|
severity res = severity_disabled;
|
||||||
size_t b;
|
for (size_t b = 0; b < warnings_size; ++b)
|
||||||
for (b = 0; b < warnings_size; ++b)
|
|
||||||
if (flags & 1 << b)
|
if (flags & 1 << b)
|
||||||
{
|
{
|
||||||
res = res < warnings_flag[b] ? warnings_flag[b] : res;
|
res = res < warnings_flag[b] ? warnings_flag[b] : res;
|
||||||
@@ -225,8 +222,7 @@ warning_severity (warnings flags)
|
|||||||
bool
|
bool
|
||||||
warning_is_unset (warnings flags)
|
warning_is_unset (warnings flags)
|
||||||
{
|
{
|
||||||
size_t b;
|
for (size_t b = 0; b < warnings_size; ++b)
|
||||||
for (b = 0; b < warnings_size; ++b)
|
|
||||||
if (flags & 1 << b && warnings_flag[b] != severity_unset)
|
if (flags & 1 << b && warnings_flag[b] != severity_unset)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -238,8 +234,7 @@ static void
|
|||||||
warnings_print_categories (warnings warn_flags, FILE *f)
|
warnings_print_categories (warnings warn_flags, FILE *f)
|
||||||
{
|
{
|
||||||
/* Display only the first match, the second is "-Wall". */
|
/* Display only the first match, the second is "-Wall". */
|
||||||
size_t i;
|
for (size_t i = 0; warnings_args[i]; ++i)
|
||||||
for (i = 0; warnings_args[i]; ++i)
|
|
||||||
if (warn_flags & warnings_types[i])
|
if (warn_flags & warnings_types[i])
|
||||||
{
|
{
|
||||||
severity s = warning_severity (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)
|
compute_exts_from_src (const char *ext)
|
||||||
{
|
{
|
||||||
/* We use this function when the user specifies `-o' or `--output',
|
/* 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. */
|
given by this option. */
|
||||||
src_extension = xstrdup (ext);
|
src_extension = xstrdup (ext);
|
||||||
header_extension = xstrdup (ext);
|
header_extension = xstrdup (ext);
|
||||||
|
|||||||
+26
-14
@@ -27,6 +27,32 @@
|
|||||||
+ (YY_FLEX_MINOR_VERSION) * 1000 \
|
+ (YY_FLEX_MINOR_VERSION) * 1000 \
|
||||||
+ (YY_FLEX_SUBMINOR_VERSION))
|
+ (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. */
|
/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
|
||||||
#if FLEX_VERSION <= 2005031
|
#if FLEX_VERSION <= 2005031
|
||||||
int FLEX_PREFIX (get_lineno) (void);
|
int FLEX_PREFIX (get_lineno) (void);
|
||||||
@@ -44,20 +70,6 @@ int FLEX_PREFIX (lex_destroy) (void);
|
|||||||
|
|
||||||
#define last_string FLEX_PREFIX (last_string)
|
#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,
|
/* 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
|
yyleng etc. when a prefix is given, since there is no longer a
|
||||||
#define, but rather the token is actually changed in the output.
|
#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;
|
int trace_flag = trace_none;
|
||||||
|
|
||||||
static struct bison_language const valid_languages[] = {
|
static struct bison_language const valid_languages[] = {
|
||||||
{ "c", "c-skel.m4", ".c", ".h", true },
|
/* lang, skeleton, ext, hdr, add_tab */
|
||||||
{ "c++", "c++-skel.m4", ".cc", ".hh", true },
|
{ "c", "c-skel.m4", ".c", ".h", true },
|
||||||
|
{ "c++", "c++-skel.m4", ".cc", ".hh", true },
|
||||||
{ "java", "java-skel.m4", ".java", ".java", false },
|
{ "java", "java-skel.m4", ".java", ".java", false },
|
||||||
{ "", "", "", "", false }
|
{ "", "", "", "", false }
|
||||||
};
|
};
|
||||||
@@ -127,7 +128,7 @@ flags_argmatch (const char *opt,
|
|||||||
|
|
||||||
/** Decode a set of sub arguments.
|
/** 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 Args the effective sub arguments to decode.
|
||||||
* \param All the "all" value.
|
* \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: "
|
fputs (_("General help using GNU software: "
|
||||||
"<http://www.gnu.org/gethelp/>.\n"),
|
"<http://www.gnu.org/gethelp/>.\n"),
|
||||||
stdout);
|
stdout);
|
||||||
|
|
||||||
|
#if (defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__
|
||||||
/* Don't output this redundant message for English locales.
|
/* Don't output this redundant message for English locales.
|
||||||
Note we still output for 'C' so that it gets included in the
|
Note we still output for 'C' so that it gets included in the
|
||||||
man page. */
|
man page. */
|
||||||
@@ -372,6 +375,7 @@ FEATURE is a list of comma separated words that can include:\n\
|
|||||||
email address. */
|
email address. */
|
||||||
fputs (_("Report translation bugs to "
|
fputs (_("Report translation bugs to "
|
||||||
"<http://translationproject.org/team/>.\n"), stdout);
|
"<http://translationproject.org/team/>.\n"), stdout);
|
||||||
|
#endif
|
||||||
fputs (_("For complete documentation, run: info bison.\n"), stdout);
|
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)
|
if (prio < language_prio)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; valid_languages[i].language[0]; ++i)
|
||||||
for (i = 0; valid_languages[i].language[0]; i++)
|
|
||||||
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
||||||
{
|
{
|
||||||
language_prio = prio;
|
language_prio = prio;
|
||||||
@@ -721,7 +724,7 @@ getargs (int argc, char *argv[])
|
|||||||
if (argc - optind != 1)
|
if (argc - optind != 1)
|
||||||
{
|
{
|
||||||
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
|
else
|
||||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||||
usage (EXIT_FAILURE);
|
usage (EXIT_FAILURE);
|
||||||
|
|||||||
+25
-39
@@ -46,6 +46,8 @@ symbol_number *token_translations = NULL;
|
|||||||
|
|
||||||
int max_user_token_number = 256;
|
int max_user_token_number = 256;
|
||||||
|
|
||||||
|
int required_version = 0;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
rule_useful_in_grammar_p (rule const *r)
|
rule_useful_in_grammar_p (rule const *r)
|
||||||
{
|
{
|
||||||
@@ -84,8 +86,7 @@ size_t
|
|||||||
rule_rhs_length (rule const *r)
|
rule_rhs_length (rule const *r)
|
||||||
{
|
{
|
||||||
size_t res = 0;
|
size_t res = 0;
|
||||||
item_number *rhsp;
|
for (item_number *rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
||||||
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
|
||||||
++res;
|
++res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -94,11 +95,8 @@ void
|
|||||||
rule_rhs_print (rule const *r, FILE *out)
|
rule_rhs_print (rule const *r, FILE *out)
|
||||||
{
|
{
|
||||||
if (0 <= *r->rhs)
|
if (0 <= *r->rhs)
|
||||||
{
|
for (item_number *rp = r->rhs; *rp >= 0; rp++)
|
||||||
item_number *rp;
|
fprintf (out, " %s", symbols[*rp]->tag);
|
||||||
for (rp = r->rhs; *rp >= 0; rp++)
|
|
||||||
fprintf (out, " %s", symbols[*rp]->tag);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
fputs (" %empty", out);
|
fputs (" %empty", out);
|
||||||
}
|
}
|
||||||
@@ -108,9 +106,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
|||||||
{
|
{
|
||||||
if (*r->rhs >= 0)
|
if (*r->rhs >= 0)
|
||||||
{
|
{
|
||||||
item_number *rp;
|
|
||||||
xml_puts (out, level, "<rhs>");
|
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_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||||
xml_escape (symbols[*rp]->tag));
|
xml_escape (symbols[*rp]->tag));
|
||||||
xml_puts (out, level, "</rhs>");
|
xml_puts (out, level, "</rhs>");
|
||||||
@@ -126,9 +123,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
|||||||
void
|
void
|
||||||
ritem_print (FILE *out)
|
ritem_print (FILE *out)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
fputs ("RITEM\n", out);
|
fputs ("RITEM\n", out);
|
||||||
for (i = 0; i < nritems; ++i)
|
for (unsigned i = 0; i < nritems; ++i)
|
||||||
if (ritem[i] >= 0)
|
if (ritem[i] >= 0)
|
||||||
fprintf (out, " %s", symbols[ritem[i]]->tag);
|
fprintf (out, " %s", symbols[ritem[i]]->tag);
|
||||||
else
|
else
|
||||||
@@ -140,9 +136,7 @@ size_t
|
|||||||
ritem_longest_rhs (void)
|
ritem_longest_rhs (void)
|
||||||
{
|
{
|
||||||
int max = 0;
|
int max = 0;
|
||||||
rule_number r;
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
|
|
||||||
for (r = 0; r < nrules; ++r)
|
|
||||||
{
|
{
|
||||||
int length = rule_rhs_length (&rules[r]);
|
int length = rule_rhs_length (&rules[r]);
|
||||||
if (length > max)
|
if (length > max)
|
||||||
@@ -156,12 +150,11 @@ void
|
|||||||
grammar_rules_partial_print (FILE *out, const char *title,
|
grammar_rules_partial_print (FILE *out, const char *title,
|
||||||
rule_filter filter)
|
rule_filter filter)
|
||||||
{
|
{
|
||||||
rule_number r;
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
sym_content *previous_lhs = NULL;
|
sym_content *previous_lhs = NULL;
|
||||||
|
|
||||||
/* rule # : LHS -> RHS */
|
/* 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]))
|
if (filter && !filter (&rules[r]))
|
||||||
continue;
|
continue;
|
||||||
@@ -188,10 +181,9 @@ grammar_rules_print (FILE *out)
|
|||||||
void
|
void
|
||||||
grammar_rules_print_xml (FILE *out, int level)
|
grammar_rules_print_xml (FILE *out, int level)
|
||||||
{
|
{
|
||||||
rule_number r;
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||||
{
|
{
|
||||||
if (first)
|
if (first)
|
||||||
xml_puts (out, level + 1, "<rules>");
|
xml_puts (out, level + 1, "<rules>");
|
||||||
@@ -233,10 +225,9 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
|
|
||||||
fprintf (out, "Variables\n---------\n\n");
|
fprintf (out, "Variables\n---------\n\n");
|
||||||
{
|
{
|
||||||
symbol_number i;
|
|
||||||
fprintf (out, "Value Sprec Sassoc Tag\n");
|
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",
|
fprintf (out, "%5d %5d %5d %s\n",
|
||||||
i,
|
i,
|
||||||
symbols[i]->content->prec, symbols[i]->content->assoc,
|
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");
|
fprintf (out, "Rules\n-----\n\n");
|
||||||
{
|
{
|
||||||
rule_number i;
|
|
||||||
fprintf (out,
|
fprintf (out,
|
||||||
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
|
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
|
||||||
" -> Rhs (Ritem range) [Num]\n");
|
" -> 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];
|
rule const *rule_i = &rules[i];
|
||||||
item_number *rp = NULL;
|
unsigned const rhs_itemno = rule_i->rhs - ritem;
|
||||||
unsigned rhs_itemno = rule_i->rhs - ritem;
|
|
||||||
unsigned rhs_count = 0;
|
|
||||||
/* Find the last RHS index in ritems. */
|
/* 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;
|
++rhs_count;
|
||||||
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
||||||
i,
|
i,
|
||||||
@@ -268,31 +257,28 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
rhs_itemno + rhs_count - 1,
|
rhs_itemno + rhs_count - 1,
|
||||||
rule_i->lhs->number);
|
rule_i->lhs->number);
|
||||||
/* Dumped the RHS. */
|
/* 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, " %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, "\n\n");
|
||||||
|
|
||||||
fprintf (out, "Rules interpreted\n-----------------\n\n");
|
fprintf (out, "Rules interpreted\n-----------------\n\n");
|
||||||
{
|
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||||
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, "%-5d %s:", r, rules[r].lhs->symbol->tag);
|
fprintf (out, "\n");
|
||||||
rule_rhs_print (&rules[r], out);
|
}
|
||||||
fprintf (out, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grammar_rules_useless_report (const char *message)
|
grammar_rules_useless_report (const char *message)
|
||||||
{
|
{
|
||||||
rule_number r;
|
for (rule_number r = 0; r < nrules ; ++r)
|
||||||
for (r = 0; r < nrules ; ++r)
|
|
||||||
/* Don't complain about rules whose LHS is useless, we already
|
/* Don't complain about rules whose LHS is useless, we already
|
||||||
complained about it. */
|
complained about it. */
|
||||||
if (!reduce_nonterminal_useless_in_grammar (rules[r].lhs)
|
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. */
|
/* Free the packed grammar. */
|
||||||
void grammar_free (void);
|
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_ */
|
#endif /* !GRAM_H_ */
|
||||||
|
|||||||
+31
-36
@@ -87,12 +87,14 @@ escape (char const *name)
|
|||||||
static void
|
static void
|
||||||
no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
|
no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
|
||||||
{
|
{
|
||||||
int n;
|
|
||||||
*no_reduce_set = bitset_create (ntokens, BITSET_FIXED);
|
*no_reduce_set = bitset_create (ntokens, BITSET_FIXED);
|
||||||
bitset_zero (*no_reduce_set);
|
bitset_zero (*no_reduce_set);
|
||||||
FOR_EACH_SHIFT (s->transitions, n)
|
{
|
||||||
bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n));
|
int n;
|
||||||
for (n = 0; n < s->errs->num; ++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])
|
if (s->errs->symbols[n])
|
||||||
bitset_set (*no_reduce_set, s->errs->symbols[n]->content->number);
|
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
|
static bool
|
||||||
print_token (struct obstack *out, bool first, char const *tok)
|
print_token (struct obstack *out, bool first, char const *tok)
|
||||||
{
|
{
|
||||||
char const *q = escape (tok);
|
|
||||||
|
|
||||||
if (! first)
|
if (! first)
|
||||||
obstack_sgrow (out, ", ");
|
obstack_sgrow (out, ", ");
|
||||||
obstack_sgrow (out, q);
|
obstack_sgrow (out, escape (tok));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +157,7 @@ void
|
|||||||
output_red (state const *s, reductions const *reds, FILE *fout)
|
output_red (state const *s, reductions const *reds, FILE *fout)
|
||||||
{
|
{
|
||||||
bitset no_reduce_set;
|
bitset no_reduce_set;
|
||||||
int j;
|
no_reduce_bitset_init (s, &no_reduce_set);
|
||||||
int source = s->number;
|
|
||||||
|
|
||||||
/* Two obstacks are needed: one for the enabled reductions, and one
|
/* Two obstacks are needed: one for the enabled reductions, and one
|
||||||
for the disabled reductions, because in the end we want two
|
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. */
|
be printed. */
|
||||||
struct obstack dout;
|
struct obstack dout;
|
||||||
struct obstack eout;
|
struct obstack eout;
|
||||||
|
|
||||||
no_reduce_bitset_init (s, &no_reduce_set);
|
|
||||||
obstack_init (&dout);
|
obstack_init (&dout);
|
||||||
obstack_init (&eout);
|
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 firstd = true;
|
||||||
bool firste = true;
|
bool firste = true;
|
||||||
rule_number ruleno = reds->rules[j]->number;
|
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)
|
if (reds->lookahead_tokens)
|
||||||
{
|
for (int i = 0; i < ntokens; i++)
|
||||||
int i;
|
if (bitset_test (reds->lookahead_tokens[j], 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);
|
||||||
if (bitset_test (no_reduce_set, i))
|
else
|
||||||
firstd = print_token (&dout, firstd, symbols[i]->tag);
|
{
|
||||||
else
|
if (! defaulted)
|
||||||
{
|
firste = print_token (&eout, firste, symbols[i]->tag);
|
||||||
if (! defaulted)
|
bitset_set (no_reduce_set, i);
|
||||||
firste = print_token (&eout, firste, symbols[i]->tag);
|
}
|
||||||
bitset_set (no_reduce_set, i);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Do the actual output. */
|
/* Do the actual output. */
|
||||||
conclude_red (&dout, source, ruleno, false, firstd, fout);
|
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
|
* compatibility or, if <tt>annotation_lists = NULL</tt>, the canonical
|
||||||
* LR(1) state compatibility test was used.
|
* LR(1) state compatibility test was used.
|
||||||
* - If <tt>annotation_lists = NULL</tt>, reduction lookahead sets were
|
* - 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.
|
* computed from item lookahead sets.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
@@ -1004,7 +1004,7 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows,
|
|||||||
lookahead sets. */
|
lookahead sets. */
|
||||||
if (!annotation_lists)
|
if (!annotation_lists)
|
||||||
{
|
{
|
||||||
timevar_push (TV_IELR_PHASE4);
|
timevar_push (tv_ielr_phase4);
|
||||||
initialize_LA ();
|
initialize_LA ();
|
||||||
for (state_list *node = first_state; node; node = node->next)
|
for (state_list *node = first_state; node; node = node->next)
|
||||||
if (!node->state->consistent)
|
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. */
|
/* Free state list. */
|
||||||
@@ -1080,7 +1080,7 @@ ielr (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Phase 0: LALR(1). */
|
/* Phase 0: LALR(1). */
|
||||||
timevar_push (TV_LALR);
|
timevar_push (tv_lalr);
|
||||||
if (lr_type == LR_TYPE__CANONICAL_LR)
|
if (lr_type == LR_TYPE__CANONICAL_LR)
|
||||||
set_goto_map ();
|
set_goto_map ();
|
||||||
else
|
else
|
||||||
@@ -1088,10 +1088,10 @@ ielr (void)
|
|||||||
if (lr_type == LR_TYPE__LALR)
|
if (lr_type == LR_TYPE__LALR)
|
||||||
{
|
{
|
||||||
bitsetv_free (goto_follows);
|
bitsetv_free (goto_follows);
|
||||||
timevar_pop (TV_LALR);
|
timevar_pop (tv_lalr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timevar_pop (TV_LALR);
|
timevar_pop (tv_lalr);
|
||||||
|
|
||||||
{
|
{
|
||||||
bitsetv follow_kernel_items;
|
bitsetv follow_kernel_items;
|
||||||
@@ -1104,14 +1104,14 @@ ielr (void)
|
|||||||
{
|
{
|
||||||
/* Phase 1: Compute Auxiliary Tables. */
|
/* Phase 1: Compute Auxiliary Tables. */
|
||||||
state ***predecessors;
|
state ***predecessors;
|
||||||
timevar_push (TV_IELR_PHASE1);
|
timevar_push (tv_ielr_phase1);
|
||||||
ielr_compute_auxiliary_tables (
|
ielr_compute_auxiliary_tables (
|
||||||
&follow_kernel_items, &always_follows,
|
&follow_kernel_items, &always_follows,
|
||||||
lr_type == LR_TYPE__CANONICAL_LR ? NULL : &predecessors);
|
lr_type == LR_TYPE__CANONICAL_LR ? NULL : &predecessors);
|
||||||
timevar_pop (TV_IELR_PHASE1);
|
timevar_pop (tv_ielr_phase1);
|
||||||
|
|
||||||
/* Phase 2: Compute Annotations. */
|
/* Phase 2: Compute Annotations. */
|
||||||
timevar_push (TV_IELR_PHASE2);
|
timevar_push (tv_ielr_phase2);
|
||||||
if (lr_type != LR_TYPE__CANONICAL_LR)
|
if (lr_type != LR_TYPE__CANONICAL_LR)
|
||||||
{
|
{
|
||||||
obstack_init (&annotations_obstack);
|
obstack_init (&annotations_obstack);
|
||||||
@@ -1125,11 +1125,11 @@ ielr (void)
|
|||||||
bitsetv_free (goto_follows);
|
bitsetv_free (goto_follows);
|
||||||
lalr_free ();
|
lalr_free ();
|
||||||
}
|
}
|
||||||
timevar_pop (TV_IELR_PHASE2);
|
timevar_pop (tv_ielr_phase2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Phase 3: Split States. */
|
/* Phase 3: Split States. */
|
||||||
timevar_push (TV_IELR_PHASE3);
|
timevar_push (tv_ielr_phase3);
|
||||||
{
|
{
|
||||||
state_number nstates_lr0 = nstates;
|
state_number nstates_lr0 = nstates;
|
||||||
ielr_split_states (follow_kernel_items, always_follows,
|
ielr_split_states (follow_kernel_items, always_follows,
|
||||||
@@ -1144,11 +1144,11 @@ ielr (void)
|
|||||||
free (annotation_lists);
|
free (annotation_lists);
|
||||||
bitsetv_free (follow_kernel_items);
|
bitsetv_free (follow_kernel_items);
|
||||||
bitsetv_free (always_follows);
|
bitsetv_free (always_follows);
|
||||||
timevar_pop (TV_IELR_PHASE3);
|
timevar_pop (tv_ielr_phase3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Phase 4: Compute Reduction Lookaheads. */
|
/* Phase 4: Compute Reduction Lookaheads. */
|
||||||
timevar_push (TV_IELR_PHASE4);
|
timevar_push (tv_ielr_phase4);
|
||||||
free (goto_map);
|
free (goto_map);
|
||||||
free (from_state);
|
free (from_state);
|
||||||
free (to_state);
|
free (to_state);
|
||||||
@@ -1163,5 +1163,5 @@ ielr (void)
|
|||||||
lalr ();
|
lalr ();
|
||||||
bitsetv_free (goto_follows);
|
bitsetv_free (goto_follows);
|
||||||
}
|
}
|
||||||
timevar_pop (TV_IELR_PHASE4);
|
timevar_pop (tv_ielr_phase4);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -13,7 +13,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
LDADD = lib/libbison.a $(LIBINTL)
|
LDADD = \
|
||||||
|
$(ISNAND_LIBM) \
|
||||||
|
$(ISNANF_LIBM) \
|
||||||
|
$(ISNANL_LIBM) \
|
||||||
|
$(LDEXPL_LIBM) \
|
||||||
|
$(LDEXP_LIBM) \
|
||||||
|
$(LIBINTL) \
|
||||||
|
$(LIBTHREAD) \
|
||||||
|
lib/libbison.a
|
||||||
|
|
||||||
bin_PROGRAMS = src/bison
|
bin_PROGRAMS = src/bison
|
||||||
# Prettify Automake-computed names of compiled objects.
|
# Prettify Automake-computed names of compiled objects.
|
||||||
@@ -116,6 +124,7 @@ bin_SCRIPTS = src/yacc
|
|||||||
endif
|
endif
|
||||||
EXTRA_SCRIPTS = src/yacc
|
EXTRA_SCRIPTS = src/yacc
|
||||||
MOSTLYCLEANFILES += src/yacc
|
MOSTLYCLEANFILES += src/yacc
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
|
|
||||||
src/yacc:
|
src/yacc:
|
||||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
$(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. */
|
same file all over for each error. */
|
||||||
struct caret_info
|
struct caret_info
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ void location_compute (location *loc,
|
|||||||
Warning: uses quotearg's slot 3. */
|
Warning: uses quotearg's slot 3. */
|
||||||
unsigned location_print (location loc, FILE *out);
|
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. */
|
left-over by the usage of location_caret. */
|
||||||
void cleanup_caret (void);
|
void cleanup_caret (void);
|
||||||
|
|
||||||
|
|||||||
+28
-28
@@ -80,9 +80,9 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
getargs (argc, argv);
|
getargs (argc, argv);
|
||||||
|
|
||||||
timevar_report = trace_flag & trace_time;
|
timevar_enabled = trace_flag & trace_time;
|
||||||
init_timevar ();
|
timevar_init ();
|
||||||
timevar_start (TV_TOTAL);
|
timevar_start (tv_total);
|
||||||
|
|
||||||
if (trace_flag & trace_bitsets)
|
if (trace_flag & trace_bitsets)
|
||||||
bitset_stats_enable ();
|
bitset_stats_enable ();
|
||||||
@@ -91,29 +91,29 @@ main (int argc, char *argv[])
|
|||||||
and FATTRS. In file reader.c. The other parts are recorded in
|
and FATTRS. In file reader.c. The other parts are recorded in
|
||||||
the grammar; see gram.h. */
|
the grammar; see gram.h. */
|
||||||
|
|
||||||
timevar_push (TV_READER);
|
timevar_push (tv_reader);
|
||||||
reader ();
|
reader ();
|
||||||
timevar_pop (TV_READER);
|
timevar_pop (tv_reader);
|
||||||
|
|
||||||
if (complaint_status == status_complaint)
|
if (complaint_status == status_complaint)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
/* Find useless nonterminals and productions and reduce the grammar. */
|
/* Find useless nonterminals and productions and reduce the grammar. */
|
||||||
timevar_push (TV_REDUCE);
|
timevar_push (tv_reduce);
|
||||||
reduce_grammar ();
|
reduce_grammar ();
|
||||||
timevar_pop (TV_REDUCE);
|
timevar_pop (tv_reduce);
|
||||||
|
|
||||||
/* Record other info about the grammar. In files derives and
|
/* Record other info about the grammar. In files derives and
|
||||||
nullable. */
|
nullable. */
|
||||||
timevar_push (TV_SETS);
|
timevar_push (tv_sets);
|
||||||
derives_compute ();
|
derives_compute ();
|
||||||
nullable_compute ();
|
nullable_compute ();
|
||||||
timevar_pop (TV_SETS);
|
timevar_pop (tv_sets);
|
||||||
|
|
||||||
/* Compute LR(0) parser states. See state.h for more info. */
|
/* Compute LR(0) parser states. See state.h for more info. */
|
||||||
timevar_push (TV_LR0);
|
timevar_push (tv_lr0);
|
||||||
generate_states ();
|
generate_states ();
|
||||||
timevar_pop (TV_LR0);
|
timevar_pop (tv_lr0);
|
||||||
|
|
||||||
/* Add lookahead sets to parser states. Except when LALR(1) is
|
/* Add lookahead sets to parser states. Except when LALR(1) is
|
||||||
requested, split states to eliminate LR(1)-relative
|
requested, split states to eliminate LR(1)-relative
|
||||||
@@ -124,7 +124,7 @@ main (int argc, char *argv[])
|
|||||||
lookahead is not enough to disambiguate the parsing. In file
|
lookahead is not enough to disambiguate the parsing. In file
|
||||||
conflicts. Also resolve s/r conflicts based on precedence
|
conflicts. Also resolve s/r conflicts based on precedence
|
||||||
declarations. */
|
declarations. */
|
||||||
timevar_push (TV_CONFLICTS);
|
timevar_push (tv_conflicts);
|
||||||
conflicts_solve ();
|
conflicts_solve ();
|
||||||
if (!muscle_percent_define_flag_if ("lr.keep-unreachable-state"))
|
if (!muscle_percent_define_flag_if ("lr.keep-unreachable-state"))
|
||||||
{
|
{
|
||||||
@@ -136,12 +136,12 @@ main (int argc, char *argv[])
|
|||||||
free (old_to_new);
|
free (old_to_new);
|
||||||
}
|
}
|
||||||
conflicts_print ();
|
conflicts_print ();
|
||||||
timevar_pop (TV_CONFLICTS);
|
timevar_pop (tv_conflicts);
|
||||||
|
|
||||||
/* Compute the parser tables. */
|
/* Compute the parser tables. */
|
||||||
timevar_push (TV_ACTIONS);
|
timevar_push (tv_actions);
|
||||||
tables_generate ();
|
tables_generate ();
|
||||||
timevar_pop (TV_ACTIONS);
|
timevar_pop (tv_actions);
|
||||||
|
|
||||||
grammar_rules_useless_report (_("rule useless in parser due to conflicts"));
|
grammar_rules_useless_report (_("rule useless in parser due to conflicts"));
|
||||||
|
|
||||||
@@ -153,25 +153,25 @@ main (int argc, char *argv[])
|
|||||||
/* Output the detailed report on the grammar. */
|
/* Output the detailed report on the grammar. */
|
||||||
if (report_flag)
|
if (report_flag)
|
||||||
{
|
{
|
||||||
timevar_push (TV_REPORT);
|
timevar_push (tv_report);
|
||||||
print_results ();
|
print_results ();
|
||||||
timevar_pop (TV_REPORT);
|
timevar_pop (tv_report);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output the graph. */
|
/* Output the graph. */
|
||||||
if (graph_flag)
|
if (graph_flag)
|
||||||
{
|
{
|
||||||
timevar_push (TV_GRAPH);
|
timevar_push (tv_graph);
|
||||||
print_graph ();
|
print_graph ();
|
||||||
timevar_pop (TV_GRAPH);
|
timevar_pop (tv_graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output xml. */
|
/* Output xml. */
|
||||||
if (xml_flag)
|
if (xml_flag)
|
||||||
{
|
{
|
||||||
timevar_push (TV_XML);
|
timevar_push (tv_xml);
|
||||||
print_xml ();
|
print_xml ();
|
||||||
timevar_pop (TV_XML);
|
timevar_pop (tv_xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop if there were errors, to avoid trashing previous output
|
/* Stop if there were errors, to avoid trashing previous output
|
||||||
@@ -180,16 +180,16 @@ main (int argc, char *argv[])
|
|||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
/* Lookahead tokens are no longer needed. */
|
/* Lookahead tokens are no longer needed. */
|
||||||
timevar_push (TV_FREE);
|
timevar_push (tv_free);
|
||||||
lalr_free ();
|
lalr_free ();
|
||||||
timevar_pop (TV_FREE);
|
timevar_pop (tv_free);
|
||||||
|
|
||||||
/* Output the tables and the parser to ftable. In file output. */
|
/* Output the tables and the parser to ftable. In file output. */
|
||||||
timevar_push (TV_PARSER);
|
timevar_push (tv_parser);
|
||||||
output ();
|
output ();
|
||||||
timevar_pop (TV_PARSER);
|
timevar_pop (tv_parser);
|
||||||
|
|
||||||
timevar_push (TV_FREE);
|
timevar_push (tv_free);
|
||||||
nullable_free ();
|
nullable_free ();
|
||||||
derives_free ();
|
derives_free ();
|
||||||
tables_free ();
|
tables_free ();
|
||||||
@@ -207,7 +207,7 @@ main (int argc, char *argv[])
|
|||||||
code_scanner_free ();
|
code_scanner_free ();
|
||||||
skel_scanner_free ();
|
skel_scanner_free ();
|
||||||
quotearg_free ();
|
quotearg_free ();
|
||||||
timevar_pop (TV_FREE);
|
timevar_pop (tv_free);
|
||||||
|
|
||||||
if (trace_flag & trace_bitsets)
|
if (trace_flag & trace_bitsets)
|
||||||
bitset_stats_dump (stderr);
|
bitset_stats_dump (stderr);
|
||||||
@@ -215,7 +215,7 @@ main (int argc, char *argv[])
|
|||||||
finish:
|
finish:
|
||||||
|
|
||||||
/* Stop timing and print the times. */
|
/* Stop timing and print the times. */
|
||||||
timevar_stop (TV_TOTAL);
|
timevar_stop (tv_total);
|
||||||
timevar_print (stderr);
|
timevar_print (stderr);
|
||||||
|
|
||||||
cleanup_caret ();
|
cleanup_caret ();
|
||||||
|
|||||||
+57
-73
@@ -175,9 +175,6 @@ muscle_grow (const char *key, const char *val,
|
|||||||
const char *separator, const char *terminator)
|
const char *separator, const char *terminator)
|
||||||
{
|
{
|
||||||
muscle_entry *entry = muscle_lookup (key);
|
muscle_entry *entry = muscle_lookup (key);
|
||||||
size_t vals = strlen (val);
|
|
||||||
size_t terms = strlen (terminator);
|
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
obstack_sgrow (&muscle_obstack, entry->value);
|
obstack_sgrow (&muscle_obstack, entry->value);
|
||||||
@@ -189,12 +186,14 @@ muscle_grow (const char *key, const char *val,
|
|||||||
|
|
||||||
obstack_sgrow (&muscle_obstack, val);
|
obstack_sgrow (&muscle_obstack, val);
|
||||||
|
|
||||||
|
size_t vals = strlen (val);
|
||||||
|
size_t terms = strlen (terminator);
|
||||||
if (terms <= vals
|
if (terms <= vals
|
||||||
&& STRNEQ (val + vals - terms, terminator))
|
&& STRNEQ (val + vals - terms, terminator))
|
||||||
obstack_sgrow (&muscle_obstack, terminator);
|
obstack_sgrow (&muscle_obstack, terminator);
|
||||||
|
|
||||||
{
|
{
|
||||||
char *new_val = obstack_finish0 (&muscle_obstack);
|
char const *new_val = obstack_finish0 (&muscle_obstack);
|
||||||
entry->value = entry->storage = xstrdup (new_val);
|
entry->value = entry->storage = xstrdup (new_val);
|
||||||
obstack_free (&muscle_obstack, new_val);
|
obstack_free (&muscle_obstack, new_val);
|
||||||
}
|
}
|
||||||
@@ -208,12 +207,11 @@ muscle_grow (const char *key, const char *val,
|
|||||||
static void
|
static void
|
||||||
muscle_syncline_grow (char const *key, location loc)
|
muscle_syncline_grow (char const *key, location loc)
|
||||||
{
|
{
|
||||||
char *extension = NULL;
|
|
||||||
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
|
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
|
||||||
obstack_quote (&muscle_obstack,
|
obstack_quote (&muscle_obstack,
|
||||||
quotearg_style (c_quoting_style, loc.start.file));
|
quotearg_style (c_quoting_style, loc.start.file));
|
||||||
obstack_sgrow (&muscle_obstack, ")[");
|
obstack_sgrow (&muscle_obstack, ")[");
|
||||||
extension = obstack_finish0 (&muscle_obstack);
|
char const *extension = obstack_finish0 (&muscle_obstack);
|
||||||
muscle_grow (key, extension, "", "");
|
muscle_grow (key, extension, "", "");
|
||||||
obstack_free (&muscle_obstack, extension);
|
obstack_free (&muscle_obstack, extension);
|
||||||
}
|
}
|
||||||
@@ -236,13 +234,12 @@ void
|
|||||||
muscle_pair_list_grow (const char *muscle,
|
muscle_pair_list_grow (const char *muscle,
|
||||||
const char *a1, const char *a2)
|
const char *a1, const char *a2)
|
||||||
{
|
{
|
||||||
char *pair;
|
|
||||||
obstack_sgrow (&muscle_obstack, "[");
|
obstack_sgrow (&muscle_obstack, "[");
|
||||||
obstack_quote (&muscle_obstack, a1);
|
obstack_quote (&muscle_obstack, a1);
|
||||||
obstack_sgrow (&muscle_obstack, ", ");
|
obstack_sgrow (&muscle_obstack, ", ");
|
||||||
obstack_quote (&muscle_obstack, a2);
|
obstack_quote (&muscle_obstack, a2);
|
||||||
obstack_sgrow (&muscle_obstack, "]");
|
obstack_sgrow (&muscle_obstack, "]");
|
||||||
pair = obstack_finish0 (&muscle_obstack);
|
char const *pair = obstack_finish0 (&muscle_obstack);
|
||||||
muscle_grow (muscle, pair, ",\n", "");
|
muscle_grow (muscle, pair, ",\n", "");
|
||||||
obstack_free (&muscle_obstack, pair);
|
obstack_free (&muscle_obstack, pair);
|
||||||
}
|
}
|
||||||
@@ -275,11 +272,10 @@ muscle_find (char const *key)
|
|||||||
static void
|
static void
|
||||||
muscle_boundary_grow (char const *key, boundary bound)
|
muscle_boundary_grow (char const *key, boundary bound)
|
||||||
{
|
{
|
||||||
char *extension;
|
|
||||||
obstack_sgrow (&muscle_obstack, "[[");
|
obstack_sgrow (&muscle_obstack, "[[");
|
||||||
obstack_escape (&muscle_obstack, bound.file);
|
obstack_escape (&muscle_obstack, bound.file);
|
||||||
obstack_printf (&muscle_obstack, ":%d.%d]]", bound.line, bound.column);
|
obstack_printf (&muscle_obstack, ":%d.%d]]", bound.line, bound.column);
|
||||||
extension = obstack_finish0 (&muscle_obstack);
|
char const *extension = obstack_finish0 (&muscle_obstack);
|
||||||
muscle_grow (key, extension, "", "");
|
muscle_grow (key, extension, "", "");
|
||||||
obstack_free (&muscle_obstack, extension);
|
obstack_free (&muscle_obstack, extension);
|
||||||
}
|
}
|
||||||
@@ -322,9 +318,6 @@ static char *
|
|||||||
string_decode (char const *key)
|
string_decode (char const *key)
|
||||||
{
|
{
|
||||||
char const *value = muscle_find_const (key);
|
char const *value = muscle_find_const (key);
|
||||||
char *value_decoded;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
if (!value)
|
if (!value)
|
||||||
return NULL;
|
return NULL;
|
||||||
do {
|
do {
|
||||||
@@ -337,20 +330,20 @@ string_decode (char const *key)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (*value++);
|
} while (*value++);
|
||||||
value_decoded = obstack_finish (&muscle_obstack);
|
char const *value_decoded = obstack_finish (&muscle_obstack);
|
||||||
result = xstrdup (value_decoded);
|
char *res = xstrdup (value_decoded);
|
||||||
obstack_free (&muscle_obstack, value_decoded);
|
obstack_free (&muscle_obstack, value_decoded);
|
||||||
return result;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reverse of muscle_location_grow. */
|
/* Reverse of muscle_location_grow. */
|
||||||
static location
|
static location
|
||||||
location_decode (char const *value)
|
location_decode (char const *value)
|
||||||
{
|
{
|
||||||
location loc;
|
|
||||||
aver (value);
|
aver (value);
|
||||||
aver (*value == '[');
|
aver (*value == '[');
|
||||||
++value; aver (*value == '[');
|
++value; aver (*value == '[');
|
||||||
|
location loc;
|
||||||
while (*++value)
|
while (*++value)
|
||||||
switch (*value)
|
switch (*value)
|
||||||
{
|
{
|
||||||
@@ -359,29 +352,26 @@ location_decode (char const *value)
|
|||||||
aver (false);
|
aver (false);
|
||||||
break;
|
break;
|
||||||
case ']':
|
case ']':
|
||||||
{
|
++value; aver (*value == ']');
|
||||||
char *boundary_str;
|
char *boundary_str = obstack_finish0 (&muscle_obstack);
|
||||||
++value; aver (*value == ']');
|
switch (*++value)
|
||||||
boundary_str = obstack_finish0 (&muscle_obstack);
|
{
|
||||||
switch (*++value)
|
case ',':
|
||||||
{
|
boundary_set_from_string (&loc.start, boundary_str);
|
||||||
case ',':
|
obstack_free (&muscle_obstack, boundary_str);
|
||||||
boundary_set_from_string (&loc.start, boundary_str);
|
++value; aver (*value == ' ');
|
||||||
obstack_free (&muscle_obstack, boundary_str);
|
++value; aver (*value == '[');
|
||||||
++value; aver (*value == ' ');
|
++value; aver (*value == '[');
|
||||||
++value; aver (*value == '[');
|
break;
|
||||||
++value; aver (*value == '[');
|
case '\0':
|
||||||
break;
|
boundary_set_from_string (&loc.end, boundary_str);
|
||||||
case '\0':
|
obstack_free (&muscle_obstack, boundary_str);
|
||||||
boundary_set_from_string (&loc.end, boundary_str);
|
return loc;
|
||||||
obstack_free (&muscle_obstack, boundary_str);
|
break;
|
||||||
return loc;
|
default:
|
||||||
break;
|
aver (false);
|
||||||
default:
|
break;
|
||||||
aver (false);
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
aver (false);
|
aver (false);
|
||||||
@@ -446,21 +436,21 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
|
|||||||
} conversion_type;
|
} conversion_type;
|
||||||
const conversion_type conversion[] =
|
const conversion_type conversion[] =
|
||||||
{
|
{
|
||||||
{ "api.push_pull", "api.push-pull", },
|
{ "api.push_pull", "api.push-pull", },
|
||||||
{ "api.tokens.prefix", "api.token.prefix", },
|
{ "api.tokens.prefix", "api.token.prefix", },
|
||||||
{ "lex_symbol", "api.token.constructor", },
|
{ "lex_symbol", "api.token.constructor", },
|
||||||
{ "location_type", "api.location.type", },
|
{ "location_type", "api.location.type", },
|
||||||
{ "lr.default-reductions", "lr.default-reduction", },
|
{ "lr.default-reductions", "lr.default-reduction", },
|
||||||
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
|
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
|
||||||
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
|
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
|
||||||
{ "namespace", "api.namespace", },
|
{ "namespace", "api.namespace", },
|
||||||
{ "stype", "api.value.type", },
|
{ "stype", "api.value.type", },
|
||||||
{ "variant=", "api.value.type=variant", },
|
{ "variant=", "api.value.type=variant", },
|
||||||
{ "variant=true", "api.value.type=variant", },
|
{ "variant=true", "api.value.type=variant", },
|
||||||
{ NULL, NULL, }
|
{ NULL, NULL, }
|
||||||
};
|
};
|
||||||
conversion_type const *c;
|
|
||||||
for (c = conversion; c->obsolete; ++c)
|
for (conversion_type const *c = conversion; c->obsolete; ++c)
|
||||||
{
|
{
|
||||||
char const *eq = strchr (c->obsolete, '=');
|
char const *eq = strchr (c->obsolete, '=');
|
||||||
if (eq
|
if (eq
|
||||||
@@ -474,14 +464,12 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
|
|||||||
free (old);
|
free (old);
|
||||||
free (upd);
|
free (upd);
|
||||||
char *res = xstrdup (c->updated);
|
char *res = xstrdup (c->updated);
|
||||||
{
|
char *eq2 = strchr (res, '=');
|
||||||
char *eq2 = strchr (res, '=');
|
if (eq2)
|
||||||
if (eq2)
|
{
|
||||||
{
|
*eq2 = '\0';
|
||||||
*eq2 = '\0';
|
*value = eq2 + 1;
|
||||||
*value = eq2 + 1;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -507,9 +495,9 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
|||||||
&& muscle_find_const (name))
|
&& muscle_find_const (name))
|
||||||
{
|
{
|
||||||
muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
|
muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
|
||||||
unsigned i = 0;
|
|
||||||
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
||||||
goto end;
|
goto end;
|
||||||
|
unsigned i = 0;
|
||||||
complain_indent (&variable_loc, complaint, &i,
|
complain_indent (&variable_loc, complaint, &i,
|
||||||
_("%%define variable %s redefined"),
|
_("%%define variable %s redefined"),
|
||||||
quote (variable));
|
quote (variable));
|
||||||
@@ -645,16 +633,16 @@ bool
|
|||||||
muscle_percent_define_flag_if (char const *variable)
|
muscle_percent_define_flag_if (char const *variable)
|
||||||
{
|
{
|
||||||
uniqstr invalid_boolean_name = muscle_name (variable, "invalid_boolean");
|
uniqstr invalid_boolean_name = muscle_name (variable, "invalid_boolean");
|
||||||
bool result = false;
|
bool res = false;
|
||||||
|
|
||||||
if (muscle_percent_define_ifdef (variable))
|
if (muscle_percent_define_ifdef (variable))
|
||||||
{
|
{
|
||||||
char *value = muscle_percent_define_get (variable);
|
char *value = muscle_percent_define_get (variable);
|
||||||
muscle_percent_define_check_kind (variable, muscle_keyword);
|
muscle_percent_define_check_kind (variable, muscle_keyword);
|
||||||
if (value[0] == '\0' || STREQ (value, "true"))
|
if (value[0] == '\0' || STREQ (value, "true"))
|
||||||
result = true;
|
res = true;
|
||||||
else if (STREQ (value, "false"))
|
else if (STREQ (value, "false"))
|
||||||
result = false;
|
res = false;
|
||||||
else if (!muscle_find_const (invalid_boolean_name))
|
else if (!muscle_find_const (invalid_boolean_name))
|
||||||
{
|
{
|
||||||
muscle_insert (invalid_boolean_name, "");
|
muscle_insert (invalid_boolean_name, "");
|
||||||
@@ -669,7 +657,7 @@ muscle_percent_define_flag_if (char const *variable)
|
|||||||
complain (NULL, fatal, _("%s: undefined %%define variable %s"),
|
complain (NULL, fatal, _("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_flag", quote (variable));
|
"muscle_percent_define_flag", quote (variable));
|
||||||
|
|
||||||
return result;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -705,14 +693,12 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
for (++values; *values; ++values)
|
for (++values; *values; ++values)
|
||||||
{
|
if (STREQ (value, *values))
|
||||||
if (STREQ (value, *values))
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!*values)
|
if (!*values)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
|
||||||
location loc = muscle_percent_define_get_loc (*variablep);
|
location loc = muscle_percent_define_get_loc (*variablep);
|
||||||
|
unsigned i = 0;
|
||||||
complain_indent (&loc, complaint, &i,
|
complain_indent (&loc, complaint, &i,
|
||||||
_("invalid value for %%define variable %s: %s"),
|
_("invalid value for %%define variable %s: %s"),
|
||||||
quote (*variablep), quote_n (1, value));
|
quote (*variablep), quote_n (1, value));
|
||||||
@@ -722,10 +708,8 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
_("accepted value: %s"), quote (*values));
|
_("accepted value: %s"), quote (*values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
while (*values)
|
||||||
while (*values)
|
++values;
|
||||||
++values;
|
|
||||||
}
|
|
||||||
free (value);
|
free (value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ char *muscle_percent_define_get (char const *variable);
|
|||||||
/* Mimic muscle_percent_define_get_loc in ../data/bison.m4 exactly. That is,
|
/* Mimic muscle_percent_define_get_loc in ../data/bison.m4 exactly. That is,
|
||||||
if the %define variable VARIABLE is undefined, complain fatally since that's
|
if the %define variable VARIABLE is undefined, complain fatally since that's
|
||||||
a Bison error. Otherwise, return its definition location in a form
|
a Bison error. Otherwise, return its definition location in a form
|
||||||
approriate for the first argument of warn_at, complain_at, or fatal_at.
|
appropriate for the first argument of warn_at, complain_at, or fatal_at.
|
||||||
Don't record this as a Bison usage of VARIABLE as there's no reason to
|
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. */
|
suspect that the user-supplied value has yet influenced the output. */
|
||||||
location muscle_percent_define_get_loc (char const *variable);
|
location muscle_percent_define_get_loc (char const *variable);
|
||||||
|
|||||||
+9
-7
@@ -21,10 +21,10 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include <concat-filename.h>
|
|
||||||
#include <configmake.h>
|
#include <configmake.h>
|
||||||
#include <filename.h>
|
#include <filename.h> /* IS_PATH_WITH_DIR */
|
||||||
#include <get-errno.h>
|
#include <get-errno.h>
|
||||||
|
#include <path-join.h>
|
||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
#include <spawn-pipe.h>
|
#include <spawn-pipe.h>
|
||||||
#include <timevar.h>
|
#include <timevar.h>
|
||||||
@@ -531,11 +531,11 @@ output_skeleton (void)
|
|||||||
/* Compute the names of the package data dir and skeleton files. */
|
/* Compute the names of the package data dir and skeleton files. */
|
||||||
char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
|
char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
|
||||||
char const *datadir = pkgdatadir ();
|
char const *datadir = pkgdatadir ();
|
||||||
char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
|
char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4");
|
||||||
char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
|
char *m4bison = xpath_join (datadir, "bison.m4");
|
||||||
char *skel = (IS_PATH_WITH_DIR (skeleton)
|
char *skel = (IS_PATH_WITH_DIR (skeleton)
|
||||||
? xstrdup (skeleton)
|
? xstrdup (skeleton)
|
||||||
: xconcatenated_filename (datadir, skeleton, NULL));
|
: xpath_join (datadir, skeleton));
|
||||||
|
|
||||||
/* Test whether m4sugar.m4 is readable, to check for proper
|
/* Test whether m4sugar.m4 is readable, to check for proper
|
||||||
installation. A faulty installation can cause deadlock, so a
|
installation. A faulty installation can cause deadlock, so a
|
||||||
@@ -603,7 +603,7 @@ output_skeleton (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read and process m4's output. */
|
/* Read and process m4's output. */
|
||||||
timevar_push (TV_M4);
|
timevar_push (tv_m4);
|
||||||
{
|
{
|
||||||
FILE *in = xfdopen (filter_fd[0], "r");
|
FILE *in = xfdopen (filter_fd[0], "r");
|
||||||
scan_skel (in);
|
scan_skel (in);
|
||||||
@@ -614,7 +614,7 @@ output_skeleton (void)
|
|||||||
xfclose (in);
|
xfclose (in);
|
||||||
}
|
}
|
||||||
wait_subprocess (pid, "m4", false, false, true, true, NULL);
|
wait_subprocess (pid, "m4", false, false, true, true, NULL);
|
||||||
timevar_pop (TV_M4);
|
timevar_pop (tv_m4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -625,6 +625,8 @@ prepare (void)
|
|||||||
char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
|
char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
|
||||||
bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
|
bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
|
||||||
|
|
||||||
|
MUSCLE_INSERT_INT ("required_version", required_version);
|
||||||
|
|
||||||
/* Flags. */
|
/* Flags. */
|
||||||
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
||||||
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
||||||
|
|||||||
+299
-267
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 3.0.5.75-d835. */
|
/* A Bison parser, made by GNU Bison 3.1.222-4227c. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ extern int gram_debug;
|
|||||||
|
|
||||||
#include "symlist.h"
|
#include "symlist.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#line 221 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 222 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ extern int gram_debug;
|
|||||||
param_parse = 1 << 1,
|
param_parse = 1 << 1,
|
||||||
param_both = param_lex | param_parse
|
param_both = param_lex | param_parse
|
||||||
} param_type;
|
} param_type;
|
||||||
#line 644 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 645 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
#include "muscle-tab.h"
|
#include "muscle-tab.h"
|
||||||
|
|
||||||
#line 68 "src/parse-gram.h" /* yacc.c:1913 */
|
#line 68 "src/parse-gram.h" /* yacc.c:1913 */
|
||||||
@@ -135,27 +135,27 @@ extern int gram_debug;
|
|||||||
|
|
||||||
union GRAM_STYPE
|
union GRAM_STYPE
|
||||||
{
|
{
|
||||||
#line 182 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 183 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
unsigned char character;
|
unsigned char character;
|
||||||
#line 186 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 187 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
char *code;
|
char *code;
|
||||||
#line 191 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 192 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
uniqstr uniqstr;
|
uniqstr uniqstr;
|
||||||
#line 199 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 200 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
int integer;
|
int integer;
|
||||||
#line 203 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 204 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
#line 208 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 209 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
assoc assoc;
|
assoc assoc;
|
||||||
#line 211 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 212 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
#line 214 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 215 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
named_ref *named_ref;
|
named_ref *named_ref;
|
||||||
#line 241 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 242 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
param_type param;
|
param_type param;
|
||||||
#line 408 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 409 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
code_props_type code_type;
|
code_props_type code_type;
|
||||||
#line 646 "src/parse-gram.y" /* yacc.c:1913 */
|
#line 647 "src/parse-gram.y" /* yacc.c:1913 */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|||||||
+31
-3
@@ -32,6 +32,7 @@
|
|||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "c-ctype.h"
|
#include "c-ctype.h"
|
||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
@@ -822,10 +823,37 @@ add_param (param_type type, char *decl, location loc)
|
|||||||
static void
|
static void
|
||||||
version_check (location const *loc, char const *version)
|
version_check (location const *loc, char const *version)
|
||||||
{
|
{
|
||||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
/* Changes of behavior are only on minor version changes, so "3.0.5"
|
||||||
|
is the same as "3.0". */
|
||||||
|
errno = 0;
|
||||||
|
char* cp = NULL;
|
||||||
|
unsigned long major = strtoul (version, &cp, 10);
|
||||||
|
if (errno || *cp != '.')
|
||||||
{
|
{
|
||||||
complain (loc, complaint, "require bison %s, but have %s",
|
complain (loc, complaint, _("invalid version requirement: %s"),
|
||||||
version, PACKAGE_VERSION);
|
version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++cp;
|
||||||
|
unsigned long minor = strtoul (cp, NULL, 10);
|
||||||
|
if (errno)
|
||||||
|
{
|
||||||
|
complain (loc, complaint, _("invalid version requirement: %s"),
|
||||||
|
version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
required_version = major * 100 + minor;
|
||||||
|
/* Pretend to be at least 3.2, even if we are only 3.1-211, as it
|
||||||
|
allows us to check features published in 3.2 while developping
|
||||||
|
3.2. */
|
||||||
|
const char* api_version = "3.2";
|
||||||
|
const char* package_version =
|
||||||
|
strverscmp (api_version, PACKAGE_VERSION) > 0
|
||||||
|
? api_version : PACKAGE_VERSION;
|
||||||
|
if (strverscmp (version, package_version) > 0)
|
||||||
|
{
|
||||||
|
complain (loc, complaint, _("require bison %s, but have %s"),
|
||||||
|
version, package_version);
|
||||||
exit (EX_MISMATCH);
|
exit (EX_MISMATCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-10
@@ -48,7 +48,6 @@ print_core (struct obstack *oout, state *s)
|
|||||||
{
|
{
|
||||||
item_number const *sitems = s->items;
|
item_number const *sitems = s->items;
|
||||||
sym_content *previous_lhs = NULL;
|
sym_content *previous_lhs = NULL;
|
||||||
size_t i;
|
|
||||||
size_t snritems = s->nitems;
|
size_t snritems = s->nitems;
|
||||||
|
|
||||||
/* Output all the items of a state, not just its kernel. */
|
/* Output all the items of a state, not just its kernel. */
|
||||||
@@ -61,16 +60,15 @@ print_core (struct obstack *oout, state *s)
|
|||||||
|
|
||||||
obstack_printf (oout, _("State %d"), s->number);
|
obstack_printf (oout, _("State %d"), s->number);
|
||||||
obstack_sgrow (oout, "\\n\\l");
|
obstack_sgrow (oout, "\\n\\l");
|
||||||
for (i = 0; i < snritems; i++)
|
for (size_t i = 0; i < snritems; ++i)
|
||||||
{
|
{
|
||||||
item_number const *sp1 = ritem + sitems[i];
|
item_number const *sp1 = ritem + sitems[i];
|
||||||
item_number const *sp = sp1;
|
item_number const *sp = sp1;
|
||||||
rule *r;
|
|
||||||
|
|
||||||
while (0 <= *sp)
|
while (0 <= *sp)
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
r = &rules[item_number_as_rule_number (*sp)];
|
rule *r = &rules[item_number_as_rule_number (*sp)];
|
||||||
|
|
||||||
obstack_printf (oout, "%3d ", r->number);
|
obstack_printf (oout, "%3d ", r->number);
|
||||||
if (previous_lhs && UNIQSTR_EQ (previous_lhs->symbol->tag,
|
if (previous_lhs && UNIQSTR_EQ (previous_lhs->symbol->tag,
|
||||||
@@ -130,16 +128,15 @@ static void
|
|||||||
print_actions (state const *s, FILE *fgraph)
|
print_actions (state const *s, FILE *fgraph)
|
||||||
{
|
{
|
||||||
transitions const *trans = s->transitions;
|
transitions const *trans = s->transitions;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!trans->num && !s->reductions)
|
if (!trans->num && !s->reductions)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < trans->num; i++)
|
for (int i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, i))
|
if (!TRANSITION_IS_DISABLED (trans, i))
|
||||||
{
|
{
|
||||||
state *s1 = trans->states[i];
|
const state *s1 = trans->states[i];
|
||||||
symbol_number sym = s1->accessing_symbol;
|
const symbol_number sym = s1->accessing_symbol;
|
||||||
|
|
||||||
/* Shifts are solid, gotos are dashed, and error is dotted. */
|
/* Shifts are solid, gotos are dashed, and error is dotted. */
|
||||||
char const *style =
|
char const *style =
|
||||||
@@ -183,13 +180,12 @@ print_state (state *s, FILE *fgraph)
|
|||||||
void
|
void
|
||||||
print_graph (void)
|
print_graph (void)
|
||||||
{
|
{
|
||||||
state_number i;
|
|
||||||
FILE *fgraph = xfopen (spec_graph_file, "w");
|
FILE *fgraph = xfopen (spec_graph_file, "w");
|
||||||
start_graph (fgraph);
|
start_graph (fgraph);
|
||||||
|
|
||||||
/* Output nodes and edges. */
|
/* Output nodes and edges. */
|
||||||
new_closure (nritems);
|
new_closure (nritems);
|
||||||
for (i = 0; i < nstates; i++)
|
for (int i = 0; i < nstates; i++)
|
||||||
print_state (states[i], fgraph);
|
print_state (states[i], fgraph);
|
||||||
free_closure ();
|
free_closure ();
|
||||||
|
|
||||||
|
|||||||
+71
-50
@@ -253,8 +253,8 @@ grammar_current_rule_begin (symbol *lhs, location loc,
|
|||||||
/*----------------------------------------------------------------------.
|
/*----------------------------------------------------------------------.
|
||||||
| A symbol should be used if either: |
|
| A symbol should be used if either: |
|
||||||
| 1. It has a destructor. |
|
| 1. It has a destructor. |
|
||||||
| 2. The symbol is a mid-rule symbol (i.e., the generated LHS |
|
| 2. The symbol is a midrule symbol (i.e., the generated LHS |
|
||||||
| replacing a mid-rule action) that was assigned to or used, as in |
|
| replacing a midrule action) that was assigned to or used, as in |
|
||||||
| "exp: { $$ = 1; } { $$ = $1; }". |
|
| "exp: { $$ = 1; } { $$ = $1; }". |
|
||||||
`----------------------------------------------------------------------*/
|
`----------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -275,13 +275,14 @@ symbol_should_be_used (symbol_list const *s, bool *midrule_warning)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
/*-----------------------------------------------------------------.
|
||||||
| Check that the rule R is properly defined. For instance, there |
|
| Check that the rule R is properly defined. For instance, there |
|
||||||
| should be no type clash on the default action. |
|
| should be no type clash on the default action. Possibly install |
|
||||||
`----------------------------------------------------------------*/
|
| the default action. |
|
||||||
|
`-----------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grammar_rule_check (const symbol_list *r)
|
grammar_rule_check_and_complete (symbol_list *r)
|
||||||
{
|
{
|
||||||
/* Type check.
|
/* Type check.
|
||||||
|
|
||||||
@@ -303,6 +304,23 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
complain (&r->location, Wother,
|
complain (&r->location, Wother,
|
||||||
_("type clash on default action: <%s> != <%s>"),
|
_("type clash on default action: <%s> != <%s>"),
|
||||||
lhs_type, rhs_type);
|
lhs_type, rhs_type);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Install the default action only for C++. */
|
||||||
|
const bool is_cxx =
|
||||||
|
STREQ (language->language, "c++")
|
||||||
|
|| (skeleton && (STREQ (skeleton, "glr.cc")
|
||||||
|
|| STREQ (skeleton, "lalr1.cc")));
|
||||||
|
if (is_cxx)
|
||||||
|
{
|
||||||
|
code_props_rule_action_init (&r->action_props, "{ $$ = $1; }",
|
||||||
|
r->location, r,
|
||||||
|
/* name */ NULL,
|
||||||
|
/* type */ NULL,
|
||||||
|
/* is_predicate */ false);
|
||||||
|
code_props_translate_code (&r->action_props);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Warn if there is no default for $$ but we need one. */
|
/* Warn if there is no default for $$ but we need one. */
|
||||||
else
|
else
|
||||||
@@ -373,9 +391,9 @@ grammar_current_rule_end (location loc)
|
|||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
| The previous action turns out to be a mid-rule action. Attach it |
|
| The previous action turns out to be a midrule action. Attach it |
|
||||||
| to the current rule, i.e., create a dummy symbol, attach it this |
|
| to the current rule, i.e., create a dummy symbol, attach it this |
|
||||||
| mid-rule action, and append this dummy nonterminal to the current |
|
| midrule action, and append this dummy nonterminal to the current |
|
||||||
| rule. |
|
| rule. |
|
||||||
`-------------------------------------------------------------------*/
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -439,14 +457,14 @@ grammar_current_rule_prec_set (symbol *precsym, location loc)
|
|||||||
{
|
{
|
||||||
/* POSIX says that any identifier is a nonterminal if it does not
|
/* POSIX says that any identifier is a nonterminal if it does not
|
||||||
appear on the LHS of a grammar rule and is not defined by %token
|
appear on the LHS of a grammar rule and is not defined by %token
|
||||||
or by one of the directives that assigns precedence to a token. We
|
or by one of the directives that assigns precedence to a token.
|
||||||
ignore this here because the only kind of identifier that POSIX
|
We ignore this here because the only kind of identifier that
|
||||||
allows to follow a %prec is a token and because assuming it's a
|
POSIX allows to follow a %prec is a token and because assuming
|
||||||
token now can produce more logical error messages. Nevertheless,
|
it's a token now can produce more logical error messages.
|
||||||
grammar_rule_check does obey what we believe is the real intent of
|
Nevertheless, grammar_rule_check_and_complete does obey what we
|
||||||
POSIX here: that an error be reported for any identifier that
|
believe is the real intent of POSIX here: that an error be
|
||||||
appears after %prec but that is not defined separately as a
|
reported for any identifier that appears after %prec but that is
|
||||||
token. */
|
not defined separately as a token. */
|
||||||
symbol_class_set (precsym, token_sym, loc, false);
|
symbol_class_set (precsym, token_sym, loc, false);
|
||||||
if (current_rule->ruleprec)
|
if (current_rule->ruleprec)
|
||||||
duplicate_directive ("%prec",
|
duplicate_directive ("%prec",
|
||||||
@@ -512,7 +530,7 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Attach SYM to the current rule. If needed, move the previous
|
/* Attach SYM to the current rule. If needed, move the previous
|
||||||
action as a mid-rule action. */
|
action as a midrule action. */
|
||||||
|
|
||||||
void
|
void
|
||||||
grammar_current_rule_symbol_append (symbol *sym, location loc,
|
grammar_current_rule_symbol_append (symbol *sym, location loc,
|
||||||
@@ -576,39 +594,40 @@ packgram (void)
|
|||||||
|
|
||||||
for (symbol_list *p = grammar; p; p = p->next)
|
for (symbol_list *p = grammar; p; p = p->next)
|
||||||
{
|
{
|
||||||
symbol *ruleprec = p->ruleprec;
|
symbol_list *lhs = p;
|
||||||
record_merge_function_type (p->merger, p->content.sym->content->type_name,
|
record_merge_function_type (lhs->merger, lhs->content.sym->content->type_name,
|
||||||
p->merger_declaration_location);
|
lhs->merger_declaration_location);
|
||||||
rules[ruleno].user_number = ruleno;
|
|
||||||
rules[ruleno].number = ruleno;
|
|
||||||
rules[ruleno].lhs = p->content.sym->content;
|
|
||||||
rules[ruleno].rhs = ritem + itemno;
|
|
||||||
rules[ruleno].prec = NULL;
|
|
||||||
rules[ruleno].dprec = p->dprec;
|
|
||||||
rules[ruleno].merger = p->merger;
|
|
||||||
rules[ruleno].precsym = NULL;
|
|
||||||
rules[ruleno].location = p->location;
|
|
||||||
rules[ruleno].useful = true;
|
|
||||||
rules[ruleno].action = p->action_props.code;
|
|
||||||
rules[ruleno].action_location = p->action_props.location;
|
|
||||||
rules[ruleno].is_predicate = p->action_props.is_predicate;
|
|
||||||
|
|
||||||
/* If the midrule's $$ is set or its $n is used, remove the '$' from the
|
/* If the midrule's $$ is set or its $n is used, remove the '$' from the
|
||||||
symbol name so that it's a user-defined symbol so that the default
|
symbol name so that it's a user-defined symbol so that the default
|
||||||
%destructor and %printer apply. */
|
%destructor and %printer apply. */
|
||||||
if (p->midrule_parent_rule
|
if (lhs->midrule_parent_rule
|
||||||
&& (p->action_props.is_value_used
|
&& (lhs->action_props.is_value_used
|
||||||
|| (symbol_list_n_get (p->midrule_parent_rule,
|
|| (symbol_list_n_get (lhs->midrule_parent_rule,
|
||||||
p->midrule_parent_rhs_index)
|
lhs->midrule_parent_rhs_index)
|
||||||
->action_props.is_value_used)))
|
->action_props.is_value_used)))
|
||||||
p->content.sym->tag += 1;
|
lhs->content.sym->tag += 1;
|
||||||
|
|
||||||
/* Don't check the generated rule 0. It has no action, so some rhs
|
/* Don't check the generated rule 0. It has no action, so some rhs
|
||||||
symbols may appear unused, but the parsing algorithm ensures that
|
symbols may appear unused, but the parsing algorithm ensures that
|
||||||
%destructor's are invoked appropriately. */
|
%destructor's are invoked appropriately. */
|
||||||
if (p != grammar)
|
if (p != grammar)
|
||||||
grammar_rule_check (p);
|
grammar_rule_check_and_complete (p);
|
||||||
|
|
||||||
|
rules[ruleno].user_number = ruleno;
|
||||||
|
rules[ruleno].number = ruleno;
|
||||||
|
rules[ruleno].lhs = lhs->content.sym->content;
|
||||||
|
rules[ruleno].rhs = ritem + itemno;
|
||||||
|
rules[ruleno].prec = NULL;
|
||||||
|
rules[ruleno].dprec = lhs->dprec;
|
||||||
|
rules[ruleno].merger = lhs->merger;
|
||||||
|
rules[ruleno].precsym = NULL;
|
||||||
|
rules[ruleno].location = lhs->location;
|
||||||
|
rules[ruleno].useful = true;
|
||||||
|
rules[ruleno].action = lhs->action_props.code;
|
||||||
|
rules[ruleno].action_location = lhs->action_props.location;
|
||||||
|
rules[ruleno].is_predicate = lhs->action_props.is_predicate;
|
||||||
|
|
||||||
|
/* Traverse the rhs. */
|
||||||
{
|
{
|
||||||
size_t rule_length = 0;
|
size_t rule_length = 0;
|
||||||
for (p = p->next; p->content.sym; p = p->next)
|
for (p = p->next; p->content.sym; p = p->next)
|
||||||
@@ -633,11 +652,12 @@ packgram (void)
|
|||||||
|
|
||||||
/* If this rule has a %prec,
|
/* If this rule has a %prec,
|
||||||
the specified symbol's precedence replaces the default. */
|
the specified symbol's precedence replaces the default. */
|
||||||
if (ruleprec)
|
if (lhs->ruleprec)
|
||||||
{
|
{
|
||||||
rules[ruleno].precsym = ruleprec->content;
|
rules[ruleno].precsym = lhs->ruleprec->content;
|
||||||
rules[ruleno].prec = ruleprec->content;
|
rules[ruleno].prec = lhs->ruleprec->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An item ends by the rule number (negated). */
|
/* An item ends by the rule number (negated). */
|
||||||
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
||||||
aver (itemno < ITEM_NUMBER_MAX);
|
aver (itemno < ITEM_NUMBER_MAX);
|
||||||
@@ -797,12 +817,13 @@ check_and_convert_grammar (void)
|
|||||||
symbols_pack above) so that token types are set correctly before the rule
|
symbols_pack above) so that token types are set correctly before the rule
|
||||||
action type checking.
|
action type checking.
|
||||||
|
|
||||||
Before invoking grammar_rule_check (in packgram below) on any rule, make
|
Before invoking grammar_rule_check_and_complete (in packgram
|
||||||
sure all actions have already been scanned in order to set 'used' flags.
|
below) on any rule, make sure all actions have already been
|
||||||
Otherwise, checking that a midrule's $$ should be set will not always work
|
scanned in order to set 'used' flags. Otherwise, checking that a
|
||||||
properly because the check must forward-reference the midrule's parent
|
midrule's $$ should be set will not always work properly because
|
||||||
rule. For the same reason, all the 'used' flags must be set before
|
the check must forward-reference the midrule's parent rule. For
|
||||||
checking whether to remove '$' from any midrule symbol name (also in
|
the same reason, all the 'used' flags must be set before checking
|
||||||
|
whether to remove '$' from any midrule symbol name (also in
|
||||||
packgram). */
|
packgram). */
|
||||||
for (symbol_list *sym = grammar; sym; sym = sym->next)
|
for (symbol_list *sym = grammar; sym; sym = sym->next)
|
||||||
code_props_translate_code (&sym->action_props);
|
code_props_translate_code (&sym->action_props);
|
||||||
|
|||||||
+30
-57
@@ -52,9 +52,7 @@ static bitset V;
|
|||||||
'useless', but no warning should be issued). */
|
'useless', but no warning should be issued). */
|
||||||
static bitset V1;
|
static bitset V1;
|
||||||
|
|
||||||
static unsigned nuseful_productions;
|
|
||||||
unsigned nuseless_productions;
|
unsigned nuseless_productions;
|
||||||
static unsigned nuseful_nonterminals;
|
|
||||||
unsigned nuseless_nonterminals;
|
unsigned nuseless_nonterminals;
|
||||||
|
|
||||||
#define bitset_swap(Lhs, Rhs) \
|
#define bitset_swap(Lhs, Rhs) \
|
||||||
@@ -73,12 +71,10 @@ unsigned nuseless_nonterminals;
|
|||||||
static bool
|
static bool
|
||||||
useful_production (rule_number r, bitset N0)
|
useful_production (rule_number r, bitset N0)
|
||||||
{
|
{
|
||||||
item_number *rhsp;
|
|
||||||
|
|
||||||
/* A production is useful if all of the nonterminals in its appear
|
/* A production is useful if all of the nonterminals in its appear
|
||||||
in the set of useful nonterminals. */
|
in the set of useful nonterminals. */
|
||||||
|
|
||||||
for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
|
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
|
||||||
if (ISVAR (*rhsp) && !bitset_test (N0, *rhsp - ntokens))
|
if (ISVAR (*rhsp) && !bitset_test (N0, *rhsp - ntokens))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -115,9 +111,8 @@ useless_nonterminals (void)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
rule_number r;
|
|
||||||
bitset_copy (Np, N);
|
bitset_copy (Np, N);
|
||||||
for (r = 0; r < nrules; ++r)
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
if (!bitset_test (P, r)
|
if (!bitset_test (P, r)
|
||||||
&& useful_production (r, N))
|
&& useful_production (r, N))
|
||||||
{
|
{
|
||||||
@@ -169,15 +164,13 @@ inaccessable_symbols (void)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
rule_number r;
|
|
||||||
bitset_copy (Vp, V);
|
bitset_copy (Vp, V);
|
||||||
for (r = 0; r < nrules; ++r)
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
if (!bitset_test (Pp, r)
|
if (!bitset_test (Pp, r)
|
||||||
&& bitset_test (P, r)
|
&& bitset_test (P, r)
|
||||||
&& bitset_test (V, rules[r].lhs->number))
|
&& bitset_test (V, rules[r].lhs->number))
|
||||||
{
|
{
|
||||||
item_number *rhsp;
|
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
|
||||||
for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
|
|
||||||
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
|
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
|
||||||
bitset_set (Vp, *rhsp);
|
bitset_set (Vp, *rhsp);
|
||||||
bitset_set (Pp, r);
|
bitset_set (Pp, r);
|
||||||
@@ -200,24 +193,18 @@ inaccessable_symbols (void)
|
|||||||
bitset_free (P);
|
bitset_free (P);
|
||||||
P = Pp;
|
P = Pp;
|
||||||
|
|
||||||
nuseful_productions = bitset_count (P);
|
unsigned nuseful_productions = bitset_count (P);
|
||||||
nuseless_productions = nrules - nuseful_productions;
|
nuseless_productions = nrules - nuseful_productions;
|
||||||
|
|
||||||
nuseful_nonterminals = 0;
|
unsigned nuseful_nonterminals = 0;
|
||||||
{
|
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||||
symbol_number i;
|
nuseful_nonterminals += bitset_test (V, i);
|
||||||
for (i = ntokens; i < nsyms; ++i)
|
|
||||||
nuseful_nonterminals += bitset_test (V, i);
|
|
||||||
}
|
|
||||||
nuseless_nonterminals = nvars - nuseful_nonterminals;
|
nuseless_nonterminals = nvars - nuseful_nonterminals;
|
||||||
|
|
||||||
/* A token that was used in %prec should not be warned about. */
|
/* A token that was used in %prec should not be warned about. */
|
||||||
{
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
rule_number r;
|
if (rules[r].precsym != 0)
|
||||||
for (r = 0; r < nrules; ++r)
|
bitset_set (V1, rules[r].precsym->number);
|
||||||
if (rules[r].precsym != 0)
|
|
||||||
bitset_set (V1, rules[r].precsym->number);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -231,8 +218,7 @@ reduce_grammar_tables (void)
|
|||||||
{
|
{
|
||||||
/* Report and flag useless productions. */
|
/* Report and flag useless productions. */
|
||||||
{
|
{
|
||||||
rule_number r;
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
for (r = 0; r < nrules; ++r)
|
|
||||||
rules[r].useful = bitset_test (P, r);
|
rules[r].useful = bitset_test (P, r);
|
||||||
grammar_rules_useless_report (_("rule useless in grammar"));
|
grammar_rules_useless_report (_("rule useless in grammar"));
|
||||||
}
|
}
|
||||||
@@ -243,14 +229,13 @@ reduce_grammar_tables (void)
|
|||||||
int useful = 0;
|
int useful = 0;
|
||||||
int useless = nrules - nuseless_productions;
|
int useless = nrules - nuseless_productions;
|
||||||
rule *rules_sorted = xnmalloc (nrules, sizeof *rules_sorted);
|
rule *rules_sorted = xnmalloc (nrules, sizeof *rules_sorted);
|
||||||
rule_number r;
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
for (r = 0; r < nrules; ++r)
|
|
||||||
rules_sorted[rules[r].useful ? useful++ : useless++] = rules[r];
|
rules_sorted[rules[r].useful ? useful++ : useless++] = rules[r];
|
||||||
free (rules);
|
free (rules);
|
||||||
rules = rules_sorted;
|
rules = rules_sorted;
|
||||||
|
|
||||||
/* Renumber the rules markers in RITEMS. */
|
/* Renumber the rules markers in RITEMS. */
|
||||||
for (r = 0; r < nrules; ++r)
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
{
|
{
|
||||||
item_number *rhsp = rules[r].rhs;
|
item_number *rhsp = rules[r].rhs;
|
||||||
for (/* Nothing. */; 0 <= *rhsp; ++rhsp)
|
for (/* Nothing. */; 0 <= *rhsp; ++rhsp)
|
||||||
@@ -262,14 +247,10 @@ reduce_grammar_tables (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust NRITEMS. */
|
/* Adjust NRITEMS. */
|
||||||
{
|
for (rule_number r = nrules; r < nrules + nuseless_productions; ++r)
|
||||||
rule_number r;
|
{
|
||||||
int length;
|
int length = rule_rhs_length (&rules[r]);
|
||||||
for (r = nrules; r < nrules + nuseless_productions; ++r)
|
nritems -= length + 1;
|
||||||
{
|
|
||||||
length = rule_rhs_length (&rules[r]);
|
|
||||||
nritems -= length + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,11 +268,10 @@ nonterminals_reduce (void)
|
|||||||
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
|
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
|
||||||
{
|
{
|
||||||
symbol_number n = ntokens;
|
symbol_number n = ntokens;
|
||||||
symbol_number i;
|
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||||
for (i = ntokens; i < nsyms; ++i)
|
|
||||||
if (bitset_test (V, i))
|
if (bitset_test (V, i))
|
||||||
nontermmap[i - ntokens] = n++;
|
nontermmap[i - ntokens] = n++;
|
||||||
for (i = ntokens; i < nsyms; ++i)
|
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||||
if (!bitset_test (V, i))
|
if (!bitset_test (V, i))
|
||||||
{
|
{
|
||||||
nontermmap[i - ntokens] = n++;
|
nontermmap[i - ntokens] = n++;
|
||||||
@@ -306,26 +286,21 @@ nonterminals_reduce (void)
|
|||||||
/* Shuffle elements of tables indexed by symbol number. */
|
/* Shuffle elements of tables indexed by symbol number. */
|
||||||
{
|
{
|
||||||
symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted);
|
symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted);
|
||||||
symbol_number i;
|
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||||
for (i = ntokens; i < nsyms; ++i)
|
|
||||||
symbols[i]->content->number = nontermmap[i - ntokens];
|
symbols[i]->content->number = nontermmap[i - ntokens];
|
||||||
for (i = ntokens; i < nsyms; ++i)
|
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||||
symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i];
|
symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i];
|
||||||
for (i = ntokens; i < nsyms; ++i)
|
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||||
symbols[i] = symbols_sorted[i - ntokens];
|
symbols[i] = symbols_sorted[i - ntokens];
|
||||||
free (symbols_sorted);
|
free (symbols_sorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
rule_number r;
|
for (rule_number r = 0; r < nrules; ++r)
|
||||||
for (r = 0; r < nrules; ++r)
|
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
|
||||||
{
|
if (ISVAR (*rhsp))
|
||||||
item_number *rhsp;
|
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
|
||||||
for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
|
- ntokens]);
|
||||||
if (ISVAR (*rhsp))
|
|
||||||
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
|
|
||||||
- ntokens]);
|
|
||||||
}
|
|
||||||
accept->content->number = nontermmap[accept->content->number - ntokens];
|
accept->content->number = nontermmap[accept->content->number - ntokens];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,17 +320,15 @@ reduce_output (FILE *out)
|
|||||||
{
|
{
|
||||||
if (nuseless_nonterminals)
|
if (nuseless_nonterminals)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
||||||
for (i = 0; i < nuseless_nonterminals; ++i)
|
for (int i = 0; i < nuseless_nonterminals; ++i)
|
||||||
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
|
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
bool b = false;
|
bool b = false;
|
||||||
int i;
|
for (int i = 0; i < ntokens; ++i)
|
||||||
for (i = 0; i < ntokens; ++i)
|
|
||||||
if (reduce_token_unused_in_grammar (i))
|
if (reduce_token_unused_in_grammar (i))
|
||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ typedef struct code_props {
|
|||||||
/** Named reference. */
|
/** Named reference. */
|
||||||
named_ref *named_ref;
|
named_ref *named_ref;
|
||||||
|
|
||||||
/** Type, for mid-rule actions. */
|
/** Type, for midrule actions. */
|
||||||
uniqstr type;
|
uniqstr type;
|
||||||
} code_props;
|
} code_props;
|
||||||
|
|
||||||
|
|||||||
+36
-58
@@ -215,10 +215,7 @@ is_dot_or_dash (char ch)
|
|||||||
static inline bool
|
static inline bool
|
||||||
contains_dot_or_dash (const char* p)
|
contains_dot_or_dash (const char* p)
|
||||||
{
|
{
|
||||||
for (; *p; ++p)
|
return strpbrk(p, ".-");
|
||||||
if (is_dot_or_dash (*p))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Defines a variant of a symbolic name resolution. */
|
/* Defines a variant of a symbolic name resolution. */
|
||||||
@@ -277,26 +274,21 @@ variant_table_free (void)
|
|||||||
variant_table_size = variant_count = 0;
|
variant_table_size = variant_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char const *
|
||||||
find_prefix_end (const char *prefix, char *begin, char *end)
|
find_prefix_end (char const *prefix, char const *cp, char const *end)
|
||||||
{
|
{
|
||||||
char *ptr = begin;
|
for (; *prefix && cp != end; ++prefix, ++cp)
|
||||||
|
if (*prefix != *cp)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (; *prefix && ptr != end; ++prefix, ++ptr)
|
return *prefix ? NULL : cp;
|
||||||
if (*prefix != *ptr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (*prefix)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static variant *
|
static variant *
|
||||||
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
||||||
char *cp, char *cp_end, bool explicit_bracketing)
|
char const *cp, char const *cp_end, bool explicit_bracketing)
|
||||||
{
|
{
|
||||||
char *prefix_end = find_prefix_end (id, cp, cp_end);
|
char const *prefix_end = find_prefix_end (id, cp, cp_end);
|
||||||
if (prefix_end &&
|
if (prefix_end &&
|
||||||
(prefix_end == cp_end ||
|
(prefix_end == cp_end ||
|
||||||
(!explicit_bracketing && is_dot_or_dash (*prefix_end))))
|
(!explicit_bracketing && is_dot_or_dash (*prefix_end))))
|
||||||
@@ -379,7 +371,7 @@ show_sub_message (warnings warning,
|
|||||||
|
|
||||||
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
||||||
obstack_printf (&msg_buf,
|
obstack_printf (&msg_buf,
|
||||||
_(", cannot be accessed from mid-rule action at $%d"),
|
_(", cannot be accessed from midrule action at $%d"),
|
||||||
midrule_rhs_index);
|
midrule_rhs_index);
|
||||||
|
|
||||||
complain_indent (&id_loc, warning, &indent, "%s",
|
complain_indent (&id_loc, warning, &indent, "%s",
|
||||||
@@ -433,35 +425,14 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *cp_end;
|
bool const explicit_bracketing = *cp == '[';
|
||||||
bool explicit_bracketing;
|
|
||||||
|
|
||||||
if ('[' == *cp)
|
if (explicit_bracketing)
|
||||||
{
|
++cp;
|
||||||
/* Ignore the brackets. */
|
|
||||||
char *p;
|
|
||||||
for (p = ++cp; *p != ']'; ++p)
|
|
||||||
continue;
|
|
||||||
cp_end = p;
|
|
||||||
|
|
||||||
explicit_bracketing = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
ref_tail_fields = strpbrk (cp, ".-");
|
||||||
/* Take all characters of the name. */
|
|
||||||
char* p;
|
|
||||||
for (p = cp; *p; ++p)
|
|
||||||
if (is_dot_or_dash (*p))
|
|
||||||
{
|
|
||||||
ref_tail_fields = p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for (p = cp; *p; ++p)
|
|
||||||
continue;
|
|
||||||
cp_end = p;
|
|
||||||
|
|
||||||
explicit_bracketing = false;
|
char const *cp_end = strchr (cp, explicit_bracketing ? ']' : '\0');
|
||||||
}
|
|
||||||
|
|
||||||
/* Add all relevant variants. */
|
/* Add all relevant variants. */
|
||||||
{
|
{
|
||||||
@@ -494,7 +465,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
variant *var = &variant_table[i];
|
variant *var = &variant_table[i];
|
||||||
unsigned symbol_index = var->symbol_index;
|
unsigned symbol_index = var->symbol_index;
|
||||||
|
|
||||||
/* Check visibility from mid-rule actions. */
|
/* Check visibility from midrule actions. */
|
||||||
if (midrule_rhs_index != 0
|
if (midrule_rhs_index != 0
|
||||||
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
|
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
|
||||||
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
|
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
|
||||||
@@ -705,8 +676,15 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
obstack_quote (&obstack_for_string, type_name);
|
obstack_quote (&obstack_for_string, type_name);
|
||||||
obstack_sgrow (&obstack_for_string, ")[");
|
obstack_sgrow (&obstack_for_string, ")[");
|
||||||
if (0 < n)
|
if (0 < n)
|
||||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
{
|
||||||
true;
|
symbol_list *sym = symbol_list_n_get (effective_rule, n);
|
||||||
|
if (muscle_percent_define_ifdef ("api.value.automove")
|
||||||
|
&& sym->action_props.is_value_used)
|
||||||
|
complain (&dollar_loc, Wother,
|
||||||
|
_("multiple occurrences of $%d with api.value.automove"),
|
||||||
|
n);
|
||||||
|
sym->action_props.is_value_used = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -834,17 +812,17 @@ code_props_translate_code (code_props *self)
|
|||||||
{
|
{
|
||||||
switch (self->kind)
|
switch (self->kind)
|
||||||
{
|
{
|
||||||
case CODE_PROPS_NONE:
|
case CODE_PROPS_NONE:
|
||||||
break;
|
break;
|
||||||
case CODE_PROPS_PLAIN:
|
case CODE_PROPS_PLAIN:
|
||||||
self->code = translate_action (self, INITIAL);
|
self->code = translate_action (self, INITIAL);
|
||||||
break;
|
break;
|
||||||
case CODE_PROPS_SYMBOL_ACTION:
|
case CODE_PROPS_SYMBOL_ACTION:
|
||||||
self->code = translate_action (self, SC_SYMBOL_ACTION);
|
self->code = translate_action (self, SC_SYMBOL_ACTION);
|
||||||
break;
|
break;
|
||||||
case CODE_PROPS_RULE_ACTION:
|
case CODE_PROPS_RULE_ACTION:
|
||||||
self->code = translate_action (self, SC_RULE_ACTION);
|
self->code = translate_action (self, SC_RULE_ACTION);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -707,7 +707,7 @@ eqopt ([[:space:]]*=)?
|
|||||||
"{"|"<"{splice}"%" STRING_GROW; nesting++;
|
"{"|"<"{splice}"%" STRING_GROW; nesting++;
|
||||||
"%"{splice}">" STRING_GROW; nesting--;
|
"%"{splice}">" STRING_GROW; nesting--;
|
||||||
|
|
||||||
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrrectly
|
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrectly
|
||||||
(as '<' '<%'). */
|
(as '<' '<%'). */
|
||||||
"<"{splice}"<" STRING_GROW;
|
"<"{splice}"<" STRING_GROW;
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -29,8 +29,9 @@
|
|||||||
#define FLEX_PREFIX(Id) skel_ ## Id
|
#define FLEX_PREFIX(Id) skel_ ## Id
|
||||||
#include <src/flex-scanner.h>
|
#include <src/flex-scanner.h>
|
||||||
|
|
||||||
#include <dirname.h>
|
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
|
#include <dirname.h>
|
||||||
|
#include <path-join.h>
|
||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
|
|
||||||
#include <src/complain.h>
|
#include <src/complain.h>
|
||||||
@@ -236,14 +237,14 @@ at_complain (int argc, char *argv[], char **out_namep, int *out_linenop)
|
|||||||
static void
|
static void
|
||||||
at_output (int argc, char *argv[], char **out_namep, int *out_linenop)
|
at_output (int argc, char *argv[], char **out_namep, int *out_linenop)
|
||||||
{
|
{
|
||||||
if (2 < argc)
|
if (3 < argc)
|
||||||
fail_for_at_directive_too_many_args (argv[0]);
|
fail_for_at_directive_too_many_args (argv[0]);
|
||||||
if (*out_namep)
|
if (*out_namep)
|
||||||
{
|
{
|
||||||
free (*out_namep);
|
free (*out_namep);
|
||||||
xfclose (yyout);
|
xfclose (yyout);
|
||||||
}
|
}
|
||||||
*out_namep = xstrdup (argv[1]);
|
*out_namep = xpath_join (argv[1], 2 < argc ? argv[2] : NULL);
|
||||||
output_file_name_check (out_namep, true);
|
output_file_name_check (out_namep, true);
|
||||||
/* If there were errors, do not generate the output. */
|
/* If there were errors, do not generate the output. */
|
||||||
yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w");
|
yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w");
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user