mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 10:15:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb3bf6493d | ||
|
|
57503e2165 | ||
|
|
b3abe014f2 | ||
|
|
80f3220fea | ||
|
|
fc2040a750 | ||
|
|
d55f240991 | ||
|
|
4f961a706d | ||
|
|
ac203e6c3c | ||
|
|
9141f0b79f | ||
|
|
d57eab87e8 | ||
|
|
bb901beb68 | ||
|
|
fa00c56c17 | ||
|
|
5359c479bc | ||
|
|
20107b77c0 | ||
|
|
5e71eef267 | ||
|
|
472531dc72 | ||
|
|
046f238826 | ||
|
|
9bf06f6963 | ||
|
|
357336d254 | ||
|
|
d4a6c3c58a | ||
|
|
8976e0f567 | ||
|
|
6dca1eb950 | ||
|
|
f8d82ff039 | ||
|
|
9e9e49224f | ||
|
|
8b53f4e022 | ||
|
|
8c87a62308 | ||
|
|
478cb5cf12 | ||
|
|
94f70bd861 | ||
|
|
9b4f0970fe | ||
|
|
869028a66d | ||
|
|
6f92a7f664 | ||
|
|
6a61b6b17e | ||
|
|
a4bf7cdf9e | ||
|
|
9471a5ffe9 | ||
|
|
24c5214ae8 | ||
|
|
2f7097d1b1 | ||
|
|
28369ecb5d | ||
|
|
b92f064e9b | ||
|
|
98f19578aa | ||
|
|
7d9839c4a8 | ||
|
|
ad32ec64c8 | ||
|
|
44cdc0f001 | ||
|
|
ca796220ec | ||
|
|
8a910107b3 | ||
|
|
28d1ca8f48 | ||
|
|
1817b475a6 | ||
|
|
22ca07defa | ||
|
|
dbd6975b5c | ||
|
|
cd726fdc4d | ||
|
|
60ebd8e210 | ||
|
|
3765e3e790 | ||
|
|
c313360deb | ||
|
|
25698b58c0 | ||
|
|
17d34c231b | ||
|
|
af000bab11 | ||
|
|
b2347a3c3e | ||
|
|
008d927f71 | ||
|
|
1650c729d9 | ||
|
|
7bdf7246fb | ||
|
|
583c193ffa | ||
|
|
47b9ada6fa | ||
|
|
dcd5bb26e3 | ||
|
|
cce6c998b6 | ||
|
|
3398b0fa90 | ||
|
|
2bd1d9e20f | ||
|
|
1f2546396e | ||
|
|
809268c1a4 | ||
|
|
10acc148bb | ||
|
|
28f1e1546c | ||
|
|
c53b379784 | ||
|
|
fead28d9e3 | ||
|
|
7e0b50c524 | ||
|
|
8228d96d33 | ||
|
|
a5fc4e3b44 | ||
|
|
3be912e4af | ||
|
|
4b4e532748 | ||
|
|
6e7d8ba6a7 | ||
|
|
c680300a29 | ||
|
|
0cbefb71e8 | ||
|
|
402332c4b6 | ||
|
|
aa244fc5fe | ||
|
|
719395c9cd | ||
|
|
fa9871a2fb | ||
|
|
76597d01f3 | ||
|
|
bc5efb558d | ||
|
|
17e21f6158 | ||
|
|
6ef8513e7c | ||
|
|
3945beb1d2 | ||
|
|
c86b7815fc | ||
|
|
048730c691 | ||
|
|
ec64a0bc7e | ||
|
|
d6fe39cd18 | ||
|
|
d76ea5ce06 | ||
|
|
fdef997432 | ||
|
|
0073b5ea5f | ||
|
|
717be0a0f0 | ||
|
|
c6e4b260e0 | ||
|
|
8b87da8d12 | ||
|
|
41b1f828ae | ||
|
|
4e0de4df8c | ||
|
|
97d6da0c5b | ||
|
|
e31f92495c | ||
|
|
54c5d5d1b4 | ||
|
|
693e69f289 | ||
|
|
5c2c9fcb17 | ||
|
|
071f43d5b7 | ||
|
|
8a4ec5d4e4 | ||
|
|
052215a138 | ||
|
|
15c1b913cf | ||
|
|
83c9051a64 | ||
|
|
7a557ee7fe | ||
|
|
08dd5e9feb | ||
|
|
68cc2631a4 | ||
|
|
b47340982b | ||
|
|
ee35055b49 | ||
|
|
e5cbac98b6 | ||
|
|
d563a01709 | ||
|
|
a428a9fa6c | ||
|
|
2a0185b693 | ||
|
|
ab3621678a | ||
|
|
8631f35bf9 | ||
|
|
c483b6593f | ||
|
|
59cb1f421c | ||
|
|
d9d37a1196 | ||
|
|
c3db1394a1 | ||
|
|
2c20ae9b41 | ||
|
|
0c56c195e0 | ||
|
|
3dd2ae4415 | ||
|
|
d50df39f1a | ||
|
|
2c66acfec0 | ||
|
|
3f320159e3 | ||
|
|
f41e0cf73c | ||
|
|
d6ce0521cf | ||
|
|
cf298ebb7d | ||
|
|
734db67004 | ||
|
|
7d47d51962 | ||
|
|
602d562d6f | ||
|
|
825150b085 | ||
|
|
d4b6c86c7f | ||
|
|
5463291a91 | ||
|
|
6373b90fc8 | ||
|
|
beceb2fa93 | ||
|
|
58302c6079 | ||
|
|
d2a7a28438 | ||
|
|
9e6c5328d3 | ||
|
|
fec13ce2db | ||
|
|
be3cf406af | ||
|
|
126c4622de | ||
|
|
dd64eaf9db | ||
|
|
0b585c49ae | ||
|
|
37c4d0b175 | ||
|
|
56bcccbc51 | ||
|
|
17cc7da519 | ||
|
|
2713e7c4ff | ||
|
|
32e5a91a91 | ||
|
|
5973d763c0 | ||
|
|
4246cd81df | ||
|
|
e69b47cd18 | ||
|
|
8f5aaa0e04 | ||
|
|
b75b055288 | ||
|
|
41e84cddc7 | ||
|
|
5709f94a91 | ||
|
|
bc96b757ca | ||
|
|
1133220416 | ||
|
|
39eb80bdbc | ||
|
|
361004aabe | ||
|
|
032a52be6e | ||
|
|
843ef49bc3 | ||
|
|
5df33278b4 | ||
|
|
d96fff6115 | ||
|
|
be92ad1eb4 | ||
|
|
ff2f02815b | ||
|
|
67dcef357c | ||
|
|
133edcd248 | ||
|
|
4d9ff272cf | ||
|
|
2ca6b71967 | ||
|
|
871c02b327 | ||
|
|
a57e74a5bf | ||
|
|
4971409e39 | ||
|
|
b772baef24 | ||
|
|
406e8c7c02 | ||
|
|
97c4169f23 | ||
|
|
8add45dbd9 | ||
|
|
b3e9c20227 | ||
|
|
b2c381cd25 | ||
|
|
67bff62e31 | ||
|
|
5f45cb05f1 | ||
|
|
b61b0eb9ac | ||
|
|
69277e109a | ||
|
|
f716484627 | ||
|
|
945b917da2 | ||
|
|
1ef407d923 | ||
|
|
576b863e91 | ||
|
|
2274c34e91 | ||
|
|
fccab9bc40 | ||
|
|
488607534a | ||
|
|
4db572dd21 | ||
|
|
8faf075fd7 | ||
|
|
453639dfac | ||
|
|
4901ee115b | ||
|
|
6c7b2dfe51 | ||
|
|
a3e201de02 | ||
|
|
5e95bb6251 | ||
|
|
569125a6bf | ||
|
|
8ac28ba1f0 | ||
|
|
3ca713abd0 | ||
|
|
8c18e3f18c | ||
|
|
1e5e274972 | ||
|
|
b1679f8346 | ||
|
|
9861bcc540 | ||
|
|
d94d83e10b | ||
|
|
2f6e377953 | ||
|
|
32dff87c1d | ||
|
|
19da501e06 | ||
|
|
5e4133175d | ||
|
|
0b093ac4d9 | ||
|
|
69b22b49d4 | ||
|
|
ec11f08fb3 | ||
|
|
67444a6f0d | ||
|
|
4eed3a0f0c | ||
|
|
84a6621c78 | ||
|
|
06a273625b | ||
|
|
d120a07e6b | ||
|
|
741a58a504 | ||
|
|
d80815ac23 | ||
|
|
0b417c3479 | ||
|
|
f6fd9be688 | ||
|
|
77dbdd0d59 | ||
|
|
f8db8fe4d7 | ||
|
|
375eb71489 | ||
|
|
d3a86f7b20 | ||
|
|
29c75ef27f | ||
|
|
628012d830 | ||
|
|
f788ba2ab6 | ||
|
|
53526f31df | ||
|
|
e63811dd86 | ||
|
|
47262c36bb | ||
|
|
1e452b1553 | ||
|
|
ed796869bb | ||
|
|
12c412f6bb | ||
|
|
2663035ea5 | ||
|
|
de7c66ab41 | ||
|
|
feeacc2d57 | ||
|
|
cc10f9ab24 | ||
|
|
a9499e6ea2 | ||
|
|
09a4bfdab4 | ||
|
|
7d701f4378 | ||
|
|
378963b139 | ||
|
|
2dd882bce5 | ||
|
|
989503b1ba | ||
|
|
61c2c40092 | ||
|
|
3953c61362 | ||
|
|
39e584c018 | ||
|
|
611eaffd28 | ||
|
|
3f4ad2cd24 | ||
|
|
989a7aa865 | ||
|
|
95cbd56882 | ||
|
|
92124d27c1 | ||
|
|
6d81b91ae0 | ||
|
|
9145bd0b61 | ||
|
|
d7cf3f5b18 | ||
|
|
f49598a1e1 | ||
|
|
72d4ae5306 | ||
|
|
996abe62d7 | ||
|
|
0420362ee8 | ||
|
|
6f47eea7ab | ||
|
|
99bfdc09cb | ||
|
|
52f21717f7 | ||
|
|
cbdc22af10 | ||
|
|
220c593a79 | ||
|
|
e29ac453d0 | ||
|
|
44a56b20ac | ||
|
|
f99956b550 | ||
|
|
1f02348d6c | ||
|
|
421ff03018 | ||
|
|
5d3468e0d1 | ||
|
|
40a8dddde1 | ||
|
|
9bdefd7984 | ||
|
|
d233a2e314 | ||
|
|
d90023af5f | ||
|
|
964c6508b1 | ||
|
|
4e3c6f59cc | ||
|
|
801582b410 | ||
|
|
6d35340556 | ||
|
|
1161649446 | ||
|
|
13577a809e | ||
|
|
afc219a765 | ||
|
|
21aa4b2713 | ||
|
|
63f4dca78f | ||
|
|
0984f70e08 | ||
|
|
f26bd45da3 | ||
|
|
a3adc1701b | ||
|
|
7ab275214b | ||
|
|
0428c429a1 | ||
|
|
14fb2cc820 | ||
|
|
faf033957c | ||
|
|
0555e25a41 | ||
|
|
cde8c0a0e6 | ||
|
|
5b525e86a5 | ||
|
|
df77a98edf | ||
|
|
c23fa0fc97 | ||
|
|
08c0571613 | ||
|
|
f2b210a901 | ||
|
|
66ac4acc6c | ||
|
|
cd0f25df5f | ||
|
|
0f46038589 | ||
|
|
1105cf841b | ||
|
|
a298a6d82b | ||
|
|
5f33acefd1 | ||
|
|
849ba01b8b | ||
|
|
29c9cb3188 | ||
|
|
ec4d49e129 | ||
|
|
d84b245c63 | ||
|
|
73797b2552 | ||
|
|
dfef525920 | ||
|
|
7f017ae1c9 | ||
|
|
65126716d7 | ||
|
|
1dcd6068dd | ||
|
|
02f16dc799 | ||
|
|
aa21c457f2 | ||
|
|
9f26e6d6b3 | ||
|
|
8d3e782e05 | ||
|
|
1c671bad33 | ||
|
|
88cd9570b6 | ||
|
|
c423ad17e7 | ||
|
|
9114b267a8 | ||
|
|
70c3f3ade5 | ||
|
|
1934304acf | ||
|
|
c8e57e8159 | ||
|
|
1e49f5e1e6 | ||
|
|
49aae94bed | ||
|
|
e191bf7b9f | ||
|
|
f520e150eb | ||
|
|
75db37c564 | ||
|
|
886b503e4b | ||
|
|
a2f0444c6e | ||
|
|
66100b640f | ||
|
|
de5207244b | ||
|
|
cae8132690 | ||
|
|
a1a847bfb5 | ||
|
|
3ac95de01a | ||
|
|
da7af36a13 | ||
|
|
3f25104caf | ||
|
|
6b1933d992 | ||
|
|
5163803a63 | ||
|
|
fee7c78a83 | ||
|
|
8fc544b03c | ||
|
|
d62d5c4b33 | ||
|
|
ab3eaff7c4 | ||
|
|
85e83ea968 | ||
|
|
0269c6fb03 | ||
|
|
23e536af49 | ||
|
|
cd56929097 | ||
|
|
7aa38561f7 | ||
|
|
22a00cfbf2 | ||
|
|
8c06cb9130 | ||
|
|
b5233ba323 | ||
|
|
013720f0e7 | ||
|
|
365b4d95a4 | ||
|
|
5bb44cca81 | ||
|
|
15f9f8c853 | ||
|
|
04676a5085 | ||
|
|
cf44351dd7 | ||
|
|
614e0bbe23 | ||
|
|
3eb7b0ee78 | ||
|
|
02a1600994 | ||
|
|
f6868c5a77 | ||
|
|
f92f2f8afe | ||
|
|
0cc04eaa2a | ||
|
|
57290d63fd | ||
|
|
33b246a624 | ||
|
|
dc5ce5989f | ||
|
|
7ea108fa67 | ||
|
|
386cf25088 | ||
|
|
a514c51e55 | ||
|
|
91b8f3f171 | ||
|
|
8f5d475079 | ||
|
|
f5a4e279bc | ||
|
|
571447afe8 | ||
|
|
9260e5ca4f | ||
|
|
971e72514f | ||
|
|
0ee5ac5367 | ||
|
|
935d119c82 | ||
|
|
01fe32ee53 | ||
|
|
19ea6b1405 | ||
|
|
a4d33cdf48 | ||
|
|
a992a3cb9e | ||
|
|
95d688957f | ||
|
|
a9b350fb3a | ||
|
|
afe7dfd3b9 | ||
|
|
6b6c3de2ae | ||
|
|
1b70f687fa | ||
|
|
520d474ec6 | ||
|
|
deec7ca65c | ||
|
|
dff7454371 | ||
|
|
e50eedf3c5 | ||
|
|
341776b03b | ||
|
|
79f7afb125 | ||
|
|
2f3d9717ee | ||
|
|
9ad7524659 | ||
|
|
4ec413da32 | ||
|
|
61d53e606d | ||
|
|
d67b7daa1d | ||
|
|
2ab70cf0c6 | ||
|
|
99664706e2 | ||
|
|
a745041b7d | ||
|
|
0dd97f7c87 | ||
|
|
69a823c72d | ||
|
|
0f193d2d21 | ||
|
|
9832fdd6ef | ||
|
|
507c679b9b | ||
|
|
0b42cf8a36 | ||
|
|
10175e4a65 | ||
|
|
18831f985c | ||
|
|
6d4e6bf118 | ||
|
|
a8558bc5a6 | ||
|
|
bbf37f2534 | ||
|
|
d332ff3c77 | ||
|
|
eb92ec3dc6 | ||
|
|
dee8fbbc1e | ||
|
|
75303c61d8 | ||
|
|
af99826ef4 | ||
|
|
af1c6f973a | ||
|
|
b5cd777ad6 | ||
|
|
ae91c3cce3 | ||
|
|
5de4e79fc8 | ||
|
|
4d34b06fb3 | ||
|
|
22a413ce9f | ||
|
|
01855ca328 | ||
|
|
225bc5836a | ||
|
|
941cdf921d | ||
|
|
58ae95670b | ||
|
|
4e19ab9fcd | ||
|
|
6cb612e7e3 | ||
|
|
35add841ee | ||
|
|
f6e38d7ac9 | ||
|
|
855fbf1c11 | ||
|
|
e5ec21215e | ||
|
|
91bbf4219d | ||
|
|
f4c1586454 | ||
|
|
9a71d9d1c6 | ||
|
|
bb0310a353 | ||
|
|
f8408562f8 | ||
|
|
8eac78f8ef | ||
|
|
d57751d2fb | ||
|
|
e062b9f70d | ||
|
|
c837141832 | ||
|
|
a415a78d71 | ||
|
|
5255b919ae | ||
|
|
b12f9c76e2 | ||
|
|
575b814119 | ||
|
|
661bbacfc7 | ||
|
|
d04962f788 | ||
|
|
ec8142391a | ||
|
|
59bec5fade | ||
|
|
5230e610fc | ||
|
|
b81419a9fd | ||
|
|
2b9ee006d8 | ||
|
|
609b40f1a1 | ||
|
|
1e76448ced | ||
|
|
967a59d2c0 | ||
|
|
fbf94ac900 | ||
|
|
a11c144609 | ||
|
|
4848092bf8 | ||
|
|
948f3decb4 | ||
|
|
7d6747cec9 | ||
|
|
420e7b03ec | ||
|
|
b31015a927 | ||
|
|
bd55d43333 | ||
|
|
98020cedf7 | ||
|
|
cbf213915c | ||
|
|
93371999ee | ||
|
|
6289d673a0 | ||
|
|
0adda755a2 | ||
|
|
0782ed3274 | ||
|
|
d7ec136ffb | ||
|
|
dbdf2878ab | ||
|
|
8654fca058 | ||
|
|
05a8097779 | ||
|
|
c06ec1f132 | ||
|
|
fb83319d9c | ||
|
|
e42a7a1862 | ||
|
|
8cbf3ce22c | ||
|
|
1997093e21 | ||
|
|
f23b879ff5 | ||
|
|
8b2d233283 | ||
|
|
40fc688765 | ||
|
|
30f61b0549 | ||
|
|
ad7d8af6d1 | ||
|
|
f293345aa8 | ||
|
|
e18ad5a96b | ||
|
|
dd232b95b7 | ||
|
|
51861998c7 | ||
|
|
e346210c03 | ||
|
|
0d44f83fcc | ||
|
|
40b5f89ee0 | ||
|
|
eed9550993 | ||
|
|
cf96d1b0af | ||
|
|
3d25b52a10 | ||
|
|
56c00ed1ea | ||
|
|
513d2f723f | ||
|
|
48429252c1 | ||
|
|
d459a5b8e6 | ||
|
|
9566232422 | ||
|
|
dc654a925c | ||
|
|
76366e8e5c | ||
|
|
781d2b02de | ||
|
|
8b5fc2143f | ||
|
|
5670677cb6 | ||
|
|
32b9dcecc7 | ||
|
|
ac12b725ea | ||
|
|
e1783bc686 | ||
|
|
c4f143eb96 | ||
|
|
94054924a9 | ||
|
|
c639611002 | ||
|
|
3075d96d44 | ||
|
|
7fec997ecf | ||
|
|
7355a35e4b | ||
|
|
e585377e68 | ||
|
|
9cd7bd4d5f | ||
|
|
a108d84f88 | ||
|
|
1e83dd2229 | ||
|
|
d02ca923e2 | ||
|
|
f82f7eb1d8 | ||
|
|
0d472b29ec | ||
|
|
21a7fa8063 | ||
|
|
83463dfbee | ||
|
|
c3c50c0030 | ||
|
|
e85ab7ac9b | ||
|
|
a11463a02f |
@@ -1,8 +1,6 @@
|
||||
*.eps
|
||||
*.log
|
||||
*.o
|
||||
*.pdf
|
||||
*.png
|
||||
*.stamp
|
||||
*.trs
|
||||
*~
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
3.3.1
|
||||
3.4.92
|
||||
|
||||
+235
-130
@@ -1,8 +1,7 @@
|
||||
# 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.
|
||||
|
||||
# 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:
|
||||
@@ -11,8 +10,65 @@ env:
|
||||
# See https://github.com/nemequ/icc-travis.
|
||||
secure: B3manbbi0anCAGDJTdAa9TlodzRHeiYD87FKmFzS877dPm8Cm0BDvtUhKBUpBvP8+nbHOWFGrgDmLugSZjTGU+mAxtuQpamUFHvinu0BIk3qtjlqouwvbtIqUu8iiZ3Uqu+xKeAANKRy0YVZGLlEb9F3N119tJ/Fxp1p9bXL1qph+CZ25OFbUgZ2s4F+/AyHMUxJlNXKFe3Qean65hC6edhU3zoaKzr/g/wtbhRmcyWbkOa1dJqzr2yKotcPvrnApGhDzgMKFtohg/t7xfMADDVv6sGS5XNpt25Z+MUCmLg4Z9eD7u109jvRV1eu/jgVafqsthWEhXbuMiFgFhKBKGCNZ0dACIfKZSkFZI6FdM7ovJ6aNhSlxZ2169Ybd22rN1UTHeCQWySPcVVOg5taLVpqe+E8Xhnv4hBO5NrzElWwCMLxIdPUSwVStYvtDr8ZytHWzfot50vSnFKIFpTOr9hP4+AJMVmmqJfaJo2MLBft/q2xkztrMv3lQSj3m4+ma9kPDwXIu9uCutjlnhc00jNx9qegi5VfpAjxcG1R+pX4T20az6ByHk/7LPQsANkT31RJq/jAeD9LEuMOy8miha83q4QuvbFaqPK3PY0el/O1LZaXqLsV2aQ0uqH8YX0l4r5NzHdhb+3lYgvpMBO5ytr/EWJiEyNYV518050IUDE=
|
||||
|
||||
matrix:
|
||||
# Run in two steps:
|
||||
# 1. Build the tarball
|
||||
# On a modern distro, with all the needed dependencies, including the whole git history.
|
||||
# 2. Check it on various environments.
|
||||
# Less dependencies, and little git content (we would like to have none, but it's not
|
||||
# an option on Travis).
|
||||
stages:
|
||||
- dist
|
||||
- check
|
||||
|
||||
# The 'check' jobs do not need the repo at all, only the 'dist'
|
||||
# does. Let's save time, bandwith, energy, and polar bears.
|
||||
git:
|
||||
clone: false
|
||||
|
||||
# matrix.include and jobs.include are aliases
|
||||
# (https://docs.travis-ci.com/user/conditional-builds-stages-jobs/).
|
||||
jobs:
|
||||
include:
|
||||
- stage: dist
|
||||
name: "Make dist"
|
||||
git:
|
||||
clone: true
|
||||
dist: bionic
|
||||
script:
|
||||
- sudo apt-get install -qq autoconf automake autopoint flex gettext graphviz help2man m4 texinfo
|
||||
- autoconf --version
|
||||
- automake --version
|
||||
- autopoint --version
|
||||
- dot -V
|
||||
- gettext --version
|
||||
- help2man --version
|
||||
- makeinfo --version
|
||||
- m4 --version
|
||||
|
||||
# Travis makes a shallow clone, but we need it in full to build the ChangeLog and apply the fixes in git-log-fix.
|
||||
- git fetch --unshallow || true
|
||||
- git submodule update --init --recursive
|
||||
|
||||
- ./bootstrap
|
||||
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
||||
- make -j2
|
||||
- make -j2 dist
|
||||
# Can help understanding why we get "dirty" tarballs.
|
||||
- git status
|
||||
- dist=$(echo bison*.xz)
|
||||
|
||||
# Unfortunately we cannot deterministically know the name of the tarball without the full
|
||||
# git history (because git describe --abbrev=4 may use more than 4 characters if there are
|
||||
# conflicts).
|
||||
#
|
||||
# So for the sake of the 'check' jobs (that don't even have the repo at all), also expose this
|
||||
# tarball on a name that only depends on the Travis build number.
|
||||
#
|
||||
# Without -b -, exit status is always 0.
|
||||
#
|
||||
# If we rerun a job that was already uploaded, 'ln -s' will fail: remove beforehand.
|
||||
- sftp -b - [email protected] <<< "put $dist"$'\n'"-rm bison-$TRAVIS_BUILD_NUMBER.tar.xz"$'\n'"ln -s $dist bison-$TRAVIS_BUILD_NUMBER.tar.xz"
|
||||
|
||||
## ------- ##
|
||||
## First. ##
|
||||
## ------- ##
|
||||
@@ -20,154 +76,167 @@ matrix:
|
||||
# Start with three completely different environments, to get
|
||||
# errors asap.
|
||||
|
||||
- name: "GCC 7 -O3"
|
||||
- name: "GCC 9 -O3"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
packages: g++-9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
|
||||
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
|
||||
|
||||
# ASAN is time consuming, and we timeout the 50min granted by
|
||||
# Travis if we run all the tests in on go. Run in two parts.
|
||||
- name: "Clang 7 libc++ and ASAN part 1"
|
||||
# Travis if we run all the tests in one go. Run in two parts.
|
||||
- name: "Clang 9 libc++ and ASAN part 1"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
dist: bionic
|
||||
addons: &clang9
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-xenial-7
|
||||
- ubuntu-toolchain-r-test
|
||||
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
packages:
|
||||
- clang-7
|
||||
- libc++-7-dev
|
||||
- libc++abi-7-dev
|
||||
- clang-9
|
||||
- libc++-9-dev
|
||||
- libc++abi-9-dev
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- MATRIX_EVAL="PART=1 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
|
||||
- MATRIX_EVAL="CC='clang-9 -fsanitize=address' CXX='clang++-9 -fsanitize=address -stdlib=libc++'"
|
||||
- PART=1
|
||||
|
||||
- name: "Clang 7 libc++ and ASAN part 2"
|
||||
- name: "Clang 9 libc++ and ASAN part 2"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-xenial-7
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang-7
|
||||
- libc++-7-dev
|
||||
- libc++abi-7-dev
|
||||
dist: bionic
|
||||
addons: *clang9
|
||||
env:
|
||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||
- MATRIX_EVAL="PART=2 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
|
||||
- MATRIX_EVAL="CC='clang-9 -fsanitize=address' CXX='clang++-9 -fsanitize=address -stdlib=libc++'"
|
||||
- PART=2
|
||||
|
||||
- name: "ICC"
|
||||
os: linux
|
||||
dist: xenial
|
||||
env:
|
||||
# ICC's warnings are often very wrong (e.g., it thinks foo ?
|
||||
# "bar" : "baz" is char* instead of const char*), so don't try
|
||||
# to work around the, and obviously, don't die on them.
|
||||
- MATRIX_EVAL="CC=icc && CXX=icpc"
|
||||
- MAKE_ARGS='WERROR_CFLAGS= WERROR_CXXFLAGS='
|
||||
# Currently no longer works (https://github.com/nemequ/icc-travis/issues/15).
|
||||
# - name: "ICC"
|
||||
# stage: check
|
||||
# # We need the build-aux/install-icc.sh script.
|
||||
# git:
|
||||
# clone: true
|
||||
# submodules: false
|
||||
# depth: 1
|
||||
# os: linux
|
||||
# dist: xenial
|
||||
# env:
|
||||
# # ICC's warnings are often very wrong (e.g., it thinks foo ?
|
||||
# # "bar" : "baz" is char* instead of const char*), so don't try
|
||||
# # to work around the, and obviously, don't die on them.
|
||||
# - MATRIX_EVAL="CC=icc && CXX=icpc"
|
||||
# - MAKE_ARGS='WERROR_CFLAGS= WERROR_CXXFLAGS='
|
||||
|
||||
|
||||
## ----- ##
|
||||
## GCC. ##
|
||||
## ----- ##
|
||||
|
||||
#- name: "GCC 8 with sanitizers"
|
||||
# os: linux
|
||||
# dist: xenial
|
||||
# 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' (on trusty)
|
||||
# # /usr/bin/ld: unrecognized option '--push-state--no-as-needed' (on xenial)
|
||||
# #
|
||||
# # https://stackoverflow.com/questions/50024731/ suggests using the gold linker.
|
||||
# - MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
|
||||
- name: "GCC 8 with sanitizers part 1"
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages: g++-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
|
||||
- CONFIGUREFLAGS='CFLAGS=-O1 CXXFLAGS=-O1'
|
||||
- PART=1
|
||||
|
||||
- name: "GCC 8"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages: g++-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
|
||||
- name: "GCC 7"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages: g++-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
|
||||
- name: "GCC 6"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-6
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
||||
|
||||
- name: "GCC 5"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-5
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-5
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
||||
|
||||
- name: "GCC 4.9"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
|
||||
|
||||
- name: "GCC 4.8"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
|
||||
|
||||
- name: "GCC 4.7"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
|
||||
|
||||
- name: "GCC 4.6"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-4.6 && CXX=g++-4.6"
|
||||
|
||||
@@ -175,7 +244,35 @@ matrix:
|
||||
## Clang. ##
|
||||
## ------- ##
|
||||
|
||||
- name: "Clang 6 -O3 and libc++"
|
||||
- name: "Clang 8 -O3"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
- libc++-8-dev
|
||||
- libc++abi-8-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-8 && CXX='clang++-8 -stdlib=libc++'"
|
||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||
|
||||
- name: "Clang 7"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
- libc++-7-dev
|
||||
- libc++abi-7-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-7 && CXX='clang++-7 -stdlib=libc++'"
|
||||
|
||||
- name: "Clang 6 and libc++"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
@@ -188,15 +285,14 @@ matrix:
|
||||
- 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"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-xenial-5.0
|
||||
sources: llvm-toolchain-xenial-5.0
|
||||
packages:
|
||||
- clang-5.0
|
||||
- libc++-dev
|
||||
@@ -204,30 +300,29 @@ matrix:
|
||||
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
|
||||
|
||||
- name: "Clang 4"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-xenial-4.0
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources: llvm-toolchain-xenial-4.0
|
||||
packages: clang-4.0
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
|
||||
|
||||
- name: "Clang 3.9"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-xenial-3.9
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources: llvm-toolchain-xenial-3.9
|
||||
packages: clang-3.9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
|
||||
|
||||
- name: "Clang 3.8"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
@@ -235,12 +330,12 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
packages:
|
||||
- clang-3.8
|
||||
packages: clang-3.8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
||||
|
||||
- name: "CLang 3.7"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
@@ -248,12 +343,12 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
packages:
|
||||
- clang-3.7
|
||||
packages: clang-3.7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
|
||||
|
||||
- name: "Clang 3.6"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
@@ -261,12 +356,12 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
packages:
|
||||
- clang-3.6
|
||||
packages: clang-3.6
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
|
||||
|
||||
- name: "Clang 3.5"
|
||||
stage: check
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
@@ -274,79 +369,89 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
packages:
|
||||
- clang-3.5
|
||||
packages: clang-3.5
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
|
||||
|
||||
- name: "Clang 3.4"
|
||||
stage: check
|
||||
os: linux
|
||||
# Not available on Xenial.
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
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"
|
||||
stage: check
|
||||
os: linux
|
||||
# Not available on Xenial.
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
packages: clang-3.3
|
||||
env:
|
||||
# See comment for 3.4.
|
||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
||||
|
||||
## From https://docs.gitlab.com/ce/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor.
|
||||
## Applies to Travis too. Applied to all the 'script's (of all the jobs).
|
||||
before_script:
|
||||
- 'which ssh-agent || ( sudo apt-get install openssh-client -y )'
|
||||
- eval "$(ssh-agent -s)"
|
||||
# $SSH_PRIVATE_KEY is multiline. Use $'...' to register its value: $'-----BEGIN OPENSSH PRIVATE KEY-----\nXXXXX...\n...==\n-----END OPENSSH PRIVATE KEY-----'.
|
||||
- echo "$SSH_PRIVATE_KEY" >/tmp/key.id_rsa
|
||||
- chmod 600 /tmp/key.id_rsa
|
||||
- ssh-add /tmp/key.id_rsa </dev/null
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo '|1|bpc51UGxoDZjCPiwRlCStW32trI=|rfh6mLoLZv/vAvOVrpZXI1hTLxg= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIR+ckMoJTNXHvAQLHWSfrRnrNJGW2ZR6kr5pBVDGCkz1v1RcQ5rleq0NAt9kS3v4hgnuLiEVnK7KDRzcEH3ikc=' >>~/.ssh/known_hosts
|
||||
- chmod 600 ~/.ssh/known_hosts
|
||||
|
||||
before_install:
|
||||
# Applies only to the jobs that don't have a 'script', i.e., applies to all the 'check' jobs, but not the 'dist' one.
|
||||
script:
|
||||
- eval "$MATRIX_EVAL"
|
||||
- env
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq autoconf automake autopoint doxygen flex gettext graphviz help2man m4 texinfo
|
||||
# Beware not too leak $SSH_PRIVATE_KEY.
|
||||
# - env
|
||||
- sudo apt-get install -qq doxygen flex m4
|
||||
# Install and activate ICC.
|
||||
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
|
||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||
# Install and activate dmd
|
||||
# Install and activate dmd.
|
||||
- mkdir -p ~/dlang && wget https://dlang.org/install.sh -O ~/dlang/install.sh
|
||||
- source $(source ~/dlang/install.sh dmd -a)
|
||||
- autoconf --version
|
||||
- automake --version
|
||||
- autopoint --version
|
||||
|
||||
- $CC --version
|
||||
- $CXX --version
|
||||
- dmd --version
|
||||
- doxygen --version
|
||||
- flex --version
|
||||
- gettext --version
|
||||
- dot -V
|
||||
- help2man --version
|
||||
- ld --version
|
||||
- m4 --version
|
||||
- makeinfo --version
|
||||
|
||||
script:
|
||||
- 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
|
||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||
# Unset this variable, otherwise, Java programs' stderr is cluttered
|
||||
# with `Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m`, which makes
|
||||
# the test suite fail.
|
||||
- unset _JAVA_OPTIONS
|
||||
- ./bootstrap
|
||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
|
||||
|
||||
# Fail fast from now on.
|
||||
- set -e
|
||||
- sftp [email protected]:bison-$TRAVIS_BUILD_NUMBER.tar.xz
|
||||
- tar xf bison-$TRAVIS_BUILD_NUMBER.tar.xz
|
||||
- dir=$(tar tf bison-$TRAVIS_BUILD_NUMBER.tar.xz | sed 1q)
|
||||
- cd $dir
|
||||
- mkdir _build
|
||||
- cd _build
|
||||
- ../configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
|
||||
- make -j2 $MAKE_ARGS
|
||||
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat test-suite.log && cat tests/testsuite.log && false; }; fi
|
||||
- if test ${PART-1} = 1; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||
- if test ${PART-2} = 2; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||
|
||||
after_script:
|
||||
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
|
||||
- uninstall_intel_software || true
|
||||
|
||||
+19
-5
@@ -18,7 +18,7 @@
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = po runtime-po .
|
||||
SUBDIRS = po runtime-po gnulib-po .
|
||||
|
||||
# Files installed for use by Automake.
|
||||
aclocaldir = @aclocaldir@
|
||||
@@ -29,12 +29,12 @@ EXTRA_DIST = .prev-version .version cfg.mk PACKAGING \
|
||||
|
||||
dist_doc_DATA = AUTHORS COPYING NEWS README THANKS TODO
|
||||
|
||||
# Let generated files (e.g., from exampkles/) depend on this variable,
|
||||
# Let generated files (e.g., from examples/) depend on this variable,
|
||||
# to make sure they are regenerated when there are changes in Bison.
|
||||
#
|
||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||
# in srcdir, including during distcheck, which is forbidden.
|
||||
dependencies = $(BISON_IN) $(dist_skeletons_DATA)
|
||||
dependencies = $(BISON_IN) $(src_bison_SOURCES) $(dist_skeletons_DATA)
|
||||
|
||||
## Running the bison from this tarball. To generate our own parser,
|
||||
## but also to run the tests. Of course, you ought to keep a sane
|
||||
@@ -42,7 +42,8 @@ dependencies = $(BISON_IN) $(dist_skeletons_DATA)
|
||||
BISON = $(top_builddir)/tests/bison
|
||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||
YACC = $(BISON) -o y.tab.c
|
||||
AM_YFLAGS = -d -v -Werror -Wall -Wno-yacc --report=all
|
||||
AM_YFLAGS_WITH_LINES = --defines -Werror -Wall --report=all
|
||||
AM_YFLAGS = $(AM_YFLAGS_WITH_LINES) --no-lines
|
||||
|
||||
# Initialization before completion by local.mk's.
|
||||
AM_CFLAGS = $(WARN_CFLAGS)
|
||||
@@ -87,9 +88,22 @@ clean-local:
|
||||
BUILT_SOURCES += $(top_srcdir)/.version
|
||||
$(top_srcdir)/.version: configure
|
||||
echo $(VERSION) > $@-t && mv $@-t $@
|
||||
dist-hook: gen-ChangeLog
|
||||
dist-hook: gen-ChangeLog gen-synclines
|
||||
echo $(VERSION) > $(distdir)/.tarball-version
|
||||
|
||||
# When generating a release, include the #lines in Bison's parser. Do it
|
||||
# only if needed. In particular, distcheck runs dist with read-only
|
||||
# sources, so don't try to update src/parse-gram.c: we don't have the
|
||||
# permissions.
|
||||
.PHONY: gen-synclines
|
||||
gen-synclines:
|
||||
cd $(distdir) && \
|
||||
if ! grep '#line' src/parse-gram.c >/dev/null 2>&1; then \
|
||||
$(abs_top_builddir)/tests/bison \
|
||||
$(AM_YFLAGS_WITH_LINES) src/parse-gram.y \
|
||||
-o src/parse-gram.c; \
|
||||
fi
|
||||
|
||||
.PHONY: update-b4-copyright update-package-copyright-year
|
||||
update-b4-copyright:
|
||||
$(AM_V_GEN)find $(srcdir)/data -type f \
|
||||
|
||||
@@ -1,5 +1,375 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.5 (2019-12-11) [stable]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
Lone carriage-return characters (aka \r or ^M) in the grammar files are no
|
||||
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||
particular their locations.
|
||||
|
||||
In C++, line numbers and columns are now represented as 'int' not
|
||||
'unsigned', so that integer overflow on positions is easily checkable via
|
||||
'gcc -fsanitize=undefined' and the like. This affects the API for
|
||||
positions. The default position and location classes now expose
|
||||
'counter_type' (int), used to define line and column numbers.
|
||||
|
||||
** Deprecated features
|
||||
|
||||
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
|
||||
It is deprecated and its support will be removed eventually.
|
||||
|
||||
** New features
|
||||
|
||||
*** Lookahead correction in C++
|
||||
|
||||
Contributed by Adrian Vogelsgesang.
|
||||
|
||||
The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
|
||||
%define variable parse.lac.
|
||||
|
||||
*** Variable api.token.raw: Optimized token numbers (all skeletons)
|
||||
|
||||
In the generated parsers, tokens have two numbers: the "external" token
|
||||
number as returned by yylex (which starts at 257), and the "internal"
|
||||
symbol number (which starts at 3). Each time yylex is called, a table
|
||||
lookup maps the external token number to the internal symbol number.
|
||||
|
||||
When the %define variable api.token.raw is set, tokens are assigned their
|
||||
internal number, which saves one table lookup per token, and also saves
|
||||
the generation of the mapping table.
|
||||
|
||||
The gain is typically moderate, but in extreme cases (very simple user
|
||||
actions), a 10% improvement can be observed.
|
||||
|
||||
*** Generated parsers use better types for states
|
||||
|
||||
Stacks now use the best integral type for state numbers, instead of always
|
||||
using 15 bits. As a result "small" parsers now have a smaller memory
|
||||
footprint (they use 8 bits), and there is support for large automata (16
|
||||
bits), and extra large (using int, i.e., typically 31 bits).
|
||||
|
||||
*** Generated parsers prefer signed integer types
|
||||
|
||||
Bison skeletons now prefer signed to unsigned integer types when either
|
||||
will do, as the signed types are less error-prone and allow for better
|
||||
checking with 'gcc -fsanitize=undefined'. Also, the types chosen are now
|
||||
portable to unusual machines where char, short and int are all the same
|
||||
width. On non-GNU platforms this may entail including <limits.h> and (if
|
||||
available) <stdint.h> to define integer types and constants.
|
||||
|
||||
*** A skeleton for the D programming language
|
||||
|
||||
For the last few releases, Bison has shipped a stealth experimental
|
||||
skeleton: lalr1.d. It was first contributed by Oliver Mangold, based on
|
||||
Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
|
||||
H. S. Teoh.
|
||||
|
||||
However, because nobody has committed to improving, testing, and
|
||||
documenting this skeleton, it is not clear that it will be supported in
|
||||
the future.
|
||||
|
||||
The lalr1.d skeleton *is functional*, and works well, as demonstrated in
|
||||
examples/d/calc.d. Please try it, enjoy it, and... commit to support it.
|
||||
|
||||
*** Debug traces in Java
|
||||
|
||||
The Java backend no longer emits code and data for parser tracing if the
|
||||
%define variable parse.trace is not defined.
|
||||
|
||||
** Diagnostics
|
||||
|
||||
*** New diagnostic: -Wdangling-alias
|
||||
|
||||
String literals, which allow for better error messages, are (too)
|
||||
liberally accepted by Bison, which might result in silent errors. For
|
||||
instance
|
||||
|
||||
%type <exVal> cond "condition"
|
||||
|
||||
does not define "condition" as a string alias to 'cond' (nonterminal
|
||||
symbols do not have string aliases). It is rather equivalent to
|
||||
|
||||
%nterm <exVal> cond
|
||||
%token <exVal> "condition"
|
||||
|
||||
i.e., it gives the type 'exVal' to the "condition" token, which was
|
||||
clearly not the intention.
|
||||
|
||||
Also, because string aliases need not be defined, typos such as "baz"
|
||||
instead of "bar" will be not reported.
|
||||
|
||||
The option -Wdangling-alias catches these situations. On
|
||||
|
||||
%token BAR "bar"
|
||||
%type <ival> foo "foo"
|
||||
%%
|
||||
foo: "baz" {}
|
||||
|
||||
bison -Wdangling-alias reports
|
||||
|
||||
warning: string literal not attached to a symbol
|
||||
| %type <ival> foo "foo"
|
||||
| ^~~~~
|
||||
warning: string literal not attached to a symbol
|
||||
| foo: "baz" {}
|
||||
| ^~~~~
|
||||
|
||||
The -Wall option does not (yet?) include -Wdangling-alias.
|
||||
|
||||
*** Better POSIX Yacc compatibility diagnostics
|
||||
|
||||
POSIX Yacc restricts %type to nonterminals. This is now diagnosed by
|
||||
-Wyacc.
|
||||
|
||||
%token TOKEN1
|
||||
%type <ival> TOKEN1 TOKEN2 't'
|
||||
%token TOKEN2
|
||||
%%
|
||||
expr:
|
||||
|
||||
gives with -Wyacc
|
||||
|
||||
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~~~~
|
||||
input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~
|
||||
input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~~~~
|
||||
|
||||
*** Diagnostics with insertion
|
||||
|
||||
The diagnostics now display the suggestion below the underlined source.
|
||||
Replacement for undeclared symbols are now also suggested.
|
||||
|
||||
$ cat /tmp/foo.y
|
||||
%%
|
||||
list: lis '.' |
|
||||
|
||||
$ bison -Wall foo.y
|
||||
foo.y:2.7-9: error: symbol 'lis' is used, but is not defined as a token and has no rules; did you mean 'list'?
|
||||
2 | list: lis '.' |
|
||||
| ^~~
|
||||
| list
|
||||
foo.y:2.16: warning: empty rule without %empty [-Wempty-rule]
|
||||
2 | list: lis '.' |
|
||||
| ^
|
||||
| %empty
|
||||
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||
|
||||
*** Diagnostics about long lines
|
||||
|
||||
Quoted sources may now be truncated to fit the screen. For instance, on a
|
||||
30-column wide terminal:
|
||||
|
||||
$ cat foo.y
|
||||
%token FOO FOO FOO
|
||||
%%
|
||||
exp: FOO
|
||||
$ bison foo.y
|
||||
foo.y:1.34-36: warning: symbol FOO redeclared [-Wother]
|
||||
1 | … FOO …
|
||||
| ^~~
|
||||
foo.y:1.8-10: previous declaration
|
||||
1 | %token FOO …
|
||||
| ^~~
|
||||
foo.y:1.62-64: warning: symbol FOO redeclared [-Wother]
|
||||
1 | … FOO
|
||||
| ^~~
|
||||
foo.y:1.8-10: previous declaration
|
||||
1 | %token FOO …
|
||||
| ^~~
|
||||
|
||||
** Changes
|
||||
|
||||
*** Debugging glr.c and glr.cc
|
||||
|
||||
The glr.c skeleton always had asserts to check its own behavior (not the
|
||||
user's). These assertions are now under the control of the parse.assert
|
||||
%define variable (disabled by default).
|
||||
|
||||
*** Clean up
|
||||
|
||||
Several new compiler warnings in the generated output have been avoided.
|
||||
Some unused features are no longer emitted. Cleaner generated code in
|
||||
general.
|
||||
|
||||
** Bug Fixes
|
||||
|
||||
Portability issues in the test suite.
|
||||
|
||||
In theory, parsers using %nonassoc could crash when reporting verbose
|
||||
error messages. This unlikely bug has been fixed.
|
||||
|
||||
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||
|
||||
* Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
In some cases, when warnings are disabled, bison could emit tons of white
|
||||
spaces as diagnostics.
|
||||
|
||||
When running out of memory, bison could crash (found by fuzzing).
|
||||
|
||||
When defining twice the EOF token, bison would crash.
|
||||
|
||||
New warnings from recent compilers have been addressed in the generated
|
||||
parsers (yacc.c, glr.c, glr.cc).
|
||||
|
||||
When lone carriage-return characters appeared in the input file,
|
||||
diagnostics could hang forever.
|
||||
|
||||
* Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Portability fixes.
|
||||
|
||||
* Noteworthy changes in release 3.4 (2019-05-19) [stable]
|
||||
|
||||
** Deprecated features
|
||||
|
||||
The %pure-parser directive is deprecated in favor of '%define api.pure'
|
||||
since Bison 2.3b (2008-05-27), but no warning was issued; there is one
|
||||
now. Note that since Bison 2.7 you are strongly encouraged to use
|
||||
'%define api.pure full' instead of '%define api.pure'.
|
||||
|
||||
** New features
|
||||
|
||||
*** Colored diagnostics
|
||||
|
||||
As an experimental feature, diagnostics are now colored, controlled by the
|
||||
new options --color and --style.
|
||||
|
||||
To use them, install the libtextstyle library before configuring Bison.
|
||||
It is available from
|
||||
|
||||
https://alpha.gnu.org/gnu/gettext/
|
||||
|
||||
for instance
|
||||
|
||||
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz
|
||||
|
||||
The option --color supports the following arguments:
|
||||
- always, yes: Enable colors.
|
||||
- never, no: Disable colors.
|
||||
- auto, tty (default): Enable colors if the output device is a tty.
|
||||
|
||||
To customize the styles, create a CSS file similar to
|
||||
|
||||
/* bison-bw.css */
|
||||
.warning { }
|
||||
.error { font-weight: 800; text-decoration: underline; }
|
||||
.note { }
|
||||
|
||||
then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
|
||||
environment variable to "bison-bw.css".
|
||||
|
||||
*** Disabling output
|
||||
|
||||
When given -fsyntax-only, the diagnostics are reported, but no output is
|
||||
generated.
|
||||
|
||||
The name of this option is somewhat misleading as bison does more than
|
||||
just checking the syntax: every stage is run (including checking for
|
||||
conflicts for instance), except the generation of the output files.
|
||||
|
||||
*** Include the generated header (yacc.c)
|
||||
|
||||
Before, when --defines is used, bison generated a header, and pasted an
|
||||
exact copy of it into the generated parser implementation file. If the
|
||||
header name is not "y.tab.h", it is now #included instead of being
|
||||
duplicated.
|
||||
|
||||
To use an '#include' even if the header name is "y.tab.h" (which is what
|
||||
happens with --yacc, or when using the Autotools' ylwrap), define
|
||||
api.header.include to the exact argument to pass to #include. For
|
||||
instance:
|
||||
|
||||
%define api.header.include {"parse.h"}
|
||||
|
||||
or
|
||||
|
||||
%define api.header.include {<parser/parse.h>}
|
||||
|
||||
*** api.location.type is now supported in C (yacc.c, glr.c)
|
||||
|
||||
The %define variable api.location.type defines the name of the type to use
|
||||
for locations. When defined, Bison no longer defines YYLTYPE.
|
||||
|
||||
This can be used in programs with several parsers to factor their
|
||||
definition of locations: let one of them generate them, and the others
|
||||
just use them.
|
||||
|
||||
** Changes
|
||||
|
||||
*** Graphviz output
|
||||
|
||||
In conformance with the recommendations of the Graphviz team, if %require
|
||||
"3.4" (or better) is specified, the option --graph generates a *.gv file
|
||||
by default, instead of *.dot.
|
||||
|
||||
*** Diagnostics overhaul
|
||||
|
||||
Column numbers were wrong with multibyte characters, which would also
|
||||
result in skewed diagnostics with carets. Beside, because we were
|
||||
indenting the quoted source with a single space, lines with tab characters
|
||||
were incorrectly underlined.
|
||||
|
||||
To address these issues, and to be clearer, Bison now issues diagnostics
|
||||
as GCC9 does. For instance it used to display (there's a tab before the
|
||||
opening brace):
|
||||
|
||||
foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
|
||||
expr: expr '+' "number" { $$ = $1 + $2; }
|
||||
^~
|
||||
It now reports
|
||||
|
||||
foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
|
||||
3 | expr: expr '+' "number" { $$ = $1 + $2; }
|
||||
| ^~
|
||||
|
||||
Other constructs now also have better locations, resulting in more precise
|
||||
diagnostics.
|
||||
|
||||
*** Fix-it hints for %empty
|
||||
|
||||
Running Bison with -Wempty-rules and --update will remove incorrect %empty
|
||||
annotations, and add the missing ones.
|
||||
|
||||
*** Generated reports
|
||||
|
||||
The format of the reports (parse.output) was improved for readability.
|
||||
|
||||
*** Better support for --no-line.
|
||||
|
||||
When --no-line is used, the generated files are now cleaner: no lines are
|
||||
generated instead of empty lines. Together with using api.header.include,
|
||||
that should help people saving the generated files into version control
|
||||
systems get smaller diffs.
|
||||
|
||||
** Documentation
|
||||
|
||||
A new example in C shows an simple infix calculator with a hand-written
|
||||
scanner (examples/c/calc).
|
||||
|
||||
A new example in C shows a reentrant parser (capable of recursive calls)
|
||||
built with Flex and Bison (examples/c/reccalc).
|
||||
|
||||
There is a new section about the history of Yaccs and Bison.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
A few obscure bugs were fixed, including the second oldest (known) bug in
|
||||
Bison: it was there when Bison was entered in the RCS version control
|
||||
system, in December 1987. See the NEWS of Bison 3.3 for the previous
|
||||
oldest bug.
|
||||
|
||||
* Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
|
||||
|
||||
** Bug fixes
|
||||
@@ -737,10 +1107,10 @@ GNU Bison NEWS
|
||||
|
||||
bison used to report:
|
||||
|
||||
/tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO
|
||||
foo.yy:2.10-11: error: %printer redeclaration for FOO
|
||||
%printer {} "foo"
|
||||
^^
|
||||
/tmp/foo.yy:3.10-11: previous declaration
|
||||
foo.yy:3.10-11: previous declaration
|
||||
%printer {} FOO
|
||||
^^
|
||||
|
||||
@@ -3482,12 +3852,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
||||
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
||||
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
|
||||
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir
|
||||
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir bw
|
||||
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
|
||||
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
|
||||
LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
|
||||
LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
|
||||
LocalWords: noexcept constexpr ispell american deprecations
|
||||
LocalWords: noexcept constexpr ispell american deprecations backend Teoh
|
||||
LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
|
||||
LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata
|
||||
|
||||
Local Variables:
|
||||
ispell-dictionary: "american"
|
||||
|
||||
@@ -1,15 +1,47 @@
|
||||
This package contains the GNU Bison parser generator.
|
||||
|
||||
* Installation
|
||||
** Build
|
||||
# Installation
|
||||
## Build from git
|
||||
Here are basic installation instructions for a repository checkout:
|
||||
|
||||
$ git submodule update --init
|
||||
$ ./bootstrap
|
||||
|
||||
then proceed with the usual `configure && make` steps.
|
||||
|
||||
The file README-hacking.md is about building, modifying and checking Bison.
|
||||
|
||||
## Build from tarball
|
||||
See the file INSTALL for generic compilation and installation instructions.
|
||||
|
||||
Bison requires GNU m4 1.4.6 or later. See:
|
||||
Bison requires GNU m4 1.4.6 or later. See
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
|
||||
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
|
||||
## Colored diagnostics
|
||||
As an experimental feature, diagnostics are now colored, controlled by the
|
||||
`--color` and `--style` options.
|
||||
|
||||
** Relocatability
|
||||
If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
|
||||
To use them, install the libtextstyle library before configuring Bison. It
|
||||
is available from https://alpha.gnu.org/gnu/gettext/, for instance
|
||||
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz.
|
||||
|
||||
The option --color supports the following arguments:
|
||||
- always, yes: Enable colors.
|
||||
- never, no: Disable colors.
|
||||
- auto, tty (default): Enable colors if the output device is a tty.
|
||||
|
||||
To customize the styles, create a CSS file, say `bison-bw.css`, similar to
|
||||
|
||||
/* bison-bw.css */
|
||||
.warning { }
|
||||
.error { font-weight: 800; text-decoration: underline; }
|
||||
.note { }
|
||||
|
||||
then invoke bison with `--style=bison-bw.css`, or set the `BISON_STYLE`
|
||||
environment variable to `bison-bw.css`.
|
||||
|
||||
## Relocatability
|
||||
If you pass `--enable-relocatable` to `configure`, Bison is relocatable.
|
||||
|
||||
A relocatable program can be moved or copied to a different location on the
|
||||
file system. It can also be used through mount points for network sharing.
|
||||
@@ -18,7 +50,7 @@ invoke them through the symlink.
|
||||
|
||||
See "Enabling Relocatability" in the documentation.
|
||||
|
||||
** Internationalization
|
||||
## Internationalization
|
||||
Bison supports two catalogs: one for Bison itself (i.e., for the
|
||||
maintainer-side parser generation), and one for the generated parsers (i.e.,
|
||||
for the user-side parser execution). The requirements between both differ:
|
||||
@@ -28,31 +60,25 @@ generated parsers could have been localized. See
|
||||
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for more
|
||||
details.
|
||||
|
||||
* Questions
|
||||
# Questions
|
||||
See the section FAQ in the documentation (doc/bison.info) for frequently
|
||||
asked questions. The documentation is also available in PDF and HTML,
|
||||
provided you have a recent version of Texinfo installed: run "make pdf" or
|
||||
"make html".
|
||||
provided you have a recent version of Texinfo installed: run `make pdf` or
|
||||
`make html`.
|
||||
|
||||
If you have questions about using Bison and the documentation does not
|
||||
answer them, please send mail to <[email protected]>.
|
||||
|
||||
* Bug reports
|
||||
# Bug reports
|
||||
Please send bug reports to <[email protected]>. Be sure to include the
|
||||
version number from 'bison --version', and a complete, self-contained test
|
||||
version number from `bison --version`, and a complete, self-contained test
|
||||
case in each bug report.
|
||||
|
||||
* Copyright statements
|
||||
# Copyright statements
|
||||
For any copyright year range specified as YYYY-ZZZZ in this package, note
|
||||
that the range specifies every single year in that closed interval.
|
||||
|
||||
-----
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
<!--
|
||||
|
||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2019 Free
|
||||
Software Foundation, Inc.
|
||||
@@ -72,5 +98,13 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
||||
# LocalWords: MERCHANTABILITY
|
||||
Local Variables:
|
||||
mode: markdown
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
||||
LocalWords: MERCHANTABILITY
|
||||
|
||||
-->
|
||||
|
||||
+220
-158
@@ -2,20 +2,19 @@ This file attempts to describe the rules to use when hacking Bison.
|
||||
Don't put this file into the distribution.
|
||||
|
||||
Everything related to the development of Bison is on Savannah:
|
||||
|
||||
http://savannah.gnu.org/projects/bison/
|
||||
http://savannah.gnu.org/projects/bison/.
|
||||
|
||||
|
||||
* Administrivia
|
||||
# Administrivia
|
||||
|
||||
** If you incorporate a change from somebody on the net:
|
||||
## If you incorporate a change from somebody on the net:
|
||||
First, if it is a large change, you must make sure they have signed the
|
||||
appropriate paperwork. Second, be sure to add their name and email address
|
||||
to THANKS.
|
||||
|
||||
** If a change fixes a test, mention the test in the commit message.
|
||||
## If a change fixes a test, mention the test in the commit message.
|
||||
|
||||
** Bug reports
|
||||
## Bug reports
|
||||
If somebody reports a new bug, mention his name in the commit message and in
|
||||
the test case you write. Put him into THANKS.
|
||||
|
||||
@@ -24,18 +23,18 @@ demonstrates the bug. Then fix the bug, re-run the test suite, and check
|
||||
everything in.
|
||||
|
||||
|
||||
* Hacking
|
||||
# Hacking
|
||||
|
||||
** Visible changes
|
||||
## Visible changes
|
||||
Which include serious bug fixes, must be mentioned in NEWS.
|
||||
|
||||
** Translations
|
||||
## Translations
|
||||
Only user visible strings are to be translated: error messages, bits of the
|
||||
.output file etc. This excludes impossible error messages (comparable to
|
||||
assert/abort), and all the --trace output which is meant for the maintainers
|
||||
only.
|
||||
|
||||
** Horizontal tabs
|
||||
## Horizontal tabs
|
||||
Do not add horizontal tab characters to any file in Bison's repository
|
||||
except where required. For example, do not use tabs to format C code.
|
||||
However, make files, ChangeLog, and some regular expressions require tabs.
|
||||
@@ -43,12 +42,12 @@ Also, test cases might need to contain tabs to check that Bison properly
|
||||
processes tabs in its input.
|
||||
|
||||
|
||||
* Working from the repository
|
||||
# Working from the repository
|
||||
|
||||
These notes intend to help people working on the checked-out sources.
|
||||
These requirements do not apply when building from a distribution tarball.
|
||||
These notes intend to help people working on the checked-out sources. These
|
||||
requirements do not apply when building from a distribution tarball.
|
||||
|
||||
** Requirements
|
||||
## Requirements
|
||||
|
||||
We've opted to keep only the highest-level sources in the repository. This
|
||||
eases our maintenance burden, (fewer merges etc.), but imposes more
|
||||
@@ -75,8 +74,8 @@ If you're using a GNU/Linux distribution, the easiest way to install the
|
||||
above packages depends on your system. The following shell command should
|
||||
work for Debian-based systems such as Ubuntu:
|
||||
|
||||
sudo apt-get install \
|
||||
autoconf automake autopoint flex graphviz help2man texinfo valgrind
|
||||
sudo apt-get install \
|
||||
autoconf automake autopoint flex graphviz help2man texinfo valgrind
|
||||
|
||||
Bison is written using Bison grammars, so there are bootstrapping issues.
|
||||
The bootstrap script attempts to discover when the C code generated from the
|
||||
@@ -89,145 +88,184 @@ after synchronizing from the repository a plain 'make' should be sufficient.
|
||||
Note, however, that when gnulib is updated, running './bootstrap' again
|
||||
might be needed.
|
||||
|
||||
** First checkout
|
||||
## First checkout
|
||||
|
||||
Obviously, if you are reading these notes, you did manage to check out this
|
||||
package from the repository. For the record, you will find all the relevant
|
||||
information on:
|
||||
|
||||
http://savannah.gnu.org/git/?group=bison
|
||||
information on http://savannah.gnu.org/git/?group=bison.
|
||||
|
||||
Bison uses Git submodules: subscriptions to other Git repositories. In
|
||||
particular it uses gnulib, the GNU portability library. To ask Git to
|
||||
perform the first checkout of the submodules, run
|
||||
|
||||
$ git submodule update --init
|
||||
$ git submodule update --init
|
||||
|
||||
The next step is to get other files needed to build, which are extracted
|
||||
from other source packages:
|
||||
|
||||
$ ./bootstrap
|
||||
$ ./bootstrap
|
||||
|
||||
Bootstrapping updates the submodules to the versions registered in the
|
||||
top-level directory. To change gnulib, first check out the version you want
|
||||
in `gnulib`, then commit this change in Bison's repository, and finally run
|
||||
bootstrap.
|
||||
|
||||
If it fails with missing symbols (e.g., "error: possibly undefined macro:
|
||||
AC_PROG_GNU_M4"), you are likely to have forgotten the submodule
|
||||
If it fails with missing symbols (e.g., `error: possibly undefined macro:
|
||||
AC_PROG_GNU_M4`), you are likely to have forgotten the submodule
|
||||
initialization part. To recover from it, run `git reset --hard HEAD`, and
|
||||
restart with the submodule initialization. Otherwise, there you are! Just
|
||||
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make check
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make check
|
||||
|
||||
At this point, there should be no difference between your local copy, and
|
||||
the master copy:
|
||||
|
||||
$ git diff
|
||||
$ git diff
|
||||
|
||||
should output no difference.
|
||||
|
||||
Enjoy!
|
||||
|
||||
** Updating
|
||||
## Updating
|
||||
|
||||
The use of submodules make things somewhat different because git does not
|
||||
support recursive operations: submodules must be taken care of explicitly by
|
||||
the user.
|
||||
If you have git at version 1.8.2 or later, the command
|
||||
|
||||
*** Updating Bison
|
||||
$ git submodule update --recursive --remote
|
||||
|
||||
If you pull a newer version of a branch, say via "git pull", you might
|
||||
import requests for updated submodules. A simple "git diff" will reveal if
|
||||
will be useful for updating to the latest version of all submodules.
|
||||
|
||||
Under earlier versions, use of submodules make things somewhat different
|
||||
because git does not yet support recursive operations: submodules must be
|
||||
taken care of explicitly.
|
||||
|
||||
### Updating Bison
|
||||
|
||||
If you pull a newer version of a branch, say via `git pull`, you might
|
||||
import requests for updated submodules. A simple `git diff` will reveal if
|
||||
the current version of the submodule (i.e., the actual contents of the
|
||||
gnulib directory) and the current request from the subscriber (i.e., the
|
||||
reference of the version of gnulib that the Bison repository requests)
|
||||
differ. To upgrade the submodules (i.e., to check out the version that is
|
||||
actually requested by the subscriber, run "git submodule update".
|
||||
actually requested by the subscriber, run `git submodule update`.
|
||||
|
||||
$ git pull
|
||||
$ git submodule update
|
||||
$ git pull
|
||||
$ git submodule update
|
||||
|
||||
*** Updating a submodule
|
||||
### Updating a submodule
|
||||
To update a submodule, say gnulib, do as follows:
|
||||
|
||||
Get the most recent version of the master branch from git.
|
||||
|
||||
$ cd gnulib
|
||||
$ git fetch
|
||||
$ git checkout -b master --track origin/master
|
||||
$ cd gnulib
|
||||
$ git fetch
|
||||
$ git checkout -b master --track origin/master
|
||||
|
||||
Make sure Bison can live with that version of gnulib.
|
||||
|
||||
$ cd ..
|
||||
$ ./bootstrap
|
||||
$ make distcheck
|
||||
$ cd ..
|
||||
$ ./bootstrap
|
||||
$ make distcheck
|
||||
|
||||
Register your changes.
|
||||
|
||||
$ git checkin ...
|
||||
$ git commit ...
|
||||
|
||||
For a suggestion of what gnulib commit might be stable enough for a formal
|
||||
release, see the ChangeLog in the latest gnulib snapshot at:
|
||||
|
||||
http://erislabs.net/ianb/projects/gnulib/
|
||||
release, see the ChangeLog in the latest gnulib snapshot at
|
||||
http://erislabs.net/ianb/projects/gnulib/.
|
||||
|
||||
The Autoconf files we use are currently:
|
||||
|
||||
m4/m4.m4
|
||||
lib/m4sugar/m4sugar.m4
|
||||
lib/m4sugar/foreach.m4
|
||||
- m4/m4.m4
|
||||
- lib/m4sugar/m4sugar.m4
|
||||
- lib/m4sugar/foreach.m4
|
||||
|
||||
These files don't change very often in Autoconf, so it should be relatively
|
||||
straight-forward to examine the differences in order to decide whether to
|
||||
update.
|
||||
|
||||
* Test suite
|
||||
# Test Suite
|
||||
|
||||
** make check
|
||||
Use liberally.
|
||||
## make check
|
||||
Consume without moderation. It is composed of two kinds of tests: the
|
||||
examples, and the main test suite.
|
||||
|
||||
** TESTSUITEFLAGS
|
||||
### The Examples
|
||||
In examples/, there is a number of ready-to-use examples (see
|
||||
examples/README.md). These examples have small test suites run by `make
|
||||
check`. The test results are in local `*.log` files (e.g.,
|
||||
`$build/examples/c/calc/calc.log`).
|
||||
|
||||
To run just the testsuite (not the tests related to the examples), run `make
|
||||
check-local`.
|
||||
### The Main Test Suite
|
||||
The main test suite, in tests/, is written on top of GNU Autotest, which is
|
||||
part of Autoconf. Run `info autoconf 'Using Autotest'` to read the
|
||||
documentation, not only about how to write tests, but also where are the
|
||||
logs, how to read them etc.
|
||||
|
||||
The main test suite generates a log for each test (e.g.,
|
||||
`$build/tests/testsuite.dir/004/testsuite.log` for test #4), and a main log
|
||||
file in `$build/tests/testsuite.log`. The latter is meant for end users: it
|
||||
contains lots of details that should help diagnosing issues, including build
|
||||
issues. The per-test logs are more convenient when working locally.
|
||||
|
||||
#### TESTSUITEFLAGS
|
||||
To run just the main test suite, run `make check-local`.
|
||||
|
||||
The default is for make check-local to run all tests sequentially. This can
|
||||
be very time consuming when checking repeatedly or on slower setups. This
|
||||
can be sped up in two ways:
|
||||
|
||||
Using -j, in a make-like fashion, for example:
|
||||
$ make check-local TESTSUITEFLAGS='-j8'
|
||||
|
||||
$ make check-local TESTSUITEFLAGS='-j8'
|
||||
|
||||
Actually, when using GNU Make, TESTSUITEFLAGS defaults to the -jN passed to
|
||||
it, so you may simply run
|
||||
|
||||
$ make check-local -j8
|
||||
|
||||
Running only the tests of a certain category, as specified in the AT files
|
||||
with AT_KEYWORDS([[category]]). Categories include:
|
||||
- c++, for c++ parsers
|
||||
- deprec, for tests concerning deprecated constructs.
|
||||
- glr, for glr parsers
|
||||
- java, for java parsers
|
||||
- report, for automaton dumps
|
||||
- c++, for c++ parsers
|
||||
- deprec, for tests concerning deprecated constructs.
|
||||
- glr, for glr parsers
|
||||
- java, for java parsers
|
||||
- report, for automaton dumps
|
||||
|
||||
To get a list of all the tests (and their keywords for -k), run
|
||||
|
||||
$ ./tests/testsuite -l
|
||||
|
||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||
|
||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||
|
||||
Both can be combined.
|
||||
|
||||
** Typical errors
|
||||
If the test suite shows failures such as the following one
|
||||
$ make check-local TESTSUITEFLAGS='-j8 -k c++'
|
||||
|
||||
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
|
||||
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
|
||||
To rerun the tests that failed:
|
||||
|
||||
it probably means that some file was compiled without
|
||||
AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
|
||||
pick up gnulib's replacement headers, such as getopt.h, and this will go
|
||||
wrong if config.h was not included first.
|
||||
$ make recheck -j5
|
||||
|
||||
See tests/local.at for details.
|
||||
#### Updating the Expectations
|
||||
Sometimes some changes have a large impact on the test suite (e.g., when we
|
||||
added the `[-Wother]` part to all the warnings). Part of the update can be
|
||||
done with a crude tool: `build-aux/update-test`.
|
||||
|
||||
** make maintainer-check-valgrind
|
||||
Once you ran the test suite, and therefore have many `testsuite.log` files,
|
||||
run, from the source tree:
|
||||
|
||||
$ ./build-aux/update-test $build/tests/testsuite.dir/*/testsuite.log
|
||||
|
||||
where `$build` would be your build tree. This will hopefully update most
|
||||
tests. Re-run the test suite. It might be interesting to run `update-test`
|
||||
again, since some early failures may stop latter tests from being run. Yet
|
||||
at some point, you'll have to fix remaining issues by hand...
|
||||
|
||||
|
||||
## make maintainer-check-valgrind
|
||||
This target uses valgrind both to check bison, and the generated parsers.
|
||||
|
||||
This is not mature on Mac OS X. First, Valgrind does support the way bison
|
||||
@@ -238,13 +276,13 @@ bison. build-aux/darwin11.4.0.valgrind addresses some of them.
|
||||
|
||||
Third, valgrind issues warnings such as:
|
||||
|
||||
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
|
||||
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
|
||||
|
||||
which cause the test to fail uselessly. It is hard to ignore these errors
|
||||
with a major overhaul of the way instrumentation is performed in the test
|
||||
suite. So currently, do not try to run valgrind on Mac OS X.
|
||||
|
||||
** Release checks
|
||||
## Release checks
|
||||
Try to run the test suite with more severe conditions before a
|
||||
release:
|
||||
|
||||
@@ -256,25 +294,25 @@ release:
|
||||
its warnings; there's no need to obey blindly to it
|
||||
(<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
|
||||
|
||||
- Check with "make syntax-check" if there are issues diagnosed by gnulib.
|
||||
- Check with `make syntax-check` if there are issues diagnosed by gnulib.
|
||||
|
||||
- run "make maintainer-check" which:
|
||||
- runs "valgrind -q bison" to run Bison under Valgrind.
|
||||
- run `make maintainer-check` which:
|
||||
- runs `valgrind -q bison` to run Bison under Valgrind.
|
||||
- runs the parsers under Valgrind.
|
||||
- runs the test suite with G++ as C compiler...
|
||||
|
||||
- run "make maintainer-check-push", which runs "make maintainer-check" while
|
||||
- run `make maintainer-check-push`, which runs `make maintainer-check` while
|
||||
activating the push implementation and its pull interface wrappers in many
|
||||
test cases that were originally written to exercise only the pull
|
||||
implementation. This makes certain the push implementation can perform
|
||||
every task the pull implementation can.
|
||||
|
||||
- run "make maintainer-check-xml", which runs "make maintainer-check" while
|
||||
- run `make maintainer-check-xml`, which runs `make maintainer-check` while
|
||||
checking Bison's XML automaton report for every working grammar passed to
|
||||
Bison in the test suite. The check just diffs the output of Bison's
|
||||
included XSLT style sheets with the output of --report=all and --graph.
|
||||
|
||||
- running "make maintainer-check-release" takes care of running
|
||||
- running `make maintainer-check-release` takes care of running
|
||||
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
||||
|
||||
- Change tests/atlocal/CFLAGS to add your preferred options.
|
||||
@@ -282,59 +320,77 @@ release:
|
||||
- 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.
|
||||
|
||||
## gnulib
|
||||
To run tests on gnulib components (e.g., on bitset):
|
||||
|
||||
* Release Procedure
|
||||
cd gnulib
|
||||
./gnulib-tool --test bitset-tests
|
||||
|
||||
possibly within a specified environment:
|
||||
|
||||
CC='gcc-mp-8 -fsanitize=undefined' ./gnulib-tool --test bitset-tests
|
||||
|
||||
To be able to run the tests several times, and to use symlinks instead of
|
||||
copies so that one can update the origin gnulib directory and immediately
|
||||
re-run the tests, run:
|
||||
|
||||
./gnulib-tool --symlink --create-test --dir=/tmp/gnutest bitset-tests
|
||||
cd /tmp/gnutest
|
||||
./configure -C CC='gcc-mp-8 -fsanitize=undefined' CFLAGS='-ggdb'
|
||||
make check
|
||||
|
||||
# Release Procedure
|
||||
This section needs to be updated to take into account features from gnulib.
|
||||
In particular, be sure to read README-release.
|
||||
|
||||
** Update the submodules. See above.
|
||||
## Update the submodules. See above.
|
||||
|
||||
** Update maintainer tools, such as Autoconf. See above.
|
||||
## Update maintainer tools, such as Autoconf. See above.
|
||||
|
||||
** Try to get the *.pot files to the Translation Project at least one
|
||||
## Try to get the *.pot files to the Translation Project at least one
|
||||
week before a stable release, to give them time to translate them. Before
|
||||
generating the *.pot files, make sure that po/POTFILES.in and
|
||||
runtime-po/POTFILES.in list all files with translatable strings. This
|
||||
helps: grep -l '\<_(' *.
|
||||
helps: `grep -l '\<_(' *`.
|
||||
|
||||
** Tests
|
||||
## Tests
|
||||
See above.
|
||||
|
||||
** Update the foreign files
|
||||
Running "./bootstrap" in the top level should update them all for you. This
|
||||
## Update the foreign files
|
||||
Running `./bootstrap` in the top level should update them all for you. This
|
||||
covers PO files too. Sometimes a PO file contains problems that causes it
|
||||
to be rejected by recent Gettext releases; please report these to the
|
||||
Translation Project.
|
||||
|
||||
** Update README
|
||||
## Update README
|
||||
Make sure the information in README is current. Most notably, make sure it
|
||||
recommends a version of GNU M4 that is compatible with the latest Bison
|
||||
sources.
|
||||
|
||||
** Check copyright years.
|
||||
## Check copyright years.
|
||||
We update years in copyright statements throughout Bison once at the start
|
||||
of every year by running "make update-copyright". However, before a
|
||||
of every year by running `make update-copyright`. However, before a
|
||||
release, it's good to verify that it's actually been run. Besides the
|
||||
copyright statement for each Bison file, check the copyright statements that
|
||||
the skeletons insert into generated parsers, and check all occurrences of
|
||||
PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
||||
`PACKAGE_COPYRIGHT_YEAR` in configure.ac.
|
||||
|
||||
** Update NEWS, commit and tag.
|
||||
## Update NEWS, commit and tag.
|
||||
See do-release-commit-and-tag in README-release. For a while, we used beta
|
||||
names such as "2.6_rc1". Now that we use gnulib in the release procedure,
|
||||
we must use "2.5.90", which has the additional benefit of being properly
|
||||
sorted in "git tag -l".
|
||||
names such as `2.6_rc1`. Now that we use gnulib in the release procedure,
|
||||
we must use `2.5.90`, which has the additional benefit of being properly
|
||||
sorted in `git tag -l`.
|
||||
|
||||
** make alpha, beta, or stable
|
||||
## make alpha, beta, or stable
|
||||
See README-release.
|
||||
|
||||
** Upload
|
||||
## Upload
|
||||
There are two ways to upload the tarballs to the GNU servers: using gnupload
|
||||
(from gnulib), or by hand. Obviously prefer the former. But in either
|
||||
case, be sure to read the following paragraph.
|
||||
|
||||
*** Setup
|
||||
You need "gnupg".
|
||||
### Setup
|
||||
You need `gnupg`.
|
||||
|
||||
Make sure your public key has been uploaded at least to keys.gnupg.net. You
|
||||
can upload it with:
|
||||
@@ -343,106 +399,105 @@ can upload it with:
|
||||
|
||||
where F125BDF3 should be replaced with your key ID.
|
||||
|
||||
*** Using gnupload
|
||||
You need "ncftp".
|
||||
### Using gnupload
|
||||
You need `ncftp`.
|
||||
|
||||
At the end "make stable" (or alpha/beta) will display the procedure to run.
|
||||
At the end `make stable` (or alpha/beta) will display the procedure to run.
|
||||
Just copy and paste it in your shell.
|
||||
|
||||
*** By hand
|
||||
### By hand
|
||||
|
||||
The generic GNU upload procedure is at:
|
||||
|
||||
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads
|
||||
The generic GNU upload procedure is at
|
||||
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads.
|
||||
|
||||
Follow the instructions there to register your information so you're permitted
|
||||
to upload.
|
||||
|
||||
Here's a brief reminder of how to roll the tarballs and upload them:
|
||||
|
||||
*** make distcheck
|
||||
*** gpg -b bison-2.3b.tar.gz
|
||||
*** In a file named "bison-2.3b.tar.gz.directive", type:
|
||||
### make distcheck
|
||||
### gpg -b bison-2.3b.tar.gz
|
||||
### In a file named `bison-2.3b.tar.gz.directive`, type:
|
||||
|
||||
version: 1.1
|
||||
directory: bison
|
||||
filename: bison-2.3b.tar.gz
|
||||
version: 1.1
|
||||
directory: bison
|
||||
filename: bison-2.3b.tar.gz
|
||||
|
||||
*** gpg --clearsign bison-2.3b.tar.gz.directive
|
||||
*** ftp ftp-upload.gnu.org # Log in as anonymous.
|
||||
*** cd /incoming/alpha # cd /incoming/ftp for full release.
|
||||
*** put bison-2.3b.tar.gz # This can take a while.
|
||||
*** put bison-2.3b.tar.gz.sig
|
||||
*** put bison-2.3b.tar.gz.directive.asc
|
||||
*** Repeat all these steps for bison-2.3b.tar.xz.
|
||||
### gpg --clearsign bison-2.3b.tar.gz.directive
|
||||
### ftp ftp-upload.gnu.org # Log in as anonymous.
|
||||
### cd /incoming/alpha # cd /incoming/ftp for full release.
|
||||
### put bison-2.3b.tar.gz # This can take a while.
|
||||
### put bison-2.3b.tar.gz.sig
|
||||
### put bison-2.3b.tar.gz.directive.asc
|
||||
### Repeat all these steps for bison-2.3b.tar.xz.
|
||||
|
||||
** Update Bison manual on www.gnu.org.
|
||||
## Update Bison manual on www.gnu.org.
|
||||
|
||||
The instructions below are obsolete, and left in case one would like to run
|
||||
the commands by hand. Today, one just needs to run
|
||||
|
||||
$ make web-manual-update
|
||||
$ make web-manual-update
|
||||
|
||||
See README-release.
|
||||
|
||||
*** You need a non-anonymous checkout of the web pages directory.
|
||||
### You need a non-anonymous checkout of the web pages directory.
|
||||
|
||||
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
|
||||
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
|
||||
|
||||
*** Get familiar with the instructions for web page maintainers.
|
||||
### Get familiar with the instructions for web page maintainers.
|
||||
http://www.gnu.org/server/standards/readme_index.html
|
||||
http://www.gnu.org/server/standards/README.software.html
|
||||
especially the note about symlinks.
|
||||
|
||||
*** Build the web pages.
|
||||
### Build the web pages.
|
||||
Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
|
||||
BISON_WWW_CHECKOUT refers to the web directory created above, do:
|
||||
|
||||
$ cd $BISON_CHECKOUT/doc
|
||||
$ make stamp-vti
|
||||
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
|
||||
bison "Bison - GNU parser generator"
|
||||
$ cd $BISON_WWW_CHECKOUT
|
||||
$ cd $BISON_CHECKOUT/doc
|
||||
$ make stamp-vti
|
||||
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
|
||||
bison "Bison - GNU parser generator"
|
||||
$ cd $BISON_WWW_CHECKOUT
|
||||
|
||||
Verify that the result looks sane.
|
||||
|
||||
*** Commit the modified and the new files.
|
||||
### Commit the modified and the new files.
|
||||
|
||||
*** Remove old files.
|
||||
### Remove old files.
|
||||
Find the files which have not been overwritten (because they belonged to
|
||||
sections that have been removed or renamed):
|
||||
|
||||
$ cd manual/html_node
|
||||
$ ls -lt
|
||||
$ cd manual/html_node
|
||||
$ ls -lt
|
||||
|
||||
Remove these files and commit their removal to CVS. For each of these
|
||||
files, add a line to the file .symlinks. This will ensure that hyperlinks
|
||||
to the removed files will redirect to the entire manual; this is better than
|
||||
a 404 error.
|
||||
|
||||
** Announce
|
||||
## Announce
|
||||
The "make release" command just created a template,
|
||||
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
|
||||
`$HOME/announce-bison-X.Y`. Otherwise, to generate it, run:
|
||||
|
||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
||||
|
||||
where alpha can be replaced by beta or stable and F125BDF3 should be
|
||||
where alpha can be replaced by `beta` or `table` and F125BDF3 should be
|
||||
replaced with your key ID.
|
||||
|
||||
Complete/fix the announcement file. The generated list of recipients
|
||||
(info-gnu@gnu.org, bug-bison@gnu.org, help-bison@gnu.org,
|
||||
bison-patches@gnu.org, and coordinator@translationproject.org) is
|
||||
appropriate for a stable release or a "serious beta". For any other
|
||||
release, drop at least info-gnu@gnu.org. For an example of how to fill out
|
||||
the rest of the template, search the mailing list archives for the most
|
||||
recent release announcement.
|
||||
(info-gnu@gnu.org, bison-announce@gnu.org, bug-bison@gnu.org,
|
||||
help-bison@gnu.org, bison-patches@gnu.org, and
|
||||
coordinator@translationproject.org) is appropriate for a stable release or a
|
||||
"serious beta". For any other release, drop at least info-gnu@gnu.org. For
|
||||
an example of how to fill out the rest of the template, search the mailing
|
||||
list archives for the most recent release announcement.
|
||||
|
||||
For a stable release, send the same announcement on the comp.compilers
|
||||
newsgroup by sending email to compilers@iecc.com. Do not make any Cc as the
|
||||
moderator will throw away anything cross-posted or Cc'ed. It really needs
|
||||
to be a separate message.
|
||||
|
||||
** Prepare NEWS
|
||||
## Prepare NEWS
|
||||
So that developers don't accidentally add new items to the old NEWS entry,
|
||||
create a new empty entry in line 3 (without the two leading spaces):
|
||||
|
||||
@@ -450,7 +505,7 @@ create a new empty entry in line 3 (without the two leading spaces):
|
||||
|
||||
Push these changes.
|
||||
|
||||
-----
|
||||
<!--
|
||||
|
||||
Copyright (C) 2002-2005, 2007-2015, 2018-2019 Free Software Foundation,
|
||||
Inc.
|
||||
@@ -470,13 +525,20 @@ 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: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
||||
LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
|
||||
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||
LocalWords: symlinks vti html lt POSIX Cc'ed
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
mode: markdown
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
||||
LocalWords: submodule init cd distcheck ChangeLog valgrind sigreturn sudo
|
||||
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||
LocalWords: symlinks vti html lt POSIX Cc'ed Graphviz Texinfo autoconf jN
|
||||
LocalWords: automake autopoint graphviz texinfo PROG Wother parsers
|
||||
LocalWords: TESTSUITEFLAGS deprec struct gnulib's getopt config ggdb
|
||||
LocalWords: bitset fsanitize symlink CFLAGS MERCHANTABILITY ispell
|
||||
LocalWords: american
|
||||
|
||||
-->
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
From phr Tue Jul 8 10:36:19 1986
|
||||
Date: Tue, 8 Jul 86 00:52:24 EDT
|
||||
From: phr (Paul Rubin)
|
||||
To: riferguson%[email protected], tower
|
||||
Subject: Re: Bison documentation?
|
||||
|
||||
The main difference between Bison and Yacc that I know of is that
|
||||
Bison supports the @N construction, which gives you access to
|
||||
the starting and ending line number and character number associated
|
||||
with any of the symbols in the current rule.
|
||||
|
||||
Also, Bison supports the command '%expect N' which says not to mention
|
||||
the conflicts if there are N shift/reduce conflicts and no reduce/reduce
|
||||
conflicts.
|
||||
|
||||
The differences in the algorithms stem mainly from the horrible
|
||||
kludges that Johnson had to perpetrate to make Yacc fit in a PDP-11.
|
||||
|
||||
Also, Bison uses a faster but less space-efficient encoding for the
|
||||
parse tables (see Corbett's PhD thesis from Berkeley, "Static
|
||||
Semantics in Compiler Error Recovery", June 1985, Report No. UCB/CSD
|
||||
85/251), and more modern technique for generating the lookahead sets.
|
||||
(See Frank DeRemer and Thomas Pennello, "Efficient Computation of
|
||||
LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
|
||||
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
||||
technique is the standard one now.)
|
||||
|
||||
paul rubin
|
||||
free software foundation
|
||||
|
||||
|
||||
[DeRemer-Pennello reference corrected by Paul Eggert <[email protected]>,
|
||||
2004-06-21.]
|
||||
@@ -10,6 +10,7 @@ Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Alexandre Duret-Lutz [email protected]
|
||||
Andre da Costa Barros [email protected]
|
||||
Andreas Damm [email protected]
|
||||
Andreas Schwab [email protected]
|
||||
Andrew Suffield [email protected]
|
||||
Angelo Borsotti [email protected]
|
||||
@@ -33,6 +34,7 @@ Bruce Lilly [email protected]
|
||||
Bruno Haible [email protected]
|
||||
Charles-Henri de Boysson [email protected]
|
||||
Christian Burger [email protected]
|
||||
Clément Démoulins [email protected]
|
||||
Colin Daley [email protected]
|
||||
Cris Bailiff [email protected]
|
||||
Cris van Pelt [email protected]
|
||||
@@ -56,6 +58,7 @@ Didier Godefroy [email protected]
|
||||
Efi Fogel [email protected]
|
||||
Enrico Scholz [email protected]
|
||||
Eric Blake [email protected]
|
||||
Eric S. Raymond [email protected]
|
||||
Étienne Renault [email protected]
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
@@ -65,6 +68,7 @@ Frank Heckenbach [email protected]
|
||||
Frans Englich [email protected]
|
||||
Gabriel Rassoul [email protected]
|
||||
Gary L Peskin [email protected]
|
||||
Gavin Smith [email protected]
|
||||
Georg Sauthoff [email protected]
|
||||
George Neuner [email protected]
|
||||
Gilles Espinasse [email protected]
|
||||
@@ -86,15 +90,19 @@ Jonathan Fabrizio [email protected]
|
||||
Jonathan Nieder [email protected]
|
||||
Josh Soref [email protected]
|
||||
Juan Manuel Guerrero [email protected]
|
||||
Karl Berry [email protected]
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne [email protected]
|
||||
Ken Moffat [email protected]
|
||||
Kiyoshi Kanazawa [email protected]
|
||||
Lars Maier [email protected]
|
||||
László Várady [email protected]
|
||||
Laurent Mascherpa [email protected]
|
||||
Lie Yan [email protected]
|
||||
Magnus Fromreide [email protected]
|
||||
Marc Autret [email protected]
|
||||
Marc Mendiola [email protected]
|
||||
Marc Schönefeld [email protected]
|
||||
Mark Boyall [email protected]
|
||||
Martin Jacobs [email protected]
|
||||
Martin Mokrejs [email protected]
|
||||
@@ -115,6 +123,7 @@ Mike Sullivan [email protected]
|
||||
Nate Guerin [email protected]
|
||||
Neil Booth [email protected]
|
||||
Nelson H. F. Beebe [email protected]
|
||||
neok m4700 [email protected]
|
||||
Nick Bowler [email protected]
|
||||
Nicolas Bedon [email protected]
|
||||
Nicolas Burrus [email protected]
|
||||
@@ -127,6 +136,7 @@ Oliver Mangold [email protected]
|
||||
Paolo Bonzini [email protected]
|
||||
Paolo Simone Gasparello [email protected]
|
||||
Pascal Bart [email protected]
|
||||
Patrice Dumas [email protected]
|
||||
Paul Eggert [email protected]
|
||||
Paul Hilfinger [email protected]
|
||||
Per Allansson [email protected]
|
||||
@@ -165,16 +175,22 @@ Sum Wu [email protected]
|
||||
Théophile Ranquet [email protected]
|
||||
Thiru Ramakrishnan [email protected]
|
||||
Thomas Jahns [email protected]
|
||||
Thomas Petazzoni [email protected]
|
||||
Tim Josling [email protected]
|
||||
Tim Landscheidt [email protected]
|
||||
Tim Van Holder [email protected]
|
||||
Tobias Frost [email protected]
|
||||
Todd Freed [email protected]
|
||||
Tom Kramer [email protected]
|
||||
Tom Lane [email protected]
|
||||
Tom Tromey [email protected]
|
||||
Tomasz Kłoczko [email protected]
|
||||
Tommy Nordgren [email protected]
|
||||
Troy A. Johnson [email protected]
|
||||
Tys Lefering [email protected]
|
||||
Uxio Prego [email protected]
|
||||
Valentin Tolmer [email protected]
|
||||
wcventure [email protected]
|
||||
Victor Khomenko [email protected]
|
||||
Victor Zverovich [email protected]
|
||||
Vin Shelton [email protected]
|
||||
@@ -187,8 +203,11 @@ Wolfgang Thaller [email protected]
|
||||
Wolfram Wagner [email protected]
|
||||
Wwp [email protected]
|
||||
xolodho [email protected]
|
||||
Yuichiro Kaneko [email protected]
|
||||
Zack Weinberg [email protected]
|
||||
江 祖铭 [email protected]
|
||||
長田偉伸 [email protected]
|
||||
马俊 [email protected]
|
||||
|
||||
Many people are not named here because we lost track of them. We
|
||||
thank them! Please, help us keeping this list up to date.
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
* Bison 3.4
|
||||
** injection rules
|
||||
** glr.cc
|
||||
move glr.c into the yy namespace
|
||||
* Bison 3.6
|
||||
** doc
|
||||
I feel its ugly to use the GNU style to declare functions in the doc. It
|
||||
generates tons of white space in the page, and may contribute to bad page
|
||||
breaks.
|
||||
|
||||
Also, we seem to teach YYPRINT very early on, although it should be
|
||||
considered deprecated: %printer is superior.
|
||||
|
||||
** improve syntax errors (UTF-8, internationalization)
|
||||
Bison depends on the current locale. For instance:
|
||||
|
||||
@@ -43,18 +48,133 @@ syntax error, unexpected $end, expecting ↦ or 🎅🐃 or '\n'
|
||||
|
||||
|
||||
While at it, we should stop using "$end" by default, in favor of "end of
|
||||
file", or "end of input", whatever.
|
||||
file", or "end of input", whatever. See how lalr1.java does that.
|
||||
|
||||
** use gettext-h in gnulib instead of gettext
|
||||
** use gnulib-po
|
||||
For some reason, according to syntax-check, we have to keep getopt.c in
|
||||
POTIFILES.in, but not bitset/stats.c, although both come from gnulib. But
|
||||
bitset/stats.c is a symlink, not getopt.c. This is fishy and should be
|
||||
fixed.
|
||||
** consistency
|
||||
token vs terminal, variable vs non terminal.
|
||||
|
||||
Meanwhile, bitset/stats.c is removed from the set of translations, which is
|
||||
not too much of a problem as users are not expected to see this.
|
||||
** Stop indentation in diagnostics
|
||||
Before Bison 2.7, we printed "flatly" the dependencies in long diagnostics:
|
||||
|
||||
input.y:2.7-12: %type redeclaration for exp
|
||||
input.y:1.7-12: previous declaration
|
||||
|
||||
In Bison 2.7, we indented them
|
||||
|
||||
input.y:2.7-12: error: %type redeclaration for exp
|
||||
input.y:1.7-12: previous declaration
|
||||
|
||||
Later we quoted the source in the diagnostics, and today we have:
|
||||
|
||||
/tmp/foo.y:1.12-14: warning: symbol FOO redeclared [-Wother]
|
||||
1 | %token FOO FOO
|
||||
| ^~~
|
||||
/tmp/foo.y:1.8-10: previous declaration
|
||||
1 | %token FOO FOO
|
||||
| ^~~
|
||||
|
||||
The indentation is no longer helping. We should probably get rid of it, or
|
||||
maybe keep it only when -fno-caret. GCC displays this as a "note":
|
||||
|
||||
$ g++-mp-9 -Wall /tmp/foo.c -c
|
||||
/tmp/foo.c:1:10: error: redefinition of 'int foo'
|
||||
1 | int foo, foo;
|
||||
| ^~~
|
||||
/tmp/foo.c:1:5: note: 'int foo' previously declared here
|
||||
1 | int foo, foo;
|
||||
| ^~~
|
||||
|
||||
Likewise for Clang, contrary to what I believed (because "note:" is written
|
||||
in black, so it doesn't show in my terminal :-)
|
||||
|
||||
$ clang++-mp-8.0 -Wall /tmp/foo.c -c
|
||||
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
|
||||
/tmp/foo.c:1:10: error: redefinition of 'foo'
|
||||
int foo, foo;
|
||||
^
|
||||
/tmp/foo.c:1:5: note: previous definition is here
|
||||
int foo, foo;
|
||||
^
|
||||
1 error generated.
|
||||
|
||||
See also the item "Complaint submessage indentation" below.
|
||||
|
||||
** api.token.raw
|
||||
Maybe we should exhibit the YYUNDEFTOK token. It could also be assigned a
|
||||
semantic value so that yyerror could be used to report invalid lexemes.
|
||||
See also the item "$undefined" below.
|
||||
|
||||
** C++
|
||||
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
||||
itself uses int (for yylen for instance), yet stack is based on size_t.
|
||||
|
||||
Maybe locations should also move to ints.
|
||||
|
||||
Paul Eggert already covered most of this. But before publishing these
|
||||
changes, we need to ask our C++ users if they agree with that change, or if
|
||||
we need some migration path. Could be a %define variable, or simply
|
||||
%require "3.5".
|
||||
|
||||
* Bison 3.7
|
||||
** Unit rules / Injection rules (Akim Demaille)
|
||||
Maybe we could expand unit rules (or "injections", see
|
||||
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
|
||||
transform
|
||||
|
||||
exp: arith | bool;
|
||||
arith: exp '+' exp;
|
||||
bool: exp '&' exp;
|
||||
|
||||
into
|
||||
|
||||
exp: exp '+' exp | exp '&' exp;
|
||||
|
||||
when there are no actions. This can significantly speed up some grammars.
|
||||
I can't find the papers. In particular the book 'LR parsing: Theory and
|
||||
Practice' is impossible to find, but according to 'Parsing Techniques: a
|
||||
Practical Guide', it includes information about this issue. Does anybody
|
||||
have it?
|
||||
|
||||
** clean up (Akim Demaille)
|
||||
Do not work on these items now, as I (Akim) have branches with a lot of
|
||||
changes in this area (hitting several files), and no desire to have to fix
|
||||
conflicts. Addressing these items will happen after my branches have been
|
||||
merged.
|
||||
|
||||
*** lalr.c
|
||||
Introduce a goto struct, and use it in place of from_state/to_state.
|
||||
Rename states1 as path, length as pathlen.
|
||||
Introduce inline functions for things such as nullable[*rp - ntokens]
|
||||
where we need to map from symbol number to nterm number.
|
||||
|
||||
There are probably a significant part of the relations management that
|
||||
should be migrated on top of a bitsetv.
|
||||
|
||||
*** closure
|
||||
It should probably take a "state*" instead of two arguments.
|
||||
|
||||
*** traces
|
||||
The "automaton" and "set" categories are not so useful. We should probably
|
||||
introduce lr(0) and lalr, just the way we have ielr categories. The
|
||||
"closure" function is too verbose, it should probably have its own category.
|
||||
|
||||
"set" can still be used for summariring the important sets. That would make
|
||||
tests easy to maintain.
|
||||
|
||||
*** complain.*
|
||||
Rename these guys as "diagnostics.*" (or "diagnose.*"), since that's the
|
||||
name they have in gcc, clang, etc. Likewise for the complain_* series of
|
||||
functions.
|
||||
|
||||
*** ritem
|
||||
states/nstates, rules/nrules, ..., ritem/nritems
|
||||
Fix the latter.
|
||||
|
||||
* Modernization
|
||||
Fix data/skeletons/yacc.c so that it defines YYPTRDIFF_T properly for modern
|
||||
and older C++ compilers. Currently the code defaults to defining it to
|
||||
'long' for non-GCC compilers, but it should use the proper C++ magic to
|
||||
define it to the same type as the C ptrdiff_t type.
|
||||
|
||||
* Completion
|
||||
Several features are not available in all the backends.
|
||||
@@ -74,24 +194,42 @@ $ ./tests/testsuite -l | grep errors | sed q
|
||||
38: input.at:1730 errors
|
||||
|
||||
* Short term
|
||||
** consistency
|
||||
token vs terminal
|
||||
** Get rid of YYPRINT and b4_toknum
|
||||
Besides yytoknum is wrong when api.token.raw is defined.
|
||||
|
||||
** yacc.c
|
||||
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
|
||||
than duplicating it.
|
||||
** Better design for diagnostics
|
||||
The current implementation of diagnostics is adhoc, it grew organically. It
|
||||
works as a series of calls to several functions, with dependency of the
|
||||
latter calls on the former. For instance:
|
||||
|
||||
** C++
|
||||
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
||||
itself uses int (for yylen for instance), yet stack is based on size_t.
|
||||
complain (&sym->location,
|
||||
sym->content->status == needed ? complaint : Wother,
|
||||
_("symbol %s is used, but is not defined as a token"
|
||||
" and has no rules; did you mean %s?"),
|
||||
quote_n (0, sym->tag),
|
||||
quote_n (1, best->tag));
|
||||
if (feature_flag & feature_caret)
|
||||
location_caret_suggestion (sym->location, best->tag, stderr);
|
||||
|
||||
Maybe locations should also move to ints.
|
||||
We should rewrite this in a more FP way:
|
||||
|
||||
** C
|
||||
Introduce state_type rather than spreading yytype_int16 everywhere?
|
||||
1. build a rich structure that denotes the (complete) diagnostic.
|
||||
"Complete" in the sense that it also contains the suggestions, the list
|
||||
of possible matches, etc.
|
||||
|
||||
** glr.c
|
||||
yyspaceLeft should probably be a pointer diff.
|
||||
2. send this to the pretty-printing routine. The diagnostic structure
|
||||
should be sufficient so that we can generate all the 'format' of
|
||||
diagnostics, including the fixits.
|
||||
|
||||
If properly done, this diagnostic module can be detached from Bison and be
|
||||
put in gnulib. It could be used, for instance, for errors caught by
|
||||
xgettext.
|
||||
|
||||
There's certainly already something alike in GCC. At least that's the
|
||||
impression I get from reading the "-fdiagnostics-format=FORMAT" part of this
|
||||
page:
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
|
||||
|
||||
** Graphviz display code thoughts
|
||||
The code for the --graph option is over two files: print_graph, and
|
||||
@@ -112,9 +250,6 @@ Little effort seems to have been given to factoring these files and their
|
||||
rint{,-xml} counterpart. We would very much like to re-use the pretty format
|
||||
of states from .output for the graphs, etc.
|
||||
|
||||
Also, the underscore in print_graph.[ch] isn't very fitting considering the
|
||||
dashes in the other filenames.
|
||||
|
||||
Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
|
||||
|
||||
** push-parser
|
||||
@@ -171,15 +306,14 @@ class in the printers/destructors, which is not good for an operator<<
|
||||
since it is no longer bound to a particular parser, it's just a
|
||||
(standalone symbol).
|
||||
|
||||
** Rename LR0.cc
|
||||
as lr0.cc, why upper case?
|
||||
|
||||
* Various
|
||||
** Rewrite glr.cc in C++
|
||||
** Rewrite glr.cc in C++ (Valentin Tolmer)
|
||||
As a matter of fact, it would be very interesting to see how much we can
|
||||
share between lalr1.cc and glr.cc. Most of the skeletons should be common.
|
||||
It would be a very nice source of inspiration for the other languages.
|
||||
|
||||
Valentin Tolmer is working on this.
|
||||
|
||||
** YYERRCODE
|
||||
Defined to 256, but not used, not documented. Probably the token
|
||||
number for the error token, which POSIX wants to be 256, but which
|
||||
@@ -249,10 +383,21 @@ other improvements and also made it faster (probably because memory
|
||||
management is performed once instead of three times). I suggest that
|
||||
we do the same in yacc.c.
|
||||
|
||||
(Some time later): it's also very nice to have three stacks: it's more dense
|
||||
as we don't lose bits to padding. For instance the typical stack for states
|
||||
will use 8 bits, while it is likely to consume 32 bits in a struct.
|
||||
|
||||
We need trustworthy benchmarks for Bison, for all our backends. Akim has a
|
||||
few things scattered around; we need to put them in the repo, and make them
|
||||
more useful.
|
||||
|
||||
** yysyntax_error
|
||||
The code bw glr.c and yacc.c is really alike, we can certainly factor
|
||||
some parts.
|
||||
|
||||
This should be worked on when we also address the expected improvements for
|
||||
error generation (e.g., i18n).
|
||||
|
||||
|
||||
* Report
|
||||
|
||||
@@ -263,7 +408,7 @@ grammars she is working on. We should probably also include some
|
||||
information about the variables (I'm not sure for instance we even
|
||||
specify what LR variant was used).
|
||||
|
||||
** GLR
|
||||
** GLR
|
||||
How would Paul like to display the conflicted actions? In particular,
|
||||
what when two reductions are possible on a given lookahead token, but one is
|
||||
part of $default. Should we make the two reductions explicit, or just
|
||||
@@ -292,7 +437,26 @@ LORIA, INRIA Nancy - Grand Est, Nancy, France
|
||||
|
||||
* Extensions
|
||||
** Multiple start symbols
|
||||
Would be very useful when parsing closely related languages.
|
||||
Would be very useful when parsing closely related languages. The idea is to
|
||||
declare several start symbols, for instance
|
||||
|
||||
%start stmt expr
|
||||
%%
|
||||
stmt: ...
|
||||
expr: ...
|
||||
|
||||
and to generate parse(), parse_stmt() and parse_expr(). Technically, the
|
||||
above grammar would be transformed into
|
||||
|
||||
%start yy_start
|
||||
%token YY_START_STMT YY_START_EXPR
|
||||
%%
|
||||
yy_start: YY_START_STMT stmt | YY_START_EXPR expr
|
||||
|
||||
so that there are no new conflicts in the grammar (as would undoubtedly
|
||||
happen with yy_start: stmt | expr). Then adjust the skeletons so that this
|
||||
initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the
|
||||
corresponding parse function.
|
||||
|
||||
** Better error messages
|
||||
The users are not provided with enough tools to forge their error messages.
|
||||
@@ -310,6 +474,12 @@ should make this reasonably easy to implement.
|
||||
Bruce Mardle <[email protected]>
|
||||
https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
|
||||
|
||||
However, there are many other things to do before having such a feature,
|
||||
because I don't want a % equivalent to #include (which we all learned to
|
||||
hate). I want something that builds "modules" of grammars, and assembles
|
||||
them together, paying attention to keep separate bits separated, in pseudo
|
||||
name spaces.
|
||||
|
||||
** Push parsers
|
||||
There is demand for push parsers in Java and C++. And GLR I guess.
|
||||
|
||||
@@ -336,6 +506,10 @@ must be in the scanner: we must not parse what is in a switched off
|
||||
part of %if. Akim Demaille thinks it should be in the parser, so as
|
||||
to avoid falling into another CPP mistake.
|
||||
|
||||
(Later): I'm sure there's actually good case for this. People who need that
|
||||
feature can use m4/cpp on top of Bison. I don't think it is worth the
|
||||
trouble in Bison itself.
|
||||
|
||||
** XML Output
|
||||
There are couple of available extensions of Bison targeting some XML
|
||||
output. Some day we should consider including them. One issue is
|
||||
@@ -355,32 +529,8 @@ XML output for GNU Bison
|
||||
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
|
||||
http://www.cs.cornell.edu/andru/papers/cupex/
|
||||
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules (or "injections", see
|
||||
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
|
||||
transform
|
||||
|
||||
exp: arith | bool;
|
||||
arith: exp '+' exp;
|
||||
bool: exp '&' exp;
|
||||
|
||||
into
|
||||
|
||||
exp: exp '+' exp | exp '&' exp;
|
||||
|
||||
when there are no actions. This can significantly speed up some grammars.
|
||||
I can't find the papers. In particular the book 'LR parsing: Theory and
|
||||
Practice' is impossible to find, but according to 'Parsing Techniques: a
|
||||
Practical Guide', it includes information about this issue. Does anybody
|
||||
have it?
|
||||
|
||||
|
||||
|
||||
* Documentation
|
||||
|
||||
** History/Bibliography
|
||||
Some history of Bison and some bibliography would be most welcome.
|
||||
Are there any Texinfo standards for bibliography?
|
||||
Andrew Myers and Vincent Imbimbo are working on this item, see
|
||||
https://github.com/akimd/bison/issues/12
|
||||
|
||||
* Coding system independence
|
||||
Paul notes:
|
||||
@@ -399,7 +549,7 @@ Paul notes:
|
||||
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
||||
the source code. This should get fixed.
|
||||
|
||||
* Broken options ?
|
||||
* Broken options?
|
||||
** %token-table
|
||||
** Skeleton strategy
|
||||
Must we keep %token-table?
|
||||
@@ -411,6 +561,7 @@ It is unfortunate that there is a total order for precedence. It
|
||||
makes it impossible to have modular precedence information. We should
|
||||
move to partial orders (sounds like series/parallel orders to me).
|
||||
|
||||
This is a prerequisite for modules.
|
||||
|
||||
* $undefined
|
||||
From Hans:
|
||||
@@ -452,23 +603,6 @@ to bison. If you're interested, I'll work on a patch.
|
||||
* Better graphics
|
||||
Equip the parser with a means to create the (visual) parse tree.
|
||||
|
||||
* Complaint submessage indentation.
|
||||
We already have an implementation that works fairly well for named
|
||||
reference messages, but it would be nice to use it consistently for all
|
||||
submessages from Bison. For example, the "previous definition"
|
||||
submessage or the list of correct values for a %define variable might
|
||||
look better with indentation.
|
||||
|
||||
However, the current implementation makes the assumption that the
|
||||
location printed on the first line is not usually much shorter than the
|
||||
locations printed on the submessage lines that follow. That assumption
|
||||
may not hold true as often for some kinds of submessages especially if
|
||||
we ever support multiple grammar files.
|
||||
|
||||
Here's a proposal for how a new implementation might look:
|
||||
|
||||
http://lists.gnu.org/archive/html/bison-patches/2009-09/msg00086.html
|
||||
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
|
||||
@@ -166,7 +166,7 @@ bootstrap_epilogue() { :; }
|
||||
# specified directory. Fill in the first %s with the destination
|
||||
# directory and the second with the domain name.
|
||||
po_download_command_format=\
|
||||
"wget --mirror --level=1 -nd -q -A.po -P '%s' \
|
||||
"wget --mirror --level=1 -nd -nv -A.po -P '%s' \
|
||||
https://translationproject.org/latest/%s/"
|
||||
|
||||
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
||||
|
||||
+20
-23
@@ -17,19 +17,21 @@
|
||||
|
||||
# gnulib modules used by this package.
|
||||
gnulib_modules='
|
||||
argmatch array-list assert
|
||||
argmatch array-list assert assure
|
||||
bitsetv
|
||||
calloc-posix close closeout config-h c-strcase
|
||||
configmake
|
||||
dirname
|
||||
error extensions fdl fopen-safer
|
||||
error extensions
|
||||
fdl fopen-safer fstrcmp
|
||||
getopt-gnu
|
||||
gettext git-version-gen gitlog-to-changelog
|
||||
gpl-3.0 hash inttypes isnan javacomp-script
|
||||
gettext-h git-version-gen gitlog-to-changelog
|
||||
gpl-3.0 intprops inttypes isnan javacomp-script
|
||||
javaexec-script
|
||||
ldexpl
|
||||
libtextstyle-optional
|
||||
malloc-gnu
|
||||
mbswidth
|
||||
mbfile mbswidth
|
||||
non-recursive-gnulib-prefix-hack
|
||||
obstack
|
||||
obstack-printf
|
||||
@@ -44,9 +46,12 @@ gnulib_modules='
|
||||
unistd unistd-safer unlink unlocked-io
|
||||
update-copyright unsetenv verify
|
||||
warnings
|
||||
winsz-ioctl
|
||||
winsz-termios
|
||||
xalloc
|
||||
xalloc-die
|
||||
xconcat-filename
|
||||
xhash
|
||||
xlist
|
||||
xmemdup0
|
||||
xstrndup
|
||||
@@ -55,6 +60,8 @@ gnulib_modules='
|
||||
vsnprintf-posix vsprintf-posix
|
||||
'
|
||||
|
||||
checkout_only_file=README-hacking.md
|
||||
|
||||
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--from-code=UTF-8\\\
|
||||
@@ -67,24 +74,7 @@ XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
||||
--keyword=YY_ \\\
|
||||
'
|
||||
|
||||
# Gettext supplies these files, but we don't need them since
|
||||
# we don't have an intl subdirectory.
|
||||
excluded_files='
|
||||
m4/glibc2.m4
|
||||
m4/intdiv0.m4
|
||||
m4/intl.m4
|
||||
m4/intldir.m4
|
||||
m4/intmax.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lock.m4
|
||||
m4/longdouble.m4
|
||||
m4/signed.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/visibility.m4
|
||||
'
|
||||
|
||||
gnulib_tool_option_extras='--symlink --conditional-dependencies --makefile-name=gnulib.mk'
|
||||
gnulib_tool_option_extras='--symlink --conditional-dependencies --makefile-name=gnulib.mk --po-base=gnulib-po --po-domain=bison'
|
||||
|
||||
bootstrap_post_import_hook()
|
||||
{
|
||||
@@ -102,6 +92,13 @@ bootstrap_epilogue()
|
||||
touch src/parse-gram.[ch]
|
||||
|
||||
perl -pi -e "s/\@PACKAGE\@/$package/g" README-release
|
||||
|
||||
# Bison currently uses Gettext 0.19, but the gnulib-po module
|
||||
# imports files from more recent versions of Gettext that are not
|
||||
# yet available widely enough (e.g., not in bionic, used by the CI).
|
||||
# Work around this. Don't use autopoint, which sends some other
|
||||
# files in the past.
|
||||
cp po/Makefile.in.in gnulib-po
|
||||
}
|
||||
|
||||
# Keep our bootstrap script in sync with gnulib's. If we ever need to
|
||||
|
||||
@@ -27,3 +27,4 @@
|
||||
/install-reloc
|
||||
/reloc-ldflags
|
||||
/relocatable.sh.in
|
||||
/libtool-reloc
|
||||
|
||||
+12
-10
@@ -12,7 +12,7 @@ while (<STDIN>)
|
||||
{
|
||||
if (/^\s* # Initial spaces.
|
||||
(?:(-\w),\s+)? # $1: $short: Possible short option.
|
||||
(--[-\w]+) # $2: $long: Long option.
|
||||
(--[-\w]+) # $2: $long: Mandatory long option.
|
||||
(\[?) # $3: $opt: '[' iff the argument is optional.
|
||||
(?:=(\S+))? # $4: $arg: Possible argument name.
|
||||
\s # Spaces.
|
||||
@@ -32,7 +32,6 @@ while (<STDIN>)
|
||||
# if $opt, $arg contains the closing ].
|
||||
substr ($arg, -1) = ''
|
||||
if $opt eq '[';
|
||||
$arg =~ s/^=//;
|
||||
$arg = lc ($arg);
|
||||
my $dir_arg = $arg;
|
||||
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
|
||||
@@ -72,12 +71,15 @@ while (<STDIN>)
|
||||
my $sep = '';
|
||||
foreach my $long (sort keys %option)
|
||||
{
|
||||
# Avoid trailing spaces.
|
||||
print $sep;
|
||||
$sep = "\n";
|
||||
print '@item @option{', $long, "}\n\@tab";
|
||||
print ' @option{', $option{$long}, '}' if $option{$long};
|
||||
print "\n\@tab";
|
||||
print ' @code{', $directive{$long}, '}' if $directive{$long};
|
||||
print "\n";
|
||||
# Couldn't find a means to escape @ in the format (for @item, @tab), so
|
||||
# pass it as a literal to print.
|
||||
format STDOUT =
|
||||
@item @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @tab @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @tab @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
{
|
||||
'@', '@option{' . $long . '}',
|
||||
'@', $option{$long} ? ('@option{' . $option{$long} . '}') : '',
|
||||
'@', $directive{$long} ? ('@code{' . $directive{$long} . '}') : ''
|
||||
}
|
||||
.
|
||||
write;
|
||||
}
|
||||
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# usage:
|
||||
#
|
||||
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
|
||||
#
|
||||
# from your source tree.
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
def getargs():
|
||||
p = argparse.ArgumentParser(description='Update test cases.')
|
||||
opt = p.add_argument
|
||||
opt('logs', metavar='log', nargs='+', type=str, default=None,
|
||||
help='log files to process')
|
||||
opt('-v', '--verbose', action='store_true',
|
||||
help='Be verbose')
|
||||
return p.parse_args()
|
||||
|
||||
args = getargs()
|
||||
subst = dict()
|
||||
|
||||
|
||||
def trace(*args_):
|
||||
if args.verbose:
|
||||
print(*args_)
|
||||
|
||||
|
||||
def contents(file):
|
||||
'''The contents of a file.'''
|
||||
trace(file)
|
||||
f = open(file)
|
||||
return f.read()
|
||||
|
||||
|
||||
def diff_to_re(match):
|
||||
'''Convert a portion of patch into a regex substitution to perform.
|
||||
No longer used, we now use the expected/effective parts.
|
||||
'''
|
||||
frm = []
|
||||
to = []
|
||||
is_diff = False
|
||||
for l in match.group(1).splitlines():
|
||||
print(l)
|
||||
# t in [-+ ]
|
||||
t = l[0]
|
||||
l = l[1:]
|
||||
if t in ['-', ' ']:
|
||||
is_diff = True
|
||||
frm.append(l)
|
||||
if t in ['+', ' ']:
|
||||
is_diff = True
|
||||
to.append(l)
|
||||
if is_diff:
|
||||
frm = "\n".join(frm)
|
||||
to = "\n".join(to)
|
||||
subst[frm] = to
|
||||
|
||||
|
||||
def update(at_file, logfile):
|
||||
test = contents(at_file)
|
||||
if os.path.isfile(logfile):
|
||||
trace("LOG: ", logfile)
|
||||
l = contents(logfile)
|
||||
trace("LOG: ", l)
|
||||
global subst
|
||||
subst = {}
|
||||
re.sub(r'(?:^@@.*\n)((?:^[-+ ].*\n)+)',
|
||||
diff_to_re, l, flags = re.MULTILINE)
|
||||
print(subst)
|
||||
if subst:
|
||||
# Turn "subst{frm} -> to" into a large RE.
|
||||
frm = '|'.join([re.escape(x) for x in subst])
|
||||
trace("FROM:", frm)
|
||||
test = re.sub("(" + frm + ")",
|
||||
lambda m: subst[m.group(1)],
|
||||
test, flags=re.MULTILINE)
|
||||
open(at_file, 'w').write(test)
|
||||
|
||||
|
||||
def process(logfile):
|
||||
log = contents(logfile)
|
||||
# Look for the file to update.
|
||||
m = re.search(r'^\d+\. ([-\w]+\.at):\d+: ', log, re.MULTILINE)
|
||||
if not m:
|
||||
trace("no diff found:", logfile)
|
||||
return
|
||||
at_file = 'tests/' + m.group(1)
|
||||
print(at_file)
|
||||
update(at_file, logfile)
|
||||
|
||||
for logfile in args.logs:
|
||||
trace("FILE:", logfile)
|
||||
process(logfile)
|
||||
@@ -26,6 +26,9 @@ regen: _version
|
||||
manual_title = The Yacc-compatible Parser Generator
|
||||
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
||||
|
||||
# By default, propagate -j from make to Bison's test suite.
|
||||
TESTSUITEFLAGS = $(filter -j%,$(MAKEFLAGS))
|
||||
|
||||
# It's useful to run maintainer-check* targets during development, but we
|
||||
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
||||
# override the _is-dist-target from GNUmakefile so that maintainer-check*
|
||||
@@ -60,18 +63,6 @@ update-copyright-env = \
|
||||
## More syntax-checks. ##
|
||||
## -------------------- ##
|
||||
|
||||
# At least for Mac OS X's grep, the order between . and [ in "[^.[]"
|
||||
# matters:
|
||||
# $ LC_ALL=fr_FR grep -nE '[^[.]' /dev/null
|
||||
# $ LC_ALL=C grep -nE '[^[.]' /dev/null
|
||||
# grep: invalid collating element or class
|
||||
# $ LC_ALL=fr_FR grep -nE '[^.[]' /dev/null
|
||||
# $ LC_ALL=C grep -nE '[^.[]' /dev/null
|
||||
sc_at_parser_check:
|
||||
@prohibit='AT_PARSER_CHECK\(\[+[^.[]|AT_CHECK\(\[+\./' \
|
||||
halt='use AT_PARSER_CHECK for and only for generated parsers' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Indent only with spaces.
|
||||
# Taken from Coreutils.
|
||||
sc_prohibit_tab_based_indentation:
|
||||
@@ -156,11 +147,16 @@ sc_space_before_open_paren:
|
||||
## syntax-checks exceptions. ##
|
||||
## -------------------------- ##
|
||||
|
||||
# po-check: we use gnulib-po, so we don't need/want them in our POTFILE.
|
||||
generated_files =
|
||||
|
||||
exclude = \
|
||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||
|
||||
$(call exclude, \
|
||||
bindtextdomain=^lib/main.c$$ \
|
||||
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
||||
po_check=(^po/POTFILES.in|.md)$$ \
|
||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||
program_name=^lib/main.c$$ \
|
||||
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||
@@ -169,8 +165,8 @@ $(call exclude,
|
||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
|
||||
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^\.git|Makefile$$ \
|
||||
prohibit_strcmp=^doc/bison\.texi|examples|tests/local\.at$$ \
|
||||
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^\.git|tests/input.at|Makefile$$ \
|
||||
require_config_h=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||
require_config_h_first=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||
space_before_open_paren=^data/skeletons/ \
|
||||
|
||||
+37
-12
@@ -36,6 +36,9 @@ AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# We use Automake 1.14's %D% and %C%.
|
||||
#
|
||||
# When we move to Automake 1.16, simplify examples/c/reccalc/local.mk.
|
||||
# Our CI runs on Xenial, which has only Automake 1.15.
|
||||
#
|
||||
# We want gnits strictness only when rolling a stable release. For
|
||||
# release candidates, we use version strings like 2.4.3_rc1, but gnits
|
||||
# doesn't like that, so we let the underscore disable gnits. Between
|
||||
@@ -94,13 +97,18 @@ AC_ARG_ENABLE([gcc-warnings],
|
||||
[enable_gcc_warnings=no])
|
||||
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
||||
if test "$enable_gcc_warnings" = yes; then
|
||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
|
||||
# -Wno-tautological-constant-out-of-range-compare for Clang 3.3 and
|
||||
# 3.4 on GNU/Linux that choke on intprops.h's INT_MULTIPLY_WRAPV,
|
||||
# etc.
|
||||
warn_common='-Wall -Wextra -Wcast-align
|
||||
-fparse-all-comments -Wdocumentation
|
||||
-Wformat -Wimplicit-fallthrough -Wnull-dereference
|
||||
-Wno-sign-compare -Wno-tautological-constant-out-of-range-compare
|
||||
-Wpointer-arith -Wshadow
|
||||
-Wwrite-strings'
|
||||
warn_c='-Wbad-function-cast -Wstrict-prototypes'
|
||||
warn_cxx='-Wextra-semi -Wnoexcept -Wundefined-func-template -Wweak-vtables'
|
||||
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
|
||||
-Wweak-vtables'
|
||||
# Warnings for the test suite only.
|
||||
#
|
||||
# -fno-color-diagnostics: Clang's use of colors in the error
|
||||
@@ -112,6 +120,7 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
# details for lalr1.cc.
|
||||
warn_tests='-Wundef -pedantic -Wconversion
|
||||
-Wdeprecated -Wsign-compare -Wsign-conversion
|
||||
-Wtautological-constant-out-of-range-compare
|
||||
-fno-color-diagnostics
|
||||
-Wno-keyword-macro'
|
||||
|
||||
@@ -142,8 +151,6 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
|
||||
# Warnings for the test suite, and maybe for bison if GCC is modern
|
||||
# enough.
|
||||
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
|
||||
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
|
||||
test $lv_cv_gcc_pragma_push_works = yes &&
|
||||
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
||||
|
||||
@@ -170,6 +177,14 @@ if test "$enable_gcc_warnings" = yes; then
|
||||
[[if (sizeof (long) < sizeof (int)) return 1;]])])
|
||||
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
||||
[AC_LANG_PROGRAM([], [nullptr])])
|
||||
# Before GCC6, the pragmas don't work well enough to neutralize
|
||||
# this warning.
|
||||
gl_WARN_ADD([-Wuseless-cast], [WARN_CXXFLAGS],
|
||||
[AC_LANG_PROGRAM([], [
|
||||
#if defined __GNUC__ && ! defined __ICC && ! defined __clang__ && __GNUC__ < 6
|
||||
syntax error
|
||||
#endif
|
||||
])])
|
||||
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
||||
# Warnings for the test suite only.
|
||||
for i in $warn_tests;
|
||||
@@ -192,6 +207,7 @@ BISON_CXX_COMPILER_POSIXLY_CORRECT
|
||||
|
||||
# D.
|
||||
AC_CHECK_PROGS([DC], [dmd])
|
||||
AC_CHECK_PROGS([DCFLAGS], [-g])
|
||||
AM_CONDITIONAL([ENABLE_D], [test x"$DC" != x])
|
||||
|
||||
# Java.
|
||||
@@ -210,10 +226,11 @@ AC_CONFIG_FILES([src/yacc], [chmod +x src/yacc])
|
||||
# Checks for programs.
|
||||
AM_MISSING_PROG([DOT], [dot])
|
||||
AC_PROG_LEX
|
||||
$LEX_IS_FLEX || test "X$LEX" = X: || {
|
||||
if ! "$LEX_IS_FLEX" || test "X$LEX" = X:; then
|
||||
AC_MSG_WARN([bypassing lex because flex is required])
|
||||
LEX=:
|
||||
}
|
||||
fi
|
||||
AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX])
|
||||
AM_CONDITIONAL([FLEX_CXX_WORKS],
|
||||
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
|
||||
AC_PROG_YACC
|
||||
@@ -223,9 +240,6 @@ AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
||||
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
|
||||
supports -g, otherwise to "".])
|
||||
AC_PATH_PROG([PERL], [perl])
|
||||
if test -z "$PERL"; then
|
||||
AC_MSG_ERROR([perl not found])
|
||||
fi
|
||||
AM_MISSING_PROG([HELP2MAN], [help2man])
|
||||
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
||||
AC_SUBST([XSLTPROC])
|
||||
@@ -242,14 +256,14 @@ gl_INIT
|
||||
|
||||
# Checks for library functions.
|
||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||
AM_WITH_DMALLOC
|
||||
|
||||
# Gettext.
|
||||
# We use gnulib, which is only guaranteed to work properly with the
|
||||
# latest Gettext.
|
||||
AM_GNU_GETTEXT([external], [need-ngettext])
|
||||
AM_GNU_GETTEXT_VERSION([0.18])
|
||||
AM_GNU_GETTEXT_VERSION([0.19])
|
||||
BISON_I18N
|
||||
AC_CONFIG_FILES([gnulib-po/Makefile.in])
|
||||
|
||||
# Internationalized parsers.
|
||||
AC_CONFIG_FILES([runtime-po/Makefile.in])
|
||||
@@ -271,7 +285,7 @@ uname=`uname`
|
||||
case $VALGRIND:$uname in
|
||||
'':*) ;;
|
||||
*:Darwin)
|
||||
# See README-hacking.
|
||||
# See README-hacking.md.
|
||||
VALGRIND=;;
|
||||
*:*)
|
||||
suppfile=build-aux/$uname.valgrind
|
||||
@@ -294,4 +308,15 @@ AC_SUBST([GCC])
|
||||
AC_CONFIG_FILES([Makefile
|
||||
po/Makefile.in
|
||||
doc/yacc.1])
|
||||
|
||||
# Fix LIBOBJS to give the Makefile the right file names. Otherwise
|
||||
# compilation works, but with unexpected file names, so clean rules don't
|
||||
# remove the actual files and distcheck fails.
|
||||
AC_CONFIG_COMMANDS_PRE([
|
||||
case $am__api_version in
|
||||
1.14*|1.15*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/lib_libbison_a-,g'`;;
|
||||
*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/libbison_a-,g'`;;
|
||||
esac
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -138,9 +138,10 @@ The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||
- `printer`: string
|
||||
- `printer_file`: string
|
||||
- `printer_line`: integer
|
||||
- `printer_loc`: location
|
||||
If the symbol has a printer, everything about it.
|
||||
|
||||
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`
|
||||
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`, `destructor_loc`
|
||||
Likewise.
|
||||
|
||||
### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])`
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Default styling rules for Bison when doing terminal output.
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This is an experimental feature. The class names may change in the
|
||||
future. */
|
||||
|
||||
/* Diagnostics. */
|
||||
.warning { color: purple; }
|
||||
.error { color: red; }
|
||||
.note { color: cyan; }
|
||||
|
||||
.fixit-insert { color: green; }
|
||||
|
||||
/* Semantic values in Bison's own parser traces. */
|
||||
.value { color: green; }
|
||||
|
||||
/* "Sections" in traces (--trace). */
|
||||
.trace0 { color: green; }
|
||||
+2
-1
@@ -15,7 +15,8 @@
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
data/README
|
||||
data/README.md \
|
||||
data/bison-default.css
|
||||
|
||||
skeletonsdir = $(pkgdatadir)/skeletons
|
||||
dist_skeletons_DATA = \
|
||||
|
||||
+35
-28
@@ -192,7 +192,7 @@ m4_define([b4_error],
|
||||
# @warn(1@)
|
||||
# @warn(1@,2@)
|
||||
m4_define([b4_warn],
|
||||
[b4_error([[warn]], [], [], $@)])
|
||||
[b4_warn_at([], [], $@)])
|
||||
|
||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# ---------------------------------------------------
|
||||
@@ -210,7 +210,7 @@ m4_define([b4_warn_at],
|
||||
#
|
||||
# See b4_warn example.
|
||||
m4_define([b4_complain],
|
||||
[b4_error([[complain]], [], [], $@)])
|
||||
[b4_complain_at([], [], $@)])
|
||||
|
||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# -------------------------------------------------------
|
||||
@@ -226,8 +226,7 @@ m4_define([b4_complain_at],
|
||||
#
|
||||
# See b4_warn example.
|
||||
m4_define([b4_fatal],
|
||||
[b4_error([[fatal]], [], [], $@)dnl
|
||||
m4_exit(1)])
|
||||
[b4_fatal_at([], [], $@)])
|
||||
|
||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# ----------------------------------------------------
|
||||
@@ -438,13 +437,6 @@ m4_define([b4_symbol_tag_comment],
|
||||
])
|
||||
|
||||
|
||||
# b4_symbol_action_location(SYMBOL-NUM, KIND)
|
||||
# -------------------------------------------
|
||||
# Report the location of the KIND action as FILE:LINE.
|
||||
m4_define([b4_symbol_action_location],
|
||||
[b4_symbol([$1], [$2_file]):b4_syncline([b4_symbol([$1], [$2_line])])])
|
||||
|
||||
|
||||
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||
# ----------------------------------
|
||||
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
||||
@@ -455,9 +447,9 @@ m4_define([b4_symbol_action],
|
||||
[],
|
||||
[(*yylocationp)])dnl
|
||||
_b4_symbol_case([$1])[]dnl
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;
|
||||
|
||||
b4_dollar_popdef[]dnl
|
||||
@@ -542,7 +534,7 @@ m4_define([b4_token_format],
|
||||
[b4_token_visible_if([$2],
|
||||
[m4_quote(m4_format([$1],
|
||||
[b4_symbol([$2], [id])],
|
||||
[b4_symbol([$2], [user_number])]))])])
|
||||
[b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))]))])])
|
||||
|
||||
|
||||
## ------- ##
|
||||
@@ -586,12 +578,15 @@ m4_define([b4_basename],
|
||||
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
||||
|
||||
|
||||
# b4_syncline(LINE, FILE)
|
||||
# -----------------------
|
||||
# b4_syncline(LINE, FILE)dnl
|
||||
# --------------------------
|
||||
# Should always be following by a dnl.
|
||||
#
|
||||
# Emit "#line LINE FILE /* __LINE__ __FILE__ */".
|
||||
m4_define([b4_syncline],
|
||||
[b4_flag_if([synclines],
|
||||
[b4_sync_start([$1], [$2]) b4_sync_end([__line__],
|
||||
[b4_basename(m4_quote(__file__))])[]dnl
|
||||
[b4_sync_start([$1], [$2])[]dnl
|
||||
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||
])])
|
||||
|
||||
# b4_sync_start(LINE, FILE)
|
||||
@@ -603,7 +598,17 @@ m4_define([b4_sync_start], [b4_comment([$2:$1])])
|
||||
# -----------------------
|
||||
# Syncline for the current place, which ends. Typically a comment
|
||||
# left for the reader.
|
||||
m4_define([b4_sync_end], [b4_comment([$2:$1])])
|
||||
m4_define([b4_sync_end], [ b4_comment([$2:$1])]
|
||||
)
|
||||
# This generates dependencies on the Bison skeletons hence lots of
|
||||
# useless 'git diff'. This location is useless for the regular
|
||||
# user (who does not care about the skeletons) and is actually not
|
||||
# useful for Bison developpers too (I, Akim, never used this to locate
|
||||
# the code in skeletons that generated output). So disable it
|
||||
# completely. If someone thinks this was actually useful, a %define
|
||||
# variable should be provided to control the level of verbosity of
|
||||
# '#line', in replacement of --no-lines.
|
||||
m4_define([b4_sync_end])
|
||||
|
||||
|
||||
# b4_user_code(USER-CODE)
|
||||
@@ -753,8 +758,10 @@ m4_define([b4_percent_define_get_kind],
|
||||
[m4_indir([b4_percent_define_kind(]$1[)])],
|
||||
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
||||
|
||||
# b4_percent_define_get_syncline(VARIABLE)
|
||||
# ----------------------------------------
|
||||
# b4_percent_define_get_syncline(VARIABLE)dnl
|
||||
# -------------------------------------------
|
||||
# Should always be following by a dnl.
|
||||
#
|
||||
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.
|
||||
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
||||
# since that's a Bison or skeleton error. Otherwise, return its definition
|
||||
@@ -968,10 +975,9 @@ m4_define([b4_percent_code_get],
|
||||
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
||||
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
||||
m4_ifdef(b4_macro_name,
|
||||
[b4_comment([m4_if([$#], [0], [[Unqualified %code]],
|
||||
[["%code ]$1["]])[ blocks.]])
|
||||
b4_user_code([m4_indir(b4_macro_name)])
|
||||
])dnl
|
||||
[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]],
|
||||
[[["%code ]$1[" blocks.]]]))
|
||||
b4_user_code([m4_indir(b4_macro_name)])])dnl
|
||||
m4_popdef([b4_macro_name])])
|
||||
|
||||
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
||||
@@ -995,6 +1001,7 @@ m4_define([b4_percent_code_ifdef],
|
||||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
||||
# ----------------------------------------------------------
|
||||
b4_percent_define_if_define([api.token.raw])
|
||||
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||
b4_percent_define_if_define([parse.assert])
|
||||
@@ -1071,10 +1078,10 @@ m4_define_default([b4_location_initial_line], [1])
|
||||
## Sanity checks. ##
|
||||
## --------------- ##
|
||||
|
||||
# api.location.prefix={...} (Java and C++).
|
||||
# api.location.type={...} (C, C++ and Java).
|
||||
b4_percent_define_check_kind([api.location.type], [code], [deprecated])
|
||||
|
||||
# api.position.prefix={...} (Java).
|
||||
# api.position.type={...} (Java).
|
||||
b4_percent_define_check_kind([api.position.type], [code], [deprecated])
|
||||
|
||||
# api.prefix >< %name-prefix.
|
||||
|
||||
+12
-30
@@ -147,13 +147,13 @@ m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
||||
[[namespace reference has a trailing "::"]])])
|
||||
|
||||
m4_define([b4_namespace_open],
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
||||
[^\(.\)[ ]*::], [\1])),
|
||||
[::], [ { namespace ])[ {]])])
|
||||
|
||||
m4_define([b4_namespace_close],
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||
[\1])),
|
||||
@@ -194,7 +194,7 @@ m4_define([b4_value_type_declare],
|
||||
[union\|union-directive],
|
||||
[[ union semantic_type
|
||||
{
|
||||
]b4_user_union_members[
|
||||
]b4_user_union_members[
|
||||
};]])])dnl
|
||||
])
|
||||
|
||||
@@ -367,9 +367,6 @@ m4_define([b4_symbol_type_define],
|
||||
/// \a empty when empty.
|
||||
symbol_number_type type_get () const YY_NOEXCEPT;
|
||||
|
||||
/// The token.
|
||||
token_type token () const YY_NOEXCEPT;
|
||||
|
||||
/// The symbol type.
|
||||
/// \a empty_symbol when empty.
|
||||
/// An int, not token_number_type, to be able to store empty_symbol.
|
||||
@@ -498,22 +495,7 @@ m4_define([b4_public_types_define],
|
||||
{
|
||||
return type;
|
||||
}
|
||||
]b4_token_ctor_if([[
|
||||
]b4_inline([$1])b4_parser_class[::token_type
|
||||
]b4_parser_class[::by_type::token () const YY_NOEXCEPT
|
||||
{
|
||||
// YYTOKNUM[NUM] -- (External) token number corresponding to the
|
||||
// (internal) symbol number NUM (which must be that of a token). */
|
||||
static
|
||||
const ]b4_int_type_for([b4_toknum])[
|
||||
yytoken_number_[] =
|
||||
{
|
||||
]b4_toknum[
|
||||
};
|
||||
return token_type (yytoken_number_[type]);
|
||||
}
|
||||
]])[]dnl
|
||||
])
|
||||
]])
|
||||
|
||||
|
||||
# b4_token_constructor_define
|
||||
@@ -529,10 +511,11 @@ m4_define([b4_token_constructor_define], [])
|
||||
# sometimes in the cc file.
|
||||
m4_define([b4_yytranslate_define],
|
||||
[ b4_inline([$1])b4_parser_class[::token_number_type
|
||||
]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type],
|
||||
[int])[ t)
|
||||
]b4_parser_class[::yytranslate_ (int t)
|
||||
{
|
||||
// YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
]b4_api_token_raw_if(
|
||||
[[ return static_cast<token_number_type> (t);]],
|
||||
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
// TOKEN-NUM as returned by yylex.
|
||||
static
|
||||
const token_number_type
|
||||
@@ -540,15 +523,14 @@ m4_define([b4_yytranslate_define],
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
const unsigned user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
const token_number_type undef_token_ = ]b4_undef_token_number[;
|
||||
const int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
|
||||
if (static_cast<int> (t) <= yyeof_)
|
||||
if (t <= 0)
|
||||
return yyeof_;
|
||||
else if (static_cast<unsigned> (t) <= user_token_number_max_)
|
||||
else if (t <= user_token_number_max_)
|
||||
return translate_table[t];
|
||||
else
|
||||
return undef_token_;
|
||||
return yy_undef_token_;]])[
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
+156
-48
@@ -167,38 +167,110 @@ b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
# Return a narrow int type able to handle integers ranging from MIN
|
||||
# to MAX (included) in portable C code. Assume MIN and MAX fall in
|
||||
# 'int' range.
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||
b4_ints_in($@, [-128], [127]), [1], [signed char],
|
||||
[m4_if(b4_ints_in($@, [-127], [127]), [1], [signed char],
|
||||
b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||
|
||||
b4_ints_in($@, [-32767], [32767]), [1], [short],
|
||||
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
|
||||
m4_eval([0 <= $1]), [1], [unsigned],
|
||||
|
||||
[int])])
|
||||
|
||||
# b4_c99_int_type(MIN, MAX)
|
||||
# -------------------------
|
||||
# Like b4_int_type, but for C99.
|
||||
# b4_c99_int_type_define replaces b4_int_type with this.
|
||||
m4_define([b4_c99_int_type],
|
||||
[m4_if(b4_ints_in($@, [-127], [127]), [1], [yytype_int8],
|
||||
b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
||||
|
||||
b4_ints_in($@, [-32767], [32767]), [1], [yytype_int16],
|
||||
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
|
||||
|
||||
[int])])
|
||||
|
||||
# b4_c99_int_type_define
|
||||
# ----------------------
|
||||
# Define private types suitable for holding small integers in C99 or later.
|
||||
m4_define([b4_c99_int_type_define],
|
||||
[m4_copy_force([b4_c99_int_type], [b4_int_type])dnl
|
||||
[/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
|
||||
<limits.h> and (if available) <stdint.h> are included
|
||||
so that the code can choose integer types of a good width. */
|
||||
|
||||
#ifndef __PTRDIFF_MAX__
|
||||
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_STDINT_H
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Narrow types that promote to a signed type and that can represent a
|
||||
signed or unsigned integer of at least N bits. In tables they can
|
||||
save space and decrease cache pressure. Promoting to a signed type
|
||||
helps avoid bugs in integer arithmetic. */
|
||||
|
||||
#ifdef __INT_LEAST8_MAX__
|
||||
typedef __INT_LEAST8_TYPE__ yytype_int8;
|
||||
#elif defined YY_STDINT_H
|
||||
typedef int_least8_t yytype_int8;
|
||||
#else
|
||||
typedef signed char yytype_int8;
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST16_MAX__
|
||||
typedef __INT_LEAST16_TYPE__ yytype_int16;
|
||||
#elif defined YY_STDINT_H
|
||||
typedef int_least16_t yytype_int16;
|
||||
#else
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
|
||||
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
|
||||
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
|
||||
&& UINT_LEAST8_MAX <= INT_MAX)
|
||||
typedef uint_least8_t yytype_uint8;
|
||||
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
|
||||
typedef unsigned char yytype_uint8;
|
||||
#else
|
||||
typedef short yytype_uint8;
|
||||
#endif
|
||||
|
||||
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
|
||||
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
|
||||
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
|
||||
&& UINT_LEAST16_MAX <= INT_MAX)
|
||||
typedef uint_least16_t yytype_uint16;
|
||||
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
|
||||
typedef unsigned short yytype_uint16;
|
||||
#else
|
||||
typedef int yytype_uint16;
|
||||
#endif]])
|
||||
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# Return a narrow int type able to handle numbers ranging from
|
||||
# 'NAME_min' to 'NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
|
||||
# b4_table_value_equals(TABLE, VALUE, LITERAL)
|
||||
# --------------------------------------------
|
||||
# b4_table_value_equals(TABLE, VALUE, LITERAL, SYMBOL)
|
||||
# ----------------------------------------------------
|
||||
# Without inducing a comparison warning from the compiler, check if the
|
||||
# literal value LITERAL equals VALUE from table TABLE, which must have
|
||||
# TABLE_min and TABLE_max defined.
|
||||
# TABLE_min and TABLE_max defined. SYMBOL denotes
|
||||
m4_define([b4_table_value_equals],
|
||||
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
||||
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
||||
[[0]],
|
||||
[(!!(($2) == ($3)))])])
|
||||
[(($2) == $4)])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
@@ -210,37 +282,39 @@ m4_define([b4_table_value_equals],
|
||||
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
||||
# _Noreturn.
|
||||
m4_define([b4_attribute_define],
|
||||
[[#ifndef YY_ATTRIBUTE
|
||||
# if (defined __GNUC__ \
|
||||
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|
||||
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
|
||||
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
|
||||
[[#ifndef YY_ATTRIBUTE_PURE
|
||||
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
||||
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
# else
|
||||
# define YY_ATTRIBUTE(Spec) /* empty */
|
||||
# define YY_ATTRIBUTE_PURE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YY_ATTRIBUTE_PURE
|
||||
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
|
||||
#endif
|
||||
|
||||
#ifndef YY_ATTRIBUTE_UNUSED
|
||||
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
|
||||
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
|
||||
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define YY_ATTRIBUTE_UNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
||||
#if ! defined _Noreturn
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
]dnl This is an exact copy of lib/_Noreturn.h.
|
||||
[#ifndef _Noreturn
|
||||
# if (defined __cplusplus \
|
||||
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
|
||||
# define _Noreturn [[noreturn]]
|
||||
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
|
||||
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|
||||
|| 0x5110 <= __SUNPRO_C)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif defined _MSC_VER && 1200 <= _MSC_VER
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
# elif ((!defined __cplusplus || defined __clang__) \
|
||||
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
|
||||
/* _Noreturn works as-is. */
|
||||
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -253,11 +327,11 @@ m4_define([b4_attribute_define],
|
||||
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#else
|
||||
# define YY_INITIAL_VALUE(Value) Value
|
||||
@@ -269,9 +343,36 @@ m4_define([b4_attribute_define],
|
||||
#ifndef YY_INITIAL_VALUE
|
||||
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
|
||||
# define YY_IGNORE_USELESS_CAST_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
|
||||
# define YY_IGNORE_USELESS_CAST_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#endif
|
||||
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
|
||||
# define YY_IGNORE_USELESS_CAST_BEGIN
|
||||
# define YY_IGNORE_USELESS_CAST_END
|
||||
#endif
|
||||
]])
|
||||
|
||||
|
||||
# b4_cast_define
|
||||
# --------------
|
||||
m4_define([b4_cast_define],
|
||||
[# ifndef YY_CAST
|
||||
# ifdef __cplusplus
|
||||
# define YY_CAST(Type, Val) static_cast<Type> (Val)
|
||||
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
|
||||
# else
|
||||
# define YY_CAST(Type, Val) ((Type) (Val))
|
||||
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
|
||||
# endif
|
||||
# endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_null_define
|
||||
# --------------
|
||||
# Portability issues: define a YY_NULLPTR appropriate for the current
|
||||
@@ -470,7 +571,7 @@ m4_define([b4_sync_start], [[#]line $1 $2])
|
||||
m4_define([b4_case],
|
||||
[ case $1:
|
||||
$2
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;])
|
||||
|
||||
|
||||
@@ -480,7 +581,7 @@ m4_define([b4_predicate_case],
|
||||
[ case $1:
|
||||
if (! (
|
||||
$2)) YYERROR;
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;])
|
||||
|
||||
|
||||
@@ -540,8 +641,12 @@ m4_if(b4_skeleton, ["yacc.c"],
|
||||
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
||||
# endif
|
||||
]])dnl
|
||||
b4_symbol_actions([printer])[
|
||||
}
|
||||
b4_percent_code_get([[pre-printer]])dnl
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
b4_symbol_actions([printer])
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
b4_percent_code_get([[post-printer]])dnl
|
||||
[}
|
||||
|
||||
|
||||
/*---------------------------.
|
||||
@@ -709,13 +814,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
|
||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||
[union\|union-directive],
|
||||
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
||||
union ]b4_percent_define_get([[api.value.union.name]])[
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||
[union ]b4_percent_define_get([[api.value.union.name]])[
|
||||
{
|
||||
]b4_user_union_members[
|
||||
};
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
||||
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||
[typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
||||
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
||||
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||
#endif
|
||||
@@ -726,7 +831,10 @@ typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[S
|
||||
# -----------------------
|
||||
m4_define([b4_location_type_define],
|
||||
[[/* Location type. */
|
||||
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||
]b4_percent_define_ifdef([[api.location.type]],
|
||||
[[typedef ]b4_percent_define_get([[api.location.type]])[ ]b4_api_PREFIX[LTYPE;
|
||||
]],
|
||||
[[#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
||||
struct ]b4_api_PREFIX[LTYPE
|
||||
{
|
||||
@@ -738,7 +846,7 @@ struct ]b4_api_PREFIX[LTYPE
|
||||
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
||||
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
]])
|
||||
]])])
|
||||
|
||||
|
||||
# b4_declare_yylstype
|
||||
|
||||
+24
-12
@@ -18,11 +18,29 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# b4_comment(TEXT)
|
||||
# ----------------
|
||||
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
||||
], [
|
||||
]) */])
|
||||
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
||||
# --------------------------------------
|
||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||
# Avoid adding indentation to the first line, as the indentation comes
|
||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||
#
|
||||
# Prefix all the output lines with PREFIX.
|
||||
m4_define([_b4_comment],
|
||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
||||
\(.\)], [
|
||||
$3\1])$4])
|
||||
|
||||
|
||||
# b4_comment(TEXT, [PREFIX])
|
||||
# --------------------------
|
||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment],
|
||||
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
|
||||
|
||||
|
||||
# b4_sync_start(LINE, FILE)
|
||||
# -------------------------
|
||||
m4_define([b4_sync_start], [[#]line $1 $2])
|
||||
|
||||
|
||||
# b4_list2(LIST1, LIST2)
|
||||
@@ -82,12 +100,6 @@ m4_define([b4_location_type_if],
|
||||
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_locations_if(TRUE, FALSE)
|
||||
# ----------------------------
|
||||
m4_define([b4_locations_if],
|
||||
[m4_if(b4_locations_flag, 1, [$1], [$2])])
|
||||
|
||||
|
||||
# b4_identification
|
||||
# -----------------
|
||||
m4_define([b4_identification],
|
||||
@@ -177,7 +189,7 @@ b4_percent_define_default([[stype]], [[YYSemanticType]])])
|
||||
# %name-prefix
|
||||
m4_define_default([b4_prefix], [[YY]])
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]YYParser])])
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])])
|
||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
#b4_percent_define_default([[location_type]], [Location])])
|
||||
|
||||
+298
-260
File diff suppressed because it is too large
Load Diff
+22
-8
@@ -100,8 +100,8 @@ m4_defn([b4_initial_action])]))])[
|
||||
|
||||
# Hijack the post prologue to declare yyerror.
|
||||
]m4_append([b4_post_prologue],
|
||||
[b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_function_declare([yyerror],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
b4_function_declare([yyerror],
|
||||
[static void],b4_locations_if([
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||
[yylocationp]],])
|
||||
@@ -128,8 +128,8 @@ m4_if(b4_prefix, [yy], [],
|
||||
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||
# functions etc.).
|
||||
m4_append([b4_epilogue],
|
||||
[b4_syncline([@oline@], [@ofile@])[
|
||||
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
[
|
||||
/*------------------.
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
@@ -234,7 +234,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
|
||||
#endif
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
b4_namespace_close
|
||||
b4_namespace_close[]dnl
|
||||
])
|
||||
|
||||
|
||||
@@ -257,6 +257,20 @@ b4_percent_code_get([[requires]])[
|
||||
]b4_attribute_define[
|
||||
]b4_null_define[
|
||||
|
||||
// This skeleton is based on C, yet compiles it as C++.
|
||||
// So expect warnings about C style casts.
|
||||
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
|
||||
# pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
|
||||
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
||||
// -pedantic reports as being a C++11 extension.
|
||||
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L && 4 <= __clang_major__
|
||||
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
||||
#endif
|
||||
|
||||
// Whether we are compiled with exception support.
|
||||
#ifndef YY_EXCEPTIONS
|
||||
# if defined __GNUC__ && !defined __EXCEPTIONS
|
||||
@@ -351,15 +365,15 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
])
|
||||
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
[b4_output_begin([b4_spec_header_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
[2002-2015, 2018-2019])[
|
||||
// C++ GLR parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_cpp_guard_open([b4_spec_header_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]b4_cpp_guard_close([b4_spec_header_file])[
|
||||
]b4_output_end])
|
||||
|
||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||
|
||||
+13
-2
@@ -184,8 +184,19 @@ b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
||||
|
||||
# %name-prefix
|
||||
m4_define_default([b4_prefix], [[YY]])
|
||||
# b4_api_prefix, b4_api_PREFIX
|
||||
# ----------------------------
|
||||
# Corresponds to %define api.prefix
|
||||
b4_percent_define_default([[api.prefix]], [[YY]])
|
||||
m4_define([b4_api_prefix],
|
||||
[b4_percent_define_get([[api.prefix]])])
|
||||
m4_define([b4_api_PREFIX],
|
||||
[m4_toupper(b4_api_prefix)])
|
||||
|
||||
# b4_prefix
|
||||
# ---------
|
||||
# If the %name-prefix is not given, it is api.prefix.
|
||||
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])
|
||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
+270
-54
@@ -20,14 +20,22 @@ m4_include(b4_skeletonsdir/[c++.m4])
|
||||
# api.value.type=variant is valid.
|
||||
m4_define([b4_value_type_setup_variant])
|
||||
|
||||
# Check the value of %define parse.lac, where LAC stands for lookahead
|
||||
# correction.
|
||||
b4_percent_define_default([[parse.lac]], [[none]])
|
||||
b4_define_flag_if([lac])
|
||||
m4_define([b4_lac_flag],
|
||||
[m4_if(b4_percent_define_get([[parse.lac]]),
|
||||
[none], [[0]], [[1]])])
|
||||
|
||||
|
||||
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
||||
# --------------------------------------------------------------
|
||||
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
||||
m4_define([b4_integral_parser_table_declare],
|
||||
[m4_ifval([$3], [b4_comment([$3], [ ])
|
||||
[m4_ifval([$3], [b4_comment([$3], [ ])
|
||||
])dnl
|
||||
static const b4_int_type_for([$2]) yy$1_[[]];dnl
|
||||
static const b4_int_type_for([$2]) yy$1_[[]];dnl
|
||||
])
|
||||
|
||||
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
||||
@@ -111,9 +119,9 @@ b4_dollar_pushdef([yysym.value],
|
||||
[],
|
||||
[yysym.location])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])])dnl
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;
|
||||
|
||||
m4_popdef([b4_symbol_value])[]dnl
|
||||
@@ -166,6 +174,7 @@ m4_define([b4_shared_declarations],
|
||||
]b4_variant_if([b4_variant_includes])[
|
||||
|
||||
]b4_attribute_define[
|
||||
]b4_cast_define[
|
||||
]b4_null_define[
|
||||
|
||||
]b4_YYDEBUG_define[
|
||||
@@ -220,10 +229,21 @@ m4_define([b4_shared_declarations],
|
||||
private:
|
||||
/// This class is not copyable.
|
||||
]b4_parser_class[ (const ]b4_parser_class[&);
|
||||
]b4_parser_class[& operator= (const ]b4_parser_class[&);
|
||||
]b4_parser_class[& operator= (const ]b4_parser_class[&);]b4_lac_if([[
|
||||
|
||||
/// State numbers.
|
||||
typedef int state_type;
|
||||
/// Check the lookahead yytoken.
|
||||
/// \returns true iff the token will be eventually shifted.
|
||||
bool yy_lac_check_ (int yytoken) const;
|
||||
/// Establish the initial context if no initial context currently exists.
|
||||
/// \returns true iff the token will be eventually shifted.
|
||||
bool yy_lac_establish_ (int yytoken);
|
||||
/// Discard any previous initial lookahead context because of event.
|
||||
/// \param event the event which caused the lookahead to be discarded.
|
||||
/// Only used for debbuging output.
|
||||
void yy_lac_discard_ (const char* event);]])[
|
||||
|
||||
/// Stored state numbers (used for stacks).
|
||||
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ state_type;
|
||||
|
||||
/// Generate an error message.
|
||||
/// \param yystate the state where the error occurred.
|
||||
@@ -234,7 +254,7 @@ m4_define([b4_shared_declarations],
|
||||
/// Compute post-reduction state.
|
||||
/// \param yystate the current state
|
||||
/// \param yysym the nonterminal to push on the stack
|
||||
state_type yy_lr_goto_state_ (state_type yystate, int yysym);
|
||||
static state_type yy_lr_goto_state_ (state_type yystate, int yysym);
|
||||
|
||||
/// Whether the given \c yypact_ value indicates a defaulted state.
|
||||
/// \param yyvalue the value to check
|
||||
@@ -248,7 +268,9 @@ m4_define([b4_shared_declarations],
|
||||
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
|
||||
|
||||
/// Convert a scanner token number \a t to a symbol number.
|
||||
static token_number_type yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t);
|
||||
/// In theory \a t should be a token_type, but character literals
|
||||
/// are valid, yet not members of the token_type enum.
|
||||
static token_number_type yytranslate_ (int t);
|
||||
|
||||
// Tables.
|
||||
]b4_parser_tables_declare[]b4_error_verbose_if([
|
||||
@@ -313,7 +335,8 @@ m4_define([b4_shared_declarations],
|
||||
symbol_number_type type_get () const YY_NOEXCEPT;
|
||||
|
||||
/// The state number used to denote an empty symbol.
|
||||
enum { empty_state = -1 };
|
||||
/// We use the initial state, as it does not have a value.
|
||||
enum { empty_state = 0 };
|
||||
|
||||
/// The state.
|
||||
/// \a empty when empty.
|
||||
@@ -335,6 +358,10 @@ m4_define([b4_shared_declarations],
|
||||
/// Assignment, needed by push_back by some old implementations.
|
||||
/// Moves the contents of that.
|
||||
stack_symbol_type& operator= (stack_symbol_type& that);
|
||||
|
||||
/// Assignment, needed by push_back by other implementations.
|
||||
/// Needed by some other old implementations.
|
||||
stack_symbol_type& operator= (const stack_symbol_type& that);
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -344,7 +371,16 @@ m4_define([b4_shared_declarations],
|
||||
typedef stack<stack_symbol_type> stack_type;
|
||||
|
||||
/// The stack.
|
||||
stack_type yystack_;
|
||||
stack_type yystack_;]b4_lac_if([[
|
||||
/// The stack for LAC.
|
||||
/// Logically, the yy_lac_stack's lifetime is confined to the function
|
||||
/// yy_lac_check_. We just store it as a member of this class to hold
|
||||
/// on to the memory and to avoid frequent reallocations.
|
||||
/// Since yy_lac_check_ is const, this member must be mutable.
|
||||
mutable std::vector<state_type> yylac_stack_;
|
||||
/// Whether an initial LAC context was established.
|
||||
bool yy_lac_established_;
|
||||
]])[
|
||||
|
||||
/// Push a new state on the stack.
|
||||
/// \param m a debug message to display
|
||||
@@ -364,6 +400,10 @@ m4_define([b4_shared_declarations],
|
||||
/// Pop \a n symbols from the stack.
|
||||
void yypop_ (int n = 1);
|
||||
|
||||
/// Some specific tokens.
|
||||
static const token_number_type yy_error_token_ = 1;
|
||||
static const token_number_type yy_undef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
/// Constants.
|
||||
enum
|
||||
{
|
||||
@@ -371,8 +411,6 @@ m4_define([b4_shared_declarations],
|
||||
yylast_ = ]b4_last[, ///< Last index in yytable_.
|
||||
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
|
||||
yyfinal_ = ]b4_final_state_number[, ///< Termination state number.
|
||||
yyterror_ = 1,
|
||||
yyerrcode_ = 256,
|
||||
yyntokens_ = ]b4_tokens_number[ ///< Number of tokens.
|
||||
};
|
||||
|
||||
@@ -399,22 +437,22 @@ m4_define([b4_shared_declarations],
|
||||
## -------------- ##
|
||||
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
[b4_output_begin([b4_spec_header_file])
|
||||
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
|
||||
[
|
||||
/**
|
||||
** \file ]b4_spec_defines_file[
|
||||
** \file ]b4_spec_header_file[
|
||||
** Define the ]b4_namespace_ref[::parser class.
|
||||
*/
|
||||
|
||||
// C++ LALR(1) parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_cpp_guard_open([b4_spec_header_file])[
|
||||
]b4_shared_declarations(hh)[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])
|
||||
b4_output_end
|
||||
])
|
||||
]b4_cpp_guard_close([b4_spec_header_file])[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
@@ -428,7 +466,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
|
||||
]b4_user_pre_prologue[
|
||||
|
||||
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
||||
]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
|
||||
[b4_shared_declarations([cc])])[
|
||||
|
||||
]b4_user_post_prologue[
|
||||
@@ -459,9 +497,6 @@ m4_if(b4_prefix, [yy], [],
|
||||
[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
|
||||
]b4_yylloc_default_define])[
|
||||
|
||||
// Suppress unused-variable warnings by "using" E.
|
||||
#define YYUSE(E) ((void) (E))
|
||||
|
||||
// Enable debugging if requested.
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
|
||||
@@ -551,12 +586,14 @@ m4_if(b4_prefix, [yy], [],
|
||||
]])[
|
||||
|
||||
/// Build a parser object.
|
||||
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||
:])[
|
||||
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
||||
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||
#endif]b4_parse_param_cons[
|
||||
: yydebug_ (false),
|
||||
yycdebug_ (&std::cerr)]b4_lac_if([,], [m4_ifset([b4_parse_param], [,])])[
|
||||
#else
|
||||
]b4_lac_if([ :], [m4_ifset([b4_parse_param], [ :])])[
|
||||
#endif]b4_lac_if([[
|
||||
yy_lac_established_ (false)]m4_ifset([b4_parse_param], [,])])[]b4_parse_param_cons[
|
||||
{}
|
||||
|
||||
]b4_parser_class::~b4_parser_class[ ()
|
||||
@@ -630,6 +667,17 @@ m4_if(b4_prefix, [yy], [],
|
||||
}
|
||||
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
]b4_parser_class[::stack_symbol_type&
|
||||
]b4_parser_class[::stack_symbol_type::operator= (const stack_symbol_type& that)
|
||||
{
|
||||
state = that.state;
|
||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
||||
[value], [copy], [that.value])],
|
||||
[[value = that.value;]])[]b4_locations_if([
|
||||
location = that.location;])[
|
||||
return *this;
|
||||
}
|
||||
|
||||
]b4_parser_class[::stack_symbol_type&
|
||||
]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that)
|
||||
{
|
||||
@@ -761,7 +809,6 @@ m4_if(b4_prefix, [yy], [],
|
||||
int
|
||||
]b4_parser_class[::parse ()
|
||||
{
|
||||
// State.
|
||||
int yyn;
|
||||
/// Length of the RHS of the rule being reduced.
|
||||
int yylen = 0;
|
||||
@@ -777,7 +824,11 @@ m4_if(b4_prefix, [yy], [],
|
||||
stack_symbol_type yyerror_range[3];]])[
|
||||
|
||||
/// The return value of parse ().
|
||||
int yyresult;
|
||||
int yyresult;]b4_lac_if([[
|
||||
|
||||
/// Discard the LAC context in case there still is one left from a
|
||||
/// previous invocation.
|
||||
yy_lac_discard_ ("init");]])[
|
||||
|
||||
#if YY_EXCEPTIONS
|
||||
try
|
||||
@@ -801,7 +852,7 @@ b4_dollar_popdef])[]dnl
|
||||
| yynewstate -- push a new symbol on the stack. |
|
||||
`-----------------------------------------------*/
|
||||
yynewstate:
|
||||
YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
|
||||
YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
|
||||
|
||||
// Accept?
|
||||
if (yystack_[0].state == yyfinal_)
|
||||
@@ -846,14 +897,21 @@ b4_dollar_popdef])[]dnl
|
||||
to detect an error, take that action. */
|
||||
yyn += yyla.type_get ();
|
||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
|
||||
goto yydefault;
|
||||
{]b4_lac_if([[
|
||||
if (!yy_lac_establish_ (yyla.type_get ()))
|
||||
goto yyerrlab;]])[
|
||||
goto yydefault;
|
||||
}
|
||||
|
||||
// Reduce or error.
|
||||
yyn = yytable_[yyn];
|
||||
if (yyn <= 0)
|
||||
{
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
goto yyerrlab;
|
||||
goto yyerrlab;]b4_lac_if([[
|
||||
if (!yy_lac_establish_ (yyla.type_get ()))
|
||||
goto yyerrlab;
|
||||
]])[
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
@@ -863,7 +921,8 @@ b4_dollar_popdef])[]dnl
|
||||
--yyerrstatus_;
|
||||
|
||||
// Shift the lookahead token.
|
||||
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
|
||||
yypush_ ("Shifting", static_cast<state_type> (yyn), YY_MOVE (yyla));]b4_lac_if([[
|
||||
yy_lac_discard_ ("shift");]])[
|
||||
goto yynewstate;
|
||||
|
||||
|
||||
@@ -1001,8 +1060,8 @@ b4_dollar_popdef])[]dnl
|
||||
yyn = yypact_[yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
yyn += yy_error_token_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -1023,8 +1082,9 @@ b4_dollar_popdef])[]dnl
|
||||
yyerror_range[2].location = yyla.location;
|
||||
YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
|
||||
|
||||
// Shift the error token.
|
||||
error_token.state = yyn;
|
||||
// Shift the error token.]b4_lac_if([[
|
||||
yy_lac_discard_ ("error recovery");]])[
|
||||
error_token.state = static_cast<state_type> (yyn);
|
||||
yypush_ ("Shifting", YY_MOVE (error_token));
|
||||
}
|
||||
goto yynewstate;
|
||||
@@ -1088,8 +1148,147 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
error (]b4_join(b4_locations_if([yyexc.location]),
|
||||
[[yyexc.what ()]])[);
|
||||
}]b4_lac_if([[
|
||||
|
||||
bool
|
||||
]b4_parser_class[::yy_lac_check_ (int yytoken) const
|
||||
{
|
||||
// Logically, the yylac_stack's lifetime is confined to this function.
|
||||
// Clear it, to get rid of potential left-overs from previous call.
|
||||
yylac_stack_.clear ();
|
||||
// Reduce until we encounter a shift and thereby accept the token.
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
YYCDEBUG << "LAC: checking lookahead " << yytname_[yytoken] << ':';
|
||||
#endif
|
||||
std::ptrdiff_t lac_top = 0;
|
||||
while (true)
|
||||
{
|
||||
state_type top_state = (yylac_stack_.empty ()
|
||||
? yystack_[lac_top].state
|
||||
: yylac_stack_.back ());
|
||||
int yyrule = yypact_[top_state];
|
||||
if (yy_pact_value_is_default_ (yyrule)
|
||||
|| (yyrule += yytoken) < 0 || yylast_ < yyrule
|
||||
|| yycheck_[yyrule] != yytoken)
|
||||
{
|
||||
// Use the default action.
|
||||
yyrule = yydefact_[top_state];
|
||||
if (yyrule == 0)
|
||||
{
|
||||
YYCDEBUG << " Err\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the action from yytable.
|
||||
yyrule = yytable_[yyrule];
|
||||
if (yy_table_value_is_error_ (yyrule))
|
||||
{
|
||||
YYCDEBUG << " Err\n";
|
||||
return false;
|
||||
}
|
||||
if (0 < yyrule)
|
||||
{
|
||||
YYCDEBUG << " S" << yyrule << '\n';
|
||||
return true;
|
||||
}
|
||||
yyrule = -yyrule;
|
||||
}
|
||||
// By now we know we have to simulate a reduce.
|
||||
YYCDEBUG << " R" << yyrule - 1;
|
||||
// Pop the corresponding number of values from the stack.
|
||||
{
|
||||
std::ptrdiff_t yylen = yyr2_[yyrule];
|
||||
// First pop from the LAC stack as many tokens as possible.
|
||||
std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ());
|
||||
if (yylen < lac_size)
|
||||
{
|
||||
yylac_stack_.resize (std::size_t (lac_size - yylen));
|
||||
yylen = 0;
|
||||
}
|
||||
else if (lac_size)
|
||||
{
|
||||
yylac_stack_.clear ();
|
||||
yylen -= lac_size;
|
||||
}
|
||||
// Only afterwards look at the main stack.
|
||||
// We simulate popping elements by incrementing lac_top.
|
||||
lac_top += yylen;
|
||||
}
|
||||
// Keep top_state in sync with the updated stack.
|
||||
top_state = (yylac_stack_.empty ()
|
||||
? yystack_[lac_top].state
|
||||
: yylac_stack_.back ());
|
||||
// Push the resulting state of the reduction.
|
||||
state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]);
|
||||
YYCDEBUG << " G" << state;
|
||||
yylac_stack_.push_back (state);
|
||||
}
|
||||
}
|
||||
|
||||
// Establish the initial context if no initial context currently exists.
|
||||
bool
|
||||
]b4_parser_class[::yy_lac_establish_ (int yytoken)
|
||||
{
|
||||
/* Establish the initial context for the current lookahead if no initial
|
||||
context is currently established.
|
||||
|
||||
We define a context as a snapshot of the parser stacks. We define
|
||||
the initial context for a lookahead as the context in which the
|
||||
parser initially examines that lookahead in order to select a
|
||||
syntactic action. Thus, if the lookahead eventually proves
|
||||
syntactically unacceptable (possibly in a later context reached via a
|
||||
series of reductions), the initial context can be used to determine
|
||||
the exact set of tokens that would be syntactically acceptable in the
|
||||
lookahead's place. Moreover, it is the context after which any
|
||||
further semantic actions would be erroneous because they would be
|
||||
determined by a syntactically unacceptable token.
|
||||
|
||||
yy_lac_establish_ should be invoked when a reduction is about to be
|
||||
performed in an inconsistent state (which, for the purposes of LAC,
|
||||
includes consistent states that don't know they're consistent because
|
||||
their default reductions have been disabled).
|
||||
|
||||
For parse.lac=full, the implementation of yy_lac_establish_ is as
|
||||
follows. If no initial context is currently established for the
|
||||
current lookahead, then check if that lookahead can eventually be
|
||||
shifted if syntactic actions continue from the current context. */
|
||||
if (!yy_lac_established_)
|
||||
{
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
YYCDEBUG << "LAC: initial context established for "
|
||||
<< yytname_[yytoken] << '\n';
|
||||
#endif
|
||||
yy_lac_established_ = true;
|
||||
return yy_lac_check_ (yytoken);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Discard any previous initial lookahead context.
|
||||
void
|
||||
]b4_parser_class[::yy_lac_discard_ (const char* evt)
|
||||
{
|
||||
/* Discard any previous initial lookahead context because of Event,
|
||||
which may be a lookahead change or an invalidation of the currently
|
||||
established initial context for the current lookahead.
|
||||
|
||||
The most common example of a lookahead change is a shift. An example
|
||||
of both cases is syntax error recovery. That is, a syntax error
|
||||
occurs when the lookahead is syntactically erroneous for the
|
||||
currently established initial context, so error recovery manipulates
|
||||
the parser stacks to try to find a new initial context in which the
|
||||
current lookahead is syntactically acceptable. If it fails to find
|
||||
such a context, it discards the lookahead. */
|
||||
if (yy_lac_established_)
|
||||
{
|
||||
YYCDEBUG << "LAC: initial context discarded due to "
|
||||
<< evt << '\n';
|
||||
yy_lac_established_ = false;
|
||||
}
|
||||
}]])[
|
||||
|
||||
// Generate an error message.
|
||||
std::string
|
||||
]b4_parser_class[::yysyntax_error_ (]dnl
|
||||
@@ -1098,7 +1297,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
{]b4_error_verbose_if([[
|
||||
// Number of reported tokens (one for the "unexpected", one per
|
||||
// "expected").
|
||||
size_t yycount = 0;
|
||||
std::ptrdiff_t yycount = 0;
|
||||
// Its maximum.
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
// Arguments of yyformat.
|
||||
@@ -1118,24 +1317,41 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
a consistent state with a default action. There might have
|
||||
been a previous inconsistent state, consistent state with a
|
||||
non-default action, or user semantic action that manipulated
|
||||
yyla. (However, yyla is currently not documented for users.)
|
||||
yyla. (However, yyla is currently not documented for users.)]b4_lac_if([[
|
||||
In the first two cases, it might appear that the current syntax
|
||||
error should have been detected in the previous state when
|
||||
yy_lac_check was invoked. However, at that time, there might
|
||||
have been a different syntax error that discarded a different
|
||||
initial context during error recovery, leaving behind the
|
||||
current lookahead.]], [[
|
||||
- Of course, the expected token list depends on states to have
|
||||
correct lookahead information, and it depends on the parser not
|
||||
to perform extra reductions after fetching a lookahead from the
|
||||
scanner and before detecting a syntax error. Thus, state
|
||||
merging (from LALR or IELR) and default reductions corrupt the
|
||||
expected token list. However, the list is correct for
|
||||
canonical LR with one exception: it will still contain any
|
||||
token that will not be accepted due to an error action in a
|
||||
later state.
|
||||
scanner and before detecting a syntax error. Thus, state merging
|
||||
(from LALR or IELR) and default reductions corrupt the expected
|
||||
token list. However, the list is correct for canonical LR with
|
||||
one exception: it will still contain any token that will not be
|
||||
accepted due to an error action in a later state.]])[
|
||||
*/
|
||||
if (!yyla.empty ())
|
||||
{
|
||||
int yytoken = yyla.type_get ();
|
||||
yyarg[yycount++] = yytname_[yytoken];
|
||||
symbol_number_type yytoken = yyla.type_get ();
|
||||
yyarg[yycount++] = yytname_[yytoken];]b4_lac_if([[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
// Execute LAC once. We don't care if it is succesful, we
|
||||
// only do it for the sake of debugging output.
|
||||
if (!yy_lac_established_)
|
||||
yy_lac_check_ (yytoken);
|
||||
#endif]])[
|
||||
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
{]b4_lac_if([[
|
||||
for (int yyx = 0; yyx < yyntokens_; ++yyx)
|
||||
if (yyx != yy_error_token_ && yyx != yy_undef_token_
|
||||
&& yy_lac_check_ (yyx))
|
||||
{]], [[
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
@@ -1144,9 +1360,9 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != yy_error_token_
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
{]])[
|
||||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
||||
{
|
||||
yycount = 1;
|
||||
@@ -1177,7 +1393,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
|
||||
std::string yyres;
|
||||
// Argument number.
|
||||
size_t yyi = 0;
|
||||
std::ptrdiff_t yyi = 0;
|
||||
for (char const* yyp = yyformat; *yyp; ++yyp)
|
||||
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
||||
{
|
||||
@@ -1218,7 +1434,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
i = yystack_.begin (),
|
||||
i_end = yystack_.end ();
|
||||
i != i_end; ++i)
|
||||
*yycdebug_ << ' ' << i->state;
|
||||
*yycdebug_ << ' ' << int (i->state);
|
||||
*yycdebug_ << '\n';
|
||||
}
|
||||
|
||||
@@ -1226,7 +1442,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
void
|
||||
]b4_parser_class[::yy_reduce_print_ (int yyrule)
|
||||
{
|
||||
unsigned yylno = yyrline_[yyrule];
|
||||
int yylno = yyrline_[yyrule];
|
||||
int yynrhs = yyr2_[yyrule];
|
||||
// Print the symbols being reduced, and their result.
|
||||
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
||||
|
||||
+252
-254
@@ -1,6 +1,6 @@
|
||||
# Java skeleton for Bison -*- autoconf -*-
|
||||
# D skeleton for Bison -*- autoconf -*-
|
||||
|
||||
# Copyright (C) 2007-2011, 2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2012, 2019 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
|
||||
@@ -18,12 +18,11 @@
|
||||
m4_include(b4_skeletonsdir/[d.m4])
|
||||
|
||||
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_parser_file_name@)@
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
|
||||
[2007-2012, 2019])
|
||||
[2007-2012, 2019])[
|
||||
|
||||
b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
||||
]b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
||||
])[
|
||||
version(D_Version2) {
|
||||
} else {
|
||||
@@ -47,8 +46,8 @@ import std.format;
|
||||
* parser <tt>]b4_parser_class[</tt>.
|
||||
*/
|
||||
public interface Lexer
|
||||
{
|
||||
]b4_locations_if([[/**
|
||||
{]b4_locations_if([[
|
||||
/**
|
||||
* Method to retrieve the beginning position of the last scanned token.
|
||||
* @@return the position at which the last scanned token starts. */
|
||||
@@property ]b4_position_type[ startPos ();
|
||||
@@ -56,8 +55,9 @@ public interface Lexer
|
||||
/**
|
||||
* Method to retrieve the ending position of the last scanned token.
|
||||
* @@return the first position beyond the last scanned token. */
|
||||
@@property ]b4_position_type[ endPos ();]])[
|
||||
@@property ]b4_position_type[ endPos ();
|
||||
|
||||
]])[
|
||||
/**
|
||||
* Method to retrieve the semantic value of the last scanned token.
|
||||
* @@return the semantic value of the last scanned token. */
|
||||
@@ -68,80 +68,26 @@ public interface Lexer
|
||||
* to the next token and prepares to return the semantic value
|
||||
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
||||
* @@return the token identifier corresponding to the next token. */
|
||||
YYTokenType yylex ();
|
||||
int yylex ();
|
||||
|
||||
/**
|
||||
* Entry point for error reporting. Emits an error
|
||||
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
|
||||
*
|
||||
* ]b4_locations_if([[@@param loc The location of the element to which the
|
||||
*]b4_locations_if([[
|
||||
* @@param loc The location of the element to which the
|
||||
* error message is related]])[
|
||||
* @@param s The string for the error message. */
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[string s);
|
||||
}
|
||||
|
||||
private final struct YYStackElement{
|
||||
int state;
|
||||
]b4_yystype[ value;
|
||||
]b4_locations_if(b4_location_type[[] location;])[
|
||||
}
|
||||
|
||||
private final struct YYStack {
|
||||
private YYStackElement[] stack = [];
|
||||
|
||||
public final @@property ulong height()
|
||||
{
|
||||
return stack.length;
|
||||
}
|
||||
|
||||
public final void push (int state, ]b4_yystype[ value]dnl
|
||||
b4_locations_if([, ref ]b4_location_type[ loc])[)
|
||||
{
|
||||
stack ~= YYStackElement(state, value]b4_locations_if([, loc])[);
|
||||
}
|
||||
|
||||
public final void pop ()
|
||||
{
|
||||
pop (1);
|
||||
}
|
||||
|
||||
public final void pop (int num)
|
||||
{
|
||||
stack.length -= num;
|
||||
}
|
||||
|
||||
public final int stateAt (int i)
|
||||
{
|
||||
return stack[$-i-1].state;
|
||||
}
|
||||
|
||||
]b4_locations_if([[public final ref ]b4_location_type[ locationAt (int i)
|
||||
{
|
||||
return stack[$-i-1].location;
|
||||
}
|
||||
|
||||
]])[public final ref ]b4_yystype[ valueAt (int i)
|
||||
{
|
||||
return stack[$-i-1].value;
|
||||
}
|
||||
|
||||
// Print the state stack on the debug stream.
|
||||
public final void print (File stream)
|
||||
{
|
||||
stream.write ("Stack now");
|
||||
for (int i = 0; i < stack.length; i++)
|
||||
stream.write (" %d", stack[i].state);
|
||||
stream.writeln ();
|
||||
}
|
||||
}
|
||||
]b4_locations_if(b4_position_type_if([[[
|
||||
]b4_locations_if([b4_position_type_if([[
|
||||
static assert(__traits(compiles,
|
||||
(new ]b4_position_type[[1])[0]=(new ]b4_position_type[[1])[0]),
|
||||
"struct/class ]b4_position_type[ must be default-constructible "
|
||||
"and assignable");
|
||||
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_position_type[).toString()),
|
||||
"error: struct/class ]b4_position_type[ must have toString method");
|
||||
]]], [[
|
||||
]], [[
|
||||
/**
|
||||
* A struct denoting a point in the input.*/
|
||||
public struct ]b4_position_type[ {
|
||||
@@ -151,15 +97,18 @@ public struct ]b4_position_type[ {
|
||||
/** The line number within an input file. */
|
||||
public int line = 1;
|
||||
/** The name of the input file. */
|
||||
public string filename = "(unspecified file)";
|
||||
public string filename = null;
|
||||
|
||||
/**
|
||||
* Return a string representation of the position. */
|
||||
* A string representation of the position. */
|
||||
public string toString() const {
|
||||
return format("%s:%d.%d", filename, line, column);
|
||||
if (filename)
|
||||
return format("%s:%d.%d", filename, line, column);
|
||||
else
|
||||
return format("%d.%d", line, column);
|
||||
}
|
||||
}
|
||||
]])b4_location_type_if([[[
|
||||
]])b4_location_type_if([[
|
||||
static assert(__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0]))) &&
|
||||
__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0], (new ]b4_position_type[[1])[0]))),
|
||||
"error: struct/class ]b4_location_type[ must have "
|
||||
@@ -173,7 +122,7 @@ static assert(__traits(compiles, (new ]b4_location_type[[1])[0].begin=(new ]b4_l
|
||||
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_location_type[[1])[0].toString()),
|
||||
"error: struct/class ]b4_location_type[ must have toString method.");
|
||||
|
||||
private immutable bool yy_location_is_class = !__traits(compiles, *(new ]b4_location_type[((new ]b4_position_type[[1])[0])));]]], [[
|
||||
private immutable bool yy_location_is_class = !__traits(compiles, *(new ]b4_location_type[((new ]b4_position_type[[1])[0])));]], [[
|
||||
/**
|
||||
* A class defining a pair of positions. Positions, defined by the
|
||||
* <code>]b4_position_type[</code> class, denote a point in the input.
|
||||
@@ -195,6 +144,9 @@ public class ]b4_location_type[
|
||||
this.begin = this.end = loc;
|
||||
}
|
||||
|
||||
public this () {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>]b4_location_type[</code> from the endpoints of the range.
|
||||
* @@param begin The first position included in the range.
|
||||
@@ -206,20 +158,25 @@ public class ]b4_location_type[
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a representation of the location. For this to be correct,
|
||||
* A representation of the location. For this to be correct,
|
||||
* <code>]b4_position_type[</code> should override the <code>toString</code>
|
||||
* method. */
|
||||
public const string toString () const {
|
||||
if (begin==end)
|
||||
return begin.toString ();
|
||||
else
|
||||
return begin.toString () ~ "-" ~ end.toString ();
|
||||
public override string toString () const {
|
||||
auto end_col = 0 < end.column ? end.column - 1 : 0;
|
||||
auto res = begin.toString ();
|
||||
if (end.filename && begin.filename != end.filename)
|
||||
res ~= "-" ~ format("%s:%d.%d", end.filename, end.line, end_col);
|
||||
else if (begin.line < end.line)
|
||||
res ~= "-" ~ format("%d.%d", end.line, end_col);
|
||||
else if (begin.column < end_col)
|
||||
res ~= "-" ~ format("%d", end_col);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
private immutable bool yy_location_is_class = true;
|
||||
|
||||
]]))m4_ifdef([b4_user_union_members], [private union YYSemanticType
|
||||
]])])m4_ifdef([b4_user_union_members], [private union YYSemanticType
|
||||
{
|
||||
b4_user_union_members
|
||||
};],
|
||||
@@ -230,10 +187,7 @@ b4_user_union_members
|
||||
{
|
||||
]b4_identification[
|
||||
|
||||
/** True if verbose error messages are enabled. */
|
||||
public bool errorVerbose = ]b4_flag_value([error_verbose]);
|
||||
|
||||
b4_locations_if([[
|
||||
]b4_locations_if([[
|
||||
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
|
||||
{
|
||||
static if (yy_location_is_class) {
|
||||
@@ -249,40 +203,38 @@ b4_user_union_members
|
||||
}
|
||||
}]])[
|
||||
|
||||
]b4_lexer_if([[private class YYLexer implements Lexer {
|
||||
]b4_lexer_if([[ private class YYLexer implements Lexer {
|
||||
]b4_percent_code_get([[lexer]])[
|
||||
}
|
||||
|
||||
]])[/** The object doing lexical analysis for us. */
|
||||
]])[
|
||||
/** The object doing lexical analysis for us. */
|
||||
private Lexer yylexer;
|
||||
]
|
||||
b4_parse_param_vars
|
||||
|
||||
b4_lexer_if([[
|
||||
]b4_parse_param_vars[
|
||||
|
||||
]b4_lexer_if([[
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
* Instantiate the Bison-generated parser.
|
||||
*/
|
||||
public this] (b4_parse_param_decl([b4_lex_param_decl])[) {
|
||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
||||
this.yyDebugStream = stderr;
|
||||
]b4_parse_param_cons[
|
||||
this (new YYLexer(]b4_lex_param_call[));
|
||||
}
|
||||
]])
|
||||
]])[
|
||||
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
* Instantiate the Bison-generated parser.
|
||||
* @@param yylexer The scanner that will supply tokens to the parser.
|
||||
*/
|
||||
b4_lexer_if([[protected]], [[public]]) [this (]b4_parse_param_decl([[Lexer yylexer]])[) {
|
||||
this.yylexer = yylexer;
|
||||
this.yyDebugStream = stderr;
|
||||
]b4_parse_param_cons[
|
||||
]b4_lexer_if([[protected]], [[public]]) [this (]b4_parse_param_decl([[Lexer yylexer]])[) {
|
||||
this.yylexer = yylexer;]b4_parse_trace_if([[
|
||||
this.yyDebugStream = stderr;]])[
|
||||
]b4_parse_param_cons[
|
||||
}
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
private File yyDebugStream;
|
||||
|
||||
/**
|
||||
* Return the <tt>File</tt> on which the debugging output is
|
||||
* The <tt>File</tt> on which the debugging output is
|
||||
* printed.
|
||||
*/
|
||||
public File getDebugStream () { return yyDebugStream; }
|
||||
@@ -308,16 +260,17 @@ b4_lexer_if([[
|
||||
*/
|
||||
public final void setDebugLevel(int level) { yydebug = level; }
|
||||
|
||||
protected final void yycdebug (string s) {
|
||||
if (0 < yydebug)
|
||||
yyDebugStream.writeln (s);
|
||||
}
|
||||
]])[
|
||||
private final int yylex () {
|
||||
return yylexer.yylex ();
|
||||
}
|
||||
|
||||
protected final void yyerror (]b4_locations_if(ref [b4_location_type[ loc, ]])[string s) {
|
||||
yylexer.yyerror (]b4_locations_if([loc, ])[s);
|
||||
}]
|
||||
|
||||
[protected final void yycdebug (string s) {
|
||||
if (yydebug > 0)
|
||||
yyDebugStream.writeln (s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,11 +297,11 @@ b4_lexer_if([[
|
||||
private static immutable int YYERRLAB1 = 7;
|
||||
private static immutable int YYRETURN = 8;
|
||||
]b4_locations_if([
|
||||
private static immutable YYSemanticType yy_semantic_null = cast(YYSemanticType)null;])[
|
||||
private static immutable YYSemanticType yy_semantic_null;])[
|
||||
private int yyerrstatus_ = 0;
|
||||
|
||||
/**
|
||||
* Return whether error recovery is being done. In this state, the parser
|
||||
* Whether error recovery is being done. In this state, the parser
|
||||
* reads token until it reaches a known state, and then restarts normal
|
||||
* operation. */
|
||||
public final bool recovering ()
|
||||
@@ -358,8 +311,8 @@ b4_lexer_if([[
|
||||
|
||||
private int yyaction (int yyn, ref YYStack yystack, int yylen)
|
||||
{
|
||||
]b4_yystype[ yyval;
|
||||
]b4_locations_if([b4_location_type[ yyloc = yylloc_from_stack (yystack, yylen);]])[
|
||||
]b4_yystype[ yyval;]b4_locations_if([[
|
||||
]b4_location_type[ yyloc = yylloc_from_stack (yystack, yylen);]])[
|
||||
|
||||
/* If YYLEN is nonzero, implement the default value of the action:
|
||||
`$$ = $1'. Otherwise, use the top of the stack.
|
||||
@@ -372,7 +325,8 @@ b4_lexer_if([[
|
||||
else
|
||||
yyval = yystack.valueAt (0);
|
||||
|
||||
yy_reduce_print (yyn, yystack);
|
||||
]b4_parse_trace_if([[
|
||||
yy_reduce_print (yyn, yystack);]])[
|
||||
|
||||
switch (yyn)
|
||||
{
|
||||
@@ -380,7 +334,8 @@ b4_lexer_if([[
|
||||
default: break;
|
||||
}
|
||||
|
||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
||||
]b4_parse_trace_if([[
|
||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystack.pop (yylen);
|
||||
yylen = 0;
|
||||
@@ -408,7 +363,8 @@ b4_lexer_if([[
|
||||
if (yystr[0] == '"')
|
||||
{
|
||||
string yyr;
|
||||
strip_quotes: for (int i = 1; i < yystr.length; i++)
|
||||
strip_quotes:
|
||||
for (int i = 1; i < yystr.length; i++)
|
||||
switch (yystr[i])
|
||||
{
|
||||
case '\'':
|
||||
@@ -427,12 +383,12 @@ b4_lexer_if([[
|
||||
return yyr;
|
||||
}
|
||||
}
|
||||
else if (yystr=="$end")
|
||||
else if (yystr == "$end")
|
||||
return "end of input";
|
||||
|
||||
return yystr;
|
||||
}
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
@@ -441,11 +397,12 @@ b4_lexer_if([[
|
||||
ref ]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
{
|
||||
if (yydebug > 0) {
|
||||
if (0 < yydebug)
|
||||
{
|
||||
string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
|
||||
~ yytname_[yytype] ~ " ("]b4_locations_if([
|
||||
~ yylocationp.toString() ~ ": "])[;
|
||||
static if (__traits(compiles, message~=yyvaluep.toString ()))
|
||||
static if (__traits(compiles, message ~= yyvaluep.toString ()))
|
||||
message ~= yyvaluep.toString ();
|
||||
else
|
||||
message ~= format ("%s", &yyvaluep);
|
||||
@@ -453,7 +410,7 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
yycdebug (message);
|
||||
}
|
||||
}
|
||||
|
||||
]])[
|
||||
/**
|
||||
* Parse input from the scanner that was specified at object construction
|
||||
* time. Return whether the end of the input was reached successfully.
|
||||
@@ -475,22 +432,22 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
YYStack yystack;
|
||||
|
||||
/* Error handling. */
|
||||
int yynerrs_ = 0;
|
||||
]b4_locations_if([/// The location where the error started.
|
||||
int yynerrs_ = 0;]b4_locations_if([[
|
||||
/// The location where the error started.
|
||||
]b4_location_type[ yyerrloc = null;
|
||||
|
||||
/// ]b4_location_type[ of the lookahead.
|
||||
]b4_location_type[ yylloc;
|
||||
|
||||
/// @@$.
|
||||
]b4_location_type[ yyloc;])[
|
||||
]b4_location_type[ yyloc;]])[
|
||||
|
||||
/// Semantic value of the lookahead.
|
||||
]b4_yystype[ yylval;
|
||||
|
||||
int yyresult;
|
||||
int yyresult;]b4_parse_trace_if([[
|
||||
|
||||
yycdebug ("Starting parse\n");
|
||||
yycdebug ("Starting parse\n");]])[
|
||||
yyerrstatus_ = 0;
|
||||
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
@@ -510,10 +467,10 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
{
|
||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||
pushed when we come here. */
|
||||
case YYNEWSTATE:
|
||||
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||
yycdebug (format("Entering state %d\n", yystate));
|
||||
if (yydebug > 0)
|
||||
yystack.print (yyDebugStream);
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
|
||||
/* Accept? */
|
||||
if (yystate == yyfinal_)
|
||||
@@ -529,10 +486,9 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Read a lookahead token. */
|
||||
if (yychar == yyempty_)
|
||||
{
|
||||
yycdebug ("Reading a token: ");
|
||||
yychar = yylex ();]
|
||||
b4_locations_if([[
|
||||
{]b4_parse_trace_if([[
|
||||
yycdebug ("Reading a token: ");]])[
|
||||
yychar = yylex ();]b4_locations_if([[
|
||||
static if (yy_location_is_class) {
|
||||
yylloc = new ]b4_location_type[(yylexer.startPos, yylexer.endPos);
|
||||
} else {
|
||||
@@ -542,17 +498,9 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
}
|
||||
|
||||
/* Convert token to internal form. */
|
||||
if (yychar <= YYTokenType.EOF)
|
||||
{
|
||||
yychar = yytoken = YYTokenType.EOF;
|
||||
yycdebug ("Now at end of input.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
yytoken = yytranslate_ (yychar);
|
||||
yy_symbol_print ("Next token is",
|
||||
yytoken, yylval]b4_locations_if([, yylloc])[);
|
||||
}
|
||||
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Next token is",
|
||||
yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
detect an error, take that action. */
|
||||
@@ -573,9 +521,9 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* Discard the token being shifted. */
|
||||
yychar = yyempty_;
|
||||
@@ -624,7 +572,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||
}
|
||||
|
||||
]b4_locations_if([yyerrloc = yylloc;])[
|
||||
]b4_locations_if([ yyerrloc = yylloc;])[
|
||||
if (yyerrstatus_ == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
@@ -648,9 +596,8 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
/*-------------------------------------------------.
|
||||
| errorlab -- error raised explicitly by YYERROR. |
|
||||
`-------------------------------------------------*/
|
||||
case YYERROR:
|
||||
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
|
||||
case YYERROR:]b4_locations_if([
|
||||
yyerrloc = yystack.locationAt (yylen - 1);])[
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYERROR. */
|
||||
yystack.pop (yylen);
|
||||
@@ -663,15 +610,15 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
||||
`-------------------------------------------------------------*/
|
||||
case YYERRLAB1:
|
||||
yyerrstatus_ = 3; /* Each real token shifted decrements this.xb */
|
||||
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
||||
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
yyn += yy_error_token_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -683,23 +630,23 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
if (yystack.height == 1)
|
||||
return false;
|
||||
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
|
||||
]b4_locations_if([ yyerrloc = yystack.locationAt (0);])[
|
||||
yystack.pop ();
|
||||
yystate = yystack.stateAt (0);
|
||||
if (yydebug > 0)
|
||||
yystack.print (yyDebugStream);
|
||||
yystate = yystack.stateAt (0);]b4_parse_trace_if([[
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
}
|
||||
|
||||
]b4_locations_if([
|
||||
]b4_locations_if([
|
||||
/* Muck with the stack to setup for yylloc. */
|
||||
yystack.push (0, yy_semantic_null, yylloc);
|
||||
yystack.push (0, yy_semantic_null, yyerrloc);
|
||||
yyloc = yylloc_from_stack (yystack, 2);
|
||||
yystack.pop (2);])[
|
||||
|
||||
/* Shift the error token. */
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
||||
yylval]b4_locations_if([, yyloc])[);
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystate = yyn;
|
||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||
@@ -718,78 +665,74 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
// Generate an error message.
|
||||
private final string yysyntax_error (int yystate, int tok)
|
||||
{
|
||||
if (errorVerbose)
|
||||
{]b4_error_verbose_if([[
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||
See
|
||||
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||
for details. YYERROR is fine as it does not invoke this
|
||||
function.
|
||||
- If this state is a consistent state with a default action,
|
||||
then the only way this function was invoked is if the
|
||||
default action is an error action. In that case, don't
|
||||
check for expected tokens because there are none.
|
||||
- The only way there can be no lookahead present (in tok) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this
|
||||
state is a consistent state with a default action. There
|
||||
might have been a previous inconsistent state, consistent
|
||||
state with a non-default action, or user semantic action
|
||||
that manipulated yychar. (However, yychar is currently out
|
||||
of scope during semantic actions.)
|
||||
- Of course, the expected token list depends on states to
|
||||
have correct lookahead information, and it depends on the
|
||||
parser not to perform extra reductions after fetching a
|
||||
lookahead from the scanner and before detecting a syntax
|
||||
error. Thus, state merging (from LALR or IELR) and default
|
||||
reductions corrupt the expected token list. However, the
|
||||
list is correct for canonical LR with one exception: it
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
if (tok != yyempty_)
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||
See
|
||||
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||
for details. YYERROR is fine as it does not invoke this
|
||||
function.
|
||||
- If this state is a consistent state with a default action,
|
||||
then the only way this function was invoked is if the
|
||||
default action is an error action. In that case, don't
|
||||
check for expected tokens because there are none.
|
||||
- The only way there can be no lookahead present (in tok) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this
|
||||
state is a consistent state with a default action. There
|
||||
might have been a previous inconsistent state, consistent
|
||||
state with a non-default action, or user semantic action
|
||||
that manipulated yychar. (However, yychar is currently out
|
||||
of scope during semantic actions.)
|
||||
- Of course, the expected token list depends on states to
|
||||
have correct lookahead information, and it depends on the
|
||||
parser not to perform extra reductions after fetching a
|
||||
lookahead from the scanner and before detecting a syntax
|
||||
error. Thus, state merging (from LALR or IELR) and default
|
||||
reductions corrupt the expected token list. However, the
|
||||
list is correct for canonical LR with one exception: it
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
if (tok != yyempty_)
|
||||
// FIXME: This method of building the message is not compatible
|
||||
// with internationalization.
|
||||
string res = "syntax error, unexpected ";
|
||||
res ~= yytnamerr_ (yytname_[tok]);
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
// FIXME: This method of building the message is not compatible
|
||||
// with internationalization.
|
||||
string res = "syntax error, unexpected ";
|
||||
res ~= yytnamerr_ (yytname_[tok]);
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
-YYN actions for this state because they are default
|
||||
actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||
res ~= yytnamerr_ (yytname_[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
-YYN actions for this state because they are default
|
||||
actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||
res ~= yytnamerr_ (yytname_[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}]])[
|
||||
return "syntax error";
|
||||
}
|
||||
|
||||
@@ -822,14 +765,6 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
||||
to YYLEX-NUM. */
|
||||
private static immutable ]b4_int_type_for([b4_toknum])[[]
|
||||
yytoken_number_ =
|
||||
@{
|
||||
]b4_toknum[
|
||||
@};
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||
private static immutable string[] yytname_ =
|
||||
@@ -837,6 +772,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
]b4_tname[
|
||||
@};
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
||||
private static immutable ]b4_int_type_for([b4_rline])[[] yyrline_ =
|
||||
@{
|
||||
@@ -862,36 +798,98 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}
|
||||
]])[
|
||||
|
||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
private static immutable ]b4_int_type_for([b4_translate])[[] yytranslate_table_ =
|
||||
@{
|
||||
]b4_translate[
|
||||
@};
|
||||
|
||||
private static ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||
private static token_number_type yytranslate_ (int t)
|
||||
{
|
||||
if (t >= 0 && t <= yyuser_token_number_max_)
|
||||
return yytranslate_table_[t];
|
||||
]b4_api_token_raw_if(
|
||||
[[ import std.conv : to;
|
||||
return to!byte (t);]],
|
||||
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
immutable token_number_type[] translate_table =
|
||||
@{
|
||||
]b4_translate[
|
||||
@};
|
||||
|
||||
immutable int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
immutable token_number_type undef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
if (t <= 0)
|
||||
return YYTokenType.EOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
return translate_table[t];
|
||||
else
|
||||
return yyundef_token_;
|
||||
return undef_token_;]])[
|
||||
}
|
||||
|
||||
alias ]b4_int_type_for([b4_translate])[ token_number_type;
|
||||
|
||||
private static immutable token_number_type yy_error_token_ = 1;
|
||||
|
||||
private static immutable int yylast_ = ]b4_last[;
|
||||
private static immutable int yynnts_ = ]b4_nterms_number[;
|
||||
private static immutable int yyempty_ = -2;
|
||||
private static immutable int yyfinal_ = ]b4_final_state_number[;
|
||||
private static immutable int yyterror_ = 1;
|
||||
private static immutable int yyerrcode_ = 256;
|
||||
private static immutable int yyntokens_ = ]b4_tokens_number[;
|
||||
|
||||
private static immutable int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||
private static immutable int yyundef_token_ = ]b4_undef_token_number[;
|
||||
private final struct YYStackElement {
|
||||
int state;
|
||||
]b4_yystype[ value;]b4_locations_if(
|
||||
b4_location_type[[] location;])[
|
||||
}
|
||||
|
||||
]/* User implementation code. */
|
||||
b4_percent_code_get[]dnl
|
||||
private final struct YYStack {
|
||||
private YYStackElement[] stack = [];
|
||||
|
||||
public final @@property ulong height()
|
||||
{
|
||||
return stack.length;
|
||||
}
|
||||
|
||||
public final void push (int state, ]b4_yystype[ value]dnl
|
||||
b4_locations_if([, ref ]b4_location_type[ loc])[)
|
||||
{
|
||||
stack ~= YYStackElement(state, value]b4_locations_if([, loc])[);
|
||||
}
|
||||
|
||||
public final void pop ()
|
||||
{
|
||||
pop (1);
|
||||
}
|
||||
|
||||
public final void pop (int num)
|
||||
{
|
||||
stack.length -= num;
|
||||
}
|
||||
|
||||
public final int stateAt (int i)
|
||||
{
|
||||
return stack[$-i-1].state;
|
||||
}
|
||||
|
||||
]b4_locations_if([[
|
||||
public final ref ]b4_location_type[ locationAt (int i)
|
||||
{
|
||||
return stack[$-i-1].location;
|
||||
}]])[
|
||||
|
||||
public final ref ]b4_yystype[ valueAt (int i)
|
||||
{
|
||||
return stack[$-i-1].value;
|
||||
}
|
||||
]b4_parse_trace_if([[
|
||||
// Print the state stack on the debug stream.
|
||||
public final void print (File stream)
|
||||
{
|
||||
stream.write ("Stack now");
|
||||
for (int i = 0; i < stack.length; i++)
|
||||
stream.write (" ", stack[i].state);
|
||||
stream.writeln ();
|
||||
}]])[
|
||||
}
|
||||
|
||||
/* User implementation code. */
|
||||
]b4_percent_code_get[
|
||||
}
|
||||
|
||||
b4_epilogue
|
||||
m4_divert_pop(0)dnl
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end
|
||||
|
||||
+137
-153
@@ -1,4 +1,4 @@
|
||||
# Java skeleton for Bison -*- autoconf -*-
|
||||
# Java skeleton for Bison -*- autoconf -*-
|
||||
|
||||
# Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
|
||||
@@ -17,18 +17,12 @@
|
||||
|
||||
m4_include(b4_skeletonsdir/[java.m4])
|
||||
|
||||
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
|
||||
[b4_skeleton])])
|
||||
|
||||
# We do not depend on %debug in Java, but pacify warnings about
|
||||
# non-used flags.
|
||||
b4_parse_trace_if([0], [0])
|
||||
b4_defines_if([b4_complain([%defines does not make sense in Java])])
|
||||
|
||||
m4_define([b4_symbol_no_destructor_assert],
|
||||
[b4_symbol_if([$1], [has_destructor],
|
||||
[b4_fatal([%s: %s: %%destructor does not make sense in Java],
|
||||
[b4_skeleton],
|
||||
[b4_symbol_action_location([$1], [destructor])])])])
|
||||
[b4_complain_at(m4_unquote(b4_symbol([$1], [destructor_loc])),
|
||||
[%destructor does not make sense in Java])])])
|
||||
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
||||
|
||||
# Setup some macros for api.push-pull.
|
||||
@@ -72,25 +66,25 @@ m4_define([b4_define_state],[[
|
||||
|
||||
/* Error handling. */
|
||||
int yynerrs_ = 0;
|
||||
]b4_locations_if([/* The location where the error started. */
|
||||
b4_location_type yyerrloc = null;
|
||||
]b4_locations_if([[/* The location where the error started. */
|
||||
]b4_location_type[ yyerrloc = null;
|
||||
|
||||
/* Location. */
|
||||
b4_location_type yylloc = new b4_location_type (null, null);])[
|
||||
]b4_location_type[ yylloc = new ]b4_location_type[ (null, null);]])[
|
||||
|
||||
/* Semantic value of the lookahead. */
|
||||
]b4_yystype[ yylval = null;
|
||||
]])
|
||||
]])[
|
||||
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
]b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2015, 2018])[
|
||||
[2007-2015, 2018-2019])[
|
||||
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
||||
]])[
|
||||
]b4_user_pre_prologue[
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get([[imports]])
|
||||
[/**
|
||||
]b4_percent_code_get([[imports]])[
|
||||
/**
|
||||
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
||||
*
|
||||
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
||||
@@ -105,7 +99,7 @@ b4_output_begin([b4_parser_file_name])[
|
||||
private boolean yyErrorVerbose = true;
|
||||
|
||||
/**
|
||||
* Return whether verbose error messages are enabled.
|
||||
* Whether verbose error messages are enabled.
|
||||
*/
|
||||
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
||||
|
||||
@@ -167,12 +161,12 @@ b4_locations_if([[
|
||||
}
|
||||
}
|
||||
|
||||
]])
|
||||
]])[
|
||||
|
||||
b4_locations_if([[
|
||||
]b4_locations_if([[
|
||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
||||
{
|
||||
if (n > 0)
|
||||
if (0 < n)
|
||||
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
||||
else
|
||||
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
||||
@@ -222,10 +216,11 @@ b4_locations_if([[
|
||||
* error message is related]])[
|
||||
* @@param msg The string for the error message.
|
||||
*/
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);]
|
||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);
|
||||
}
|
||||
|
||||
b4_lexer_if([[private class YYLexer implements Lexer {
|
||||
]b4_lexer_if([[
|
||||
private class YYLexer implements Lexer {
|
||||
]b4_percent_code_get([[lexer]])[
|
||||
}
|
||||
|
||||
@@ -233,10 +228,10 @@ b4_locations_if([[
|
||||
* The object doing lexical analysis for us.
|
||||
*/
|
||||
private Lexer yylexer;
|
||||
]
|
||||
b4_parse_param_vars
|
||||
|
||||
b4_lexer_if([[
|
||||
]b4_parse_param_vars[
|
||||
|
||||
]b4_lexer_if([[
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
*/
|
||||
@@ -246,24 +241,24 @@ b4_lexer_if([[
|
||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
||||
]b4_parse_param_cons[
|
||||
}
|
||||
]])
|
||||
]])[
|
||||
|
||||
/**
|
||||
* Instantiates the Bison-generated parser.
|
||||
* @@param yylexer The scanner that will supply tokens to the parser.
|
||||
*/
|
||||
b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
||||
]b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
||||
{
|
||||
]b4_percent_code_get([[init]])[
|
||||
this.yylexer = yylexer;
|
||||
]b4_parse_param_cons[
|
||||
}
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
private java.io.PrintStream yyDebugStream = System.err;
|
||||
|
||||
/**
|
||||
* Return the <tt>PrintStream</tt> on which the debugging output is
|
||||
* printed.
|
||||
* The <tt>PrintStream</tt> on which the debugging output is printed.
|
||||
*/
|
||||
public final java.io.PrintStream getDebugStream () { return yyDebugStream; }
|
||||
|
||||
@@ -287,6 +282,7 @@ b4_lexer_if([[
|
||||
* @@param level The verbosity level for debugging output.
|
||||
*/
|
||||
public final void setDebugLevel(int level) { yydebug = level; }
|
||||
]])[
|
||||
|
||||
/**
|
||||
* Print an error message via the lexer.
|
||||
@@ -316,12 +312,12 @@ b4_lexer_if([[
|
||||
public final void yyerror (]b4_position_type[ pos, String msg)
|
||||
{
|
||||
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
|
||||
}]])
|
||||
|
||||
[protected final void yycdebug (String s) {
|
||||
if (yydebug > 0)
|
||||
}]])[
|
||||
]b4_parse_trace_if([[
|
||||
protected final void yycdebug (String s) {
|
||||
if (0 < yydebug)
|
||||
yyDebugStream.println (s);
|
||||
}
|
||||
}]])[
|
||||
|
||||
private final class YYStack {
|
||||
private int[] stateStack = new int[16];
|
||||
@@ -362,7 +358,7 @@ b4_lexer_if([[
|
||||
|
||||
public final void pop (int num) {
|
||||
// Avoid memory leaks... garbage collection is a white lie!
|
||||
if (num > 0) {
|
||||
if (0 < num) {
|
||||
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
|
||||
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
||||
}
|
||||
@@ -432,10 +428,9 @@ b4_lexer_if([[
|
||||
|
||||
private int yyerrstatus_ = 0;
|
||||
|
||||
]b4_push_if([dnl
|
||||
b4_define_state])[
|
||||
]b4_push_if([b4_define_state])[
|
||||
/**
|
||||
* Return whether error recovery is being done. In this state, the parser
|
||||
* Whether error recovery is being done. In this state, the parser
|
||||
* reads token until it reaches a known state, and then restarts normal
|
||||
* operation.
|
||||
*/
|
||||
@@ -448,7 +443,7 @@ b4_define_state])[
|
||||
* @@param yystate the current state
|
||||
* @@param yysym the nonterminal to push on the stack
|
||||
*/
|
||||
private int yy_lr_goto_state_ (int yystate, int yysym)
|
||||
private int yyLRGotoState (int yystate, int yysym)
|
||||
{
|
||||
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
|
||||
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
||||
@@ -459,35 +454,30 @@ b4_define_state])[
|
||||
|
||||
private int yyaction (int yyn, YYStack yystack, int yylen) ]b4_maybe_throws([b4_throws])[
|
||||
{
|
||||
]b4_yystype[ yyval;
|
||||
]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[
|
||||
|
||||
/* If YYLEN is nonzero, implement the default value of the action:
|
||||
'$$ = $1'. Otherwise, use the top of the stack.
|
||||
|
||||
Otherwise, the following line sets YYVAL to garbage.
|
||||
This behavior is undocumented and Bison
|
||||
users should not rely upon it. */
|
||||
if (yylen > 0)
|
||||
yyval = yystack.valueAt (yylen - 1);
|
||||
else
|
||||
yyval = yystack.valueAt (0);
|
||||
]b4_yystype[ yyval = (0 < yylen) ? yystack.valueAt (yylen - 1) : yystack.valueAt (0);
|
||||
]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[]b4_parse_trace_if([[
|
||||
|
||||
yy_reduce_print (yyn, yystack);
|
||||
yyReducePrint (yyn, yystack);]])[
|
||||
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}
|
||||
}]b4_parse_trace_if([[
|
||||
|
||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
||||
yySymbolPrint ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystack.pop (yylen);
|
||||
yylen = 0;
|
||||
|
||||
/* Shift the result of the reduction. */
|
||||
int yystate = yy_lr_goto_state_ (yystack.stateAt (0), yyr1_[yyn]);
|
||||
int yystate = yyLRGotoState (yystack.stateAt (0), yyr1_[yyn]);
|
||||
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
|
||||
return YYNEWSTATE;
|
||||
}
|
||||
@@ -528,21 +518,20 @@ b4_define_state])[
|
||||
return yystr;
|
||||
}
|
||||
]])[
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
private void yy_symbol_print (String s, int yytype,
|
||||
]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, Object yylocationp])[)
|
||||
private void yySymbolPrint (String s, int yytype,
|
||||
]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, Object yylocationp])[)
|
||||
{
|
||||
if (yydebug > 0)
|
||||
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
|
||||
+ yytname_[yytype] + " ("]b4_locations_if([
|
||||
+ yylocationp + ": "])[
|
||||
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
|
||||
}
|
||||
}]])[
|
||||
|
||||
]b4_push_if([],[[
|
||||
/**
|
||||
@@ -552,7 +541,7 @@ b4_define_state])[
|
||||
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||
* imply that there were no syntax errors.
|
||||
*/
|
||||
public boolean parse () ]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[]])[
|
||||
public boolean parse () ]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[]])[
|
||||
]b4_push_if([
|
||||
/**
|
||||
* Push Parse input from external lexer
|
||||
@@ -569,8 +558,8 @@ b4_define_state])[
|
||||
]b4_locations_if([/* @@$. */
|
||||
b4_location_type yyloc;])[
|
||||
]b4_push_if([],[[
|
||||
]b4_define_state[
|
||||
yycdebug ("Starting parse\n");
|
||||
]b4_define_state[]b4_parse_trace_if([[
|
||||
yycdebug ("Starting parse\n");]])[
|
||||
yyerrstatus_ = 0;
|
||||
|
||||
/* Initialize the stack. */
|
||||
@@ -589,8 +578,8 @@ b4_dollar_popdef[]dnl
|
||||
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef[]dnl
|
||||
])[
|
||||
yycdebug ("Starting parse\n");
|
||||
])[]b4_parse_trace_if([[
|
||||
yycdebug ("Starting parse\n");]])[
|
||||
yyerrstatus_ = 0;
|
||||
} else
|
||||
label = YYGETTOKEN;
|
||||
@@ -602,10 +591,10 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||
pushed when we come here. */
|
||||
case YYNEWSTATE:
|
||||
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||
yycdebug ("Entering state " + yystate + "\n");
|
||||
if (yydebug > 0)
|
||||
yystack.print (yyDebugStream);
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
|
||||
/* Accept? */
|
||||
if (yystate == yyfinal_)
|
||||
@@ -614,7 +603,7 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* Take a decision. First try without lookahead. */
|
||||
yyn = yypact_[yystate];
|
||||
if (yy_pact_value_is_default_ (yyn))
|
||||
if (yyPactValueIsDefault (yyn))
|
||||
{
|
||||
label = YYDEFAULT;
|
||||
break;
|
||||
@@ -627,14 +616,13 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
]b4_push_if([[
|
||||
if (!push_token_consumed)
|
||||
return YYPUSH_MORE;
|
||||
yycdebug ("Reading a token: ");
|
||||
return YYPUSH_MORE;]b4_parse_trace_if([[
|
||||
yycdebug ("Reading a token: ");]])[
|
||||
yychar = yylextoken;
|
||||
yylval = yylexval;]b4_locations_if([
|
||||
yylloc = yylexloc;])[
|
||||
push_token_consumed = false;]])[
|
||||
]b4_push_if([],[[
|
||||
yycdebug ("Reading a token: ");
|
||||
push_token_consumed = false;]], [b4_parse_trace_if([[
|
||||
yycdebug ("Reading a token: ");]])[
|
||||
yychar = yylexer.yylex ();
|
||||
yylval = yylexer.getLVal ();]b4_locations_if([
|
||||
yylloc = new b4_location_type (yylexer.getStartPos (),
|
||||
@@ -643,17 +631,9 @@ b4_dollar_popdef[]dnl
|
||||
}
|
||||
|
||||
/* Convert token to internal form. */
|
||||
if (yychar <= Lexer.EOF)
|
||||
{
|
||||
yychar = yytoken = Lexer.EOF;
|
||||
yycdebug ("Now at end of input.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
yytoken = yytranslate_ (yychar);
|
||||
yy_symbol_print ("Next token is", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
}
|
||||
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Next token is", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);]])[
|
||||
|
||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
detect an error, take that action. */
|
||||
@@ -664,7 +644,7 @@ b4_dollar_popdef[]dnl
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
{
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
if (yyTableValueIsError (yyn))
|
||||
label = YYERRLAB;
|
||||
else
|
||||
{
|
||||
@@ -675,10 +655,10 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
else
|
||||
{
|
||||
/* Shift the lookahead token. */
|
||||
yy_symbol_print ("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
|
||||
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Shifting", yytoken,
|
||||
yylval]b4_locations_if([, yylloc])[);
|
||||
]])[
|
||||
/* Discard the token being shifted. */
|
||||
yychar = yyempty_;
|
||||
|
||||
@@ -729,17 +709,17 @@ b4_dollar_popdef[]dnl
|
||||
]b4_locations_if([yyerrloc = yylloc;])[
|
||||
if (yyerrstatus_ == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
error, discard it. */
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
error, discard it. */
|
||||
|
||||
if (yychar <= Lexer.EOF)
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == Lexer.EOF)
|
||||
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
||||
}
|
||||
else
|
||||
yychar = yyempty_;
|
||||
if (yychar <= Lexer.EOF)
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == Lexer.EOF)
|
||||
]b4_push_if([{label = YYABORT; break;}], [return false;])[
|
||||
}
|
||||
else
|
||||
yychar = yyempty_;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token after shifting the error
|
||||
@@ -751,7 +731,6 @@ b4_dollar_popdef[]dnl
|
||||
| errorlab -- error raised explicitly by YYERROR. |
|
||||
`-------------------------------------------------*/
|
||||
case YYERROR:
|
||||
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYERROR. */
|
||||
@@ -770,10 +749,10 @@ b4_dollar_popdef[]dnl
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
yyn += yy_error_token_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -788,9 +767,9 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
|
||||
yystack.pop ();
|
||||
yystate = yystack.stateAt (0);
|
||||
if (yydebug > 0)
|
||||
yystack.print (yyDebugStream);
|
||||
yystate = yystack.stateAt (0);]b4_parse_trace_if([[
|
||||
if (0 < yydebug)
|
||||
yystack.print (yyDebugStream);]])[
|
||||
}
|
||||
|
||||
if (label == YYABORT)
|
||||
@@ -804,9 +783,9 @@ b4_dollar_popdef[]dnl
|
||||
yyloc = yylloc (yystack, 2);
|
||||
yystack.pop (2);])[
|
||||
|
||||
/* Shift the error token. */
|
||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
||||
yylval]b4_locations_if([, yyloc])[);
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Shifting", yystos_[yyn],
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystate = yyn;
|
||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||
@@ -872,9 +851,9 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
return push_parse (yylextoken, yylexval, new b4_location_type (yylexpos));
|
||||
}
|
||||
])[]])
|
||||
])[]])[
|
||||
|
||||
b4_both_if([[
|
||||
]b4_both_if([[
|
||||
/**
|
||||
* Parse input from the scanner that was specified at object construction
|
||||
* time. Return whether the end of the input was reached successfully.
|
||||
@@ -883,21 +862,21 @@ b4_both_if([[
|
||||
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||
* imply that there were no syntax errors.
|
||||
*/
|
||||
public boolean parse () ]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[
|
||||
{
|
||||
if (yylexer == null)
|
||||
throw new NullPointerException("Null Lexer");
|
||||
int status;
|
||||
do {
|
||||
int token = yylexer.yylex();
|
||||
]b4_yystype[ lval = yylexer.getLVal();
|
||||
public boolean parse () ]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[
|
||||
{
|
||||
if (yylexer == null)
|
||||
throw new NullPointerException("Null Lexer");
|
||||
int status;
|
||||
do {
|
||||
int token = yylexer.yylex();
|
||||
]b4_yystype[ lval = yylexer.getLVal();
|
||||
]b4_locations_if([dnl
|
||||
b4_location_type yyloc = new b4_location_type (yylexer.getStartPos (),
|
||||
yylexer.getEndPos ());])[
|
||||
]b4_locations_if([status = push_parse(token,lval,yyloc);],[
|
||||
status = push_parse(token,lval);])[
|
||||
} while (status == YYPUSH_MORE);
|
||||
return (status == YYACCEPT);
|
||||
b4_location_type yyloc = new b4_location_type (yylexer.getStartPos (),
|
||||
yylexer.getEndPos ());])[
|
||||
]b4_locations_if([status = push_parse(token,lval,yyloc);],[
|
||||
status = push_parse(token,lval);])[
|
||||
} while (status == YYPUSH_MORE);
|
||||
return (status == YYACCEPT);
|
||||
}
|
||||
]])[
|
||||
|
||||
@@ -940,7 +919,7 @@ b4_both_if([[
|
||||
new StringBuffer ("syntax error, unexpected ");
|
||||
res.append (yytnamerr_ (yytname_[tok]));
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative
|
||||
indexes in YYCHECK. In other words, skip the first
|
||||
@@ -952,15 +931,15 @@ b4_both_if([[
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||
{
|
||||
res.append (count++ == 0 ? ", expecting " : " or ");
|
||||
res.append (yytnamerr_ (yytname_[x]));
|
||||
@@ -978,7 +957,7 @@ b4_both_if([[
|
||||
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
||||
* @@param yyvalue the value to check
|
||||
*/
|
||||
private static boolean yy_pact_value_is_default_ (int yyvalue)
|
||||
private static boolean yyPactValueIsDefault (int yyvalue)
|
||||
{
|
||||
return yyvalue == yypact_ninf_;
|
||||
}
|
||||
@@ -988,7 +967,7 @@ b4_both_if([[
|
||||
* value indicates a syntax error.
|
||||
* @@param yyvalue the value to check
|
||||
*/
|
||||
private static boolean yy_table_value_is_error_ (int yyvalue)
|
||||
private static boolean yyTableValueIsError (int yyvalue)
|
||||
{
|
||||
return yyvalue == yytable_ninf_;
|
||||
}
|
||||
@@ -997,20 +976,18 @@ b4_both_if([[
|
||||
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
||||
|
||||
]b4_parser_tables_define[
|
||||
]b4_integral_parser_table_define([token_number], [b4_toknum],
|
||||
[[YYTOKEN_NUMBER[YYLEX-NUM] -- Internal symbol number corresponding
|
||||
to YYLEX-NUM.]])[
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
]b4_integral_parser_table_define([rline], [b4_rline],
|
||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
||||
|
||||
|
||||
// Report on the debug stream that the rule yyrule is going to be reduced.
|
||||
private void yy_reduce_print (int yyrule, YYStack yystack)
|
||||
private void yyReducePrint (int yyrule, YYStack yystack)
|
||||
{
|
||||
if (yydebug == 0)
|
||||
return;
|
||||
@@ -1023,37 +1000,44 @@ b4_both_if([[
|
||||
|
||||
/* The symbols being reduced. */
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yy_symbol_print (" $" + (yyi + 1) + " =",
|
||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}
|
||||
yySymbolPrint (" $" + (yyi + 1) + " =",
|
||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}]])[
|
||||
|
||||
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||
/* YYTRANSLATE_(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, with out-of-bounds checking. */
|
||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||
|
||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||
{
|
||||
if (t >= 0 && t <= yyuser_token_number_max_)
|
||||
]b4_api_token_raw_if(dnl
|
||||
[[ {
|
||||
return t;
|
||||
}
|
||||
]],
|
||||
[[ {
|
||||
int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
]b4_int_type_for([b4_translate])[ undef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
if (t <= 0)
|
||||
return Lexer.EOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
return yytranslate_table_[t];
|
||||
else
|
||||
return yyundef_token_;
|
||||
return undef_token_;
|
||||
}
|
||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||
]])[
|
||||
|
||||
private static final ]b4_int_type_for([b4_translate])[ yy_error_token_ = 1;
|
||||
|
||||
private static final int yylast_ = ]b4_last[;
|
||||
private static final int yynnts_ = ]b4_nterms_number[;
|
||||
private static final int yyempty_ = -2;
|
||||
private static final int yyfinal_ = ]b4_final_state_number[;
|
||||
private static final int yyterror_ = 1;
|
||||
private static final int yyerrcode_ = 256;
|
||||
private static final int yyntokens_ = ]b4_tokens_number[;
|
||||
|
||||
private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||
private static final int yyundef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
]/* User implementation code. */
|
||||
b4_percent_code_get[]dnl
|
||||
/* User implementation code. */
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
}
|
||||
|
||||
|
||||
+42
-32
@@ -62,11 +62,14 @@ m4_define([b4_location_define],
|
||||
[[ /// A point in a source file.
|
||||
class position
|
||||
{
|
||||
public:]m4_ifdef([b4_location_constructors], [[
|
||||
public:
|
||||
/// Type for line and column numbers.
|
||||
typedef int counter_type;
|
||||
]m4_ifdef([b4_location_constructors], [[
|
||||
/// Construct a position.
|
||||
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
: filename (f)
|
||||
, line (l)
|
||||
, column (c)
|
||||
@@ -75,8 +78,8 @@ m4_define([b4_location_define],
|
||||
]])[
|
||||
/// Initialization.
|
||||
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
{
|
||||
filename = fn;
|
||||
line = l;
|
||||
@@ -86,17 +89,17 @@ m4_define([b4_location_define],
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
void lines (int count = 1)
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
if (count)
|
||||
{
|
||||
column = ]b4_location_initial_column[u;
|
||||
column = ]b4_location_initial_column[;
|
||||
line = add_ (line, count, ]b4_location_initial_line[);
|
||||
}
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
void columns (int count = 1)
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
column = add_ (column, count, ]b4_location_initial_column[);
|
||||
}
|
||||
@@ -105,22 +108,21 @@ m4_define([b4_location_define],
|
||||
/// File name to which this position refers.
|
||||
]b4_percent_define_get([[filename_type]])[* filename;
|
||||
/// Current line number.
|
||||
unsigned line;
|
||||
counter_type line;
|
||||
/// Current column number.
|
||||
unsigned column;
|
||||
counter_type column;
|
||||
|
||||
private:
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
||||
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
||||
{
|
||||
return static_cast<unsigned> (std::max (min,
|
||||
static_cast<int> (lhs) + rhs));
|
||||
return lhs + rhs < min ? min : lhs + rhs;
|
||||
}
|
||||
};
|
||||
|
||||
/// Add \a width columns, in place.
|
||||
inline position&
|
||||
operator+= (position& res, int width)
|
||||
operator+= (position& res, position::counter_type width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
@@ -128,21 +130,21 @@ m4_define([b4_location_define],
|
||||
|
||||
/// Add \a width columns.
|
||||
inline position
|
||||
operator+ (position res, int width)
|
||||
operator+ (position res, position::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns, in place.
|
||||
inline position&
|
||||
operator-= (position& res, int width)
|
||||
operator-= (position& res, position::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns.
|
||||
inline position
|
||||
operator- (position res, int width)
|
||||
operator- (position res, position::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
@@ -182,6 +184,8 @@ m4_define([b4_location_define],
|
||||
class location
|
||||
{
|
||||
public:
|
||||
/// Type for line and column numbers.
|
||||
typedef position::counter_type counter_type;
|
||||
]m4_ifdef([b4_location_constructors], [
|
||||
/// Construct a location from \a b to \a e.
|
||||
location (const position& b, const position& e)
|
||||
@@ -197,8 +201,8 @@ m4_define([b4_location_define],
|
||||
|
||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||
explicit location (]b4_percent_define_get([[filename_type]])[* f,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{}
|
||||
@@ -206,8 +210,8 @@ m4_define([b4_location_define],
|
||||
])[
|
||||
/// Initialization.
|
||||
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
{
|
||||
begin.initialize (f, l, c);
|
||||
end = begin;
|
||||
@@ -223,13 +227,13 @@ m4_define([b4_location_define],
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
void columns (int count = 1)
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
void lines (int count = 1)
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
end.lines (count);
|
||||
}
|
||||
@@ -244,39 +248,45 @@ m4_define([b4_location_define],
|
||||
};
|
||||
|
||||
/// Join two locations, in place.
|
||||
inline location& operator+= (location& res, const location& end)
|
||||
inline location&
|
||||
operator+= (location& res, const location& end)
|
||||
{
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Join two locations.
|
||||
inline location operator+ (location res, const location& end)
|
||||
inline location
|
||||
operator+ (location res, const location& end)
|
||||
{
|
||||
return res += end;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position, in place.
|
||||
inline location& operator+= (location& res, int width)
|
||||
inline location&
|
||||
operator+= (location& res, location::counter_type width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position.
|
||||
inline location operator+ (location res, int width)
|
||||
inline location
|
||||
operator+ (location res, location::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position, in place.
|
||||
inline location& operator-= (location& res, int width)
|
||||
inline location&
|
||||
operator-= (location& res, location::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position.
|
||||
inline location operator- (location res, int width)
|
||||
inline location
|
||||
operator- (location res, location::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
@@ -305,7 +315,8 @@ m4_define([b4_location_define],
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
location::counter_type end_col
|
||||
= 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
@@ -327,7 +338,7 @@ m4_ifdef([b4_position_file], [[
|
||||
// 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
|
||||
// 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.
|
||||
|
||||
@@ -346,7 +357,6 @@ m4_ifdef([b4_location_file], [[
|
||||
|
||||
]b4_cpp_guard_open([b4_location_path])[
|
||||
|
||||
# include <algorithm> // std::max
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
|
||||
+19
-30
@@ -35,6 +35,7 @@ m4_define([b4_stack_define],
|
||||
typedef typename S::reverse_iterator iterator;
|
||||
typedef typename S::const_reverse_iterator const_iterator;
|
||||
typedef typename S::size_type size_type;
|
||||
typedef typename std::ptrdiff_t index_type;
|
||||
|
||||
stack (size_type n = 200)
|
||||
: seq_ (n)
|
||||
@@ -43,37 +44,19 @@ m4_define([b4_stack_define],
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
T&
|
||||
operator[] (size_type i)
|
||||
const T&
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return seq_[size () - 1 - i];
|
||||
return seq_[size_type (size () - 1 - i)];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
T&
|
||||
operator[] (int i)
|
||||
operator[] (index_type i)
|
||||
{
|
||||
return operator[] (size_type (i));
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
const T&
|
||||
operator[] (size_type i) const
|
||||
{
|
||||
return seq_[size () - 1 - i];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
const T&
|
||||
operator[] (int i) const
|
||||
{
|
||||
return operator[] (size_type (i));
|
||||
return seq_[size_type (size () - 1 - i)];
|
||||
}
|
||||
|
||||
/// Steal the contents of \a t.
|
||||
@@ -88,7 +71,7 @@ m4_define([b4_stack_define],
|
||||
|
||||
/// Pop elements from the stack.
|
||||
void
|
||||
pop (int n = 1) YY_NOEXCEPT
|
||||
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
|
||||
{
|
||||
for (; 0 < n; --n)
|
||||
seq_.pop_back ();
|
||||
@@ -102,10 +85,16 @@ m4_define([b4_stack_define],
|
||||
}
|
||||
|
||||
/// Number of elements on the stack.
|
||||
size_type
|
||||
index_type
|
||||
size () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.size ();
|
||||
return index_type (seq_.size ());
|
||||
}
|
||||
|
||||
std::ptrdiff_t
|
||||
ssize () const YY_NOEXCEPT
|
||||
{
|
||||
return std::ptrdiff_t (size ());
|
||||
}
|
||||
|
||||
/// Iterator on top of the stack (going downwards).
|
||||
@@ -126,20 +115,20 @@ m4_define([b4_stack_define],
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice (const stack& stack, int range)
|
||||
slice (const stack& stack, index_type range)
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (int i) const
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const stack& stack_;
|
||||
int range_;
|
||||
index_type range_;
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -157,7 +146,7 @@ m4_ifdef([b4_stack_file],
|
||||
// used to define is now defined with the parser itself.
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add 'require "3.2"' (or newer) to your grammar file
|
||||
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system.
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
+20
-20
@@ -72,9 +72,9 @@ m4_map([ b4_symbol_tag_comment], [$@])dnl
|
||||
# The needed includes for variants support.
|
||||
m4_define([b4_variant_includes],
|
||||
[b4_parse_assert_if([[#include <typeinfo>]])[
|
||||
#ifndef YYASSERT
|
||||
#ifndef YY_ASSERT
|
||||
# include <cassert>
|
||||
# define YYASSERT assert
|
||||
# define YY_ASSERT assert
|
||||
#endif
|
||||
]])
|
||||
|
||||
@@ -111,14 +111,14 @@ m4_define([b4_value_type_declare],
|
||||
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||
}
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
~semantic_type () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
])[}
|
||||
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
@@ -127,8 +127,8 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
emplace (U&&... u)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
||||
}
|
||||
@@ -138,8 +138,8 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
emplace ()
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T ();
|
||||
}
|
||||
@@ -149,8 +149,8 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
emplace (const T& t)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= size);
|
||||
YY_ASSERT (!yytypeid_);
|
||||
YY_ASSERT (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (t);
|
||||
}
|
||||
@@ -179,9 +179,9 @@ m4_define([b4_value_type_declare],
|
||||
T&
|
||||
as () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == typeid (T));
|
||||
YYASSERT (sizeof (T) <= size);])[
|
||||
YY_ASSERT (yytypeid_);
|
||||
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||
YY_ASSERT (sizeof (T) <= size);])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
@@ -190,9 +190,9 @@ m4_define([b4_value_type_declare],
|
||||
const T&
|
||||
as () const YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == typeid (T));
|
||||
YYASSERT (sizeof (T) <= size);])[
|
||||
YY_ASSERT (yytypeid_);
|
||||
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||
YY_ASSERT (sizeof (T) <= size);])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ m4_define([b4_value_type_declare],
|
||||
void
|
||||
swap (self_type& that) YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == *that.yytypeid_);])[
|
||||
YY_ASSERT (yytypeid_);
|
||||
YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
|
||||
std::swap (as<T> (), that.as<T> ());
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ m4_define([_b4_token_constructor_define],
|
||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||
b4_locations_if([std::move (l)]))[)
|
||||
{
|
||||
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
}
|
||||
#else
|
||||
symbol_type (]b4_join(
|
||||
@@ -413,7 +413,7 @@ m4_define([_b4_token_constructor_define],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l]))[)
|
||||
{
|
||||
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||
}
|
||||
#endif
|
||||
]])])
|
||||
|
||||
+257
-218
@@ -1,4 +1,4 @@
|
||||
-*- C -*-
|
||||
# -*- C -*-
|
||||
# Yacc compatible skeleton for Bison
|
||||
|
||||
# Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software
|
||||
@@ -20,51 +20,11 @@ m4_pushdef([b4_copyright_years],
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Check the value of %define api.push-pull.
|
||||
b4_percent_define_default([[api.push-pull]], [[pull]])
|
||||
b4_percent_define_check_values([[[[api.push-pull]],
|
||||
[[pull]], [[push]], [[both]]]])
|
||||
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
|
||||
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
|
||||
m4_case(b4_percent_define_get([[api.push-pull]]),
|
||||
[pull], [m4_define([b4_push_flag], [[0]])],
|
||||
[push], [m4_define([b4_pull_flag], [[0]])])
|
||||
|
||||
# Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
|
||||
# tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
|
||||
# behavior of Bison at all when push parsing is already requested.
|
||||
b4_define_flag_if([use_push_for_pull])
|
||||
b4_use_push_for_pull_if([
|
||||
b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
|
||||
[m4_define([b4_push_flag], [[1]])])])
|
||||
|
||||
# Check the value of %define parse.lac and friends, where LAC stands for
|
||||
# lookahead correction.
|
||||
b4_percent_define_default([[parse.lac]], [[none]])
|
||||
b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]])
|
||||
b4_percent_define_default([[parse.lac.memory-trace]], [[failures]])
|
||||
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]],
|
||||
[[[[parse.lac.memory-trace]],
|
||||
[[failures]], [[full]]]])
|
||||
b4_define_flag_if([lac])
|
||||
m4_define([b4_lac_flag],
|
||||
[m4_if(b4_percent_define_get([[parse.lac]]),
|
||||
[none], [[0]], [[1]])])
|
||||
|
||||
m4_include(b4_skeletonsdir/[c.m4])
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
# Stack parameters.
|
||||
m4_define_default([b4_stack_depth_max], [10000])
|
||||
m4_define_default([b4_stack_depth_init], [200])
|
||||
|
||||
|
||||
## ------------------------ ##
|
||||
## Pure/impure interfaces. ##
|
||||
## ------------------------ ##
|
||||
## ---------- ##
|
||||
## api.pure. ##
|
||||
## ---------- ##
|
||||
|
||||
b4_percent_define_default([[api.pure]], [[false]])
|
||||
b4_percent_define_check_values([[[[api.pure]],
|
||||
@@ -84,6 +44,51 @@ m4_define([b4_pure_if],
|
||||
[2], [$1])])
|
||||
[m4_fatal([invalid api.pure value: ]$1)])])
|
||||
|
||||
## --------------- ##
|
||||
## api.push-pull. ##
|
||||
## --------------- ##
|
||||
|
||||
b4_percent_define_default([[api.push-pull]], [[pull]])
|
||||
b4_percent_define_check_values([[[[api.push-pull]],
|
||||
[[pull]], [[push]], [[both]]]])
|
||||
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
|
||||
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
|
||||
m4_case(b4_percent_define_get([[api.push-pull]]),
|
||||
[pull], [m4_define([b4_push_flag], [[0]])],
|
||||
[push], [m4_define([b4_pull_flag], [[0]])])
|
||||
|
||||
# Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
|
||||
# tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
|
||||
# behavior of Bison at all when push parsing is already requested.
|
||||
b4_define_flag_if([use_push_for_pull])
|
||||
b4_use_push_for_pull_if([
|
||||
b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
|
||||
[m4_define([b4_push_flag], [[1]])])])
|
||||
|
||||
## ----------- ##
|
||||
## parse.lac. ##
|
||||
## ----------- ##
|
||||
|
||||
b4_percent_define_default([[parse.lac]], [[none]])
|
||||
b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]])
|
||||
b4_percent_define_default([[parse.lac.memory-trace]], [[failures]])
|
||||
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]],
|
||||
[[[[parse.lac.memory-trace]],
|
||||
[[failures]], [[full]]]])
|
||||
b4_define_flag_if([lac])
|
||||
m4_define([b4_lac_flag],
|
||||
[m4_if(b4_percent_define_get([[parse.lac]]),
|
||||
[none], [[0]], [[1]])])
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
# Stack parameters.
|
||||
m4_define_default([b4_stack_depth_max], [10000])
|
||||
m4_define_default([b4_stack_depth_init], [200])
|
||||
|
||||
|
||||
# b4_yyerror_arg_loc_if(ARG)
|
||||
# --------------------------
|
||||
# Expand ARG iff yyerror is to be given a location as argument.
|
||||
@@ -101,28 +106,6 @@ m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
|
||||
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data Types. ##
|
||||
## ------------ ##
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included). Overwrite the version from c.m4, which
|
||||
# uses only C89 types, so that the user can override the shorter
|
||||
# types, and so that pre-C89 compilers are handled correctly.
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
||||
b4_ints_in($@, [-128], [127]), [1], [yytype_int8],
|
||||
|
||||
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
|
||||
|
||||
m4_eval([0 <= $1]), [1], [unsigned],
|
||||
|
||||
[int])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
@@ -199,7 +182,7 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
||||
/* Number of syntax errors so far. */
|
||||
int yynerrs;
|
||||
]])[
|
||||
int yystate;
|
||||
yy_state_fast_t yystate;
|
||||
/* Number of tokens to shift before error messages enabled. */
|
||||
int yyerrstatus;
|
||||
|
||||
@@ -212,9 +195,9 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
||||
to reallocate them elsewhere. */
|
||||
|
||||
/* The state stack. */
|
||||
yytype_int16 yyssa[YYINITDEPTH];
|
||||
yytype_int16 *yyss;
|
||||
yytype_int16 *yyssp;
|
||||
yy_state_t yyssa[YYINITDEPTH];
|
||||
yy_state_t *yyss;
|
||||
yy_state_t *yyssp;
|
||||
|
||||
/* The semantic value stack. */
|
||||
YYSTYPE yyvsa[YYINITDEPTH];
|
||||
@@ -229,11 +212,11 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
||||
/* The locations where the error started and ended. */
|
||||
YYLTYPE yyerror_range[3];]])[
|
||||
|
||||
YYSIZE_T yystacksize;]b4_lac_if([[
|
||||
YYPTRDIFF_T yystacksize;]b4_lac_if([[
|
||||
|
||||
yytype_int16 yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
|
||||
yytype_int16 *yyes;
|
||||
YYSIZE_T yyes_capacity;]])])
|
||||
yy_state_t yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
|
||||
yy_state_t *yyes;
|
||||
YYPTRDIFF_T yyes_capacity;]])])
|
||||
|
||||
|
||||
# _b4_declare_yyparse_push
|
||||
@@ -284,20 +267,48 @@ m4_define([b4_declare_yyparse],
|
||||
# Declaration that might either go into the header (if --defines)
|
||||
# or open coded in the parser body.
|
||||
m4_define([b4_shared_declarations],
|
||||
[b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
[b4_cpp_guard_open([b4_spec_header_file])[
|
||||
]b4_declare_yydebug[
|
||||
]b4_percent_code_get([[requires]])[
|
||||
]b4_token_enums_defines[
|
||||
]b4_declare_yylstype[
|
||||
]b4_declare_yyparse[
|
||||
]b4_percent_code_get([[provides]])[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
|
||||
]b4_cpp_guard_close([b4_spec_header_file])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_header_include_if(IF-TRUE, IF-FALSE)
|
||||
# ---------------------------------------
|
||||
# Run IF-TRUE if we generate an output file and api.header.include
|
||||
# is defined.
|
||||
m4_define([b4_header_include_if],
|
||||
[m4_ifval(m4_quote(b4_spec_header_file),
|
||||
[b4_percent_define_ifdef([[api.header.include]],
|
||||
[$1],
|
||||
[$2])],
|
||||
[$2])])
|
||||
|
||||
m4_if(b4_spec_header_file, [[y.tab.h]],
|
||||
[b4_percent_define_default([[api.header.include]],
|
||||
[["@basename(]b4_spec_header_file[@)"]])])
|
||||
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Output files. ##
|
||||
## -------------- ##
|
||||
|
||||
|
||||
b4_defines_if([[
|
||||
]b4_output_begin([b4_spec_header_file])[
|
||||
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||
]b4_disclaimer[
|
||||
]b4_shared_declarations[
|
||||
]b4_output_end[
|
||||
]])# b4_defines_if
|
||||
|
||||
b4_output_begin([b4_parser_file_name])[
|
||||
]b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||
@@ -328,13 +339,13 @@ m4_if(b4_api_prefix, [yy], [],
|
||||
#define yylex ]b4_prefix[lex
|
||||
#define yyerror ]b4_prefix[error
|
||||
#define yydebug ]b4_prefix[debug
|
||||
#define yynerrs ]b4_prefix[nerrs
|
||||
]]b4_pure_if([], [[
|
||||
#define yynerrs ]b4_prefix[nerrs]]b4_pure_if([], [[
|
||||
#define yylval ]b4_prefix[lval
|
||||
#define yychar ]b4_prefix[char]b4_locations_if([[
|
||||
#define yylloc ]b4_prefix[lloc]])]))[
|
||||
|
||||
]b4_user_pre_prologue[
|
||||
]b4_cast_define[
|
||||
]b4_null_define[
|
||||
|
||||
/* Enabling verbose error messages. */
|
||||
@@ -345,11 +356,11 @@ m4_if(b4_api_prefix, [yy], [],
|
||||
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
||||
#endif
|
||||
|
||||
]m4_ifval(m4_quote(b4_spec_defines_file),
|
||||
[[/* In a future release of Bison, this section will be replaced
|
||||
by #include "@basename(]b4_spec_defines_file[@)". */
|
||||
]])dnl
|
||||
b4_shared_declarations[
|
||||
]b4_header_include_if([[#include ]b4_percent_define_get([[api.header.include]])],
|
||||
[m4_ifval(m4_quote(b4_spec_header_file),
|
||||
[/* Use api.header.include to #include this header
|
||||
instead of duplicating it here. */
|
||||
])b4_shared_declarations])[
|
||||
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[]dnl
|
||||
@@ -358,28 +369,22 @@ b4_shared_declarations[
|
||||
# undef short
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_UINT8
|
||||
typedef YYTYPE_UINT8 yytype_uint8;
|
||||
#else
|
||||
typedef unsigned char yytype_uint8;
|
||||
#endif
|
||||
]b4_c99_int_type_define[
|
||||
|
||||
#ifdef YYTYPE_INT8
|
||||
typedef YYTYPE_INT8 yytype_int8;
|
||||
#else
|
||||
typedef signed char yytype_int8;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_UINT16
|
||||
typedef YYTYPE_UINT16 yytype_uint16;
|
||||
#else
|
||||
typedef unsigned short yytype_uint16;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_INT16
|
||||
typedef YYTYPE_INT16 yytype_int16;
|
||||
#else
|
||||
typedef short yytype_int16;
|
||||
#ifndef YYPTRDIFF_T
|
||||
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
|
||||
# define YYPTRDIFF_T __PTRDIFF_TYPE__
|
||||
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
|
||||
# elif defined PTRDIFF_MAX
|
||||
# ifndef ptrdiff_t
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# define YYPTRDIFF_T ptrdiff_t
|
||||
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
|
||||
# else
|
||||
# define YYPTRDIFF_T long
|
||||
# define YYPTRDIFF_MAXIMUM LONG_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
@@ -387,7 +392,7 @@ typedef short yytype_int16;
|
||||
# define YYSIZE_T __SIZE_TYPE__
|
||||
# elif defined size_t
|
||||
# define YYSIZE_T size_t
|
||||
# elif ! defined YYSIZE_T
|
||||
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
@@ -395,7 +400,19 @@ typedef short yytype_int16;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
||||
#define YYSIZE_MAXIMUM \
|
||||
YY_CAST (YYPTRDIFF_T, \
|
||||
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
|
||||
? YYPTRDIFF_MAXIMUM \
|
||||
: YY_CAST (YYSIZE_T, -1)))
|
||||
|
||||
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
||||
|
||||
/* Stored state numbers (used for stacks). */
|
||||
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;
|
||||
|
||||
/* State numbers in computations. */
|
||||
typedef int yy_state_fast_t;
|
||||
|
||||
#ifndef YY_
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
@@ -411,6 +428,15 @@ typedef short yytype_int16;
|
||||
|
||||
]b4_attribute_define[
|
||||
|
||||
]b4_parse_assert_if([[#ifdef NDEBUG
|
||||
# define YY_ASSERT(E) ((void) (0 && (E)))
|
||||
#else
|
||||
# include <assert.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_ASSERT(E) assert (E)
|
||||
#endif
|
||||
]],
|
||||
[[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
|
||||
|
||||
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
|
||||
|
||||
/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
|
||||
@@ -489,22 +515,23 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
/* A type that is properly aligned for any stack member. */
|
||||
union yyalloc
|
||||
{
|
||||
yytype_int16 yyss_alloc;
|
||||
yy_state_t yyss_alloc;
|
||||
YYSTYPE yyvs_alloc;]b4_locations_if([
|
||||
YYLTYPE yyls_alloc;])[
|
||||
};
|
||||
|
||||
/* The size of the maximum gap between one aligned stack and the next. */
|
||||
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
|
||||
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
|
||||
|
||||
/* The size of an array large to enough to hold all stacks, each with
|
||||
N elements. */
|
||||
]b4_locations_if(
|
||||
[# define YYSTACK_BYTES(N) \
|
||||
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
|
||||
((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
|
||||
+ YYSIZEOF (YYLTYPE)) \
|
||||
+ 2 * YYSTACK_GAP_MAXIMUM)],
|
||||
[# define YYSTACK_BYTES(N) \
|
||||
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
|
||||
((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
|
||||
+ YYSTACK_GAP_MAXIMUM)])[
|
||||
|
||||
# define YYCOPY_NEEDED 1
|
||||
@@ -517,11 +544,11 @@ union yyalloc
|
||||
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yynewbytes; \
|
||||
YYPTRDIFF_T yynewbytes; \
|
||||
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
||||
Stack = &yyptr->Stack_alloc; \
|
||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||
yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||
yyptr += yynewbytes / YYSIZEOF (*yyptr); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
@@ -533,12 +560,12 @@ union yyalloc
|
||||
# ifndef YYCOPY
|
||||
# if defined __GNUC__ && 1 < __GNUC__
|
||||
# define YYCOPY(Dst, Src, Count) \
|
||||
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
|
||||
__builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
|
||||
# else
|
||||
# define YYCOPY(Dst, Src, Count) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yyi; \
|
||||
YYPTRDIFF_T yyi; \
|
||||
for (yyi = 0; yyi < (Count); yyi++) \
|
||||
(Dst)[yyi] = (Src)[yyi]; \
|
||||
} \
|
||||
@@ -564,17 +591,20 @@ union yyalloc
|
||||
#define YYUNDEFTOK ]b4_undef_token_number[
|
||||
#define YYMAXUTOK ]b4_user_token_number_max[
|
||||
|
||||
|
||||
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, with out-of-bounds checking. */
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
]b4_api_token_raw_if(dnl
|
||||
[[#define YYTRANSLATE(YYX) (YYX)]],
|
||||
[[#define YYTRANSLATE(YYX) \
|
||||
(0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex. */
|
||||
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
};]])[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
]b4_integral_parser_table_define([rline], [b4_rline],
|
||||
@@ -599,15 +629,15 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
||||
};
|
||||
# endif
|
||||
|
||||
#define YYPACT_NINF ]b4_pact_ninf[
|
||||
#define YYPACT_NINF (]b4_pact_ninf[)
|
||||
|
||||
#define yypact_value_is_default(Yystate) \
|
||||
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
|
||||
#define yypact_value_is_default(Yyn) \
|
||||
]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
|
||||
|
||||
#define YYTABLE_NINF ]b4_table_ninf[
|
||||
#define YYTABLE_NINF (]b4_table_ninf[)
|
||||
|
||||
#define yytable_value_is_error(Yytable_value) \
|
||||
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
|
||||
#define yytable_value_is_error(Yyn) \
|
||||
]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
@@ -685,8 +715,8 @@ do { \
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
]b4_function_define([yy_stack_print], [static void],
|
||||
[[yytype_int16 *yybottom], [yybottom]],
|
||||
[[yytype_int16 *yytop], [yytop]])[
|
||||
[[yy_state_t *yybottom], [yybottom]],
|
||||
[[yy_state_t *yytop], [yytop]])[
|
||||
{
|
||||
YYFPRINTF (stderr, "Stack now");
|
||||
for (; yybottom <= yytop; yybottom++)
|
||||
@@ -709,16 +739,16 @@ do { \
|
||||
`------------------------------------------------*/
|
||||
|
||||
]b4_function_define([yy_reduce_print], [static void],
|
||||
[[yytype_int16 *yyssp], [yyssp]],
|
||||
[[yy_state_t *yyssp], [yyssp]],
|
||||
[[YYSTYPE *yyvsp], [yyvsp]],
|
||||
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
||||
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
||||
b4_parse_param]))[
|
||||
{
|
||||
unsigned long yylno = yyrline[yyrule];
|
||||
int yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
|
||||
yyrule - 1, yylno);
|
||||
/* The symbols being reduced. */
|
||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||
@@ -777,22 +807,22 @@ int yydebug;
|
||||
using YYSTACK_FREE. Return 0 if successful or if no reallocation is
|
||||
required. Return 1 if memory is exhausted. */
|
||||
static int
|
||||
yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
|
||||
yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
char const *yydebug_prefix,
|
||||
char const *yydebug_suffix,
|
||||
#endif
|
||||
yytype_int16 **yybottom,
|
||||
yytype_int16 *yybottom_no_free,
|
||||
yytype_int16 **yytop, yytype_int16 *yytop_empty)
|
||||
yy_state_t **yybottom,
|
||||
yy_state_t *yybottom_no_free,
|
||||
yy_state_t **yytop, yy_state_t *yytop_empty)
|
||||
{
|
||||
YYSIZE_T yysize_old =
|
||||
(YYSIZE_T) (*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1);
|
||||
YYSIZE_T yysize_new = yysize_old + yyadd;
|
||||
YYPTRDIFF_T yysize_old =
|
||||
*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
|
||||
YYPTRDIFF_T yysize_new = yysize_old + yyadd;
|
||||
if (*yycapacity < yysize_new)
|
||||
{
|
||||
YYSIZE_T yyalloc = 2 * yysize_new;
|
||||
yytype_int16 *yybottom_new;
|
||||
YYPTRDIFF_T yyalloc = 2 * yysize_new;
|
||||
yy_state_t *yybottom_new;
|
||||
/* Use YYMAXDEPTH for maximum stack size given that the stack
|
||||
should never need to grow larger than the main state stack
|
||||
needs to grow without LAC. */
|
||||
@@ -805,7 +835,9 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
|
||||
if (YYMAXDEPTH < yyalloc)
|
||||
yyalloc = YYMAXDEPTH;
|
||||
yybottom_new =
|
||||
(yytype_int16*) YYSTACK_ALLOC (yyalloc * sizeof *yybottom_new);
|
||||
YY_CAST (yy_state_t *,
|
||||
YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
|
||||
yyalloc * YYSIZEOF (*yybottom_new))));
|
||||
if (!yybottom_new)
|
||||
{
|
||||
YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
|
||||
@@ -822,8 +854,10 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
|
||||
*yybottom = yybottom_new;
|
||||
*yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
|
||||
[full], [[
|
||||
YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix,
|
||||
(unsigned long) yyalloc, yydebug_suffix));]])[
|
||||
YY_IGNORE_USELESS_CAST_BEGIN
|
||||
YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
|
||||
YY_CAST (long, yyalloc), yydebug_suffix));
|
||||
YY_IGNORE_USELESS_CAST_END]])[
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -908,11 +942,11 @@ do { \
|
||||
contents of either array, alter *YYES and *YYES_CAPACITY, and free
|
||||
any old *YYES other than YYESA. */
|
||||
static int
|
||||
yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken)
|
||||
yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
|
||||
YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken)
|
||||
{
|
||||
yytype_int16 *yyes_prev = yyssp;
|
||||
yytype_int16 *yyesp = yyes_prev;
|
||||
yy_state_t *yyes_prev = yyssp;
|
||||
yy_state_t *yyesp = yyes_prev;
|
||||
YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken]));
|
||||
if (yytoken == YYUNDEFTOK)
|
||||
{
|
||||
@@ -949,11 +983,11 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
yyrule = -yyrule;
|
||||
}
|
||||
{
|
||||
YYSIZE_T yylen = yyr2[yyrule];
|
||||
YYPTRDIFF_T yylen = yyr2[yyrule];
|
||||
YYDPRINTF ((stderr, " R%d", yyrule - 1));
|
||||
if (yyesp != yyes_prev)
|
||||
{
|
||||
YYSIZE_T yysize = (YYSIZE_T) (yyesp - *yyes + 1);
|
||||
YYPTRDIFF_T yysize = yyesp - *yyes + 1;
|
||||
if (yylen < yysize)
|
||||
{
|
||||
yyesp -= yylen;
|
||||
@@ -969,19 +1003,20 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
yyesp = yyes_prev -= yylen;
|
||||
}
|
||||
{
|
||||
yytype_int16 yystate;
|
||||
yy_state_fast_t yystate;
|
||||
{
|
||||
const int yylhs = yyr1[yyrule] - YYNTOKENS;
|
||||
const int yyi = yypgoto[yylhs] + *yyesp;
|
||||
yystate = ((yytype_int16)
|
||||
(0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
|
||||
? yytable[yyi]
|
||||
: yydefgoto[yylhs]));
|
||||
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
|
||||
? yytable[yyi]
|
||||
: yydefgoto[yylhs]);
|
||||
}
|
||||
if (yyesp == yyes_prev)
|
||||
{
|
||||
yyesp = *yyes;
|
||||
*yyesp = yystate;
|
||||
YY_IGNORE_USELESS_CAST_BEGIN
|
||||
*yyesp = YY_CAST (yy_state_t, yystate);
|
||||
YY_IGNORE_USELESS_CAST_END
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -994,9 +1029,11 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
YYDPRINTF ((stderr, "\n"));
|
||||
return 2;
|
||||
}
|
||||
*++yyesp = yystate;
|
||||
YY_IGNORE_USELESS_CAST_BEGIN
|
||||
*++yyesp = YY_CAST (yy_state_t, yystate);
|
||||
YY_IGNORE_USELESS_CAST_END
|
||||
}
|
||||
YYDPRINTF ((stderr, " G%d", (int) yystate));
|
||||
YYDPRINTF ((stderr, " G%d", yystate));
|
||||
}
|
||||
}
|
||||
}]])[
|
||||
@@ -1006,13 +1043,13 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
|
||||
# ifndef yystrlen
|
||||
# if defined __GLIBC__ && defined _STRING_H
|
||||
# define yystrlen strlen
|
||||
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
|
||||
# else
|
||||
/* Return the length of YYSTR. */
|
||||
]b4_function_define([yystrlen], [static YYSIZE_T],
|
||||
]b4_function_define([yystrlen], [static YYPTRDIFF_T],
|
||||
[[const char *yystr], [yystr]])[
|
||||
{
|
||||
YYSIZE_T yylen;
|
||||
YYPTRDIFF_T yylen;
|
||||
for (yylen = 0; yystr[yylen]; yylen++)
|
||||
continue;
|
||||
return yylen;
|
||||
@@ -1048,12 +1085,12 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
||||
null, do not copy; instead, return the length of what the result
|
||||
would have been. */
|
||||
static YYSIZE_T
|
||||
static YYPTRDIFF_T
|
||||
yytnamerr (char *yyres, const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
YYSIZE_T yyn = 0;
|
||||
YYPTRDIFF_T yyn = 0;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
@@ -1084,10 +1121,10 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
do_not_strip_quotes: ;
|
||||
}
|
||||
|
||||
if (! yyres)
|
||||
if (yyres)
|
||||
return yystpcpy (yyres, yystr) - yyres;
|
||||
else
|
||||
return yystrlen (yystr);
|
||||
|
||||
return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -1102,20 +1139,20 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
required number of bytes is too large to store]b4_lac_if([[ or if
|
||||
yy_lac returned 2]])[. */
|
||||
static int
|
||||
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken)
|
||||
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
||||
]b4_lac_if([[yy_state_t *yyesa, yy_state_t **yyes,
|
||||
YYPTRDIFF_T *yyes_capacity, ]])[yy_state_t *yyssp, int yytoken)
|
||||
{
|
||||
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
|
||||
YYSIZE_T yysize = yysize0;
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
/* Internationalized format string. */
|
||||
const char *yyformat = YY_NULLPTR;
|
||||
/* Arguments of yyformat. */
|
||||
/* Arguments of yyformat: reported tokens (one for the "unexpected",
|
||||
one per "expected"). */
|
||||
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
||||
/* Number of reported tokens (one for the "unexpected", one per
|
||||
"expected"). */
|
||||
/* Actual size of YYARG. */
|
||||
int yycount = 0;
|
||||
/* Cumulated lengths of YYARG. */
|
||||
YYPTRDIFF_T yysize = 0;
|
||||
|
||||
/* There are many possibilities here to consider:
|
||||
- If this state is a consistent state with a default action, then
|
||||
@@ -1147,19 +1184,14 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
*/
|
||||
if (yytoken != YYEMPTY)
|
||||
{
|
||||
int yyn = yypact[*yyssp];]b4_lac_if([[
|
||||
int yyn = yypact[*yyssp];
|
||||
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
|
||||
yysize = yysize0;]b4_lac_if([[
|
||||
YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
|
||||
yyarg[yycount++] = yytname[yytoken];
|
||||
if (!yypact_value_is_default (yyn))
|
||||
{]b4_lac_if([], [[
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = YYLAST - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;]])[
|
||||
int yyx;]b4_lac_if([[
|
||||
{]b4_lac_if([[
|
||||
int yyx;
|
||||
|
||||
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
|
||||
if (yyx != YYTERROR && yyx != YYUNDEFTOK)
|
||||
@@ -1172,6 +1204,14 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
if (yy_lac_status == 1)
|
||||
continue;
|
||||
}]], [[
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = YYLAST - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
int yyx;
|
||||
|
||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
|
||||
@@ -1185,7 +1225,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
}
|
||||
yyarg[yycount++] = yytname[yyx];
|
||||
{
|
||||
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
|
||||
YYPTRDIFF_T yysize1
|
||||
= yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
|
||||
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
|
||||
yysize = yysize1;
|
||||
else
|
||||
@@ -1216,7 +1257,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
}
|
||||
|
||||
{
|
||||
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
|
||||
/* Don't count the "%s"s in the final size, but reserve room for
|
||||
the terminator. */
|
||||
YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
|
||||
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
|
||||
yysize = yysize1;
|
||||
else
|
||||
@@ -1246,8 +1289,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
}
|
||||
else
|
||||
{
|
||||
yyp++;
|
||||
yyformat++;
|
||||
++yyp;
|
||||
++yyformat;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -1313,7 +1356,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
yypstate *yyps;]b4_pure_if([], [[
|
||||
if (yypstate_allocated)
|
||||
return YY_NULLPTR;]])[
|
||||
yyps = (yypstate *) malloc (sizeof *yyps);
|
||||
yyps = YY_CAST (yypstate *, malloc (sizeof *yyps));
|
||||
if (!yyps)
|
||||
return YY_NULLPTR;
|
||||
yyps->yynew = 1;]b4_pure_if([], [[
|
||||
@@ -1397,7 +1440,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
/* Buffer for error messages, and its allocated size. */
|
||||
char yymsgbuf[128];
|
||||
char *yymsg = yymsgbuf;
|
||||
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
|
||||
YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
|
||||
#endif
|
||||
|
||||
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
|
||||
@@ -1418,7 +1461,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
yystacksize = YYINITDEPTH;]b4_lac_if([[
|
||||
|
||||
yyes = yyesa;
|
||||
yyes_capacity = sizeof yyesa / sizeof *yyes;
|
||||
yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[;
|
||||
if (YYMAXDEPTH < yyes_capacity)
|
||||
yyes_capacity = YYMAXDEPTH;]])[
|
||||
|
||||
@@ -1450,10 +1493,14 @@ yynewstate:
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------.
|
||||
| yynewstate -- set current state (the top of the stack) to yystate. |
|
||||
| yysetstate -- set current state (the top of the stack) to yystate. |
|
||||
`--------------------------------------------------------------------*/
|
||||
yysetstate:
|
||||
*yyssp = (yytype_int16) yystate;
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
|
||||
YY_IGNORE_USELESS_CAST_BEGIN
|
||||
*yyssp = YY_CAST (yy_state_t, yystate);
|
||||
YY_IGNORE_USELESS_CAST_END
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
|
||||
@@ -1461,15 +1508,15 @@ yysetstate:
|
||||
#else
|
||||
{
|
||||
/* Get the current used size of the three stacks, in elements. */
|
||||
YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
|
||||
YYPTRDIFF_T yysize = yyssp - yyss + 1;
|
||||
|
||||
# if defined yyoverflow
|
||||
{
|
||||
/* Give user a chance to reallocate the stack. Use copies of
|
||||
these so that the &'s don't force the real ones into
|
||||
memory. */
|
||||
YYSTYPE *yyvs1 = yyvs;
|
||||
yytype_int16 *yyss1 = yyss;]b4_locations_if([
|
||||
yy_state_t *yyss1 = yyss;
|
||||
YYSTYPE *yyvs1 = yyvs;]b4_locations_if([
|
||||
YYLTYPE *yyls1 = yyls;])[
|
||||
|
||||
/* Each stack pointer address is followed by the size of the
|
||||
@@ -1477,9 +1524,9 @@ yysetstate:
|
||||
conditional around just the two extra args, but that might
|
||||
be undefined if yyoverflow is a macro. */
|
||||
yyoverflow (YY_("memory exhausted"),
|
||||
&yyss1, yysize * sizeof (*yyssp),
|
||||
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
|
||||
&yyls1, yysize * sizeof (*yylsp),])[
|
||||
&yyss1, yysize * YYSIZEOF (*yyssp),
|
||||
&yyvs1, yysize * YYSIZEOF (*yyvsp),]b4_locations_if([
|
||||
&yyls1, yysize * YYSIZEOF (*yylsp),])[
|
||||
&yystacksize);
|
||||
yyss = yyss1;
|
||||
yyvs = yyvs1;]b4_locations_if([
|
||||
@@ -1494,9 +1541,10 @@ yysetstate:
|
||||
yystacksize = YYMAXDEPTH;
|
||||
|
||||
{
|
||||
yytype_int16 *yyss1 = yyss;
|
||||
yy_state_t *yyss1 = yyss;
|
||||
union yyalloc *yyptr =
|
||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
||||
YY_CAST (union yyalloc *,
|
||||
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
|
||||
if (! yyptr)
|
||||
goto yyexhaustedlab;
|
||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||
@@ -1512,16 +1560,16 @@ yysetstate:
|
||||
yyvsp = yyvs + yysize - 1;]b4_locations_if([
|
||||
yylsp = yyls + yysize - 1;])[
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long) yystacksize));
|
||||
YY_IGNORE_USELESS_CAST_BEGIN
|
||||
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
|
||||
YY_CAST (long, yystacksize)));
|
||||
YY_IGNORE_USELESS_CAST_END
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
}
|
||||
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
|
||||
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
|
||||
if (yystate == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
@@ -1605,16 +1653,15 @@ yyread_pushed_token:]])[
|
||||
|
||||
/* Shift the lookahead token. */
|
||||
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
||||
yystate = yyn;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
*++yyvsp = yylval;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END]b4_locations_if([
|
||||
*++yylsp = yylloc;])[
|
||||
|
||||
/* Discard the shifted token. */
|
||||
yychar = YYEMPTY;]b4_lac_if([[
|
||||
YY_LAC_DISCARD ("shift");]])[
|
||||
|
||||
yystate = yyn;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
*++yyvsp = yylval;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
]b4_locations_if([ *++yylsp = yylloc;])[
|
||||
goto yynewstate;
|
||||
|
||||
|
||||
@@ -1662,7 +1709,7 @@ yyreduce:
|
||||
}]], [[
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_user_actions[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}]])[
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@@ -1729,7 +1776,7 @@ yyerrlab:
|
||||
{
|
||||
if (yymsg != yymsgbuf)
|
||||
YYSTACK_FREE (yymsg);
|
||||
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
|
||||
yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
|
||||
if (!yymsg)
|
||||
{
|
||||
yymsg = yymsgbuf;
|
||||
@@ -1917,11 +1964,3 @@ yypushreturn:]])[
|
||||
}
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end
|
||||
|
||||
b4_defines_if([[
|
||||
]b4_output_begin([b4_spec_defines_file])[
|
||||
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||
]b4_disclaimer[
|
||||
]b4_shared_declarations[
|
||||
]b4_output_end[
|
||||
]])# b4_defines_if
|
||||
|
||||
@@ -31,3 +31,5 @@
|
||||
/version.texi
|
||||
/yacc.1
|
||||
/relocatable.texi
|
||||
/figs/*.eps
|
||||
/figs/*.svg
|
||||
|
||||
+1167
-789
File diff suppressed because it is too large
Load Diff
+35
-11
@@ -14,7 +14,12 @@
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AM_MAKEINFOFLAGS = --no-split
|
||||
AM_MAKEINFOFLAGS = \
|
||||
--no-split \
|
||||
--set-customization-variable=SECTION_NAME_IN_TITLE=true \
|
||||
--set-customization-variable=AVOID_MENU_REDUNDANCY=true \
|
||||
--set-customization-variable=ICONS=true
|
||||
|
||||
info_TEXINFOS = doc/bison.texi
|
||||
doc_bison_TEXINFOS = \
|
||||
$(CROSS_OPTIONS_TEXI) \
|
||||
@@ -28,7 +33,7 @@ doc_bison = doc/bison
|
||||
$(doc_bison).dvi: $(FIGS_GV:.gv=.eps)
|
||||
$(doc_bison).info: $(FIGS_GV:.gv=.txt)
|
||||
$(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
||||
$(doc_bison).html: $(FIGS_GV:.gv=.png)
|
||||
$(doc_bison).html: $(FIGS_GV:.gv=.svg)
|
||||
|
||||
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
||||
CLEANDIRS += doc/bison.t2d
|
||||
@@ -49,6 +54,23 @@ $(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||
|
||||
|
||||
# Fix Info's @code in @deftype
|
||||
# https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html
|
||||
all: $(srcdir)/$(doc_bison).info.bak
|
||||
$(srcdir)/$(doc_bison).info.bak: $(srcdir)/$(doc_bison).info
|
||||
$(AM_V_GEN) $(PERL) -pi.bak -0777 \
|
||||
-e 's{(^ --.*\n(?: {10}.*\n)*)}' \
|
||||
-e '{' \
|
||||
-e ' $$def = $$1;' \
|
||||
-e ' $$def =~ s/‘|’//g;' \
|
||||
-e ' $$def;' \
|
||||
-e '}gem;' $(srcdir)/$(doc_bison).info
|
||||
@ touch $@
|
||||
EXTRA_DIST += $(srcdir)/$(doc_bison).info.bak
|
||||
MAINTAINERCLEANFILES += $(srcdir)/$(doc_bison).info.bak
|
||||
|
||||
|
||||
## ---------- ##
|
||||
## Ref card. ##
|
||||
## ---------- ##
|
||||
@@ -88,11 +110,13 @@ EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
||||
if ! CROSS_COMPILING
|
||||
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
||||
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
||||
$(AM_V_GEN)LC_ALL=C src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
||||
$(AM_V_at) LC_ALL=C src/bison$(EXEEXT) --help | \
|
||||
$(AM_V_GEN)LC_ALL=C tests/bison --version >doc/bison.help.tmp
|
||||
$(AM_V_at) LC_ALL=C tests/bison --help | \
|
||||
## Avoid depending on the path to Bison.
|
||||
sed -e 's,^Usage: .*/bison \[OPTION\],Usage: bison [OPTION],g' \
|
||||
## Avoid variations in the output depending on whether we are
|
||||
## on a glibc system.
|
||||
sed '/translation bugs/d' >>doc/bison.help.tmp
|
||||
-e '/translation bugs/d' >>doc/bison.help.tmp
|
||||
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
||||
endif ! CROSS_COMPILING
|
||||
|
||||
@@ -118,7 +142,7 @@ endif
|
||||
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
||||
$(AM_V_GEN)$(HELP2MAN) \
|
||||
--include=$(top_srcdir)/doc/bison.x \
|
||||
--output=$@.tmp src/bison$(EXEEXT)
|
||||
--output=$@.tmp tests/bison
|
||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.tmp 2>/dev/null && \
|
||||
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
|
||||
touch $@; \
|
||||
@@ -135,14 +159,14 @@ endif
|
||||
## Graphviz examples generation. ##
|
||||
## ----------------------------- ##
|
||||
|
||||
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
|
||||
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||
FIGS_GV = \
|
||||
doc/figs/example.gv \
|
||||
doc/figs/example-reduce.gv doc/figs/example-shift.gv
|
||||
EXTRA_DIST += \
|
||||
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
|
||||
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
|
||||
SUFFIXES += .gv .eps .pdf .png
|
||||
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||
SUFFIXES += .gv .eps .pdf .svg
|
||||
|
||||
.gv.eps:
|
||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||
@@ -154,9 +178,9 @@ SUFFIXES += .gv .eps .pdf .png
|
||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
||||
$(AM_V_at) mv $@.tmp $@
|
||||
|
||||
.gv.png:
|
||||
.gv.svg:
|
||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp
|
||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tsvg $< >$@.tmp
|
||||
$(AM_V_at) mv $@.tmp $@
|
||||
|
||||
## -------------- ##
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/simple.yy
|
||||
@@ -18,8 +18,6 @@
|
||||
## Parser generation. ##
|
||||
## ------------------- ##
|
||||
|
||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||
# in srcdir, including during distcheck, which is forbidden.
|
||||
%D%/parser.stamp: $(dependencies)
|
||||
SUFFIXES += .yy .stamp
|
||||
.yy.stamp:
|
||||
@@ -33,6 +31,7 @@ $(calcxx_sources_generated): %D%/parser.stamp
|
||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/parser.stamp
|
||||
CLEANFILES += \
|
||||
$(calcxx_sources_generated) \
|
||||
%D%/parser.dot \
|
||||
%D%/parser.output \
|
||||
%D%/parser.stamp \
|
||||
%D%/scanner.cc
|
||||
|
||||
@@ -68,4 +68,6 @@ endif
|
||||
EXTRA_DIST += %D%/variant-11.test
|
||||
|
||||
dist_cxx_DATA = %D%/README.md %D%/Makefile %D%/variant.yy %D%/variant-11.yy
|
||||
CLEANFILES += %D%/simple.output %D%/variant.output %D%/variant-11.output
|
||||
CLEANFILES += \
|
||||
%D%/simple.output %D%/variant.output %D%/variant-11.output \
|
||||
%D%/simple.hh %D%/variant.hh %D%/variant-11.hh
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace yy
|
||||
static int count = 0;
|
||||
const int stage = count;
|
||||
++count;
|
||||
auto loc = parser::location_type{nullptr, unsigned (stage + 1), unsigned (stage + 1)};
|
||||
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)
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace yy
|
||||
static int count = 0;
|
||||
const int stage = count;
|
||||
++count;
|
||||
parser::location_type loc (NULLPTR, unsigned (stage + 1), unsigned (stage + 1));
|
||||
parser::location_type loc (NULLPTR, stage + 1, stage + 1);
|
||||
switch (stage)
|
||||
{
|
||||
case 0:
|
||||
|
||||
+27
-6
@@ -1,9 +1,11 @@
|
||||
This directory contains examples of Bison grammar files.
|
||||
# Examples in C
|
||||
|
||||
Most of them come from the documentation, which should be installed together
|
||||
This directory contains simple examples of Bison grammar files in C.
|
||||
|
||||
Some of them come from the documentation, which should be installed together
|
||||
with Bison. The URLs are provided for convenience.
|
||||
|
||||
# rpcalc - Reverse Polish Notation Calculator
|
||||
## rpcalc - Reverse Polish Notation Calculator
|
||||
The first example is that of a simple double-precision Reverse Polish
|
||||
Notation calculator (a calculator using postfix operators). This example
|
||||
provides a good starting point, since operator precedence is not an issue.
|
||||
@@ -11,12 +13,30 @@ 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.
|
||||
## calc - Simple Calculator
|
||||
This example is slightly more complex than rpcalc: it features infix
|
||||
operators (`1 + 2`, instead of `1 2 +` in rpcalc), but it does so using a
|
||||
unambiguous grammar of the arithmetic instead of using precedence
|
||||
directives (%left, etc.).
|
||||
|
||||
## mfcalc - Multi-Function Calculator
|
||||
A more complete C example: a multi-function calculator. More complex than
|
||||
the previous example. Using precedence directives to support infix
|
||||
operators.
|
||||
|
||||
Extracted from the documentation: "Multi-Function Calculator: mfcalc".
|
||||
https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
|
||||
|
||||
## lexcalc - calculator with Flex and Bison
|
||||
The calculator, redux. This time using a scanner generated by Flex.
|
||||
|
||||
## reccalc - recursive calculator with Flex and Bison
|
||||
The example builds on top of the previous one to provide a reentrant parser.
|
||||
Such parsers can be called concurrently in different threads, or even
|
||||
recursively. To demonstrate this feature, expressions in parentheses are
|
||||
tokenized as strings, and then recursively parsed from the parser. So
|
||||
`(((1)+(2))*((3)+(4)))` uses eight parsers, with a depth of four.
|
||||
|
||||
|
||||
<!---
|
||||
|
||||
@@ -34,5 +54,6 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy
|
||||
# LocalWords: mfcalc calc parsers yy rpcalc lexcalc redux reccalc ispell
|
||||
# LocalWords: reentrant tokenized american postfix
|
||||
--->
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BASE = calc
|
||||
BISON = bison
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
all: $(BASE)
|
||||
|
||||
%.c %.h %.xml %.gv: %.y
|
||||
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
$(BASE): $(BASE).o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||
./$<
|
||||
|
||||
html: $(BASE).html
|
||||
%.html: %.xml
|
||||
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||
|
||||
CLEANFILES = \
|
||||
$(BASE) *.o $(BASE).[ch] $(BASE).output $(BASE).xml $(BASE).html $(BASE).gv
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
@@ -0,0 +1,28 @@
|
||||
# calc - calculator with Bison
|
||||
|
||||
This directory contains calc, the traditional example of using Bison to
|
||||
build a simple calculator.
|
||||
|
||||
<!---
|
||||
Local Variables:
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--->
|
||||
@@ -0,0 +1,37 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
EOF
|
||||
run 0 7
|
||||
|
||||
cat >input <<EOF
|
||||
1 - 2 - 3
|
||||
EOF
|
||||
run 0 -4
|
||||
|
||||
cat >input <<EOF
|
||||
8 / 2 / 2
|
||||
EOF
|
||||
run 0 2
|
||||
|
||||
cat >input <<EOF
|
||||
(1+2) * 3
|
||||
EOF
|
||||
run 0 9
|
||||
run -noerr 0 9 -p
|
||||
@@ -0,0 +1,93 @@
|
||||
%code top {
|
||||
#include <ctype.h> /* isdigit. */
|
||||
#include <stdio.h> /* For printf, etc. */
|
||||
#include <string.h> /* strcmp. */
|
||||
|
||||
int yylex (void);
|
||||
void yyerror (char const *);
|
||||
}
|
||||
|
||||
%define api.header.include {"calc.h"}
|
||||
%define api.value.type union /* Generate YYSTYPE from these types: */
|
||||
%token <double> NUM "number"
|
||||
%type <double> expr term fact
|
||||
|
||||
/* Generate the parser description file. */
|
||||
%verbose
|
||||
/* Enable run-time traces (yydebug). */
|
||||
%define parse.trace
|
||||
|
||||
/* Formatting semantic values. */
|
||||
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||
|
||||
%% /* The grammar follows. */
|
||||
input:
|
||||
%empty
|
||||
| input line
|
||||
;
|
||||
|
||||
line:
|
||||
'\n'
|
||||
| expr '\n' { printf ("%.10g\n", $1); }
|
||||
| error '\n' { yyerrok; }
|
||||
;
|
||||
|
||||
expr:
|
||||
expr '+' term { $$ = $1 + $3; }
|
||||
| expr '-' term { $$ = $1 - $3; }
|
||||
| term
|
||||
;
|
||||
|
||||
term:
|
||||
term '*' fact { $$ = $1 * $3; }
|
||||
| term '/' fact { $$ = $1 / $3; }
|
||||
| fact
|
||||
;
|
||||
|
||||
fact:
|
||||
"number"
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
int
|
||||
yylex (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Ignore white space, get first nonwhite character. */
|
||||
while ((c = getchar ()) == ' ' || c == '\t')
|
||||
continue;
|
||||
|
||||
if (c == EOF)
|
||||
return 0;
|
||||
|
||||
/* Char starts a number => parse the number. */
|
||||
if (c == '.' || isdigit (c))
|
||||
{
|
||||
ungetc (c, stdin);
|
||||
scanf ("%lf", &yylval.NUM);
|
||||
return NUM;
|
||||
}
|
||||
|
||||
/* Any other character is a token by itself. */
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Called by yyparse on error. */
|
||||
void
|
||||
yyerror (char const *s)
|
||||
{
|
||||
fprintf (stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char const* argv[])
|
||||
{
|
||||
/* Enable parse traces on option -p. */
|
||||
for (int i = 1; i < argc; ++i)
|
||||
if (!strcmp (argv[i], "-p"))
|
||||
yydebug = 1;
|
||||
return yyparse ();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
## Copyright (C) 2019 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/>.
|
||||
|
||||
calcdir = $(docdir)/%D%
|
||||
|
||||
## ------ ##
|
||||
## Calc. ##
|
||||
## ------ ##
|
||||
|
||||
check_PROGRAMS += %D%/calc
|
||||
TESTS += %D%/calc.test
|
||||
EXTRA_DIST += %D%/calc.test
|
||||
nodist_%C%_calc_SOURCES = %D%/calc.y
|
||||
%D%/calc.c: $(dependencies)
|
||||
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
|
||||
dist_calc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/calc.[ch] %D%/calc.output %D%/scan.c
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
@@ -15,7 +15,7 @@ all: $(BASE)
|
||||
$(FLEX) $(FLEXFLAGS) -o$@ $<
|
||||
|
||||
scan.o: parse.h
|
||||
lexcalc: parse.o scan.o
|
||||
$(BASE): parse.o scan.o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
run: $(BASE)
|
||||
|
||||
@@ -25,3 +25,8 @@ cat >input <<EOF
|
||||
EOF
|
||||
run 0 9
|
||||
run -noerr 0 9 -p
|
||||
|
||||
cat >input <<EOF
|
||||
(1+2) *
|
||||
EOF
|
||||
run 1 'err: syntax error, unexpected end-of-line, expecting ( or number'
|
||||
|
||||
+14
-11
@@ -15,18 +15,21 @@
|
||||
|
||||
lexcalcdir = $(docdir)/%D%
|
||||
|
||||
## ------ ##
|
||||
## Calc. ##
|
||||
## ------ ##
|
||||
## --------- ##
|
||||
## LexCalc. ##
|
||||
## --------- ##
|
||||
|
||||
if FLEX_WORKS
|
||||
check_PROGRAMS += %D%/lexcalc
|
||||
TESTS += %D%/lexcalc.test
|
||||
nodist_%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
endif FLEX_WORKS
|
||||
|
||||
%D%/parse.c: $(dependencies)
|
||||
|
||||
check_PROGRAMS += %D%/lexcalc
|
||||
TESTS += %D%/lexcalc.test
|
||||
EXTRA_DIST += %D%/lexcalc.test
|
||||
%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
|
||||
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
|
||||
dist_lexcalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/lexcalc %D%/*.o %D%/parse.c %D%/scan.c
|
||||
CLEANFILES += %D%/parse.[ch] %D%/scan.c %D%/parse.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
+11
-11
@@ -15,8 +15,8 @@
|
||||
// Emitted on top of the implementation file.
|
||||
%code top
|
||||
{
|
||||
#include <stdio.h> /* printf. */
|
||||
#include <stdlib.h> /* getenv. */
|
||||
#include <stdio.h> // printf.
|
||||
#include <stdlib.h> // getenv.
|
||||
}
|
||||
|
||||
%define api.pure full
|
||||
@@ -39,7 +39,7 @@
|
||||
;
|
||||
|
||||
%token <int> NUM "number"
|
||||
%type <int> exp line
|
||||
%type <int> exp
|
||||
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||
|
||||
// Precedence (from lowest to highest) and associativity.
|
||||
@@ -50,18 +50,18 @@
|
||||
// Rules.
|
||||
input:
|
||||
%empty
|
||||
| input line { printf ("%d\n", $line); }
|
||||
| input line
|
||||
;
|
||||
|
||||
line:
|
||||
exp EOL { $$ = $1; }
|
||||
exp EOL { printf ("%d\n", $exp); }
|
||||
| error EOL { yyerrok; }
|
||||
;
|
||||
|
||||
exp:
|
||||
exp "+" exp { $$ = $1 + $3; }
|
||||
| exp "-" exp { $$ = $1 - $3; }
|
||||
| exp "*" exp { $$ = $1 * $3; }
|
||||
exp "+" exp { $$ = $1 + $3; }
|
||||
| exp "-" exp { $$ = $1 - $3; }
|
||||
| exp "*" exp { $$ = $1 * $3; }
|
||||
| exp "/" exp
|
||||
{
|
||||
if ($3 == 0)
|
||||
@@ -72,15 +72,15 @@ exp:
|
||||
else
|
||||
$$ = $1 / $3;
|
||||
}
|
||||
| "(" exp ")" { $$ = $2; }
|
||||
| "(" exp ")" { $$ = $2; }
|
||||
| NUM { $$ = $1; }
|
||||
;
|
||||
%%
|
||||
// Epilogue (C code).
|
||||
void yyerror(int *nerrs, const char *msg)
|
||||
void yyerror (int *nerrs, const char *msg)
|
||||
{
|
||||
fprintf (stderr, "%s\n", msg);
|
||||
++nerrs;
|
||||
++*nerrs;
|
||||
}
|
||||
|
||||
int main (void)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
%option nodefault noinput nounput noyywrap
|
||||
|
||||
%{
|
||||
#include <errno.h> /* errno, ERANGE */
|
||||
#include <limits.h> /* INT_MIN */
|
||||
#include <stdlib.h> /* strtol */
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
cdir = $(docdir)/%D%
|
||||
dist_c_DATA = %D%/README.md
|
||||
|
||||
include %D%/calc/local.mk
|
||||
include %D%/lexcalc/local.mk
|
||||
include %D%/mfcalc/local.mk
|
||||
include %D%/reccalc/local.mk
|
||||
include %D%/rpcalc/local.mk
|
||||
|
||||
@@ -28,6 +28,7 @@ extracted += $(mfcalc_extracted)
|
||||
|
||||
check_PROGRAMS += %D%/mfcalc
|
||||
nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
|
||||
%D%/mfcalc.c: $(dependencies)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
%C%_mfcalc_LDADD = -lm
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/scan.c
|
||||
/scan.h
|
||||
@@ -0,0 +1,35 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BASE = reccalc
|
||||
BISON = bison
|
||||
FLEX = flex
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
all: $(BASE)
|
||||
|
||||
%.c %.h %.xml %.gv: %.y
|
||||
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
%.c %.h: %.l
|
||||
$(FLEX) $(FLEXFLAGS) -o$*.c --header-file=$*.h $<
|
||||
|
||||
scan.o: parse.h
|
||||
parse.o: scan.h
|
||||
$(BASE): parse.o scan.o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||
./$<
|
||||
|
||||
html: parse.html
|
||||
%.html: %.xml
|
||||
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||
|
||||
CLEANFILES = \
|
||||
$(BASE) *.o \
|
||||
parse.[ch] parse.output parse.xml parse.html parse.gv \
|
||||
scan.[ch]
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
@@ -0,0 +1,45 @@
|
||||
# reccalc - recursive calculator with Flex and Bison
|
||||
|
||||
In this example the generated parser is pure and reentrant: it can be used
|
||||
concurrently in different threads, or recursively. As a proof of this
|
||||
reentrancy, expressions in parenthesis are tokenized as strings, and then
|
||||
recursively parsed from the parser:
|
||||
|
||||
```
|
||||
exp: STR
|
||||
{
|
||||
result r = parse_string ($1);
|
||||
free ($1);
|
||||
if (r.nerrs)
|
||||
{
|
||||
res->nerrs += r.nerrs;
|
||||
YYERROR;
|
||||
}
|
||||
else
|
||||
$$ = r.value;
|
||||
}
|
||||
```
|
||||
|
||||
<!---
|
||||
Local Variables:
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--->
|
||||
@@ -0,0 +1,79 @@
|
||||
## Copyright (C) 2019 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/>.
|
||||
|
||||
reccalcdir = $(docdir)/%D%
|
||||
|
||||
## --------- ##
|
||||
## RecCalc. ##
|
||||
## --------- ##
|
||||
|
||||
if FLEX_WORKS
|
||||
check_PROGRAMS += %D%/reccalc
|
||||
TESTS += %D%/reccalc.test
|
||||
nodist_%C%_reccalc_SOURCES = %D%/parse.y %D%/scan.h %D%/scan.c
|
||||
BUILT_SOURCES += $(nodist_%C%_reccalc_SOURCES)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_reccalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||
endif FLEX_WORKS
|
||||
|
||||
%D%/parse.c: $(dependencies)
|
||||
|
||||
# Tell Make that parse.o depends on scan.h, so that scan.h is built
|
||||
# before parse.o. Obfuscate the name of the target, otherwise
|
||||
# Automake removes its recipe for parse.o and leaves only our
|
||||
# additional dependency.
|
||||
DASH = -
|
||||
%D%/reccalc$(DASH)parse.o: %D%/scan.h
|
||||
# Tell Make scan.o depends on parse.h, except that Make sees only
|
||||
# parse.c, not parse.h. We can't use BUILT_SOURCES to this end, since
|
||||
# we use the built bison.
|
||||
%D%/reccalc$(DASH)scan.o: %D%/parse.c
|
||||
|
||||
# Likewise, but for Automake before 1.16.
|
||||
%D%/examples_c_reccalc_reccalc$(DASH)parse.o: %D%/scan.h
|
||||
%D%/examples_c_reccalc_reccalc$(DASH)scan.o: %D%/parse.c
|
||||
|
||||
## See "info automake 'Multiple Outputs'" for this rule.
|
||||
%D%/scan.c %D%/scan.h: %D%/scan.stamp
|
||||
## Recover from the removal of $@
|
||||
@if test -f $@; then :; else \
|
||||
trap 'rm -rf %D%/scan.lock %D%/scan.stamp' 1 2 13 15; \
|
||||
## mkdir is a portable test-and-set
|
||||
if mkdir %D%/scan.lock 2>/dev/null; then \
|
||||
## This code is being executed by the first process.
|
||||
rm -f %D%/scan.stamp; \
|
||||
$(MAKE) $(AM_MAKEFLAGS) %D%/scan.stamp; \
|
||||
result=$$?; rm -rf %D%/scan.lock; exit $$result; \
|
||||
else \
|
||||
## This code is being executed by the follower processes.
|
||||
## Wait until the first process is done.
|
||||
while test -d %D%/scan.lock; do sleep 1; done; \
|
||||
## Succeed if and only if the first process succeeded.
|
||||
test -f %D%/scan.stamp; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
%D%/scan.stamp: %D%/scan.l
|
||||
$(AM_V_LEX)rm -f $@ $@.tmp
|
||||
$(AM_V_at)$(MKDIR_P) %D%
|
||||
$(AM_V_at)touch $@.tmp
|
||||
$(AM_V_at)$(LEX) $(AM_LFLAGS) $(LFLAGS) -o%D%/scan.c --header-file=%D%/scan.h $(srcdir)/%D%/scan.l
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
|
||||
|
||||
EXTRA_DIST += %D%/reccalc.test %D%/scan.l
|
||||
dist_reccalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/parse.[ch] %D%/parse.output %D%/scan.[ch] %D%/*.stamp
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
@@ -0,0 +1,183 @@
|
||||
// Prologue (directives).
|
||||
%expect 0
|
||||
|
||||
// Emitted in the header file, before the definition of YYSTYPE.
|
||||
%code requires
|
||||
{
|
||||
typedef void* yyscan_t;
|
||||
typedef struct
|
||||
{
|
||||
// Whether to print the intermediate results.
|
||||
int verbose;
|
||||
// Value of the last computation.
|
||||
int value;
|
||||
// Number of errors.
|
||||
int nerrs;
|
||||
} result;
|
||||
}
|
||||
|
||||
// Emitted in the header file, after the definition of YYSTYPE.
|
||||
%code provides
|
||||
{
|
||||
// Tell Flex the expected prototype of yylex.
|
||||
// The scanner argument must be named yyscanner.
|
||||
#define YY_DECL \
|
||||
enum yytokentype yylex (YYSTYPE* yylval, yyscan_t yyscanner, result *res)
|
||||
YY_DECL;
|
||||
|
||||
void yyerror (yyscan_t scanner, result *res, const char *msg, ...);
|
||||
}
|
||||
|
||||
// Emitted on top of the implementation file.
|
||||
%code top
|
||||
{
|
||||
#include <stdarg.h> // va_list.
|
||||
#include <stdio.h> // printf.
|
||||
#include <stdlib.h> // getenv.
|
||||
}
|
||||
|
||||
%code
|
||||
{
|
||||
result parse_string (const char* cp);
|
||||
result parse (void);
|
||||
}
|
||||
|
||||
%define api.pure full
|
||||
%define api.token.prefix {TOK_}
|
||||
%define api.value.type union
|
||||
%define parse.error verbose
|
||||
%define parse.trace
|
||||
%verbose
|
||||
|
||||
// Scanner and error count are exchanged between main, yyparse and yylex.
|
||||
%param {yyscan_t scanner}{result *res}
|
||||
|
||||
%token
|
||||
PLUS "+"
|
||||
MINUS "-"
|
||||
STAR "*"
|
||||
SLASH "/"
|
||||
EOL "end-of-line"
|
||||
EOF 0 "end-of-file"
|
||||
;
|
||||
|
||||
%token <int> NUM "number"
|
||||
%type <int> exp
|
||||
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||
|
||||
%token <char*> STR "string"
|
||||
%printer { fprintf (yyo, "\"%s\"", $$); } <char*>
|
||||
%destructor { free ($$); } <char*>
|
||||
|
||||
// Precedence (from lowest to highest) and associativity.
|
||||
%left "+" "-"
|
||||
%left "*" "/"
|
||||
%precedence UNARY
|
||||
|
||||
%%
|
||||
// Rules.
|
||||
input:
|
||||
line
|
||||
| input line
|
||||
;
|
||||
|
||||
line:
|
||||
exp eol
|
||||
{
|
||||
res->value = $exp;
|
||||
if (res->verbose)
|
||||
printf ("%d\n", $exp);
|
||||
}
|
||||
| error eol
|
||||
{
|
||||
yyerrok;
|
||||
}
|
||||
;
|
||||
|
||||
eol:
|
||||
EOF
|
||||
| EOL
|
||||
;
|
||||
|
||||
exp:
|
||||
NUM { $$ = $1; }
|
||||
| exp "+" exp { $$ = $1 + $3; }
|
||||
| exp "-" exp { $$ = $1 - $3; }
|
||||
| exp "*" exp { $$ = $1 * $3; }
|
||||
| exp "/" exp
|
||||
{
|
||||
if ($3 == 0)
|
||||
{
|
||||
yyerror (scanner, res, "invalid division by zero");
|
||||
YYERROR;
|
||||
}
|
||||
else
|
||||
$$ = $1 / $3;
|
||||
}
|
||||
| "+" exp %prec UNARY { $$ = + $2; }
|
||||
| "-" exp %prec UNARY { $$ = - $2; }
|
||||
| STR
|
||||
{
|
||||
result r = parse_string ($1);
|
||||
free ($1);
|
||||
if (r.nerrs)
|
||||
{
|
||||
res->nerrs += r.nerrs;
|
||||
YYERROR;
|
||||
}
|
||||
else
|
||||
$$ = r.value;
|
||||
}
|
||||
;
|
||||
|
||||
%%
|
||||
// Epilogue (C code).
|
||||
|
||||
#include "scan.h"
|
||||
|
||||
result
|
||||
parse (void)
|
||||
{
|
||||
yyscan_t scanner;
|
||||
yylex_init (&scanner);
|
||||
result res = {1, 0, 0};
|
||||
yyparse (scanner, &res);
|
||||
yylex_destroy (scanner);
|
||||
return res;
|
||||
}
|
||||
|
||||
result
|
||||
parse_string (const char *str)
|
||||
{
|
||||
yyscan_t scanner;
|
||||
yylex_init (&scanner);
|
||||
YY_BUFFER_STATE buf = yy_scan_string (str ? str : "", scanner);
|
||||
result res = {0, 0, 0};
|
||||
yyparse (scanner, &res);
|
||||
yy_delete_buffer (buf, scanner);
|
||||
yylex_destroy (scanner);
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
yyerror (yyscan_t scanner, result *res,
|
||||
const char *msg, ...)
|
||||
{
|
||||
(void) scanner;
|
||||
va_list args;
|
||||
va_start (args, msg);
|
||||
vfprintf (stderr, msg, args);
|
||||
va_end (args);
|
||||
fputc ('\n', stderr);
|
||||
res->nerrs += 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
// Possibly enable parser runtime debugging.
|
||||
yydebug = !!getenv ("YYDEBUG");
|
||||
result res = parse ();
|
||||
// Exit on failure if there were errors.
|
||||
return !!res.nerrs;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cat >input <<EOF
|
||||
1+2*3
|
||||
EOF
|
||||
run 0 '7'
|
||||
|
||||
cat >input <<EOF
|
||||
(1+2) * 3
|
||||
EOF
|
||||
run 0 '9'
|
||||
run -noerr 0 '9' -p
|
||||
|
||||
cat >input <<EOF
|
||||
(((1)+(2))*((3)+(4)))
|
||||
EOF
|
||||
run 0 '21'
|
||||
|
||||
# Some really deep computation.
|
||||
# for 4, gives 4 + (3 + (2 + (1 + (- (4 * (4 + 1)) / 2)))).
|
||||
n=100
|
||||
for i in $(seq 0 $n)
|
||||
do
|
||||
if [ "$i" -eq 0 ]; then
|
||||
input="- ($n * ($n + 1)) / 2"
|
||||
else
|
||||
input="$i + ($input)"
|
||||
fi
|
||||
done
|
||||
echo "$input" > input
|
||||
run 0 '0'
|
||||
|
||||
cat >input <<EOF
|
||||
() + ()
|
||||
EOF
|
||||
run 1 'err: syntax error, unexpected end-of-file, expecting + or - or number or string'
|
||||
|
||||
cat >input <<EOF
|
||||
1 + $
|
||||
EOF
|
||||
run 1 'err: syntax error, invalid character: $
|
||||
err: syntax error, unexpected end-of-line, expecting + or - or number or string'
|
||||
@@ -0,0 +1,85 @@
|
||||
/* Prologue (directives). -*- C++ -*- */
|
||||
|
||||
/* Disable Flex features we don't need, to avoid warnings. */
|
||||
%option nodefault noinput nounput noyywrap
|
||||
|
||||
%option reentrant
|
||||
|
||||
%{
|
||||
#include <assert.h>
|
||||
#include <limits.h> /* INT_MIN */
|
||||
#include <stdlib.h> /* strtol */
|
||||
|
||||
#include "parse.h"
|
||||
%}
|
||||
|
||||
%x SC_STRING
|
||||
|
||||
%%
|
||||
%{
|
||||
int nesting = 0;
|
||||
char *str = NULL;
|
||||
int size = 0;
|
||||
int capacity = 0;
|
||||
#define STR_APPEND() \
|
||||
do { \
|
||||
if (capacity < size + yyleng + 1) \
|
||||
{ \
|
||||
do \
|
||||
capacity = capacity ? 2 * capacity : 128; \
|
||||
while (capacity < size + yyleng + 1); \
|
||||
str = realloc (str, capacity); \
|
||||
} \
|
||||
memcpy (str + size, yytext, yyleng); \
|
||||
size += yyleng; \
|
||||
assert (size < capacity); \
|
||||
} while (0)
|
||||
%}
|
||||
|
||||
// Rules.
|
||||
|
||||
"+" return TOK_PLUS;
|
||||
"-" return TOK_MINUS;
|
||||
"*" return TOK_STAR;
|
||||
"/" return TOK_SLASH;
|
||||
|
||||
"(" nesting += 1; BEGIN SC_STRING;
|
||||
|
||||
/* Scan an integer. */
|
||||
[0-9]+ {
|
||||
errno = 0;
|
||||
long n = strtol (yytext, NULL, 10);
|
||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||
yyerror (yyscanner, res, "integer is out of range");
|
||||
yylval->TOK_NUM = (int) n;
|
||||
return TOK_NUM;
|
||||
}
|
||||
|
||||
/* Ignore white spaces. */
|
||||
[ \t]+ continue;
|
||||
|
||||
"\n" return TOK_EOL;
|
||||
|
||||
. yyerror (yyscanner, res, "syntax error, invalid character: %c", yytext[0]);
|
||||
|
||||
<SC_STRING>
|
||||
{
|
||||
"("+ nesting += yyleng; STR_APPEND ();
|
||||
")" {
|
||||
if (!--nesting)
|
||||
{
|
||||
BEGIN INITIAL;
|
||||
if (str)
|
||||
str[size] = 0;
|
||||
yylval->TOK_STR = str;
|
||||
return TOK_STR;
|
||||
}
|
||||
else
|
||||
STR_APPEND ();
|
||||
}
|
||||
[^()]+ STR_APPEND ();
|
||||
}
|
||||
|
||||
<<EOF>> return TOK_EOF;
|
||||
%%
|
||||
/* Epilogue (C code). */
|
||||
@@ -28,6 +28,7 @@ extracted += $(rpcalc_extracted)
|
||||
|
||||
check_PROGRAMS += %D%/rpcalc
|
||||
nodist_%C%_rpcalc_SOURCES = $(rpcalc_sources)
|
||||
%D%/rpcalc.c: $(dependencies)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_rpcalc_CPPFLAGS = -I$(top_builddir)/%D%
|
||||
%C%_rpcalc_LDADD = -lm
|
||||
|
||||
@@ -23,4 +23,4 @@ run 0 7
|
||||
cat >input <<EOF
|
||||
1 + 2 * * 3
|
||||
EOF
|
||||
run 0 "err: syntax error, unexpected *, expecting - or ! or ( or number"
|
||||
run 1 "err: syntax error, unexpected *, expecting + or - or ( or number"
|
||||
|
||||
+59
-78
@@ -3,11 +3,6 @@
|
||||
%define api.parser.class {Calc}
|
||||
%define parse.error verbose
|
||||
|
||||
%code imports {
|
||||
import std.ascii;
|
||||
import std.stdio;
|
||||
}
|
||||
|
||||
%union {
|
||||
int ival;
|
||||
}
|
||||
@@ -18,17 +13,15 @@
|
||||
MINUS "-"
|
||||
STAR "*"
|
||||
SLASH "/"
|
||||
BANG "!"
|
||||
LPAR "("
|
||||
RPAR ")"
|
||||
EOL "end of line"
|
||||
%token <ival> NUM "number"
|
||||
%type <ival> exp
|
||||
|
||||
%nonassoc "=" /* comparison */
|
||||
%left "-" "+"
|
||||
%left "*" "/"
|
||||
%precedence NEG /* negation--unary minus */
|
||||
%precedence UNARY /* unary operators */
|
||||
|
||||
/* Grammar follows */
|
||||
%%
|
||||
@@ -44,96 +37,84 @@ line:
|
||||
;
|
||||
|
||||
exp:
|
||||
NUM { $$ = $1; }
|
||||
| exp "=" exp
|
||||
{
|
||||
if ($1 != $3)
|
||||
yyerror (format ("calc: error: %d != %d", $1, $3));
|
||||
}
|
||||
| exp "+" exp { $$ = $1 + $3; }
|
||||
| exp "-" exp { $$ = $1 - $3; }
|
||||
| exp "*" exp { $$ = $1 * $3; }
|
||||
| exp "/" exp { $$ = $1 / $3; }
|
||||
| "-" exp %prec NEG { $$ = -$2; }
|
||||
| "(" exp ")" { $$ = $2; }
|
||||
| "(" error ")" { $$ = 1111; }
|
||||
| "!" { $$ = 0; return YYERROR; }
|
||||
| "-" error { $$ = 0; return YYERROR; }
|
||||
NUM { $$ = $1; }
|
||||
| exp "+" exp { $$ = $1 + $3; }
|
||||
| exp "-" exp { $$ = $1 - $3; }
|
||||
| exp "*" exp { $$ = $1 * $3; }
|
||||
| exp "/" exp { $$ = $1 / $3; }
|
||||
| "+" exp %prec UNARY { $$ = -$2; }
|
||||
| "-" exp %prec UNARY { $$ = -$2; }
|
||||
| "(" exp ")" { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
%%
|
||||
class CalcLexer : Lexer {
|
||||
import std.range.primitives;
|
||||
import std.stdio;
|
||||
|
||||
this ()
|
||||
{}
|
||||
auto calcLexer(R)(R range)
|
||||
if (isInputRange!R && is (ElementType!R : dchar))
|
||||
{
|
||||
return new CalcLexer!R(range);
|
||||
}
|
||||
|
||||
int
|
||||
get_char ()
|
||||
{
|
||||
import stdc = core.stdc.stdio;
|
||||
return stdc.getc (stdc.stdin);
|
||||
}
|
||||
auto calcLexer (File f)
|
||||
{
|
||||
import std.algorithm : map, joiner;
|
||||
import std.utf : byDchar;
|
||||
|
||||
void
|
||||
unget_char (int c)
|
||||
{
|
||||
import stdc = core.stdc.stdio;
|
||||
stdc.ungetc (c, stdc.stdin);
|
||||
}
|
||||
return f.byChunk(1024) // avoid making a syscall roundtrip per char
|
||||
.map!(chunk => cast(char[]) chunk) // because byChunk returns ubyte[]
|
||||
.joiner // combine chunks into a single virtual range of char
|
||||
.calcLexer; // forward to other overload
|
||||
}
|
||||
|
||||
class CalcLexer(R) : Lexer
|
||||
if (isInputRange!R && is (ElementType!R : dchar))
|
||||
{
|
||||
R input;
|
||||
|
||||
this(R r) { input = r; }
|
||||
|
||||
// Should be a local in main, shared with %parse-param.
|
||||
int exit_status = 0;
|
||||
|
||||
public void yyerror (string s)
|
||||
{
|
||||
exit_status = 1;
|
||||
stderr.writeln (s);
|
||||
}
|
||||
|
||||
int
|
||||
read_signed_integer ()
|
||||
{
|
||||
int c = get_char ();
|
||||
int sign = 1;
|
||||
int n = 0;
|
||||
|
||||
if (c == '-')
|
||||
{
|
||||
c = get_char ();
|
||||
sign = -1;
|
||||
}
|
||||
|
||||
while (isDigit (c))
|
||||
{
|
||||
n = 10 * n + (c - '0');
|
||||
c = get_char ();
|
||||
}
|
||||
|
||||
unget_char (c);
|
||||
return sign * n;
|
||||
}
|
||||
|
||||
YYSemanticType semanticVal_;
|
||||
|
||||
public final @property YYSemanticType semanticVal()
|
||||
public final @property YYSemanticType semanticVal ()
|
||||
{
|
||||
return semanticVal_;
|
||||
}
|
||||
|
||||
YYTokenType yylex ()
|
||||
int yylex ()
|
||||
{
|
||||
int c;
|
||||
/* Skip white spaces. */
|
||||
do
|
||||
{}
|
||||
while ((c = get_char ()) == ' ' || c == '\t');
|
||||
import std.uni : isWhite, isNumber;
|
||||
|
||||
/* process numbers */
|
||||
if (c == '.' || isDigit (c))
|
||||
// Skip initial spaces
|
||||
while (!input.empty && input.front != '\n' && isWhite (input.front))
|
||||
input.popFront;
|
||||
|
||||
// Handle EOF.
|
||||
if (input.empty)
|
||||
return YYTokenType.EOF;
|
||||
|
||||
// Numbers.
|
||||
if (input.front.isNumber)
|
||||
{
|
||||
unget_char (c);
|
||||
semanticVal_.ival = read_signed_integer ();
|
||||
import std.conv : parse;
|
||||
semanticVal_.ival = input.parse!int;
|
||||
return YYTokenType.NUM;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
// Individual characters
|
||||
auto ch = input.front;
|
||||
input.popFront;
|
||||
switch (ch)
|
||||
{
|
||||
case EOF: return YYTokenType.EOF;
|
||||
case '=': return YYTokenType.EQ;
|
||||
@@ -141,7 +122,6 @@ class CalcLexer : Lexer {
|
||||
case '-': return YYTokenType.MINUS;
|
||||
case '*': return YYTokenType.STAR;
|
||||
case '/': return YYTokenType.SLASH;
|
||||
case '!': return YYTokenType.BANG;
|
||||
case '(': return YYTokenType.LPAR;
|
||||
case ')': return YYTokenType.RPAR;
|
||||
case '\n': return YYTokenType.EOL;
|
||||
@@ -150,9 +130,10 @@ class CalcLexer : Lexer {
|
||||
}
|
||||
}
|
||||
|
||||
void main ()
|
||||
int main ()
|
||||
{
|
||||
CalcLexer l = new CalcLexer ();
|
||||
Calc p = new Calc (l);
|
||||
auto l = calcLexer (stdin);
|
||||
auto p = new Calc (l);
|
||||
p.parse ();
|
||||
return l.exit_status;
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,10 +27,10 @@ EXTRA_DIST += %D%/calc.test
|
||||
|
||||
%D%/calc.d: %D%/calc.y $(dependencies)
|
||||
$(AM_V_GEN)$(MKDIR_P) %D%
|
||||
$(AM_V_at)$(BISON) $< -o $@
|
||||
$(AM_V_at)$(BISON) $(srcdir)/%D%/calc.y -o $@
|
||||
|
||||
%D%/calc: %D%/calc.d
|
||||
$(AM_V_GEN) $(DC) $(DCFLAGS) -of$@ $<
|
||||
$(AM_V_GEN) $(DC) $(DCFLAGS) -of$@ %D%/calc.d
|
||||
|
||||
dist_d_DATA = %D%/calc.y %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/calc %D%/calc.[do]
|
||||
|
||||
+5
-1
@@ -60,7 +60,11 @@ sub normalize($)
|
||||
{
|
||||
local ($_) = @_;
|
||||
|
||||
s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*\n//mg;
|
||||
# If we just remove this lines, then the compiler's tracking of
|
||||
# #lines is broken. Leave lines that that accepted by all our tools
|
||||
# (including flex, hence the leading space), and that will be easy
|
||||
# to remove (see the Make examples-unline recipe).
|
||||
s{^\@(c |comment|dots|end (ignore|group)|ignore|group).*}{ /**/}mg;
|
||||
s/\@value\{VERSION\}/$ENV{VERSION}/g;
|
||||
s/^\@(error|result)\{\}//mg;
|
||||
s/\@([{}@])/$1/g;
|
||||
|
||||
@@ -78,9 +78,9 @@ class CalcLexer implements Calc.Lexer {
|
||||
st = new StreamTokenizer (new InputStreamReader (is));
|
||||
st.resetSyntax ();
|
||||
st.eolIsSignificant (true);
|
||||
st.whitespaceChars (9, 9);
|
||||
st.whitespaceChars (32, 32);
|
||||
st.wordChars (48, 57);
|
||||
st.whitespaceChars ('\t', '\t');
|
||||
st.whitespaceChars (' ', ' ');
|
||||
st.wordChars ('0', '9');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ EXTRA_DIST += %D%/Calc.test
|
||||
|
||||
%D%/Calc.java: %D%/Calc.y $(dependencies)
|
||||
$(AM_V_GEN)$(MKDIR_P) %D%
|
||||
$(AM_V_at)$(BISON) $< -o $@
|
||||
$(AM_V_at)$(BISON) $(srcdir)/%D%/Calc.y -o $@
|
||||
|
||||
%D%/Calc.class: %D%/Calc.java
|
||||
$(AM_V_GEN) $(SHELL) $(top_builddir)/javacomp.sh $<
|
||||
$(AM_V_GEN) $(SHELL) $(top_builddir)/javacomp.sh %D%/Calc.java
|
||||
|
||||
dist_java_DATA = %D%/Calc.y %D%/Makefile %D%/README.md
|
||||
CLEANFILES += %D%/*.class %D%/Calc.java
|
||||
|
||||
+21
-7
@@ -14,8 +14,26 @@
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
## Because some of our examples use
|
||||
##
|
||||
## %C%_reccalc_SOURCES = %D%/parse.y
|
||||
##
|
||||
## Automake ships parse.y and parse.c, and possibly parse.h when it
|
||||
## "understands" that there is one. This is not what we want: ship only
|
||||
## parser.y. Yet we still want to use Automake to compile the sources
|
||||
## from parser.y. The easiest seems to use
|
||||
##
|
||||
## nodist_%C%_reccalc_SOURCES = %D%/parse.y
|
||||
##
|
||||
## together with
|
||||
##
|
||||
## dist_reccalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
|
||||
##
|
||||
## which guarantees that parse.y is indeed shipped.
|
||||
|
||||
dist_noinst_SCRIPTS = %D%/extexi %D%/test
|
||||
TEST_LOG_COMPILER = $(top_srcdir)/%D%/test
|
||||
TEST_LOG_COMPILER = $(SHELL) $(top_srcdir)/%D%/test
|
||||
|
||||
AM_CXXFLAGS = \
|
||||
$(WARN_CXXFLAGS) $(WARN_CXXFLAGS_TEST) $(WERROR_CXXFLAGS)
|
||||
@@ -59,12 +77,8 @@ EXTRA_DIST += %D%/extracted.stamp
|
||||
dist-hook: examples-unline
|
||||
.PHONY: examples-unline
|
||||
examples-unline:
|
||||
for e in $(extracted); \
|
||||
do \
|
||||
e=$(distdir)/$$e; \
|
||||
sed -e '/#line/d' $$e >$$e.tmp; \
|
||||
mv -f $$e.tmp $$e; \
|
||||
done
|
||||
cd $(distdir) && \
|
||||
perl -pi -0777 -e 's/#line.*\n//g;s{^ /\*\*/\n}{}mg' $(extracted)
|
||||
|
||||
|
||||
## ---------- ##
|
||||
|
||||
+1
-1
Submodule gnulib updated: 34881aff40...b943dd6649
@@ -0,0 +1,20 @@
|
||||
/*.gmo
|
||||
/*.po
|
||||
/LINGUAS
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/Makefile.in.in
|
||||
/Makevars
|
||||
/Makevars.template
|
||||
/POTFILES
|
||||
/POTFILES.in
|
||||
/Rules-quot
|
||||
/bison-gnulib.pot
|
||||
/boldquot.sed
|
||||
/[email protected]
|
||||
/[email protected]
|
||||
/insert-header.sin
|
||||
/quot.sed
|
||||
/remove-potcdate.sed
|
||||
/remove-potcdate.sin
|
||||
/stamp-po
|
||||
+32
-3
@@ -16,6 +16,8 @@
|
||||
/argmatch.c
|
||||
/argmatch.h
|
||||
/asnprintf.c
|
||||
/asprintf.c
|
||||
/assure.h
|
||||
/basename-lgpl.c
|
||||
/basename.c
|
||||
/binary-io.c
|
||||
@@ -38,6 +40,7 @@
|
||||
/canonicalize-lgpl.c
|
||||
/careadlinkat.c
|
||||
/careadlinkat.h
|
||||
/cdefs.h
|
||||
/charset.alias
|
||||
/cloexec.c
|
||||
/cloexec.h
|
||||
@@ -51,6 +54,7 @@
|
||||
/config.h
|
||||
/config.in.h
|
||||
/configmake.h
|
||||
/diffseq.h
|
||||
/dirname-lgpl.c
|
||||
/dirname.c
|
||||
/dirname.h
|
||||
@@ -89,9 +93,13 @@
|
||||
/fseterr.c
|
||||
/fseterr.h
|
||||
/fstat.c
|
||||
/fstrcmp.c
|
||||
/fstrcmp.h
|
||||
/fsync.c
|
||||
/getdtablesize.c
|
||||
/gethrxtime.c
|
||||
/gethrxtime.h
|
||||
/getopt-cdefs.h
|
||||
/getopt-cdefs.in.h
|
||||
/getopt-core.h
|
||||
/getopt-ext.h
|
||||
@@ -129,8 +137,10 @@
|
||||
/isnanf.c
|
||||
/isnanl-nolibm.h
|
||||
/isnanl.c
|
||||
/iswblank.c
|
||||
/itold.c
|
||||
/ldexpl.c
|
||||
/libc-config.h
|
||||
/limits.h
|
||||
/limits.in.h
|
||||
/localcharset.c
|
||||
@@ -144,6 +154,10 @@
|
||||
/math.c
|
||||
/math.h
|
||||
/math.in.h
|
||||
/mbchar.c
|
||||
/mbchar.h
|
||||
/mbfile.c
|
||||
/mbfile.h
|
||||
/mbrtowc.c
|
||||
/mbsinit.c
|
||||
/mbswidth.c
|
||||
@@ -189,6 +203,9 @@
|
||||
/relocatable.c
|
||||
/relocatable.h
|
||||
/relocwrapper.c
|
||||
/rename.c
|
||||
/rmdir.c
|
||||
/same-inode.h
|
||||
/sched.h
|
||||
/sched.in.h
|
||||
/setenv.c
|
||||
@@ -264,6 +281,8 @@
|
||||
/sys_types.in.h
|
||||
/sys_wait.in.h
|
||||
/sysexits.in.h
|
||||
/textstyle.h
|
||||
/textstyle.in.h
|
||||
/time.h
|
||||
/time.in.h
|
||||
/timespec.c
|
||||
@@ -285,6 +304,7 @@
|
||||
/unsetenv.c
|
||||
/vasnprintf.c
|
||||
/vasnprintf.h
|
||||
/vasprintf.c
|
||||
/verify.h
|
||||
/vfprintf.c
|
||||
/vsnprintf.c
|
||||
@@ -300,10 +320,22 @@
|
||||
/wctype.h
|
||||
/wctype.in.h
|
||||
/wcwidth.c
|
||||
/windows-initguard.h
|
||||
/windows-mutex.c
|
||||
/windows-mutex.h
|
||||
/windows-once.c
|
||||
/windows-once.h
|
||||
/windows-recmutex.c
|
||||
/windows-recmutex.h
|
||||
/windows-rwlock.c
|
||||
/windows-rwlock.h
|
||||
/windows-tls.c
|
||||
/windows-tls.h
|
||||
/xalloc-die.c
|
||||
/xalloc-oversized.h
|
||||
/xalloc.h
|
||||
/xconcat-filename.c
|
||||
/xhash.c
|
||||
/xmalloc.c
|
||||
/xmemdup0.c
|
||||
/xmemdup0.h
|
||||
@@ -315,6 +347,3 @@
|
||||
/xstrndup.h
|
||||
/xtime.c
|
||||
/xtime.h
|
||||
/rename.c
|
||||
/rmdir.c
|
||||
/same-inode.h
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/lock.c
|
||||
/lock.h
|
||||
/threadlib.c
|
||||
/tls.c
|
||||
/tls.h
|
||||
|
||||
+33
-20
@@ -1,13 +1,14 @@
|
||||
/*~
|
||||
/00gnulib.m4
|
||||
/__inline.m4
|
||||
/absolute-header.m4
|
||||
/alloca.m4
|
||||
/asm-underscore.m4
|
||||
/assert.m4
|
||||
/calloc.m4
|
||||
/close-stream.m4
|
||||
/canonicalize.m4
|
||||
/clock_time.m4
|
||||
/close.m4
|
||||
/closeout.m4
|
||||
/codeset.m4
|
||||
/config-h.m4
|
||||
/configmake.m4
|
||||
@@ -36,16 +37,22 @@
|
||||
/frexpl.m4
|
||||
/fseterr.m4
|
||||
/fstat.m4
|
||||
/fsync.m4
|
||||
/getdtablesize.m4
|
||||
/gethrxtime.m4
|
||||
/getopt.m4
|
||||
/getprogname.m4
|
||||
/getrusage.m4
|
||||
/gettext.m4
|
||||
/gettime.m4
|
||||
/gettimeofday.m4
|
||||
/glibc2.m4
|
||||
/glibc21.m4
|
||||
/gnulib-cache.m4
|
||||
/gnulib-common.m4
|
||||
/gnulib-comp.m4
|
||||
/gnulib-tool.m4
|
||||
/host-cpu-c-abi.m4
|
||||
/iconv.m4
|
||||
/include_next.m4
|
||||
/intdiv0.m4
|
||||
@@ -61,8 +68,11 @@
|
||||
/isnand.m4
|
||||
/isnanf.m4
|
||||
/isnanl.m4
|
||||
/iswblank.m4
|
||||
/javacomp.m4
|
||||
/javaexec.m4
|
||||
/jm-winsz1.m4
|
||||
/jm-winsz2.m4
|
||||
/largefile.m4
|
||||
/lcmessage.m4
|
||||
/ldexp.m4
|
||||
@@ -70,18 +80,23 @@
|
||||
/lib-ld.m4
|
||||
/lib-link.m4
|
||||
/lib-prefix.m4
|
||||
/libtextstyle-optional.m4
|
||||
/libtextstyle.m4
|
||||
/libunistring-base.m4
|
||||
/limits-h.m4
|
||||
/localcharset.m4
|
||||
/locale-fr.m4
|
||||
/locale-ja.m4
|
||||
/locale-zh.m4
|
||||
/localtime-buffer.m4
|
||||
/lock.m4
|
||||
/longlong.m4
|
||||
/lstat.m4
|
||||
/malloc.m4
|
||||
/malloca.m4
|
||||
/math_h.m4
|
||||
/mbchar.m4
|
||||
/mbfile.m4
|
||||
/mbrtowc.m4
|
||||
/mbsinit.m4
|
||||
/mbstate_t.m4
|
||||
@@ -100,6 +115,7 @@
|
||||
/obstack.m4
|
||||
/off_t.m4
|
||||
/open-cloexec.m4
|
||||
/open-slash.m4
|
||||
/open.m4
|
||||
/pathmax.m4
|
||||
/perror.m4
|
||||
@@ -117,9 +133,15 @@
|
||||
/quotearg.m4
|
||||
/raise.m4
|
||||
/rawmemchr.m4
|
||||
/readlink.m4
|
||||
/realloc.m4
|
||||
/relocatable-lib.m4
|
||||
/relocatable.m4
|
||||
/rename.m4
|
||||
/rmdir.m4
|
||||
/sched_h.m4
|
||||
/setenv.m4
|
||||
/sh-filename.m4
|
||||
/sig_atomic_t.m4
|
||||
/sigaction.m4
|
||||
/signal_h.m4
|
||||
@@ -132,7 +154,9 @@
|
||||
/spawn_h.m4
|
||||
/sprintf-posix.m4
|
||||
/ssize_t.m4
|
||||
/stat-time.m4
|
||||
/stat.m4
|
||||
/std-gnu11.m4
|
||||
/stdbool.m4
|
||||
/stddef_h.m4
|
||||
/stdint.m4
|
||||
@@ -148,18 +172,25 @@
|
||||
/strndup.m4
|
||||
/strnlen.m4
|
||||
/strverscmp.m4
|
||||
/sys_resource_h.m4
|
||||
/sys_socket_h.m4
|
||||
/sys_stat_h.m4
|
||||
/sys_time_h.m4
|
||||
/sys_times_h.m4
|
||||
/sys_types_h.m4
|
||||
/sys_wait_h.m4
|
||||
/threadlib.m4
|
||||
/time_h.m4
|
||||
/timespec.m4
|
||||
/tls.m4
|
||||
/uintmax_t.m4
|
||||
/unistd-safer.m4
|
||||
/unistd_h.m4
|
||||
/unlink.m4
|
||||
/unlocked-io.m4
|
||||
/vasnprintf.m4
|
||||
/vasprintf-posix.m4
|
||||
/vasprintf.m4
|
||||
/vfprintf-posix.m4
|
||||
/visibility.m4
|
||||
/vsnprintf-posix.m4
|
||||
@@ -177,21 +208,3 @@
|
||||
/xalloc.m4
|
||||
/xsize.m4
|
||||
/xstrndup.m4
|
||||
/host-cpu-c-abi.m4
|
||||
/stat-time.m4
|
||||
/sys_time_h.m4
|
||||
/sys_times_h.m4
|
||||
/sh-filename.m4
|
||||
/clock_time.m4
|
||||
/gethrxtime.m4
|
||||
/getrusage.m4
|
||||
/gettime.m4
|
||||
/gettimeofday.m4
|
||||
/localtime-buffer.m4
|
||||
/sys_resource_h.m4
|
||||
/timespec.m4
|
||||
/intl-thread-locale.m4
|
||||
/canonicalize.m4
|
||||
/readlink.m4
|
||||
/relocatable-lib.m4
|
||||
/relocatable.m4
|
||||
|
||||
@@ -63,6 +63,9 @@ m4_define([_BISON_CXXSTD_11_snippet],
|
||||
for (int r: std::set<int>{1, 2})
|
||||
continue;
|
||||
}
|
||||
|
||||
// GCC 4.8.2 on Solaris 11.3 does not support to_string.
|
||||
auto e = std::to_string(42);
|
||||
])
|
||||
|
||||
m4_define([_BISON_CXXSTD_14_snippet],
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
## ----------------------------------- ##
|
||||
## Check if --with-dmalloc was given. ##
|
||||
## From Franc,ois Pinard ##
|
||||
## ----------------------------------- ##
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN([AM_WITH_DMALLOC],
|
||||
[AC_MSG_CHECKING([if malloc debugging is wanted])
|
||||
AC_ARG_WITH(dmalloc,
|
||||
[ --with-dmalloc use dmalloc, as in
|
||||
http://www.dmalloc.com/dmalloc.tar.gz],
|
||||
[if test "$withval" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([WITH_DMALLOC],1,
|
||||
[Define if using the dmalloc debugging malloc package])
|
||||
LIBS="$LIBS -ldmalloc"
|
||||
LDFLAGS="$LDFLAGS -g"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi], [AC_MSG_RESULT(no)])
|
||||
])
|
||||
+4
-3
@@ -15,7 +15,10 @@ AC_DEFUN_ONCE([AC_PROG_LEX],
|
||||
[AC_CHECK_PROGS([LEX], [flex lex], [:])
|
||||
if test "x$LEX" != "x:"; then
|
||||
_AC_PROG_LEX_YYTEXT_DECL
|
||||
fi])
|
||||
fi
|
||||
AC_SUBST([LEX_IS_FLEX],
|
||||
[`test "$ac_cv_prog_lex_is_flex" = yes && echo true || echo false`])dnl
|
||||
])
|
||||
|
||||
|
||||
# _AC_PROG_LEX_YYTEXT_DECL
|
||||
@@ -37,8 +40,6 @@ else
|
||||
ac_cv_prog_lex_is_flex=no
|
||||
fi
|
||||
])
|
||||
AC_SUBST([LEX_IS_FLEX],
|
||||
[`test "$ac_cv_prog_lex_is_flex" = yes && echo true || echo false`])dnl
|
||||
|
||||
cat >conftest.l <<_ACEOF[
|
||||
%%
|
||||
|
||||
+1
-13
@@ -9,23 +9,11 @@ src/location.c
|
||||
src/main.c
|
||||
src/muscle-tab.c
|
||||
src/parse-gram.y
|
||||
src/print-graph.c
|
||||
src/print.c
|
||||
src/print_graph.c
|
||||
src/reader.c
|
||||
src/reduce.c
|
||||
src/scan-code.l
|
||||
src/scan-gram.l
|
||||
src/scan-skel.l
|
||||
src/symtab.c
|
||||
|
||||
lib/argmatch.c
|
||||
lib/closeout.c
|
||||
lib/error.c
|
||||
lib/getopt.c
|
||||
lib/obstack.c
|
||||
lib/spawn-pipe.c
|
||||
lib/quotearg.c
|
||||
lib/timevar.c
|
||||
lib/w32spawn.h
|
||||
lib/wait-process.c
|
||||
lib/xalloc-die.c
|
||||
|
||||
@@ -269,7 +269,7 @@ AnnotationList__computePredecessorAnnotations (
|
||||
if (item_number_is_rule_number (ritem[s->items[self_item]
|
||||
- 2]))
|
||||
{
|
||||
unsigned rulei;
|
||||
int rulei;
|
||||
for (rulei = s->items[self_item];
|
||||
!item_number_is_rule_number (ritem[rulei]);
|
||||
++rulei)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# include "InadequacyList.h"
|
||||
# include "state.h"
|
||||
|
||||
typedef unsigned AnnotationIndex;
|
||||
typedef int AnnotationIndex;
|
||||
|
||||
/**
|
||||
* A node in a list of annotations on a particular LR(0) state. Each
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "InadequacyList.h"
|
||||
|
||||
#include <intprops.h>
|
||||
|
||||
ContributionIndex const ContributionIndex__none = -1;
|
||||
ContributionIndex const ContributionIndex__error_action = -2;
|
||||
|
||||
@@ -31,8 +33,11 @@ InadequacyList__new_conflict (state *manifesting_state, symbol *token,
|
||||
InadequacyListNodeCount *node_count)
|
||||
{
|
||||
InadequacyList *result = xmalloc (sizeof *result);
|
||||
result->id = (*node_count)++;
|
||||
aver (*node_count != 0);
|
||||
result->id = *node_count;
|
||||
IGNORE_TYPE_LIMITS_BEGIN
|
||||
if (INT_ADD_WRAPV (*node_count, 1, node_count))
|
||||
aver (false);
|
||||
IGNORE_TYPE_LIMITS_END
|
||||
result->next = NULL;
|
||||
result->manifestingState = manifesting_state;
|
||||
result->contributionCount = bitset_count (actions);
|
||||
|
||||
@@ -27,11 +27,8 @@
|
||||
|
||||
/**
|
||||
* A unique ID assigned to every \c InadequacyList node.
|
||||
*
|
||||
* This must remain unsigned so that the overflow check in
|
||||
* \c InadequacyList__new_conflict works properly.
|
||||
*/
|
||||
typedef unsigned long long InadequacyListNodeCount;
|
||||
typedef long long InadequacyListNodeCount;
|
||||
|
||||
/**
|
||||
* For a conflict, each rule in the grammar can have at most one contributing
|
||||
|
||||
+1
-3
@@ -29,9 +29,6 @@ assoc_to_string (assoc a)
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
|
||||
case undef_assoc:
|
||||
return "undefined associativity";
|
||||
|
||||
@@ -47,4 +44,5 @@ assoc_to_string (assoc a)
|
||||
case precedence_assoc:
|
||||
return "%precedence";
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
|
||||
+13
-10
@@ -35,6 +35,9 @@
|
||||
item_number *itemset;
|
||||
size_t nitemset;
|
||||
|
||||
/* RULESET contains a bit for each rule. CLOSURE sets the bits for
|
||||
all rules which could potentially describe the next input to be
|
||||
read. */
|
||||
static bitset ruleset;
|
||||
|
||||
/* internal data. See comments before set_fderives and set_firsts. */
|
||||
@@ -51,7 +54,7 @@ static bitsetv firsts = NULL;
|
||||
`-----------------*/
|
||||
|
||||
static void
|
||||
print_closure (char const *title, item_number const *array, size_t size)
|
||||
closure_print (char const *title, item_number const *array, size_t size)
|
||||
{
|
||||
fprintf (stderr, "Closure: %s\n", title);
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
@@ -167,7 +170,7 @@ set_fderives (void)
|
||||
|
||||
|
||||
void
|
||||
new_closure (unsigned n)
|
||||
closure_new (int n)
|
||||
{
|
||||
itemset = xnmalloc (n, sizeof *itemset);
|
||||
|
||||
@@ -181,8 +184,8 @@ new_closure (unsigned n)
|
||||
void
|
||||
closure (item_number const *core, size_t n)
|
||||
{
|
||||
if (trace_flag & trace_sets)
|
||||
print_closure ("input", core, n);
|
||||
if (trace_flag & trace_closure)
|
||||
closure_print ("input", core, n);
|
||||
|
||||
bitset_zero (ruleset);
|
||||
|
||||
@@ -192,12 +195,12 @@ closure (item_number const *core, size_t n)
|
||||
|
||||
/* core is sorted on item index in ritem, which is sorted on rule number.
|
||||
Compute itemset with the same sort. */
|
||||
nitemset = 0;
|
||||
size_t c = 0;
|
||||
|
||||
/* A bit index over RULESET. */
|
||||
rule_number ruleno;
|
||||
bitset_iterator iter;
|
||||
|
||||
nitemset = 0;
|
||||
size_t c = 0;
|
||||
BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
|
||||
{
|
||||
item_number itemno = rules[ruleno].rhs - ritem;
|
||||
@@ -218,13 +221,13 @@ closure (item_number const *core, size_t n)
|
||||
c++;
|
||||
}
|
||||
|
||||
if (trace_flag & trace_sets)
|
||||
print_closure ("output", itemset, nitemset);
|
||||
if (trace_flag & trace_closure)
|
||||
closure_print ("output", itemset, nitemset);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
free_closure (void)
|
||||
closure_free (void)
|
||||
{
|
||||
free (itemset);
|
||||
bitset_free (ruleset);
|
||||
|
||||
+10
-13
@@ -27,29 +27,26 @@
|
||||
data so that closure can be called. n is the number of elements to
|
||||
allocate for itemset. */
|
||||
|
||||
void new_closure (unsigned n);
|
||||
void closure_new (int n);
|
||||
|
||||
|
||||
/* Given the kernel (aka core) of a state (a sorted vector of item numbers
|
||||
ITEMS, of length N), set up RULESET and ITEMSET to indicate what
|
||||
rules could be run and which items could be accepted when those
|
||||
items are the active ones.
|
||||
|
||||
RULESET contains a bit for each rule. CLOSURE sets the bits for
|
||||
all rules which could potentially describe the next input to be
|
||||
read.
|
||||
|
||||
ITEMSET is a sorted vector of item numbers; NITEMSET is its size
|
||||
(actually, points to just beyond the end of the part of it that is
|
||||
significant). CLOSURE places there the indices of all items which
|
||||
represent units of input that could arrive next. */
|
||||
items are the active ones. */
|
||||
|
||||
void closure (item_number const *items, size_t n);
|
||||
|
||||
|
||||
/* Frees ITEMSET, RULESET and internal data. */
|
||||
/* Free ITEMSET, RULESET and internal data. */
|
||||
|
||||
void free_closure (void);
|
||||
void closure_free (void);
|
||||
|
||||
|
||||
/* ITEMSET is a sorted vector of item numbers; NITEMSET is its size
|
||||
(actually, points to just beyond the end of the part of it that is
|
||||
significant). CLOSURE places there the indices of all items which
|
||||
represent units of input that could arrive next. */
|
||||
|
||||
extern item_number *itemset;
|
||||
extern size_t nitemset;
|
||||
|
||||
+249
-89
@@ -23,8 +23,10 @@
|
||||
#include "system.h"
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <stdarg.h>
|
||||
#include <progname.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <textstyle.h>
|
||||
|
||||
#include "complain.h"
|
||||
#include "files.h"
|
||||
@@ -61,52 +63,105 @@ typedef enum
|
||||
/** For each warning type, its severity. */
|
||||
static severity warnings_flag[warnings_size];
|
||||
|
||||
static unsigned *indent_ptr = 0;
|
||||
styled_ostream_t errstream = NULL;
|
||||
|
||||
void
|
||||
begin_use_class (const char *s, FILE *out)
|
||||
{
|
||||
if (out == stderr)
|
||||
{
|
||||
if (color_debug)
|
||||
fprintf (out, "<%s>", s);
|
||||
else
|
||||
{
|
||||
styled_ostream_begin_use_class (errstream, s);
|
||||
styled_ostream_flush_to_current_style (errstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
end_use_class (const char *s, FILE *out)
|
||||
{
|
||||
if (out == stderr)
|
||||
{
|
||||
if (color_debug)
|
||||
fprintf (out, "</%s>", s);
|
||||
else
|
||||
{
|
||||
styled_ostream_end_use_class (errstream, s);
|
||||
styled_ostream_flush_to_current_style (errstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
flush (FILE *out)
|
||||
{
|
||||
if (out == stderr)
|
||||
ostream_flush (errstream, FLUSH_THIS_STREAM);
|
||||
fflush (out);
|
||||
}
|
||||
|
||||
/*------------------------.
|
||||
| --warnings's handling. |
|
||||
`------------------------*/
|
||||
|
||||
static const char * const warnings_args[] =
|
||||
ARGMATCH_DEFINE_GROUP (warning, warnings)
|
||||
|
||||
static const argmatch_warning_doc argmatch_warning_docs[] =
|
||||
{
|
||||
"none",
|
||||
"midrule-values",
|
||||
"yacc",
|
||||
"conflicts-sr",
|
||||
"conflicts-rr",
|
||||
"deprecated",
|
||||
"empty-rule",
|
||||
"precedence",
|
||||
"other",
|
||||
"all",
|
||||
"error",
|
||||
"everything",
|
||||
0
|
||||
{ "conflicts-sr", N_("S/R conflicts (enabled by default)") },
|
||||
{ "conflicts-rr", N_("R/R conflicts (enabled by default)") },
|
||||
{ "dangling-alias", N_("string aliases not attached to a symbol") },
|
||||
{ "deprecated", N_("obsolete constructs") },
|
||||
{ "empty-rule", N_("empty rules without %empty") },
|
||||
{ "midrule-values", N_("unset or unused midrule values") },
|
||||
{ "precedence", N_("useless precedence and associativity") },
|
||||
{ "yacc", N_("incompatibilities with POSIX Yacc") },
|
||||
{ "other", N_("all other warnings (enabled by default)") },
|
||||
{ "all", N_("all the warnings except 'dangling-alias' and 'yacc'") },
|
||||
{ "no-CATEGORY", N_("turn off warnings in CATEGORY") },
|
||||
{ "none", N_("turn off all the warnings") },
|
||||
{ "error[=CATEGORY]", N_("treat warnings as errors") },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const warnings warnings_types[] =
|
||||
static const argmatch_warning_arg argmatch_warning_args[] =
|
||||
{
|
||||
Wnone,
|
||||
Wmidrule_values,
|
||||
Wyacc,
|
||||
Wconflicts_sr,
|
||||
Wconflicts_rr,
|
||||
Wdeprecated,
|
||||
Wempty_rule,
|
||||
Wprecedence,
|
||||
Wother,
|
||||
Wall,
|
||||
Werror,
|
||||
Weverything
|
||||
{ "all", Wall },
|
||||
{ "conflicts-rr", Wconflicts_rr },
|
||||
{ "conflicts-sr", Wconflicts_sr },
|
||||
{ "dangling-alias", Wdangling_alias },
|
||||
{ "deprecated", Wdeprecated },
|
||||
{ "empty-rule", Wempty_rule },
|
||||
{ "everything", Weverything },
|
||||
{ "midrule-values", Wmidrule_values },
|
||||
{ "none", Wnone },
|
||||
{ "other", Wother },
|
||||
{ "precedence", Wprecedence },
|
||||
{ "yacc", Wyacc },
|
||||
{ NULL, Wnone }
|
||||
};
|
||||
|
||||
ARGMATCH_VERIFY (warnings_args, warnings_types);
|
||||
const argmatch_warning_group_type argmatch_warning_group =
|
||||
{
|
||||
argmatch_warning_args,
|
||||
argmatch_warning_docs,
|
||||
N_("Warning categories include:"),
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
warning_usage (FILE *out)
|
||||
{
|
||||
argmatch_warning_usage (out);
|
||||
}
|
||||
|
||||
void
|
||||
warning_argmatch (char const *arg, size_t no, size_t err)
|
||||
{
|
||||
int value = XARGMATCH ("--warning", arg + no + err,
|
||||
warnings_args, warnings_types);
|
||||
int value = *argmatch_warning_value ("--warning", arg + no + err);
|
||||
|
||||
/* -Wnone == -Wno-everything, and -Wno-none == -Weverything. */
|
||||
if (!value)
|
||||
@@ -145,7 +200,14 @@ warning_argmatch (char const *arg, size_t no, size_t err)
|
||||
void
|
||||
warnings_argmatch (char *args)
|
||||
{
|
||||
if (args)
|
||||
if (!args)
|
||||
warning_argmatch ("all", 0, 0);
|
||||
else if (STREQ (args, "help"))
|
||||
{
|
||||
warning_usage (stdout);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
for (args = strtok (args, ","); args; args = strtok (NULL, ","))
|
||||
if (STREQ (args, "error"))
|
||||
warnings_are_errors = true;
|
||||
@@ -161,8 +223,43 @@ warnings_argmatch (char *args)
|
||||
|
||||
warning_argmatch (args, no, err);
|
||||
}
|
||||
else
|
||||
warning_argmatch ("all", 0, 0);
|
||||
}
|
||||
|
||||
/* Color style for this type of message. */
|
||||
static const char*
|
||||
severity_style (severity s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case severity_disabled:
|
||||
case severity_unset:
|
||||
return "note";
|
||||
case severity_warning:
|
||||
return "warning";
|
||||
case severity_error:
|
||||
case severity_fatal:
|
||||
return "error";
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Prefix for this type of message. */
|
||||
static const char*
|
||||
severity_prefix (severity s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case severity_disabled:
|
||||
case severity_unset:
|
||||
return "";
|
||||
case severity_warning:
|
||||
return _("warning");
|
||||
case severity_error:
|
||||
return _("error");
|
||||
case severity_fatal:
|
||||
return _("fatal error");
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
@@ -170,9 +267,53 @@ warnings_argmatch (char *args)
|
||||
| complain. |
|
||||
`-----------*/
|
||||
|
||||
void
|
||||
complain_init_color (void)
|
||||
{
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
if (color_mode == color_yes
|
||||
|| color_mode == color_html
|
||||
|| (color_mode == color_tty && isatty (STDERR_FILENO)))
|
||||
{
|
||||
style_file_prepare ("BISON_STYLE", "BISON_STYLEDIR", pkgdatadir (),
|
||||
"bison-default.css");
|
||||
/* As a fallback, use the default in the current directory. */
|
||||
struct stat statbuf;
|
||||
if ((style_file_name == NULL || stat (style_file_name, &statbuf) < 0)
|
||||
&& stat ("bison-default.css", &statbuf) == 0)
|
||||
style_file_name = "bison-default.css";
|
||||
}
|
||||
else
|
||||
/* No styling. */
|
||||
style_file_name = NULL;
|
||||
#endif
|
||||
|
||||
/* Workaround clang's warning (starting at Clang 3.5) about the stub
|
||||
code of html_styled_ostream_create:
|
||||
|
||||
| src/complain.c:274:7: error: code will never be executed [-Werror,-Wunreachable-code]
|
||||
| ? html_styled_ostream_create (file_ostream_create (stderr),
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
#if defined __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wunreachable-code"
|
||||
#endif
|
||||
errstream =
|
||||
color_mode == color_html
|
||||
? html_styled_ostream_create (file_ostream_create (stderr),
|
||||
style_file_name)
|
||||
: styled_ostream_create (STDERR_FILENO, "(stderr)", TTYCTL_AUTO,
|
||||
style_file_name);
|
||||
#if defined __clang__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
complain_init (void)
|
||||
{
|
||||
caret_init ();
|
||||
|
||||
warnings warnings_default =
|
||||
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||
|
||||
@@ -185,6 +326,12 @@ complain_init (void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
complain_free (void)
|
||||
{
|
||||
caret_free ();
|
||||
styled_ostream_free (errstream);
|
||||
}
|
||||
|
||||
/* A diagnostic with FLAGS is about to be issued. With what severity?
|
||||
(severity_fatal, severity_error, severity_disabled, or
|
||||
@@ -229,19 +376,31 @@ warning_is_unset (warnings flags)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Display a "[-Wyacc]" like message on \a f. */
|
||||
bool
|
||||
warning_is_enabled (warnings flags)
|
||||
{
|
||||
return severity_warning <= warning_severity (flags);
|
||||
}
|
||||
|
||||
/** Display a "[-Wyacc]" like message on \a out. */
|
||||
|
||||
static void
|
||||
warnings_print_categories (warnings warn_flags, FILE *f)
|
||||
warnings_print_categories (warnings warn_flags, FILE *out)
|
||||
{
|
||||
/* Display only the first match, the second is "-Wall". */
|
||||
for (size_t i = 0; warnings_args[i]; ++i)
|
||||
if (warn_flags & warnings_types[i])
|
||||
for (int wbit = 0; wbit < warnings_size; ++wbit)
|
||||
if (warn_flags & (1 << wbit))
|
||||
{
|
||||
severity s = warning_severity (warnings_types[i]);
|
||||
fprintf (f, " [-W%s%s]",
|
||||
warnings w = 1 << wbit;
|
||||
severity s = warning_severity (w);
|
||||
const char* style = severity_style (s);
|
||||
fputs (" [", out);
|
||||
begin_use_class (style, out);
|
||||
fprintf (out, "-W%s%s",
|
||||
s == severity_error ? "error=" : "",
|
||||
warnings_args[i]);
|
||||
argmatch_warning_argument (&w));
|
||||
end_use_class (style, out);
|
||||
fputc (']', out);
|
||||
/* Display only the first match, the second is "-Wall". */
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -250,8 +409,10 @@ warnings_print_categories (warnings warn_flags, FILE *f)
|
||||
*
|
||||
* \param loc the location, defaulting to the current file,
|
||||
* or the program name.
|
||||
* \param indent optional indentation for the error message.
|
||||
* \param flags the category for this message.
|
||||
* \param prefix put before the message (e.g., "warning").
|
||||
* \param sever to decide the prefix to put before the message
|
||||
* (e.g., "warning").
|
||||
* \param message the error message, a printf format string. Iff it
|
||||
* ends with ": ", then no trailing newline is printed,
|
||||
* and the caller should print the remaining
|
||||
@@ -260,35 +421,41 @@ warnings_print_categories (warnings warn_flags, FILE *f)
|
||||
*/
|
||||
static
|
||||
void
|
||||
error_message (const location *loc, warnings flags, const char *prefix,
|
||||
const char *message, va_list args)
|
||||
error_message (const location *loc, int *indent, warnings flags,
|
||||
severity sever, const char *message, va_list args)
|
||||
{
|
||||
unsigned pos = 0;
|
||||
int pos = 0;
|
||||
|
||||
if (loc)
|
||||
pos += location_print (*loc, stderr);
|
||||
else
|
||||
pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
|
||||
pos += fprintf (stderr, "%s", grammar_file ? grammar_file : program_name);
|
||||
pos += fprintf (stderr, ": ");
|
||||
|
||||
if (indent_ptr)
|
||||
if (indent)
|
||||
{
|
||||
if (*indent_ptr)
|
||||
prefix = NULL;
|
||||
if (!*indent_ptr)
|
||||
*indent_ptr = pos;
|
||||
else if (*indent_ptr > pos)
|
||||
fprintf (stderr, "%*s", *indent_ptr - pos, "");
|
||||
indent_ptr = NULL;
|
||||
if (*indent)
|
||||
sever = severity_disabled;
|
||||
if (!*indent)
|
||||
*indent = pos;
|
||||
else if (*indent > pos)
|
||||
fprintf (stderr, "%*s", *indent - pos, "");
|
||||
}
|
||||
|
||||
if (prefix)
|
||||
fprintf (stderr, "%s: ", prefix);
|
||||
const char* style = severity_style (sever);
|
||||
|
||||
if (sever != severity_disabled)
|
||||
{
|
||||
begin_use_class (style, stderr);
|
||||
fprintf (stderr, "%s:", severity_prefix (sever));
|
||||
end_use_class (style, stderr);
|
||||
fputc (' ', stderr);
|
||||
}
|
||||
|
||||
vfprintf (stderr, message, args);
|
||||
/* Print the type of warning, only if this is not a sub message
|
||||
(in which case the prefix is null). */
|
||||
if (! (flags & silent) && prefix)
|
||||
if (! (flags & silent) && sever != severity_disabled)
|
||||
warnings_print_categories (flags, stderr);
|
||||
|
||||
{
|
||||
@@ -296,20 +463,19 @@ error_message (const location *loc, warnings flags, const char *prefix,
|
||||
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
|
||||
{
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
flush (stderr);
|
||||
if (loc && feature_flag & feature_caret && !(flags & no_caret))
|
||||
location_caret (*loc, stderr);
|
||||
location_caret (*loc, style, stderr);
|
||||
}
|
||||
}
|
||||
fflush (stderr);
|
||||
flush (stderr);
|
||||
}
|
||||
|
||||
/** Raise a complaint. That can be a fatal error, an error or just a
|
||||
warning. */
|
||||
/** Raise a complaint (fatal error, error or just warning). */
|
||||
|
||||
static void
|
||||
complains (const location *loc, warnings flags, const char *message,
|
||||
va_list args)
|
||||
complains (const location *loc, int *indent, warnings flags,
|
||||
const char *message, va_list args)
|
||||
{
|
||||
severity s = warning_severity (flags);
|
||||
if ((flags & complaint) && complaint_status < status_complaint)
|
||||
@@ -317,13 +483,9 @@ complains (const location *loc, warnings flags, const char *message,
|
||||
|
||||
if (severity_warning <= s)
|
||||
{
|
||||
const char* prefix =
|
||||
s == severity_fatal ? _("fatal error")
|
||||
: s == severity_error ? _("error")
|
||||
: _("warning");
|
||||
if (severity_error <= s && ! complaint_status)
|
||||
complaint_status = status_warning_as_error;
|
||||
error_message (loc, flags, prefix, message, args);
|
||||
error_message (loc, indent, flags, s, message, args);
|
||||
}
|
||||
|
||||
if (flags & fatal)
|
||||
@@ -335,23 +497,22 @@ complain (location const *loc, warnings flags, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, message);
|
||||
complains (loc, flags, message, args);
|
||||
complains (loc, NULL, flags, message, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||
complain_indent (location const *loc, warnings flags, int *indent,
|
||||
const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
indent_ptr = indent;
|
||||
va_start (args, message);
|
||||
complains (loc, flags, message, args);
|
||||
complains (loc, indent, flags, message, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
complain_args (location const *loc, warnings w, unsigned *indent,
|
||||
complain_args (location const *loc, warnings w, int *indent,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
switch (argc)
|
||||
@@ -389,24 +550,23 @@ bison_directive (location const *loc, char const *directive)
|
||||
void
|
||||
deprecated_directive (location const *loc, char const *old, char const *upd)
|
||||
{
|
||||
if (feature_flag & feature_caret)
|
||||
complain (loc, Wdeprecated,
|
||||
_("deprecated directive, use %s"),
|
||||
quote_n (1, upd));
|
||||
else
|
||||
complain (loc, Wdeprecated,
|
||||
_("deprecated directive: %s, use %s"),
|
||||
quote (old), quote_n (1, upd));
|
||||
/* Register updates only if -Wdeprecated is enabled. */
|
||||
if (warnings_flag[warning_deprecated] != severity_disabled)
|
||||
fixits_register (loc, upd);
|
||||
if (warning_is_enabled (Wdeprecated))
|
||||
{
|
||||
complain (loc, Wdeprecated,
|
||||
_("deprecated directive: %s, use %s"),
|
||||
quote (old), quote_n (1, upd));
|
||||
if (feature_flag & feature_caret)
|
||||
location_caret_suggestion (*loc, upd, stderr);
|
||||
/* Register updates only if -Wdeprecated is enabled. */
|
||||
fixits_register (loc, upd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
duplicate_directive (char const *directive,
|
||||
location first, location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
if (feature_flag & feature_caret)
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive"));
|
||||
else
|
||||
@@ -420,7 +580,7 @@ void
|
||||
duplicate_rule_directive (char const *directive,
|
||||
location first, location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("only one %s allowed per rule"), directive);
|
||||
i += SUB_INDENT;
|
||||
|
||||
+43
-16
@@ -24,6 +24,20 @@
|
||||
/* Sub-messages indent. */
|
||||
# define SUB_INDENT (4)
|
||||
|
||||
/*---------------.
|
||||
| Error stream. |
|
||||
`---------------*/
|
||||
|
||||
/** Enable a style on \a out provided it's stderr. */
|
||||
void begin_use_class (const char *style, FILE *out);
|
||||
|
||||
/** Disable a style on \a out provided it's stderr. */
|
||||
void end_use_class (const char *style, FILE *out);
|
||||
|
||||
/** Flush \a out. */
|
||||
void flush (FILE *out);
|
||||
|
||||
|
||||
/*-------------.
|
||||
| --warnings. |
|
||||
`-------------*/
|
||||
@@ -31,14 +45,15 @@
|
||||
/** The bits assigned to each warning type. */
|
||||
typedef enum
|
||||
{
|
||||
warning_midrule_values, /**< Unset or unused midrule values. */
|
||||
warning_conflicts_rr,
|
||||
warning_conflicts_sr,
|
||||
warning_dangling_alias,
|
||||
warning_deprecated,
|
||||
warning_empty_rule,
|
||||
warning_midrule_values,
|
||||
warning_other,
|
||||
warning_precedence,
|
||||
warning_yacc, /**< POSIXME. */
|
||||
warning_conflicts_sr, /**< S/R conflicts. */
|
||||
warning_conflicts_rr, /**< R/R conflicts. */
|
||||
warning_empty_rule, /**< Implicitly empty rules. */
|
||||
warning_deprecated, /**< Obsolete constructs. */
|
||||
warning_precedence, /**< Useless precedence and associativity. */
|
||||
warning_other, /**< All other warnings. */
|
||||
|
||||
warnings_size /**< The number of warnings. Must be last. */
|
||||
} warning_bit;
|
||||
@@ -46,6 +61,9 @@ typedef enum
|
||||
/** Whether -Werror was set. */
|
||||
extern bool warnings_are_errors;
|
||||
|
||||
/** Document --warning arguments. */
|
||||
void warning_usage (FILE *out);
|
||||
|
||||
/** Decode a single argument from -W.
|
||||
*
|
||||
* \param arg the subarguments to decode.
|
||||
@@ -76,20 +94,26 @@ void warnings_argmatch (char *args);
|
||||
/** Initialize this module. */
|
||||
void complain_init (void);
|
||||
|
||||
/** Reclaim resources. */
|
||||
void complain_free (void);
|
||||
|
||||
/** Initialize support for colored messages. */
|
||||
void complain_init_color (void);
|
||||
|
||||
/** Flags passed to diagnostics functions. */
|
||||
typedef enum
|
||||
{
|
||||
Wnone = 0, /**< Issue no warnings. */
|
||||
|
||||
Wmidrule_values = 1 << warning_midrule_values,
|
||||
Wyacc = 1 << warning_yacc,
|
||||
Wconflicts_sr = 1 << warning_conflicts_sr,
|
||||
Wconflicts_rr = 1 << warning_conflicts_rr,
|
||||
Wconflicts_sr = 1 << warning_conflicts_sr,
|
||||
Wdangling_alias = 1 << warning_dangling_alias,
|
||||
Wdeprecated = 1 << warning_deprecated,
|
||||
Wempty_rule = 1 << warning_empty_rule,
|
||||
Wprecedence = 1 << warning_precedence,
|
||||
Wmidrule_values = 1 << warning_midrule_values,
|
||||
Wother = 1 << warning_other,
|
||||
|
||||
Werror = 1 << 10, /** This bit is no longer used. */
|
||||
Wprecedence = 1 << warning_precedence,
|
||||
Wyacc = 1 << warning_yacc,
|
||||
|
||||
complaint = 1 << 11, /**< All complaints. */
|
||||
fatal = 1 << 12, /**< All fatal errors. */
|
||||
@@ -98,23 +122,26 @@ typedef enum
|
||||
|
||||
/**< All above warnings. */
|
||||
Weverything = ~complaint & ~fatal & ~silent,
|
||||
Wall = Weverything & ~Wyacc
|
||||
Wall = Weverything & ~Wdangling_alias & ~Wyacc
|
||||
} warnings;
|
||||
|
||||
/** Whether the warnings of \a flags are all unset.
|
||||
(Never enabled, never disabled). */
|
||||
bool warning_is_unset (warnings flags);
|
||||
|
||||
/** Whether warnings of \a flags should be reported. */
|
||||
bool warning_is_enabled (warnings flags);
|
||||
|
||||
/** Make a complaint, with maybe a location. */
|
||||
void complain (location const *loc, warnings flags, char const *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
/** Likewise, but with an \a argc/argv interface. */
|
||||
void complain_args (location const *loc, warnings w, unsigned *indent,
|
||||
void complain_args (location const *loc, warnings w, int *indent,
|
||||
int argc, char *arg[]);
|
||||
|
||||
/** Make a complaint with location and some indentation. */
|
||||
void complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||
void complain_indent (location const *loc, warnings flags, int *indent,
|
||||
char const *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||
|
||||
|
||||
+39
-32
@@ -23,13 +23,13 @@
|
||||
|
||||
#include <bitset.h>
|
||||
|
||||
#include "LR0.h"
|
||||
#include "complain.h"
|
||||
#include "conflicts.h"
|
||||
#include "files.h"
|
||||
#include "getargs.h"
|
||||
#include "gram.h"
|
||||
#include "lalr.h"
|
||||
#include "lr0.h"
|
||||
#include "print-xml.h"
|
||||
#include "reader.h"
|
||||
#include "state.h"
|
||||
@@ -38,7 +38,10 @@
|
||||
/* -1 stands for not specified. */
|
||||
int expected_sr_conflicts = -1;
|
||||
int expected_rr_conflicts = -1;
|
||||
static char *conflicts;
|
||||
|
||||
/* CONFLICTS[STATE-NUM] -- Whether that state has unresolved conflicts. */
|
||||
static bool *conflicts;
|
||||
|
||||
static struct obstack solved_conflicts_obstack;
|
||||
static struct obstack solved_conflicts_xml_obstack;
|
||||
|
||||
@@ -73,8 +76,9 @@ log_resolution (rule *r, symbol_number token,
|
||||
{
|
||||
case shift_resolution:
|
||||
case right_resolution:
|
||||
obstack_sgrow (&solved_conflicts_obstack, " ");
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
_("Conflict between rule %d and token %s"
|
||||
" resolved as shift"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
@@ -82,16 +86,18 @@ log_resolution (rule *r, symbol_number token,
|
||||
|
||||
case reduce_resolution:
|
||||
case left_resolution:
|
||||
obstack_sgrow (&solved_conflicts_obstack, " ");
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
_("Conflict between rule %d and token %s"
|
||||
" resolved as reduce"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_sgrow (&solved_conflicts_obstack, " ");
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
_("Conflict between rule %d and token %s"
|
||||
" resolved as an error"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
@@ -369,13 +375,16 @@ set_conflicts (state *s, symbol **errors)
|
||||
s->solved_conflicts_xml = obstack_finish0 (&solved_conflicts_xml_obstack);
|
||||
|
||||
/* Loop over all rules which require lookahead in this state. Check
|
||||
for conflicts not resolved above. */
|
||||
for (int i = 0; i < reds->num; ++i)
|
||||
{
|
||||
if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
|
||||
conflicts[s->number] = 1;
|
||||
bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]);
|
||||
}
|
||||
for conflicts not resolved above.
|
||||
|
||||
reds->lookahead_tokens can be NULL if the LR type is LR(0). */
|
||||
if (reds->lookahead_tokens)
|
||||
for (int i = 0; i < reds->num; ++i)
|
||||
{
|
||||
if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
|
||||
conflicts[s->number] = true;
|
||||
bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +434,7 @@ conflicts_update_state_numbers (state_number old_to_new[],
|
||||
`---------------------------------------------*/
|
||||
|
||||
static size_t
|
||||
count_state_sr_conflicts (state *s)
|
||||
count_state_sr_conflicts (const state *s)
|
||||
{
|
||||
transitions *trans = s->transitions;
|
||||
reductions *reds = s->reductions;
|
||||
@@ -473,7 +482,7 @@ count_sr_conflicts (void)
|
||||
`-----------------------------------------------------------------*/
|
||||
|
||||
static size_t
|
||||
count_state_rr_conflicts (state *s)
|
||||
count_state_rr_conflicts (const state *s)
|
||||
{
|
||||
reductions *reds = s->reductions;
|
||||
size_t res = 0;
|
||||
@@ -585,24 +594,22 @@ conflicts_output (FILE *out)
|
||||
{
|
||||
bool printed_sth = false;
|
||||
for (state_number i = 0; i < nstates; ++i)
|
||||
{
|
||||
state *s = states[i];
|
||||
if (conflicts[i])
|
||||
{
|
||||
int src = count_state_sr_conflicts (s);
|
||||
int rrc = count_state_rr_conflicts (s);
|
||||
fprintf (out, _("State %d "), i);
|
||||
if (src && rrc)
|
||||
fprintf (out,
|
||||
_("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
||||
src, rrc);
|
||||
else if (src)
|
||||
fprintf (out, _("conflicts: %d shift/reduce\n"), src);
|
||||
else if (rrc)
|
||||
fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc);
|
||||
printed_sth = true;
|
||||
}
|
||||
}
|
||||
if (conflicts[i])
|
||||
{
|
||||
const state *s = states[i];
|
||||
int src = count_state_sr_conflicts (s);
|
||||
int rrc = count_state_rr_conflicts (s);
|
||||
fprintf (out, _("State %d "), i);
|
||||
if (src && rrc)
|
||||
fprintf (out,
|
||||
_("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
||||
src, rrc);
|
||||
else if (src)
|
||||
fprintf (out, _("conflicts: %d shift/reduce\n"), src);
|
||||
else if (rrc)
|
||||
fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc);
|
||||
printed_sth = true;
|
||||
}
|
||||
if (printed_sth)
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
+11
-14
@@ -40,15 +40,12 @@ rule ***derives;
|
||||
static void
|
||||
print_derives (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
fputs ("DERIVES\n", stderr);
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||
{
|
||||
rule **rp;
|
||||
fprintf (stderr, " %s derives\n", symbols[i]->tag);
|
||||
for (rp = derives[i - ntokens]; *rp; ++rp)
|
||||
for (rule **rp = derives[i - ntokens]; *rp; ++rp)
|
||||
{
|
||||
fprintf (stderr, " %3d ", (*rp)->user_number);
|
||||
rule_rhs_print (*rp, stderr);
|
||||
@@ -63,10 +60,6 @@ print_derives (void)
|
||||
void
|
||||
derives_compute (void)
|
||||
{
|
||||
symbol_number i;
|
||||
rule_number r;
|
||||
rule **q;
|
||||
|
||||
/* DSET[NTERM - NTOKENS] -- A linked list of the numbers of the rules
|
||||
whose LHS is NTERM. */
|
||||
rule_list **dset = xcalloc (nvars, sizeof *dset);
|
||||
@@ -76,7 +69,7 @@ derives_compute (void)
|
||||
indexed by rule numbers. */
|
||||
rule_list *delts = xnmalloc (nrules, sizeof *delts);
|
||||
|
||||
for (r = nrules - 1; r >= 0; --r)
|
||||
for (rule_number r = nrules - 1; r >= 0; --r)
|
||||
{
|
||||
symbol_number lhs = rules[r].lhs->number;
|
||||
rule_list *p = &delts[r];
|
||||
@@ -90,9 +83,10 @@ derives_compute (void)
|
||||
it a single array. */
|
||||
|
||||
derives = xnmalloc (nvars, sizeof *derives);
|
||||
q = xnmalloc (nvars + nrules, sizeof *q);
|
||||
/* Q is the storage for DERIVES[...] (DERIVES[0] = q). */
|
||||
rule **q = xnmalloc (nvars + nrules, sizeof *q);
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||
{
|
||||
rule_list *p = dset[i - ntokens];
|
||||
derives[i - ntokens] = q;
|
||||
@@ -115,6 +109,9 @@ derives_compute (void)
|
||||
void
|
||||
derives_free (void)
|
||||
{
|
||||
free (derives[0]);
|
||||
free (derives);
|
||||
if (derives)
|
||||
{
|
||||
free (derives[0]);
|
||||
free (derives);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-6
@@ -21,11 +21,13 @@
|
||||
#include <config.h>
|
||||
#include "system.h"
|
||||
|
||||
#include <configmake.h> /* PKGDATADIR */
|
||||
#include <error.h>
|
||||
#include <dirname.h>
|
||||
#include <get-errno.h>
|
||||
#include <quote.h>
|
||||
#include <quotearg.h>
|
||||
#include <relocatable.h> /* relocate2 */
|
||||
#include <stdio-safer.h>
|
||||
#include <xstrndup.h>
|
||||
|
||||
@@ -49,7 +51,7 @@ location spec_name_prefix_loc = EMPTY_LOCATION_INIT;
|
||||
char *spec_verbose_file = NULL; /* for --verbose. */
|
||||
char *spec_graph_file = NULL; /* for -g. */
|
||||
char *spec_xml_file = NULL; /* for -x. */
|
||||
char *spec_defines_file = NULL; /* for --defines. */
|
||||
char *spec_header_file = NULL; /* for --defines. */
|
||||
char *parser_file_name;
|
||||
|
||||
/* All computed output file names. */
|
||||
@@ -66,7 +68,6 @@ static generated_file *generated_files = NULL;
|
||||
static int generated_files_size = 0;
|
||||
|
||||
uniqstr grammar_file = NULL;
|
||||
uniqstr current_file = NULL;
|
||||
|
||||
/* If --output=dir/foo.c was specified,
|
||||
DIR_PREFIX is 'dir/' and ALL_BUT_EXT and ALL_BUT_TAB_EXT are 'dir/foo'.
|
||||
@@ -333,14 +334,15 @@ compute_output_file_names (void)
|
||||
|
||||
if (defines_flag)
|
||||
{
|
||||
if (! spec_defines_file)
|
||||
spec_defines_file = concat2 (all_but_ext, header_extension);
|
||||
if (! spec_header_file)
|
||||
spec_header_file = concat2 (all_but_ext, header_extension);
|
||||
}
|
||||
|
||||
if (graph_flag)
|
||||
{
|
||||
if (! spec_graph_file)
|
||||
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
||||
spec_graph_file = concat2 (all_but_tab_ext,
|
||||
304 <= required_version ? ".gv" : ".dot");
|
||||
output_file_name_check (&spec_graph_file, false);
|
||||
}
|
||||
|
||||
@@ -404,6 +406,21 @@ unlink_generated_sources (void)
|
||||
unlink (generated_files[i].name);
|
||||
}
|
||||
|
||||
/* Memory allocated by relocate2, to free. */
|
||||
static char *relocate_buffer = NULL;
|
||||
|
||||
char const *
|
||||
pkgdatadir (void)
|
||||
{
|
||||
if (relocate_buffer)
|
||||
return relocate_buffer;
|
||||
else
|
||||
{
|
||||
char const *cp = getenv ("BISON_PKGDATADIR");
|
||||
return cp ? cp : relocate2 (PKGDATADIR, &relocate_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
output_file_names_free (void)
|
||||
{
|
||||
@@ -411,10 +428,11 @@ output_file_names_free (void)
|
||||
free (spec_verbose_file);
|
||||
free (spec_graph_file);
|
||||
free (spec_xml_file);
|
||||
free (spec_defines_file);
|
||||
free (spec_header_file);
|
||||
free (parser_file_name);
|
||||
free (dir_prefix);
|
||||
for (int i = 0; i < generated_files_size; i++)
|
||||
free (generated_files[i].name);
|
||||
free (generated_files);
|
||||
free (relocate_buffer);
|
||||
}
|
||||
|
||||
+4
-4
@@ -48,7 +48,7 @@ extern char *spec_graph_file;
|
||||
extern char *spec_xml_file;
|
||||
|
||||
/* File name specified with --defines. */
|
||||
extern char *spec_defines_file;
|
||||
extern char *spec_header_file;
|
||||
|
||||
/* Directory prefix of output file names. */
|
||||
extern char *dir_prefix;
|
||||
@@ -58,12 +58,12 @@ extern char *dir_prefix;
|
||||
and therefore GCC warns about a name clash. */
|
||||
extern uniqstr grammar_file;
|
||||
|
||||
/* The current file name. Might change with #line. */
|
||||
extern uniqstr current_file;
|
||||
|
||||
/* The computed base for output file names. */
|
||||
extern char *all_but_ext;
|
||||
|
||||
/* Where our data files are installed. */
|
||||
char const *pkgdatadir (void);
|
||||
|
||||
void compute_output_file_names (void);
|
||||
void output_file_names_free (void);
|
||||
|
||||
|
||||
+24
-8
@@ -52,6 +52,11 @@ fixit_new (location const *loc, char const* fix)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
fixit_cmp (const fixit *a, const fixit *b)
|
||||
{
|
||||
return location_cmp (a->location, b->location);
|
||||
}
|
||||
|
||||
static void
|
||||
fixit_free (fixit *f)
|
||||
@@ -69,8 +74,8 @@ fixit_print (fixit const *f, FILE *out)
|
||||
{
|
||||
fprintf (out, "fix-it:%s:{%d:%d-%d:%d}:%s\n",
|
||||
quotearg_n_style (1, c_quoting_style, f->location.start.file),
|
||||
f->location.start.line, f->location.start.column,
|
||||
f->location.end.line, f->location.end.column,
|
||||
f->location.start.line, f->location.start.byte,
|
||||
f->location.end.line, f->location.end.byte,
|
||||
quotearg_n_style (2, c_quoting_style, f->fix));
|
||||
}
|
||||
|
||||
@@ -85,8 +90,8 @@ fixits_register (location const *loc, char const* fix)
|
||||
(gl_listelement_dispose_fn) fixit_free,
|
||||
true);
|
||||
fixit *f = fixit_new (loc, fix);
|
||||
gl_list_add_last (fixits, f);
|
||||
if (feature_flag & feature_fixit_parsable)
|
||||
gl_sortedlist_add (fixits, (gl_listelement_compar_fn) fixit_cmp, f);
|
||||
if (feature_flag & feature_fixit)
|
||||
fixit_print (f, stderr);
|
||||
}
|
||||
|
||||
@@ -136,19 +141,29 @@ fixits_run (void)
|
||||
}
|
||||
putc (c, out);
|
||||
}
|
||||
|
||||
/* Look for the right offset. */
|
||||
while (offset < f->location.start.column)
|
||||
bool need_eol = false;
|
||||
while (offset < f->location.start.byte)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
break;
|
||||
++offset;
|
||||
putc (c, out);
|
||||
if (c == '\n')
|
||||
/* The position we are asked for is beyond the actual
|
||||
line: pad with spaces, and remember we need a \n. */
|
||||
need_eol = true;
|
||||
putc (need_eol ? ' ' : c, out);
|
||||
}
|
||||
|
||||
/* Paste the fix instead. */
|
||||
fputs (f->fix, out);
|
||||
|
||||
/* Maybe install the eol afterwards. */
|
||||
if (need_eol)
|
||||
putc ('\n', out);
|
||||
|
||||
/* Skip the bad input. */
|
||||
while (line < f->location.end.line)
|
||||
{
|
||||
@@ -161,16 +176,17 @@ fixits_run (void)
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
while (offset < f->location.end.column)
|
||||
while (offset < f->location.end.byte)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
break;
|
||||
++offset;
|
||||
}
|
||||
|
||||
/* If erasing the content of a full line, also remove the
|
||||
end-of-line. */
|
||||
if (f->fix[0] == 0 && f->location.start.column == 1)
|
||||
if (f->fix[0] == 0 && f->location.start.byte == 1)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
|
||||
+316
-206
@@ -19,8 +19,9 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
#include "getargs.h"
|
||||
|
||||
#include "system.h"
|
||||
#include "output.h"
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <c-strcase.h>
|
||||
@@ -28,12 +29,13 @@
|
||||
#include <error.h>
|
||||
#include <getopt.h>
|
||||
#include <progname.h>
|
||||
#include <quote.h>
|
||||
#include <textstyle.h>
|
||||
|
||||
#include "complain.h"
|
||||
#include "files.h"
|
||||
#include "getargs.h"
|
||||
#include "muscle-tab.h"
|
||||
#include "quote.h"
|
||||
#include "output.h"
|
||||
#include "uniqstr.h"
|
||||
|
||||
bool defines_flag = false;
|
||||
@@ -43,6 +45,7 @@ bool no_lines_flag = false;
|
||||
bool token_table_flag = false;
|
||||
location yacc_loc = EMPTY_LOCATION_INIT;
|
||||
bool update_flag = false; /* for -u */
|
||||
bool color_debug = false;
|
||||
|
||||
bool nondeterministic_parser = false;
|
||||
bool glr_parser = false;
|
||||
@@ -65,28 +68,28 @@ const char *skeleton = NULL;
|
||||
int language_prio = default_prio;
|
||||
struct bison_language const *language = &valid_languages[0];
|
||||
|
||||
typedef int* (xargmatch_fn) (const char *context, const char *arg);
|
||||
|
||||
/** Decode an option's key.
|
||||
*
|
||||
* \param opt option being decoded.
|
||||
* \param keys array of valid subarguments.
|
||||
* \param values array of corresponding (int) values.
|
||||
* \param all the all value.
|
||||
* \param flags the flags to update
|
||||
* \param arg the subarguments to decode.
|
||||
* If null, then activate all the flags.
|
||||
* \param no length of the potential "no-" prefix.
|
||||
* Can be 0 or 3. If 3, negate the action of the subargument.
|
||||
* \param opt option being decoded.
|
||||
* \param xargmatch matching function.
|
||||
* \param all the value of the argument 'all'.
|
||||
* \param flags the flags to update
|
||||
* \param arg the subarguments to decode.
|
||||
* If null, then activate all the flags.
|
||||
* \param no length of the potential "no-" prefix.
|
||||
* Can be 0 or 3. If 3, negate the action of the subargument.
|
||||
*
|
||||
* If VALUE != 0 then KEY sets flags and no-KEY clears them.
|
||||
* If VALUE == 0 then KEY clears all flags from \c all and no-KEY sets all
|
||||
* flags from \c all. Thus no-none = all and no-all = none.
|
||||
*/
|
||||
static void
|
||||
flag_argmatch (const char *opt,
|
||||
const char *const keys[], const int values[],
|
||||
flag_argmatch (const char *opt, xargmatch_fn xargmatch,
|
||||
int all, int *flags, char *arg, size_t no)
|
||||
{
|
||||
int value = XARGMATCH (opt, arg + no, keys, values);
|
||||
int value = *xargmatch (opt, arg + no);
|
||||
|
||||
/* -rnone == -rno-all, and -rno-none == -rall. */
|
||||
if (!value)
|
||||
@@ -101,30 +104,38 @@ flag_argmatch (const char *opt,
|
||||
*flags |= value;
|
||||
}
|
||||
|
||||
typedef void (usage_fn) (FILE *out);
|
||||
|
||||
/** Decode an option's set of keys.
|
||||
*
|
||||
* \param opt option being decoded (e.g., --report).
|
||||
* \param keys array of valid subarguments.
|
||||
* \param values array of corresponding (int) values.
|
||||
* \param all the all value.
|
||||
* \param flags the flags to update
|
||||
* \param args comma separated list of effective subarguments to decode.
|
||||
* If 0, then activate all the flags.
|
||||
* \param opt option being decoded (e.g., --report).
|
||||
* \param xargmatch matching function.
|
||||
* \param usage function that implement --help for this option.
|
||||
* \param all the value of the argument 'all'.
|
||||
* \param flags the flags to update
|
||||
* \param args comma separated list of effective subarguments to decode.
|
||||
* If 0, then activate all the flags.
|
||||
*/
|
||||
static void
|
||||
flags_argmatch (const char *opt,
|
||||
const char * const keys[], const int values[],
|
||||
xargmatch_fn xargmatch,
|
||||
usage_fn usage,
|
||||
int all, int *flags, char *args)
|
||||
{
|
||||
if (args)
|
||||
if (!args)
|
||||
*flags |= all;
|
||||
else if (STREQ (args, "help"))
|
||||
{
|
||||
usage (stdout);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
for (args = strtok (args, ","); args; args = strtok (NULL, ","))
|
||||
{
|
||||
size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
|
||||
flag_argmatch (opt, keys,
|
||||
values, all, flags, args, no);
|
||||
flag_argmatch (opt, xargmatch,
|
||||
all, flags, args, no);
|
||||
}
|
||||
else
|
||||
*flags |= all;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,110 +150,188 @@ flags_argmatch (const char *opt,
|
||||
* \arg FlagName_flag the flag to update.
|
||||
*/
|
||||
#define FLAGS_ARGMATCH(FlagName, Args, All) \
|
||||
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
||||
flags_argmatch ("--" #FlagName, \
|
||||
(xargmatch_fn*) argmatch_## FlagName ## _value, \
|
||||
argmatch_## FlagName ## _usage, \
|
||||
All, &FlagName ## _flag, Args)
|
||||
|
||||
/*---------------------.
|
||||
| --color's handling. |
|
||||
`---------------------*/
|
||||
|
||||
enum color
|
||||
{
|
||||
color_always,
|
||||
color_never,
|
||||
color_auto
|
||||
};
|
||||
|
||||
ARGMATCH_DEFINE_GROUP (color, enum color)
|
||||
|
||||
static const argmatch_color_doc argmatch_color_docs[] =
|
||||
{
|
||||
{ "always", N_("colorize the output") },
|
||||
{ "never", N_("don't colorize the output") },
|
||||
{ "auto", N_("colorize if the output device is a tty") },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
static const argmatch_color_arg argmatch_color_args[] =
|
||||
{
|
||||
{ "always", color_always },
|
||||
{ "yes", color_always },
|
||||
{ "never", color_never },
|
||||
{ "no", color_never },
|
||||
{ "auto", color_auto },
|
||||
{ "tty", color_auto },
|
||||
{ NULL, color_always },
|
||||
};
|
||||
|
||||
const argmatch_color_group_type argmatch_color_group =
|
||||
{
|
||||
argmatch_color_args,
|
||||
argmatch_color_docs,
|
||||
/* TRANSLATORS: Use the same translation for WHEN as in the
|
||||
--color=WHEN help message. */
|
||||
N_("WHEN can be one of the following:"),
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/*----------------------.
|
||||
| --report's handling. |
|
||||
`----------------------*/
|
||||
|
||||
static const char * const report_args[] =
|
||||
ARGMATCH_DEFINE_GROUP (report, enum report)
|
||||
|
||||
static const argmatch_report_doc argmatch_report_docs[] =
|
||||
{
|
||||
/* In a series of synonyms, present the most meaningful first, so
|
||||
that argmatch_valid be more readable. */
|
||||
"none",
|
||||
"state", "states",
|
||||
"itemset", "itemsets",
|
||||
"lookahead", "lookaheads", "look-ahead",
|
||||
"solved",
|
||||
"all",
|
||||
0
|
||||
{ "states", N_("describe the states") },
|
||||
{ "itemsets", N_("complete the core item sets with their closure") },
|
||||
{ "lookaheads", N_("explicitly associate lookahead tokens to items") },
|
||||
{ "solved", N_("describe shift/reduce conflicts solving") },
|
||||
{ "all", N_("include all the above information") },
|
||||
{ "none", N_("disable the report") },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
static const int report_types[] =
|
||||
static const argmatch_report_arg argmatch_report_args[] =
|
||||
{
|
||||
report_none,
|
||||
report_states, report_states,
|
||||
report_states | report_itemsets, report_states | report_itemsets,
|
||||
report_states | report_lookahead_tokens,
|
||||
report_states | report_lookahead_tokens,
|
||||
report_states | report_lookahead_tokens,
|
||||
report_states | report_solved_conflicts,
|
||||
report_all
|
||||
{ "none", report_none },
|
||||
{ "states", report_states },
|
||||
{ "itemsets", report_states | report_itemsets },
|
||||
{ "lookaheads", report_states | report_lookahead_tokens },
|
||||
{ "solved", report_states | report_solved_conflicts },
|
||||
{ "all", report_all },
|
||||
{ NULL, report_none },
|
||||
};
|
||||
|
||||
ARGMATCH_VERIFY (report_args, report_types);
|
||||
|
||||
const argmatch_report_group_type argmatch_report_group =
|
||||
{
|
||||
argmatch_report_args,
|
||||
argmatch_report_docs,
|
||||
/* TRANSLATORS: Use the same translation for THINGS as in the
|
||||
--report=THINGS help message. */
|
||||
N_("THINGS is a list of comma separated words that can include:"),
|
||||
NULL
|
||||
};
|
||||
|
||||
/*---------------------.
|
||||
| --trace's handling. |
|
||||
`---------------------*/
|
||||
|
||||
static const char * const trace_args[] =
|
||||
ARGMATCH_DEFINE_GROUP (trace, enum trace)
|
||||
|
||||
static const argmatch_trace_doc argmatch_trace_docs[] =
|
||||
{
|
||||
"none - no traces",
|
||||
"scan - grammar scanner traces",
|
||||
"parse - grammar parser traces",
|
||||
"automaton - construction of the automaton",
|
||||
"bitsets - use of bitsets",
|
||||
"grammar - reading, reducing the grammar",
|
||||
"resource - memory consumption (where available)",
|
||||
"sets - grammar sets: firsts, nullable etc.",
|
||||
"muscles - m4 definitions passed to the skeleton",
|
||||
"tools - m4 invocation",
|
||||
"m4 - m4 traces",
|
||||
"skeleton - skeleton postprocessing",
|
||||
"time - time consumption",
|
||||
"ielr - IELR conversion",
|
||||
"all - all of the above",
|
||||
0
|
||||
/* Meant for developers only, don't translate them. */
|
||||
{ "none", "no traces" },
|
||||
{ "locations", "full display of the locations" },
|
||||
{ "scan", "grammar scanner traces" },
|
||||
{ "parse", "grammar parser traces" },
|
||||
{ "automaton", "construction of the automaton" },
|
||||
{ "bitsets", "use of bitsets" },
|
||||
{ "closure", "input/output of closure" },
|
||||
{ "grammar", "reading, reducing the grammar" },
|
||||
{ "resource", "memory consumption (where available)" },
|
||||
{ "sets", "grammar sets: firsts, nullable etc." },
|
||||
{ "muscles", "m4 definitions passed to the skeleton" },
|
||||
{ "tools", "m4 invocation" },
|
||||
{ "m4", "m4 traces" },
|
||||
{ "skeleton", "skeleton postprocessing" },
|
||||
{ "time", "time consumption" },
|
||||
{ "ielr", "IELR conversion" },
|
||||
{ "all", "all of the above" },
|
||||
{ NULL, NULL},
|
||||
};
|
||||
|
||||
static const int trace_types[] =
|
||||
static const argmatch_trace_arg argmatch_trace_args[] =
|
||||
{
|
||||
trace_none,
|
||||
trace_scan,
|
||||
trace_parse,
|
||||
trace_automaton,
|
||||
trace_bitsets,
|
||||
trace_grammar,
|
||||
trace_resource,
|
||||
trace_sets,
|
||||
trace_muscles,
|
||||
trace_tools,
|
||||
trace_m4,
|
||||
trace_skeleton,
|
||||
trace_time,
|
||||
trace_ielr,
|
||||
trace_all
|
||||
{ "none", trace_none },
|
||||
{ "locations", trace_locations },
|
||||
{ "scan", trace_scan },
|
||||
{ "parse", trace_parse },
|
||||
{ "automaton", trace_automaton },
|
||||
{ "bitsets", trace_bitsets },
|
||||
{ "closure", trace_closure },
|
||||
{ "grammar", trace_grammar },
|
||||
{ "resource", trace_resource },
|
||||
{ "sets", trace_sets },
|
||||
{ "muscles", trace_muscles },
|
||||
{ "tools", trace_tools },
|
||||
{ "m4", trace_m4 },
|
||||
{ "skeleton", trace_skeleton },
|
||||
{ "time", trace_time },
|
||||
{ "ielr", trace_ielr },
|
||||
{ "all", trace_all },
|
||||
{ NULL, trace_none},
|
||||
};
|
||||
|
||||
ARGMATCH_VERIFY (trace_args, trace_types);
|
||||
|
||||
const argmatch_trace_group_type argmatch_trace_group =
|
||||
{
|
||||
argmatch_trace_args,
|
||||
argmatch_trace_docs,
|
||||
N_("TRACES is a list of comma separated words that can include:"),
|
||||
NULL
|
||||
};
|
||||
|
||||
/*-----------------------.
|
||||
| --feature's handling. |
|
||||
`-----------------------*/
|
||||
|
||||
static const char * const feature_args[] =
|
||||
ARGMATCH_DEFINE_GROUP (feature, enum feature)
|
||||
|
||||
static const argmatch_feature_doc argmatch_feature_docs[] =
|
||||
{
|
||||
"none",
|
||||
"caret", "diagnostics-show-caret",
|
||||
"fixit", "diagnostics-parseable-fixits",
|
||||
"all",
|
||||
0
|
||||
{ "caret", N_("show errors with carets") },
|
||||
{ "fixit", N_("show machine-readable fixes") },
|
||||
{ "syntax-only", N_("do not generate any file") },
|
||||
{ "all", N_("all of the above") },
|
||||
{ "none", N_("disable all of the above") },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const int feature_types[] =
|
||||
static const argmatch_feature_arg argmatch_feature_args[] =
|
||||
{
|
||||
feature_none,
|
||||
feature_caret, feature_caret,
|
||||
feature_fixit_parsable, feature_fixit_parsable,
|
||||
feature_all
|
||||
{ "none", feature_none },
|
||||
{ "caret", feature_caret },
|
||||
{ "diagnostics-show-caret", feature_caret },
|
||||
{ "fixit", feature_fixit },
|
||||
{ "diagnostics-parseable-fixits", feature_fixit },
|
||||
{ "syntax-only", feature_syntax_only },
|
||||
{ "all", feature_all },
|
||||
{ NULL, feature_none}
|
||||
};
|
||||
|
||||
ARGMATCH_VERIFY (feature_args, feature_types);
|
||||
const argmatch_feature_group_type argmatch_feature_group =
|
||||
{
|
||||
argmatch_feature_args,
|
||||
argmatch_feature_docs,
|
||||
/* TRANSLATORS: Use the same translation for FEATURES as in the
|
||||
--feature=FEATURES help message. */
|
||||
N_("FEATURES is a list of comma separated words that can include:"),
|
||||
NULL
|
||||
};
|
||||
|
||||
/*-------------------------------------------.
|
||||
| Display the help message and exit STATUS. |
|
||||
@@ -266,8 +355,7 @@ usage (int status)
|
||||
printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
|
||||
fputs (_("\
|
||||
Generate a deterministic LR or generalized LR (GLR) parser employing\n\
|
||||
LALR(1), IELR(1), or canonical LR(1) parser tables. IELR(1) and\n\
|
||||
canonical LR(1) support is experimental.\n\
|
||||
LALR(1), IELR(1), or canonical LR(1) parser tables.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
|
||||
@@ -277,10 +365,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (_("\
|
||||
The same is true for optional arguments.\n\
|
||||
"), stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
fputs (_("\
|
||||
\n\
|
||||
Operation modes:\n\
|
||||
Operation Modes:\n\
|
||||
-h, --help display this help and exit\n\
|
||||
-V, --version output version information and exit\n\
|
||||
--print-localedir output directory containing locale-dependent data\n\
|
||||
@@ -288,32 +376,48 @@ Operation modes:\n\
|
||||
--print-datadir output directory containing skeletons and XSLT\n\
|
||||
and exit\n\
|
||||
-u, --update apply fixes to the source grammar file and exit\n\
|
||||
-y, --yacc emulate POSIX Yacc\n\
|
||||
-W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\
|
||||
-f, --feature[=FEATURE] activate miscellaneous features\n\
|
||||
-f, --feature[=FEATURES] activate miscellaneous features\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
|
||||
argmatch_feature_usage (stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
fputs (_("\
|
||||
Parser:\n\
|
||||
Diagnostics:\n\
|
||||
-W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\
|
||||
--color[=WHEN] whether to colorize the diagnostics\n\
|
||||
--style=FILE specify the CSS FILE for colorizer diagnostics\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
|
||||
warning_usage (stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
argmatch_color_usage (stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
fputs (_("\
|
||||
Tuning the Parser:\n\
|
||||
-L, --language=LANGUAGE specify the output programming language\n\
|
||||
-S, --skeleton=FILE specify the skeleton to use\n\
|
||||
-t, --debug instrument the parser for tracing\n\
|
||||
same as '-Dparse.trace'\n\
|
||||
--locations enable location support\n\
|
||||
-D, --define=NAME[=VALUE] similar to '%define NAME \"VALUE\"'\n\
|
||||
-F, --force-define=NAME[=VALUE] override '%define NAME \"VALUE\"'\n\
|
||||
-D, --define=NAME[=VALUE] similar to '%define NAME VALUE'\n\
|
||||
-F, --force-define=NAME[=VALUE] override '%define NAME VALUE'\n\
|
||||
-p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
|
||||
deprecated by '-Dapi.prefix=PREFIX'\n\
|
||||
deprecated by '-Dapi.prefix={PREFIX}'\n\
|
||||
-l, --no-lines don't generate '#line' directives\n\
|
||||
-k, --token-table include a table of token names\n\
|
||||
-y, --yacc emulate POSIX Yacc\n\
|
||||
"), stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
/* Keep -d and --defines separate so that ../build-aux/cross-options.pl
|
||||
* won't assume that -d also takes an argument. */
|
||||
fputs (_("\
|
||||
Output:\n\
|
||||
Output Files:\n\
|
||||
--defines[=FILE] also produce a header file\n\
|
||||
-d likewise but cannot specify FILE (for POSIX Yacc)\n\
|
||||
-r, --report=THINGS also produce details on the automaton\n\
|
||||
@@ -323,46 +427,12 @@ Output:\n\
|
||||
-o, --output=FILE leave output to FILE\n\
|
||||
-g, --graph[=FILE] also output a graph of the automaton\n\
|
||||
-x, --xml[=FILE] also output an XML report of the automaton\n\
|
||||
(the XML schema is experimental)\n\
|
||||
"), stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
fputs (_("\
|
||||
Warning categories include:\n\
|
||||
'midrule-values' unset or unused midrule values\n\
|
||||
'yacc' incompatibilities with POSIX Yacc\n\
|
||||
'conflicts-sr' S/R conflicts (enabled by default)\n\
|
||||
'conflicts-rr' R/R conflicts (enabled by default)\n\
|
||||
'deprecated' obsolete constructs\n\
|
||||
'empty-rule' empty rules without %empty\n\
|
||||
'precedence' useless precedence and associativity\n\
|
||||
'other' all other warnings (enabled by default)\n\
|
||||
'all' all the warnings except 'yacc'\n\
|
||||
'no-CATEGORY' turn off warnings in CATEGORY\n\
|
||||
'none' turn off all the warnings\n\
|
||||
'error[=CATEGORY]' treat warnings as errors\n\
|
||||
"), stdout);
|
||||
argmatch_report_usage (stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
fputs (_("\
|
||||
THINGS is a list of comma separated words that can include:\n\
|
||||
'state' describe the states\n\
|
||||
'itemset' complete the core item sets with their closure\n\
|
||||
'lookahead' explicitly associate lookahead tokens to items\n\
|
||||
'solved' describe shift/reduce conflicts solving\n\
|
||||
'all' include all the above information\n\
|
||||
'none' disable the report\n\
|
||||
"), stdout);
|
||||
putc ('\n', stdout);
|
||||
|
||||
fputs (_("\
|
||||
FEATURE is a list of comma separated words that can include:\n\
|
||||
'caret' show errors with carets\n\
|
||||
'all' all of the above\n\
|
||||
'none' disable all of the above\n\
|
||||
"), stdout);
|
||||
|
||||
putc ('\n', stdout);
|
||||
printf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
||||
printf (_("%s home page: <%s>.\n"), PACKAGE_NAME, PACKAGE_URL);
|
||||
fputs (_("General help using GNU software: "
|
||||
@@ -436,7 +506,7 @@ skeleton_arg (char const *arg, int prio, location loc)
|
||||
void
|
||||
language_argmatch (char const *arg, int prio, location loc)
|
||||
{
|
||||
char const *msg;
|
||||
char const *msg = NULL;
|
||||
|
||||
if (prio < language_prio)
|
||||
{
|
||||
@@ -451,10 +521,9 @@ language_argmatch (char const *arg, int prio, location loc)
|
||||
}
|
||||
else if (language_prio == prio)
|
||||
msg = _("multiple language declarations are invalid");
|
||||
else
|
||||
return;
|
||||
|
||||
complain (&loc, complaint, msg, quotearg_colon (arg));
|
||||
if (msg)
|
||||
complain (&loc, complaint, msg, quotearg_colon (arg));
|
||||
}
|
||||
|
||||
/*----------------------.
|
||||
@@ -491,12 +560,16 @@ static char const short_options[] =
|
||||
/* Values for long options that do not have single-letter equivalents. */
|
||||
enum
|
||||
{
|
||||
LOCATIONS_OPTION = CHAR_MAX + 1,
|
||||
PRINT_LOCALEDIR_OPTION,
|
||||
COLOR_OPTION = CHAR_MAX + 1,
|
||||
FIXED_OUTPUT_FILES_OPTION,
|
||||
LOCATIONS_OPTION,
|
||||
PRINT_DATADIR_OPTION,
|
||||
REPORT_FILE_OPTION
|
||||
PRINT_LOCALEDIR_OPTION,
|
||||
REPORT_FILE_OPTION,
|
||||
STYLE_OPTION
|
||||
};
|
||||
|
||||
/* In the same order as in usage(), and in the documentation. */
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
/* Operation modes. */
|
||||
@@ -505,53 +578,43 @@ static struct option const long_options[] =
|
||||
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
|
||||
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
|
||||
{ "update", no_argument, 0, 'u' },
|
||||
{ "warnings", optional_argument, 0, 'W' },
|
||||
{ "feature", optional_argument, 0, 'f' },
|
||||
|
||||
/* Parser. */
|
||||
{ "name-prefix", required_argument, 0, 'p' },
|
||||
/* Diagnostics. */
|
||||
{ "warnings", optional_argument, 0, 'W' },
|
||||
{ "color", optional_argument, 0, COLOR_OPTION },
|
||||
{ "style", optional_argument, 0, STYLE_OPTION },
|
||||
|
||||
/* Output. */
|
||||
{ "file-prefix", required_argument, 0, 'b' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "output-file", required_argument, 0, 'o' },
|
||||
{ "graph", optional_argument, 0, 'g' },
|
||||
{ "xml", optional_argument, 0, 'x' },
|
||||
/* Tuning the Parser. */
|
||||
{ "language", required_argument, 0, 'L' },
|
||||
{ "skeleton", required_argument, 0, 'S' },
|
||||
{ "debug", no_argument, 0, 't' },
|
||||
{ "locations", no_argument, 0, LOCATIONS_OPTION },
|
||||
{ "define", required_argument, 0, 'D' },
|
||||
{ "force-define", required_argument, 0, 'F' },
|
||||
{ "name-prefix", required_argument, 0, 'p' },
|
||||
{ "no-lines", no_argument, 0, 'l' },
|
||||
{ "token-table", no_argument, 0, 'k' },
|
||||
{ "yacc", no_argument, 0, 'y' },
|
||||
|
||||
/* Output Files. */
|
||||
{ "defines", optional_argument, 0, 'd' },
|
||||
{ "report", required_argument, 0, 'r' },
|
||||
{ "report-file", required_argument, 0, REPORT_FILE_OPTION },
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
{ "file-prefix", required_argument, 0, 'b' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "graph", optional_argument, 0, 'g' },
|
||||
{ "xml", optional_argument, 0, 'x' },
|
||||
|
||||
/* Hidden. */
|
||||
{ "trace", optional_argument, 0, 'T' },
|
||||
|
||||
/* Output. */
|
||||
{ "defines", optional_argument, 0, 'd' },
|
||||
{ "feature", optional_argument, 0, 'f' },
|
||||
|
||||
/* Operation modes. */
|
||||
{ "fixed-output-files", no_argument, 0, 'y' },
|
||||
{ "yacc", no_argument, 0, 'y' },
|
||||
|
||||
/* Parser. */
|
||||
{ "debug", no_argument, 0, 't' },
|
||||
{ "define", required_argument, 0, 'D' },
|
||||
{ "force-define", required_argument, 0, 'F' },
|
||||
{ "locations", no_argument, 0, LOCATIONS_OPTION },
|
||||
{ "no-lines", no_argument, 0, 'l' },
|
||||
{ "skeleton", required_argument, 0, 'S' },
|
||||
{ "language", required_argument, 0, 'L' },
|
||||
{ "token-table", no_argument, 0, 'k' },
|
||||
{ "fixed-output-files", no_argument, 0, FIXED_OUTPUT_FILES_OPTION },
|
||||
{ "output-file", required_argument, 0, 'o' },
|
||||
{ "trace", optional_argument, 0, 'T' },
|
||||
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* Under DOS, there is no difference on the case. This can be
|
||||
troublesome when looking for '.tab' etc. */
|
||||
#ifdef MSDOS
|
||||
# define AS_FILE_NAME(File) (strlwr (File), (File))
|
||||
#else
|
||||
# define AS_FILE_NAME(File) (File)
|
||||
#endif
|
||||
|
||||
/* Build a location for the current command line argument. */
|
||||
static
|
||||
location
|
||||
@@ -559,19 +622,52 @@ command_line_location (void)
|
||||
{
|
||||
location res;
|
||||
/* "<command line>" is used in GCC's messages about -D. */
|
||||
boundary_set (&res.start, uniqstr_new ("<command line>"), optind - 1, -1);
|
||||
boundary_set (&res.start, uniqstr_new ("<command line>"), optind - 1, -1, -1);
|
||||
res.end = res.start;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* Handle the command line options for color support. Do it early, so
|
||||
that error messages from getargs be also colored as per the user's
|
||||
request. This is consistent with the way GCC and Clang behave. */
|
||||
|
||||
static void
|
||||
getargs_colors (int argc, char *argv[])
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
const char *arg = argv[i];
|
||||
if (STRPREFIX_LIT ("--color=", arg))
|
||||
{
|
||||
const char *color = arg + strlen ("--color=");
|
||||
if (STREQ (color, "debug"))
|
||||
color_debug = true;
|
||||
else
|
||||
handle_color_option (color);
|
||||
}
|
||||
else if (STREQ ("--color", arg))
|
||||
handle_color_option (NULL);
|
||||
else if (STRPREFIX_LIT ("--style=", arg))
|
||||
{
|
||||
const char *style = arg + strlen ("--style=");
|
||||
handle_style_option (style);
|
||||
}
|
||||
}
|
||||
complain_init_color ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
getargs (int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
getargs_colors (argc, argv);
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
location loc = command_line_location ();
|
||||
switch (c)
|
||||
{
|
||||
/* ASCII Sorting for short options (i.e., upper case then
|
||||
@@ -604,7 +700,7 @@ getargs (int argc, char *argv[])
|
||||
*end = 0;
|
||||
}
|
||||
}
|
||||
muscle_percent_define_insert (name, command_line_location (),
|
||||
muscle_percent_define_insert (name, loc,
|
||||
kind, value ? value : "",
|
||||
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
|
||||
: MUSCLE_PERCENT_DEFINE_F);
|
||||
@@ -612,13 +708,11 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
language_argmatch (optarg, command_line_prio,
|
||||
command_line_location ());
|
||||
language_argmatch (optarg, command_line_prio, loc);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
|
||||
command_line_location ());
|
||||
skeleton_arg (optarg, command_line_prio, loc);
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
@@ -638,7 +732,7 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
spec_file_prefix = AS_FILE_NAME (optarg);
|
||||
spec_file_prefix = optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
@@ -646,8 +740,8 @@ getargs (int argc, char *argv[])
|
||||
defines_flag = true;
|
||||
if (optarg)
|
||||
{
|
||||
free (spec_defines_file);
|
||||
spec_defines_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
free (spec_header_file);
|
||||
spec_header_file = xstrdup (optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -656,7 +750,7 @@ getargs (int argc, char *argv[])
|
||||
if (optarg)
|
||||
{
|
||||
free (spec_graph_file);
|
||||
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
spec_graph_file = xstrdup (optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -672,7 +766,7 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
spec_outfile = AS_FILE_NAME (optarg);
|
||||
spec_outfile = optarg;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
@@ -685,13 +779,14 @@ getargs (int argc, char *argv[])
|
||||
|
||||
case 't':
|
||||
muscle_percent_define_insert ("parse.trace",
|
||||
command_line_location (),
|
||||
loc,
|
||||
muscle_keyword, "",
|
||||
MUSCLE_PERCENT_DEFINE_D);
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
update_flag = true;
|
||||
feature_flag |= feature_syntax_only;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
@@ -703,18 +798,28 @@ getargs (int argc, char *argv[])
|
||||
if (optarg)
|
||||
{
|
||||
free (spec_xml_file);
|
||||
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
spec_xml_file = xstrdup (optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
warning_argmatch ("yacc", 0, 0);
|
||||
yacc_loc = command_line_location ();
|
||||
yacc_loc = loc;
|
||||
break;
|
||||
|
||||
case COLOR_OPTION:
|
||||
/* Handled in getargs_colors. */
|
||||
break;
|
||||
|
||||
case FIXED_OUTPUT_FILES_OPTION:
|
||||
complain (&loc, Wdeprecated,
|
||||
_("deprecated option: %s, use %s"),
|
||||
quote ("--fixed-output-files"), quote_n (1, "-o y.tab.c"));
|
||||
spec_outfile = "y.tab.c";
|
||||
break;
|
||||
|
||||
case LOCATIONS_OPTION:
|
||||
muscle_percent_define_ensure ("locations",
|
||||
command_line_location (), true);
|
||||
muscle_percent_define_ensure ("locations", loc, true);
|
||||
break;
|
||||
|
||||
case PRINT_LOCALEDIR_OPTION:
|
||||
@@ -727,12 +832,17 @@ getargs (int argc, char *argv[])
|
||||
|
||||
case REPORT_FILE_OPTION:
|
||||
free (spec_verbose_file);
|
||||
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
spec_verbose_file = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
case STYLE_OPTION:
|
||||
/* Handled in getargs_colors. */
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind != 1)
|
||||
{
|
||||
@@ -743,7 +853,7 @@ getargs (int argc, char *argv[])
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
current_file = grammar_file = uniqstr_new (argv[optind]);
|
||||
grammar_file = uniqstr_new (argv[optind]);
|
||||
MUSCLE_INSERT_C_STRING ("file_name", grammar_file);
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -41,7 +41,7 @@ extern bool no_lines_flag; /* for -l */
|
||||
extern bool token_table_flag; /* for -k */
|
||||
extern location yacc_loc; /* for -y */
|
||||
extern bool update_flag; /* for -u */
|
||||
|
||||
extern bool color_debug; /* --color=debug. */
|
||||
/* GLR_PARSER is true if the input file says to use the GLR
|
||||
(Generalized LR) parser, and to output some additional information
|
||||
used by the GLR algorithm. */
|
||||
@@ -103,6 +103,8 @@ enum trace
|
||||
trace_m4 = 1 << 10, /**< M4 traces. */
|
||||
trace_muscles = 1 << 11, /**< M4 definitions of the muscles. */
|
||||
trace_ielr = 1 << 12, /**< IELR conversion. */
|
||||
trace_closure = 1 << 13, /**< Input/output of closure(). */
|
||||
trace_locations = 1 << 14, /**< Full display of locations. */
|
||||
trace_all = ~0 /**< All of the above. */
|
||||
};
|
||||
/** What debug items bison displays during its run. */
|
||||
@@ -114,10 +116,11 @@ extern int trace_flag;
|
||||
|
||||
enum feature
|
||||
{
|
||||
feature_none = 0, /**< No additional feature. */
|
||||
feature_caret = 1 << 0, /**< Output errors with carets. */
|
||||
feature_fixit_parsable = 1 << 1, /**< Issue instructions to fix the sources. */
|
||||
feature_all = ~0 /**< All above features. */
|
||||
feature_none = 0, /**< No additional feature. */
|
||||
feature_caret = 1 << 0, /**< Output errors with carets. */
|
||||
feature_fixit = 1 << 1, /**< Issue instructions to fix the sources. */
|
||||
feature_syntax_only = 1 << 2, /**< Don't generate output. */
|
||||
feature_all = ~0 /**< All above features. */
|
||||
};
|
||||
/** What additional features to use. */
|
||||
extern int feature_flag;
|
||||
|
||||
+87
-44
@@ -32,7 +32,7 @@
|
||||
/* Comments for these variables are in gram.h. */
|
||||
|
||||
item_number *ritem = NULL;
|
||||
unsigned nritems = 0;
|
||||
int nritems = 0;
|
||||
|
||||
rule *rules = NULL;
|
||||
rule_number nrules = 0;
|
||||
@@ -48,6 +48,34 @@ int max_user_token_number = 256;
|
||||
|
||||
int required_version = 0;
|
||||
|
||||
rule const *
|
||||
item_rule (item_number const *item)
|
||||
{
|
||||
item_number const *sp = item;
|
||||
while (0 <= *sp)
|
||||
++sp;
|
||||
rule_number r = item_number_as_rule_number (*sp);
|
||||
return &rules[r];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
item_print (item_number *item, rule const *previous_rule, FILE *out)
|
||||
{
|
||||
rule const *r = item_rule (item);
|
||||
rule_lhs_print (r, previous_rule ? previous_rule->lhs : NULL, out);
|
||||
|
||||
for (item_number *sp = r->rhs; sp < item; sp++)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
fputs (" .", out);
|
||||
if (0 <= *r->rhs)
|
||||
for (item_number *sp = item; 0 <= *sp; ++sp)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
else
|
||||
fprintf (out, " %%empty");
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
rule_useful_in_grammar_p (rule const *r)
|
||||
{
|
||||
@@ -66,6 +94,12 @@ rule_useless_in_parser_p (rule const *r)
|
||||
return !r->useful && rule_useful_in_grammar_p (r);
|
||||
}
|
||||
|
||||
bool
|
||||
rule_useless_chain_p (rule const *r)
|
||||
{
|
||||
return rule_rhs_length (r) == 1 && !r->action;
|
||||
}
|
||||
|
||||
void
|
||||
rule_lhs_print (rule const *r, sym_content const *previous_lhs, FILE *out)
|
||||
{
|
||||
@@ -86,7 +120,7 @@ size_t
|
||||
rule_rhs_length (rule const *r)
|
||||
{
|
||||
size_t res = 0;
|
||||
for (item_number *rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
||||
for (item_number *rhsp = r->rhs; 0 <= *rhsp; ++rhsp)
|
||||
++res;
|
||||
return res;
|
||||
}
|
||||
@@ -95,8 +129,8 @@ void
|
||||
rule_rhs_print (rule const *r, FILE *out)
|
||||
{
|
||||
if (0 <= *r->rhs)
|
||||
for (item_number *rp = r->rhs; *rp >= 0; rp++)
|
||||
fprintf (out, " %s", symbols[*rp]->tag);
|
||||
for (item_number *rhsp = r->rhs; 0 <= *rhsp; ++rhsp)
|
||||
fprintf (out, " %s", symbols[*rhsp]->tag);
|
||||
else
|
||||
fputs (" %empty", out);
|
||||
}
|
||||
@@ -107,9 +141,9 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
||||
if (*r->rhs >= 0)
|
||||
{
|
||||
xml_puts (out, level, "<rhs>");
|
||||
for (item_number *rp = r->rhs; *rp >= 0; rp++)
|
||||
for (item_number *rhsp = r->rhs; 0 <= *rhsp; ++rhsp)
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[*rp]->tag));
|
||||
xml_escape (symbols[*rhsp]->tag));
|
||||
xml_puts (out, level, "</rhs>");
|
||||
}
|
||||
else
|
||||
@@ -120,11 +154,18 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rule_print (rule const *r, rule const *prev_rule, FILE *out)
|
||||
{
|
||||
rule_lhs_print (r, prev_rule ? prev_rule->lhs : NULL, out);
|
||||
rule_rhs_print (r, out);
|
||||
}
|
||||
|
||||
void
|
||||
ritem_print (FILE *out)
|
||||
{
|
||||
fputs ("RITEM\n", out);
|
||||
for (unsigned i = 0; i < nritems; ++i)
|
||||
for (int i = 0; i < nritems; ++i)
|
||||
if (ritem[i] >= 0)
|
||||
fprintf (out, " %s", symbols[ritem[i]]->tag);
|
||||
else
|
||||
@@ -138,7 +179,7 @@ ritem_longest_rhs (void)
|
||||
int max = 0;
|
||||
for (rule_number r = 0; r < nrules; ++r)
|
||||
{
|
||||
int length = rule_rhs_length (&rules[r]);
|
||||
size_t length = rule_rhs_length (&rules[r]);
|
||||
if (length > max)
|
||||
max = length;
|
||||
}
|
||||
@@ -151,7 +192,7 @@ grammar_rules_partial_print (FILE *out, const char *title,
|
||||
rule_filter filter)
|
||||
{
|
||||
bool first = true;
|
||||
sym_content *previous_lhs = NULL;
|
||||
rule *previous_rule = NULL;
|
||||
|
||||
/* rule # : LHS -> RHS */
|
||||
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||
@@ -160,13 +201,12 @@ grammar_rules_partial_print (FILE *out, const char *title,
|
||||
continue;
|
||||
if (first)
|
||||
fprintf (out, "%s\n\n", title);
|
||||
else if (previous_lhs && previous_lhs != rules[r].lhs)
|
||||
else if (previous_rule && previous_rule->lhs != rules[r].lhs)
|
||||
fputc ('\n', out);
|
||||
first = false;
|
||||
rule_lhs_print (&rules[r], previous_lhs, out);
|
||||
rule_rhs_print (&rules[r], out);
|
||||
fprintf (out, "\n");
|
||||
previous_lhs = rules[r].lhs;
|
||||
rule_print (&rules[r], previous_rule, out);
|
||||
fputc ('\n', out);
|
||||
previous_rule = &rules[r];
|
||||
}
|
||||
if (!first)
|
||||
fputs ("\n\n", out);
|
||||
@@ -189,13 +229,10 @@ grammar_rules_print_xml (FILE *out, int level)
|
||||
xml_puts (out, level + 1, "<rules>");
|
||||
first = false;
|
||||
{
|
||||
char const *usefulness;
|
||||
if (rule_useless_in_grammar_p (&rules[r]))
|
||||
usefulness = "useless-in-grammar";
|
||||
else if (rule_useless_in_parser_p (&rules[r]))
|
||||
usefulness = "useless-in-parser";
|
||||
else
|
||||
usefulness = "useful";
|
||||
char const *usefulness
|
||||
= rule_useless_in_grammar_p (&rules[r]) ? "useless-in-grammar"
|
||||
: rule_useless_in_parser_p (&rules[r]) ? "useless-in-parser"
|
||||
: "useful";
|
||||
xml_indent (out, level + 2);
|
||||
fprintf (out, "<rule number=\"%d\" usefulness=\"%s\"",
|
||||
rules[r].number, usefulness);
|
||||
@@ -222,12 +259,11 @@ grammar_dump (FILE *out, const char *title)
|
||||
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
|
||||
ntokens, nvars, nsyms, nrules, nritems);
|
||||
|
||||
|
||||
fprintf (out, "Variables\n---------\n\n");
|
||||
fprintf (out, "Tokens\n------\n\n");
|
||||
{
|
||||
fprintf (out, "Value Sprec Sassoc Tag\n");
|
||||
|
||||
for (symbol_number i = ntokens; i < nsyms; i++)
|
||||
for (symbol_number i = 0; i < ntokens; i++)
|
||||
fprintf (out, "%5d %5d %5d %s\n",
|
||||
i,
|
||||
symbols[i]->content->prec, symbols[i]->content->assoc,
|
||||
@@ -235,42 +271,49 @@ grammar_dump (FILE *out, const char *title)
|
||||
fprintf (out, "\n\n");
|
||||
}
|
||||
|
||||
fprintf (out, "Non terminals\n-------------\n\n");
|
||||
{
|
||||
fprintf (out, "Value Tag\n");
|
||||
|
||||
for (symbol_number i = ntokens; i < nsyms; i++)
|
||||
fprintf (out, "%5d %s\n",
|
||||
i, symbols[i]->tag);
|
||||
fprintf (out, "\n\n");
|
||||
}
|
||||
|
||||
fprintf (out, "Rules\n-----\n\n");
|
||||
{
|
||||
fprintf (out,
|
||||
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
|
||||
" -> Rhs (Ritem range) [Num]\n");
|
||||
for (rule_number i = 0; i < nrules + nuseless_productions; i++)
|
||||
"Num (Prec, Assoc, Useful, UselessChain) Lhs"
|
||||
" -> (Ritem Range) Rhs\n");
|
||||
for (rule_number i = 0; i < nrules + nuseless_productions; ++i)
|
||||
{
|
||||
rule const *rule_i = &rules[i];
|
||||
unsigned const rhs_itemno = rule_i->rhs - ritem;
|
||||
/* Find the last RHS index in ritems. */
|
||||
unsigned rhs_count = 0;
|
||||
for (item_number *rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
++rhs_count;
|
||||
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
||||
int const rhs_itemno = rule_i->rhs - ritem;
|
||||
int length = rule_rhs_length (rule_i);
|
||||
aver (item_number_as_rule_number (rule_i->rhs[length]) == i);
|
||||
fprintf (out, "%3d (%2d, %2d, %2s, %2s) %2d -> (%2u-%2u)",
|
||||
i,
|
||||
rule_i->prec ? rule_i->prec->prec : 0,
|
||||
rule_i->prec ? rule_i->prec->assoc : 0,
|
||||
rule_i->useful,
|
||||
rhs_itemno,
|
||||
rhs_itemno + rhs_count - 1,
|
||||
rule_i->lhs->number);
|
||||
rule_i->useful ? "t" : "f",
|
||||
rule_useless_chain_p (rule_i) ? "t" : "f",
|
||||
rule_i->lhs->number,
|
||||
rhs_itemno, rhs_itemno + length - 1);
|
||||
/* Dumped the RHS. */
|
||||
for (item_number *rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
fprintf (out, " %3d", *rp);
|
||||
fprintf (out, " [%d]\n",
|
||||
item_number_as_rule_number (rule_i->rhs[rhs_count+1]));
|
||||
for (item_number *rhsp = rule_i->rhs; 0 <= *rhsp; ++rhsp)
|
||||
fprintf (out, " %3d", *rhsp);
|
||||
fputc ('\n', out);
|
||||
}
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
|
||||
fprintf (out, "Rules interpreted\n-----------------\n\n");
|
||||
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
|
||||
for (rule_number r = 0; r < nrules + nuseless_productions; ++r)
|
||||
{
|
||||
fprintf (out, "%-5d %s:", r, rules[r].lhs->symbol->tag);
|
||||
rule_rhs_print (&rules[r], out);
|
||||
fprintf (out, "\n");
|
||||
fputc ('\n', out);
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
}
|
||||
@@ -278,7 +321,7 @@ grammar_dump (FILE *out, const char *title)
|
||||
void
|
||||
grammar_rules_useless_report (const char *message)
|
||||
{
|
||||
for (rule_number r = 0; r < nrules ; ++r)
|
||||
for (rule_number r = 0; r < nrules; ++r)
|
||||
/* Don't complain about rules whose LHS is useless, we already
|
||||
complained about it. */
|
||||
if (!reduce_nonterminal_useless_in_grammar (rules[r].lhs)
|
||||
|
||||
+28
-10
@@ -75,7 +75,7 @@
|
||||
|
||||
RULES[R].line -- the line where R was defined.
|
||||
|
||||
RULES[R].useful -- true iff the rule is used (i.e., false if thrown
|
||||
RULES[R].useful -- whether the rule is used (i.e., false if thrown
|
||||
away by reduce).
|
||||
|
||||
The right hand side is stored as symbol numbers in a portion of
|
||||
@@ -115,7 +115,7 @@ extern int nvars;
|
||||
typedef int item_number;
|
||||
# define ITEM_NUMBER_MAX INT_MAX
|
||||
extern item_number *ritem;
|
||||
extern unsigned nritems;
|
||||
extern int nritems;
|
||||
|
||||
/* There is weird relationship between OT1H item_number and OTOH
|
||||
symbol_number and rule_number: we store the latter in
|
||||
@@ -146,7 +146,6 @@ item_number_is_symbol_number (item_number i)
|
||||
/* Rule numbers. */
|
||||
typedef int rule_number;
|
||||
# define RULE_NUMBER_MAX INT_MAX
|
||||
extern rule_number nrules;
|
||||
|
||||
static inline item_number
|
||||
rule_number_as_item_number (rule_number r)
|
||||
@@ -166,6 +165,7 @@ item_number_is_rule_number (item_number i)
|
||||
return i < 0;
|
||||
}
|
||||
|
||||
|
||||
/*--------.
|
||||
| Rules. |
|
||||
`--------*/
|
||||
@@ -192,6 +192,7 @@ typedef struct
|
||||
/* This symbol was attached to the rule via %prec. */
|
||||
sym_content *precsym;
|
||||
|
||||
/* Location of the rhs. */
|
||||
location location;
|
||||
bool useful;
|
||||
bool is_predicate;
|
||||
@@ -202,26 +203,40 @@ typedef struct
|
||||
int expected_rr_conflicts;
|
||||
|
||||
const char *action;
|
||||
location action_location;
|
||||
location action_loc;
|
||||
} rule;
|
||||
|
||||
/* The used rules (size NRULES). */
|
||||
extern rule *rules;
|
||||
extern rule_number nrules;
|
||||
|
||||
/* Get the rule associated to this item. ITEM points inside RITEM. */
|
||||
rule const *item_rule (item_number const *item);
|
||||
|
||||
/* Pretty-print this ITEM (as in the report). ITEM points inside
|
||||
RITEM. PREVIOUS_RULE is used to see if the lhs is common, in which
|
||||
case LHS is factored. Passing NULL is fine. */
|
||||
void item_print (item_number *item, rule const *previous_rule,
|
||||
FILE *out);
|
||||
|
||||
/* A function that selects a rule. */
|
||||
typedef bool (*rule_filter) (rule const *);
|
||||
|
||||
/* Return true IFF the rule has a 'number' smaller than NRULES. That is, it is
|
||||
useful in the grammar. */
|
||||
/* Whether the rule has a 'number' smaller than NRULES. That is, it
|
||||
is useful in the grammar. */
|
||||
bool rule_useful_in_grammar_p (rule const *r);
|
||||
|
||||
/* Return true IFF the rule has a 'number' higher than NRULES. That is, it is
|
||||
/* Whether the rule has a 'number' higher than NRULES. That is, it is
|
||||
useless in the grammar. */
|
||||
bool rule_useless_in_grammar_p (rule const *r);
|
||||
|
||||
/* Return true IFF the rule is not flagged as useful but is useful in the
|
||||
/* Whether the rule is not flagged as useful but is useful in the
|
||||
grammar. In other words, it was discarded because of conflicts. */
|
||||
bool rule_useless_in_parser_p (rule const *r);
|
||||
|
||||
/* Whether the rule has a single RHS, and no user action. */
|
||||
bool rule_useless_chain_p (rule const *r);
|
||||
|
||||
/* Print this rule's number and lhs on OUT. If a PREVIOUS_LHS was
|
||||
already displayed (by a previous call for another rule), avoid
|
||||
useless repetitions. */
|
||||
@@ -229,12 +244,15 @@ void rule_lhs_print (rule const *r, sym_content const *previous_lhs,
|
||||
FILE *out);
|
||||
void rule_lhs_print_xml (rule const *r, FILE *out, int level);
|
||||
|
||||
/* Return the length of the RHS. */
|
||||
/* The length of the RHS. */
|
||||
size_t rule_rhs_length (rule const *r);
|
||||
|
||||
/* Print this rule's RHS on OUT. */
|
||||
void rule_rhs_print (rule const *r, FILE *out);
|
||||
|
||||
/* Print this rule on OUT. If a PREVIOUS_RULE was already displayed,
|
||||
avoid useless repetitions of their LHS. */
|
||||
void rule_print (rule const *r, rule const *prev_rule, FILE *out);
|
||||
|
||||
|
||||
|
||||
@@ -252,7 +270,7 @@ extern int max_user_token_number;
|
||||
/* Dump RITEM for traces. */
|
||||
void ritem_print (FILE *out);
|
||||
|
||||
/* Return the size of the longest rule RHS. */
|
||||
/* The size of the longest rule RHS. */
|
||||
size_t ritem_longest_rhs (void);
|
||||
|
||||
/* Print the grammar's rules that match FILTER on OUT under TITLE. */
|
||||
|
||||
+3
-5
@@ -159,6 +159,9 @@ output_red (state const *s, reductions const *reds, FILE *fout)
|
||||
bitset no_reduce_set;
|
||||
no_reduce_bitset_init (s, &no_reduce_set);
|
||||
|
||||
rule *default_reduction
|
||||
= yydefact[s->number] ? &rules[yydefact[s->number] - 1] : NULL;
|
||||
|
||||
/* Two obstacks are needed: one for the enabled reductions, and one
|
||||
for the disabled reductions, because in the end we want two
|
||||
separate edges, even though in most cases only one will actually
|
||||
@@ -171,11 +174,6 @@ output_red (state const *s, reductions const *reds, FILE *fout)
|
||||
const int source = s->number;
|
||||
for (int j = 0; j < reds->num; ++j)
|
||||
{
|
||||
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
|
||||
|
||||
+63
-39
@@ -36,7 +36,36 @@
|
||||
#include "symtab.h"
|
||||
|
||||
/** Records the value of the \%define variable lr.type. */
|
||||
typedef enum { LR_TYPE__LALR, LR_TYPE__IELR, LR_TYPE__CANONICAL_LR } LrType;
|
||||
typedef enum
|
||||
{
|
||||
LR_TYPE__LR0,
|
||||
LR_TYPE__LALR,
|
||||
LR_TYPE__IELR,
|
||||
LR_TYPE__CANONICAL_LR
|
||||
} LrType;
|
||||
|
||||
/* The user's requested LR type. */
|
||||
static LrType
|
||||
lr_type_get (void)
|
||||
{
|
||||
char *type = muscle_percent_define_get ("lr.type");
|
||||
LrType res;
|
||||
if (STREQ (type, "lr""(0)"))
|
||||
res = LR_TYPE__LR0;
|
||||
else if (STREQ (type, "lalr"))
|
||||
res = LR_TYPE__LALR;
|
||||
else if (STREQ (type, "ielr"))
|
||||
res = LR_TYPE__IELR;
|
||||
else if (STREQ (type, "canonical-lr"))
|
||||
res = LR_TYPE__CANONICAL_LR;
|
||||
else
|
||||
{
|
||||
aver (false);
|
||||
abort ();
|
||||
}
|
||||
free (type);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* \post:
|
||||
@@ -49,7 +78,7 @@ static bitset
|
||||
ielr_compute_ritem_sees_lookahead_set (void)
|
||||
{
|
||||
bitset result = bitset_create (nritems, BITSET_FIXED);
|
||||
unsigned i = nritems-1;
|
||||
int i = nritems-1;
|
||||
while (0 < i)
|
||||
{
|
||||
--i;
|
||||
@@ -167,10 +196,7 @@ ielr_compute_internal_follow_edges (bitset ritem_sees_lookahead_set,
|
||||
relation_transpose (edgesp, ngotos);
|
||||
|
||||
if (trace_flag & trace_ielr)
|
||||
{
|
||||
fprintf (stderr, "internal_follow_edges:\n");
|
||||
relation_print (*edgesp, ngotos, stderr);
|
||||
}
|
||||
relation_print ("internal_follow_edges", *edgesp, ngotos, NULL, stderr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +241,7 @@ ielr_compute_follow_kernel_items (bitset ritem_sees_lookahead_set,
|
||||
&& bitset_test (ritem_sees_lookahead_set, items[j]))
|
||||
bitset_set ((*follow_kernel_itemsp)[i], j);
|
||||
}
|
||||
relation_digraph (internal_follow_edges, ngotos, follow_kernel_itemsp);
|
||||
relation_digraph (internal_follow_edges, ngotos, *follow_kernel_itemsp);
|
||||
|
||||
if (trace_flag & trace_ielr)
|
||||
{
|
||||
@@ -271,12 +297,11 @@ ielr_compute_always_follows (goto_number ***edgesp,
|
||||
}
|
||||
free (edge_array);
|
||||
}
|
||||
relation_digraph (*edgesp, ngotos, always_followsp);
|
||||
relation_digraph (*edgesp, ngotos, *always_followsp);
|
||||
|
||||
if (trace_flag & trace_ielr)
|
||||
{
|
||||
fprintf (stderr, "always follow edges:\n");
|
||||
relation_print (*edgesp, ngotos, stderr);
|
||||
relation_print ("always follow edges", *edgesp, ngotos, NULL, stderr);
|
||||
fprintf (stderr, "always_follows:\n");
|
||||
debug_bitsetv (*always_followsp);
|
||||
}
|
||||
@@ -393,7 +418,7 @@ ielr_item_has_lookahead (state *s, symbol_number lhs, size_t item,
|
||||
top-level invocation), go get it. */
|
||||
if (!lhs)
|
||||
{
|
||||
unsigned i;
|
||||
int i;
|
||||
for (i = s->items[item];
|
||||
!item_number_is_rule_number (ritem[i]);
|
||||
++i)
|
||||
@@ -471,7 +496,7 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items,
|
||||
AnnotationIndex *annotation_counts =
|
||||
xnmalloc (nstates, sizeof *annotation_counts);
|
||||
ContributionIndex max_contributions = 0;
|
||||
unsigned total_annotations = 0;
|
||||
int total_annotations = 0;
|
||||
|
||||
*inadequacy_listsp = xnmalloc (nstates, sizeof **inadequacy_listsp);
|
||||
*annotation_listsp = xnmalloc (nstates, sizeof **annotation_listsp);
|
||||
@@ -540,7 +565,7 @@ typedef struct state_list
|
||||
/**
|
||||
* nextIsocore is the next state in a circularly linked-list of all states
|
||||
* with the same core. The one originally computed by generate_states in
|
||||
* LR0.c is lr0Isocore.
|
||||
* lr0.c is lr0Isocore.
|
||||
*/
|
||||
struct state_list *lr0Isocore;
|
||||
struct state_list *nextIsocore;
|
||||
@@ -608,7 +633,7 @@ ielr_compute_lookaheads (bitsetv follow_kernel_items, bitsetv always_follows,
|
||||
{
|
||||
if (item_number_is_rule_number (ritem[t->items[t_item] - 2]))
|
||||
{
|
||||
unsigned rule_item;
|
||||
int rule_item;
|
||||
for (rule_item = t->items[t_item];
|
||||
!item_number_is_rule_number (ritem[rule_item]);
|
||||
++rule_item)
|
||||
@@ -1051,41 +1076,40 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ielr (void)
|
||||
{
|
||||
LrType lr_type;
|
||||
|
||||
/* Examine user options. */
|
||||
{
|
||||
char *type = muscle_percent_define_get ("lr.type");
|
||||
if (STREQ (type, "lalr"))
|
||||
lr_type = LR_TYPE__LALR;
|
||||
else if (STREQ (type, "ielr"))
|
||||
lr_type = LR_TYPE__IELR;
|
||||
else if (STREQ (type, "canonical-lr"))
|
||||
lr_type = LR_TYPE__CANONICAL_LR;
|
||||
else
|
||||
{
|
||||
aver (false);
|
||||
abort ();
|
||||
}
|
||||
free (type);
|
||||
}
|
||||
LrType lr_type = lr_type_get ();
|
||||
|
||||
/* Phase 0: LALR(1). */
|
||||
timevar_push (tv_lalr);
|
||||
if (lr_type == LR_TYPE__CANONICAL_LR)
|
||||
set_goto_map ();
|
||||
else
|
||||
lalr ();
|
||||
if (lr_type == LR_TYPE__LALR)
|
||||
switch (lr_type)
|
||||
{
|
||||
case LR_TYPE__LR0:
|
||||
timevar_push (tv_lalr);
|
||||
set_goto_map ();
|
||||
timevar_pop (tv_lalr);
|
||||
return;
|
||||
|
||||
case LR_TYPE__CANONICAL_LR:
|
||||
timevar_push (tv_lalr);
|
||||
set_goto_map ();
|
||||
timevar_pop (tv_lalr);
|
||||
break;
|
||||
|
||||
case LR_TYPE__LALR:
|
||||
timevar_push (tv_lalr);
|
||||
lalr ();
|
||||
bitsetv_free (goto_follows);
|
||||
timevar_pop (tv_lalr);
|
||||
return;
|
||||
|
||||
case LR_TYPE__IELR:
|
||||
timevar_push (tv_lalr);
|
||||
lalr ();
|
||||
timevar_pop (tv_lalr);
|
||||
break;
|
||||
}
|
||||
timevar_pop (tv_lalr);
|
||||
|
||||
{
|
||||
bitsetv follow_kernel_items;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user