mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 10:15:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
437f6250c5 | ||
|
|
334cb8f222 | ||
|
|
03878edf77 | ||
|
|
cacdfc2f6e | ||
|
|
56c00ed1ea | ||
|
|
513d2f723f | ||
|
|
48429252c1 | ||
|
|
d459a5b8e6 | ||
|
|
9566232422 | ||
|
|
dc654a925c | ||
|
|
76366e8e5c | ||
|
|
31788ed4c7 | ||
|
|
781d2b02de | ||
|
|
8b5fc2143f | ||
|
|
5670677cb6 | ||
|
|
32b9dcecc7 | ||
|
|
ac12b725ea | ||
|
|
e1783bc686 | ||
|
|
c4f143eb96 | ||
|
|
94054924a9 | ||
|
|
c639611002 | ||
|
|
69061fed82 | ||
|
|
3075d96d44 | ||
|
|
7fec997ecf | ||
|
|
7355a35e4b | ||
|
|
e585377e68 | ||
|
|
9cd7bd4d5f | ||
|
|
a108d84f88 | ||
|
|
1e83dd2229 | ||
|
|
d02ca923e2 | ||
|
|
f82f7eb1d8 | ||
|
|
0d472b29ec | ||
|
|
7a21067bb9 | ||
|
|
ed02d34fbc | ||
|
|
8b0b295569 | ||
|
|
59a108c0a6 | ||
|
|
83ebc8bdb6 | ||
|
|
21a7fa8063 | ||
|
|
83463dfbee | ||
|
|
c3c50c0030 | ||
|
|
e85ab7ac9b | ||
|
|
a11463a02f | ||
|
|
8023b3153a | ||
|
|
b23ca37ed2 | ||
|
|
bb5e4b659b | ||
|
|
bc8ec1d7bf | ||
|
|
665c5d688c | ||
|
|
53d379b905 | ||
|
|
aa85bfe3a7 | ||
|
|
5ec9c99662 | ||
|
|
36cae8e752 | ||
|
|
7498ede3ab | ||
|
|
27104acdbe | ||
|
|
7b3368a155 | ||
|
|
ec08b369ec | ||
|
|
05b70f47e8 | ||
|
|
626d2f2dca | ||
|
|
5c797b1627 | ||
|
|
ac692b572a | ||
|
|
2f208ee43a | ||
|
|
013a695add | ||
|
|
54ed577da0 | ||
|
|
4a690d3d19 | ||
|
|
cd1a9f076c | ||
|
|
7a0f681cb8 | ||
|
|
eb0f3e79e0 | ||
|
|
25b7421c40 | ||
|
|
e86adac52d | ||
|
|
5879c8dc5a | ||
|
|
d5d148630a | ||
|
|
b443932991 | ||
|
|
f5a646c390 | ||
|
|
f038f0b12f | ||
|
|
b6b397b7f0 | ||
|
|
2c8fb4d126 | ||
|
|
169fe80c7f | ||
|
|
b7e0d3131d | ||
|
|
a634aad9e6 | ||
|
|
ad326ada91 | ||
|
|
a049509d04 | ||
|
|
7c5e508b39 | ||
|
|
55bf52860e | ||
|
|
8575bd06ae | ||
|
|
7c63cc1f6b | ||
|
|
4a41a8ec51 | ||
|
|
ba469451d8 | ||
|
|
8580b268c3 | ||
|
|
41aaa8374c | ||
|
|
79e79be298 | ||
|
|
ffe2e4aaec | ||
|
|
dad14ec3e4 | ||
|
|
a7ff1c75be | ||
|
|
8c3a7687e4 | ||
|
|
72c488aa62 | ||
|
|
a88f8117b0 | ||
|
|
3551d51dd9 | ||
|
|
38b17c36da | ||
|
|
f9db426de6 | ||
|
|
c927c955c8 |
@@ -1,8 +1,6 @@
|
||||
*.eps
|
||||
*.log
|
||||
*.o
|
||||
*.pdf
|
||||
*.png
|
||||
*.stamp
|
||||
*.trs
|
||||
*~
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
3.2.2
|
||||
3.4.2
|
||||
|
||||
+237
-131
@@ -1,17 +1,74 @@
|
||||
# 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:
|
||||
global:
|
||||
# ICC serial number.
|
||||
secure: ED3w6rzxuE6tVu3oyxha2MoGMRzRQCtinvr9uor1gw9TGKB80esTLx4KyX0xHemUdyQVarFDDQfVS5rf7jSDY8XiWIR6O+2Af9/30gb+8eyngyvACu7E28n+1XHmYWIEHsbvB9mic6C60FBj5sPcDnFWZeyttGL0WooSjYHiw1Egafwqbeu1mD3Aet9OI9VaLQvy0KcWAdVrYWSI9UWLvLM+xPVUjPFko4oS+dTlETzVnmn6JFbZX1OKONtfcvdoDRFBzs3iHm5dQUt/Fz+y/DtKSuvF3zvePHSgF6c8URbEPPjBdh87gkovSLyy+83fVeh4WMkF8b+dGZmikQv6kRsjKJdbQrS8tiMhZlORC5Gfmn4HXNgmapL+paUweakH7UZQHm6d5SZoBgCHNazfqMrywbZsZkGvZTDQIVG1Be7Lhh2BDFbPhPZNDvI9XYiqZP0QSb0BVfeO+AUSRcUPM7TvarxB74jYdfpTBu7sqJP6dSwhcDTEUhHmuLGjzsNm3uTZe8SUw/TGGx5uPTXNsCjJq6ClIOAIYXZTXLbBmIL/NBWCy0MUpD+9zsiknU7vzzq1RfgCCExhvYgosTjBLcX1kKI+eRSU5M44e+xCg4xx0m9WfafbKbhA20FfnWxCFIkZeVpkOOsexJ9zfe0SflVLxkd7vmci5SCBixLVbN0=
|
||||
# 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. ##
|
||||
## ------- ##
|
||||
@@ -19,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"
|
||||
|
||||
@@ -174,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:
|
||||
@@ -187,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
|
||||
@@ -203,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:
|
||||
@@ -234,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:
|
||||
@@ -247,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:
|
||||
@@ -260,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:
|
||||
@@ -273,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,6 +1,293 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.2.90 (2019-01-12) [beta]
|
||||
* Noteworthy changes in release 3.4.90 (2019-10-29) [beta]
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
Lone carriage-return characters (aka \r or ^M) in the grammar files are no
|
||||
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||
particular their locations.
|
||||
|
||||
In C++, line numbers and columns are now represented as 'int' not
|
||||
'unsigned', so that integer overflow on positions is easily checkable via
|
||||
'gcc -fsanitize=undefined' and the like. This affects the API for
|
||||
positions.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||
|
||||
** New features
|
||||
|
||||
*** Lookahead correction in C++
|
||||
|
||||
Contributed by Adrian Vogelsgesang.
|
||||
|
||||
The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
|
||||
%define variable parse.lac.
|
||||
|
||||
*** Variable api.token.raw: Optimized token numbers (all skeletons)
|
||||
|
||||
In the generated parsers, tokens have two numbers: the "external" token
|
||||
number as returned by yylex (which starts at 257), and the "internal"
|
||||
symbol number (which starts at 3). Each time yylex is called, a table
|
||||
lookup maps the external token number to the internal symbol number.
|
||||
|
||||
When the %define variable api.token.raw is set, tokens are assigned their
|
||||
internal number, which saves one table lookup per token, and also saves
|
||||
the generation of the mapping table.
|
||||
|
||||
The gain is typically moderate, but in extreme cases (very simple user
|
||||
actions), a 10% improvement can be observed.
|
||||
|
||||
*** Diagnostics with insertion
|
||||
|
||||
The diagnostics now display suggestion below the underlined source.
|
||||
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 …
|
||||
| ^~~
|
||||
|
||||
*** 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.
|
||||
|
||||
*** 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.
|
||||
|
||||
*** 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).
|
||||
|
||||
* 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
|
||||
|
||||
Bison 3.3 failed to generate parsers for grammars with unused nonterminal
|
||||
symbols.
|
||||
|
||||
* Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
|
||||
|
||||
** Changes
|
||||
|
||||
The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
|
||||
extensions into errors. It now makes them simple warnings (-Wyacc).
|
||||
|
||||
* Noteworthy changes in release 3.3 (2019-01-26) [stable]
|
||||
|
||||
A new mailing list was created, Bison Announce. It is low traffic, and is
|
||||
only about announcing new releases and important messages (e.g., polls
|
||||
about major decisions to make).
|
||||
|
||||
https://lists.gnu.org/mailman/listinfo/bison-announce
|
||||
|
||||
** Backward incompatible changes
|
||||
|
||||
@@ -9,6 +296,11 @@ GNU Bison NEWS
|
||||
|
||||
** Deprecated features
|
||||
|
||||
A new feature, --update (see below) helps adjusting existing grammars to
|
||||
deprecations.
|
||||
|
||||
*** Deprecated directives
|
||||
|
||||
The %error-verbose directive is deprecated in favor of '%define
|
||||
parse.error verbose' since Bison 3.0, but no warning was issued.
|
||||
|
||||
@@ -16,9 +308,19 @@ GNU Bison NEWS
|
||||
api.prefix {xx}' since Bison 3.0, but no warning was issued. These
|
||||
directives are slightly different, you might need to adjust your code.
|
||||
%name-prefix renames only symbols with external linkage, while api.prefix
|
||||
also renames types and macros, including @code{YYDEBUG},
|
||||
@code{YYTOKENTYPE}, @code{yytokentype}, @code{YYSTYPE}, @code{YYLTYPE},
|
||||
etc.
|
||||
also renames types and macros, including YYDEBUG, YYTOKENTYPE,
|
||||
yytokentype, YYSTYPE, YYLTYPE, etc.
|
||||
|
||||
Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix
|
||||
{xx}' will typically have to update YY_DECL from
|
||||
|
||||
#define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
|
||||
to
|
||||
|
||||
#define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc)
|
||||
|
||||
*** Deprecated %define variable names
|
||||
|
||||
The following variables, mostly related to parsers in Java, have been
|
||||
renamed for consistency. Backward compatibility is ensured, but upgrading
|
||||
@@ -35,14 +337,66 @@ GNU Bison NEWS
|
||||
|
||||
** New features
|
||||
|
||||
*** Generation of fix-its for IDEs/Editors
|
||||
|
||||
When given the new option -ffixit (aka -fdiagnostics-parseable-fixits),
|
||||
bison now generates machine readable editing instructions to fix some
|
||||
issues. Currently, this is mostly limited to updating deprecated
|
||||
directives and removing duplicates. For instance:
|
||||
|
||||
$ cat foo.y
|
||||
%error-verbose
|
||||
%define parser_class_name "Parser"
|
||||
%define api.parser.class "Parser"
|
||||
%%
|
||||
exp:;
|
||||
|
||||
See the "fix-it:" lines below:
|
||||
|
||||
$ bison -ffixit foo.y
|
||||
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
|
||||
%error-verbose
|
||||
^~~~~~~~~~~~~~
|
||||
fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose"
|
||||
foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
|
||||
%define parser_class_name "Parser"
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}"
|
||||
foo.y:3.1-33: error: %define variable 'api.parser.class' redefined
|
||||
%define api.parser.class "Parser"
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
foo.y:2.1-34: previous definition
|
||||
%define parser_class_name "Parser"
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
fix-it:"foo.y":{3:1-3:34}:""
|
||||
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||
|
||||
This uses the same output format as GCC and Clang.
|
||||
|
||||
*** Updating grammar files
|
||||
|
||||
Fixes can be applied on the fly. The previous example ends with the
|
||||
suggestion to re-run bison with the option -u/--update, which results in a
|
||||
cleaner grammar file.
|
||||
|
||||
$ bison --update foo.y
|
||||
[...]
|
||||
bison: file 'foo.y' was updated (backup: 'foo.y~')
|
||||
|
||||
$ cat foo.y
|
||||
%define parse.error verbose
|
||||
%define api.parser.class {Parser}
|
||||
%%
|
||||
exp:;
|
||||
|
||||
*** Bison is now relocatable
|
||||
|
||||
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. It is possible to make symlinks to the installed and moved
|
||||
programs, and invoke them through the symlink.
|
||||
sharing. It is possible to make symbolic links to the installed and moved
|
||||
programs, and invoke them through the symbolic link.
|
||||
|
||||
*** %expect and %expect-rr modifiers on individual rules
|
||||
|
||||
@@ -121,7 +475,7 @@ GNU Bison NEWS
|
||||
*** C++: Actual token constructors
|
||||
|
||||
When variants and token constructors are enabled, in addition to the
|
||||
type-safe named token constructors (make_ID, amke_INT, etc.), we now
|
||||
type-safe named token constructors (make_ID, make_INT, etc.), we now
|
||||
generate genuine constructors for symbol_type.
|
||||
|
||||
For instance with these declarations
|
||||
@@ -136,17 +490,18 @@ GNU Bison NEWS
|
||||
symbol_type (int token, const int&);
|
||||
symbol_type (int token);
|
||||
|
||||
which should be used in a Flex-scanner as follows.
|
||||
|
||||
%%
|
||||
[a-z]+ return yy::parser::symbol_type (ID, yytext);
|
||||
[0-9]+ return yy::parser::symbol_type (INT, text_to_int (yytext);
|
||||
":" return yy::parser::symbol_type (’:’);
|
||||
<<EOF>> return yy::parser::symbol_type (0);
|
||||
|
||||
Correct matching between token types and value types is checked via
|
||||
'assert'. For instance, 'symbol_type (ID, 42)' would abort (while
|
||||
'make_ID (42)' would not even compile).
|
||||
'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named
|
||||
constructors are preferable, as they offer better type safety (for
|
||||
instance 'make_ID (42)' would not even compile), but symbol_type
|
||||
constructors may help when token types are discovered at run-time, e.g.,
|
||||
|
||||
[a-z]+ {
|
||||
if (auto i = lookup_keyword (yytext))
|
||||
return yy::parser::symbol_type (i);
|
||||
else
|
||||
return yy::parser::make_ID (yytext);
|
||||
}
|
||||
|
||||
*** C++: Variadic emplace
|
||||
|
||||
@@ -238,7 +593,7 @@ GNU Bison NEWS
|
||||
where TAG denotes a type tag such as ‘<ival>’, ID denotes an identifier
|
||||
such as ‘NUM’, NUMBER a decimal or hexadecimal integer such as ‘300’ or
|
||||
‘0x12d’, CHAR a character literal such as ‘'+'’, and STRING a string
|
||||
literal such as ‘"number"’. The postfix quantifiers are ‘?’ (zero or
|
||||
literal such as ‘"number"’. The post-fix quantifiers are ‘?’ (zero or
|
||||
one), ‘*’ (zero or more) and ‘+’ (one or more).
|
||||
|
||||
* Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
|
||||
@@ -649,10 +1004,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
|
||||
^^
|
||||
|
||||
@@ -3394,11 +3749,15 @@ 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: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG
|
||||
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW
|
||||
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 backend
|
||||
|
||||
Local Variables:
|
||||
ispell-dictionary: "american"
|
||||
mode: outline
|
||||
fill-column: 76
|
||||
End:
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
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.
|
||||
|
||||
Be sure to read README-hacking, which contains all the needed information
|
||||
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:
|
||||
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
|
||||
|
||||
** Relocatability
|
||||
## 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
|
||||
@@ -18,7 +29,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,7 +39,7 @@ 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
|
||||
@@ -37,19 +48,19 @@ provided you have a recent version of Texinfo installed: run "make pdf" or
|
||||
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
|
||||
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
|
||||
mode: markdown
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
@@ -72,5 +83,7 @@ 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
|
||||
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
||||
LocalWords: MERCHANTABILITY
|
||||
|
||||
-->
|
||||
|
||||
+42
-6
@@ -45,8 +45,8 @@ processes tabs in its input.
|
||||
|
||||
* 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
|
||||
|
||||
@@ -133,9 +133,15 @@ Enjoy!
|
||||
|
||||
** 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
|
||||
|
||||
$ git submodule update --recursive --remote
|
||||
|
||||
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
|
||||
|
||||
@@ -189,8 +195,12 @@ update.
|
||||
** make check
|
||||
Use liberally.
|
||||
|
||||
** TESTSUITEFLAGS
|
||||
** 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: tests/update-test. Read it for more information.
|
||||
|
||||
** TESTSUITEFLAGS
|
||||
To run just the testsuite (not the tests related to the examples), run `make
|
||||
check-local`.
|
||||
|
||||
@@ -201,6 +211,10 @@ can be sped up in two ways:
|
||||
Using -j, in a make-like fashion, for example:
|
||||
$ 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
|
||||
@@ -213,6 +227,10 @@ To run a specific set of tests, use -k (for "keyword"). For example:
|
||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||
|
||||
Both can be combined.
|
||||
$ make check-local TESTSUITEFLAGS='-j8 -k c++'
|
||||
|
||||
To rerun the tests that failed:
|
||||
$ make recheck -j5
|
||||
|
||||
** Typical errors
|
||||
If the test suite shows failures such as the following one
|
||||
@@ -282,6 +300,24 @@ 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):
|
||||
|
||||
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.
|
||||
|
||||
-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]
|
||||
@@ -18,6 +19,7 @@ Antonio Silva Correia [email protected]
|
||||
Arnold Robbins [email protected]
|
||||
Art Haas [email protected]
|
||||
Askar Safin [email protected]
|
||||
Balázs Scheidler [email protected]
|
||||
Baron Schwartz [email protected]
|
||||
Ben Pfaff [email protected]
|
||||
Benoit Perrot [email protected]
|
||||
@@ -32,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]
|
||||
@@ -55,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]
|
||||
@@ -64,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]
|
||||
@@ -85,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]
|
||||
@@ -114,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]
|
||||
@@ -126,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]
|
||||
@@ -164,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]
|
||||
@@ -186,8 +203,10 @@ 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]
|
||||
|
||||
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,5 +1,12 @@
|
||||
* Bison 3.4
|
||||
** injection rules
|
||||
* Bison 3.5
|
||||
** 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:
|
||||
|
||||
@@ -41,18 +48,73 @@ 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.
|
||||
** 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.
|
||||
|
||||
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.
|
||||
* Bison 3.6
|
||||
** 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.
|
||||
@@ -72,12 +134,88 @@ $ ./tests/testsuite -l | grep errors | sed q
|
||||
38: input.at:1730 errors
|
||||
|
||||
* Short term
|
||||
** consistency
|
||||
token vs terminal
|
||||
** Stop indentation in diagnostics
|
||||
Before Bison 2.7, we printed "flatly" the dependencies in long diagnostics:
|
||||
|
||||
** yacc.c
|
||||
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
|
||||
than duplicating it.
|
||||
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.
|
||||
|
||||
** 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:
|
||||
|
||||
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);
|
||||
|
||||
We should rewrite this in a more FP way:
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
** consistency
|
||||
token vs terminal, variable vs non terminal.
|
||||
|
||||
** C++
|
||||
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
||||
@@ -85,11 +223,10 @@ itself uses int (for yylen for instance), yet stack is based on size_t.
|
||||
|
||||
Maybe locations should also move to ints.
|
||||
|
||||
** C
|
||||
Introduce state_type rather than spreading yytype_int16 everywhere?
|
||||
|
||||
** glr.c
|
||||
yyspaceLeft should probably be a pointer diff.
|
||||
Paul Eggert already covered most of this. But before publishing these
|
||||
changes, we need to ask our C++ users if they agree with that change, or if
|
||||
we need some migration path. Could be a %define variable, or simply
|
||||
%require "3.5".
|
||||
|
||||
** Graphviz display code thoughts
|
||||
The code for the --graph option is over two files: print_graph, and
|
||||
@@ -110,9 +247,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
|
||||
@@ -169,15 +303,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
|
||||
@@ -247,10 +380,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
|
||||
|
||||
@@ -261,7 +405,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
|
||||
@@ -290,7 +434,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.
|
||||
@@ -308,6 +471,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.
|
||||
|
||||
@@ -334,6 +503,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
|
||||
@@ -353,32 +526,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:
|
||||
@@ -397,7 +546,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?
|
||||
@@ -409,6 +558,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:
|
||||
|
||||
@@ -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
|
||||
|
||||
+23
-24
@@ -17,17 +17,21 @@
|
||||
|
||||
# gnulib modules used by this package.
|
||||
gnulib_modules='
|
||||
argmatch 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
|
||||
javaexec-script ldexpl malloc-gnu
|
||||
mbswidth
|
||||
gettext-h git-version-gen gitlog-to-changelog
|
||||
gpl-3.0 intprops inttypes isnan javacomp-script
|
||||
javaexec-script
|
||||
ldexpl
|
||||
libtextstyle-optional
|
||||
malloc-gnu
|
||||
mbfile mbswidth
|
||||
non-recursive-gnulib-prefix-hack
|
||||
obstack
|
||||
obstack-printf
|
||||
@@ -36,14 +40,19 @@ gnulib_modules='
|
||||
readme-release
|
||||
realloc-posix
|
||||
relocatable-prog relocatable-script
|
||||
rename
|
||||
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
||||
timevar
|
||||
unistd unistd-safer unlink unlocked-io
|
||||
update-copyright unsetenv verify
|
||||
warnings
|
||||
winsz-ioctl
|
||||
winsz-termios
|
||||
xalloc
|
||||
xalloc-die
|
||||
xconcat-filename
|
||||
xhash
|
||||
xlist
|
||||
xmemdup0
|
||||
xstrndup
|
||||
|
||||
@@ -63,24 +72,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()
|
||||
{
|
||||
@@ -98,6 +90,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
|
||||
|
||||
+17
-11
@@ -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]]),
|
||||
@@ -48,7 +47,11 @@ while (<STDIN>)
|
||||
# are strings and have the same syntax as on the command line.
|
||||
if ($dir_arg eq 'name[=value]')
|
||||
{
|
||||
$dir_arg = '@var{name} ["@var{value}"]';
|
||||
# -D/-F do not add quotes to the argument.
|
||||
$dir_arg =
|
||||
$dir eq "%define"
|
||||
? '@var{name} [@var{value}]'
|
||||
: '@var{name} ["@var{value}"]';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -68,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
+94
@@ -0,0 +1,94 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# usage:
|
||||
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
|
||||
|
||||
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,10 +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$$ \
|
||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||
program_name=^lib/main.c$$ \
|
||||
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||
@@ -168,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/ \
|
||||
|
||||
+31
-11
@@ -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,11 +97,17 @@ 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 -Wnull-dereference -Wpointer-arith -Wwrite-strings'
|
||||
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
||||
warn_cxx='-Wnoexcept'
|
||||
-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'
|
||||
# Warnings for the test suite only.
|
||||
#
|
||||
# -fno-color-diagnostics: Clang's use of colors in the error
|
||||
@@ -110,6 +119,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'
|
||||
|
||||
@@ -190,6 +200,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.
|
||||
@@ -208,10 +219,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
|
||||
@@ -221,9 +233,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])
|
||||
@@ -240,14 +249,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])
|
||||
@@ -292,4 +301,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
|
||||
|
||||
@@ -75,48 +75,76 @@ skeletons.
|
||||
|
||||
## Symbols
|
||||
|
||||
### `b4_symbol(NUM, FIELD)`
|
||||
In order to unify the handling of the various aspects of symbols (tag, type
|
||||
name, whether terminal, etc.), bison.exe defines one macro per (token,
|
||||
field), where field can `has_id`, `id`, etc.: see
|
||||
src/output.c:prepare_symbols_definitions().
|
||||
`prepare_symbols_definitions()` in `src/output.c`.
|
||||
|
||||
The various FIELDS are:
|
||||
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||
|
||||
- `has_id`: 0 or 1.
|
||||
|
||||
- has_id: 0 or 1.
|
||||
Whether the symbol has an id.
|
||||
- id: string
|
||||
If has_id, the id. Guaranteed to be usable as a C identifier.
|
||||
Prefixed by api.token.prefix if defined.
|
||||
- tag: string.
|
||||
|
||||
- `id`: string
|
||||
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
|
||||
defined as empty. Guaranteed to be usable as a C identifier.
|
||||
|
||||
- `tag`: string.
|
||||
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||
- user_number: integer
|
||||
|
||||
- `user_number`: integer
|
||||
The external number as used by yylex. Can be ASCII code when a character,
|
||||
some number chosen by bison, or some user number in the case of
|
||||
%token FOO <NUM>. Corresponds to yychar in yacc.c.
|
||||
- is_token: 0 or 1
|
||||
|
||||
- `is_token`: 0 or 1
|
||||
Whether this is a terminal symbol.
|
||||
- number: integer
|
||||
|
||||
- `number`: integer
|
||||
The internal number (computed from the external number by yytranslate).
|
||||
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
||||
key in b4_symbol(NUM, FIELD).
|
||||
- has_type: 0, 1
|
||||
|
||||
In bison, symbols are first assigned increasing numbers in order of
|
||||
appearance (but tokens first, then nterms). After grammar reduction,
|
||||
unused nterms are then renumbered to appear last (i.e., first tokens, then
|
||||
used nterms and finally unused nterms). This final number NUM is the one
|
||||
contained in this field, and it is the one used as key in `b4_symbol(NUM,
|
||||
FIELD)`.
|
||||
|
||||
The code of the rule actions, however, is emitted before we know what
|
||||
symbols are unused, so they use the original numbers. To avoid confusion,
|
||||
they actually use "orig NUM" instead of just "NUM". bison also emits
|
||||
definitions for `b4_symbol(orig NUM, number)` that map from original
|
||||
numbers to the new ones. `b4_symbol` actually resolves `orig NUM` in the
|
||||
other case, i.e., `b4_symbol(orig 42, tag)` would return the tag of the
|
||||
symbols whose original number was 42.
|
||||
|
||||
- `has_type`: 0, 1
|
||||
Whether has a semantic value.
|
||||
- type_tag: string
|
||||
|
||||
- `type_tag`: string
|
||||
When api.value.type=union, the generated name for the union member.
|
||||
yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
|
||||
- type
|
||||
|
||||
- `type`
|
||||
If it has a semantic value, its type tag, or, if variant are used,
|
||||
its type.
|
||||
In the case of api.value.type=union, type is the real type (e.g. int).
|
||||
- has_printer: 0, 1
|
||||
- printer: string
|
||||
- printer_file: string
|
||||
- printer_line: integer
|
||||
|
||||
- `has_printer`: 0, 1
|
||||
- `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])
|
||||
### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])`
|
||||
Expansion of $$, $1, $<TYPE-TAG>3, etc.
|
||||
|
||||
The semantic value from a given VAL.
|
||||
@@ -127,14 +155,14 @@ The semantic value from a given VAL.
|
||||
The result can be used safely, it is put in parens to avoid nasty precedence
|
||||
issues.
|
||||
|
||||
### b4_lhs_value(SYMBOL-NUM, [TYPE])
|
||||
### `b4_lhs_value(SYMBOL-NUM, [TYPE])`
|
||||
Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`.
|
||||
|
||||
### b4_rhs_data(RULE-LENGTH, POS)
|
||||
### `b4_rhs_data(RULE-LENGTH, POS)`
|
||||
The data corresponding to the symbol `#POS`, where the current rule has
|
||||
`RULE-LENGTH` symbols on RHS.
|
||||
|
||||
### b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||
### `b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])`
|
||||
Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols
|
||||
on RHS.
|
||||
|
||||
@@ -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 = \
|
||||
|
||||
+48
-27
@@ -389,17 +389,28 @@ m4_define([b4_glr_cc_if],
|
||||
#
|
||||
# The following macros provide access to symbol related values.
|
||||
|
||||
# _b4_symbol(NUM, FIELD)
|
||||
# ----------------------
|
||||
# __b4_symbol(NUM, FIELD)
|
||||
# -----------------------
|
||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||
# undefined.
|
||||
m4_define([_b4_symbol],
|
||||
m4_define([__b4_symbol],
|
||||
[m4_indir([b4_symbol($1, $2)])])
|
||||
|
||||
|
||||
# _b4_symbol(NUM, FIELD)
|
||||
# ----------------------
|
||||
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||
# undefined.
|
||||
m4_define([_b4_symbol],
|
||||
[m4_ifdef([b4_symbol($1, number)],
|
||||
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
|
||||
[__b4_symbol([$1], [$2])])])
|
||||
|
||||
|
||||
|
||||
# b4_symbol(NUM, FIELD)
|
||||
# ---------------------
|
||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||
# undefined. If FIELD = id, prepend the token prefix.
|
||||
m4_define([b4_symbol],
|
||||
[m4_case([$2],
|
||||
@@ -427,13 +438,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.
|
||||
@@ -444,9 +448,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
|
||||
@@ -480,7 +484,9 @@ m4_popdef([b4_actions_])dnl
|
||||
|
||||
# _b4_symbol_case(SYMBOL-NUM)
|
||||
# ---------------------------
|
||||
# Issue a "case NUM" for SYMBOL-NUM.
|
||||
# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it
|
||||
# easier to use with m4_map, but then, use []dnl to suppress the last
|
||||
# one.
|
||||
m4_define([_b4_symbol_case],
|
||||
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
||||
])
|
||||
@@ -529,7 +535,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]]))]))])])
|
||||
|
||||
|
||||
## ------- ##
|
||||
@@ -573,12 +579,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)
|
||||
@@ -590,7 +599,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)
|
||||
@@ -740,8 +759,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
|
||||
@@ -957,8 +978,7 @@ 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_user_code([m4_indir(b4_macro_name)])])dnl
|
||||
m4_popdef([b4_macro_name])])
|
||||
|
||||
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
||||
@@ -982,6 +1002,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])
|
||||
@@ -1058,10 +1079,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.
|
||||
|
||||
+48
-47
@@ -77,11 +77,13 @@ m4_define([b4_cxx_portability],
|
||||
// Support noexcept when possible.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
# define YY_NOEXCEPT noexcept
|
||||
# define YY_NOTHROW
|
||||
#else
|
||||
# define YY_NOEXCEPT
|
||||
#endif[]dnl
|
||||
# define YY_NOTHROW throw ()
|
||||
#endif
|
||||
|
||||
// Support noexcept when possible.
|
||||
// Support constexpr when possible.
|
||||
#if 201703 <= YY_CPLUSPLUS
|
||||
# define YY_CONSTEXPR constexpr
|
||||
#else
|
||||
@@ -145,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])),
|
||||
@@ -192,7 +194,7 @@ m4_define([b4_value_type_declare],
|
||||
[union\|union-directive],
|
||||
[[ union semantic_type
|
||||
{
|
||||
]b4_user_union_members[
|
||||
]b4_user_union_members[
|
||||
};]])])dnl
|
||||
])
|
||||
|
||||
@@ -217,7 +219,14 @@ m4_define([b4_public_types_declare],
|
||||
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
||||
: std::runtime_error (m)]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}]b4_locations_if([
|
||||
{}
|
||||
|
||||
syntax_error (const syntax_error& s)
|
||||
: std::runtime_error (s.what ())]b4_locations_if([
|
||||
, location (s.location)])[
|
||||
{}
|
||||
|
||||
~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([
|
||||
|
||||
location_type location;])[
|
||||
};
|
||||
@@ -260,7 +269,10 @@ m4_define([b4_symbol_type_define],
|
||||
typedef Base super_type;
|
||||
|
||||
/// Default constructor.
|
||||
basic_symbol ();
|
||||
basic_symbol ()
|
||||
: value ()]b4_locations_if([
|
||||
, location ()])[
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
@@ -282,10 +294,29 @@ m4_define([b4_symbol_type_define],
|
||||
YY_RVREF (location_type) l])[);
|
||||
]])[
|
||||
/// Destroy the symbol.
|
||||
~basic_symbol ();
|
||||
~basic_symbol ()
|
||||
{
|
||||
clear ();
|
||||
}
|
||||
|
||||
/// Destroy contents, and record that is empty.
|
||||
void clear ();
|
||||
void clear ()
|
||||
{]b4_variant_if([[
|
||||
// User destructor.
|
||||
symbol_number_type yytype = this->type_get ();
|
||||
basic_symbol<Base>& yysym = *this;
|
||||
(void) yysym;
|
||||
switch (yytype)
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Type destructor.
|
||||
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
/// Whether empty.
|
||||
bool empty () const YY_NOEXCEPT;
|
||||
@@ -352,7 +383,7 @@ m4_define([b4_symbol_type_define],
|
||||
typedef basic_symbol<by_type> super_type;
|
||||
|
||||
/// Empty symbol.
|
||||
symbol_type () {};
|
||||
symbol_type () {}
|
||||
|
||||
/// Constructor for valueless symbols, and symbols from each type.
|
||||
]b4_type_foreach([_b4_token_constructor_define])dnl
|
||||
@@ -365,12 +396,6 @@ m4_define([b4_symbol_type_define],
|
||||
# Provide the implementation needed by the public types.
|
||||
m4_define([b4_public_types_define],
|
||||
[[ // basic_symbol.
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol ()
|
||||
: value ()]b4_locations_if([
|
||||
, location ()])[
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
|
||||
@@ -416,32 +441,6 @@ m4_define([b4_public_types_define],
|
||||
(void) v;
|
||||
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::~basic_symbol ()
|
||||
{
|
||||
clear ();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
void
|
||||
]b4_parser_class[::basic_symbol<Base>::clear ()
|
||||
{]b4_variant_if([[
|
||||
// User destructor.
|
||||
symbol_number_type yytype = this->type_get ();
|
||||
basic_symbol<Base>& yysym = *this;
|
||||
(void) yysym;
|
||||
switch (yytype)
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Type destructor.
|
||||
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
bool
|
||||
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
||||
@@ -517,7 +516,7 @@ m4_define([b4_public_types_define],
|
||||
])
|
||||
|
||||
|
||||
# b4_tolen_constructor_define
|
||||
# b4_token_constructor_define
|
||||
# ----------------------------
|
||||
# Define symbol constructors for all the value types.
|
||||
# Use at class-level. Redefined in variant.hh.
|
||||
@@ -533,7 +532,9 @@ m4_define([b4_yytranslate_define],
|
||||
]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type],
|
||||
[int])[ t)
|
||||
{
|
||||
// YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
]b4_api_token_raw_if(
|
||||
[[ return static_cast<yy::parser::token_number_type> (t);]],
|
||||
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
// TOKEN-NUM as returned by yylex.
|
||||
static
|
||||
const token_number_type
|
||||
@@ -541,15 +542,15 @@ m4_define([b4_yytranslate_define],
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
const unsigned user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
const int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
const token_number_type undef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
if (static_cast<int> (t) <= yyeof_)
|
||||
return yyeof_;
|
||||
else if (static_cast<unsigned> (t) <= user_token_number_max_)
|
||||
else if (static_cast<int> (t) <= user_token_number_max_)
|
||||
return translate_table[t];
|
||||
else
|
||||
return undef_token_;
|
||||
return undef_token_;]])[
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
+125
-44
@@ -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
|
||||
|
||||
@@ -470,7 +544,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 +554,7 @@ m4_define([b4_predicate_case],
|
||||
[ case $1:
|
||||
if (! (
|
||||
$2)) YYERROR;
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;])
|
||||
|
||||
|
||||
@@ -540,8 +614,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 +787,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 +804,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 +819,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])])
|
||||
|
||||
+147
-137
@@ -196,14 +196,14 @@ m4_if(b4_skeleton, ["glr.c"],
|
||||
# glr.cc produces its own header.
|
||||
b4_glr_cc_if([],
|
||||
[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])[
|
||||
]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_output_end
|
||||
])])
|
||||
]b4_cpp_guard_close([b4_spec_header_file])[
|
||||
]b4_output_end[
|
||||
]])])
|
||||
|
||||
|
||||
# ------------------------- #
|
||||
@@ -238,7 +238,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
||||
]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
|
||||
[b4_shared_declarations])[
|
||||
|
||||
/* Enabling verbose error messages. */
|
||||
@@ -259,10 +259,14 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
[#include <stdio.h>
|
||||
[#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
]b4_c99_int_type_define[
|
||||
|
||||
#ifndef YY_
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
# if ENABLE_NLS
|
||||
@@ -285,7 +289,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
# define YYREALLOC realloc
|
||||
#endif
|
||||
|
||||
#define YYSIZEMAX ((size_t) -1)
|
||||
#define YYSIZEMAX (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : (ptrdiff_t) SIZE_MAX)
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef bool yybool;
|
||||
@@ -293,7 +297,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
# define yyfalse false
|
||||
#else
|
||||
/* When we move to stdbool, get rid of the various casts to yybool. */
|
||||
typedef unsigned char yybool;
|
||||
typedef signed char yybool;
|
||||
# define yytrue 1
|
||||
# define yyfalse 0
|
||||
#endif
|
||||
@@ -346,15 +350,17 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
|
||||
/* 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
|
||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||
@@ -373,8 +379,8 @@ static const char *const yytname[] =
|
||||
};
|
||||
#endif
|
||||
|
||||
#define YYPACT_NINF ]b4_pact_ninf[
|
||||
#define YYTABLE_NINF ]b4_table_ninf[
|
||||
#define YYPACT_NINF (]b4_pact_ninf[)
|
||||
#define YYTABLE_NINF (]b4_table_ninf[)
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
@@ -488,7 +494,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
||||
int yydebug;
|
||||
|
||||
struct yyGLRStack;
|
||||
static void yypstack (struct yyGLRStack* yystackp, size_t yyk)
|
||||
static void yypstack (struct yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
YY_ATTRIBUTE_UNUSED;
|
||||
static void yypdumpstack (struct yyGLRStack* yystackp)
|
||||
YY_ATTRIBUTE_UNUSED;
|
||||
@@ -572,12 +578,12 @@ yystpcpy (char *yydest, const char *yysrc)
|
||||
backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
||||
null, do not copy; instead, return the length of what the result
|
||||
would have been. */
|
||||
static size_t
|
||||
static ptrdiff_t
|
||||
yytnamerr (char *yyres, const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
size_t yyn = 0;
|
||||
ptrdiff_t yyn = 0;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
@@ -590,7 +596,10 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
/* Fall through. */
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
if (yyres)
|
||||
yyres[yyn] = *yyp;
|
||||
@@ -605,25 +614,25 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
do_not_strip_quotes: ;
|
||||
}
|
||||
|
||||
if (! yyres)
|
||||
return strlen (yystr);
|
||||
|
||||
return (size_t) (yystpcpy (yyres, yystr) - yyres);
|
||||
if (yyres)
|
||||
return yystpcpy (yyres, yystr) - yyres;
|
||||
else
|
||||
return (ptrdiff_t) strlen (yystr);
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* !YYERROR_VERBOSE */
|
||||
|
||||
/** State numbers, as in LALR(1) machine */
|
||||
/** State numbers. */
|
||||
typedef int yyStateNum;
|
||||
|
||||
/** Rule numbers, as in LALR(1) machine */
|
||||
/** Rule numbers. */
|
||||
typedef int yyRuleNum;
|
||||
|
||||
/** Grammar symbol */
|
||||
/** Grammar symbol. */
|
||||
typedef int yySymbol;
|
||||
|
||||
/** Item references, as in LALR(1) machine */
|
||||
/** Item references. */
|
||||
typedef short yyItemNum;
|
||||
|
||||
typedef struct yyGLRState yyGLRState;
|
||||
@@ -643,7 +652,7 @@ struct yyGLRState {
|
||||
/** Preceding state in this stack */
|
||||
yyGLRState* yypred;
|
||||
/** Source position of the last token produced by my symbol */
|
||||
size_t yyposn;
|
||||
ptrdiff_t yyposn;
|
||||
union {
|
||||
/** First in a chain of alternative reductions producing the
|
||||
* nonterminal corresponding to this state, threaded through
|
||||
@@ -663,7 +672,8 @@ struct yyGLRStateSet {
|
||||
* operation, yylookaheadNeeds[0] is not maintained since it would merely
|
||||
* duplicate yychar != YYEMPTY. */
|
||||
yybool* yylookaheadNeeds;
|
||||
size_t yysize, yycapacity;
|
||||
ptrdiff_t yysize;
|
||||
ptrdiff_t yycapacity;
|
||||
};
|
||||
|
||||
struct yySemanticOption {
|
||||
@@ -703,7 +713,7 @@ struct yyGLRStack {
|
||||
YYJMP_BUF yyexception_buffer;
|
||||
yyGLRStackItem* yyitems;
|
||||
yyGLRStackItem* yynextFree;
|
||||
size_t yyspaceLeft;
|
||||
ptrdiff_t yyspaceLeft;
|
||||
yyGLRState* yysplitPoint;
|
||||
yyGLRState* yylastDeleted;
|
||||
yyGLRStateSet yytops;
|
||||
@@ -962,8 +972,8 @@ yylhsNonterm (yyRuleNum yyrule)
|
||||
return yyr1[yyrule];
|
||||
}
|
||||
|
||||
#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])[
|
||||
|
||||
/** True iff LR state YYSTATE has only a default reduction (regardless
|
||||
* of token). */
|
||||
@@ -980,8 +990,8 @@ yydefaultAction (yyStateNum yystate)
|
||||
return yydefact[yystate];
|
||||
}
|
||||
|
||||
#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])[
|
||||
|
||||
/** The action to take in YYSTATE on seeing YYTOKEN.
|
||||
* Result R means
|
||||
@@ -1061,7 +1071,7 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
|
||||
* alternative actions for YYSTATE. Assumes that YYRHS comes from
|
||||
* stack #YYK of *YYSTACKP. */
|
||||
static void
|
||||
yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
||||
yyaddDeferredAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyGLRState* yystate,
|
||||
yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
{
|
||||
yySemanticOption* yynewOption =
|
||||
@@ -1091,17 +1101,22 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
||||
{
|
||||
yyset->yysize = 1;
|
||||
yyset->yycapacity = 16;
|
||||
yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
|
||||
yyset->yystates
|
||||
= (yyGLRState**) YYMALLOC ((size_t) yyset->yycapacity
|
||||
* sizeof yyset->yystates[0]);
|
||||
if (! yyset->yystates)
|
||||
return yyfalse;
|
||||
yyset->yystates[0] = YY_NULLPTR;
|
||||
yyset->yylookaheadNeeds =
|
||||
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
|
||||
yyset->yylookaheadNeeds
|
||||
= (yybool*) YYMALLOC ((size_t) yyset->yycapacity
|
||||
* sizeof yyset->yylookaheadNeeds[0]);
|
||||
if (! yyset->yylookaheadNeeds)
|
||||
{
|
||||
YYFREE (yyset->yystates);
|
||||
return yyfalse;
|
||||
}
|
||||
memset (yyset->yylookaheadNeeds,
|
||||
0, (size_t) yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
|
||||
return yytrue;
|
||||
}
|
||||
|
||||
@@ -1114,13 +1129,14 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
|
||||
/** Initialize *YYSTACKP to a single empty stack, with total maximum
|
||||
* capacity for all stacks of YYSIZE. */
|
||||
static yybool
|
||||
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
||||
yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize)
|
||||
{
|
||||
yystackp->yyerrState = 0;
|
||||
yynerrs = 0;
|
||||
yystackp->yyspaceLeft = yysize;
|
||||
yystackp->yyitems =
|
||||
(yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]);
|
||||
(yyGLRStackItem*) YYMALLOC ((size_t) yysize
|
||||
* sizeof yystackp->yynextFree[0]);
|
||||
if (!yystackp->yyitems)
|
||||
return yyfalse;
|
||||
yystackp->yynextFree = yystackp->yyitems;
|
||||
@@ -1144,15 +1160,16 @@ yyexpandGLRStack (yyGLRStack* yystackp)
|
||||
{
|
||||
yyGLRStackItem* yynewItems;
|
||||
yyGLRStackItem* yyp0, *yyp1;
|
||||
size_t yynewSize;
|
||||
size_t yyn;
|
||||
size_t yysize = (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
ptrdiff_t yynewSize;
|
||||
ptrdiff_t yyn;
|
||||
ptrdiff_t yysize = yystackp->yynextFree - yystackp->yyitems;
|
||||
if (YYMAXDEPTH - YYHEADROOM < yysize)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yynewSize = 2*yysize;
|
||||
if (YYMAXDEPTH < yynewSize)
|
||||
yynewSize = YYMAXDEPTH;
|
||||
yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
|
||||
yynewItems = (yyGLRStackItem*) YYMALLOC ((size_t) yynewSize
|
||||
* sizeof yynewItems[0]);
|
||||
if (! yynewItems)
|
||||
yyMemoryExhausted (yystackp);
|
||||
for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
|
||||
@@ -1216,7 +1233,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
||||
|
||||
/** Invalidate stack #YYK in *YYSTACKP. */
|
||||
static inline void
|
||||
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
||||
yymarkStackDeleted (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
{
|
||||
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
|
||||
@@ -1240,7 +1257,7 @@ yyundeleteLastStack (yyGLRStack* yystackp)
|
||||
static inline void
|
||||
yyremoveDeletes (yyGLRStack* yystackp)
|
||||
{
|
||||
size_t yyi, yyj;
|
||||
ptrdiff_t yyi, yyj;
|
||||
yyi = yyj = 0;
|
||||
while (yyj < yystackp->yytops.yysize)
|
||||
{
|
||||
@@ -1264,8 +1281,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
||||
yystackp->yytops.yylookaheadNeeds[yyi];
|
||||
if (yyj != yyi)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
|
||||
(unsigned long) yyi, (unsigned long) yyj));
|
||||
YYDPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
|
||||
(long) yyi, (long) yyj));
|
||||
}
|
||||
yyj += 1;
|
||||
}
|
||||
@@ -1277,8 +1294,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
||||
* state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
|
||||
* value *YYVALP and source location *YYLOCP. */
|
||||
static inline void
|
||||
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
size_t yyposn,
|
||||
yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
|
||||
ptrdiff_t yyposn,
|
||||
YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
|
||||
{
|
||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||
@@ -1298,8 +1315,8 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
||||
* semantic value of YYRHS under the action for YYRULE. */
|
||||
static inline void
|
||||
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
|
||||
ptrdiff_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
{
|
||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||
YYASSERT (yynewState->yyisState);
|
||||
@@ -1329,15 +1346,14 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
`----------------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
|
||||
yyRuleNum yyrule]b4_user_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
||||
int yylow = 1;])[
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
|
||||
(unsigned long) yyk, yyrule - 1,
|
||||
(unsigned long) yyrline[yyrule]);
|
||||
YYFPRINTF (stderr, "Reducing stack %ld by rule %d (line %d):\n",
|
||||
(long) yyk, yyrule - 1, yyrline[yyrule]);
|
||||
if (! yynormal)
|
||||
yyfillin (yyvsp, 1, -yynrhs);
|
||||
/* The symbols being reduced. */
|
||||
@@ -1363,7 +1379,7 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
* and *YYLOCP to the computed location (if any). Return value is as
|
||||
* for userAction. */
|
||||
static inline YYRESULTTAG
|
||||
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
YYSTYPE* yyvalp]b4_locuser_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);
|
||||
@@ -1374,7 +1390,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
||||
YYASSERT (yyk == 0);
|
||||
yystackp->yynextFree -= yynrhs;
|
||||
yystackp->yyspaceLeft += (size_t) yynrhs;
|
||||
yystackp->yyspaceLeft += yynrhs;
|
||||
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
||||
YY_REDUCE_PRINT ((yytrue, yyrhs, yyk, yyrule]b4_user_args[));
|
||||
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
|
||||
@@ -1382,11 +1398,10 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
}
|
||||
else
|
||||
{
|
||||
int yyi;
|
||||
yyGLRState* yys;
|
||||
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
||||
yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
|
||||
= yystackp->yytops.yystates[yyk];]b4_locations_if([[
|
||||
yyGLRState* yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
|
||||
= yystackp->yytops.yystates[yyk];
|
||||
int yyi;]b4_locations_if([[
|
||||
if (yynrhs == 0)
|
||||
/* Set default location. */
|
||||
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
|
||||
@@ -1415,10 +1430,10 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
* added to the options for the existing state's semantic value.
|
||||
*/
|
||||
static inline YYRESULTTAG
|
||||
yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
yybool yyforceEval]b4_user_formals[)
|
||||
{
|
||||
size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
||||
ptrdiff_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
||||
|
||||
if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR)
|
||||
{
|
||||
@@ -1428,8 +1443,9 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
|
||||
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
|
||||
(unsigned long) yyk, yyrule - 1));
|
||||
YYDPRINTF ((stderr,
|
||||
"Parse on stack %ld rejected by rule %d (line %d).\n",
|
||||
(long) yyk, yyrule - 1, yyrline[yyrule - 1]));
|
||||
}
|
||||
if (yyflag != yyok)
|
||||
return yyflag;
|
||||
@@ -1441,7 +1457,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t yyi;
|
||||
ptrdiff_t yyi;
|
||||
int yyn;
|
||||
yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
|
||||
yyStateNum yynewLRState;
|
||||
@@ -1455,9 +1471,9 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyupdateSplit (yystackp, yys);
|
||||
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
||||
YYDPRINTF ((stderr,
|
||||
"Reduced stack %lu by rule #%d; action deferred. "
|
||||
"Reduced stack %ld by rule %d (line %d); action deferred. "
|
||||
"Now in state %d.\n",
|
||||
(unsigned long) yyk, yyrule - 1, yynewLRState));
|
||||
(long) yyk, yyrule - 1, yyrline[yyrule - 1], yynewLRState));
|
||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
|
||||
{
|
||||
@@ -1469,9 +1485,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
{
|
||||
yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
|
||||
(unsigned long) yyk,
|
||||
(unsigned long) yyi));
|
||||
YYDPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
|
||||
(long) yyk, (long) yyi));
|
||||
return yyok;
|
||||
}
|
||||
yyp = yyp->yypred;
|
||||
@@ -1483,8 +1498,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
return yyok;
|
||||
}
|
||||
|
||||
static size_t
|
||||
yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
static ptrdiff_t
|
||||
yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
{
|
||||
if (yystackp->yysplitPoint == YY_NULLPTR)
|
||||
{
|
||||
@@ -1495,15 +1510,16 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
{
|
||||
yyGLRState** yynewStates = YY_NULLPTR;
|
||||
yybool* yynewLookaheadNeeds;
|
||||
ptrdiff_t state_size = sizeof yynewStates[0];
|
||||
ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
|
||||
|
||||
if (yystackp->yytops.yycapacity
|
||||
> (YYSIZEMAX / (2 * sizeof yynewStates[0])))
|
||||
if (half_max_capacity < yystackp->yytops.yycapacity)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yystackp->yytops.yycapacity *= 2;
|
||||
|
||||
yynewStates =
|
||||
(yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
|
||||
(yystackp->yytops.yycapacity
|
||||
((size_t) yystackp->yytops.yycapacity
|
||||
* sizeof yynewStates[0]));
|
||||
if (yynewStates == YY_NULLPTR)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1511,7 +1527,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
|
||||
yynewLookaheadNeeds =
|
||||
(yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
|
||||
(yystackp->yytops.yycapacity
|
||||
((size_t) yystackp->yytops.yycapacity
|
||||
* sizeof yynewLookaheadNeeds[0]));
|
||||
if (yynewLookaheadNeeds == YY_NULLPTR)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1713,10 +1729,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
|
||||
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
|
||||
yyx->yyrule - 1);
|
||||
else
|
||||
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
|
||||
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
|
||||
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
|
||||
yyx->yyrule - 1, (unsigned long) (yys->yyposn + 1),
|
||||
(unsigned long) yyx->yystate->yyposn);
|
||||
yyx->yyrule - 1, (long) (yys->yyposn + 1),
|
||||
(long) yyx->yystate->yyposn);
|
||||
for (yyi = 1; yyi <= yynrhs; yyi += 1)
|
||||
{
|
||||
if (yystates[yyi]->yyresolved)
|
||||
@@ -1725,10 +1741,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
|
||||
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
|
||||
yytokenName (yystos[yystates[yyi]->yylrState]));
|
||||
else
|
||||
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
|
||||
YYFPRINTF (stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
|
||||
yytokenName (yystos[yystates[yyi]->yylrState]),
|
||||
(unsigned long) (yystates[yyi-1]->yyposn + 1),
|
||||
(unsigned long) yystates[yyi]->yyposn);
|
||||
(long) (yystates[yyi-1]->yyposn + 1),
|
||||
(long) yystates[yyi]->yyposn);
|
||||
}
|
||||
else
|
||||
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
|
||||
@@ -1923,9 +1939,9 @@ yycompressStack (yyGLRStack* yystackp)
|
||||
yyr = yyp, yyp = yyq, yyq = yyp->yypred)
|
||||
yyp->yypred = yyr;
|
||||
|
||||
yystackp->yyspaceLeft += (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
|
||||
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
|
||||
yystackp->yyspaceLeft -= (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
|
||||
yystackp->yysplitPoint = YY_NULLPTR;
|
||||
yystackp->yylastDeleted = YY_NULLPTR;
|
||||
|
||||
@@ -1941,14 +1957,13 @@ yycompressStack (yyGLRStack* yystackp)
|
||||
}
|
||||
|
||||
static YYRESULTTAG
|
||||
yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
size_t yyposn]b4_pure_formals[)
|
||||
yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
|
||||
ptrdiff_t yyposn]b4_pure_formals[)
|
||||
{
|
||||
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
{
|
||||
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
|
||||
YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
|
||||
(unsigned long) yyk, yystate));
|
||||
YYDPRINTF ((stderr, "Stack %ld Entering state %d\n", yyk, yystate));
|
||||
|
||||
YYASSERT (yystate != YYFINAL);
|
||||
|
||||
@@ -1958,8 +1973,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
yyRuleNum yyrule = yydefaultAction (yystate);
|
||||
if (yyrule == 0)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||
(unsigned long) yyk));
|
||||
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
return yyok;
|
||||
}
|
||||
@@ -1967,9 +1981,9 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
if (yyflag == yyerr)
|
||||
{
|
||||
YYDPRINTF ((stderr,
|
||||
"Stack %lu dies "
|
||||
"Stack %ld dies "
|
||||
"(predicate failure or explicit user error).\n",
|
||||
(unsigned long) yyk));
|
||||
(long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
return yyok;
|
||||
}
|
||||
@@ -1978,21 +1992,17 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
}
|
||||
else
|
||||
{
|
||||
yySymbol yytoken;
|
||||
int yyaction;
|
||||
yySymbol yytoken = ]b4_yygetToken_call[;
|
||||
const short* yyconflicts;
|
||||
|
||||
const int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
|
||||
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
||||
yytoken = ]b4_yygetToken_call[;
|
||||
yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
|
||||
|
||||
while (*yyconflicts != 0)
|
||||
{
|
||||
YYRESULTTAG yyflag;
|
||||
size_t yynewStack = yysplitStack (yystackp, yyk);
|
||||
YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
|
||||
(unsigned long) yynewStack,
|
||||
(unsigned long) yyk));
|
||||
ptrdiff_t yynewStack = yysplitStack (yystackp, yyk);
|
||||
YYDPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
|
||||
(long) yynewStack, (long) yyk));
|
||||
yyflag = yyglrReduce (yystackp, yynewStack,
|
||||
*yyconflicts,
|
||||
yyimmediate[*yyconflicts]]b4_user_args[);
|
||||
@@ -2001,8 +2011,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
yyposn]b4_pure_args[));
|
||||
else if (yyflag == yyerr)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||
(unsigned long) yynewStack));
|
||||
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yynewStack));
|
||||
yymarkStackDeleted (yystackp, yynewStack);
|
||||
}
|
||||
else
|
||||
@@ -2014,8 +2023,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
break;
|
||||
else if (yyisErrorAction (yyaction))
|
||||
{
|
||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||
(unsigned long) yyk));
|
||||
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
break;
|
||||
}
|
||||
@@ -2026,9 +2034,9 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
if (yyflag == yyerr)
|
||||
{
|
||||
YYDPRINTF ((stderr,
|
||||
"Stack %lu dies "
|
||||
"Stack %ld dies "
|
||||
"(predicate failure or explicit user error).\n",
|
||||
(unsigned long) yyk));
|
||||
(long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
break;
|
||||
}
|
||||
@@ -2050,8 +2058,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
#else
|
||||
{
|
||||
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
|
||||
size_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
|
||||
size_t yysize = yysize0;
|
||||
ptrdiff_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
|
||||
ptrdiff_t yysize = yysize0;
|
||||
yybool yysize_overflow = yyfalse;
|
||||
char* yymsg = YY_NULLPTR;
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
@@ -2112,10 +2120,11 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
}
|
||||
yyarg[yycount++] = yytokenName (yyx);
|
||||
{
|
||||
size_t yysz = yysize + yytnamerr (YY_NULLPTR, yytokenName (yyx));
|
||||
if (yysz < yysize)
|
||||
ptrdiff_t yysz = yytnamerr (YY_NULLPTR, yytokenName (yyx));
|
||||
if (YYSIZEMAX - yysize < yysz)
|
||||
yysize_overflow = yytrue;
|
||||
yysize = yysz;
|
||||
else
|
||||
yysize += yysz;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2138,14 +2147,15 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
}
|
||||
|
||||
{
|
||||
size_t yysz = yysize + strlen (yyformat);
|
||||
if (yysz < yysize)
|
||||
ptrdiff_t yysz = (ptrdiff_t) strlen (yyformat);
|
||||
if (YYSIZEMAX - yysize < yysz)
|
||||
yysize_overflow = yytrue;
|
||||
yysize = yysz;
|
||||
else
|
||||
yysize += yysz;
|
||||
}
|
||||
|
||||
if (!yysize_overflow)
|
||||
yymsg = (char *) YYMALLOC (yysize);
|
||||
yymsg = (char *) YYMALLOC ((size_t) yysize);
|
||||
|
||||
if (yymsg)
|
||||
{
|
||||
@@ -2222,7 +2232,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
|
||||
/* Reduce to one stack. */
|
||||
{
|
||||
size_t yyk;
|
||||
ptrdiff_t yyk;
|
||||
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
|
||||
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
break;
|
||||
@@ -2246,14 +2256,15 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
|
||||
&& yyisShiftAction (yytable[yyj]))
|
||||
{
|
||||
/* Shift the error token. */]b4_locations_if([[
|
||||
/* Shift the error token. */
|
||||
int yyaction = yytable[yyj];]b4_locations_if([[
|
||||
/* First adjust its location.*/
|
||||
YYLTYPE yyerrloc;
|
||||
yystackp->yyerror_range[2].yystate.yyloc = yylloc;
|
||||
YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[
|
||||
YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
|
||||
YY_SYMBOL_PRINT ("Shifting", yystos[yyaction],
|
||||
&yylval, &yyerrloc);
|
||||
yyglrShift (yystackp, 0, yytable[yyj],
|
||||
yyglrShift (yystackp, 0, yyaction,
|
||||
yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[);
|
||||
yys = yystackp->yytops.yystates[0];
|
||||
break;
|
||||
@@ -2295,7 +2306,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
int yyresult;
|
||||
yyGLRStack yystack;
|
||||
yyGLRStack* const yystackp = &yystack;
|
||||
size_t yyposn;
|
||||
ptrdiff_t yyposn;
|
||||
|
||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||
|
||||
@@ -2375,7 +2386,7 @@ b4_dollar_popdef])[]dnl
|
||||
while (yytrue)
|
||||
{
|
||||
yySymbol yytoken_to_shift;
|
||||
size_t yys;
|
||||
ptrdiff_t yys;
|
||||
|
||||
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
||||
yystackp->yytops.yylookaheadNeeds[yys] = (yybool) (yychar != YYEMPTY);
|
||||
@@ -2429,12 +2440,12 @@ b4_dollar_popdef])[]dnl
|
||||
int yyaction = yygetLRActions (yystate, yytoken_to_shift,
|
||||
&yyconflicts);
|
||||
/* Note that yyconflicts were handled by yyprocessOneStack. */
|
||||
YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long) yys));
|
||||
YYDPRINTF ((stderr, "On stack %ld, ", (long) yys));
|
||||
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
|
||||
yyglrShift (&yystack, yys, yyaction, yyposn,
|
||||
&yylval]b4_locations_if([, &yylloc])[);
|
||||
YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
|
||||
(unsigned long) yys,
|
||||
YYDPRINTF ((stderr, "Stack %ld now in state #%d\n",
|
||||
(long) yys,
|
||||
yystack.yytops.yystates[yys]->yylrState));
|
||||
}
|
||||
|
||||
@@ -2482,8 +2493,8 @@ b4_dollar_popdef])[]dnl
|
||||
yyGLRState** yystates = yystack.yytops.yystates;
|
||||
if (yystates)
|
||||
{
|
||||
size_t yysize = yystack.yytops.yysize;
|
||||
size_t yyk;
|
||||
ptrdiff_t yysize = yystack.yytops.yysize;
|
||||
ptrdiff_t yyk;
|
||||
for (yyk = 0; yyk < yysize; yyk += 1)
|
||||
if (yystates[yyk])
|
||||
{
|
||||
@@ -2516,8 +2527,7 @@ yy_yypstack (yyGLRState* yys)
|
||||
yy_yypstack (yys->yypred);
|
||||
YYFPRINTF (stderr, " -> ");
|
||||
}
|
||||
YYFPRINTF (stderr, "%d@@%lu", yys->yylrState,
|
||||
(unsigned long) yys->yyposn);
|
||||
YYFPRINTF (stderr, "%d@@%ld", yys->yylrState, (long) yys->yyposn);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2531,7 +2541,7 @@ yypstates (yyGLRState* yyst)
|
||||
}
|
||||
|
||||
static void
|
||||
yypstack (yyGLRStack* yystackp, size_t yyk)
|
||||
yypstack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
{
|
||||
yypstates (yystackp->yytops.yystates[yyk]);
|
||||
}
|
||||
@@ -2544,18 +2554,18 @@ static void
|
||||
yypdumpstack (yyGLRStack* yystackp)
|
||||
{
|
||||
yyGLRStackItem* yyp;
|
||||
size_t yyi;
|
||||
ptrdiff_t yyi;
|
||||
for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
|
||||
{
|
||||
YYFPRINTF (stderr, "%3lu. ",
|
||||
(unsigned long) (yyp - yystackp->yyitems));
|
||||
YYFPRINTF (stderr, "%3ld. ",
|
||||
(long) (yyp - yystackp->yyitems));
|
||||
if (*(yybool *) yyp)
|
||||
{
|
||||
YYASSERT (yyp->yystate.yyisState);
|
||||
YYASSERT (yyp->yyoption.yyisState);
|
||||
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
|
||||
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
|
||||
yyp->yystate.yyresolved, yyp->yystate.yylrState,
|
||||
(unsigned long) yyp->yystate.yyposn,
|
||||
(long) yyp->yystate.yyposn,
|
||||
(long) YYINDEX (yyp->yystate.yypred));
|
||||
if (! yyp->yystate.yyresolved)
|
||||
YYFPRINTF (stderr, ", firstVal: %ld",
|
||||
@@ -2575,7 +2585,7 @@ yypdumpstack (yyGLRStack* yystackp)
|
||||
}
|
||||
YYFPRINTF (stderr, "Tops:");
|
||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||
YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long) yyi,
|
||||
YYFPRINTF (stderr, "%ld: %ld; ", (long) yyi,
|
||||
(long) YYINDEX (yystackp->yytops.yystates[yyi]));
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
|
||||
+16
-9
@@ -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. |
|
||||
`------------------*/
|
||||
@@ -160,6 +160,9 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
]b4_parser_class::~b4_parser_class[ ()
|
||||
{}
|
||||
|
||||
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||
{}
|
||||
|
||||
int
|
||||
]b4_parser_class[::operator() ()
|
||||
{
|
||||
@@ -231,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
|
||||
])
|
||||
|
||||
|
||||
@@ -246,9 +249,12 @@ b4_percent_code_get([[requires]])[
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
]m4_ifdef([b4_location_file],
|
||||
]b4_cxx_portability[
|
||||
]m4_ifdef([b4_location_include],
|
||||
[[# include ]b4_location_include])[
|
||||
]b4_variant_if([b4_variant_includes])[
|
||||
|
||||
]b4_attribute_define[
|
||||
]b4_null_define[
|
||||
|
||||
// Whether we are compiled with exception support.
|
||||
@@ -263,6 +269,7 @@ b4_percent_code_get([[requires]])[
|
||||
]b4_YYDEBUG_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
|
||||
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||
[b4_location_define])])[
|
||||
|
||||
@@ -344,15 +351,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]])])
|
||||
|
||||
+266
-50
@@ -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)
|
||||
@@ -110,10 +118,10 @@ b4_dollar_pushdef([yysym.value],
|
||||
[$1],
|
||||
[],
|
||||
[yysym.location])dnl
|
||||
_b4_symbol_case([$1])
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||
_b4_symbol_case([$1])[]dnl
|
||||
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
|
||||
@@ -220,10 +228,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 +253,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
|
||||
@@ -335,6 +354,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 +367,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
|
||||
@@ -399,22 +431,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 +460,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 +491,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
|
||||
|
||||
@@ -532,7 +561,10 @@ m4_if(b4_prefix, [yy], [],
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
// Fall through.
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
yyr += *yyp;
|
||||
break;
|
||||
@@ -548,17 +580,21 @@ 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[ ()
|
||||
{}
|
||||
|
||||
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||
{}
|
||||
|
||||
/*---------------.
|
||||
| Symbol types. |
|
||||
@@ -625,6 +661,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)
|
||||
{
|
||||
@@ -659,10 +706,12 @@ m4_if(b4_prefix, [yy], [],
|
||||
std::ostream& yyoutput = yyo;
|
||||
YYUSE (yyoutput);
|
||||
symbol_number_type yytype = yysym.type_get ();
|
||||
#if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ * 100 + __GNUC_MINOR__ <= 408
|
||||
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
|
||||
// below array bounds".
|
||||
if (yysym.empty ())
|
||||
std::abort ();
|
||||
#endif
|
||||
yyo << (yytype < yyntokens_ ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
|
||||
<< yysym.location << ": "])[;
|
||||
@@ -754,7 +803,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;
|
||||
@@ -770,7 +818,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
|
||||
@@ -794,7 +846,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_)
|
||||
@@ -839,14 +891,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;
|
||||
}
|
||||
@@ -856,7 +915,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;
|
||||
|
||||
|
||||
@@ -896,8 +956,8 @@ b4_dollar_popdef])[]dnl
|
||||
[
|
||||
// Default location.
|
||||
{
|
||||
slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
|
||||
YYLLOC_DEFAULT (yylhs.location, slice, yylen);
|
||||
stack_type::slice range (yystack_, yylen);
|
||||
YYLLOC_DEFAULT (yylhs.location, range, yylen);
|
||||
yyerror_range[1].location = yylhs.location;
|
||||
}]])[
|
||||
|
||||
@@ -1016,8 +1076,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;
|
||||
@@ -1081,8 +1142,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
|
||||
@@ -1091,7 +1291,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.
|
||||
@@ -1111,24 +1311,40 @@ 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];
|
||||
yyarg[yycount++] = yytname_[yytoken];]b4_lac_if([[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
// Execute LAC once. We don't care if it is succesful, we
|
||||
// only do it for the sake of debugging output.
|
||||
if (!yy_lac_established_)
|
||||
yy_lac_check_ (yytoken);
|
||||
#endif]])[
|
||||
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
{]b4_lac_if([[
|
||||
for (int yyx = 0; yyx < yyntokens_; ++yyx)
|
||||
if (yyx != yyterror_ && yy_lac_check_(yyx))
|
||||
{]], [[
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
@@ -1139,7 +1355,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
{]])[
|
||||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
||||
{
|
||||
yycount = 1;
|
||||
@@ -1170,7 +1386,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)
|
||||
{
|
||||
@@ -1211,7 +1427,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';
|
||||
}
|
||||
|
||||
@@ -1219,7 +1435,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
|
||||
|
||||
+178
-168
@@ -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
|
||||
};],
|
||||
@@ -231,9 +188,9 @@ b4_user_union_members
|
||||
]b4_identification[
|
||||
|
||||
/** True if verbose error messages are enabled. */
|
||||
public bool errorVerbose = ]b4_flag_value([error_verbose]);
|
||||
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 +206,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 +263,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 +300,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 +314,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 +328,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 +337,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 +366,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 +386,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 +400,11 @@ 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 +412,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 +434,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 +469,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 +488,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 +500,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 +523,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 +574,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 +598,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,7 +612,7 @@ 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 (;;)
|
||||
{
|
||||
@@ -683,23 +632,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])[);
|
||||
@@ -837,6 +786,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,19 +812,25 @@ 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)
|
||||
{
|
||||
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 ]b4_int_type_for([b4_translate])[[] translate_table =
|
||||
@{
|
||||
]b4_translate[
|
||||
@};
|
||||
|
||||
if (t <= 0)
|
||||
return YYTokenType.EOF;
|
||||
else if (t <= yyuser_token_number_max_)
|
||||
return translate_table[t];
|
||||
else
|
||||
return yyundef_token_;
|
||||
return yyundef_token_;]])[
|
||||
}
|
||||
|
||||
private static immutable int yylast_ = ]b4_last[;
|
||||
@@ -888,10 +844,64 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
private static immutable int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||
private static immutable int yyundef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
]/* User implementation code. */
|
||||
b4_percent_code_get[]dnl
|
||||
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;
|
||||
}
|
||||
]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
|
||||
|
||||
+127
-140
@@ -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,7 +749,7 @@ 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_)
|
||||
@@ -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
|
||||
@@ -953,14 +932,14 @@ b4_both_if([[
|
||||
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]))
|
||||
&& !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]))
|
||||
&& !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_;
|
||||
}
|
||||
@@ -1005,12 +984,13 @@ b4_both_if([[
|
||||
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,23 +1003,30 @@ 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;
|
||||
}
|
||||
]],
|
||||
[[ {
|
||||
if (t <= 0)
|
||||
return Lexer.EOF;
|
||||
else if (t <= yyuser_token_number_max_)
|
||||
return yytranslate_table_[t];
|
||||
else
|
||||
return yyundef_token_;
|
||||
}
|
||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||
]])[
|
||||
|
||||
private static final int yylast_ = ]b4_last[;
|
||||
private static final int yynnts_ = ]b4_nterms_number[;
|
||||
@@ -1052,8 +1039,8 @@ b4_both_if([[
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
||||
+15
-17
@@ -65,8 +65,8 @@ m4_define([b4_location_define],
|
||||
public:]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)
|
||||
int l = ]b4_location_initial_line[,
|
||||
int c = ]b4_location_initial_column[)
|
||||
: filename (f)
|
||||
, line (l)
|
||||
, column (c)
|
||||
@@ -75,8 +75,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)
|
||||
int l = ]b4_location_initial_line[,
|
||||
int c = ]b4_location_initial_column[)
|
||||
{
|
||||
filename = fn;
|
||||
line = l;
|
||||
@@ -90,7 +90,7 @@ m4_define([b4_location_define],
|
||||
{
|
||||
if (count)
|
||||
{
|
||||
column = ]b4_location_initial_column[u;
|
||||
column = ]b4_location_initial_column[;
|
||||
line = add_ (line, count, ]b4_location_initial_line[);
|
||||
}
|
||||
}
|
||||
@@ -105,16 +105,15 @@ m4_define([b4_location_define],
|
||||
/// File name to which this position refers.
|
||||
]b4_percent_define_get([[filename_type]])[* filename;
|
||||
/// Current line number.
|
||||
unsigned line;
|
||||
int line;
|
||||
/// Current column number.
|
||||
unsigned column;
|
||||
int column;
|
||||
|
||||
private:
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
||||
static int add_ (int lhs, int rhs, int min)
|
||||
{
|
||||
return static_cast<unsigned> (std::max (min,
|
||||
static_cast<int> (lhs) + rhs));
|
||||
return lhs + rhs < min ? min : lhs + rhs;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,8 +196,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)
|
||||
int l = ]b4_location_initial_line[,
|
||||
int c = ]b4_location_initial_column[)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{}
|
||||
@@ -206,8 +205,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)
|
||||
int l = ]b4_location_initial_line[,
|
||||
int c = ]b4_location_initial_column[)
|
||||
{
|
||||
begin.initialize (f, l, c);
|
||||
end = begin;
|
||||
@@ -305,7 +304,7 @@ 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;
|
||||
int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
@@ -327,7 +326,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 +345,6 @@ m4_ifdef([b4_location_file], [[
|
||||
|
||||
]b4_cpp_guard_open([b4_location_path])[
|
||||
|
||||
# include <algorithm> // std::max
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
|
||||
+35
-48
@@ -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,15 @@ 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).
|
||||
@@ -122,33 +110,32 @@ m4_define([b4_stack_define],
|
||||
return seq_.rend ();
|
||||
}
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice (const stack& stack, index_type range)
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const stack& stack_;
|
||||
index_type range_;
|
||||
};
|
||||
|
||||
private:
|
||||
stack (const stack&);
|
||||
stack& operator= (const stack&);
|
||||
/// The wrapped container.
|
||||
S seq_;
|
||||
};
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
template <typename T, typename S = stack<T> >
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice (const S& stack, int range)
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (int i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const S& stack_;
|
||||
int range_;
|
||||
};
|
||||
]])
|
||||
|
||||
m4_ifdef([b4_stack_file],
|
||||
@@ -158,7 +145,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[
|
||||
]])
|
||||
|
||||
+234
-210
@@ -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
|
||||
@@ -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,16 @@ typedef short yytype_int16;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
||||
#define YYSIZE_MAXIMUM ((YYPTRDIFF_T) (YYPTRDIFF_MAXIMUM < (YYSIZE_T) -1 \
|
||||
? YYPTRDIFF_MAXIMUM : (YYSIZE_T) -1))
|
||||
|
||||
#define YYSIZEOF(X) ((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 +425,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 +512,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 +541,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 +557,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, (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 +588,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 +626,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 +712,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 +736,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 +804,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 +832,8 @@ 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_state_t *) YYSTACK_ALLOC ((YYSIZE_T)
|
||||
(yyalloc * YYSIZEOF (*yybottom_new)));
|
||||
if (!yybottom_new)
|
||||
{
|
||||
YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
|
||||
@@ -822,8 +850,8 @@ 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));]])[
|
||||
YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
|
||||
(long) yyalloc, yydebug_suffix));]])[
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -908,11 +936,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 +977,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 +997,18 @@ 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;
|
||||
*yyesp = (yy_state_t) yystate;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -994,9 +1021,9 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
YYDPRINTF ((stderr, "\n"));
|
||||
return 2;
|
||||
}
|
||||
*++yyesp = yystate;
|
||||
*++yyesp = (yy_state_t) yystate;
|
||||
}
|
||||
YYDPRINTF ((stderr, " G%d", (int) yystate));
|
||||
YYDPRINTF ((stderr, " G%d", yystate));
|
||||
}
|
||||
}
|
||||
}]])[
|
||||
@@ -1006,13 +1033,13 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
|
||||
# ifndef yystrlen
|
||||
# if defined __GLIBC__ && defined _STRING_H
|
||||
# define yystrlen strlen
|
||||
# define yystrlen(S) ((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 +1075,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 (;;)
|
||||
@@ -1066,7 +1093,10 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
/* Fall through. */
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
if (yyres)
|
||||
yyres[yyn] = *yyp;
|
||||
@@ -1081,10 +1111,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
|
||||
|
||||
@@ -1099,12 +1129,12 @@ 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;
|
||||
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
|
||||
YYPTRDIFF_T yysize = yysize0;
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
/* Internationalized format string. */
|
||||
const char *yyformat = YY_NULLPTR;
|
||||
@@ -1148,15 +1178,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
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)
|
||||
@@ -1169,6 +1192,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
|
||||
@@ -1182,7 +1213,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
|
||||
@@ -1213,7 +1245,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
}
|
||||
|
||||
{
|
||||
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
|
||||
YYPTRDIFF_T yysize1 = yysize + yystrlen (yyformat);
|
||||
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
|
||||
yysize = yysize1;
|
||||
else
|
||||
@@ -1394,7 +1426,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)])[)
|
||||
@@ -1415,7 +1447,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;]])[
|
||||
|
||||
@@ -1447,10 +1479,12 @@ 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);
|
||||
*yyssp = (yy_state_t) yystate;
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
|
||||
@@ -1458,15 +1492,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
|
||||
@@ -1474,9 +1508,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([
|
||||
@@ -1491,9 +1525,10 @@ yysetstate:
|
||||
yystacksize = YYMAXDEPTH;
|
||||
|
||||
{
|
||||
yytype_int16 *yyss1 = yyss;
|
||||
yy_state_t *yyss1 = yyss;
|
||||
union yyalloc *yyptr =
|
||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
||||
(union yyalloc *) YYSTACK_ALLOC ((YYSIZE_T)
|
||||
YYSTACK_BYTES (yystacksize));
|
||||
if (! yyptr)
|
||||
goto yyexhaustedlab;
|
||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||
@@ -1509,16 +1544,14 @@ yysetstate:
|
||||
yyvsp = yyvs + yysize - 1;]b4_locations_if([
|
||||
yylsp = yyls + yysize - 1;])[
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long) yystacksize));
|
||||
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
|
||||
(long) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
}
|
||||
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
|
||||
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
|
||||
if (yystate == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
@@ -1602,16 +1635,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;
|
||||
|
||||
|
||||
@@ -1659,7 +1691,7 @@ yyreduce:
|
||||
}]], [[
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_user_actions[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}]])[
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@@ -1726,7 +1758,7 @@ yyerrlab:
|
||||
{
|
||||
if (yymsg != yymsgbuf)
|
||||
YYSTACK_FREE (yymsg);
|
||||
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
|
||||
yymsg = (char *) YYSTACK_ALLOC ((YYSIZE_T) yymsg_alloc);
|
||||
if (!yymsg)
|
||||
{
|
||||
yymsg = yymsgbuf;
|
||||
@@ -1914,11 +1946,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
|
||||
|
||||
+858
-428
File diff suppressed because it is too large
Load Diff
+18
-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
|
||||
@@ -88,11 +93,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 +125,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 +142,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 +161,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)
|
||||
|
||||
|
||||
## ---------- ##
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SHELL=/bin/sh
|
||||
export SHELL
|
||||
|
||||
me=$(basename "$1" .test)
|
||||
medir=$(dirname "$1" | sed -e 's,.*examples/,,')
|
||||
|
||||
|
||||
+1
-1
Submodule gnulib updated: 315eb5ffc1...56ca994d47
@@ -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
|
||||
+72
-36
@@ -8,16 +8,26 @@
|
||||
/alignof.h
|
||||
/alloca.h
|
||||
/alloca.in.h
|
||||
/allocator.c
|
||||
/allocator.h
|
||||
/areadlink.c
|
||||
/areadlink.h
|
||||
/arg-nonnull.h
|
||||
/argmatch.c
|
||||
/argmatch.h
|
||||
/asnprintf.c
|
||||
/assure.h
|
||||
/basename-lgpl.c
|
||||
/basename.c
|
||||
/binary-io.c
|
||||
/binary-io.h
|
||||
/bitrotate.c
|
||||
/bitrotate.h
|
||||
/bitset.c
|
||||
/bitset.h
|
||||
/bitset/
|
||||
/bitsetv.c
|
||||
/bitsetv.h
|
||||
/c++defs.h
|
||||
/c-ctype.c
|
||||
/c-ctype.h
|
||||
@@ -26,6 +36,10 @@
|
||||
/c-strcaseeq.h
|
||||
/c-strncasecmp.c
|
||||
/calloc.c
|
||||
/canonicalize-lgpl.c
|
||||
/careadlinkat.c
|
||||
/careadlinkat.h
|
||||
/cdefs.h
|
||||
/charset.alias
|
||||
/cloexec.c
|
||||
/cloexec.h
|
||||
@@ -39,6 +53,7 @@
|
||||
/config.h
|
||||
/config.in.h
|
||||
/configmake.h
|
||||
/diffseq.h
|
||||
/dirname-lgpl.c
|
||||
/dirname.c
|
||||
/dirname.h
|
||||
@@ -77,7 +92,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
|
||||
@@ -90,7 +111,16 @@
|
||||
/getopt_int.h
|
||||
/getprogname.c
|
||||
/getprogname.h
|
||||
/getrusage.c
|
||||
/gettext.h
|
||||
/gettime.c
|
||||
/gettimeofday.c
|
||||
/gl_array_list.c
|
||||
/gl_array_list.h
|
||||
/gl_list.c
|
||||
/gl_list.h
|
||||
/gl_xlist.c
|
||||
/gl_xlist.h
|
||||
/gnulib.mk
|
||||
/hard-locale.c
|
||||
/hard-locale.h
|
||||
@@ -106,12 +136,16 @@
|
||||
/isnanf.c
|
||||
/isnanl-nolibm.h
|
||||
/isnanl.c
|
||||
/iswblank.c
|
||||
/itold.c
|
||||
/ldexpl.c
|
||||
/libc-config.h
|
||||
/limits.h
|
||||
/limits.in.h
|
||||
/localcharset.c
|
||||
/localcharset.h
|
||||
/localtime-buffer.c
|
||||
/localtime-buffer.h
|
||||
/lstat.c
|
||||
/malloc.c
|
||||
/malloca.c
|
||||
@@ -119,6 +153,10 @@
|
||||
/math.c
|
||||
/math.h
|
||||
/math.in.h
|
||||
/mbchar.c
|
||||
/mbchar.h
|
||||
/mbfile.c
|
||||
/mbfile.h
|
||||
/mbrtowc.c
|
||||
/mbsinit.c
|
||||
/mbswidth.c
|
||||
@@ -150,17 +188,26 @@
|
||||
/printf.c
|
||||
/progname.c
|
||||
/progname.h
|
||||
/progreloc.c
|
||||
/quote.h
|
||||
/quotearg.c
|
||||
/quotearg.h
|
||||
/raise.c
|
||||
/rawmemchr.c
|
||||
/rawmemchr.valgrind
|
||||
/readlink.c
|
||||
/realloc.c
|
||||
/ref-add.sed
|
||||
/ref-del.sed
|
||||
/relocatable.c
|
||||
/relocatable.h
|
||||
/relocwrapper.c
|
||||
/rename.c
|
||||
/rmdir.c
|
||||
/same-inode.h
|
||||
/sched.h
|
||||
/sched.in.h
|
||||
/setenv.c
|
||||
/sig-handler.c
|
||||
/sig-handler.h
|
||||
/sigaction.c
|
||||
@@ -190,6 +237,8 @@
|
||||
/spawnp.c
|
||||
/sprintf.c
|
||||
/stamp-h1
|
||||
/stat-time.c
|
||||
/stat-time.h
|
||||
/stat-w32.c
|
||||
/stat-w32.h
|
||||
/stat.c
|
||||
@@ -223,13 +272,22 @@
|
||||
/strverscmp.c
|
||||
/sys
|
||||
/sys_ioctl.in.h
|
||||
/sys_resource.in.h
|
||||
/sys_socket.in.h
|
||||
/sys_stat.in.h
|
||||
/sys_time.in.h
|
||||
/sys_times.in.h
|
||||
/sys_types.in.h
|
||||
/sys_wait.in.h
|
||||
/sysexits.in.h
|
||||
/textstyle.h
|
||||
/textstyle.in.h
|
||||
/time.h
|
||||
/time.in.h
|
||||
/timespec.c
|
||||
/timespec.h
|
||||
/timevar.c
|
||||
/timevar.h
|
||||
/unistd--.h
|
||||
/unistd-safer.h
|
||||
/unistd.c
|
||||
@@ -260,52 +318,30 @@
|
||||
/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
|
||||
/xreadlink.c
|
||||
/xreadlink.h
|
||||
/xsize.c
|
||||
/xsize.h
|
||||
/xstrndup.c
|
||||
/xstrndup.h
|
||||
/stat-time.c
|
||||
/stat-time.h
|
||||
/timevar.c
|
||||
/timevar.h
|
||||
/sys_time.in.h
|
||||
/sys_times.in.h
|
||||
/gethrxtime.c
|
||||
/gethrxtime.h
|
||||
/getrusage.c
|
||||
/gettime.c
|
||||
/gettimeofday.c
|
||||
/localtime-buffer.c
|
||||
/localtime-buffer.h
|
||||
/sys_resource.in.h
|
||||
/timespec.c
|
||||
/timespec.h
|
||||
/xtime.c
|
||||
/xtime.h
|
||||
/bitset.c
|
||||
/bitset.h
|
||||
/bitset/
|
||||
/bitsetv.c
|
||||
/bitsetv.h
|
||||
/allocator.c
|
||||
/allocator.h
|
||||
/areadlink.c
|
||||
/areadlink.h
|
||||
/canonicalize-lgpl.c
|
||||
/careadlinkat.c
|
||||
/careadlinkat.h
|
||||
/progreloc.c
|
||||
/readlink.c
|
||||
/relocatable.c
|
||||
/relocatable.h
|
||||
/relocwrapper.c
|
||||
/setenv.c
|
||||
/xreadlink.c
|
||||
/xreadlink.h
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/lock.c
|
||||
/lock.h
|
||||
/threadlib.c
|
||||
/tls.c
|
||||
/tls.h
|
||||
|
||||
+31
-36
@@ -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,23 +37,20 @@
|
||||
/frexpl.m4
|
||||
/fseterr.m4
|
||||
/fstat.m4
|
||||
/fsync.m4
|
||||
/getdtablesize.m4
|
||||
/gethrxtime.m4
|
||||
/getopt.m4
|
||||
/getprogname.m4
|
||||
/gettext.m4
|
||||
/glibc2.m4
|
||||
/glibc21.m4
|
||||
/getrusage.m4
|
||||
/gettime.m4
|
||||
/gettimeofday.m4
|
||||
/gnulib-cache.m4
|
||||
/gnulib-common.m4
|
||||
/gnulib-comp.m4
|
||||
/gnulib-tool.m4
|
||||
/iconv.m4
|
||||
/host-cpu-c-abi.m4
|
||||
/include_next.m4
|
||||
/intdiv0.m4
|
||||
/intl.m4
|
||||
/intldir.m4
|
||||
/intlmacosx.m4
|
||||
/intmax.m4
|
||||
/intmax_t.m4
|
||||
/inttypes-pri.m4
|
||||
/inttypes.m4
|
||||
@@ -61,27 +59,34 @@
|
||||
/isnand.m4
|
||||
/isnanf.m4
|
||||
/isnanl.m4
|
||||
/iswblank.m4
|
||||
/javacomp.m4
|
||||
/javaexec.m4
|
||||
/jm-winsz1.m4
|
||||
/jm-winsz2.m4
|
||||
/largefile.m4
|
||||
/lcmessage.m4
|
||||
/ldexp.m4
|
||||
/ldexpl.m4
|
||||
/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
|
||||
@@ -93,33 +98,36 @@
|
||||
/msvc-inval.m4
|
||||
/msvc-nothrow.m4
|
||||
/multiarch.m4
|
||||
/nls.m4
|
||||
/nocrash.m4
|
||||
/non-recursive-gnulib-prefix-hack.m4
|
||||
/obstack-printf.m4
|
||||
/obstack.m4
|
||||
/off_t.m4
|
||||
/open-cloexec.m4
|
||||
/open-slash.m4
|
||||
/open.m4
|
||||
/pathmax.m4
|
||||
/perror.m4
|
||||
/pipe2.m4
|
||||
/po.m4
|
||||
/posix_spawn.m4
|
||||
/printf-frexp.m4
|
||||
/printf-frexpl.m4
|
||||
/printf-posix-rpl.m4
|
||||
/printf-posix.m4
|
||||
/printf.m4
|
||||
/progtest.m4
|
||||
/pthread_rwlock_rdlock.m4
|
||||
/quote.m4
|
||||
/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 +140,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,20 +158,23 @@
|
||||
/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
|
||||
/uintmax_t.m4
|
||||
/timespec.m4
|
||||
/tls.m4
|
||||
/unistd-safer.m4
|
||||
/unistd_h.m4
|
||||
/unlink.m4
|
||||
/unlocked-io.m4
|
||||
/vasnprintf.m4
|
||||
/vfprintf-posix.m4
|
||||
/visibility.m4
|
||||
/vsnprintf-posix.m4
|
||||
/vsnprintf.m4
|
||||
/vsprintf-posix.m4
|
||||
@@ -177,21 +190,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[
|
||||
%%
|
||||
|
||||
+2
-13
@@ -1,6 +1,7 @@
|
||||
src/complain.c
|
||||
src/conflicts.c
|
||||
src/files.c
|
||||
src/fixits.c
|
||||
src/getargs.c
|
||||
src/gram.c
|
||||
src/graphviz.c
|
||||
@@ -8,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;
|
||||
|
||||
+267
-87
@@ -23,11 +23,14 @@
|
||||
#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"
|
||||
#include "fixits.h"
|
||||
#include "getargs.h"
|
||||
#include "quote.h"
|
||||
|
||||
@@ -60,52 +63,103 @@ 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)") },
|
||||
{ "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 '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
|
||||
{ "none", Wnone },
|
||||
{ "midrule-values", Wmidrule_values },
|
||||
{ "yacc", Wyacc },
|
||||
{ "conflicts-sr", Wconflicts_sr },
|
||||
{ "conflicts-rr", Wconflicts_rr },
|
||||
{ "deprecated", Wdeprecated },
|
||||
{ "empty-rule", Wempty_rule },
|
||||
{ "precedence", Wprecedence },
|
||||
{ "other", Wother },
|
||||
{ "all", Wall },
|
||||
{ "everything", Weverything },
|
||||
{ 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)
|
||||
@@ -144,7 +198,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;
|
||||
@@ -160,8 +221,41 @@ warnings_argmatch (char *args)
|
||||
|
||||
warning_argmatch (args, no, err);
|
||||
}
|
||||
else
|
||||
warning_argmatch ("all", 0, 0);
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
||||
@@ -169,9 +263,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;
|
||||
|
||||
@@ -184,6 +322,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
|
||||
@@ -228,19 +372,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;
|
||||
}
|
||||
}
|
||||
@@ -249,8 +405,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
|
||||
@@ -259,53 +417,61 @@ 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 = 0;
|
||||
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);
|
||||
if (! (flags & silent))
|
||||
/* Print the type of warning, only if this is not a sub message
|
||||
(in which case the prefix is null). */
|
||||
if (! (flags & silent) && sever != severity_disabled)
|
||||
warnings_print_categories (flags, stderr);
|
||||
|
||||
{
|
||||
size_t l = strlen (message);
|
||||
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)
|
||||
@@ -313,13 +479,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)
|
||||
@@ -331,23 +493,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)
|
||||
@@ -385,22 +546,41 @@ 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));
|
||||
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;
|
||||
complain (&second, complaint, _("only one %s allowed per rule"), directive);
|
||||
int i = 0;
|
||||
if (feature_flag & feature_caret)
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive"));
|
||||
else
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive: %s"), quote (directive));
|
||||
i += SUB_INDENT;
|
||||
complain_indent (&first, complaint, &i, _("previous declaration"));
|
||||
complain_indent (&first, Wother, &i, _("previous declaration"));
|
||||
fixits_register (&second, "");
|
||||
}
|
||||
|
||||
void
|
||||
duplicate_rule_directive (char const *directive,
|
||||
location first, location second)
|
||||
{
|
||||
int i = 0;
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("only one %s allowed per rule"), directive);
|
||||
i += SUB_INDENT;
|
||||
complain_indent (&first, complaint, &i,
|
||||
_("previous declaration"));
|
||||
fixits_register (&second, "");
|
||||
}
|
||||
|
||||
+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,14 @@
|
||||
/** The bits assigned to each warning type. */
|
||||
typedef enum
|
||||
{
|
||||
warning_midrule_values, /**< Unset or unused midrule values. */
|
||||
warning_conflicts_rr,
|
||||
warning_conflicts_sr,
|
||||
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 +60,8 @@ typedef enum
|
||||
/** Whether -Werror was set. */
|
||||
extern bool warnings_are_errors;
|
||||
|
||||
void warning_usage (FILE *out);
|
||||
|
||||
/** Decode a single argument from -W.
|
||||
*
|
||||
* \param arg the subarguments to decode.
|
||||
@@ -76,20 +92,24 @@ 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);
|
||||
|
||||
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,
|
||||
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. */
|
||||
@@ -105,16 +125,19 @@ typedef enum
|
||||
(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)));
|
||||
|
||||
@@ -126,10 +149,14 @@ void bison_directive (location const *loc, char const *directive);
|
||||
void deprecated_directive (location const *loc,
|
||||
char const *obsolete, char const *updated);
|
||||
|
||||
/** Report a repeated directive for a rule. */
|
||||
/** Report a repeated directive. */
|
||||
void duplicate_directive (char const *directive,
|
||||
location first, location second);
|
||||
|
||||
/** Report a repeated directive for a rule. */
|
||||
void duplicate_rule_directive (char const *directive,
|
||||
location first, location second);
|
||||
|
||||
/** Warnings treated as errors shouldn't stop the execution as regular
|
||||
errors should (because due to their nature, it is safe to go
|
||||
on). Thus, there are three possible execution statuses. */
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
|
||||
+48
-37
@@ -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>
|
||||
|
||||
@@ -43,11 +45,13 @@
|
||||
|
||||
char const *spec_outfile = NULL; /* for -o. */
|
||||
char const *spec_file_prefix = NULL; /* for -b. */
|
||||
location spec_file_prefix_loc = EMPTY_LOCATION_INIT;
|
||||
char const *spec_name_prefix = NULL; /* for -p. */
|
||||
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. */
|
||||
@@ -64,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'.
|
||||
@@ -115,14 +118,12 @@ concat2 (char const *str1, char const *str2)
|
||||
FILE *
|
||||
xfopen (const char *name, const char *mode)
|
||||
{
|
||||
FILE *ptr;
|
||||
|
||||
ptr = fopen_safer (name, mode);
|
||||
if (!ptr)
|
||||
FILE *res = fopen_safer (name, mode);
|
||||
if (!res)
|
||||
error (EXIT_FAILURE, get_errno (),
|
||||
_("%s: cannot open"), quotearg_colon (name));
|
||||
|
||||
return ptr;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------.
|
||||
@@ -243,19 +244,18 @@ file_name_split (const char *file_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE or
|
||||
GRAMMAR_FILE.
|
||||
|
||||
The precise -o name will be used for FTABLE. For other output
|
||||
files, remove the ".c" or ".tab.c" suffix. */
|
||||
|
||||
static void
|
||||
compute_file_name_parts (void)
|
||||
{
|
||||
const char *base, *tab, *ext;
|
||||
|
||||
/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE
|
||||
or GRAMMAR_FILE.
|
||||
|
||||
The precise -o name will be used for FTABLE. For other output
|
||||
files, remove the ".c" or ".tab.c" suffix. */
|
||||
if (spec_outfile)
|
||||
{
|
||||
const char *base, *tab, *ext;
|
||||
file_name_split (spec_outfile, &base, &tab, &ext);
|
||||
dir_prefix = xstrndup (spec_outfile, base - spec_outfile);
|
||||
|
||||
@@ -275,6 +275,7 @@ compute_file_name_parts (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *base, *tab, *ext;
|
||||
file_name_split (grammar_file, &base, &tab, &ext);
|
||||
|
||||
if (spec_file_prefix)
|
||||
@@ -285,7 +286,7 @@ compute_file_name_parts (void)
|
||||
last_component (spec_file_prefix) - spec_file_prefix);
|
||||
all_but_tab_ext = xstrdup (spec_file_prefix);
|
||||
}
|
||||
else if (yacc_flag)
|
||||
else if (! location_empty (yacc_loc))
|
||||
{
|
||||
/* If --yacc, then the output is 'y.tab.c'. */
|
||||
dir_prefix = xstrdup ("");
|
||||
@@ -306,7 +307,7 @@ compute_file_name_parts (void)
|
||||
all_but_ext = xstrdup (all_but_tab_ext);
|
||||
|
||||
/* Compute the extensions from the grammar file name. */
|
||||
if (ext && !yacc_flag)
|
||||
if (ext && location_empty (yacc_loc))
|
||||
compute_exts_from_gf (ext);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -374,16 +376,13 @@ output_file_name_check (char **file_name, bool source)
|
||||
conflict = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < generated_files_size; i++)
|
||||
if (STREQ (generated_files[i].name, *file_name))
|
||||
{
|
||||
complain (NULL, Wother, _("conflicting outputs to file %s"),
|
||||
quote (generated_files[i].name));
|
||||
conflict = true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < generated_files_size; i++)
|
||||
if (STREQ (generated_files[i].name, *file_name))
|
||||
{
|
||||
complain (NULL, Wother, _("conflicting outputs to file %s"),
|
||||
quote (generated_files[i].name));
|
||||
conflict = true;
|
||||
}
|
||||
if (conflict)
|
||||
{
|
||||
free (*file_name);
|
||||
@@ -401,13 +400,27 @@ output_file_name_check (char **file_name, bool source)
|
||||
void
|
||||
unlink_generated_sources (void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < generated_files_size; i++)
|
||||
for (int i = 0; i < generated_files_size; i++)
|
||||
if (generated_files[i].is_source)
|
||||
/* Ignore errors. The file might not even exist. */
|
||||
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)
|
||||
{
|
||||
@@ -415,13 +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);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < generated_files_size; i++)
|
||||
free (generated_files[i].name);
|
||||
}
|
||||
for (int i = 0; i < generated_files_size; i++)
|
||||
free (generated_files[i].name);
|
||||
free (generated_files);
|
||||
free (relocate_buffer);
|
||||
}
|
||||
|
||||
+7
-4
@@ -21,6 +21,7 @@
|
||||
#ifndef FILES_H_
|
||||
# define FILES_H_
|
||||
|
||||
# include "location.h"
|
||||
# include "uniqstr.h"
|
||||
|
||||
/* File name specified with -o for the output file, or 0 if no -o. */
|
||||
@@ -31,9 +32,11 @@ extern char *parser_file_name;
|
||||
|
||||
/* Symbol prefix specified with -p, or 0 if no -p. */
|
||||
extern const char *spec_name_prefix;
|
||||
extern location spec_name_prefix_loc;
|
||||
|
||||
/* File name prefix specified with -b, or 0 if no -b. */
|
||||
extern char const *spec_file_prefix;
|
||||
extern location spec_file_prefix_loc;
|
||||
|
||||
/* --verbose. */
|
||||
extern char *spec_verbose_file;
|
||||
@@ -45,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;
|
||||
@@ -55,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 %include, or 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);
|
||||
|
||||
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
/* Support for fixing grammar files.
|
||||
|
||||
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/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "fixits.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "get-errno.h"
|
||||
#include "getargs.h"
|
||||
#include "gl_array_list.h"
|
||||
#include "gl_xlist.h"
|
||||
#include "progname.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "vasnprintf.h"
|
||||
|
||||
#include "files.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
location location;
|
||||
char *fix;
|
||||
} fixit;
|
||||
|
||||
gl_list_t fixits = NULL;
|
||||
|
||||
static fixit *
|
||||
fixit_new (location const *loc, char const* fix)
|
||||
{
|
||||
fixit *res = xmalloc (sizeof *res);
|
||||
res->location = *loc;
|
||||
res->fix = xstrdup (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)
|
||||
{
|
||||
free (f->fix);
|
||||
free (f);
|
||||
}
|
||||
|
||||
|
||||
/* GCC and Clang follow the same pattern.
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
|
||||
http://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-parseable-fixits */
|
||||
static void
|
||||
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.byte,
|
||||
f->location.end.line, f->location.end.byte,
|
||||
quotearg_n_style (2, c_quoting_style, f->fix));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fixits_register (location const *loc, char const* fix)
|
||||
{
|
||||
if (!fixits)
|
||||
fixits = gl_list_create_empty (GL_ARRAY_LIST,
|
||||
/* equals */ NULL,
|
||||
/* hashcode */ NULL,
|
||||
(gl_listelement_dispose_fn) fixit_free,
|
||||
true);
|
||||
fixit *f = fixit_new (loc, fix);
|
||||
gl_sortedlist_add (fixits, (gl_listelement_compar_fn) fixit_cmp, f);
|
||||
if (feature_flag & feature_fixit)
|
||||
fixit_print (f, stderr);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
fixits_empty (void)
|
||||
{
|
||||
return !fixits;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fixits_run (void)
|
||||
{
|
||||
if (!fixits)
|
||||
return;
|
||||
|
||||
/* This is not unlike what is done in location_caret. */
|
||||
uniqstr input = ((fixit *) gl_list_get_at (fixits, 0))->location.start.file;
|
||||
/* Backup the file. */
|
||||
char buf[256];
|
||||
size_t len = sizeof (buf);
|
||||
char *backup = asnprintf (buf, &len, "%s~", input);
|
||||
if (!backup)
|
||||
xalloc_die ();
|
||||
if (rename (input, backup))
|
||||
error (EXIT_FAILURE, get_errno (),
|
||||
_("%s: cannot backup"), quotearg_colon (input));
|
||||
FILE *in = xfopen (backup, "r");
|
||||
FILE *out = xfopen (input, "w");
|
||||
size_t line = 1;
|
||||
size_t offset = 1;
|
||||
fixit const *f = NULL;
|
||||
gl_list_iterator_t iter = gl_list_iterator (fixits);
|
||||
while (gl_list_iterator_next (&iter, (const void**) &f, NULL))
|
||||
{
|
||||
/* Look for the correct line. */
|
||||
while (line < f->location.start.line)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n')
|
||||
{
|
||||
++line;
|
||||
offset = 1;
|
||||
}
|
||||
putc (c, out);
|
||||
}
|
||||
|
||||
/* Look for the right offset. */
|
||||
bool need_eol = false;
|
||||
while (offset < f->location.start.byte)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
break;
|
||||
++offset;
|
||||
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)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n')
|
||||
{
|
||||
++line;
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
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.byte == 1)
|
||||
{
|
||||
int c = getc (in);
|
||||
if (c == EOF)
|
||||
break;
|
||||
else if (c == '\n')
|
||||
{
|
||||
++line;
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
ungetc (c, in);
|
||||
}
|
||||
}
|
||||
/* Paste the rest of the file. */
|
||||
{
|
||||
int c;
|
||||
while ((c = getc (in)) != EOF)
|
||||
putc (c, out);
|
||||
}
|
||||
|
||||
gl_list_iterator_free (&iter);
|
||||
xfclose (out);
|
||||
xfclose (in);
|
||||
fprintf (stderr, "%s: file %s was updated (backup: %s)\n",
|
||||
program_name, quote_n (0, input), quote_n (1, backup));
|
||||
if (backup != buf)
|
||||
free (backup);
|
||||
}
|
||||
|
||||
|
||||
/* Free the registered fixits. */
|
||||
void fixits_free (void)
|
||||
{
|
||||
if (fixits)
|
||||
{
|
||||
gl_list_free (fixits);
|
||||
fixits = NULL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Support for fixing grammar files.
|
||||
|
||||
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/>. */
|
||||
|
||||
#ifndef FIXITS_H_
|
||||
# define FIXITS_H_ 1
|
||||
|
||||
# include "location.h"
|
||||
|
||||
/* Declare a fix to apply. */
|
||||
void fixits_register (location const *loc, char const* update);
|
||||
|
||||
/* Apply the fixits: update the source file. */
|
||||
void fixits_run (void);
|
||||
|
||||
/* Whether there are no fixits. */
|
||||
bool fixits_empty (void);
|
||||
|
||||
/* Free the registered fixits. */
|
||||
void fixits_free (void);
|
||||
|
||||
#endif /* !FIXITS_H_ */
|
||||
+333
-211
@@ -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,20 +29,23 @@
|
||||
#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;
|
||||
bool graph_flag;
|
||||
bool xml_flag;
|
||||
bool no_lines_flag;
|
||||
bool token_table_flag;
|
||||
bool yacc_flag; /* for -y */
|
||||
bool defines_flag = false;
|
||||
bool graph_flag = false;
|
||||
bool xml_flag = false;
|
||||
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;
|
||||
@@ -64,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)
|
||||
@@ -100,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,108 +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",
|
||||
"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_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. |
|
||||
@@ -263,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);
|
||||
|
||||
@@ -274,40 +365,59 @@ 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\
|
||||
and exit\n\
|
||||
--print-datadir output directory containing skeletons and XSLT\n\
|
||||
-y, --yacc emulate POSIX Yacc\n\
|
||||
-W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\
|
||||
-f, --feature[=FEATURE] activate miscellaneous features\n\
|
||||
and exit\n\
|
||||
-u, --update apply fixes to the source grammar file and exit\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\
|
||||
@@ -317,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: "
|
||||
@@ -430,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)
|
||||
{
|
||||
@@ -445,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));
|
||||
}
|
||||
|
||||
/*----------------------.
|
||||
@@ -476,6 +551,7 @@ static char const short_options[] =
|
||||
"p:"
|
||||
"r:"
|
||||
"t"
|
||||
"u" /* --update */
|
||||
"v"
|
||||
"x::"
|
||||
"y"
|
||||
@@ -484,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. */
|
||||
@@ -497,53 +577,44 @@ static struct option const long_options[] =
|
||||
{ "version", no_argument, 0, 'V' },
|
||||
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
|
||||
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
|
||||
{ "warnings", optional_argument, 0, 'W' },
|
||||
{ "update", no_argument, 0, 'u' },
|
||||
{ "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
|
||||
@@ -551,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
|
||||
@@ -596,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);
|
||||
@@ -604,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':
|
||||
@@ -630,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':
|
||||
@@ -638,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;
|
||||
|
||||
@@ -648,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;
|
||||
|
||||
@@ -664,7 +766,7 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
spec_outfile = AS_FILE_NAME (optarg);
|
||||
spec_outfile = optarg;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
@@ -677,11 +779,16 @@ 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':
|
||||
report_flag |= report_states;
|
||||
break;
|
||||
@@ -691,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 ("error=yacc", 0, 6);
|
||||
yacc_flag = true;
|
||||
warning_argmatch ("yacc", 0, 0);
|
||||
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:
|
||||
@@ -715,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)
|
||||
{
|
||||
@@ -731,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);
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -39,9 +39,9 @@ extern bool graph_flag; /* for -g */
|
||||
extern bool xml_flag; /* for -x */
|
||||
extern bool no_lines_flag; /* for -l */
|
||||
extern bool token_table_flag; /* for -k */
|
||||
extern bool yacc_flag; /* for -y */
|
||||
|
||||
|
||||
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,9 +116,11 @@ extern int trace_flag;
|
||||
|
||||
enum feature
|
||||
{
|
||||
feature_none = 0, /**< No additional feature. */
|
||||
feature_caret = 1 << 0, /**< Enhance the output of errors with carets. */
|
||||
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;
|
||||
|
||||
+75
-41
@@ -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);
|
||||
@@ -238,39 +275,36 @@ grammar_dump (FILE *out, const char *title)
|
||||
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 +312,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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user