mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-10 19:25:15 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f921d18dd | ||
|
|
cc3760ef51 | ||
|
|
2f23ca6f65 | ||
|
|
468b68c5cd | ||
|
|
9ed802a026 | ||
|
|
fb554c2804 | ||
|
|
47850d4f58 | ||
|
|
57b035a242 | ||
|
|
1587a5ea9b | ||
|
|
4ab2cf7450 | ||
|
|
7e3a513d88 | ||
|
|
57f64ebbf8 | ||
|
|
c8d997cb5f | ||
|
|
61b8a8def5 | ||
|
|
6990c5bde9 | ||
|
|
27e822abfd | ||
|
|
21ba496083 | ||
|
|
9cf0a97aa9 | ||
|
|
3dec8a4caf | ||
|
|
2cb52c5a91 | ||
|
|
04f3bfc596 | ||
|
|
c67daa9a97 | ||
|
|
2ca8e86f83 | ||
|
|
78bb152a63 | ||
|
|
4d6ff4c5e5 | ||
|
|
9bb5087ad1 | ||
|
|
d29e40a047 | ||
|
|
b10366f296 | ||
|
|
139d065594 | ||
|
|
0d73c39bb7 | ||
|
|
7f01adced9 | ||
|
|
3bad20352c | ||
|
|
cb3bf6493d | ||
|
|
57503e2165 | ||
|
|
b3abe014f2 | ||
|
|
80f3220fea | ||
|
|
fc2040a750 | ||
|
|
d55f240991 | ||
|
|
4f961a706d | ||
|
|
ac203e6c3c | ||
|
|
9141f0b79f | ||
|
|
d57eab87e8 | ||
|
|
bb901beb68 | ||
|
|
fa00c56c17 | ||
|
|
5359c479bc | ||
|
|
20107b77c0 | ||
|
|
5e71eef267 | ||
|
|
472531dc72 | ||
|
|
046f238826 | ||
|
|
9bf06f6963 | ||
|
|
357336d254 | ||
|
|
d4a6c3c58a | ||
|
|
8976e0f567 | ||
|
|
6dca1eb950 | ||
|
|
f8d82ff039 | ||
|
|
9e9e49224f | ||
|
|
8b53f4e022 | ||
|
|
8c87a62308 | ||
|
|
478cb5cf12 | ||
|
|
94f70bd861 | ||
|
|
9b4f0970fe | ||
|
|
869028a66d | ||
|
|
6f92a7f664 | ||
|
|
6a61b6b17e | ||
|
|
a4bf7cdf9e | ||
|
|
9471a5ffe9 | ||
|
|
24c5214ae8 | ||
|
|
2f7097d1b1 | ||
|
|
28369ecb5d | ||
|
|
b92f064e9b | ||
|
|
98f19578aa | ||
|
|
7d9839c4a8 | ||
|
|
ad32ec64c8 | ||
|
|
44cdc0f001 | ||
|
|
ca796220ec | ||
|
|
8a910107b3 | ||
|
|
28d1ca8f48 | ||
|
|
1817b475a6 | ||
|
|
22ca07defa | ||
|
|
dbd6975b5c | ||
|
|
cd726fdc4d | ||
|
|
60ebd8e210 | ||
|
|
3765e3e790 | ||
|
|
c313360deb | ||
|
|
25698b58c0 | ||
|
|
17d34c231b | ||
|
|
af000bab11 | ||
|
|
b2347a3c3e | ||
|
|
008d927f71 | ||
|
|
1650c729d9 | ||
|
|
7bdf7246fb | ||
|
|
583c193ffa | ||
|
|
47b9ada6fa | ||
|
|
dcd5bb26e3 | ||
|
|
cce6c998b6 | ||
|
|
3398b0fa90 | ||
|
|
2bd1d9e20f | ||
|
|
1f2546396e | ||
|
|
809268c1a4 | ||
|
|
10acc148bb | ||
|
|
28f1e1546c | ||
|
|
c53b379784 | ||
|
|
fead28d9e3 | ||
|
|
7e0b50c524 | ||
|
|
8228d96d33 | ||
|
|
a5fc4e3b44 | ||
|
|
3be912e4af | ||
|
|
4b4e532748 | ||
|
|
6e7d8ba6a7 | ||
|
|
c680300a29 | ||
|
|
0cbefb71e8 | ||
|
|
402332c4b6 | ||
|
|
aa244fc5fe | ||
|
|
719395c9cd | ||
|
|
fa9871a2fb | ||
|
|
76597d01f3 | ||
|
|
bc5efb558d | ||
|
|
17e21f6158 | ||
|
|
6ef8513e7c | ||
|
|
3945beb1d2 | ||
|
|
c86b7815fc | ||
|
|
048730c691 | ||
|
|
ec64a0bc7e | ||
|
|
d6fe39cd18 | ||
|
|
d76ea5ce06 | ||
|
|
fdef997432 | ||
|
|
0073b5ea5f | ||
|
|
717be0a0f0 | ||
|
|
c6e4b260e0 | ||
|
|
8b87da8d12 | ||
|
|
41b1f828ae | ||
|
|
4e0de4df8c | ||
|
|
97d6da0c5b | ||
|
|
e31f92495c | ||
|
|
54c5d5d1b4 | ||
|
|
693e69f289 | ||
|
|
5c2c9fcb17 | ||
|
|
071f43d5b7 | ||
|
|
8a4ec5d4e4 | ||
|
|
052215a138 | ||
|
|
15c1b913cf | ||
|
|
83c9051a64 | ||
|
|
7a557ee7fe | ||
|
|
08dd5e9feb | ||
|
|
68cc2631a4 | ||
|
|
b47340982b | ||
|
|
ee35055b49 | ||
|
|
e5cbac98b6 | ||
|
|
d563a01709 | ||
|
|
a428a9fa6c | ||
|
|
2a0185b693 | ||
|
|
ab3621678a | ||
|
|
8631f35bf9 | ||
|
|
c483b6593f | ||
|
|
59cb1f421c | ||
|
|
d9d37a1196 | ||
|
|
c3db1394a1 | ||
|
|
2c20ae9b41 | ||
|
|
0c56c195e0 | ||
|
|
3dd2ae4415 | ||
|
|
d50df39f1a | ||
|
|
2c66acfec0 | ||
|
|
3f320159e3 | ||
|
|
f41e0cf73c | ||
|
|
d6ce0521cf | ||
|
|
cf298ebb7d | ||
|
|
734db67004 | ||
|
|
7d47d51962 | ||
|
|
602d562d6f | ||
|
|
825150b085 | ||
|
|
d4b6c86c7f | ||
|
|
5463291a91 | ||
|
|
6373b90fc8 | ||
|
|
beceb2fa93 | ||
|
|
58302c6079 | ||
|
|
d2a7a28438 | ||
|
|
9e6c5328d3 | ||
|
|
fec13ce2db | ||
|
|
be3cf406af | ||
|
|
126c4622de | ||
|
|
dd64eaf9db | ||
|
|
0b585c49ae | ||
|
|
37c4d0b175 | ||
|
|
56bcccbc51 | ||
|
|
17cc7da519 | ||
|
|
2713e7c4ff | ||
|
|
32e5a91a91 | ||
|
|
5973d763c0 | ||
|
|
4246cd81df | ||
|
|
e69b47cd18 | ||
|
|
8f5aaa0e04 | ||
|
|
b75b055288 | ||
|
|
41e84cddc7 | ||
|
|
5709f94a91 | ||
|
|
bc96b757ca | ||
|
|
1133220416 | ||
|
|
39eb80bdbc | ||
|
|
361004aabe | ||
|
|
032a52be6e | ||
|
|
843ef49bc3 | ||
|
|
5df33278b4 | ||
|
|
d96fff6115 | ||
|
|
be92ad1eb4 | ||
|
|
ff2f02815b | ||
|
|
67dcef357c | ||
|
|
133edcd248 | ||
|
|
4d9ff272cf | ||
|
|
2ca6b71967 | ||
|
|
871c02b327 | ||
|
|
a57e74a5bf | ||
|
|
4971409e39 | ||
|
|
b772baef24 | ||
|
|
406e8c7c02 | ||
|
|
97c4169f23 | ||
|
|
8add45dbd9 | ||
|
|
b3e9c20227 | ||
|
|
b2c381cd25 | ||
|
|
67bff62e31 | ||
|
|
5f45cb05f1 | ||
|
|
b61b0eb9ac | ||
|
|
69277e109a | ||
|
|
f716484627 | ||
|
|
945b917da2 | ||
|
|
1ef407d923 | ||
|
|
576b863e91 | ||
|
|
2274c34e91 | ||
|
|
fccab9bc40 | ||
|
|
488607534a | ||
|
|
4db572dd21 | ||
|
|
8faf075fd7 | ||
|
|
453639dfac | ||
|
|
4901ee115b | ||
|
|
6c7b2dfe51 | ||
|
|
a3e201de02 | ||
|
|
5e95bb6251 | ||
|
|
569125a6bf | ||
|
|
8ac28ba1f0 | ||
|
|
3ca713abd0 | ||
|
|
8c18e3f18c | ||
|
|
1e5e274972 | ||
|
|
b1679f8346 | ||
|
|
9861bcc540 | ||
|
|
d94d83e10b | ||
|
|
2f6e377953 | ||
|
|
32dff87c1d | ||
|
|
19da501e06 | ||
|
|
5e4133175d | ||
|
|
0b093ac4d9 | ||
|
|
69b22b49d4 | ||
|
|
ec11f08fb3 | ||
|
|
67444a6f0d | ||
|
|
4eed3a0f0c | ||
|
|
84a6621c78 | ||
|
|
06a273625b | ||
|
|
d120a07e6b | ||
|
|
741a58a504 | ||
|
|
d80815ac23 | ||
|
|
0b417c3479 | ||
|
|
f6fd9be688 | ||
|
|
77dbdd0d59 | ||
|
|
f8db8fe4d7 | ||
|
|
375eb71489 | ||
|
|
d3a86f7b20 | ||
|
|
29c75ef27f | ||
|
|
628012d830 | ||
|
|
f788ba2ab6 | ||
|
|
53526f31df | ||
|
|
e63811dd86 | ||
|
|
47262c36bb | ||
|
|
1e452b1553 | ||
|
|
ed796869bb | ||
|
|
12c412f6bb | ||
|
|
2663035ea5 | ||
|
|
de7c66ab41 | ||
|
|
feeacc2d57 | ||
|
|
cc10f9ab24 | ||
|
|
a9499e6ea2 | ||
|
|
09a4bfdab4 | ||
|
|
7d701f4378 | ||
|
|
378963b139 | ||
|
|
2dd882bce5 | ||
|
|
989503b1ba | ||
|
|
61c2c40092 | ||
|
|
3953c61362 | ||
|
|
39e584c018 | ||
|
|
611eaffd28 | ||
|
|
3f4ad2cd24 | ||
|
|
989a7aa865 | ||
|
|
95cbd56882 | ||
|
|
92124d27c1 | ||
|
|
6d81b91ae0 | ||
|
|
9145bd0b61 | ||
|
|
d7cf3f5b18 | ||
|
|
f49598a1e1 | ||
|
|
72d4ae5306 | ||
|
|
996abe62d7 | ||
|
|
0420362ee8 | ||
|
|
6f47eea7ab | ||
|
|
99bfdc09cb | ||
|
|
52f21717f7 | ||
|
|
cbdc22af10 | ||
|
|
220c593a79 | ||
|
|
e29ac453d0 | ||
|
|
44a56b20ac | ||
|
|
f99956b550 | ||
|
|
1f02348d6c | ||
|
|
421ff03018 | ||
|
|
5d3468e0d1 | ||
|
|
40a8dddde1 | ||
|
|
9bdefd7984 | ||
|
|
d233a2e314 | ||
|
|
d90023af5f | ||
|
|
964c6508b1 | ||
|
|
4e3c6f59cc | ||
|
|
801582b410 | ||
|
|
6d35340556 | ||
|
|
1161649446 | ||
|
|
13577a809e | ||
|
|
afc219a765 | ||
|
|
21aa4b2713 | ||
|
|
63f4dca78f | ||
|
|
0984f70e08 | ||
|
|
f26bd45da3 | ||
|
|
a3adc1701b | ||
|
|
7ab275214b | ||
|
|
0428c429a1 | ||
|
|
14fb2cc820 | ||
|
|
faf033957c | ||
|
|
0555e25a41 | ||
|
|
cde8c0a0e6 | ||
|
|
5b525e86a5 | ||
|
|
df77a98edf | ||
|
|
c23fa0fc97 | ||
|
|
08c0571613 | ||
|
|
f2b210a901 | ||
|
|
66ac4acc6c | ||
|
|
cd0f25df5f | ||
|
|
0f46038589 | ||
|
|
1105cf841b | ||
|
|
a298a6d82b | ||
|
|
5f33acefd1 | ||
|
|
849ba01b8b | ||
|
|
29c9cb3188 | ||
|
|
ec4d49e129 | ||
|
|
d84b245c63 | ||
|
|
73797b2552 | ||
|
|
dfef525920 | ||
|
|
7f017ae1c9 | ||
|
|
65126716d7 | ||
|
|
1dcd6068dd | ||
|
|
02f16dc799 | ||
|
|
aa21c457f2 | ||
|
|
9f26e6d6b3 | ||
|
|
8d3e782e05 | ||
|
|
1c671bad33 | ||
|
|
88cd9570b6 | ||
|
|
c423ad17e7 | ||
|
|
9114b267a8 | ||
|
|
70c3f3ade5 | ||
|
|
1934304acf | ||
|
|
c8e57e8159 | ||
|
|
1e49f5e1e6 | ||
|
|
49aae94bed | ||
|
|
e191bf7b9f | ||
|
|
f520e150eb | ||
|
|
75db37c564 | ||
|
|
886b503e4b | ||
|
|
a2f0444c6e | ||
|
|
66100b640f | ||
|
|
de5207244b | ||
|
|
cae8132690 | ||
|
|
a1a847bfb5 | ||
|
|
3ac95de01a | ||
|
|
da7af36a13 | ||
|
|
3f25104caf | ||
|
|
6b1933d992 | ||
|
|
5163803a63 | ||
|
|
fee7c78a83 | ||
|
|
8fc544b03c | ||
|
|
d62d5c4b33 | ||
|
|
ab3eaff7c4 | ||
|
|
85e83ea968 | ||
|
|
0269c6fb03 | ||
|
|
23e536af49 | ||
|
|
cd56929097 | ||
|
|
7aa38561f7 | ||
|
|
22a00cfbf2 | ||
|
|
8c06cb9130 | ||
|
|
b5233ba323 | ||
|
|
013720f0e7 | ||
|
|
365b4d95a4 | ||
|
|
5bb44cca81 | ||
|
|
15f9f8c853 | ||
|
|
04676a5085 | ||
|
|
cf44351dd7 | ||
|
|
614e0bbe23 | ||
|
|
3eb7b0ee78 | ||
|
|
02a1600994 | ||
|
|
f6868c5a77 | ||
|
|
f92f2f8afe | ||
|
|
0cc04eaa2a | ||
|
|
57290d63fd | ||
|
|
33b246a624 | ||
|
|
dc5ce5989f | ||
|
|
7ea108fa67 | ||
|
|
386cf25088 | ||
|
|
a514c51e55 | ||
|
|
91b8f3f171 | ||
|
|
8f5d475079 | ||
|
|
f5a4e279bc | ||
|
|
571447afe8 | ||
|
|
9260e5ca4f | ||
|
|
971e72514f | ||
|
|
0ee5ac5367 | ||
|
|
935d119c82 | ||
|
|
01fe32ee53 | ||
|
|
19ea6b1405 | ||
|
|
a4d33cdf48 | ||
|
|
a992a3cb9e | ||
|
|
95d688957f | ||
|
|
a9b350fb3a | ||
|
|
afe7dfd3b9 | ||
|
|
6b6c3de2ae | ||
|
|
1b70f687fa | ||
|
|
520d474ec6 | ||
|
|
deec7ca65c | ||
|
|
dff7454371 | ||
|
|
e50eedf3c5 | ||
|
|
341776b03b | ||
|
|
79f7afb125 | ||
|
|
2f3d9717ee | ||
|
|
9ad7524659 | ||
|
|
4ec413da32 | ||
|
|
61d53e606d | ||
|
|
d67b7daa1d | ||
|
|
2ab70cf0c6 | ||
|
|
99664706e2 | ||
|
|
a745041b7d | ||
|
|
0dd97f7c87 | ||
|
|
69a823c72d | ||
|
|
0f193d2d21 | ||
|
|
9832fdd6ef | ||
|
|
507c679b9b | ||
|
|
0b42cf8a36 | ||
|
|
10175e4a65 | ||
|
|
18831f985c | ||
|
|
6d4e6bf118 | ||
|
|
a8558bc5a6 | ||
|
|
bbf37f2534 | ||
|
|
d332ff3c77 | ||
|
|
eb92ec3dc6 | ||
|
|
dee8fbbc1e | ||
|
|
75303c61d8 | ||
|
|
af99826ef4 | ||
|
|
af1c6f973a | ||
|
|
b5cd777ad6 | ||
|
|
ae91c3cce3 | ||
|
|
5de4e79fc8 | ||
|
|
4d34b06fb3 | ||
|
|
22a413ce9f | ||
|
|
01855ca328 | ||
|
|
225bc5836a | ||
|
|
941cdf921d | ||
|
|
58ae95670b | ||
|
|
4e19ab9fcd | ||
|
|
6cb612e7e3 | ||
|
|
35add841ee | ||
|
|
f6e38d7ac9 | ||
|
|
855fbf1c11 | ||
|
|
e5ec21215e | ||
|
|
91bbf4219d | ||
|
|
f4c1586454 | ||
|
|
9a71d9d1c6 | ||
|
|
bb0310a353 | ||
|
|
f8408562f8 | ||
|
|
8eac78f8ef | ||
|
|
d57751d2fb | ||
|
|
e062b9f70d | ||
|
|
c837141832 | ||
|
|
a415a78d71 | ||
|
|
5255b919ae | ||
|
|
b12f9c76e2 | ||
|
|
575b814119 | ||
|
|
661bbacfc7 | ||
|
|
d04962f788 | ||
|
|
ec8142391a | ||
|
|
59bec5fade | ||
|
|
5230e610fc | ||
|
|
b81419a9fd | ||
|
|
2b9ee006d8 | ||
|
|
609b40f1a1 | ||
|
|
1e76448ced | ||
|
|
967a59d2c0 | ||
|
|
fbf94ac900 | ||
|
|
a11c144609 | ||
|
|
4848092bf8 | ||
|
|
948f3decb4 | ||
|
|
7d6747cec9 | ||
|
|
420e7b03ec | ||
|
|
b31015a927 | ||
|
|
bd55d43333 | ||
|
|
98020cedf7 | ||
|
|
cbf213915c | ||
|
|
93371999ee | ||
|
|
6289d673a0 | ||
|
|
0adda755a2 | ||
|
|
0782ed3274 | ||
|
|
d7ec136ffb | ||
|
|
dbdf2878ab | ||
|
|
8654fca058 | ||
|
|
05a8097779 | ||
|
|
c06ec1f132 | ||
|
|
fb83319d9c | ||
|
|
e42a7a1862 | ||
|
|
8cbf3ce22c | ||
|
|
1997093e21 | ||
|
|
f23b879ff5 | ||
|
|
8b2d233283 | ||
|
|
40fc688765 | ||
|
|
30f61b0549 | ||
|
|
ad7d8af6d1 | ||
|
|
f293345aa8 | ||
|
|
e18ad5a96b | ||
|
|
dd232b95b7 | ||
|
|
51861998c7 | ||
|
|
e346210c03 | ||
|
|
0d44f83fcc | ||
|
|
40b5f89ee0 | ||
|
|
eed9550993 | ||
|
|
cf96d1b0af | ||
|
|
3d25b52a10 | ||
|
|
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 | ||
|
|
475fd79c8e | ||
|
|
586e2ab0c8 | ||
|
|
7e617dd847 | ||
|
|
3355ee32f0 | ||
|
|
7d545fd23f | ||
|
|
70a4b97daf | ||
|
|
c314b5509f | ||
|
|
f0d7f71a64 | ||
|
|
c8ee05c2b2 | ||
|
|
d3801ad2d1 | ||
|
|
8b717ca5ae | ||
|
|
b7ddb1f224 | ||
|
|
2471733f1a | ||
|
|
c0c45cfa38 | ||
|
|
230d6c5160 | ||
|
|
eb2b5aef0a | ||
|
|
df732955ff | ||
|
|
84276bc3d5 | ||
|
|
b90675e67a | ||
|
|
9ec93d4e34 | ||
|
|
9f81497a0c | ||
|
|
890ee8a1fd | ||
|
|
092b787198 | ||
|
|
6d9818b0cf | ||
|
|
80ef7e7639 | ||
|
|
5be47a73e8 | ||
|
|
0dfad676e3 | ||
|
|
d05b8f181e | ||
|
|
86cb2e72fd | ||
|
|
d07564af63 | ||
|
|
90a8537e62 | ||
|
|
6653c912da | ||
|
|
5bcd4292bb | ||
|
|
9a110873a0 | ||
|
|
7ff7ef678c | ||
|
|
597600fd83 | ||
|
|
4d7df9aec7 | ||
|
|
7c25df547e | ||
|
|
f773e6ead5 | ||
|
|
0dc44adbf6 | ||
|
|
7938ab53ff | ||
|
|
5fb0d276b3 | ||
|
|
50285ff066 | ||
|
|
f44fcd30ea | ||
|
|
a4ede8f85b | ||
|
|
53f1a0b114 | ||
|
|
ac0a0f5491 | ||
|
|
112ccb5ed7 | ||
|
|
0a4ddce822 | ||
|
|
10591c8879 | ||
|
|
807bf60cfc | ||
|
|
45cd7dfb7f | ||
|
|
9858165c52 | ||
|
|
777b0163de | ||
|
|
0978148763 | ||
|
|
e5780041b9 | ||
|
|
1f4dd2671a | ||
|
|
34c52d10ac | ||
|
|
a8e66fc010 | ||
|
|
6e9f9fcafc | ||
|
|
b04492cc5f | ||
|
|
98d199ccc8 | ||
|
|
93cc1fa6e8 | ||
|
|
1099b8dc26 | ||
|
|
8e5b1f40ae | ||
|
|
25b9eada8c | ||
|
|
dbe499e936 | ||
|
|
1d5956f87f | ||
|
|
fdceb6330f | ||
|
|
bc31dee0f7 | ||
|
|
465a47d46b | ||
|
|
953a95695a | ||
|
|
aadf6c0bf3 | ||
|
|
dbb855895f | ||
|
|
d68f05d75c | ||
|
|
b05aa7be2e | ||
|
|
20b0746793 | ||
|
|
afdefecab6 | ||
|
|
81dbd0d82e | ||
|
|
d657da9fb4 | ||
|
|
4cbdcaa572 | ||
|
|
85d303b713 | ||
|
|
1e6a68858a | ||
|
|
17730b0287 | ||
|
|
157f12c483 | ||
|
|
e1a843cc69 | ||
|
|
fe97793659 | ||
|
|
401afe5cc2 | ||
|
|
10e3ccac05 | ||
|
|
3d5059f431 | ||
|
|
9a5c12f160 | ||
|
|
156140dfc3 | ||
|
|
4176584062 | ||
|
|
cfd682f46d | ||
|
|
f15382f7d7 | ||
|
|
0ebcae4a54 | ||
|
|
22b2c286ff | ||
|
|
4a42a4f911 | ||
|
|
c20dd6279f | ||
|
|
999277ddd8 | ||
|
|
f539a56620 | ||
|
|
c44a782a4e | ||
|
|
e40db8976c | ||
|
|
d527b2d0f1 | ||
|
|
1a27d0bf28 | ||
|
|
e76a934853 | ||
|
|
7d823c505e | ||
|
|
6ef788f810 | ||
|
|
cc422ce677 | ||
|
|
d2386a35f5 | ||
|
|
3422ee7435 | ||
|
|
e1094c4c09 | ||
|
|
060da943bd | ||
|
|
b7577ea6f6 | ||
|
|
6220e96e76 | ||
|
|
2c6b7c8b2c | ||
|
|
36e587b1f6 | ||
|
|
b1d6c42ae5 | ||
|
|
8e092082cb | ||
|
|
2c5e933672 | ||
|
|
d92ed9d9f7 | ||
|
|
ebe9b20841 | ||
|
|
23e022718b | ||
|
|
0e9eade009 | ||
|
|
9686b585e7 | ||
|
|
4bddd33439 | ||
|
|
4ad877fdab | ||
|
|
9476783307 | ||
|
|
e1c55d83f8 | ||
|
|
647bf48797 | ||
|
|
bcecfbafab | ||
|
|
deb2fc1dfc | ||
|
|
3a203e2e56 | ||
|
|
709c87bb41 | ||
|
|
9ffed56cd9 | ||
|
|
cc050fd321 | ||
|
|
660811a6c5 | ||
|
|
7ded5bb764 | ||
|
|
ad0b4661d1 | ||
|
|
260ae5481c | ||
|
|
e51fd547ca | ||
|
|
4ebebcc438 | ||
|
|
2b2556b41c | ||
|
|
b34b12c4f9 | ||
|
|
487a2a9eca | ||
|
|
559114c3cb | ||
|
|
dee62718ae | ||
|
|
bee10f5774 | ||
|
|
7795db64d1 | ||
|
|
6bc54a934e | ||
|
|
ebb92c0545 | ||
|
|
e0de1020ea | ||
|
|
4e510c69b1 | ||
|
|
b72d654fa2 | ||
|
|
77086ab57d | ||
|
|
8474dbc09e | ||
|
|
8eb1d79333 | ||
|
|
7bd7644702 | ||
|
|
037eff335b | ||
|
|
7adeb80765 | ||
|
|
a52723e3e8 | ||
|
|
e4fd17bffa | ||
|
|
8ff6ff3ab0 | ||
|
|
868ea55b7c | ||
|
|
4810ed8107 | ||
|
|
35b8e0e947 | ||
|
|
be7c620d65 | ||
|
|
7928c3e6fb | ||
|
|
8d454b843c | ||
|
|
7823c65ee9 | ||
|
|
e4ee138f64 | ||
|
|
7d1b1133d0 | ||
|
|
2deb687446 | ||
|
|
3d601616da | ||
|
|
bda2bed459 | ||
|
|
3ae81aa338 | ||
|
|
c239e53bab | ||
|
|
eee37354b5 | ||
|
|
be737c3dd6 | ||
|
|
a91873a1b9 |
@@ -1,8 +1,6 @@
|
|||||||
*.eps
|
|
||||||
*.log
|
*.log
|
||||||
*.o
|
*.o
|
||||||
*.pdf
|
*.pdf
|
||||||
*.png
|
|
||||||
*.stamp
|
*.stamp
|
||||||
*.trs
|
*.trs
|
||||||
*~
|
*~
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
3.2.1
|
3.5.1
|
||||||
|
|||||||
+299
-148
@@ -1,17 +1,68 @@
|
|||||||
# Travis defines and exports CC and CXX *after* we have defined our
|
version: ~> 1.0
|
||||||
# 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
|
# If the language is set to C or C++, Travis defines and exports CC
|
||||||
|
# and CXX *after* we have defined our environment variables via 'env'.
|
||||||
|
language: minimal
|
||||||
|
|
||||||
env:
|
# Run in two steps:
|
||||||
global:
|
# 1. Build the tarball
|
||||||
# ICC serial number.
|
# On a modern distro, with all the needed dependencies, including the whole git history.
|
||||||
secure: ED3w6rzxuE6tVu3oyxha2MoGMRzRQCtinvr9uor1gw9TGKB80esTLx4KyX0xHemUdyQVarFDDQfVS5rf7jSDY8XiWIR6O+2Af9/30gb+8eyngyvACu7E28n+1XHmYWIEHsbvB9mic6C60FBj5sPcDnFWZeyttGL0WooSjYHiw1Egafwqbeu1mD3Aet9OI9VaLQvy0KcWAdVrYWSI9UWLvLM+xPVUjPFko4oS+dTlETzVnmn6JFbZX1OKONtfcvdoDRFBzs3iHm5dQUt/Fz+y/DtKSuvF3zvePHSgF6c8URbEPPjBdh87gkovSLyy+83fVeh4WMkF8b+dGZmikQv6kRsjKJdbQrS8tiMhZlORC5Gfmn4HXNgmapL+paUweakH7UZQHm6d5SZoBgCHNazfqMrywbZsZkGvZTDQIVG1Be7Lhh2BDFbPhPZNDvI9XYiqZP0QSb0BVfeO+AUSRcUPM7TvarxB74jYdfpTBu7sqJP6dSwhcDTEUhHmuLGjzsNm3uTZe8SUw/TGGx5uPTXNsCjJq6ClIOAIYXZTXLbBmIL/NBWCy0MUpD+9zsiknU7vzzq1RfgCCExhvYgosTjBLcX1kKI+eRSU5M44e+xCg4xx0m9WfafbKbhA20FfnWxCFIkZeVpkOOsexJ9zfe0SflVLxkd7vmci5SCBixLVbN0=
|
# 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
|
||||||
|
|
||||||
matrix:
|
# 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:
|
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. ##
|
## First. ##
|
||||||
## ------- ##
|
## ------- ##
|
||||||
@@ -19,299 +70,399 @@ matrix:
|
|||||||
# Start with three completely different environments, to get
|
# Start with three completely different environments, to get
|
||||||
# errors asap.
|
# errors asap.
|
||||||
|
|
||||||
- name: "GCC 7 -O3"
|
- name: "GCC 9 -O3"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: bionic
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||||
packages:
|
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||||
- g++-7
|
packages: g++-9
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
|
- CC=gcc-9
|
||||||
|
- CXX=g++-9
|
||||||
|
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||||
|
|
||||||
# ASAN is time consuming, and we timeout the 50min granted by
|
# 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.
|
# Travis if we run all the tests in one go. Run in two parts.
|
||||||
- name: "Clang 7 libc++ and ASAN part 1"
|
- name: "Clang 9 libc++ and ASAN part 1"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
addons:
|
dist: bionic
|
||||||
|
addons: &clang9
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- llvm-toolchain-trusty-7
|
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||||
- ubuntu-toolchain-r-test
|
- 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:
|
packages:
|
||||||
- clang-7
|
- clang-9
|
||||||
- libc++-7-dev
|
- libc++-9-dev
|
||||||
- libc++abi-7-dev
|
- libc++abi-9-dev
|
||||||
env:
|
env:
|
||||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
# 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++'"
|
- 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
|
os: linux
|
||||||
addons:
|
dist: bionic
|
||||||
apt:
|
addons: *clang9
|
||||||
sources:
|
|
||||||
- llvm-toolchain-trusty-7
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- clang-7
|
|
||||||
- libc++-7-dev
|
|
||||||
- libc++abi-7-dev
|
|
||||||
env:
|
env:
|
||||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
# 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++'"
|
- CC='clang-9 -fsanitize=address'
|
||||||
|
- CXX='clang++-9 -fsanitize=address -stdlib=libc++'
|
||||||
|
- PART=2
|
||||||
|
|
||||||
- name: "ICC"
|
- name: "ICC"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
compiler: icc
|
||||||
env:
|
env:
|
||||||
# ICC's warnings are often very wrong (e.g., it thinks foo ?
|
- CC=icc
|
||||||
# "bar" : "baz" is char* instead of const char*), so don't try
|
- CXX=icpc
|
||||||
# to work around the, and obviously, don't die on them.
|
install:
|
||||||
- MATRIX_EVAL="CC=icc && CXX=icpc"
|
- source /opt/intel/inteloneapi/compiler/latest/env/vars.sh
|
||||||
- MAKE_ARGS='WERROR_CFLAGS= WERROR_CXXFLAGS='
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- sourceline: 'deb https://apt.repos.intel.com/oneapi all main'
|
||||||
|
key_url: 'https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB'
|
||||||
|
packages:
|
||||||
|
- intel-oneapi-icc
|
||||||
|
|
||||||
## ----- ##
|
## ----- ##
|
||||||
## GCC. ##
|
## GCC. ##
|
||||||
## ----- ##
|
## ----- ##
|
||||||
|
|
||||||
#- name: "GCC 8 with sanitizers"
|
- name: "GCC 8 with sanitizers part 1"
|
||||||
# os: linux
|
os: linux
|
||||||
# addons:
|
dist: bionic
|
||||||
# apt:
|
addons:
|
||||||
# sources:
|
apt:
|
||||||
# - ubuntu-toolchain-r-test
|
packages: g++-8
|
||||||
# packages:
|
env:
|
||||||
# - g++-8
|
- CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||||
# env:
|
- CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||||
# # Can't use UBSAN: I get:
|
- CONFIGUREFLAGS='CFLAGS=-O1 CXXFLAGS=-O1'
|
||||||
# # configure:4951: gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer conftest.c
|
- PART=1
|
||||||
# # /usr/bin/ld: unrecognized option '--push-state'
|
|
||||||
# - MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
|
- name: "GCC 8"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages: g++-8
|
||||||
|
env:
|
||||||
|
- CC=gcc-8
|
||||||
|
- CXX=g++-8
|
||||||
|
|
||||||
|
- name: "GCC 7"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages: g++-7
|
||||||
|
env:
|
||||||
|
- CC=gcc-7
|
||||||
|
- CXX=g++-7
|
||||||
|
|
||||||
- name: "GCC 6"
|
- name: "GCC 6"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-6
|
||||||
packages:
|
|
||||||
- g++-6
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
- CC=gcc-6
|
||||||
|
- CXX=g++-6
|
||||||
|
|
||||||
- name: "GCC 5"
|
- name: "GCC 5"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-5
|
||||||
packages:
|
|
||||||
- g++-5
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
- CC=gcc-5
|
||||||
|
- CXX=g++-5
|
||||||
|
|
||||||
- name: "GCC 4.9"
|
- name: "GCC 4.9"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.9
|
||||||
packages:
|
|
||||||
- g++-4.9
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
|
- CC=gcc-4.9
|
||||||
|
- CXX=g++-4.9
|
||||||
|
|
||||||
- name: "GCC 4.8"
|
- name: "GCC 4.8"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.8
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
|
- CC=gcc-4.8
|
||||||
|
- CXX=g++-4.8
|
||||||
|
|
||||||
- name: "GCC 4.7"
|
- name: "GCC 4.7"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.7
|
||||||
packages:
|
|
||||||
- g++-4.7
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
|
- CC=gcc-4.7
|
||||||
|
- CXX=g++-4.7
|
||||||
|
|
||||||
- name: "GCC 4.6"
|
- name: "GCC 4.6"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.6
|
||||||
packages:
|
|
||||||
- g++-4.6
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.6 && CXX=g++-4.6"
|
- CC=gcc-4.6
|
||||||
|
- CXX=g++-4.6
|
||||||
|
|
||||||
## ------- ##
|
## ------- ##
|
||||||
## Clang. ##
|
## Clang. ##
|
||||||
## ------- ##
|
## ------- ##
|
||||||
|
|
||||||
- name: "Clang 6 -O3 and libc++"
|
- name: "Clang 8 -O3"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- clang-8
|
||||||
|
- libc++-8-dev
|
||||||
|
- libc++abi-8-dev
|
||||||
|
env:
|
||||||
|
- 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:
|
||||||
|
- CC=clang-7
|
||||||
|
- CXX='clang++-7 -stdlib=libc++'
|
||||||
|
|
||||||
|
- name: "Clang 6 and libc++"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- llvm-toolchain-trusty-6.0
|
- llvm-toolchain-xenial-6.0
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
packages:
|
packages:
|
||||||
- clang-6.0
|
- clang-6.0
|
||||||
- libc++-dev
|
- libc++-dev
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-6.0 && CXX='clang++-6.0 -stdlib=libc++'"
|
- CC=clang-6.0
|
||||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
- CXX='clang++-6.0 -stdlib=libc++'
|
||||||
|
|
||||||
- name: "Clang 5"
|
- name: "Clang 5"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: llvm-toolchain-xenial-5.0
|
||||||
- llvm-toolchain-trusty-5.0
|
|
||||||
packages:
|
packages:
|
||||||
- clang-5.0
|
- clang-5.0
|
||||||
- libc++-dev
|
- libc++-dev
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
|
- CC='clang-5.0'
|
||||||
|
- CXX='clang++-5.0'
|
||||||
|
|
||||||
- name: "Clang 4"
|
- name: "Clang 4"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: llvm-toolchain-xenial-4.0
|
||||||
- llvm-toolchain-trusty-4.0
|
packages: clang-4.0
|
||||||
packages:
|
|
||||||
- clang-4.0
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
|
- CC=clang-4.0
|
||||||
|
- CXX=clang++-4.0
|
||||||
|
|
||||||
- name: "Clang 3.9"
|
- name: "Clang 3.9"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: llvm-toolchain-xenial-3.9
|
||||||
- llvm-toolchain-trusty-3.9
|
packages: clang-3.9
|
||||||
packages:
|
|
||||||
- clang-3.9
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
|
- CC=clang-3.9
|
||||||
|
- CXX=clang++-3.9
|
||||||
|
|
||||||
- name: "Clang 3.8"
|
- name: "Clang 3.8"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.8
|
- llvm-toolchain-precise-3.8
|
||||||
packages:
|
packages: clang-3.8
|
||||||
- clang-3.8
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
- CC=clang-3.8
|
||||||
|
- CXX=clang++-3.8
|
||||||
|
|
||||||
- name: "CLang 3.7"
|
- name: "CLang 3.7"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- llvm-toolchain-precise-3.7
|
||||||
packages:
|
packages: clang-3.7
|
||||||
- clang-3.7
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
|
- CC=clang-3.7
|
||||||
|
- CXX=clang++-3.7
|
||||||
|
|
||||||
- name: "Clang 3.6"
|
- name: "Clang 3.6"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.6
|
- llvm-toolchain-precise-3.6
|
||||||
packages:
|
packages: clang-3.6
|
||||||
- clang-3.6
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
|
- CC=clang-3.6
|
||||||
|
- CXX=clang++-3.6
|
||||||
|
|
||||||
- name: "Clang 3.5"
|
- name: "Clang 3.5"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.5
|
- llvm-toolchain-precise-3.5
|
||||||
packages:
|
packages: clang-3.5
|
||||||
- clang-3.5
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
|
- CC=clang-3.5
|
||||||
|
- CXX=clang++-3.5
|
||||||
|
|
||||||
- name: "Clang 3.4"
|
- name: "Clang 3.4"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
# Not available on Xenial.
|
||||||
|
dist: trusty
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages: clang-3.4
|
||||||
- clang-3.4
|
|
||||||
env:
|
env:
|
||||||
# No versioned name installed, but beware that Travis installs
|
# No versioned name installed, but beware that Travis installs
|
||||||
# a more modern clang earlier in the default PATH.
|
# a more modern clang earlier in the default PATH.
|
||||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
- CC=/usr/bin/clang
|
||||||
|
- CXX=/usr/bin/clang++
|
||||||
|
|
||||||
- name: "Clang 3.3"
|
- name: "Clang 3.3"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
|
# Not available on Xenial.
|
||||||
|
dist: trusty
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages: clang-3.3
|
||||||
- clang-3.3
|
|
||||||
env:
|
env:
|
||||||
# See comment for 3.4.
|
# See comment for 3.4.
|
||||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
- CC=/usr/bin/clang
|
||||||
|
- CXX=/usr/bin/clang++
|
||||||
|
|
||||||
|
## From https://docs.gitlab.com/ce/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor.
|
||||||
|
## Applies to Travis too. Applied to all the 'script's (of all the jobs).
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
# Beware not too leak $SSH_PRIVATE_KEY.
|
||||||
|
# - env
|
||||||
|
- sudo apt-get install -qq doxygen flex m4
|
||||||
|
# Install and activate dmd.
|
||||||
|
- mkdir -p ~/dlang && wget https://dlang.org/install.sh -O ~/dlang/install.sh
|
||||||
|
- source $(source ~/dlang/install.sh dmd -a)
|
||||||
|
|
||||||
before_install:
|
|
||||||
- eval "$MATRIX_EVAL"
|
|
||||||
- env
|
|
||||||
- sudo apt-get update -qq
|
|
||||||
- sudo apt-get install -qq autoconf automake autopoint doxygen flex gettext graphviz help2man m4 texinfo
|
|
||||||
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
|
|
||||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
|
||||||
- autoconf --version
|
|
||||||
- automake --version
|
|
||||||
- autopoint --version
|
|
||||||
- $CC --version
|
- $CC --version
|
||||||
- $CXX --version
|
- $CXX --version
|
||||||
|
- dmd --version
|
||||||
- doxygen --version
|
- doxygen --version
|
||||||
- flex --version
|
- flex --version
|
||||||
- gettext --version
|
- ld --version
|
||||||
- dot -V
|
|
||||||
- help2man --version
|
|
||||||
- m4 --version
|
- m4 --version
|
||||||
- makeinfo --version
|
|
||||||
|
|
||||||
script:
|
|
||||||
- git show
|
|
||||||
- git tag -l
|
|
||||||
# For some reasons, sometimes the checkout does not have any tags,
|
|
||||||
# so `git describe` fails, so bootstrap fails.
|
|
||||||
- git describe || git tag v3.0 -m "Fake version 3.0."
|
|
||||||
- git describe
|
|
||||||
- ./bootstrap
|
|
||||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||||
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
|
# Unset this variable, otherwise, Java programs' stderr is cluttered
|
||||||
- make -j2 $MAKE_ARGS
|
# with `Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m`, which makes
|
||||||
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
# the test suite fail.
|
||||||
- if test ${PART-1} = 1; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
- unset _JAVA_OPTIONS
|
||||||
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
|
||||||
|
|
||||||
after_script:
|
# Fail fast from now on.
|
||||||
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
|
- 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-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
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ and nasty bugs.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1998-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 1998-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26733,7 +26733,7 @@
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1987-1988, 1991-2015, 2018 Free Software
|
Copyright (C) 1987-1988, 1991-2015, 2018-2020 Free Software
|
||||||
Foundation, Inc.
|
Foundation, Inc.
|
||||||
|
|
||||||
Copying and distribution of this file, with or without
|
Copying and distribution of this file, with or without
|
||||||
|
|||||||
+26
-5
@@ -1,6 +1,6 @@
|
|||||||
## Process this file with automake to produce Makefile.in.
|
## Process this file with automake to produce Makefile.in.
|
||||||
|
|
||||||
# Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2001-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
AUTOMAKE_OPTIONS = subdir-objects
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
SUBDIRS = po runtime-po .
|
SUBDIRS = po runtime-po gnulib-po .
|
||||||
|
|
||||||
# Files installed for use by Automake.
|
# Files installed for use by Automake.
|
||||||
aclocaldir = @aclocaldir@
|
aclocaldir = @aclocaldir@
|
||||||
@@ -29,13 +29,21 @@ EXTRA_DIST = .prev-version .version cfg.mk PACKAGING \
|
|||||||
|
|
||||||
dist_doc_DATA = AUTHORS COPYING NEWS README THANKS TODO
|
dist_doc_DATA = AUTHORS COPYING NEWS README THANKS TODO
|
||||||
|
|
||||||
|
# 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) $(src_bison_SOURCES) $(dist_skeletons_DATA)
|
||||||
|
|
||||||
## Running the bison from this tarball. To generate our own parser,
|
## 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
|
## but also to run the tests. Of course, you ought to keep a sane
|
||||||
## version of Bison nearby...
|
## version of Bison nearby...
|
||||||
BISON = $(top_builddir)/tests/bison
|
BISON = $(top_builddir)/tests/bison
|
||||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||||
YACC = $(BISON) -o y.tab.c
|
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.
|
# Initialization before completion by local.mk's.
|
||||||
AM_CFLAGS = $(WARN_CFLAGS)
|
AM_CFLAGS = $(WARN_CFLAGS)
|
||||||
@@ -52,12 +60,12 @@ MOSTLYCLEANFILES =
|
|||||||
SUFFIXES =
|
SUFFIXES =
|
||||||
TESTS = $(dist_TESTS)
|
TESTS = $(dist_TESTS)
|
||||||
check_PROGRAMS =
|
check_PROGRAMS =
|
||||||
|
check_SCRIPTS =
|
||||||
dist_TESTS =
|
dist_TESTS =
|
||||||
noinst_LIBRARIES =
|
noinst_LIBRARIES =
|
||||||
|
|
||||||
include build-aux/local.mk
|
include build-aux/local.mk
|
||||||
include data/local.mk
|
include data/local.mk
|
||||||
include djgpp/local.mk
|
|
||||||
include doc/local.mk
|
include doc/local.mk
|
||||||
include etc/local.mk
|
include etc/local.mk
|
||||||
include examples/local.mk
|
include examples/local.mk
|
||||||
@@ -80,9 +88,22 @@ clean-local:
|
|||||||
BUILT_SOURCES += $(top_srcdir)/.version
|
BUILT_SOURCES += $(top_srcdir)/.version
|
||||||
$(top_srcdir)/.version: configure
|
$(top_srcdir)/.version: configure
|
||||||
echo $(VERSION) > $@-t && mv $@-t $@
|
echo $(VERSION) > $@-t && mv $@-t $@
|
||||||
dist-hook: gen-ChangeLog
|
dist-hook: gen-ChangeLog gen-synclines
|
||||||
echo $(VERSION) > $(distdir)/.tarball-version
|
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
|
.PHONY: update-b4-copyright update-package-copyright-year
|
||||||
update-b4-copyright:
|
update-b4-copyright:
|
||||||
$(AM_V_GEN)find $(srcdir)/data -type f \
|
$(AM_V_GEN)find $(srcdir)/data -type f \
|
||||||
|
|||||||
@@ -1,5 +1,736 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Portability issues and minor cosmetic issues.
|
||||||
|
|
||||||
|
The lalr1.cc skeleton properly rejects unsupported values for parse.lac
|
||||||
|
(as yacc.c does).
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5.1 (2020-01-19) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Portability fixes.
|
||||||
|
|
||||||
|
Fix compiler warnings.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5 (2019-12-11) [stable]
|
||||||
|
|
||||||
|
** Backward incompatible changes
|
||||||
|
|
||||||
|
Lone carriage-return characters (aka \r or ^M) in the grammar files are no
|
||||||
|
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||||
|
particular their locations.
|
||||||
|
|
||||||
|
In C++, line numbers and columns are now represented as 'int' not
|
||||||
|
'unsigned', so that integer overflow on positions is easily checkable via
|
||||||
|
'gcc -fsanitize=undefined' and the like. This affects the API for
|
||||||
|
positions. The default position and location classes now expose
|
||||||
|
'counter_type' (int), used to define line and column numbers.
|
||||||
|
|
||||||
|
** Deprecated features
|
||||||
|
|
||||||
|
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||||
|
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
|
||||||
|
It is deprecated and its support will be removed eventually.
|
||||||
|
|
||||||
|
** New features
|
||||||
|
|
||||||
|
*** Lookahead correction in C++
|
||||||
|
|
||||||
|
Contributed by Adrian Vogelsgesang.
|
||||||
|
|
||||||
|
The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
|
||||||
|
%define variable parse.lac.
|
||||||
|
|
||||||
|
*** Variable api.token.raw: Optimized token numbers (all skeletons)
|
||||||
|
|
||||||
|
In the generated parsers, tokens have two numbers: the "external" token
|
||||||
|
number as returned by yylex (which starts at 257), and the "internal"
|
||||||
|
symbol number (which starts at 3). Each time yylex is called, a table
|
||||||
|
lookup maps the external token number to the internal symbol number.
|
||||||
|
|
||||||
|
When the %define variable api.token.raw is set, tokens are assigned their
|
||||||
|
internal number, which saves one table lookup per token, and also saves
|
||||||
|
the generation of the mapping table.
|
||||||
|
|
||||||
|
The gain is typically moderate, but in extreme cases (very simple user
|
||||||
|
actions), a 10% improvement can be observed.
|
||||||
|
|
||||||
|
*** Generated parsers use better types for states
|
||||||
|
|
||||||
|
Stacks now use the best integral type for state numbers, instead of always
|
||||||
|
using 15 bits. As a result "small" parsers now have a smaller memory
|
||||||
|
footprint (they use 8 bits), and there is support for large automata (16
|
||||||
|
bits), and extra large (using int, i.e., typically 31 bits).
|
||||||
|
|
||||||
|
*** Generated parsers prefer signed integer types
|
||||||
|
|
||||||
|
Bison skeletons now prefer signed to unsigned integer types when either
|
||||||
|
will do, as the signed types are less error-prone and allow for better
|
||||||
|
checking with 'gcc -fsanitize=undefined'. Also, the types chosen are now
|
||||||
|
portable to unusual machines where char, short and int are all the same
|
||||||
|
width. On non-GNU platforms this may entail including <limits.h> and (if
|
||||||
|
available) <stdint.h> to define integer types and constants.
|
||||||
|
|
||||||
|
*** A skeleton for the D programming language
|
||||||
|
|
||||||
|
For the last few releases, Bison has shipped a stealth experimental
|
||||||
|
skeleton: lalr1.d. It was first contributed by Oliver Mangold, based on
|
||||||
|
Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
|
||||||
|
H. S. Teoh.
|
||||||
|
|
||||||
|
However, because nobody has committed to improving, testing, and
|
||||||
|
documenting this skeleton, it is not clear that it will be supported in
|
||||||
|
the future.
|
||||||
|
|
||||||
|
The lalr1.d skeleton *is functional*, and works well, as demonstrated in
|
||||||
|
examples/d/calc.d. Please try it, enjoy it, and... commit to support it.
|
||||||
|
|
||||||
|
*** Debug traces in Java
|
||||||
|
|
||||||
|
The Java backend no longer emits code and data for parser tracing if the
|
||||||
|
%define variable parse.trace is not defined.
|
||||||
|
|
||||||
|
** Diagnostics
|
||||||
|
|
||||||
|
*** New diagnostic: -Wdangling-alias
|
||||||
|
|
||||||
|
String literals, which allow for better error messages, are (too)
|
||||||
|
liberally accepted by Bison, which might result in silent errors. For
|
||||||
|
instance
|
||||||
|
|
||||||
|
%type <exVal> cond "condition"
|
||||||
|
|
||||||
|
does not define "condition" as a string alias to 'cond' (nonterminal
|
||||||
|
symbols do not have string aliases). It is rather equivalent to
|
||||||
|
|
||||||
|
%nterm <exVal> cond
|
||||||
|
%token <exVal> "condition"
|
||||||
|
|
||||||
|
i.e., it gives the type 'exVal' to the "condition" token, which was
|
||||||
|
clearly not the intention.
|
||||||
|
|
||||||
|
Also, because string aliases need not be defined, typos such as "baz"
|
||||||
|
instead of "bar" will be not reported.
|
||||||
|
|
||||||
|
The option -Wdangling-alias catches these situations. On
|
||||||
|
|
||||||
|
%token BAR "bar"
|
||||||
|
%type <ival> foo "foo"
|
||||||
|
%%
|
||||||
|
foo: "baz" {}
|
||||||
|
|
||||||
|
bison -Wdangling-alias reports
|
||||||
|
|
||||||
|
warning: string literal not attached to a symbol
|
||||||
|
| %type <ival> foo "foo"
|
||||||
|
| ^~~~~
|
||||||
|
warning: string literal not attached to a symbol
|
||||||
|
| foo: "baz" {}
|
||||||
|
| ^~~~~
|
||||||
|
|
||||||
|
The -Wall option does not (yet?) include -Wdangling-alias.
|
||||||
|
|
||||||
|
*** Better POSIX Yacc compatibility diagnostics
|
||||||
|
|
||||||
|
POSIX Yacc restricts %type to nonterminals. This is now diagnosed by
|
||||||
|
-Wyacc.
|
||||||
|
|
||||||
|
%token TOKEN1
|
||||||
|
%type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
%token TOKEN2
|
||||||
|
%%
|
||||||
|
expr:
|
||||||
|
|
||||||
|
gives with -Wyacc
|
||||||
|
|
||||||
|
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||||
|
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
| ^~~~~~
|
||||||
|
input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||||
|
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
| ^~~
|
||||||
|
input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||||
|
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
| ^~~~~~
|
||||||
|
|
||||||
|
*** Diagnostics with insertion
|
||||||
|
|
||||||
|
The diagnostics now display the suggestion below the underlined source.
|
||||||
|
Replacement for undeclared symbols are now also suggested.
|
||||||
|
|
||||||
|
$ cat /tmp/foo.y
|
||||||
|
%%
|
||||||
|
list: lis '.' |
|
||||||
|
|
||||||
|
$ bison -Wall foo.y
|
||||||
|
foo.y:2.7-9: error: symbol 'lis' is used, but is not defined as a token and has no rules; did you mean 'list'?
|
||||||
|
2 | list: lis '.' |
|
||||||
|
| ^~~
|
||||||
|
| list
|
||||||
|
foo.y:2.16: warning: empty rule without %empty [-Wempty-rule]
|
||||||
|
2 | list: lis '.' |
|
||||||
|
| ^
|
||||||
|
| %empty
|
||||||
|
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||||
|
|
||||||
|
*** Diagnostics about long lines
|
||||||
|
|
||||||
|
Quoted sources may now be truncated to fit the screen. For instance, on a
|
||||||
|
30-column wide terminal:
|
||||||
|
|
||||||
|
$ cat foo.y
|
||||||
|
%token FOO FOO FOO
|
||||||
|
%%
|
||||||
|
exp: FOO
|
||||||
|
$ bison foo.y
|
||||||
|
foo.y:1.34-36: warning: symbol FOO redeclared [-Wother]
|
||||||
|
1 | … FOO …
|
||||||
|
| ^~~
|
||||||
|
foo.y:1.8-10: previous declaration
|
||||||
|
1 | %token FOO …
|
||||||
|
| ^~~
|
||||||
|
foo.y:1.62-64: warning: symbol FOO redeclared [-Wother]
|
||||||
|
1 | … FOO
|
||||||
|
| ^~~
|
||||||
|
foo.y:1.8-10: previous declaration
|
||||||
|
1 | %token FOO …
|
||||||
|
| ^~~
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
|
*** Debugging glr.c and glr.cc
|
||||||
|
|
||||||
|
The glr.c skeleton always had asserts to check its own behavior (not the
|
||||||
|
user's). These assertions are now under the control of the parse.assert
|
||||||
|
%define variable (disabled by default).
|
||||||
|
|
||||||
|
*** Clean up
|
||||||
|
|
||||||
|
Several new compiler warnings in the generated output have been avoided.
|
||||||
|
Some unused features are no longer emitted. Cleaner generated code in
|
||||||
|
general.
|
||||||
|
|
||||||
|
** Bug Fixes
|
||||||
|
|
||||||
|
Portability issues in the test suite.
|
||||||
|
|
||||||
|
In theory, parsers using %nonassoc could crash when reporting verbose
|
||||||
|
error messages. This unlikely bug has been fixed.
|
||||||
|
|
||||||
|
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
In some cases, when warnings are disabled, bison could emit tons of white
|
||||||
|
spaces as diagnostics.
|
||||||
|
|
||||||
|
When running out of memory, bison could crash (found by fuzzing).
|
||||||
|
|
||||||
|
When defining twice the EOF token, bison would crash.
|
||||||
|
|
||||||
|
New warnings from recent compilers have been addressed in the generated
|
||||||
|
parsers (yacc.c, glr.c, glr.cc).
|
||||||
|
|
||||||
|
When lone carriage-return characters appeared in the input file,
|
||||||
|
diagnostics could hang forever.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Portability fixes.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.4 (2019-05-19) [stable]
|
||||||
|
|
||||||
|
** Deprecated features
|
||||||
|
|
||||||
|
The %pure-parser directive is deprecated in favor of '%define api.pure'
|
||||||
|
since Bison 2.3b (2008-05-27), but no warning was issued; there is one
|
||||||
|
now. Note that since Bison 2.7 you are strongly encouraged to use
|
||||||
|
'%define api.pure full' instead of '%define api.pure'.
|
||||||
|
|
||||||
|
** New features
|
||||||
|
|
||||||
|
*** Colored diagnostics
|
||||||
|
|
||||||
|
As an experimental feature, diagnostics are now colored, controlled by the
|
||||||
|
new options --color and --style.
|
||||||
|
|
||||||
|
To use them, install the libtextstyle library before configuring Bison.
|
||||||
|
It is available from
|
||||||
|
|
||||||
|
https://alpha.gnu.org/gnu/gettext/
|
||||||
|
|
||||||
|
for instance
|
||||||
|
|
||||||
|
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz
|
||||||
|
|
||||||
|
The option --color supports the following arguments:
|
||||||
|
- always, yes: Enable colors.
|
||||||
|
- never, no: Disable colors.
|
||||||
|
- auto, tty (default): Enable colors if the output device is a tty.
|
||||||
|
|
||||||
|
To customize the styles, create a CSS file similar to
|
||||||
|
|
||||||
|
/* bison-bw.css */
|
||||||
|
.warning { }
|
||||||
|
.error { font-weight: 800; text-decoration: underline; }
|
||||||
|
.note { }
|
||||||
|
|
||||||
|
then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
|
||||||
|
environment variable to "bison-bw.css".
|
||||||
|
|
||||||
|
*** Disabling output
|
||||||
|
|
||||||
|
When given -fsyntax-only, the diagnostics are reported, but no output is
|
||||||
|
generated.
|
||||||
|
|
||||||
|
The name of this option is somewhat misleading as bison does more than
|
||||||
|
just checking the syntax: every stage is run (including checking for
|
||||||
|
conflicts for instance), except the generation of the output files.
|
||||||
|
|
||||||
|
*** Include the generated header (yacc.c)
|
||||||
|
|
||||||
|
Before, when --defines is used, bison generated a header, and pasted an
|
||||||
|
exact copy of it into the generated parser implementation file. If the
|
||||||
|
header name is not "y.tab.h", it is now #included instead of being
|
||||||
|
duplicated.
|
||||||
|
|
||||||
|
To use an '#include' even if the header name is "y.tab.h" (which is what
|
||||||
|
happens with --yacc, or when using the Autotools' ylwrap), define
|
||||||
|
api.header.include to the exact argument to pass to #include. For
|
||||||
|
instance:
|
||||||
|
|
||||||
|
%define api.header.include {"parse.h"}
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
%define api.header.include {<parser/parse.h>}
|
||||||
|
|
||||||
|
*** api.location.type is now supported in C (yacc.c, glr.c)
|
||||||
|
|
||||||
|
The %define variable api.location.type defines the name of the type to use
|
||||||
|
for locations. When defined, Bison no longer defines YYLTYPE.
|
||||||
|
|
||||||
|
This can be used in programs with several parsers to factor their
|
||||||
|
definition of locations: let one of them generate them, and the others
|
||||||
|
just use them.
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
|
*** Graphviz output
|
||||||
|
|
||||||
|
In conformance with the recommendations of the Graphviz team, if %require
|
||||||
|
"3.4" (or better) is specified, the option --graph generates a *.gv file
|
||||||
|
by default, instead of *.dot.
|
||||||
|
|
||||||
|
*** Diagnostics overhaul
|
||||||
|
|
||||||
|
Column numbers were wrong with multibyte characters, which would also
|
||||||
|
result in skewed diagnostics with carets. Beside, because we were
|
||||||
|
indenting the quoted source with a single space, lines with tab characters
|
||||||
|
were incorrectly underlined.
|
||||||
|
|
||||||
|
To address these issues, and to be clearer, Bison now issues diagnostics
|
||||||
|
as GCC9 does. For instance it used to display (there's a tab before the
|
||||||
|
opening brace):
|
||||||
|
|
||||||
|
foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
|
||||||
|
expr: expr '+' "number" { $$ = $1 + $2; }
|
||||||
|
^~
|
||||||
|
It now reports
|
||||||
|
|
||||||
|
foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
|
||||||
|
3 | expr: expr '+' "number" { $$ = $1 + $2; }
|
||||||
|
| ^~
|
||||||
|
|
||||||
|
Other constructs now also have better locations, resulting in more precise
|
||||||
|
diagnostics.
|
||||||
|
|
||||||
|
*** Fix-it hints for %empty
|
||||||
|
|
||||||
|
Running Bison with -Wempty-rules and --update will remove incorrect %empty
|
||||||
|
annotations, and add the missing ones.
|
||||||
|
|
||||||
|
*** Generated reports
|
||||||
|
|
||||||
|
The format of the reports (parse.output) was improved for readability.
|
||||||
|
|
||||||
|
*** Better support for --no-line.
|
||||||
|
|
||||||
|
When --no-line is used, the generated files are now cleaner: no lines are
|
||||||
|
generated instead of empty lines. Together with using api.header.include,
|
||||||
|
that should help people saving the generated files into version control
|
||||||
|
systems get smaller diffs.
|
||||||
|
|
||||||
|
** Documentation
|
||||||
|
|
||||||
|
A new example in C shows an simple infix calculator with a hand-written
|
||||||
|
scanner (examples/c/calc).
|
||||||
|
|
||||||
|
A new example in C shows a reentrant parser (capable of recursive calls)
|
||||||
|
built with Flex and Bison (examples/c/reccalc).
|
||||||
|
|
||||||
|
There is a new section about the history of Yaccs and Bison.
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
A few obscure bugs were fixed, including the second oldest (known) bug in
|
||||||
|
Bison: it was there when Bison was entered in the RCS version control
|
||||||
|
system, in December 1987. See the NEWS of Bison 3.3 for the previous
|
||||||
|
oldest bug.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Support for DJGPP, which has been unmaintained and untested for years, is
|
||||||
|
removed.
|
||||||
|
|
||||||
|
** 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.
|
||||||
|
|
||||||
|
The '%name-prefix "xx"' directive is deprecated in favor of '%define
|
||||||
|
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 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
|
||||||
|
is recommended.
|
||||||
|
|
||||||
|
abstract -> api.parser.abstract
|
||||||
|
annotations -> api.parser.annotations
|
||||||
|
extends -> api.parser.extends
|
||||||
|
final -> api.parser.final
|
||||||
|
implements -> api.parser.implements
|
||||||
|
parser_class_name -> api.parser.class
|
||||||
|
public -> api.parser.public
|
||||||
|
strictfp -> api.parser.strictfp
|
||||||
|
|
||||||
|
** 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 symbolic links to the installed and moved
|
||||||
|
programs, and invoke them through the symbolic link.
|
||||||
|
|
||||||
|
*** %expect and %expect-rr modifiers on individual rules
|
||||||
|
|
||||||
|
One can now document (and check) which rules participate in shift/reduce
|
||||||
|
and reduce/reduce conflicts. This is particularly important GLR parsers,
|
||||||
|
where conflicts are a normal occurrence. For example,
|
||||||
|
|
||||||
|
%glr-parser
|
||||||
|
%expect 1
|
||||||
|
%%
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
argument_list:
|
||||||
|
arguments %expect 1
|
||||||
|
| arguments ','
|
||||||
|
| %empty
|
||||||
|
;
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
expression
|
||||||
|
| argument_list ',' expression
|
||||||
|
;
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
Looking at the output from -v, one can see that the shift-reduce conflict
|
||||||
|
here is due to the fact that the parser does not know whether to reduce
|
||||||
|
arguments to argument_list until it sees the token _after_ the following
|
||||||
|
','. By marking the rule with %expect 1 (because there is a conflict in
|
||||||
|
one state), we document the source of the 1 overall shift-reduce conflict.
|
||||||
|
|
||||||
|
In GLR parsers, we can use %expect-rr in a rule for reduce/reduce
|
||||||
|
conflicts. In this case, we mark each of the conflicting rules. For
|
||||||
|
example,
|
||||||
|
|
||||||
|
%glr-parser
|
||||||
|
%expect-rr 1
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
stmt:
|
||||||
|
target_list '=' expr ';'
|
||||||
|
| expr_list ';'
|
||||||
|
;
|
||||||
|
|
||||||
|
target_list:
|
||||||
|
target
|
||||||
|
| target ',' target_list
|
||||||
|
;
|
||||||
|
|
||||||
|
target:
|
||||||
|
ID %expect-rr 1
|
||||||
|
;
|
||||||
|
|
||||||
|
expr_list:
|
||||||
|
expr
|
||||||
|
| expr ',' expr_list
|
||||||
|
;
|
||||||
|
|
||||||
|
expr:
|
||||||
|
ID %expect-rr 1
|
||||||
|
| ...
|
||||||
|
;
|
||||||
|
|
||||||
|
In a statement such as
|
||||||
|
|
||||||
|
x, y = 3, 4;
|
||||||
|
|
||||||
|
the parser must reduce x to a target or an expr, but does not know which
|
||||||
|
until it sees the '='. So we notate the two possible reductions to
|
||||||
|
indicate that each conflicts in one rule.
|
||||||
|
|
||||||
|
This feature needs user feedback, and might evolve in the future.
|
||||||
|
|
||||||
|
*** C++: Actual token constructors
|
||||||
|
|
||||||
|
When variants and token constructors are enabled, in addition to the
|
||||||
|
type-safe named token constructors (make_ID, make_INT, etc.), we now
|
||||||
|
generate genuine constructors for symbol_type.
|
||||||
|
|
||||||
|
For instance with these declarations
|
||||||
|
|
||||||
|
%token ':'
|
||||||
|
<std::string> ID
|
||||||
|
<int> INT;
|
||||||
|
|
||||||
|
you may use these constructors:
|
||||||
|
|
||||||
|
symbol_type (int token, const std::string&);
|
||||||
|
symbol_type (int token, const int&);
|
||||||
|
symbol_type (int token);
|
||||||
|
|
||||||
|
Correct matching between token types and value types is checked via
|
||||||
|
'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
|
||||||
|
|
||||||
|
If your application requires C++11 and you don't use symbol constructors,
|
||||||
|
you may now use a variadic emplace for semantic values:
|
||||||
|
|
||||||
|
%define api.value.type variant
|
||||||
|
%token <std::pair<int, int>> PAIR
|
||||||
|
|
||||||
|
in your scanner:
|
||||||
|
|
||||||
|
int yylex (parser::semantic_type *lvalp)
|
||||||
|
{
|
||||||
|
lvalp->emplace <std::pair<int, int>> (1, 2);
|
||||||
|
return parser::token::PAIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*** C++: Syntax error exceptions in GLR
|
||||||
|
|
||||||
|
The glr.cc skeleton now supports syntax_error exceptions thrown from user
|
||||||
|
actions, or from the scanner.
|
||||||
|
|
||||||
|
*** More POSIX Yacc compatibility warnings
|
||||||
|
|
||||||
|
More Bison specific directives are now reported with -y or -Wyacc. This
|
||||||
|
change was ready since the release of Bison 3.0 in September 2015. It was
|
||||||
|
delayed because Autoconf used to define YACC as `bison -y`, which resulted
|
||||||
|
in numerous warnings for Bison users that use the GNU Build System.
|
||||||
|
|
||||||
|
If you still experience that problem, either redefine YACC as `bison -o
|
||||||
|
y.tab.c`, or pass -Wno-yacc to Bison.
|
||||||
|
|
||||||
|
*** The tables yyrhs and yyphrs are back
|
||||||
|
|
||||||
|
Because no Bison skeleton uses them, these tables were removed (no longer
|
||||||
|
passed to the skeletons, not even computed) in 2008. However, some users
|
||||||
|
have expressed interest in being able to use them in their own skeletons.
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
*** Incorrect number of reduce-reduce conflicts
|
||||||
|
|
||||||
|
On a grammar such as
|
||||||
|
|
||||||
|
exp: "num" | "num" | "num"
|
||||||
|
|
||||||
|
bison used to report a single RR conflict, instead of two. This is now
|
||||||
|
fixed. This was the oldest (known) bug in Bison: it was there when Bison
|
||||||
|
was entered in the RCS version control system, in December 1987.
|
||||||
|
|
||||||
|
Some grammar files might have to adjust their %expect-rr.
|
||||||
|
|
||||||
|
*** Parser directives that were not careful enough
|
||||||
|
|
||||||
|
Passing invalid arguments to %nterm, for instance character literals, used
|
||||||
|
to result in unclear error messages.
|
||||||
|
|
||||||
|
** Documentation
|
||||||
|
|
||||||
|
The examples/ directory (installed in .../share/doc/bison/examples) has
|
||||||
|
been restructured per language for clarity. The examples come with a
|
||||||
|
README and a Makefile. Not only can they be used to toy with Bison, they
|
||||||
|
can also be starting points for your own grammars.
|
||||||
|
|
||||||
|
There is now a Java example, and a simple example in C based on Flex and
|
||||||
|
Bison (examples/c/lexcalc/).
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
|
*** Parsers in C++
|
||||||
|
|
||||||
|
They now use noexcept and constexpr. Please, report missing annotations.
|
||||||
|
|
||||||
|
*** Symbol Declarations
|
||||||
|
|
||||||
|
The syntax of the variation directives to declare symbols was overhauled
|
||||||
|
for more consistency, and also better POSIX Yacc compliance (which, for
|
||||||
|
instance, allows "%type" without actually providing a type). The %nterm
|
||||||
|
directive, supported by Bison since its inception, is now documented and
|
||||||
|
officially supported.
|
||||||
|
|
||||||
|
The syntax is now as follows:
|
||||||
|
|
||||||
|
%token TAG? ( ID NUMBER? STRING? )+ ( TAG ( ID NUMBER? STRING? )+ )*
|
||||||
|
%left TAG? ( ID NUMBER? )+ ( TAG ( ID NUMBER? )+ )*
|
||||||
|
%type TAG? ( ID | CHAR | STRING )+ ( TAG ( ID | CHAR | STRING )+ )*
|
||||||
|
%nterm TAG? ID+ ( TAG ID+ )*
|
||||||
|
|
||||||
|
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 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]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Fix the move constructor of symbol_type.
|
||||||
|
|
||||||
|
Always provide a copy constructor for symbol_type, even in modern C++.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Properly support token constructors in C++ with types that include commas
|
||||||
|
(e.g., std::pair<int, int>). A regression introduced in Bison 3.2.
|
||||||
|
|
||||||
* Noteworthy changes in release 3.2.2 (2018-11-21) [stable]
|
* Noteworthy changes in release 3.2.2 (2018-11-21) [stable]
|
||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
@@ -17,7 +748,7 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
** Backward incompatible changes
|
** Backward incompatible changes
|
||||||
|
|
||||||
Support for DJGPP, which have been unmaintained and untested for years, is
|
Support for DJGPP, which has been unmaintained and untested for years, is
|
||||||
obsolete. Unless there is activity to revive it, it will be removed.
|
obsolete. Unless there is activity to revive it, it will be removed.
|
||||||
|
|
||||||
** Changes
|
** Changes
|
||||||
@@ -187,7 +918,7 @@ GNU Bison NEWS
|
|||||||
release of Bison 3.0, five years ago. Generated parsers do not require a
|
release of Bison 3.0, five years ago. Generated parsers do not require a
|
||||||
C99 compiler.
|
C99 compiler.
|
||||||
|
|
||||||
Support for DJGPP, which have been unmaintained and untested for years, is
|
Support for DJGPP, which has been unmaintained and untested for years, is
|
||||||
obsolete. Unless there is activity to revive it, the next release of Bison
|
obsolete. Unless there is activity to revive it, the next release of Bison
|
||||||
will have it removed.
|
will have it removed.
|
||||||
|
|
||||||
@@ -393,10 +1124,10 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
bison used to report:
|
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"
|
%printer {} "foo"
|
||||||
^^
|
^^
|
||||||
/tmp/foo.yy:3.10-11: previous declaration
|
foo.yy:3.10-11: previous declaration
|
||||||
%printer {} FOO
|
%printer {} FOO
|
||||||
^^
|
^^
|
||||||
|
|
||||||
@@ -502,7 +1233,7 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
|
Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
|
||||||
Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
|
Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
|
||||||
'y.tab.h' and 'y.outout') to be generated from 'foo.y'.
|
'y.tab.h' and 'y.output') to be generated from 'foo.y'.
|
||||||
|
|
||||||
To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
|
To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
|
||||||
implementation of Yacc, was using Bison as 'bison -y'. While it does
|
implementation of Yacc, was using Bison as 'bison -y'. While it does
|
||||||
@@ -3097,7 +3828,7 @@ Output file does not redefine const for C++.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1995-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 1995-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Parser Generator.
|
This file is part of Bison, the GNU Parser Generator.
|
||||||
|
|
||||||
@@ -3138,11 +3869,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
||||||
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
||||||
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
|
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
|
||||||
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir
|
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir bw
|
||||||
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles outout PROG
|
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
|
||||||
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW
|
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 Teoh
|
||||||
|
LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
|
||||||
|
LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
|
ispell-dictionary: "american"
|
||||||
mode: outline
|
mode: outline
|
||||||
fill-column: 76
|
fill-column: 76
|
||||||
End:
|
End:
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ to the bison package.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2002, 2005, 2009-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2005, 2009-2015, 2018-2020 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -1,52 +1,87 @@
|
|||||||
This package contains the GNU Bison parser generator.
|
This package contains the GNU Bison parser generator.
|
||||||
|
|
||||||
* Installation
|
# Installation
|
||||||
** Build
|
## Build from git
|
||||||
See the file INSTALL for generic compilation and installation
|
Here are basic installation instructions for a repository checkout:
|
||||||
instructions.
|
|
||||||
|
|
||||||
Bison requires GNU m4 1.4.6 or later. See:
|
$ git submodule update --init
|
||||||
|
$ ./bootstrap
|
||||||
|
|
||||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
|
then proceed with the usual `configure && make` steps.
|
||||||
|
|
||||||
** Internationalization
|
The file README-hacking.md is about building, modifying and checking Bison.
|
||||||
|
|
||||||
|
## Build from tarball
|
||||||
|
See the file INSTALL for generic compilation and installation instructions.
|
||||||
|
|
||||||
|
Bison requires GNU m4 1.4.6 or later. See
|
||||||
|
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
|
||||||
|
|
||||||
|
## Colored diagnostics
|
||||||
|
As an experimental feature, diagnostics are now colored, controlled by the
|
||||||
|
`--color` and `--style` options.
|
||||||
|
|
||||||
|
To use them, install the libtextstyle library before configuring Bison. It
|
||||||
|
is available from https://alpha.gnu.org/gnu/gettext/, for instance
|
||||||
|
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz.
|
||||||
|
|
||||||
|
The option --color supports the following arguments:
|
||||||
|
- always, yes: Enable colors.
|
||||||
|
- never, no: Disable colors.
|
||||||
|
- auto, tty (default): Enable colors if the output device is a tty.
|
||||||
|
|
||||||
|
To customize the styles, create a CSS file, say `bison-bw.css`, similar to
|
||||||
|
|
||||||
|
/* bison-bw.css */
|
||||||
|
.warning { }
|
||||||
|
.error { font-weight: 800; text-decoration: underline; }
|
||||||
|
.note { }
|
||||||
|
|
||||||
|
then invoke bison with `--style=bison-bw.css`, or set the `BISON_STYLE`
|
||||||
|
environment variable to `bison-bw.css`.
|
||||||
|
|
||||||
|
## Relocatability
|
||||||
|
If you pass `--enable-relocatable` to `configure`, Bison is relocatable.
|
||||||
|
|
||||||
|
A relocatable program can be moved or copied to a different location on the
|
||||||
|
file system. It can also be used through mount points for network sharing.
|
||||||
|
It is possible to make symlinks to the installed and moved programs, and
|
||||||
|
invoke them through the symlink.
|
||||||
|
|
||||||
|
See "Enabling Relocatability" in the documentation.
|
||||||
|
|
||||||
|
## Internationalization
|
||||||
Bison supports two catalogs: one for Bison itself (i.e., for the
|
Bison supports two catalogs: one for Bison itself (i.e., for the
|
||||||
maintainer-side parser generation), and one for the generated parsers
|
maintainer-side parser generation), and one for the generated parsers (i.e.,
|
||||||
(i.e., for the user-side parser execution). The requirements between
|
for the user-side parser execution). The requirements between both differ:
|
||||||
both differ: bison needs ngettext, the generated parsers do not. To
|
bison needs ngettext, the generated parsers do not. To simplify the build
|
||||||
simplify the build system, neither are installed if ngettext is not
|
system, neither are installed if ngettext is not supported, even if
|
||||||
supported, even if generated parsers could have been localized. See
|
generated parsers could have been localized. See
|
||||||
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for
|
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for more
|
||||||
more details.
|
details.
|
||||||
|
|
||||||
* Questions
|
# Questions
|
||||||
See the section FAQ in the documentation (doc/bison.info) for
|
See the section FAQ in the documentation (doc/bison.info) for frequently
|
||||||
frequently asked questions. The documentation is also available in
|
asked questions. The documentation is also available in PDF and HTML,
|
||||||
PDF and HTML, provided you have a recent version of Texinfo installed:
|
provided you have a recent version of Texinfo installed: run `make pdf` or
|
||||||
run "make pdf" or "make html".
|
`make html`.
|
||||||
|
|
||||||
If you have questions about using Bison and the documentation does
|
If you have questions about using Bison and the documentation does not
|
||||||
not answer them, please send mail to <[email protected]>.
|
answer them, please send mail to <[email protected]>.
|
||||||
|
|
||||||
* Bug reports
|
# Bug reports
|
||||||
Please send bug reports to <[email protected]>. Be sure to include the
|
Please send bug reports to <[email protected]>. Be sure to include the
|
||||||
version number from 'bison --version', and a complete, self-contained test
|
version number from `bison --version`, and a complete, self-contained test
|
||||||
case in each bug report.
|
case in each bug report.
|
||||||
|
|
||||||
* Copyright statements
|
# Copyright statements
|
||||||
For any copyright year range specified as YYYY-ZZZZ in this package,
|
For any copyright year range specified as YYYY-ZZZZ in this package, note
|
||||||
note that the range specifies every single year in that closed interval.
|
that the range specifies every single year in that closed interval.
|
||||||
|
|
||||||
-----
|
<!--
|
||||||
|
|
||||||
Local Variables:
|
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2020 Free
|
||||||
mode: outline
|
Software Foundation, Inc.
|
||||||
fill-column: 76
|
|
||||||
ispell-dictionary: "american"
|
|
||||||
End:
|
|
||||||
|
|
||||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software
|
|
||||||
Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of GNU bison, the GNU Compiler Compiler.
|
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -63,5 +98,13 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
Local Variables:
|
||||||
# LocalWords: MERCHANTABILITY
|
mode: markdown
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
||||||
|
LocalWords: MERCHANTABILITY
|
||||||
|
|
||||||
|
-->
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,8 @@ the problems you encounter.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2004, 2009-2015, 2018-2020 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
|
||||||
This file is part of GNU Bison.
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
|||||||
+240
-173
@@ -2,20 +2,19 @@ This file attempts to describe the rules to use when hacking Bison.
|
|||||||
Don't put this file into the distribution.
|
Don't put this file into the distribution.
|
||||||
|
|
||||||
Everything related to the development of Bison is on Savannah:
|
Everything related to the development of Bison is on Savannah:
|
||||||
|
http://savannah.gnu.org/projects/bison/.
|
||||||
http://savannah.gnu.org/projects/bison/
|
|
||||||
|
|
||||||
|
|
||||||
* Administrivia
|
# Administrivia
|
||||||
|
|
||||||
** If you incorporate a change from somebody on the net:
|
## If you incorporate a change from somebody on the net:
|
||||||
First, if it is a large change, you must make sure they have signed the
|
First, if it is a large change, you must make sure they have signed the
|
||||||
appropriate paperwork. Second, be sure to add their name and email address
|
appropriate paperwork. Second, be sure to add their name and email address
|
||||||
to THANKS.
|
to THANKS.
|
||||||
|
|
||||||
** If a change fixes a test, mention the test in the commit message.
|
## If a change fixes a test, mention the test in the commit message.
|
||||||
|
|
||||||
** Bug reports
|
## Bug reports
|
||||||
If somebody reports a new bug, mention his name in the commit message and in
|
If somebody reports a new bug, mention his name in the commit message and in
|
||||||
the test case you write. Put him into THANKS.
|
the test case you write. Put him into THANKS.
|
||||||
|
|
||||||
@@ -24,18 +23,18 @@ demonstrates the bug. Then fix the bug, re-run the test suite, and check
|
|||||||
everything in.
|
everything in.
|
||||||
|
|
||||||
|
|
||||||
* Hacking
|
# Hacking
|
||||||
|
|
||||||
** Visible changes
|
## Visible changes
|
||||||
Which include serious bug fixes, must be mentioned in NEWS.
|
Which include serious bug fixes, must be mentioned in NEWS.
|
||||||
|
|
||||||
** Translations
|
## Translations
|
||||||
Only user visible strings are to be translated: error messages, bits of the
|
Only user visible strings are to be translated: error messages, bits of the
|
||||||
.output file etc. This excludes impossible error messages (comparable to
|
.output file etc. This excludes impossible error messages (comparable to
|
||||||
assert/abort), and all the --trace output which is meant for the maintainers
|
assert/abort), and all the --trace output which is meant for the maintainers
|
||||||
only.
|
only.
|
||||||
|
|
||||||
** Horizontal tabs
|
## Horizontal tabs
|
||||||
Do not add horizontal tab characters to any file in Bison's repository
|
Do not add horizontal tab characters to any file in Bison's repository
|
||||||
except where required. For example, do not use tabs to format C code.
|
except where required. For example, do not use tabs to format C code.
|
||||||
However, make files, ChangeLog, and some regular expressions require tabs.
|
However, make files, ChangeLog, and some regular expressions require tabs.
|
||||||
@@ -43,12 +42,12 @@ Also, test cases might need to contain tabs to check that Bison properly
|
|||||||
processes tabs in its input.
|
processes tabs in its input.
|
||||||
|
|
||||||
|
|
||||||
* Working from the repository
|
# Working from the repository
|
||||||
|
|
||||||
These notes intend to help people working on the checked-out sources.
|
These notes intend to help people working on the checked-out sources. These
|
||||||
These requirements do not apply when building from a distribution tarball.
|
requirements do not apply when building from a distribution tarball.
|
||||||
|
|
||||||
** Requirements
|
## Requirements
|
||||||
|
|
||||||
We've opted to keep only the highest-level sources in the repository. This
|
We've opted to keep only the highest-level sources in the repository. This
|
||||||
eases our maintenance burden, (fewer merges etc.), but imposes more
|
eases our maintenance burden, (fewer merges etc.), but imposes more
|
||||||
@@ -75,8 +74,8 @@ If you're using a GNU/Linux distribution, the easiest way to install the
|
|||||||
above packages depends on your system. The following shell command should
|
above packages depends on your system. The following shell command should
|
||||||
work for Debian-based systems such as Ubuntu:
|
work for Debian-based systems such as Ubuntu:
|
||||||
|
|
||||||
sudo apt-get install \
|
sudo apt-get install \
|
||||||
autoconf automake autopoint flex graphviz help2man texinfo valgrind
|
autoconf automake autopoint flex graphviz help2man texinfo valgrind
|
||||||
|
|
||||||
Bison is written using Bison grammars, so there are bootstrapping issues.
|
Bison is written using Bison grammars, so there are bootstrapping issues.
|
||||||
The bootstrap script attempts to discover when the C code generated from the
|
The bootstrap script attempts to discover when the C code generated from the
|
||||||
@@ -89,144 +88,184 @@ after synchronizing from the repository a plain 'make' should be sufficient.
|
|||||||
Note, however, that when gnulib is updated, running './bootstrap' again
|
Note, however, that when gnulib is updated, running './bootstrap' again
|
||||||
might be needed.
|
might be needed.
|
||||||
|
|
||||||
** First checkout
|
## First checkout
|
||||||
|
|
||||||
Obviously, if you are reading these notes, you did manage to check out
|
Obviously, if you are reading these notes, you did manage to check out this
|
||||||
this package from the repository. For the record, you will find all the
|
package from the repository. For the record, you will find all the relevant
|
||||||
relevant information on:
|
information on http://savannah.gnu.org/git/?group=bison.
|
||||||
|
|
||||||
http://savannah.gnu.org/git/?group=bison
|
Bison uses Git submodules: subscriptions to other Git repositories. In
|
||||||
|
particular it uses gnulib, the GNU portability library. To ask Git to
|
||||||
|
perform the first checkout of the submodules, run
|
||||||
|
|
||||||
Bison uses Git submodules: subscriptions to other Git repositories.
|
$ git submodule update --init
|
||||||
In particular it uses gnulib, the GNU portability library. To ask Git
|
|
||||||
to perform the first checkout of the submodules, run
|
|
||||||
|
|
||||||
$ git submodule update --init
|
The next step is to get other files needed to build, which are extracted
|
||||||
|
from other source packages:
|
||||||
|
|
||||||
The next step is to get other files needed to build, which are
|
$ ./bootstrap
|
||||||
extracted from other source packages:
|
|
||||||
|
|
||||||
$ ./bootstrap
|
|
||||||
|
|
||||||
Bootstrapping updates the submodules to the versions registered in the
|
Bootstrapping updates the submodules to the versions registered in the
|
||||||
top-level directory. To change gnulib, first check out the version you want
|
top-level directory. To change gnulib, first check out the version you want
|
||||||
in `gnulib`, then commit this change in Bison's repository, and finally run
|
in `gnulib`, then commit this change in Bison's repository, and finally run
|
||||||
bootstrap.
|
bootstrap.
|
||||||
|
|
||||||
If it fails with missing symbols (e.g., "error: possibly undefined macro:
|
If it fails with missing symbols (e.g., `error: possibly undefined macro:
|
||||||
AC_PROG_GNU_M4"), you are likely to have forgotten the submodule
|
AC_PROG_GNU_M4`), you are likely to have forgotten the submodule
|
||||||
initialization part. Otherwise, there you are! Just
|
initialization part. To recover from it, run `git reset --hard HEAD`, and
|
||||||
|
restart with the submodule initialization. Otherwise, there you are! Just
|
||||||
|
|
||||||
$ ./configure
|
$ ./configure
|
||||||
$ make
|
$ make
|
||||||
$ make check
|
$ make check
|
||||||
|
|
||||||
At this point, there should be no difference between your local copy,
|
At this point, there should be no difference between your local copy, and
|
||||||
and the master copy:
|
the master copy:
|
||||||
|
|
||||||
$ git diff
|
$ git diff
|
||||||
|
|
||||||
should output no difference.
|
should output no difference.
|
||||||
|
|
||||||
Enjoy!
|
Enjoy!
|
||||||
|
|
||||||
** Updating
|
## Updating
|
||||||
|
|
||||||
The use of submodules make things somewhat different because git does
|
If you have git at version 1.8.2 or later, the command
|
||||||
not support recursive operations: submodules must be taken care of
|
|
||||||
explicitly by the user.
|
|
||||||
|
|
||||||
*** Updating Bison
|
$ git submodule update --recursive --remote
|
||||||
|
|
||||||
If you pull a newer version of a branch, say via "git pull", you might
|
will be useful for updating to the latest version of all submodules.
|
||||||
import requests for updated submodules. A simple "git diff" will reveal if
|
|
||||||
|
Under earlier versions, use of submodules make things somewhat different
|
||||||
|
because git does not yet support recursive operations: submodules must be
|
||||||
|
taken care of explicitly.
|
||||||
|
|
||||||
|
### Updating Bison
|
||||||
|
|
||||||
|
If you pull a newer version of a branch, say via `git pull`, you might
|
||||||
|
import requests for updated submodules. A simple `git diff` will reveal if
|
||||||
the current version of the submodule (i.e., the actual contents of the
|
the current version of the submodule (i.e., the actual contents of the
|
||||||
gnulib directory) and the current request from the subscriber (i.e., the
|
gnulib directory) and the current request from the subscriber (i.e., the
|
||||||
reference of the version of gnulib that the Bison repository requests)
|
reference of the version of gnulib that the Bison repository requests)
|
||||||
differ. To upgrade the submodules (i.e., to check out the version that is
|
differ. To upgrade the submodules (i.e., to check out the version that is
|
||||||
actually requested by the subscriber, run "git submodule update".
|
actually requested by the subscriber, run `git submodule update`.
|
||||||
|
|
||||||
$ git pull
|
$ git pull
|
||||||
$ git submodule update
|
$ git submodule update
|
||||||
|
|
||||||
*** Updating a submodule
|
### Updating a submodule
|
||||||
To update a submodule, say gnulib, do as follows:
|
To update a submodule, say gnulib, do as follows:
|
||||||
|
|
||||||
Get the most recent version of the master branch from git.
|
Get the most recent version of the master branch from git.
|
||||||
|
|
||||||
$ cd gnulib
|
$ cd gnulib
|
||||||
$ git fetch
|
$ git fetch
|
||||||
$ git checkout -b master --track origin/master
|
$ git checkout -b master --track origin/master
|
||||||
|
|
||||||
Make sure Bison can live with that version of gnulib.
|
Make sure Bison can live with that version of gnulib.
|
||||||
|
|
||||||
$ cd ..
|
$ cd ..
|
||||||
$ ./bootstrap
|
$ ./bootstrap
|
||||||
$ make distcheck
|
$ make distcheck
|
||||||
|
|
||||||
Register your changes.
|
Register your changes.
|
||||||
|
|
||||||
$ git checkin ...
|
$ git commit ...
|
||||||
|
|
||||||
For a suggestion of what gnulib commit might be stable enough for a formal
|
For a suggestion of what gnulib commit might be stable enough for a formal
|
||||||
release, see the ChangeLog in the latest gnulib snapshot at:
|
release, see the ChangeLog in the latest gnulib snapshot at
|
||||||
|
http://erislabs.net/ianb/projects/gnulib/.
|
||||||
http://erislabs.net/ianb/projects/gnulib/
|
|
||||||
|
|
||||||
The Autoconf files we use are currently:
|
The Autoconf files we use are currently:
|
||||||
|
- m4/m4.m4
|
||||||
m4/m4.m4
|
- lib/m4sugar/m4sugar.m4
|
||||||
lib/m4sugar/m4sugar.m4
|
- lib/m4sugar/foreach.m4
|
||||||
lib/m4sugar/foreach.m4
|
|
||||||
|
|
||||||
These files don't change very often in Autoconf, so it should be relatively
|
These files don't change very often in Autoconf, so it should be relatively
|
||||||
straight-forward to examine the differences in order to decide whether to
|
straight-forward to examine the differences in order to decide whether to
|
||||||
update.
|
update.
|
||||||
|
|
||||||
* Test suite
|
# Test Suite
|
||||||
|
|
||||||
** make check
|
## make check
|
||||||
Use liberally.
|
Consume without moderation. It is composed of two kinds of tests: the
|
||||||
|
examples, and the main test suite.
|
||||||
|
|
||||||
** TESTSUITEFLAGS
|
### The Examples
|
||||||
|
In examples/, there is a number of ready-to-use examples (see
|
||||||
|
examples/README.md). These examples have small test suites run by `make
|
||||||
|
check`. The test results are in local `*.log` files (e.g.,
|
||||||
|
`$build/examples/c/calc/calc.log`).
|
||||||
|
|
||||||
To run just the testsuite (not the tests related to the examples), run `make
|
### The Main Test Suite
|
||||||
check-local`.
|
The main test suite, in tests/, is written on top of GNU Autotest, which is
|
||||||
|
part of Autoconf. Run `info autoconf 'Using Autotest'` to read the
|
||||||
|
documentation, not only about how to write tests, but also where are the
|
||||||
|
logs, how to read them etc.
|
||||||
|
|
||||||
|
The main test suite generates a log for each test (e.g.,
|
||||||
|
`$build/tests/testsuite.dir/004/testsuite.log` for test #4), and a main log
|
||||||
|
file in `$build/tests/testsuite.log`. The latter is meant for end users: it
|
||||||
|
contains lots of details that should help diagnosing issues, including build
|
||||||
|
issues. The per-test logs are more convenient when working locally.
|
||||||
|
|
||||||
|
#### TESTSUITEFLAGS
|
||||||
|
To run just the main test suite, run `make check-local`.
|
||||||
|
|
||||||
The default is for make check-local to run all tests sequentially. This can
|
The default is for make check-local to run all tests sequentially. This can
|
||||||
be very time consuming when checking repeatedly or on slower setups. This
|
be very time consuming when checking repeatedly or on slower setups. This
|
||||||
can be sped up in two ways:
|
can be sped up in two ways:
|
||||||
|
|
||||||
Using -j, in a make-like fashion, for example:
|
Using -j, in a make-like fashion, for example:
|
||||||
$ make check-local TESTSUITEFLAGS='-j8'
|
|
||||||
|
$ make check-local TESTSUITEFLAGS='-j8'
|
||||||
|
|
||||||
|
Actually, when using GNU Make, TESTSUITEFLAGS defaults to the -jN passed to
|
||||||
|
it, so you may simply run
|
||||||
|
|
||||||
|
$ make check-local -j8
|
||||||
|
|
||||||
Running only the tests of a certain category, as specified in the AT files
|
Running only the tests of a certain category, as specified in the AT files
|
||||||
with AT_KEYWORDS([[category]]). Categories include:
|
with AT_KEYWORDS([[category]]). Categories include:
|
||||||
- c++, for c++ parsers
|
- c++, for c++ parsers
|
||||||
- deprec, for tests concerning deprecated constructs.
|
- deprec, for tests concerning deprecated constructs.
|
||||||
- glr, for glr parsers
|
- glr, for glr parsers
|
||||||
- java, for java parsers
|
- java, for java parsers
|
||||||
- report, for automaton dumps
|
- report, for automaton dumps
|
||||||
|
|
||||||
|
To get a list of all the tests (and their keywords for -k), run
|
||||||
|
|
||||||
|
$ ./tests/testsuite -l
|
||||||
|
|
||||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
To run a specific set of tests, use -k (for "keyword"). For example:
|
||||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
|
||||||
|
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||||
|
|
||||||
Both can be combined.
|
Both can be combined.
|
||||||
|
|
||||||
** Typical errors
|
$ make check-local TESTSUITEFLAGS='-j8 -k c++'
|
||||||
If the test suite shows failures such as the following one
|
|
||||||
|
|
||||||
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
|
To rerun the tests that failed:
|
||||||
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
|
|
||||||
|
|
||||||
it probably means that some file was compiled without
|
$ make recheck -j5
|
||||||
AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
|
|
||||||
pick up gnulib's replacement headers, such as getopt.h, and this will go
|
|
||||||
wrong if config.h was not included first.
|
|
||||||
|
|
||||||
See tests/local.at for details.
|
#### Updating the Expectations
|
||||||
|
Sometimes some changes have a large impact on the test suite (e.g., when we
|
||||||
|
added the `[-Wother]` part to all the warnings). Part of the update can be
|
||||||
|
done with a crude tool: `build-aux/update-test`.
|
||||||
|
|
||||||
** make maintainer-check-valgrind
|
Once you ran the test suite, and therefore have many `testsuite.log` files,
|
||||||
|
run, from the source tree:
|
||||||
|
|
||||||
|
$ ./build-aux/update-test $build/tests/testsuite.dir/*/testsuite.log
|
||||||
|
|
||||||
|
where `$build` would be your build tree. This will hopefully update most
|
||||||
|
tests. Re-run the test suite. It might be interesting to run `update-test`
|
||||||
|
again, since some early failures may stop latter tests from being run. Yet
|
||||||
|
at some point, you'll have to fix remaining issues by hand...
|
||||||
|
|
||||||
|
|
||||||
|
## make maintainer-check-valgrind
|
||||||
This target uses valgrind both to check bison, and the generated parsers.
|
This target uses valgrind both to check bison, and the generated parsers.
|
||||||
|
|
||||||
This is not mature on Mac OS X. First, Valgrind does support the way bison
|
This is not mature on Mac OS X. First, Valgrind does support the way bison
|
||||||
@@ -237,13 +276,13 @@ bison. build-aux/darwin11.4.0.valgrind addresses some of them.
|
|||||||
|
|
||||||
Third, valgrind issues warnings such as:
|
Third, valgrind issues warnings such as:
|
||||||
|
|
||||||
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
|
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
|
||||||
|
|
||||||
which cause the test to fail uselessly. It is hard to ignore these errors
|
which cause the test to fail uselessly. It is hard to ignore these errors
|
||||||
with a major overhaul of the way instrumentation is performed in the test
|
with a major overhaul of the way instrumentation is performed in the test
|
||||||
suite. So currently, do not try to run valgrind on Mac OS X.
|
suite. So currently, do not try to run valgrind on Mac OS X.
|
||||||
|
|
||||||
** Release checks
|
## Release checks
|
||||||
Try to run the test suite with more severe conditions before a
|
Try to run the test suite with more severe conditions before a
|
||||||
release:
|
release:
|
||||||
|
|
||||||
@@ -255,25 +294,25 @@ release:
|
|||||||
its warnings; there's no need to obey blindly to it
|
its warnings; there's no need to obey blindly to it
|
||||||
(<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
|
(<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
|
||||||
|
|
||||||
- Check with "make syntax-check" if there are issues diagnosed by gnulib.
|
- Check with `make syntax-check` if there are issues diagnosed by gnulib.
|
||||||
|
|
||||||
- run "make maintainer-check" which:
|
- run `make maintainer-check` which:
|
||||||
- runs "valgrind -q bison" to run Bison under Valgrind.
|
- runs `valgrind -q bison` to run Bison under Valgrind.
|
||||||
- runs the parsers under Valgrind.
|
- runs the parsers under Valgrind.
|
||||||
- runs the test suite with G++ as C compiler...
|
- runs the test suite with G++ as C compiler...
|
||||||
|
|
||||||
- run "make maintainer-check-push", which runs "make maintainer-check" while
|
- run `make maintainer-check-push`, which runs `make maintainer-check` while
|
||||||
activating the push implementation and its pull interface wrappers in many
|
activating the push implementation and its pull interface wrappers in many
|
||||||
test cases that were originally written to exercise only the pull
|
test cases that were originally written to exercise only the pull
|
||||||
implementation. This makes certain the push implementation can perform
|
implementation. This makes certain the push implementation can perform
|
||||||
every task the pull implementation can.
|
every task the pull implementation can.
|
||||||
|
|
||||||
- run "make maintainer-check-xml", which runs "make maintainer-check" while
|
- run `make maintainer-check-xml`, which runs `make maintainer-check` while
|
||||||
checking Bison's XML automaton report for every working grammar passed to
|
checking Bison's XML automaton report for every working grammar passed to
|
||||||
Bison in the test suite. The check just diffs the output of Bison's
|
Bison in the test suite. The check just diffs the output of Bison's
|
||||||
included XSLT style sheets with the output of --report=all and --graph.
|
included XSLT style sheets with the output of --report=all and --graph.
|
||||||
|
|
||||||
- running "make maintainer-check-release" takes care of running
|
- running `make maintainer-check-release` takes care of running
|
||||||
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
||||||
|
|
||||||
- Change tests/atlocal/CFLAGS to add your preferred options.
|
- Change tests/atlocal/CFLAGS to add your preferred options.
|
||||||
@@ -281,59 +320,77 @@ release:
|
|||||||
- Test with a very recent version of GCC for both C and C++. Testing with
|
- Test with a very recent version of GCC for both C and C++. Testing with
|
||||||
older versions that are still in use is nice too.
|
older versions that are still in use is nice too.
|
||||||
|
|
||||||
|
## gnulib
|
||||||
|
To run tests on gnulib components (e.g., on bitset):
|
||||||
|
|
||||||
* Release Procedure
|
cd gnulib
|
||||||
|
./gnulib-tool --test bitset-tests
|
||||||
|
|
||||||
|
possibly within a specified environment:
|
||||||
|
|
||||||
|
CC='gcc-mp-8 -fsanitize=undefined' ./gnulib-tool --test bitset-tests
|
||||||
|
|
||||||
|
To be able to run the tests several times, and to use symlinks instead of
|
||||||
|
copies so that one can update the origin gnulib directory and immediately
|
||||||
|
re-run the tests, run:
|
||||||
|
|
||||||
|
./gnulib-tool --symlink --create-test --dir=/tmp/gnutest bitset-tests
|
||||||
|
cd /tmp/gnutest
|
||||||
|
./configure -C CC='gcc-mp-8 -fsanitize=undefined' CFLAGS='-ggdb'
|
||||||
|
make check
|
||||||
|
|
||||||
|
# Release Procedure
|
||||||
This section needs to be updated to take into account features from gnulib.
|
This section needs to be updated to take into account features from gnulib.
|
||||||
In particular, be sure to read README-release.
|
In particular, be sure to read README-release.
|
||||||
|
|
||||||
** Update the submodules. See above.
|
## Update the submodules. See above.
|
||||||
|
|
||||||
** Update maintainer tools, such as Autoconf. See above.
|
## Update maintainer tools, such as Autoconf. See above.
|
||||||
|
|
||||||
** Try to get the *.pot files to the Translation Project at least one
|
## Try to get the *.pot files to the Translation Project at least one
|
||||||
week before a stable release, to give them time to translate them. Before
|
week before a stable release, to give them time to translate them. Before
|
||||||
generating the *.pot files, make sure that po/POTFILES.in and
|
generating the *.pot files, make sure that po/POTFILES.in and
|
||||||
runtime-po/POTFILES.in list all files with translatable strings. This
|
runtime-po/POTFILES.in list all files with translatable strings. This
|
||||||
helps: grep -l '\<_(' *.
|
helps: `grep -l '\<_(' *`.
|
||||||
|
|
||||||
** Tests
|
## Tests
|
||||||
See above.
|
See above.
|
||||||
|
|
||||||
** Update the foreign files
|
## Update the foreign files
|
||||||
Running "./bootstrap" in the top level should update them all for you. This
|
Running `./bootstrap` in the top level should update them all for you. This
|
||||||
covers PO files too. Sometimes a PO file contains problems that causes it
|
covers PO files too. Sometimes a PO file contains problems that causes it
|
||||||
to be rejected by recent Gettext releases; please report these to the
|
to be rejected by recent Gettext releases; please report these to the
|
||||||
Translation Project.
|
Translation Project.
|
||||||
|
|
||||||
** Update README
|
## Update README
|
||||||
Make sure the information in README is current. Most notably, make sure it
|
Make sure the information in README is current. Most notably, make sure it
|
||||||
recommends a version of GNU M4 that is compatible with the latest Bison
|
recommends a version of GNU M4 that is compatible with the latest Bison
|
||||||
sources.
|
sources.
|
||||||
|
|
||||||
** Check copyright years.
|
## Check copyright years.
|
||||||
We update years in copyright statements throughout Bison once at the start
|
We update years in copyright statements throughout Bison once at the start
|
||||||
of every year by running "make update-copyright". However, before a
|
of every year by running `make update-copyright`. However, before a
|
||||||
release, it's good to verify that it's actually been run. Besides the
|
release, it's good to verify that it's actually been run. Besides the
|
||||||
copyright statement for each Bison file, check the copyright statements that
|
copyright statement for each Bison file, check the copyright statements that
|
||||||
the skeletons insert into generated parsers, and check all occurrences of
|
the skeletons insert into generated parsers, and check all occurrences of
|
||||||
PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
`PACKAGE_COPYRIGHT_YEAR` in configure.ac.
|
||||||
|
|
||||||
** Update NEWS, commit and tag.
|
## Update NEWS, commit and tag.
|
||||||
See do-release-commit-and-tag in README-release. For a while, we used beta
|
See do-release-commit-and-tag in README-release. For a while, we used beta
|
||||||
names such as "2.6_rc1". Now that we use gnulib in the release procedure,
|
names such as `2.6_rc1`. Now that we use gnulib in the release procedure,
|
||||||
we must use "2.5.90", which has the additional benefit of being properly
|
we must use `2.5.90`, which has the additional benefit of being properly
|
||||||
sorted in "git tag -l".
|
sorted in `git tag -l`.
|
||||||
|
|
||||||
** make alpha, beta, or stable
|
## make alpha, beta, or stable
|
||||||
See README-release.
|
See README-release.
|
||||||
|
|
||||||
** Upload
|
## Upload
|
||||||
There are two ways to upload the tarballs to the GNU servers: using gnupload
|
There are two ways to upload the tarballs to the GNU servers: using gnupload
|
||||||
(from gnulib), or by hand. Obviously prefer the former. But in either
|
(from gnulib), or by hand. Obviously prefer the former. But in either
|
||||||
case, be sure to read the following paragraph.
|
case, be sure to read the following paragraph.
|
||||||
|
|
||||||
*** Setup
|
### Setup
|
||||||
You need "gnupg".
|
You need `gnupg`.
|
||||||
|
|
||||||
Make sure your public key has been uploaded at least to keys.gnupg.net. You
|
Make sure your public key has been uploaded at least to keys.gnupg.net. You
|
||||||
can upload it with:
|
can upload it with:
|
||||||
@@ -342,103 +399,105 @@ can upload it with:
|
|||||||
|
|
||||||
where F125BDF3 should be replaced with your key ID.
|
where F125BDF3 should be replaced with your key ID.
|
||||||
|
|
||||||
*** Using gnupload
|
### Using gnupload
|
||||||
You need "ncftp".
|
You need `ncftp`.
|
||||||
|
|
||||||
At the end "make stable" (or alpha/beta) will display the procedure to run.
|
At the end `make stable` (or alpha/beta) will display the procedure to run.
|
||||||
Just copy and paste it in your shell.
|
Just copy and paste it in your shell.
|
||||||
|
|
||||||
*** By hand
|
### By hand
|
||||||
|
|
||||||
The generic GNU upload procedure is at:
|
The generic GNU upload procedure is at
|
||||||
|
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads.
|
||||||
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads
|
|
||||||
|
|
||||||
Follow the instructions there to register your information so you're permitted
|
Follow the instructions there to register your information so you're permitted
|
||||||
to upload.
|
to upload.
|
||||||
|
|
||||||
Here's a brief reminder of how to roll the tarballs and upload them:
|
Here's a brief reminder of how to roll the tarballs and upload them:
|
||||||
|
|
||||||
*** make distcheck
|
### make distcheck
|
||||||
*** gpg -b bison-2.3b.tar.gz
|
### gpg -b bison-2.3b.tar.gz
|
||||||
*** In a file named "bison-2.3b.tar.gz.directive", type:
|
### In a file named `bison-2.3b.tar.gz.directive`, type:
|
||||||
|
|
||||||
version: 1.1
|
version: 1.1
|
||||||
directory: bison
|
directory: bison
|
||||||
filename: bison-2.3b.tar.gz
|
filename: bison-2.3b.tar.gz
|
||||||
|
|
||||||
*** gpg --clearsign bison-2.3b.tar.gz.directive
|
### gpg --clearsign bison-2.3b.tar.gz.directive
|
||||||
*** ftp ftp-upload.gnu.org # Log in as anonymous.
|
### ftp ftp-upload.gnu.org # Log in as anonymous.
|
||||||
*** cd /incoming/alpha # cd /incoming/ftp for full release.
|
### cd /incoming/alpha # cd /incoming/ftp for full release.
|
||||||
*** put bison-2.3b.tar.gz # This can take a while.
|
### put bison-2.3b.tar.gz # This can take a while.
|
||||||
*** put bison-2.3b.tar.gz.sig
|
### put bison-2.3b.tar.gz.sig
|
||||||
*** put bison-2.3b.tar.gz.directive.asc
|
### put bison-2.3b.tar.gz.directive.asc
|
||||||
*** Repeat all these steps for bison-2.3b.tar.xz.
|
### Repeat all these steps for bison-2.3b.tar.xz.
|
||||||
|
|
||||||
** Update Bison manual on www.gnu.org.
|
## Update Bison manual on www.gnu.org.
|
||||||
|
|
||||||
*** You need a non-anonymous checkout of the web pages directory.
|
The instructions below are obsolete, and left in case one would like to run
|
||||||
|
the commands by hand. Today, one just needs to run
|
||||||
|
|
||||||
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
|
$ make web-manual-update
|
||||||
|
|
||||||
*** Get familiar with the instructions for web page maintainers.
|
See README-release.
|
||||||
|
|
||||||
|
### You need a non-anonymous checkout of the web pages directory.
|
||||||
|
|
||||||
|
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
|
||||||
|
|
||||||
|
### Get familiar with the instructions for web page maintainers.
|
||||||
http://www.gnu.org/server/standards/readme_index.html
|
http://www.gnu.org/server/standards/readme_index.html
|
||||||
http://www.gnu.org/server/standards/README.software.html
|
http://www.gnu.org/server/standards/README.software.html
|
||||||
especially the note about symlinks.
|
especially the note about symlinks.
|
||||||
|
|
||||||
*** Build the web pages.
|
### Build the web pages.
|
||||||
Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
|
Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
|
||||||
BISON_WWW_CHECKOUT refers to the web directory created above, do:
|
BISON_WWW_CHECKOUT refers to the web directory created above, do:
|
||||||
|
|
||||||
$ cd $BISON_CHECKOUT/doc
|
$ cd $BISON_CHECKOUT/doc
|
||||||
$ make stamp-vti
|
$ make stamp-vti
|
||||||
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
|
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
|
||||||
bison "Bison - GNU parser generator"
|
bison "Bison - GNU parser generator"
|
||||||
$ cd $BISON_WWW_CHECKOUT
|
$ cd $BISON_WWW_CHECKOUT
|
||||||
|
|
||||||
Verify that the result looks sane.
|
Verify that the result looks sane.
|
||||||
|
|
||||||
*** Commit the modified and the new files.
|
### Commit the modified and the new files.
|
||||||
|
|
||||||
*** Remove old files.
|
### Remove old files.
|
||||||
Find the files which have not been overwritten (because they belonged to
|
Find the files which have not been overwritten (because they belonged to
|
||||||
sections that have been removed or renamed):
|
sections that have been removed or renamed):
|
||||||
|
|
||||||
$ cd manual/html_node
|
$ cd manual/html_node
|
||||||
$ ls -lt
|
$ ls -lt
|
||||||
|
|
||||||
Remove these files and commit their removal to CVS. For each of these
|
Remove these files and commit their removal to CVS. For each of these
|
||||||
files, add a line to the file .symlinks. This will ensure that hyperlinks
|
files, add a line to the file .symlinks. This will ensure that hyperlinks
|
||||||
to the removed files will redirect to the entire manual; this is better than
|
to the removed files will redirect to the entire manual; this is better than
|
||||||
a 404 error.
|
a 404 error.
|
||||||
|
|
||||||
There is a problem with 'index.html' being written twice (once for POSIX
|
## Announce
|
||||||
function 'index', once for the table of contents); you can ignore this
|
The "make release" command just created a template,
|
||||||
issue.
|
`$HOME/announce-bison-X.Y`. Otherwise, to generate it, run:
|
||||||
|
|
||||||
** Announce
|
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
||||||
The "make stable" (or alpha/beta) command just created a template,
|
|
||||||
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
|
|
||||||
|
|
||||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
where alpha can be replaced by `beta` or `table` and F125BDF3 should be
|
||||||
|
|
||||||
where alpha can be replaced by beta or stable and F125BDF3 should be
|
|
||||||
replaced with your key ID.
|
replaced with your key ID.
|
||||||
|
|
||||||
Complete/fix the announcement file. The generated list of recipients
|
Complete/fix the announcement file. The generated list of recipients
|
||||||
(info-gnu@gnu.org, bug-bison@gnu.org, help-bison@gnu.org,
|
(info-gnu@gnu.org, bison-announce@gnu.org, bug-bison@gnu.org,
|
||||||
bison-patches@gnu.org, and coordinator@translationproject.org) is
|
help-bison@gnu.org, bison-patches@gnu.org, and
|
||||||
appropriate for a stable release or a "serious beta". For any other
|
coordinator@translationproject.org) is appropriate for a stable release or a
|
||||||
release, drop at least info-gnu@gnu.org. For an example of how to fill out
|
"serious beta". For any other release, drop at least info-gnu@gnu.org. For
|
||||||
the rest of the template, search the mailing list archives for the most
|
an example of how to fill out the rest of the template, search the mailing
|
||||||
recent release announcement.
|
list archives for the most recent release announcement.
|
||||||
|
|
||||||
For a stable release, send the same announcement on the comp.compilers
|
For a stable release, send the same announcement on the comp.compilers
|
||||||
newsgroup by sending email to compilers@iecc.com. Do not make any Cc as the
|
newsgroup by sending email to compilers@iecc.com. Do not make any Cc as the
|
||||||
moderator will throw away anything cross-posted or Cc'ed. It really needs
|
moderator will throw away anything cross-posted or Cc'ed. It really needs
|
||||||
to be a separate message.
|
to be a separate message.
|
||||||
|
|
||||||
** Prepare NEWS
|
## Prepare NEWS
|
||||||
So that developers don't accidentally add new items to the old NEWS entry,
|
So that developers don't accidentally add new items to the old NEWS entry,
|
||||||
create a new empty entry in line 3 (without the two leading spaces):
|
create a new empty entry in line 3 (without the two leading spaces):
|
||||||
|
|
||||||
@@ -446,9 +505,10 @@ create a new empty entry in line 3 (without the two leading spaces):
|
|||||||
|
|
||||||
Push these changes.
|
Push these changes.
|
||||||
|
|
||||||
-----
|
<!--
|
||||||
|
|
||||||
Copyright (C) 2002-2005, 2007-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2002-2005, 2007-2015, 2018-2020 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
|
||||||
This file is part of GNU Bison.
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
@@ -465,13 +525,20 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
|
||||||
LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
|
|
||||||
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
|
||||||
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
|
||||||
LocalWords: symlinks vti html lt POSIX Cc'ed
|
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: markdown
|
||||||
fill-column: 76
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
|
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
||||||
|
LocalWords: submodule init cd distcheck ChangeLog valgrind sigreturn sudo
|
||||||
|
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||||
|
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||||
|
LocalWords: symlinks vti html lt POSIX Cc'ed Graphviz Texinfo autoconf jN
|
||||||
|
LocalWords: automake autopoint graphviz texinfo PROG Wother parsers
|
||||||
|
LocalWords: TESTSUITEFLAGS deprec struct gnulib's getopt config ggdb
|
||||||
|
LocalWords: bitset fsanitize symlink CFLAGS MERCHANTABILITY ispell
|
||||||
|
LocalWords: american
|
||||||
|
|
||||||
|
-->
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
From phr Tue Jul 8 10:36:19 1986
|
|
||||||
Date: Tue, 8 Jul 86 00:52:24 EDT
|
|
||||||
From: phr (Paul Rubin)
|
|
||||||
To: riferguson%[email protected], tower
|
|
||||||
Subject: Re: Bison documentation?
|
|
||||||
|
|
||||||
The main difference between Bison and Yacc that I know of is that
|
|
||||||
Bison supports the @N construction, which gives you access to
|
|
||||||
the starting and ending line number and character number associated
|
|
||||||
with any of the symbols in the current rule.
|
|
||||||
|
|
||||||
Also, Bison supports the command '%expect N' which says not to mention
|
|
||||||
the conflicts if there are N shift/reduce conflicts and no reduce/reduce
|
|
||||||
conflicts.
|
|
||||||
|
|
||||||
The differences in the algorithms stem mainly from the horrible
|
|
||||||
kludges that Johnson had to perpetrate to make Yacc fit in a PDP-11.
|
|
||||||
|
|
||||||
Also, Bison uses a faster but less space-efficient encoding for the
|
|
||||||
parse tables (see Corbett's PhD thesis from Berkeley, "Static
|
|
||||||
Semantics in Compiler Error Recovery", June 1985, Report No. UCB/CSD
|
|
||||||
85/251), and more modern technique for generating the lookahead sets.
|
|
||||||
(See Frank DeRemer and Thomas Pennello, "Efficient Computation of
|
|
||||||
LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
|
|
||||||
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
|
||||||
technique is the standard one now.)
|
|
||||||
|
|
||||||
paul rubin
|
|
||||||
free software foundation
|
|
||||||
|
|
||||||
|
|
||||||
[DeRemer-Pennello reference corrected by Paul Eggert <[email protected]>,
|
|
||||||
2004-06-21.]
|
|
||||||
@@ -10,6 +10,7 @@ Albert Chin-A-Young [email protected]
|
|||||||
Alexander Belopolsky [email protected]
|
Alexander Belopolsky [email protected]
|
||||||
Alexandre Duret-Lutz [email protected]
|
Alexandre Duret-Lutz [email protected]
|
||||||
Andre da Costa Barros [email protected]
|
Andre da Costa Barros [email protected]
|
||||||
|
Andreas Damm [email protected]
|
||||||
Andreas Schwab [email protected]
|
Andreas Schwab [email protected]
|
||||||
Andrew Suffield [email protected]
|
Andrew Suffield [email protected]
|
||||||
Angelo Borsotti [email protected]
|
Angelo Borsotti [email protected]
|
||||||
@@ -18,6 +19,7 @@ Antonio Silva Correia [email protected]
|
|||||||
Arnold Robbins [email protected]
|
Arnold Robbins [email protected]
|
||||||
Art Haas [email protected]
|
Art Haas [email protected]
|
||||||
Askar Safin [email protected]
|
Askar Safin [email protected]
|
||||||
|
Balázs Scheidler [email protected]
|
||||||
Baron Schwartz [email protected]
|
Baron Schwartz [email protected]
|
||||||
Ben Pfaff [email protected]
|
Ben Pfaff [email protected]
|
||||||
Benoit Perrot [email protected]
|
Benoit Perrot [email protected]
|
||||||
@@ -32,6 +34,7 @@ Bruce Lilly [email protected]
|
|||||||
Bruno Haible [email protected]
|
Bruno Haible [email protected]
|
||||||
Charles-Henri de Boysson [email protected]
|
Charles-Henri de Boysson [email protected]
|
||||||
Christian Burger [email protected]
|
Christian Burger [email protected]
|
||||||
|
Clément Démoulins [email protected]
|
||||||
Colin Daley [email protected]
|
Colin Daley [email protected]
|
||||||
Cris Bailiff [email protected]
|
Cris Bailiff [email protected]
|
||||||
Cris van Pelt [email protected]
|
Cris van Pelt [email protected]
|
||||||
@@ -40,6 +43,7 @@ Dagobert Michelsen [email protected]
|
|||||||
Daniel Frużyński [email protected]
|
Daniel Frużyński [email protected]
|
||||||
Daniel Galloway [email protected]
|
Daniel Galloway [email protected]
|
||||||
Daniel Hagerty [email protected]
|
Daniel Hagerty [email protected]
|
||||||
|
David Barto [email protected]
|
||||||
David J. MacKenzie [email protected]
|
David J. MacKenzie [email protected]
|
||||||
David Kastrup [email protected]
|
David Kastrup [email protected]
|
||||||
David Michael [email protected]
|
David Michael [email protected]
|
||||||
@@ -54,7 +58,9 @@ Didier Godefroy [email protected]
|
|||||||
Efi Fogel [email protected]
|
Efi Fogel [email protected]
|
||||||
Enrico Scholz [email protected]
|
Enrico Scholz [email protected]
|
||||||
Eric Blake [email protected]
|
Eric Blake [email protected]
|
||||||
|
Eric S. Raymond [email protected]
|
||||||
Étienne Renault [email protected]
|
Étienne Renault [email protected]
|
||||||
|
Evan Nemerson [email protected]
|
||||||
Evgeny Stambulchik [email protected]
|
Evgeny Stambulchik [email protected]
|
||||||
Fabrice Bauzac [email protected]
|
Fabrice Bauzac [email protected]
|
||||||
Ferdinand Thiessen [email protected]
|
Ferdinand Thiessen [email protected]
|
||||||
@@ -63,6 +69,7 @@ Frank Heckenbach [email protected]
|
|||||||
Frans Englich [email protected]
|
Frans Englich [email protected]
|
||||||
Gabriel Rassoul [email protected]
|
Gabriel Rassoul [email protected]
|
||||||
Gary L Peskin [email protected]
|
Gary L Peskin [email protected]
|
||||||
|
Gavin Smith [email protected]
|
||||||
Georg Sauthoff [email protected]
|
Georg Sauthoff [email protected]
|
||||||
George Neuner [email protected]
|
George Neuner [email protected]
|
||||||
Gilles Espinasse [email protected]
|
Gilles Espinasse [email protected]
|
||||||
@@ -73,6 +80,7 @@ Hans Åberg [email protected]
|
|||||||
Horst Von Brand [email protected]
|
Horst Von Brand [email protected]
|
||||||
Jan Nieuwenhuizen [email protected]
|
Jan Nieuwenhuizen [email protected]
|
||||||
Jannick [email protected]
|
Jannick [email protected]
|
||||||
|
Jeff Hammond [email protected]
|
||||||
Jerry Quinn [email protected]
|
Jerry Quinn [email protected]
|
||||||
Jesse Thilo [email protected]
|
Jesse Thilo [email protected]
|
||||||
Jim Kent [email protected]
|
Jim Kent [email protected]
|
||||||
@@ -84,15 +92,19 @@ Jonathan Fabrizio [email protected]
|
|||||||
Jonathan Nieder [email protected]
|
Jonathan Nieder [email protected]
|
||||||
Josh Soref [email protected]
|
Josh Soref [email protected]
|
||||||
Juan Manuel Guerrero [email protected]
|
Juan Manuel Guerrero [email protected]
|
||||||
|
Karl Berry [email protected]
|
||||||
Kees Zeelenberg [email protected]
|
Kees Zeelenberg [email protected]
|
||||||
Keith Browne [email protected]
|
Keith Browne [email protected]
|
||||||
Ken Moffat [email protected]
|
Ken Moffat [email protected]
|
||||||
Kiyoshi Kanazawa [email protected]
|
Kiyoshi Kanazawa [email protected]
|
||||||
|
Lars Maier [email protected]
|
||||||
|
László Várady [email protected]
|
||||||
Laurent Mascherpa [email protected]
|
Laurent Mascherpa [email protected]
|
||||||
Lie Yan [email protected]
|
Lie Yan [email protected]
|
||||||
Magnus Fromreide [email protected]
|
Magnus Fromreide [email protected]
|
||||||
Marc Autret [email protected]
|
Marc Autret [email protected]
|
||||||
Marc Mendiola [email protected]
|
Marc Mendiola [email protected]
|
||||||
|
Marc Schönefeld [email protected]
|
||||||
Mark Boyall [email protected]
|
Mark Boyall [email protected]
|
||||||
Martin Jacobs [email protected]
|
Martin Jacobs [email protected]
|
||||||
Martin Mokrejs [email protected]
|
Martin Mokrejs [email protected]
|
||||||
@@ -113,17 +125,21 @@ Mike Sullivan [email protected]
|
|||||||
Nate Guerin [email protected]
|
Nate Guerin [email protected]
|
||||||
Neil Booth [email protected]
|
Neil Booth [email protected]
|
||||||
Nelson H. F. Beebe [email protected]
|
Nelson H. F. Beebe [email protected]
|
||||||
|
neok m4700 [email protected]
|
||||||
Nick Bowler [email protected]
|
Nick Bowler [email protected]
|
||||||
Nicolas Bedon [email protected]
|
Nicolas Bedon [email protected]
|
||||||
Nicolas Burrus [email protected]
|
Nicolas Burrus [email protected]
|
||||||
Nicolas Tisserand [email protected]
|
Nicolas Tisserand [email protected]
|
||||||
|
Nikki Valen [email protected]
|
||||||
Noah Friedman [email protected]
|
Noah Friedman [email protected]
|
||||||
Odd Arild Olsen [email protected]
|
Odd Arild Olsen [email protected]
|
||||||
Oleg Smolsky [email protected]
|
Oleg Smolsky [email protected]
|
||||||
Oleksii Taran [email protected]
|
Oleksii Taran [email protected]
|
||||||
|
Oliver Mangold [email protected]
|
||||||
Paolo Bonzini [email protected]
|
Paolo Bonzini [email protected]
|
||||||
Paolo Simone Gasparello [email protected]
|
Paolo Simone Gasparello [email protected]
|
||||||
Pascal Bart [email protected]
|
Pascal Bart [email protected]
|
||||||
|
Patrice Dumas [email protected]
|
||||||
Paul Eggert [email protected]
|
Paul Eggert [email protected]
|
||||||
Paul Hilfinger [email protected]
|
Paul Hilfinger [email protected]
|
||||||
Per Allansson [email protected]
|
Per Allansson [email protected]
|
||||||
@@ -162,28 +178,39 @@ Sum Wu [email protected]
|
|||||||
Théophile Ranquet [email protected]
|
Théophile Ranquet [email protected]
|
||||||
Thiru Ramakrishnan [email protected]
|
Thiru Ramakrishnan [email protected]
|
||||||
Thomas Jahns [email protected]
|
Thomas Jahns [email protected]
|
||||||
|
Thomas Petazzoni [email protected]
|
||||||
Tim Josling [email protected]
|
Tim Josling [email protected]
|
||||||
Tim Landscheidt [email protected]
|
Tim Landscheidt [email protected]
|
||||||
Tim Van Holder [email protected]
|
Tim Van Holder [email protected]
|
||||||
Tobias Frost [email protected]
|
Tobias Frost [email protected]
|
||||||
|
Todd Freed [email protected]
|
||||||
|
Tom Kramer [email protected]
|
||||||
Tom Lane [email protected]
|
Tom Lane [email protected]
|
||||||
Tom Tromey [email protected]
|
Tom Tromey [email protected]
|
||||||
|
Tomasz Kłoczko [email protected]
|
||||||
Tommy Nordgren [email protected]
|
Tommy Nordgren [email protected]
|
||||||
Troy A. Johnson [email protected]
|
Troy A. Johnson [email protected]
|
||||||
Tys Lefering [email protected]
|
Tys Lefering [email protected]
|
||||||
|
Uxio Prego [email protected]
|
||||||
Valentin Tolmer [email protected]
|
Valentin Tolmer [email protected]
|
||||||
|
wcventure [email protected]
|
||||||
Victor Khomenko [email protected]
|
Victor Khomenko [email protected]
|
||||||
|
Victor Zverovich [email protected]
|
||||||
Vin Shelton [email protected]
|
Vin Shelton [email protected]
|
||||||
W.C.A. Wijngaards [email protected]
|
W.C.A. Wijngaards [email protected]
|
||||||
Wayne Green [email protected]
|
Wayne Green [email protected]
|
||||||
Wei Song [email protected]
|
Wei Song [email protected]
|
||||||
Wojciech Polak [email protected]
|
Wojciech Polak [email protected]
|
||||||
Wolfgang S. Kechel [email protected]
|
Wolfgang S. Kechel [email protected]
|
||||||
|
Wolfgang Thaller [email protected]
|
||||||
Wolfram Wagner [email protected]
|
Wolfram Wagner [email protected]
|
||||||
Wwp [email protected]
|
Wwp [email protected]
|
||||||
xolodho [email protected]
|
xolodho [email protected]
|
||||||
|
Yuichiro Kaneko [email protected]
|
||||||
Zack Weinberg [email protected]
|
Zack Weinberg [email protected]
|
||||||
|
江 祖铭 [email protected]
|
||||||
長田偉伸 [email protected]
|
長田偉伸 [email protected]
|
||||||
|
马俊 [email protected]
|
||||||
|
|
||||||
Many people are not named here because we lost track of them. We
|
Many people are not named here because we lost track of them. We
|
||||||
thank them! Please, help us keeping this list up to date.
|
thank them! Please, help us keeping this list up to date.
|
||||||
@@ -195,7 +222,7 @@ End:
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2000-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2000-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Parser Generator.
|
This file is part of Bison, the GNU Parser Generator.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,108 @@
|
|||||||
* Short term
|
* Bison 3.6
|
||||||
** yacc.c
|
** doc
|
||||||
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
|
I feel its ugly to use the GNU style to declare functions in the doc. It
|
||||||
than duplicating it.
|
generates tons of white space in the page, and may contribute to bad page
|
||||||
|
breaks.
|
||||||
|
|
||||||
|
Also, we seem to teach YYPRINT very early on, although it should be
|
||||||
|
considered deprecated: %printer is superior.
|
||||||
|
|
||||||
|
** improve syntax errors (UTF-8, internationalization)
|
||||||
|
Bison depends on the current locale. For instance:
|
||||||
|
|
||||||
|
%define parse.error verbose
|
||||||
|
%code top {
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
void yyerror(const char* msg) { fprintf(stderr, "%s\n", msg); }
|
||||||
|
int yylex() { return 0; }
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
exp: "↦" | "🎅🐃" | '\n'
|
||||||
|
%%
|
||||||
|
int main() { return yyparse(); }
|
||||||
|
|
||||||
|
gives different results with/without LC_ALL=C.
|
||||||
|
|
||||||
|
$ LC_ALL=C /opt/local/bin/bison /tmp/mangle.y -o ascii.c
|
||||||
|
$ /opt/local/bin/bison /tmp/mangle.y -o utf8.c
|
||||||
|
$ diff -u ascii.c utf8.c -I#line
|
||||||
|
--- ascii.c 2019-01-12 08:15:35.878010093 +0100
|
||||||
|
+++ utf8.c 2019-01-12 08:15:38.856495929 +0100
|
||||||
|
@@ -415,9 +415,8 @@
|
||||||
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
|
static const char *const yytname[] =
|
||||||
|
{
|
||||||
|
- "$end", "error", "$undefined", "\"\\342\\206\\246\"",
|
||||||
|
- "\"\\360\\237\\216\\205\\360\\237\\220\\203\"", "'\\n'", "$accept",
|
||||||
|
- "exp", YY_NULLPTR
|
||||||
|
+ "$end", "error", "$undefined", "\"↦\"", "\"🎅🐃\"", "'\\n'",
|
||||||
|
+ "$accept", "exp", YY_NULLPTR
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
$ gcc ascii.c -o ascii && ./ascii
|
||||||
|
syntax error, unexpected $end, expecting "\342\206\246" or "\360\237\216\205\360\237\220\203" or '\n'
|
||||||
|
$ gcc utf8.c -o utf8 && ./utf8
|
||||||
|
syntax error, unexpected $end, expecting ↦ or 🎅🐃 or '\n'
|
||||||
|
|
||||||
|
|
||||||
|
While at it, we should stop using "$end" by default, in favor of "end of
|
||||||
|
file", or "end of input", whatever. See how lalr1.java does that.
|
||||||
|
|
||||||
|
** consistency
|
||||||
|
token vs terminal, variable vs non terminal.
|
||||||
|
|
||||||
|
** Stop indentation in diagnostics
|
||||||
|
Before Bison 2.7, we printed "flatly" the dependencies in long diagnostics:
|
||||||
|
|
||||||
|
input.y:2.7-12: %type redeclaration for exp
|
||||||
|
input.y:1.7-12: previous declaration
|
||||||
|
|
||||||
|
In Bison 2.7, we indented them
|
||||||
|
|
||||||
|
input.y:2.7-12: error: %type redeclaration for exp
|
||||||
|
input.y:1.7-12: previous declaration
|
||||||
|
|
||||||
|
Later we quoted the source in the diagnostics, and today we have:
|
||||||
|
|
||||||
|
/tmp/foo.y:1.12-14: warning: symbol FOO redeclared [-Wother]
|
||||||
|
1 | %token FOO FOO
|
||||||
|
| ^~~
|
||||||
|
/tmp/foo.y:1.8-10: previous declaration
|
||||||
|
1 | %token FOO FOO
|
||||||
|
| ^~~
|
||||||
|
|
||||||
|
The indentation is no longer helping. We should probably get rid of it, or
|
||||||
|
maybe keep it only when -fno-caret. GCC displays this as a "note":
|
||||||
|
|
||||||
|
$ g++-mp-9 -Wall /tmp/foo.c -c
|
||||||
|
/tmp/foo.c:1:10: error: redefinition of 'int foo'
|
||||||
|
1 | int foo, foo;
|
||||||
|
| ^~~
|
||||||
|
/tmp/foo.c:1:5: note: 'int foo' previously declared here
|
||||||
|
1 | int foo, foo;
|
||||||
|
| ^~~
|
||||||
|
|
||||||
|
Likewise for Clang, contrary to what I believed (because "note:" is written
|
||||||
|
in black, so it doesn't show in my terminal :-)
|
||||||
|
|
||||||
|
$ clang++-mp-8.0 -Wall /tmp/foo.c -c
|
||||||
|
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
|
||||||
|
/tmp/foo.c:1:10: error: redefinition of 'foo'
|
||||||
|
int foo, foo;
|
||||||
|
^
|
||||||
|
/tmp/foo.c:1:5: note: previous definition is here
|
||||||
|
int foo, foo;
|
||||||
|
^
|
||||||
|
1 error generated.
|
||||||
|
|
||||||
|
See also the item "Complaint submessage indentation" below.
|
||||||
|
|
||||||
|
** api.token.raw
|
||||||
|
Maybe we should exhibit the YYUNDEFTOK token. It could also be assigned a
|
||||||
|
semantic value so that yyerror could be used to report invalid lexemes.
|
||||||
|
See also the item "$undefined" below.
|
||||||
|
|
||||||
** C++
|
** C++
|
||||||
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
||||||
@@ -9,11 +110,126 @@ itself uses int (for yylen for instance), yet stack is based on size_t.
|
|||||||
|
|
||||||
Maybe locations should also move to ints.
|
Maybe locations should also move to ints.
|
||||||
|
|
||||||
** C
|
Paul Eggert already covered most of this. But before publishing these
|
||||||
Introduce state_type rather than spreading yytype_int16 everywhere?
|
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".
|
||||||
|
|
||||||
** glr.c
|
* Bison 3.7
|
||||||
yyspaceLeft should probably be a pointer diff.
|
** 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.
|
||||||
|
|
||||||
|
- push parsers: glr.cc, lalr1.cc
|
||||||
|
- ielr: C++ and Java
|
||||||
|
- glr: Java
|
||||||
|
- token constructors: Java and C
|
||||||
|
|
||||||
|
* Bugs
|
||||||
|
** Autotest has quotation issues
|
||||||
|
tests/input.at:1730:AT_SETUP([%define errors])
|
||||||
|
|
||||||
|
->
|
||||||
|
|
||||||
|
$ ./tests/testsuite -l | grep errors | sed q
|
||||||
|
38: input.at:1730 errors
|
||||||
|
|
||||||
|
* Short term
|
||||||
|
** Get rid of YYPRINT and b4_toknum
|
||||||
|
Besides yytoknum is wrong when api.token.raw is defined.
|
||||||
|
|
||||||
|
** Better design for diagnostics
|
||||||
|
The current implementation of diagnostics is adhoc, it grew organically. It
|
||||||
|
works as a series of calls to several functions, with dependency of the
|
||||||
|
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
|
||||||
|
|
||||||
** Graphviz display code thoughts
|
** Graphviz display code thoughts
|
||||||
The code for the --graph option is over two files: print_graph, and
|
The code for the --graph option is over two files: print_graph, and
|
||||||
@@ -34,9 +250,6 @@ Little effort seems to have been given to factoring these files and their
|
|||||||
rint{,-xml} counterpart. We would very much like to re-use the pretty format
|
rint{,-xml} counterpart. We would very much like to re-use the pretty format
|
||||||
of states from .output for the graphs, etc.
|
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?
|
Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
|
||||||
|
|
||||||
** push-parser
|
** push-parser
|
||||||
@@ -70,11 +283,6 @@ back-ported.
|
|||||||
yytoken = yytranslate_ (yychar);
|
yytoken = yytranslate_ (yychar);
|
||||||
|
|
||||||
|
|
||||||
** stack.hh
|
|
||||||
Get rid of it. The original idea is nice, but actually it makes
|
|
||||||
the code harder to follow, and uselessly different from the other
|
|
||||||
skeletons.
|
|
||||||
|
|
||||||
** Get rid of fake #lines [Bison: ...]
|
** Get rid of fake #lines [Bison: ...]
|
||||||
Possibly as simple as checking whether the column number is nonnegative.
|
Possibly as simple as checking whether the column number is nonnegative.
|
||||||
|
|
||||||
@@ -98,10 +306,14 @@ class in the printers/destructors, which is not good for an operator<<
|
|||||||
since it is no longer bound to a particular parser, it's just a
|
since it is no longer bound to a particular parser, it's just a
|
||||||
(standalone symbol).
|
(standalone symbol).
|
||||||
|
|
||||||
** Rename LR0.cc
|
|
||||||
as lr0.cc, why upper case?
|
|
||||||
|
|
||||||
* Various
|
* Various
|
||||||
|
** 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
|
** YYERRCODE
|
||||||
Defined to 256, but not used, not documented. Probably the token
|
Defined to 256, but not used, not documented. Probably the token
|
||||||
number for the error token, which POSIX wants to be 256, but which
|
number for the error token, which POSIX wants to be 256, but which
|
||||||
@@ -171,10 +383,21 @@ other improvements and also made it faster (probably because memory
|
|||||||
management is performed once instead of three times). I suggest that
|
management is performed once instead of three times). I suggest that
|
||||||
we do the same in yacc.c.
|
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
|
** yysyntax_error
|
||||||
The code bw glr.c and yacc.c is really alike, we can certainly factor
|
The code bw glr.c and yacc.c is really alike, we can certainly factor
|
||||||
some parts.
|
some parts.
|
||||||
|
|
||||||
|
This should be worked on when we also address the expected improvements for
|
||||||
|
error generation (e.g., i18n).
|
||||||
|
|
||||||
|
|
||||||
* Report
|
* Report
|
||||||
|
|
||||||
@@ -185,7 +408,7 @@ grammars she is working on. We should probably also include some
|
|||||||
information about the variables (I'm not sure for instance we even
|
information about the variables (I'm not sure for instance we even
|
||||||
specify what LR variant was used).
|
specify what LR variant was used).
|
||||||
|
|
||||||
** GLR
|
** GLR
|
||||||
How would Paul like to display the conflicted actions? In particular,
|
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
|
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
|
part of $default. Should we make the two reductions explicit, or just
|
||||||
@@ -207,13 +430,33 @@ Provide better assistance for understanding the conflicts by providing
|
|||||||
a sample text exhibiting the (LALR) ambiguity. See the paper from
|
a sample text exhibiting the (LALR) ambiguity. See the paper from
|
||||||
DeRemer and Penello: they already provide the algorithm.
|
DeRemer and Penello: they already provide the algorithm.
|
||||||
|
|
||||||
** Statically check for potential ambiguities in GLR grammars. See
|
** Statically check for potential ambiguities in GLR grammars
|
||||||
<http://www.i3s.unice.fr/~schmitz/papers.html#expamb> for an approach.
|
See <http://www.lsv.fr/~schmitz/pub/expamb.pdf> for an approach.
|
||||||
|
An Experimental Ambiguity Detection Tool ∗ Sylvain Schmitz
|
||||||
|
LORIA, INRIA Nancy - Grand Est, Nancy, France
|
||||||
|
|
||||||
* Extensions
|
* Extensions
|
||||||
** Multiple start symbols
|
** 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
|
** Better error messages
|
||||||
The users are not provided with enough tools to forge their error messages.
|
The users are not provided with enough tools to forge their error messages.
|
||||||
@@ -231,6 +474,12 @@ should make this reasonably easy to implement.
|
|||||||
Bruce Mardle <[email protected]>
|
Bruce Mardle <[email protected]>
|
||||||
https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
|
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
|
** Push parsers
|
||||||
There is demand for push parsers in Java and C++. And GLR I guess.
|
There is demand for push parsers in Java and C++. And GLR I guess.
|
||||||
|
|
||||||
@@ -257,6 +506,10 @@ must be in the scanner: we must not parse what is in a switched off
|
|||||||
part of %if. Akim Demaille thinks it should be in the parser, so as
|
part of %if. Akim Demaille thinks it should be in the parser, so as
|
||||||
to avoid falling into another CPP mistake.
|
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
|
** XML Output
|
||||||
There are couple of available extensions of Bison targeting some XML
|
There are couple of available extensions of Bison targeting some XML
|
||||||
output. Some day we should consider including them. One issue is
|
output. Some day we should consider including them. One issue is
|
||||||
@@ -276,30 +529,8 @@ XML output for GNU Bison
|
|||||||
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
|
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
|
||||||
http://www.cs.cornell.edu/andru/papers/cupex/
|
http://www.cs.cornell.edu/andru/papers/cupex/
|
||||||
|
|
||||||
* Unit rules
|
Andrew Myers and Vincent Imbimbo are working on this item, see
|
||||||
Maybe we could expand unit rules, i.e., transform
|
https://github.com/akimd/bison/issues/12
|
||||||
|
|
||||||
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?
|
|
||||||
|
|
||||||
* Coding system independence
|
* Coding system independence
|
||||||
Paul notes:
|
Paul notes:
|
||||||
@@ -318,7 +549,7 @@ Paul notes:
|
|||||||
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
||||||
the source code. This should get fixed.
|
the source code. This should get fixed.
|
||||||
|
|
||||||
* Broken options ?
|
* Broken options?
|
||||||
** %token-table
|
** %token-table
|
||||||
** Skeleton strategy
|
** Skeleton strategy
|
||||||
Must we keep %token-table?
|
Must we keep %token-table?
|
||||||
@@ -330,10 +561,7 @@ It is unfortunate that there is a total order for precedence. It
|
|||||||
makes it impossible to have modular precedence information. We should
|
makes it impossible to have modular precedence information. We should
|
||||||
move to partial orders (sounds like series/parallel orders to me).
|
move to partial orders (sounds like series/parallel orders to me).
|
||||||
|
|
||||||
** RR conflicts
|
This is a prerequisite for modules.
|
||||||
See if we can use precedence between rules to solve RR conflicts. See
|
|
||||||
what POSIX says.
|
|
||||||
|
|
||||||
|
|
||||||
* $undefined
|
* $undefined
|
||||||
From Hans:
|
From Hans:
|
||||||
@@ -344,20 +572,6 @@ addition to the $undefined value.
|
|||||||
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
||||||
|
|
||||||
|
|
||||||
* Default Action
|
|
||||||
From Hans:
|
|
||||||
- For use with my C++ parser, I transported the "switch (yyn)" statement
|
|
||||||
that Bison writes to the bison.simple skeleton file. This way, I can remove
|
|
||||||
the current default rule $$ = $1 implementation, which causes a double
|
|
||||||
assignment to $$ which may not be OK under C++, replacing it with a
|
|
||||||
"default:" part within the switch statement.
|
|
||||||
|
|
||||||
Note that the default rule $$ = $1, when typed, is perfectly OK under C,
|
|
||||||
but in the C++ implementation I made, this rule is different from
|
|
||||||
$<type_name>$ = $<type_name>1. I therefore think that one should implement
|
|
||||||
a Bison option where every typed default rule is explicitly written out
|
|
||||||
(same typed ruled can of course be grouped together).
|
|
||||||
|
|
||||||
* Pre and post actions.
|
* Pre and post actions.
|
||||||
From: Florian Krohm <[email protected]>
|
From: Florian Krohm <[email protected]>
|
||||||
Subject: YYACT_EPILOGUE
|
Subject: YYACT_EPILOGUE
|
||||||
@@ -389,23 +603,6 @@ to bison. If you're interested, I'll work on a patch.
|
|||||||
* Better graphics
|
* Better graphics
|
||||||
Equip the parser with a means to create the (visual) parse tree.
|
Equip the parser with a means to create the (visual) parse tree.
|
||||||
|
|
||||||
* Complaint submessage indentation.
|
|
||||||
We already have an implementation that works fairly well for named
|
|
||||||
reference messages, but it would be nice to use it consistently for all
|
|
||||||
submessages from Bison. For example, the "previous definition"
|
|
||||||
submessage or the list of correct values for a %define variable might
|
|
||||||
look better with indentation.
|
|
||||||
|
|
||||||
However, the current implementation makes the assumption that the
|
|
||||||
location printed on the first line is not usually much shorter than the
|
|
||||||
locations printed on the submessage lines that follow. That assumption
|
|
||||||
may not hold true as often for some kinds of submessages especially if
|
|
||||||
we ever support multiple grammar files.
|
|
||||||
|
|
||||||
Here's a proposal for how a new implementation might look:
|
|
||||||
|
|
||||||
http://lists.gnu.org/archive/html/bison-patches/2009-09/msg00086.html
|
|
||||||
|
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
@@ -415,8 +612,8 @@ End:
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2001-2004, 2006, 2008-2015, 2018 Free Software Foundation,
|
Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2020 Free Software
|
||||||
Inc.
|
Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2018-10-13.05; # UTC
|
scriptversion=2019-01-04.17; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
|
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -166,7 +166,7 @@ bootstrap_epilogue() { :; }
|
|||||||
# specified directory. Fill in the first %s with the destination
|
# specified directory. Fill in the first %s with the destination
|
||||||
# directory and the second with the domain name.
|
# directory and the second with the domain name.
|
||||||
po_download_command_format=\
|
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/"
|
https://translationproject.org/latest/%s/"
|
||||||
|
|
||||||
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
||||||
@@ -963,6 +963,16 @@ fi
|
|||||||
bootstrap_post_import_hook \
|
bootstrap_post_import_hook \
|
||||||
|| die "bootstrap_post_import_hook failed"
|
|| die "bootstrap_post_import_hook failed"
|
||||||
|
|
||||||
|
# Don't proceed if there are uninitialized submodules. In particular,
|
||||||
|
# the next step will remove dangling links, which might be links into
|
||||||
|
# uninitialized submodules.
|
||||||
|
#
|
||||||
|
# Uninitialized submodules are listed with an initial dash.
|
||||||
|
if $use_git && git submodule | grep '^-' >/dev/null; then
|
||||||
|
die "some git submodules are not initialized. " \
|
||||||
|
"Run 'git submodule init' and bootstrap again."
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
||||||
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
||||||
# The following requires GNU find 4.2.3 or newer. Considering the usual
|
# The following requires GNU find 4.2.3 or newer. Considering the usual
|
||||||
|
|||||||
+28
-25
@@ -1,6 +1,6 @@
|
|||||||
# Bootstrap configuration.
|
# Bootstrap configuration.
|
||||||
|
|
||||||
# Copyright (C) 2006-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2006-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,16 +17,21 @@
|
|||||||
|
|
||||||
# gnulib modules used by this package.
|
# gnulib modules used by this package.
|
||||||
gnulib_modules='
|
gnulib_modules='
|
||||||
argmatch assert
|
argmatch array-list assert assure
|
||||||
|
bitsetv
|
||||||
calloc-posix close closeout config-h c-strcase
|
calloc-posix close closeout config-h c-strcase
|
||||||
configmake
|
configmake
|
||||||
dirname
|
dirname
|
||||||
error extensions fdl fopen-safer
|
error extensions
|
||||||
|
fdl fopen-safer fstrcmp
|
||||||
getopt-gnu
|
getopt-gnu
|
||||||
gettext git-version-gen gitlog-to-changelog
|
gettext-h git-version-gen gitlog-to-changelog
|
||||||
gpl-3.0 hash inttypes isnan javacomp-script
|
gpl-3.0 intprops inttypes isnan javacomp-script
|
||||||
javaexec-script ldexpl malloc-gnu
|
javaexec-script
|
||||||
mbswidth
|
ldexpl
|
||||||
|
libtextstyle-optional
|
||||||
|
malloc-gnu
|
||||||
|
mbfile mbswidth
|
||||||
non-recursive-gnulib-prefix-hack
|
non-recursive-gnulib-prefix-hack
|
||||||
obstack
|
obstack
|
||||||
obstack-printf
|
obstack-printf
|
||||||
@@ -34,14 +39,20 @@ gnulib_modules='
|
|||||||
quote quotearg
|
quote quotearg
|
||||||
readme-release
|
readme-release
|
||||||
realloc-posix
|
realloc-posix
|
||||||
|
relocatable-prog relocatable-script
|
||||||
|
rename
|
||||||
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
||||||
timevar
|
timevar
|
||||||
unistd unistd-safer unlink unlocked-io
|
unistd unistd-safer unlink unlocked-io
|
||||||
update-copyright unsetenv verify
|
update-copyright unsetenv verify
|
||||||
warnings
|
warnings
|
||||||
|
winsz-ioctl
|
||||||
|
winsz-termios
|
||||||
xalloc
|
xalloc
|
||||||
xalloc-die
|
xalloc-die
|
||||||
xconcat-filename
|
xconcat-filename
|
||||||
|
xhash
|
||||||
|
xlist
|
||||||
xmemdup0
|
xmemdup0
|
||||||
xstrndup
|
xstrndup
|
||||||
|
|
||||||
@@ -49,6 +60,8 @@ gnulib_modules='
|
|||||||
vsnprintf-posix vsprintf-posix
|
vsnprintf-posix vsprintf-posix
|
||||||
'
|
'
|
||||||
|
|
||||||
|
checkout_only_file=README-hacking.md
|
||||||
|
|
||||||
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
||||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||||
--from-code=UTF-8\\\
|
--from-code=UTF-8\\\
|
||||||
@@ -61,24 +74,7 @@ XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
|||||||
--keyword=YY_ \\\
|
--keyword=YY_ \\\
|
||||||
'
|
'
|
||||||
|
|
||||||
# Gettext supplies these files, but we don't need them since
|
gnulib_tool_option_extras='--symlink --conditional-dependencies --makefile-name=gnulib.mk --po-base=gnulib-po --po-domain=bison'
|
||||||
# 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 --makefile-name=gnulib.mk'
|
|
||||||
|
|
||||||
bootstrap_post_import_hook()
|
bootstrap_post_import_hook()
|
||||||
{
|
{
|
||||||
@@ -96,6 +92,13 @@ bootstrap_epilogue()
|
|||||||
touch src/parse-gram.[ch]
|
touch src/parse-gram.[ch]
|
||||||
|
|
||||||
perl -pi -e "s/\@PACKAGE\@/$package/g" README-release
|
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
|
# Keep our bootstrap script in sync with gnulib's. If we ever need to
|
||||||
|
|||||||
@@ -23,3 +23,8 @@
|
|||||||
/useless-if-before-free
|
/useless-if-before-free
|
||||||
/vc-list-files
|
/vc-list-files
|
||||||
/ylwrap
|
/ylwrap
|
||||||
|
/config.libpath
|
||||||
|
/install-reloc
|
||||||
|
/reloc-ldflags
|
||||||
|
/relocatable.sh.in
|
||||||
|
/libtool-reloc
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+36
-11
@@ -1,5 +1,24 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
|
|
||||||
|
# Generate a release announcement message.
|
||||||
|
|
||||||
|
# Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Written by Akimn Demaille.
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use 5.005;
|
use 5.005;
|
||||||
use strict;
|
use strict;
|
||||||
@@ -12,7 +31,7 @@ while (<STDIN>)
|
|||||||
{
|
{
|
||||||
if (/^\s* # Initial spaces.
|
if (/^\s* # Initial spaces.
|
||||||
(?:(-\w),\s+)? # $1: $short: Possible short option.
|
(?:(-\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.
|
(\[?) # $3: $opt: '[' iff the argument is optional.
|
||||||
(?:=(\S+))? # $4: $arg: Possible argument name.
|
(?:=(\S+))? # $4: $arg: Possible argument name.
|
||||||
\s # Spaces.
|
\s # Spaces.
|
||||||
@@ -32,7 +51,6 @@ while (<STDIN>)
|
|||||||
# if $opt, $arg contains the closing ].
|
# if $opt, $arg contains the closing ].
|
||||||
substr ($arg, -1) = ''
|
substr ($arg, -1) = ''
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
$arg =~ s/^=//;
|
|
||||||
$arg = lc ($arg);
|
$arg = lc ($arg);
|
||||||
my $dir_arg = $arg;
|
my $dir_arg = $arg;
|
||||||
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
|
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
|
||||||
@@ -48,7 +66,11 @@ while (<STDIN>)
|
|||||||
# are strings and have the same syntax as on the command line.
|
# are strings and have the same syntax as on the command line.
|
||||||
if ($dir_arg eq 'name[=value]')
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -68,12 +90,15 @@ while (<STDIN>)
|
|||||||
my $sep = '';
|
my $sep = '';
|
||||||
foreach my $long (sort keys %option)
|
foreach my $long (sort keys %option)
|
||||||
{
|
{
|
||||||
# Avoid trailing spaces.
|
# Couldn't find a means to escape @ in the format (for @item, @tab), so
|
||||||
print $sep;
|
# pass it as a literal to print.
|
||||||
$sep = "\n";
|
format STDOUT =
|
||||||
print '@item @option{', $long, "}\n\@tab";
|
@item @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @tab @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @tab @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||||
print ' @option{', $option{$long}, '}' if $option{$long};
|
{
|
||||||
print "\n\@tab";
|
'@', '@option{' . $long . '}',
|
||||||
print ' @code{', $directive{$long}, '}' if $directive{$long};
|
'@', $option{$long} ? ('@option{' . $option{$long} . '}') : '',
|
||||||
print "\n";
|
'@', $directive{$long} ? ('@code{' . $directive{$long} . '}') : ''
|
||||||
|
}
|
||||||
|
.
|
||||||
|
write;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2000-2015, 2018 Free Software Foundation, Inc.
|
## Copyright (C) 2000-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# Update b4_copyright invocations or b4_copyright_years definitions to
|
# Update b4_copyright invocations or b4_copyright_years definitions to
|
||||||
# include the current year.
|
# include the current year.
|
||||||
|
|
||||||
# Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2009-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
|
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
|
||||||
|
|
||||||
# Copyright (C) 2010-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2010-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
Executable
+115
@@ -0,0 +1,115 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
|
||||||
|
# Update expectations in an Autotest test suite.
|
||||||
|
|
||||||
|
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Written by Akim Demaille.
|
||||||
|
|
||||||
|
# usage:
|
||||||
|
#
|
||||||
|
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
|
||||||
|
#
|
||||||
|
# from your source tree.
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def getargs():
|
||||||
|
p = argparse.ArgumentParser(description='Update test cases.')
|
||||||
|
opt = p.add_argument
|
||||||
|
opt('logs', metavar='log', nargs='+', type=str, default=None,
|
||||||
|
help='log files to process')
|
||||||
|
opt('-v', '--verbose', action='store_true',
|
||||||
|
help='Be verbose')
|
||||||
|
return p.parse_args()
|
||||||
|
|
||||||
|
args = getargs()
|
||||||
|
subst = dict()
|
||||||
|
|
||||||
|
|
||||||
|
def trace(*args_):
|
||||||
|
if args.verbose:
|
||||||
|
print(*args_)
|
||||||
|
|
||||||
|
|
||||||
|
def contents(file):
|
||||||
|
'''The contents of a file.'''
|
||||||
|
trace(file)
|
||||||
|
f = open(file)
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
def diff_to_re(match):
|
||||||
|
'''Convert a portion of patch into a regex substitution to perform.
|
||||||
|
No longer used, we now use the expected/effective parts.
|
||||||
|
'''
|
||||||
|
frm = []
|
||||||
|
to = []
|
||||||
|
is_diff = False
|
||||||
|
for l in match.group(1).splitlines():
|
||||||
|
print(l)
|
||||||
|
# t in [-+ ]
|
||||||
|
t = l[0]
|
||||||
|
l = l[1:]
|
||||||
|
if t in ['-', ' ']:
|
||||||
|
is_diff = True
|
||||||
|
frm.append(l)
|
||||||
|
if t in ['+', ' ']:
|
||||||
|
is_diff = True
|
||||||
|
to.append(l)
|
||||||
|
if is_diff:
|
||||||
|
frm = "\n".join(frm)
|
||||||
|
to = "\n".join(to)
|
||||||
|
subst[frm] = to
|
||||||
|
|
||||||
|
|
||||||
|
def update(at_file, logfile):
|
||||||
|
test = contents(at_file)
|
||||||
|
if os.path.isfile(logfile):
|
||||||
|
trace("LOG: ", logfile)
|
||||||
|
l = contents(logfile)
|
||||||
|
trace("LOG: ", l)
|
||||||
|
global subst
|
||||||
|
subst = {}
|
||||||
|
re.sub(r'(?:^@@.*\n)((?:^[-+ ].*\n)+)',
|
||||||
|
diff_to_re, l, flags = re.MULTILINE)
|
||||||
|
print(subst)
|
||||||
|
if subst:
|
||||||
|
# Turn "subst{frm} -> to" into a large RE.
|
||||||
|
frm = '|'.join([re.escape(x) for x in subst])
|
||||||
|
trace("FROM:", frm)
|
||||||
|
test = re.sub("(" + frm + ")",
|
||||||
|
lambda m: subst[m.group(1)],
|
||||||
|
test, flags=re.MULTILINE)
|
||||||
|
open(at_file, 'w').write(test)
|
||||||
|
|
||||||
|
|
||||||
|
def process(logfile):
|
||||||
|
log = contents(logfile)
|
||||||
|
# Look for the file to update.
|
||||||
|
m = re.search(r'^\d+\. ([-\w]+\.at):\d+: ', log, re.MULTILINE)
|
||||||
|
if not m:
|
||||||
|
trace("no diff found:", logfile)
|
||||||
|
return
|
||||||
|
at_file = 'tests/' + m.group(1)
|
||||||
|
print(at_file)
|
||||||
|
update(at_file, logfile)
|
||||||
|
|
||||||
|
for logfile in args.logs:
|
||||||
|
trace("FILE:", logfile)
|
||||||
|
process(logfile)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
## Customize maint.mk -*- makefile -*-
|
## Customize maint.mk -*- makefile -*-
|
||||||
## Copyright (C) 2008-2015, 2018 Free Software Foundation, Inc.
|
## Copyright (C) 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,6 +26,9 @@ regen: _version
|
|||||||
manual_title = The Yacc-compatible Parser Generator
|
manual_title = The Yacc-compatible Parser Generator
|
||||||
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
||||||
|
|
||||||
|
# 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
|
# It's useful to run maintainer-check* targets during development, but we
|
||||||
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
||||||
# override the _is-dist-target from GNUmakefile so that maintainer-check*
|
# override the _is-dist-target from GNUmakefile so that maintainer-check*
|
||||||
@@ -60,18 +63,6 @@ update-copyright-env = \
|
|||||||
## More syntax-checks. ##
|
## 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.
|
# Indent only with spaces.
|
||||||
# Taken from Coreutils.
|
# Taken from Coreutils.
|
||||||
sc_prohibit_tab_based_indentation:
|
sc_prohibit_tab_based_indentation:
|
||||||
@@ -156,23 +147,29 @@ sc_space_before_open_paren:
|
|||||||
## syntax-checks exceptions. ##
|
## syntax-checks exceptions. ##
|
||||||
## -------------------------- ##
|
## -------------------------- ##
|
||||||
|
|
||||||
|
# po-check: we use gnulib-po, so we don't need/want them in our POTFILE.
|
||||||
|
generated_files =
|
||||||
|
|
||||||
exclude = \
|
exclude = \
|
||||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
$(call exclude, \
|
|
||||||
bindtextdomain=^lib/main.c$$ \
|
$(call exclude, \
|
||||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
program_name=^lib/main.c$$ \
|
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
||||||
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
po_check=(^po/POTFILES.in|.md)$$ \
|
||||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
program_name=^lib/main.c$$ \
|
||||||
prohibit_always_true_header_tests=^djgpp/subpipe.h$$ \
|
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||||
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
|
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||||
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
|
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
prohibit_strcmp=^doc/bison\.texi|examples|tests/local\.at$$ \
|
||||||
space_before_open_paren=^(data/|djgpp/) \
|
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^\.git|tests/input.at|Makefile$$ \
|
||||||
two_space_separator_in_usage=^(bootstrap|build-aux/install-icc.sh) \
|
require_config_h=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||||
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
require_config_h_first=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||||
|
space_before_open_paren=^data/skeletons/ \
|
||||||
|
two_space_separator_in_usage=^(bootstrap|build-aux/install-icc.sh) \
|
||||||
|
unmarked_diagnostics=^(doc/bison.texi$$|tests/c\+\+\.at$$) \
|
||||||
)
|
)
|
||||||
|
|||||||
+98
-20
@@ -1,6 +1,6 @@
|
|||||||
# Configure template for GNU Bison. -*-Autoconf-*-
|
# Configure template for GNU Bison. -*-Autoconf-*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2001-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,8 +26,10 @@ m4_pattern_allow([^BISON_USE_NLS$])
|
|||||||
|
|
||||||
AC_INIT([GNU Bison],
|
AC_INIT([GNU Bison],
|
||||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||||
[[email protected]])
|
[[email protected]],
|
||||||
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2018])
|
[],
|
||||||
|
[https://www.gnu.org/software/bison/])
|
||||||
|
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2020])
|
||||||
AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
|
AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
|
||||||
[The copyright year for this package])
|
[The copyright year for this package])
|
||||||
|
|
||||||
@@ -36,6 +38,9 @@ AC_CONFIG_MACRO_DIR([m4])
|
|||||||
|
|
||||||
# We use Automake 1.14's %D% and %C%.
|
# 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
|
# We want gnits strictness only when rolling a stable release. For
|
||||||
# release candidates, we use version strings like 2.4.3_rc1, but gnits
|
# 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
|
# doesn't like that, so we let the underscore disable gnits. Between
|
||||||
@@ -94,11 +99,47 @@ AC_ARG_ENABLE([gcc-warnings],
|
|||||||
[enable_gcc_warnings=no])
|
[enable_gcc_warnings=no])
|
||||||
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
||||||
if test "$enable_gcc_warnings" = yes; then
|
if test "$enable_gcc_warnings" = yes; then
|
||||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
|
# -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.
|
||||||
|
#
|
||||||
|
# ICC: -wr188
|
||||||
|
#
|
||||||
|
# 1669 warnings warnings_default =
|
||||||
|
# ../src/complain.c(318): error #188: enumerated type mixed with another type
|
||||||
|
# 1670 Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||||
|
# 1671 ^
|
||||||
|
# 1672
|
||||||
|
# 1673../src/complain.c(393): error #188: enumerated type mixed with another type
|
||||||
|
# 1674 warnings w = 1 << wbit;
|
||||||
|
# 1675 ^
|
||||||
|
#
|
||||||
|
# ICC: -wr3179
|
||||||
|
#
|
||||||
|
# char const *usefulness
|
||||||
|
# = rule_useless_in_grammar_p (&rules[r]) ? "useless-in-grammar"
|
||||||
|
# : rule_useless_in_parser_p (&rules[r]) ? "useless-in-parser"
|
||||||
|
# : "useful";
|
||||||
|
#
|
||||||
|
# gives
|
||||||
|
#
|
||||||
|
# error #3179: deprecated conversion of string literal to char* (should be const char*)
|
||||||
|
#
|
||||||
|
# ICC: -wr2259 (that's in C, in spite of what the error messages which seems to be about C++).
|
||||||
|
# error #2259: non-pointer conversion from "int" to "yybool={signed char}" may lose significant bits
|
||||||
|
# yybool yynormal YY_ATTRIBUTE_UNUSED = yystackp->yysplitPoint == YY_NULLPTR;
|
||||||
|
# ^
|
||||||
|
warn_common='-Wall -Wextra
|
||||||
|
-Wcast-align -Wchar-subscripts
|
||||||
-fparse-all-comments -Wdocumentation
|
-fparse-all-comments -Wdocumentation
|
||||||
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
|
-Wformat -Wimplicit-fallthrough -Wnull-dereference
|
||||||
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
-Wno-sign-compare -Wno-tautological-constant-out-of-range-compare
|
||||||
warn_cxx='-Wnoexcept'
|
-Wpointer-arith -Wshadow
|
||||||
|
-Wwrite-strings
|
||||||
|
-wr188 -wr2259 -wr3179'
|
||||||
|
warn_c='-Wbad-function-cast -Wstrict-prototypes'
|
||||||
|
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
|
||||||
|
-Wweak-vtables'
|
||||||
# Warnings for the test suite only.
|
# Warnings for the test suite only.
|
||||||
#
|
#
|
||||||
# -fno-color-diagnostics: Clang's use of colors in the error
|
# -fno-color-diagnostics: Clang's use of colors in the error
|
||||||
@@ -110,9 +151,11 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
# details for lalr1.cc.
|
# details for lalr1.cc.
|
||||||
warn_tests='-Wundef -pedantic -Wconversion
|
warn_tests='-Wundef -pedantic -Wconversion
|
||||||
-Wdeprecated -Wsign-compare -Wsign-conversion
|
-Wdeprecated -Wsign-compare -Wsign-conversion
|
||||||
|
-Wtautological-constant-out-of-range-compare
|
||||||
-fno-color-diagnostics
|
-fno-color-diagnostics
|
||||||
-Wno-keyword-macro'
|
-Wno-keyword-macro'
|
||||||
|
|
||||||
|
|
||||||
AC_LANG_PUSH([C])
|
AC_LANG_PUSH([C])
|
||||||
# Clang supports many of GCC's -W options, but only issues warnings
|
# Clang supports many of GCC's -W options, but only issues warnings
|
||||||
# on the ones it does not recognize. In that case, gl_WARN_ADD
|
# on the ones it does not recognize. In that case, gl_WARN_ADD
|
||||||
@@ -126,6 +169,11 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
# CFLAGS, and restore CFLAGS after the tests.
|
# CFLAGS, and restore CFLAGS after the tests.
|
||||||
save_CFLAGS=$CFLAGS
|
save_CFLAGS=$CFLAGS
|
||||||
gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS])
|
gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS])
|
||||||
|
# Accept this warning only if it is not too touchy (e.g., clang 3.3
|
||||||
|
# and 3.4).
|
||||||
|
gl_WARN_ADD([-Wunreachable-code], [WARN_CFLAGS],
|
||||||
|
[AC_LANG_PROGRAM([],
|
||||||
|
[[if (sizeof (long) < sizeof (int)) return 1;]])])
|
||||||
for i in $warn_common $warn_c;
|
for i in $warn_common $warn_c;
|
||||||
do
|
do
|
||||||
gl_WARN_ADD([$i], [WARN_CFLAGS])
|
gl_WARN_ADD([$i], [WARN_CFLAGS])
|
||||||
@@ -134,8 +182,6 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
|
|
||||||
# Warnings for the test suite, and maybe for bison if GCC is modern
|
# Warnings for the test suite, and maybe for bison if GCC is modern
|
||||||
# enough.
|
# enough.
|
||||||
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
|
|
||||||
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
|
|
||||||
test $lv_cv_gcc_pragma_push_works = yes &&
|
test $lv_cv_gcc_pragma_push_works = yes &&
|
||||||
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
||||||
|
|
||||||
@@ -147,6 +193,7 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
CFLAGS=$save_CFLAGS
|
CFLAGS=$save_CFLAGS
|
||||||
AC_LANG_POP([C])
|
AC_LANG_POP([C])
|
||||||
|
|
||||||
|
|
||||||
AC_LANG_PUSH([C++])
|
AC_LANG_PUSH([C++])
|
||||||
save_CXXFLAGS=$CXXFLAGS
|
save_CXXFLAGS=$CXXFLAGS
|
||||||
gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
|
gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
|
||||||
@@ -154,8 +201,21 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
do
|
do
|
||||||
gl_WARN_ADD([$i], [WARN_CXXFLAGS])
|
gl_WARN_ADD([$i], [WARN_CXXFLAGS])
|
||||||
done
|
done
|
||||||
|
# Accept this warning only if it is not too touchy (e.g., clang 3.3
|
||||||
|
# and 3.4).
|
||||||
|
gl_WARN_ADD([-Wunreachable-code], [WARN_CXXFLAGS],
|
||||||
|
[AC_LANG_PROGRAM([],
|
||||||
|
[[if (sizeof (long) < sizeof (int)) return 1;]])])
|
||||||
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
||||||
[AC_LANG_PROGRAM([], [nullptr])])
|
[AC_LANG_PROGRAM([], [nullptr])])
|
||||||
|
# Before GCC6, the pragmas don't work well enough to neutralize
|
||||||
|
# this warning.
|
||||||
|
gl_WARN_ADD([-Wuseless-cast], [WARN_CXXFLAGS],
|
||||||
|
[AC_LANG_PROGRAM([], [
|
||||||
|
#if defined __GNUC__ && ! defined __ICC && ! defined __clang__ && __GNUC__ < 6
|
||||||
|
syntax error
|
||||||
|
#endif
|
||||||
|
])])
|
||||||
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
||||||
# Warnings for the test suite only.
|
# Warnings for the test suite only.
|
||||||
for i in $warn_tests;
|
for i in $warn_tests;
|
||||||
@@ -176,19 +236,32 @@ BISON_C_COMPILER_POSIXLY_CORRECT
|
|||||||
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
||||||
BISON_CXX_COMPILER_POSIXLY_CORRECT
|
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.
|
||||||
|
gt_JAVACOMP([1.7], [1.7])
|
||||||
|
gt_JAVAEXEC
|
||||||
|
AM_CONDITIONAL([ENABLE_JAVA], [test x"$CONF_JAVAC" != x && test x"$CONF_JAVA" != x])
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([yacc],
|
AC_ARG_ENABLE([yacc],
|
||||||
[AC_HELP_STRING([--disable-yacc],
|
[AC_HELP_STRING([--disable-yacc],
|
||||||
[do not build a yacc command or an -ly library])],
|
[do not build a yacc command or an -ly library])],
|
||||||
, [enable_yacc=yes])
|
, [enable_yacc=yes])
|
||||||
AM_CONDITIONAL([ENABLE_YACC], [test "$enable_yacc" = yes])
|
AM_CONDITIONAL([ENABLE_YACC], [test "$enable_yacc" = yes])
|
||||||
|
AC_CONFIG_FILES([src/yacc], [chmod +x src/yacc])
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AM_MISSING_PROG([DOT], [dot])
|
AM_MISSING_PROG([DOT], [dot])
|
||||||
AC_PROG_LEX
|
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])
|
AC_MSG_WARN([bypassing lex because flex is required])
|
||||||
LEX=:
|
LEX=:
|
||||||
}
|
fi
|
||||||
|
AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX])
|
||||||
AM_CONDITIONAL([FLEX_CXX_WORKS],
|
AM_CONDITIONAL([FLEX_CXX_WORKS],
|
||||||
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
|
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
|
||||||
AC_PROG_YACC
|
AC_PROG_YACC
|
||||||
@@ -198,9 +271,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
|
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
|
||||||
supports -g, otherwise to "".])
|
supports -g, otherwise to "".])
|
||||||
AC_PATH_PROG([PERL], [perl])
|
AC_PATH_PROG([PERL], [perl])
|
||||||
if test -z "$PERL"; then
|
|
||||||
AC_MSG_ERROR([perl not found])
|
|
||||||
fi
|
|
||||||
AM_MISSING_PROG([HELP2MAN], [help2man])
|
AM_MISSING_PROG([HELP2MAN], [help2man])
|
||||||
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
||||||
AC_SUBST([XSLTPROC])
|
AC_SUBST([XSLTPROC])
|
||||||
@@ -217,14 +287,14 @@ gl_INIT
|
|||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||||
AM_WITH_DMALLOC
|
|
||||||
|
|
||||||
# Gettext.
|
# Gettext.
|
||||||
# We use gnulib, which is only guaranteed to work properly with the
|
# We use gnulib, which is only guaranteed to work properly with the
|
||||||
# latest Gettext.
|
# latest Gettext.
|
||||||
AM_GNU_GETTEXT([external], [need-ngettext])
|
AM_GNU_GETTEXT([external], [need-ngettext])
|
||||||
AM_GNU_GETTEXT_VERSION([0.18])
|
AM_GNU_GETTEXT_VERSION([0.19])
|
||||||
BISON_I18N
|
BISON_I18N
|
||||||
|
AC_CONFIG_FILES([gnulib-po/Makefile.in])
|
||||||
|
|
||||||
# Internationalized parsers.
|
# Internationalized parsers.
|
||||||
AC_CONFIG_FILES([runtime-po/Makefile.in])
|
AC_CONFIG_FILES([runtime-po/Makefile.in])
|
||||||
@@ -246,7 +316,7 @@ uname=`uname`
|
|||||||
case $VALGRIND:$uname in
|
case $VALGRIND:$uname in
|
||||||
'':*) ;;
|
'':*) ;;
|
||||||
*:Darwin)
|
*:Darwin)
|
||||||
# See README-hacking.
|
# See README-hacking.md.
|
||||||
VALGRIND=;;
|
VALGRIND=;;
|
||||||
*:*)
|
*:*)
|
||||||
suppfile=build-aux/$uname.valgrind
|
suppfile=build-aux/$uname.valgrind
|
||||||
@@ -266,10 +336,18 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
|||||||
# Needed by tests/atlocal.in.
|
# Needed by tests/atlocal.in.
|
||||||
AC_SUBST([GCC])
|
AC_SUBST([GCC])
|
||||||
|
|
||||||
gt_JAVACOMP([1.7], [1.7])
|
|
||||||
gt_JAVAEXEC
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
doc/yacc.1])
|
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
|
AC_OUTPUT
|
||||||
|
|||||||
-72
@@ -1,72 +0,0 @@
|
|||||||
This directory contains data needed by Bison.
|
|
||||||
|
|
||||||
* Skeletons
|
|
||||||
Bison skeletons: the general shapes of the different parser kinds,
|
|
||||||
that are specialized for specific grammars by the bison program.
|
|
||||||
|
|
||||||
Currently, the supported skeletons are:
|
|
||||||
|
|
||||||
- yacc.c
|
|
||||||
It used to be named bison.simple: it corresponds to C Yacc
|
|
||||||
compatible LALR(1) parsers.
|
|
||||||
|
|
||||||
- lalr1.cc
|
|
||||||
Produces a C++ parser class.
|
|
||||||
|
|
||||||
- lalr1.java
|
|
||||||
Produces a Java parser class.
|
|
||||||
|
|
||||||
- glr.c
|
|
||||||
A Generalized LR C parser based on Bison's LALR(1) tables.
|
|
||||||
|
|
||||||
- glr.cc
|
|
||||||
A Generalized LR C++ parser. Actually a C++ wrapper around glr.c.
|
|
||||||
|
|
||||||
These skeletons are the only ones supported by the Bison team.
|
|
||||||
Because the interface between skeletons and the bison program is not
|
|
||||||
finished, *we are not bound to it*. In particular, Bison is not
|
|
||||||
mature enough for us to consider that "foreign skeletons" are
|
|
||||||
supported.
|
|
||||||
|
|
||||||
* m4sugar
|
|
||||||
This directory contains M4sugar, sort of an extended library for M4,
|
|
||||||
which is used by Bison to instantiate the skeletons.
|
|
||||||
|
|
||||||
* xslt
|
|
||||||
This directory contains XSLT programs that transform Bison's XML output
|
|
||||||
into various formats.
|
|
||||||
|
|
||||||
- bison.xsl
|
|
||||||
A library of routines used by the other XSLT programs.
|
|
||||||
|
|
||||||
- xml2dot.xsl
|
|
||||||
Conversion into GraphViz's dot format.
|
|
||||||
|
|
||||||
- xml2text.xsl
|
|
||||||
Conversion into text.
|
|
||||||
|
|
||||||
- xml2xhtml.xsl
|
|
||||||
Conversion into XHTML.
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
Local Variables:
|
|
||||||
mode: outline
|
|
||||||
End:
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2008-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of GNU Bison.
|
|
||||||
|
|
||||||
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/>.
|
|
||||||
+192
@@ -0,0 +1,192 @@
|
|||||||
|
This directory contains data needed by Bison.
|
||||||
|
|
||||||
|
# Directory content
|
||||||
|
## Skeletons
|
||||||
|
Bison skeletons: the general shapes of the different parser kinds, that are
|
||||||
|
specialized for specific grammars by the bison program.
|
||||||
|
|
||||||
|
Currently, the supported skeletons are:
|
||||||
|
|
||||||
|
- yacc.c
|
||||||
|
It used to be named bison.simple: it corresponds to C Yacc
|
||||||
|
compatible LALR(1) parsers.
|
||||||
|
|
||||||
|
- lalr1.cc
|
||||||
|
Produces a C++ parser class.
|
||||||
|
|
||||||
|
- lalr1.java
|
||||||
|
Produces a Java parser class.
|
||||||
|
|
||||||
|
- glr.c
|
||||||
|
A Generalized LR C parser based on Bison's LALR(1) tables.
|
||||||
|
|
||||||
|
- glr.cc
|
||||||
|
A Generalized LR C++ parser. Actually a C++ wrapper around glr.c.
|
||||||
|
|
||||||
|
These skeletons are the only ones supported by the Bison team. Because the
|
||||||
|
interface between skeletons and the bison program is not finished, *we are
|
||||||
|
not bound to it*. In particular, Bison is not mature enough for us to
|
||||||
|
consider that "foreign skeletons" are supported.
|
||||||
|
|
||||||
|
## m4sugar
|
||||||
|
This directory contains M4sugar, sort of an extended library for M4, which
|
||||||
|
is used by Bison to instantiate the skeletons.
|
||||||
|
|
||||||
|
## xslt
|
||||||
|
This directory contains XSLT programs that transform Bison's XML output into
|
||||||
|
various formats.
|
||||||
|
|
||||||
|
- bison.xsl
|
||||||
|
A library of routines used by the other XSLT programs.
|
||||||
|
|
||||||
|
- xml2dot.xsl
|
||||||
|
Conversion into GraphViz's dot format.
|
||||||
|
|
||||||
|
- xml2text.xsl
|
||||||
|
Conversion into text.
|
||||||
|
|
||||||
|
- xml2xhtml.xsl
|
||||||
|
Conversion into XHTML.
|
||||||
|
|
||||||
|
# Implementation note about the skeletons
|
||||||
|
|
||||||
|
"Skeleton" in Bison parlance means "backend": a skeleton is fed by the bison
|
||||||
|
executable with LR tables, facts about the symbols, etc. and they generate
|
||||||
|
the output (say parser.cc, parser.hh, location.hh, etc.). They are only in
|
||||||
|
charge of generating the parser and its auxiliary files, they do not
|
||||||
|
generate the XML output, the parser.output reports, nor the graphical
|
||||||
|
rendering.
|
||||||
|
|
||||||
|
The bits of information passing from bison to the backend is named
|
||||||
|
"muscles". Muscles are passed to M4 via its standard input: it's a set of
|
||||||
|
m4 definitions. To see them, use `--trace=muscles`.
|
||||||
|
|
||||||
|
Except for muscles, whose names are generated by bison, the skeletons have
|
||||||
|
no constraint at all on the macro names: there is no technical/theoretical
|
||||||
|
limitation, as long as you generate the output, you can do what you want.
|
||||||
|
However, of course, that would be a bad idea if, say, the C and C++
|
||||||
|
skeletons used different approaches and had completely different
|
||||||
|
implementations. That would be a maintenance nightmare.
|
||||||
|
|
||||||
|
Below, we document some of the macros that we use in several of the
|
||||||
|
skeletons. If you are to write a new skeleton, please, implement them for
|
||||||
|
your language. Overall, be sure to follow the same patterns as the existing
|
||||||
|
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
|
||||||
|
`prepare_symbols_definitions()` in `src/output.c`.
|
||||||
|
|
||||||
|
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||||
|
|
||||||
|
- `has_id`: 0 or 1.
|
||||||
|
|
||||||
|
Whether the symbol has an id.
|
||||||
|
|
||||||
|
- `id`: string
|
||||||
|
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
|
||||||
|
defined as empty. Guaranteed to be usable as a C identifier.
|
||||||
|
|
||||||
|
- `tag`: string.
|
||||||
|
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||||
|
|
||||||
|
- `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
|
||||||
|
Whether this is a terminal symbol.
|
||||||
|
|
||||||
|
- `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).
|
||||||
|
|
||||||
|
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
|
||||||
|
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`
|
||||||
|
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
|
||||||
|
- `printer_loc`: location
|
||||||
|
If the symbol has a printer, everything about it.
|
||||||
|
|
||||||
|
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`, `destructor_loc`
|
||||||
|
Likewise.
|
||||||
|
|
||||||
|
### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])`
|
||||||
|
Expansion of $$, $1, $<TYPE-TAG>3, etc.
|
||||||
|
|
||||||
|
The semantic value from a given VAL.
|
||||||
|
- `VAL`: some semantic value storage (typically a union). e.g., `yylval`
|
||||||
|
- `SYMBOL-NUM`: the symbol number from which we extract the type tag.
|
||||||
|
- `TYPE-TAG`, the user forced the `<TYPE-TAG>`.
|
||||||
|
|
||||||
|
The result can be used safely, it is put in parens to avoid nasty precedence
|
||||||
|
issues.
|
||||||
|
|
||||||
|
### `b4_lhs_value(SYMBOL-NUM, [TYPE])`
|
||||||
|
Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`.
|
||||||
|
|
||||||
|
### `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])`
|
||||||
|
Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols
|
||||||
|
on RHS.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
mode: markdown
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2002, 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
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,31 @@
|
|||||||
|
/* Default styling rules for Bison when doing terminal output.
|
||||||
|
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* 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; }
|
||||||
+30
-18
@@ -1,4 +1,5 @@
|
|||||||
## Copyright (C) 2002, 2005-2015, 2018 Free Software Foundation, Inc.
|
## Copyright (C) 2002, 2005-2015, 2018-2020 Free Software Foundation,
|
||||||
|
## Inc.
|
||||||
|
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,23 +15,34 @@
|
|||||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
dist_pkgdata_DATA = \
|
||||||
data/README \
|
data/README.md \
|
||||||
data/bison.m4 \
|
data/bison-default.css
|
||||||
data/c++-skel.m4 \
|
|
||||||
data/c++.m4 \
|
skeletonsdir = $(pkgdatadir)/skeletons
|
||||||
data/c-like.m4 \
|
dist_skeletons_DATA = \
|
||||||
data/c-skel.m4 \
|
data/skeletons/bison.m4 \
|
||||||
data/c.m4 \
|
data/skeletons/c++-skel.m4 \
|
||||||
data/glr.c \
|
data/skeletons/c++.m4 \
|
||||||
data/glr.cc \
|
data/skeletons/c-like.m4 \
|
||||||
data/java-skel.m4 \
|
data/skeletons/c-skel.m4 \
|
||||||
data/java.m4 \
|
data/skeletons/c.m4 \
|
||||||
data/lalr1.cc \
|
data/skeletons/glr.c \
|
||||||
data/lalr1.java \
|
data/skeletons/glr.cc \
|
||||||
data/location.cc \
|
data/skeletons/java-skel.m4 \
|
||||||
data/stack.hh \
|
data/skeletons/java.m4 \
|
||||||
data/variant.hh \
|
data/skeletons/lalr1.cc \
|
||||||
data/yacc.c
|
data/skeletons/lalr1.java \
|
||||||
|
data/skeletons/location.cc \
|
||||||
|
data/skeletons/stack.hh \
|
||||||
|
data/skeletons/variant.hh \
|
||||||
|
data/skeletons/yacc.c
|
||||||
|
|
||||||
|
# Experimental support for the D language.
|
||||||
|
dist_skeletons_DATA += \
|
||||||
|
data/skeletons/README-D.txt \
|
||||||
|
data/skeletons/d-skel.m4 \
|
||||||
|
data/skeletons/d.m4 \
|
||||||
|
data/skeletons/lalr1.d
|
||||||
|
|
||||||
m4sugardir = $(pkgdatadir)/m4sugar
|
m4sugardir = $(pkgdatadir)/m4sugar
|
||||||
dist_m4sugar_DATA = \
|
dist_m4sugar_DATA = \
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
Some usage notes for the D Parser:
|
||||||
|
|
||||||
|
- it is a port of the Java parser, so interface is very similar.
|
||||||
|
|
||||||
|
- the lexer class needs to implement the interface 'Lexer' (similar to
|
||||||
|
java). It typically (depending on options) looks like this:
|
||||||
|
|
||||||
|
public interface Lexer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method to retrieve the beginning position of the last scanned token.
|
||||||
|
* @return the position at which the last scanned token starts. */
|
||||||
|
@property YYPosition startPos ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to retrieve the ending position of the last scanned token.
|
||||||
|
* @return the first position beyond the last scanned token. */
|
||||||
|
@property YYPosition endPos ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to retrieve the semantic value of the last scanned token.
|
||||||
|
* @return the semantic value of the last scanned token. */
|
||||||
|
@property YYSemanticType semanticVal ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point for the scanner. Returns the token identifier corresponding
|
||||||
|
* to the next token and prepares to return the semantic value
|
||||||
|
* and beginning/ending positions of the token.
|
||||||
|
* @return the token identifier corresponding to the next token. */
|
||||||
|
YYTokenType yylex ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point for error reporting. Emits an error
|
||||||
|
* referring to the given location in a user-defined way.
|
||||||
|
*
|
||||||
|
* @param loc The location of the element to which the
|
||||||
|
* error message is related
|
||||||
|
* @param s The string for the error message. */
|
||||||
|
void yyerror (YYLocation loc, string s);
|
||||||
|
}
|
||||||
|
|
||||||
|
- semantic types are handled by D usions (same as for C/C++ parsers)
|
||||||
|
|
||||||
|
- the following (non-standard) %defines are supported:
|
||||||
|
|
||||||
|
%define package "<package_name>"
|
||||||
|
%define api.parser.class "my_class_name>"
|
||||||
|
%define position_type "my_position_type"
|
||||||
|
%define location_type "my_location_type"
|
||||||
|
|
||||||
|
- the following declarations basically work like in C/C++:
|
||||||
|
|
||||||
|
%locations
|
||||||
|
%error-verbose
|
||||||
|
%parse-param
|
||||||
|
%initial-action
|
||||||
|
%code
|
||||||
|
%union
|
||||||
|
|
||||||
|
- %destructor is not yet supported
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
# Language-independent M4 Macros for Bison.
|
# Language-independent M4 Macros for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
|
||||||
|
# Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -191,7 +192,7 @@ m4_define([b4_error],
|
|||||||
# @warn(1@)
|
# @warn(1@)
|
||||||
# @warn(1@,2@)
|
# @warn(1@,2@)
|
||||||
m4_define([b4_warn],
|
m4_define([b4_warn],
|
||||||
[b4_error([[warn]], [], [], $@)])
|
[b4_warn_at([], [], $@)])
|
||||||
|
|
||||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
@@ -209,7 +210,7 @@ m4_define([b4_warn_at],
|
|||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_complain],
|
m4_define([b4_complain],
|
||||||
[b4_error([[complain]], [], [], $@)])
|
[b4_complain_at([], [], $@)])
|
||||||
|
|
||||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
@@ -225,8 +226,7 @@ m4_define([b4_complain_at],
|
|||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_fatal],
|
m4_define([b4_fatal],
|
||||||
[b4_error([[fatal]], [], [], $@)dnl
|
[b4_fatal_at([], [], $@)])
|
||||||
m4_exit(1)])
|
|
||||||
|
|
||||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
@@ -263,8 +263,8 @@ m4_define([b4_subtract],
|
|||||||
# -------------------
|
# -------------------
|
||||||
# Join with comma, skipping empty arguments.
|
# Join with comma, skipping empty arguments.
|
||||||
# b4_join calls itself recursively until it sees the first non-empty
|
# b4_join calls itself recursively until it sees the first non-empty
|
||||||
# argument, then calls _b4_join which prepends each non-empty argument
|
# argument, then calls _b4_join (i.e., `_$0`) which prepends each
|
||||||
# with a comma.
|
# non-empty argument with a comma.
|
||||||
m4_define([b4_join],
|
m4_define([b4_join],
|
||||||
[m4_if([$#$1],
|
[m4_if([$#$1],
|
||||||
[1], [],
|
[1], [],
|
||||||
@@ -374,60 +374,42 @@ b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
|||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||||
|
|
||||||
|
|
||||||
|
# b4_glr_cc_if([IF-TRUE], [IF-FALSE])
|
||||||
|
# -----------------------------------
|
||||||
|
m4_define([b4_glr_cc_if],
|
||||||
|
[m4_if(b4_skeleton, ["glr.cc"], $@)])
|
||||||
|
|
||||||
|
|
||||||
## --------- ##
|
## --------- ##
|
||||||
## Symbols. ##
|
## Symbols. ##
|
||||||
## --------- ##
|
## --------- ##
|
||||||
|
|
||||||
# In order to unify the handling of the various aspects of symbols
|
# For a description of the Symbol handling, see README.
|
||||||
# (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().
|
|
||||||
#
|
#
|
||||||
# The various FIELDS are:
|
# The following macros provide access to symbol related values.
|
||||||
#
|
|
||||||
# - has_id: 0 or 1.
|
# __b4_symbol(NUM, FIELD)
|
||||||
# Whether the symbol has an id.
|
# -----------------------
|
||||||
# - id: string
|
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||||
# If has_id, the id. Guaranteed to be usable as a C identifier.
|
# undefined.
|
||||||
# Prefixed by api.token.prefix if defined.
|
m4_define([__b4_symbol],
|
||||||
# - tag: string.
|
[m4_indir([b4_symbol($1, $2)])])
|
||||||
# A representat of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
|
||||||
# - user_number: integer
|
|
||||||
# The assigned (external) number as used by yylex.
|
|
||||||
# - is_token: 0 or 1
|
|
||||||
# Whether this is a terminal symbol.
|
|
||||||
# - number: integer
|
|
||||||
# The internalized number (used after yytranslate).
|
|
||||||
# - has_type: 0, 1
|
|
||||||
# Whether has a semantic value.
|
|
||||||
# - 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
|
|
||||||
# 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
|
|
||||||
# If the symbol has a printer, everything about it.
|
|
||||||
# - has_destructor, destructor, destructor_file, destructor_line
|
|
||||||
# Likewise.
|
|
||||||
#
|
|
||||||
# The following macros provide access to these values.
|
|
||||||
|
|
||||||
# _b4_symbol(NUM, FIELD)
|
# _b4_symbol(NUM, FIELD)
|
||||||
# ----------------------
|
# ----------------------
|
||||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||||
# undefined.
|
# undefined.
|
||||||
m4_define([_b4_symbol],
|
m4_define([_b4_symbol],
|
||||||
[m4_indir([b4_symbol($1, $2)])])
|
[m4_ifdef([b4_symbol($1, number)],
|
||||||
|
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
|
||||||
|
[__b4_symbol([$1], [$2])])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol(NUM, FIELD)
|
# b4_symbol(NUM, FIELD)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||||
# undefined. If FIELD = id, prepend the token prefix.
|
# undefined. If FIELD = id, prepend the token prefix.
|
||||||
m4_define([b4_symbol],
|
m4_define([b4_symbol],
|
||||||
[m4_case([$2],
|
[m4_case([$2],
|
||||||
@@ -455,26 +437,19 @@ 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)
|
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||||
# ----------------------------------
|
# ----------------------------------
|
||||||
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
||||||
m4_define([b4_symbol_action],
|
m4_define([b4_symbol_action],
|
||||||
[b4_symbol_if([$1], [has_$2],
|
[b4_symbol_if([$1], [has_$2],
|
||||||
[b4_dollar_pushdef([(*yyvaluep)],
|
[b4_dollar_pushdef([(*yyvaluep)],
|
||||||
b4_symbol_if([$1], [has_type],
|
[$1],
|
||||||
[m4_dquote(b4_symbol([$1], [type]))]),
|
[],
|
||||||
[(*yylocationp)])dnl
|
[(*yylocationp)])dnl
|
||||||
_b4_symbol_case([$1])[]dnl
|
_b4_symbol_case([$1])[]dnl
|
||||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
||||||
b4_symbol([$1], [$2])
|
b4_symbol([$1], [$2])
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])dnl
|
||||||
break;
|
break;
|
||||||
|
|
||||||
b4_dollar_popdef[]dnl
|
b4_dollar_popdef[]dnl
|
||||||
@@ -497,7 +472,7 @@ m4_define([b4_symbol_actions],
|
|||||||
m4_ifval(m4_defn([b4_actions_]),
|
m4_ifval(m4_defn([b4_actions_]),
|
||||||
[switch (m4_default([$2], [yytype]))
|
[switch (m4_default([$2], [yytype]))
|
||||||
{
|
{
|
||||||
m4_defn([b4_actions_])
|
m4_defn([b4_actions_])[]dnl
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}dnl
|
}dnl
|
||||||
@@ -508,7 +483,9 @@ m4_popdef([b4_actions_])dnl
|
|||||||
|
|
||||||
# _b4_symbol_case(SYMBOL-NUM)
|
# _b4_symbol_case(SYMBOL-NUM)
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# Issue a "case NUM" for SYMBOL-NUM.
|
# Issue a "case NUM" for SYMBOL-NUM. 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],
|
m4_define([_b4_symbol_case],
|
||||||
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
||||||
])
|
])
|
||||||
@@ -555,9 +532,9 @@ m4_define([b4_any_token_visible_if],
|
|||||||
# ----------------------------
|
# ----------------------------
|
||||||
m4_define([b4_token_format],
|
m4_define([b4_token_format],
|
||||||
[b4_token_visible_if([$2],
|
[b4_token_visible_if([$2],
|
||||||
[m4_quote(m4_format([$1],
|
[m4_format([[$1]],
|
||||||
[b4_symbol([$2], [id])],
|
m4_quote(b4_symbol([$2], [id])),
|
||||||
[b4_symbol([$2], [user_number])]))])])
|
m4_quote(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])])
|
||||||
|
|
||||||
|
|
||||||
## ------- ##
|
## ------- ##
|
||||||
@@ -569,7 +546,7 @@ m4_define([b4_token_format],
|
|||||||
# Run actions for the symbol NUMS that all have the same type-name.
|
# Run actions for the symbol NUMS that all have the same type-name.
|
||||||
# Skip NUMS that have no type-name.
|
# Skip NUMS that have no type-name.
|
||||||
#
|
#
|
||||||
# To specify the action to run, define b4_dollar_dollar(NUMBER,
|
# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM,
|
||||||
# TAG, TYPE).
|
# TAG, TYPE).
|
||||||
m4_define([_b4_type_action],
|
m4_define([_b4_type_action],
|
||||||
[b4_symbol_if([$1], [has_type],
|
[b4_symbol_if([$1], [has_type],
|
||||||
@@ -601,12 +578,15 @@ m4_define([b4_basename],
|
|||||||
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
[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],
|
m4_define([b4_syncline],
|
||||||
[b4_flag_if([synclines],
|
[b4_flag_if([synclines],
|
||||||
[b4_sync_start([$1], [$2]) b4_sync_end([__line__],
|
[b4_sync_start([$1], [$2])[]dnl
|
||||||
[b4_basename(m4_quote(__file__))])[]dnl
|
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||||
])])
|
])])
|
||||||
|
|
||||||
# b4_sync_start(LINE, FILE)
|
# b4_sync_start(LINE, FILE)
|
||||||
@@ -618,7 +598,17 @@ m4_define([b4_sync_start], [b4_comment([$2:$1])])
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
# Syncline for the current place, which ends. Typically a comment
|
# Syncline for the current place, which ends. Typically a comment
|
||||||
# left for the reader.
|
# 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)
|
# b4_user_code(USER-CODE)
|
||||||
@@ -768,8 +758,10 @@ m4_define([b4_percent_define_get_kind],
|
|||||||
[m4_indir([b4_percent_define_kind(]$1[)])],
|
[m4_indir([b4_percent_define_kind(]$1[)])],
|
||||||
[b4_fatal([[$0: undefined %%define variable '%s']], [$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.
|
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.
|
||||||
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
||||||
# since that's a Bison or skeleton error. Otherwise, return its definition
|
# since that's a Bison or skeleton error. Otherwise, return its definition
|
||||||
@@ -983,10 +975,9 @@ m4_define([b4_percent_code_get],
|
|||||||
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
||||||
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
||||||
m4_ifdef(b4_macro_name,
|
m4_ifdef(b4_macro_name,
|
||||||
[b4_comment([m4_if([$#], [0], [[Unqualified %code]],
|
[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]],
|
||||||
[["%code ]$1["]])[ blocks.]])
|
[[["%code ]$1[" blocks.]]]))
|
||||||
b4_user_code([m4_indir(b4_macro_name)])
|
b4_user_code([m4_indir(b4_macro_name)])])dnl
|
||||||
])dnl
|
|
||||||
m4_popdef([b4_macro_name])])
|
m4_popdef([b4_macro_name])])
|
||||||
|
|
||||||
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
||||||
@@ -1010,6 +1001,7 @@ m4_define([b4_percent_code_ifdef],
|
|||||||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||||
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
|
b4_percent_define_if_define([api.token.raw])
|
||||||
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
||||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||||
b4_percent_define_if_define([parse.assert])
|
b4_percent_define_if_define([parse.assert])
|
||||||
@@ -1086,10 +1078,10 @@ m4_define_default([b4_location_initial_line], [1])
|
|||||||
## Sanity checks. ##
|
## 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])
|
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])
|
b4_percent_define_check_kind([api.position.type], [code], [deprecated])
|
||||||
|
|
||||||
# api.prefix >< %name-prefix.
|
# api.prefix >< %name-prefix.
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# C++ skeleton dispatching for Bison.
|
# C++ skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation,
|
# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
|
||||||
# Inc.
|
# Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,10 +18,10 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])
|
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
||||||
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])
|
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
||||||
|
|
||||||
m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.cc]])
|
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.cc]])
|
||||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||||
|
|
||||||
m4_include(b4_used_skeleton)
|
m4_include(b4_used_skeleton)
|
||||||
+154
-127
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -22,10 +22,10 @@ b4_percent_define_ifdef([[api.value.union.name]],
|
|||||||
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
||||||
[named %union is invalid in C++])])
|
[named %union is invalid in C++])])
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
m4_include(b4_skeletonsdir/[c.m4])
|
||||||
|
|
||||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
|
b4_percent_define_check_kind([api.parser.class], [code], [deprecated])
|
||||||
|
|
||||||
|
|
||||||
## ----- ##
|
## ----- ##
|
||||||
@@ -72,6 +72,22 @@ m4_define([b4_cxx_portability],
|
|||||||
# define YY_MOVE_REF(Type) Type&
|
# define YY_MOVE_REF(Type) Type&
|
||||||
# define YY_RVREF(Type) const Type&
|
# define YY_RVREF(Type) const Type&
|
||||||
# define YY_COPY(Type) const Type&
|
# define YY_COPY(Type) const Type&
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Support noexcept when possible.
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
# define YY_NOEXCEPT noexcept
|
||||||
|
# define YY_NOTHROW
|
||||||
|
#else
|
||||||
|
# define YY_NOEXCEPT
|
||||||
|
# define YY_NOTHROW throw ()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Support constexpr when possible.
|
||||||
|
#if 201703 <= YY_CPLUSPLUS
|
||||||
|
# define YY_CONSTEXPR constexpr
|
||||||
|
#else
|
||||||
|
# define YY_CONSTEXPR
|
||||||
#endif[]dnl
|
#endif[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -80,7 +96,7 @@ m4_define([b4_cxx_portability],
|
|||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
b4_percent_define_default([[parser_class_name]], [[parser]])
|
b4_percent_define_default([[api.parser.class]], [[parser]])
|
||||||
|
|
||||||
# Don't do that so that we remember whether we're using a user
|
# Don't do that so that we remember whether we're using a user
|
||||||
# request, or the default value.
|
# request, or the default value.
|
||||||
@@ -131,13 +147,13 @@ m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
|||||||
[[namespace reference has a trailing "::"]])])
|
[[namespace reference has a trailing "::"]])])
|
||||||
|
|
||||||
m4_define([b4_namespace_open],
|
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),
|
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
||||||
[^\(.\)[ ]*::], [\1])),
|
[^\(.\)[ ]*::], [\1])),
|
||||||
[::], [ { namespace ])[ {]])])
|
[::], [ { namespace ])[ {]])])
|
||||||
|
|
||||||
m4_define([b4_namespace_close],
|
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[ ]),
|
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||||
[\1])),
|
[\1])),
|
||||||
@@ -178,7 +194,7 @@ m4_define([b4_value_type_declare],
|
|||||||
[union\|union-directive],
|
[union\|union-directive],
|
||||||
[[ union semantic_type
|
[[ union semantic_type
|
||||||
{
|
{
|
||||||
]b4_user_union_members[
|
]b4_user_union_members[
|
||||||
};]])])dnl
|
};]])])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -200,7 +216,18 @@ m4_define([b4_public_types_declare],
|
|||||||
/// Syntax errors thrown from user actions.
|
/// Syntax errors thrown from user actions.
|
||||||
struct syntax_error : std::runtime_error
|
struct syntax_error : std::runtime_error
|
||||||
{
|
{
|
||||||
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m);]b4_locations_if([
|
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
||||||
|
: std::runtime_error (m)]b4_locations_if([
|
||||||
|
, location (l)])[
|
||||||
|
{}
|
||||||
|
|
||||||
|
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;])[
|
location_type location;])[
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -224,11 +251,11 @@ m4_define([b4_public_types_declare],
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_type_declare
|
# b4_symbol_type_define
|
||||||
# ----------------------
|
# ---------------------
|
||||||
# Define symbol_type, the external type for symbols used for symbol
|
# Define symbol_type, the external type for symbols used for symbol
|
||||||
# constructors.
|
# constructors.
|
||||||
m4_define([b4_symbol_type_declare],
|
m4_define([b4_symbol_type_define],
|
||||||
[[ /// A complete symbol.
|
[[ /// A complete symbol.
|
||||||
///
|
///
|
||||||
/// Expects its Base type to provide access to the symbol type
|
/// Expects its Base type to provide access to the symbol type
|
||||||
@@ -242,14 +269,21 @@ m4_define([b4_symbol_type_declare],
|
|||||||
typedef Base super_type;
|
typedef Base super_type;
|
||||||
|
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
basic_symbol ();
|
basic_symbol ()
|
||||||
|
: value ()]b4_locations_if([
|
||||||
|
, location ()])[
|
||||||
|
{}
|
||||||
|
|
||||||
/// Move or copy constructor.
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
basic_symbol (YY_RVREF (basic_symbol) other);
|
/// Move constructor.
|
||||||
|
basic_symbol (basic_symbol&& that);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Copy constructor.
|
||||||
|
basic_symbol (const basic_symbol& that);]b4_variant_if([[
|
||||||
|
|
||||||
]b4_variant_if([[
|
|
||||||
/// Constructor for valueless symbols, and symbols from each type.
|
/// Constructor for valueless symbols, and symbols from each type.
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
||||||
/// Constructor for valueless symbols.
|
/// Constructor for valueless symbols.
|
||||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
||||||
YY_MOVE_REF (location_type) l])[);
|
YY_MOVE_REF (location_type) l])[);
|
||||||
@@ -257,16 +291,35 @@ m4_define([b4_symbol_type_declare],
|
|||||||
/// Constructor for symbols with semantic value.
|
/// Constructor for symbols with semantic value.
|
||||||
basic_symbol (typename Base::kind_type t,
|
basic_symbol (typename Base::kind_type t,
|
||||||
YY_RVREF (semantic_type) v]b4_locations_if([,
|
YY_RVREF (semantic_type) v]b4_locations_if([,
|
||||||
YY_RVREF (location_type) l])[);]])[
|
YY_RVREF (location_type) l])[);
|
||||||
|
]])[
|
||||||
/// Destroy the symbol.
|
/// Destroy the symbol.
|
||||||
~basic_symbol ();
|
~basic_symbol ()
|
||||||
|
{
|
||||||
|
clear ();
|
||||||
|
}
|
||||||
|
|
||||||
/// Destroy contents, and record that is empty.
|
/// 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.
|
/// Whether empty.
|
||||||
bool empty () const;
|
bool empty () const YY_NOEXCEPT;
|
||||||
|
|
||||||
/// Destructive move, \a s is emptied into this.
|
/// Destructive move, \a s is emptied into this.
|
||||||
void move (basic_symbol& s);
|
void move (basic_symbol& s);
|
||||||
@@ -280,7 +333,7 @@ m4_define([b4_symbol_type_declare],
|
|||||||
private:
|
private:
|
||||||
#if YY_CPLUSPLUS < 201103L
|
#if YY_CPLUSPLUS < 201103L
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
basic_symbol& operator= (const basic_symbol& other);
|
basic_symbol& operator= (const basic_symbol& that);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -290,8 +343,13 @@ m4_define([b4_symbol_type_declare],
|
|||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
by_type ();
|
by_type ();
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Move constructor.
|
||||||
|
by_type (by_type&& that);
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
by_type (const by_type& other);
|
by_type (const by_type& that);
|
||||||
|
|
||||||
/// The symbol type as needed by the constructor.
|
/// The symbol type as needed by the constructor.
|
||||||
typedef token_type kind_type;
|
typedef token_type kind_type;
|
||||||
@@ -307,10 +365,7 @@ m4_define([b4_symbol_type_declare],
|
|||||||
|
|
||||||
/// The (internal) type number (corresponding to \a type).
|
/// The (internal) type number (corresponding to \a type).
|
||||||
/// \a empty when empty.
|
/// \a empty when empty.
|
||||||
symbol_number_type type_get () const;
|
symbol_number_type type_get () const YY_NOEXCEPT;
|
||||||
|
|
||||||
/// The token.
|
|
||||||
token_type token () const;
|
|
||||||
|
|
||||||
/// The symbol type.
|
/// The symbol type.
|
||||||
/// \a empty_symbol when empty.
|
/// \a empty_symbol when empty.
|
||||||
@@ -319,7 +374,17 @@ m4_define([b4_symbol_type_declare],
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// "External" symbols: returned by the scanner.
|
/// "External" symbols: returned by the scanner.
|
||||||
typedef basic_symbol<by_type> symbol_type;
|
struct symbol_type : basic_symbol<by_type>
|
||||||
|
{]b4_variant_if([[
|
||||||
|
/// Superclass.
|
||||||
|
typedef basic_symbol<by_type> super_type;
|
||||||
|
|
||||||
|
/// Empty symbol.
|
||||||
|
symbol_type () {}
|
||||||
|
|
||||||
|
/// Constructor for valueless symbols, and symbols from each type.
|
||||||
|
]b4_type_foreach([_b4_token_constructor_define])dnl
|
||||||
|
])[};
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
@@ -327,34 +392,33 @@ m4_define([b4_symbol_type_declare],
|
|||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Provide the implementation needed by the public types.
|
# Provide the implementation needed by the public types.
|
||||||
m4_define([b4_public_types_define],
|
m4_define([b4_public_types_define],
|
||||||
[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
[[ // basic_symbol.
|
||||||
: std::runtime_error (m)]b4_locations_if([
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
, location (l)])[
|
|
||||||
{}
|
|
||||||
|
|
||||||
// basic_symbol.
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
|
]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
|
||||||
: value ()]b4_locations_if([
|
: Base (std::move (that))
|
||||||
, location ()])[
|
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||||
{}
|
, location (std::move (that.location))])[
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (YY_RVREF (basic_symbol) other)
|
|
||||||
: Base (YY_MOVE (other))
|
|
||||||
, value (]b4_variant_if([], [YY_MOVE (other.value)]))b4_locations_if([
|
|
||||||
, location (YY_MOVE (other.location))])[
|
|
||||||
{]b4_variant_if([
|
{]b4_variant_if([
|
||||||
b4_symbol_variant([other.type_get ()], [value], [YY_MOVE_OR_COPY],
|
b4_symbol_variant([this->type_get ()], [value], [move],
|
||||||
[YY_MOVE (other.value)])])[
|
[std::move (that.value)])
|
||||||
}
|
])[}
|
||||||
|
#endif
|
||||||
|
|
||||||
]b4_variant_if([[
|
template <typename Base>
|
||||||
// Implementation of basic_symbol constructor for each type.
|
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
: Base (that)
|
||||||
|
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||||
|
, location (that.location)])[
|
||||||
|
{]b4_variant_if([
|
||||||
|
b4_symbol_variant([this->type_get ()], [value], [copy],
|
||||||
|
[YY_MOVE (that.value)])
|
||||||
|
])[}
|
||||||
|
|
||||||
|
]b4_variant_if([], [[
|
||||||
/// Constructor for valueless symbols.
|
/// Constructor for valueless symbols.
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||||
[typename Base::kind_type t],
|
[typename Base::kind_type t],
|
||||||
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
||||||
: Base (t)
|
: Base (t)
|
||||||
@@ -363,7 +427,7 @@ m4_define([b4_public_types_define],
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||||
[typename Base::kind_type t],
|
[typename Base::kind_type t],
|
||||||
[YY_RVREF (semantic_type) v],
|
[YY_RVREF (semantic_type) v],
|
||||||
b4_locations_if([YY_RVREF (location_type) l]))[)
|
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||||
@@ -374,42 +438,16 @@ m4_define([b4_public_types_define],
|
|||||||
(void) v;
|
(void) v;
|
||||||
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
|
||||||
{
|
|
||||||
clear ();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
void
|
|
||||||
]b4_parser_class_name[::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>
|
template <typename Base>
|
||||||
bool
|
bool
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::empty () const
|
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return Base::type_get () == empty_symbol;
|
return Base::type_get () == empty_symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s)
|
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
||||||
{
|
{
|
||||||
super_type::move (s);
|
super_type::move (s);
|
||||||
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
||||||
@@ -419,62 +457,52 @@ m4_define([b4_public_types_define],
|
|||||||
}
|
}
|
||||||
|
|
||||||
// by_type.
|
// by_type.
|
||||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type ()
|
]b4_inline([$1])b4_parser_class[::by_type::by_type ()
|
||||||
: type (empty_symbol)
|
: type (empty_symbol)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other)
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
: type (other.type)
|
]b4_inline([$1])b4_parser_class[::by_type::by_type (by_type&& that)
|
||||||
|
: type (that.type)
|
||||||
|
{
|
||||||
|
that.clear ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
]b4_inline([$1])b4_parser_class[::by_type::by_type (const by_type& that)
|
||||||
|
: type (that.type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t)
|
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t)
|
||||||
: type (yytranslate_ (t))
|
: type (yytranslate_ (t))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])[void
|
]b4_inline([$1])[void
|
||||||
]b4_parser_class_name[::by_type::clear ()
|
]b4_parser_class[::by_type::clear ()
|
||||||
{
|
{
|
||||||
type = empty_symbol;
|
type = empty_symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_inline([$1])[void
|
]b4_inline([$1])[void
|
||||||
]b4_parser_class_name[::by_type::move (by_type& that)
|
]b4_parser_class[::by_type::move (by_type& that)
|
||||||
{
|
{
|
||||||
type = that.type;
|
type = that.type;
|
||||||
that.clear ();
|
that.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_inline([$1])[int
|
]b4_inline([$1])[int
|
||||||
]b4_parser_class_name[::by_type::type_get () const
|
]b4_parser_class[::by_type::type_get () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
]b4_token_ctor_if([[
|
]])
|
||||||
]b4_inline([$1])b4_parser_class_name[::token_type
|
|
||||||
]b4_parser_class_name[::by_type::token () const
|
|
||||||
{
|
|
||||||
// YYTOKNUM[NUM] -- (External) token number corresponding to the
|
|
||||||
// (internal) symbol number NUM (which must be that of a token). */
|
|
||||||
static
|
|
||||||
const ]b4_int_type_for([b4_toknum])[
|
|
||||||
yytoken_number_[] =
|
|
||||||
{
|
|
||||||
]b4_toknum[
|
|
||||||
};
|
|
||||||
return static_cast<token_type> (yytoken_number_[type]);
|
|
||||||
}
|
|
||||||
]])[]dnl
|
|
||||||
|
|
||||||
b4_symbol_constructor_define])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_constructor_declare
|
# b4_token_constructor_define
|
||||||
# b4_symbol_constructor_define
|
# ----------------------------
|
||||||
# -----------------------------
|
# Define symbol constructors for all the value types.
|
||||||
# Declare/define symbol constructors for all the value types.
|
|
||||||
# Use at class-level. Redefined in variant.hh.
|
# Use at class-level. Redefined in variant.hh.
|
||||||
m4_define([b4_symbol_constructor_declare], [])
|
m4_define([b4_token_constructor_define], [])
|
||||||
m4_define([b4_symbol_constructor_define], [])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_yytranslate_define(cc|hh)
|
# b4_yytranslate_define(cc|hh)
|
||||||
@@ -482,41 +510,40 @@ m4_define([b4_symbol_constructor_define], [])
|
|||||||
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
||||||
# sometimes in the cc file.
|
# sometimes in the cc file.
|
||||||
m4_define([b4_yytranslate_define],
|
m4_define([b4_yytranslate_define],
|
||||||
[[ // Symbol number corresponding to token number t.
|
[ b4_inline([$1])b4_parser_class[::token_number_type
|
||||||
]b4_inline([$1])b4_parser_class_name[::token_number_type
|
]b4_parser_class[::yytranslate_ (int t)
|
||||||
]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type],
|
|
||||||
[int])[ t)
|
|
||||||
{
|
{
|
||||||
|
]b4_api_token_raw_if(
|
||||||
|
[[ return static_cast<token_number_type> (t);]],
|
||||||
|
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||||
|
// TOKEN-NUM as returned by yylex.
|
||||||
static
|
static
|
||||||
const token_number_type
|
const token_number_type
|
||||||
translate_table[] =
|
translate_table[] =
|
||||||
{
|
{
|
||||||
]b4_translate[
|
]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_)
|
if (t <= 0)
|
||||||
return yyeof_;
|
return yyeof_;
|
||||||
else if (static_cast<unsigned> (t) <= user_token_number_max_)
|
else if (t <= user_token_number_max_)
|
||||||
return translate_table[t];
|
return translate_table[t];
|
||||||
else
|
else
|
||||||
return undef_token_;
|
return yy_undef_token_;]])[
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_value([TYPE])
|
# b4_lhs_value([TYPE])
|
||||||
# --------------------
|
# --------------------
|
||||||
# Expansion of $<TYPE>$.
|
|
||||||
m4_define([b4_lhs_value],
|
m4_define([b4_lhs_value],
|
||||||
[b4_symbol_value([yyval], [$1])])
|
[b4_symbol_value([yyval], [$1])])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_value(RULE-LENGTH, POS, [TYPE])
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# FIXME: Dead code.
|
||||||
# symbols on RHS.
|
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
||||||
|
|
||||||
@@ -528,9 +555,9 @@ m4_define([b4_lhs_location],
|
|||||||
[(yyloc)])
|
[(yyloc)])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
# b4_rhs_location(RULE-LENGTH, POS)
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||||
# on RHS.
|
# on RHS.
|
||||||
m4_define([b4_rhs_location],
|
m4_define([b4_rhs_location],
|
||||||
[(yylocation_stack_@{($1) - ($2)@})])
|
[(yylocation_stack_@{($1) - ($2)@})])
|
||||||
@@ -603,7 +630,7 @@ m4_define([b4_yylloc_default_define],
|
|||||||
{ \
|
{ \
|
||||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ false)
|
while (false)
|
||||||
# endif
|
# endif
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Common code for C-like languages (C, C++, Java, etc.)
|
# Common code for C-like languages (C, C++, Java, etc.)
|
||||||
|
|
||||||
# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -39,25 +39,26 @@ m4_define([b4_comment],
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# _b4_dollar_dollar(VALUE, FIELD, DEFAULT-FIELD)
|
# _b4_dollar_dollar(VALUE, SYMBOL-NUM, FIELD, DEFAULT-FIELD)
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------------------
|
||||||
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||||
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
# otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a
|
||||||
# pointer.
|
# pointer.
|
||||||
m4_define([_b4_dollar_dollar],
|
m4_define([_b4_dollar_dollar],
|
||||||
[b4_symbol_value([$1],
|
[b4_symbol_value([$1],
|
||||||
m4_if([$2], [[]],
|
[$2],
|
||||||
[[$3]], [[$2]]))])
|
m4_if([$3], [[]],
|
||||||
|
[[$4]], [[$3]]))])
|
||||||
|
|
||||||
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
|
# b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION)
|
||||||
# b4_dollar_popdef
|
# b4_dollar_popdef
|
||||||
# ---------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,
|
# Define b4_dollar_dollar for VALUE-POINTER and DEFAULT-FIELD,
|
||||||
# and b4_at_dollar for LOCATION.
|
# and b4_at_dollar for LOCATION.
|
||||||
m4_define([b4_dollar_pushdef],
|
m4_define([b4_dollar_pushdef],
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
[m4_pushdef([b4_dollar_dollar],
|
||||||
[_b4_dollar_dollar([$1], m4_dquote($][1), [$2])])dnl
|
[_b4_dollar_dollar([$1], [$2], m4_dquote($][1), [$3])])dnl
|
||||||
m4_pushdef([b4_at_dollar], [$3])dnl
|
m4_pushdef([b4_at_dollar], [$4])dnl
|
||||||
])
|
])
|
||||||
m4_define([b4_dollar_popdef],
|
m4_define([b4_dollar_popdef],
|
||||||
[m4_popdef([b4_at_dollar])dnl
|
[m4_popdef([b4_at_dollar])dnl
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# C skeleton dispatching for Bison.
|
# C skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation,
|
# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
|
||||||
# Inc.
|
# Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,10 +18,10 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])])
|
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
||||||
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])])
|
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
||||||
|
|
||||||
m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[yacc.c]])
|
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[yacc.c]])
|
||||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||||
|
|
||||||
m4_include(b4_used_skeleton)
|
m4_include(b4_used_skeleton)
|
||||||
+178
-64
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
# C M4 Macros for Bison.
|
# C M4 Macros for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
|
||||||
|
# Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c-like.m4])
|
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||||
|
|
||||||
# b4_tocpp(STRING)
|
# b4_tocpp(STRING)
|
||||||
# ----------------
|
# ----------------
|
||||||
@@ -166,38 +167,110 @@ b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
|||||||
|
|
||||||
# b4_int_type(MIN, MAX)
|
# b4_int_type(MIN, MAX)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Return the smallest int type able to handle numbers ranging from
|
# Return a narrow int type able to handle integers ranging from MIN
|
||||||
# MIN to MAX (included).
|
# to MAX (included) in portable C code. Assume MIN and MAX fall in
|
||||||
|
# 'int' range.
|
||||||
m4_define([b4_int_type],
|
m4_define([b4_int_type],
|
||||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
[m4_if(b4_ints_in($@, [-127], [127]), [1], [signed char],
|
||||||
b4_ints_in($@, [-128], [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($@, [0], [65535]), [1], [unsigned short],
|
||||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
|
||||||
|
|
||||||
m4_eval([0 <= $1]), [1], [unsigned],
|
|
||||||
|
|
||||||
[int])])
|
[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)
|
# 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).
|
# 'NAME_min' to 'NAME_max' (included).
|
||||||
m4_define([b4_int_type_for],
|
m4_define([b4_int_type_for],
|
||||||
[b4_int_type($1_min, $1_max)])
|
[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
|
# Without inducing a comparison warning from the compiler, check if the
|
||||||
# literal value LITERAL equals VALUE from table TABLE, which must have
|
# 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_define([b4_table_value_equals],
|
||||||
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
||||||
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
||||||
[[0]],
|
[[0]],
|
||||||
[(!!(($2) == ($3)))])])
|
[(($2) == $4)])])
|
||||||
|
|
||||||
|
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
@@ -209,37 +282,39 @@ m4_define([b4_table_value_equals],
|
|||||||
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
||||||
# _Noreturn.
|
# _Noreturn.
|
||||||
m4_define([b4_attribute_define],
|
m4_define([b4_attribute_define],
|
||||||
[[#ifndef YY_ATTRIBUTE
|
[[#ifndef YY_ATTRIBUTE_PURE
|
||||||
# if (defined __GNUC__ \
|
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
||||||
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||||
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
|
|
||||||
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
|
|
||||||
# else
|
# else
|
||||||
# define YY_ATTRIBUTE(Spec) /* empty */
|
# define YY_ATTRIBUTE_PURE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef YY_ATTRIBUTE_PURE
|
|
||||||
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef YY_ATTRIBUTE_UNUSED
|
#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
|
#endif
|
||||||
|
|
||||||
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
||||||
#if ! defined _Noreturn
|
]dnl This is an exact copy of lib/_Noreturn.h.
|
||||||
# if defined __cplusplus && 201103L <= __cplusplus
|
[#ifndef _Noreturn
|
||||||
|
# if (defined __cplusplus \
|
||||||
|
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||||
|
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
|
||||||
# define _Noreturn [[noreturn]]
|
# define _Noreturn [[noreturn]]
|
||||||
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
|
# elif ((!defined __cplusplus || defined __clang__) \
|
||||||
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||||
|| 0x5110 <= __SUNPRO_C)
|
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
|
||||||
# define _Noreturn __attribute__ ((__noreturn__))
|
/* _Noreturn works as-is. */
|
||||||
# elif defined _MSC_VER && 1200 <= _MSC_VER
|
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
|
||||||
# define _Noreturn __declspec (noreturn)
|
# define _Noreturn __attribute__ ((__noreturn__))
|
||||||
# else
|
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
||||||
# define _Noreturn
|
# define _Noreturn __declspec (noreturn)
|
||||||
# endif
|
# else
|
||||||
|
# define _Noreturn
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -252,11 +327,11 @@ m4_define([b4_attribute_define],
|
|||||||
|
|
||||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||||
_Pragma ("GCC diagnostic push") \
|
_Pragma ("GCC diagnostic push") \
|
||||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
|
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
|
||||||
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
||||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||||
_Pragma ("GCC diagnostic pop")
|
_Pragma ("GCC diagnostic pop")
|
||||||
#else
|
#else
|
||||||
# define YY_INITIAL_VALUE(Value) Value
|
# define YY_INITIAL_VALUE(Value) Value
|
||||||
@@ -268,9 +343,36 @@ m4_define([b4_attribute_define],
|
|||||||
#ifndef YY_INITIAL_VALUE
|
#ifndef YY_INITIAL_VALUE
|
||||||
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
|
||||||
|
# define YY_IGNORE_USELESS_CAST_BEGIN \
|
||||||
|
_Pragma ("GCC diagnostic push") \
|
||||||
|
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
|
||||||
|
# define YY_IGNORE_USELESS_CAST_END \
|
||||||
|
_Pragma ("GCC diagnostic pop")
|
||||||
|
#endif
|
||||||
|
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
|
||||||
|
# define YY_IGNORE_USELESS_CAST_BEGIN
|
||||||
|
# define YY_IGNORE_USELESS_CAST_END
|
||||||
|
#endif
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_cast_define
|
||||||
|
# --------------
|
||||||
|
m4_define([b4_cast_define],
|
||||||
|
[# ifndef YY_CAST
|
||||||
|
# ifdef __cplusplus
|
||||||
|
# define YY_CAST(Type, Val) static_cast<Type> (Val)
|
||||||
|
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
|
||||||
|
# else
|
||||||
|
# define YY_CAST(Type, Val) ((Type) (Val))
|
||||||
|
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
|
||||||
|
# endif
|
||||||
|
# endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_null_define
|
# b4_null_define
|
||||||
# --------------
|
# --------------
|
||||||
# Portability issues: define a YY_NULLPTR appropriate for the current
|
# Portability issues: define a YY_NULLPTR appropriate for the current
|
||||||
@@ -373,15 +475,17 @@ m4_define([b4_token_enums_defines],
|
|||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_value(VAL, [TYPE])
|
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||||
# ----------------------------
|
# ----------------------------------------------
|
||||||
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
|
# See README.
|
||||||
# TYPE if TYPE is given, otherwise just return VAL. The result can be
|
|
||||||
# used safely, it is put in parens to avoid nasty precedence issues.
|
|
||||||
# TYPE is *not* put in braces, provide some if needed.
|
|
||||||
m4_define([b4_symbol_value],
|
m4_define([b4_symbol_value],
|
||||||
[($1[]m4_ifval([$2], [.$2]))])
|
[m4_ifval([$3],
|
||||||
|
[($1.$3)],
|
||||||
|
[m4_ifval([$2],
|
||||||
|
[b4_symbol_if([$2], [has_type],
|
||||||
|
[($1.b4_symbol([$2], [type]))],
|
||||||
|
[$1])],
|
||||||
|
[$1])])])
|
||||||
|
|
||||||
|
|
||||||
## ---------------------- ##
|
## ---------------------- ##
|
||||||
@@ -467,7 +571,7 @@ m4_define([b4_sync_start], [[#]line $1 $2])
|
|||||||
m4_define([b4_case],
|
m4_define([b4_case],
|
||||||
[ case $1:
|
[ case $1:
|
||||||
$2
|
$2
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])dnl
|
||||||
break;])
|
break;])
|
||||||
|
|
||||||
|
|
||||||
@@ -477,7 +581,7 @@ m4_define([b4_predicate_case],
|
|||||||
[ case $1:
|
[ case $1:
|
||||||
if (! (
|
if (! (
|
||||||
$2)) YYERROR;
|
$2)) YYERROR;
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])dnl
|
||||||
break;])
|
break;])
|
||||||
|
|
||||||
|
|
||||||
@@ -537,8 +641,12 @@ m4_if(b4_skeleton, ["yacc.c"],
|
|||||||
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
||||||
# endif
|
# endif
|
||||||
]])dnl
|
]])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
|
||||||
|
[}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------.
|
/*---------------------------.
|
||||||
@@ -604,14 +712,17 @@ m4_define([b4_type_define_tag],
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_value_union(VAL, [TYPE])
|
# b4_symbol_value_union(VAL, SYMBOL-NUM, [TYPE])
|
||||||
# ----------------------------------
|
# ----------------------------------------------
|
||||||
# Same of b4_symbol_value, but when api.value.type=union.
|
# Same of b4_symbol_value, but when api.value.type=union.
|
||||||
m4_define([b4_symbol_value_union],
|
m4_define([b4_symbol_value_union],
|
||||||
[m4_ifval([$2],
|
[m4_ifval([$3],
|
||||||
[(*($2*)(&$1))],
|
[(*($3*)(&$1))],
|
||||||
[$1])])
|
[m4_ifval([$2],
|
||||||
])
|
[b4_symbol_if([$2], [has_type],
|
||||||
|
[($1.b4_symbol([$2], [type_tag]))],
|
||||||
|
[$1])],
|
||||||
|
[$1])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_value_type_setup_union
|
# b4_value_type_setup_union
|
||||||
@@ -703,13 +814,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
|
|||||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||||
[union\|union-directive],
|
[union\|union-directive],
|
||||||
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||||
union ]b4_percent_define_get([[api.value.union.name]])[
|
[union ]b4_percent_define_get([[api.value.union.name]])[
|
||||||
{
|
{
|
||||||
]b4_user_union_members[
|
]b4_user_union_members[
|
||||||
};
|
};
|
||||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||||
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
[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_TRIVIAL 1
|
||||||
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
@@ -720,7 +831,10 @@ typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[S
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([b4_location_type_define],
|
m4_define([b4_location_type_define],
|
||||||
[[/* Location type. */
|
[[/* 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;
|
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
||||||
struct ]b4_api_PREFIX[LTYPE
|
struct ]b4_api_PREFIX[LTYPE
|
||||||
{
|
{
|
||||||
@@ -732,7 +846,7 @@ struct ]b4_api_PREFIX[LTYPE
|
|||||||
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
||||||
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
]])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_declare_yylstype
|
# b4_declare_yylstype
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
-*- Autoconf -*-
|
||||||
|
|
||||||
|
# D skeleton dispatching for Bison.
|
||||||
|
|
||||||
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
b4_glr_if( [b4_complain([%%glr-parser not supported for D])])
|
||||||
|
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for D])])
|
||||||
|
|
||||||
|
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.d]])
|
||||||
|
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||||
|
|
||||||
|
m4_include(b4_used_skeleton)
|
||||||
@@ -0,0 +1,332 @@
|
|||||||
|
-*- Autoconf -*-
|
||||||
|
|
||||||
|
# D language support for Bison
|
||||||
|
|
||||||
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
|
||||||
|
# _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)
|
||||||
|
# ----------------------
|
||||||
|
# Join two lists with a comma if necessary.
|
||||||
|
m4_define([b4_list2],
|
||||||
|
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
||||||
|
# -------------------------------------------
|
||||||
|
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
||||||
|
# otherwise NOT.
|
||||||
|
m4_define([b4_percent_define_get3],
|
||||||
|
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||||
|
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_flag_value(BOOLEAN-FLAG)
|
||||||
|
# ---------------------------
|
||||||
|
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_parser_class_declaration
|
||||||
|
# ---------------------------
|
||||||
|
# The declaration of the parser class ("class YYParser"), with all its
|
||||||
|
# qualifiers/annotations.
|
||||||
|
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||||
|
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||||
|
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||||
|
|
||||||
|
m4_define([b4_parser_class_declaration],
|
||||||
|
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||||
|
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||||
|
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||||
|
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||||
|
[class ]b4_parser_class[]dnl
|
||||||
|
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
||||||
|
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_lexer_if(TRUE, FALSE)
|
||||||
|
# ------------------------
|
||||||
|
m4_define([b4_lexer_if],
|
||||||
|
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_position_type_if(TRUE, FALSE)
|
||||||
|
# --------------------------------
|
||||||
|
m4_define([b4_position_type_if],
|
||||||
|
[b4_percent_define_ifdef([[position_type]], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_location_type_if(TRUE, FALSE)
|
||||||
|
# --------------------------------
|
||||||
|
m4_define([b4_location_type_if],
|
||||||
|
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_identification
|
||||||
|
# -----------------
|
||||||
|
m4_define([b4_identification],
|
||||||
|
[/** Version number for the Bison executable that generated this parser. */
|
||||||
|
public static immutable string yy_bison_version = "b4_version";
|
||||||
|
|
||||||
|
/** Name of the skeleton that generated this parser. */
|
||||||
|
public static immutable string yy_bison_skeleton = b4_skeleton;
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
## ------------ ##
|
||||||
|
## Data types. ##
|
||||||
|
## ------------ ##
|
||||||
|
|
||||||
|
# b4_int_type(MIN, MAX)
|
||||||
|
# ---------------------
|
||||||
|
# Return the smallest int type able to handle numbers ranging from
|
||||||
|
# MIN to MAX (included).
|
||||||
|
m4_define([b4_int_type],
|
||||||
|
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
||||||
|
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||||
|
[int])])
|
||||||
|
|
||||||
|
# b4_int_type_for(NAME)
|
||||||
|
# ---------------------
|
||||||
|
# Return the smallest 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_null
|
||||||
|
# -------
|
||||||
|
m4_define([b4_null], [null])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
||||||
|
#-----------------------------------------------------
|
||||||
|
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
||||||
|
m4_define([b4_integral_parser_table_define],
|
||||||
|
[m4_ifvaln([$3], [b4_comment([$3], [ ])])dnl
|
||||||
|
private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
||||||
|
@{
|
||||||
|
$2
|
||||||
|
@};dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------- ##
|
||||||
|
## Assigning token numbers. ##
|
||||||
|
## ------------------------- ##
|
||||||
|
|
||||||
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
|
# ---------------------------------------
|
||||||
|
# Output the definition of this token as an enum.
|
||||||
|
m4_define([b4_token_enum],
|
||||||
|
[b4_token_format([ %s = %s,
|
||||||
|
], [$1])])
|
||||||
|
|
||||||
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# Output the definition of the tokens as enums.
|
||||||
|
m4_define([b4_token_enums],
|
||||||
|
[/* Tokens. */
|
||||||
|
public enum YYTokenType {
|
||||||
|
|
||||||
|
/** Token returned by the scanner to signal the end of its input. */
|
||||||
|
EOF = 0,
|
||||||
|
b4_symbol_foreach([b4_token_enum])
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4-case(ID, CODE)
|
||||||
|
# -----------------
|
||||||
|
m4_define([b4_case], [ case $1:
|
||||||
|
$2
|
||||||
|
break;])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
||||||
|
b4_percent_define_default([[stype]], [[YYSemanticType]])])
|
||||||
|
|
||||||
|
# %name-prefix
|
||||||
|
m4_define_default([b4_prefix], [[YY]])
|
||||||
|
|
||||||
|
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])])
|
||||||
|
m4_define([b4_location_type], b4_percent_define_ifdef([[location_type]],[b4_percent_define_get([[location_type]])],[YYLocation]))
|
||||||
|
|
||||||
|
#b4_percent_define_default([[position_type]], [Position])])
|
||||||
|
m4_define([b4_position_type], b4_percent_define_ifdef([[position_type]],[b4_percent_define_get([[position_type]])],[YYPosition]))
|
||||||
|
|
||||||
|
|
||||||
|
## ----------------- ##
|
||||||
|
## Semantic Values. ##
|
||||||
|
## ----------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||||
|
# ----------------------------------------------
|
||||||
|
# See README. FIXME: factor in c-like?
|
||||||
|
m4_define([b4_symbol_value],
|
||||||
|
[m4_ifval([$3],
|
||||||
|
[($1.$3)],
|
||||||
|
[m4_ifval([$2],
|
||||||
|
[b4_symbol_if([$2], [has_type],
|
||||||
|
[($1.b4_symbol([$2], [type]))],
|
||||||
|
[$1])],
|
||||||
|
[$1])])])
|
||||||
|
|
||||||
|
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
||||||
|
# --------------------------------
|
||||||
|
# See README.
|
||||||
|
m4_define([b4_lhs_value],
|
||||||
|
[b4_symbol_value([yyval], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||||
|
# --------------------------------------------------
|
||||||
|
# See README.
|
||||||
|
#
|
||||||
|
# In this simple implementation, %token and %type have class names
|
||||||
|
# between the angle brackets.
|
||||||
|
m4_define([b4_rhs_value],
|
||||||
|
[b4_symbol_value([(yystack.valueAt (b4_subtract([$1], [$2])))], [$3], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_lhs_location()
|
||||||
|
# -----------------
|
||||||
|
# Expansion of @$.
|
||||||
|
m4_define([b4_lhs_location],
|
||||||
|
[(yyloc)])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_rhs_location(RULE-LENGTH, POS)
|
||||||
|
# ---------------------------------
|
||||||
|
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||||
|
# on RHS.
|
||||||
|
m4_define([b4_rhs_location],
|
||||||
|
[yystack.locationAt ([$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_lex_param
|
||||||
|
# b4_parse_param
|
||||||
|
# --------------
|
||||||
|
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
||||||
|
# it to be single quoted. Same for b4_parse_param.
|
||||||
|
|
||||||
|
# TODO: should be in bison.m4
|
||||||
|
m4_define_default([b4_lex_param], [[]]))
|
||||||
|
m4_define([b4_lex_param], b4_lex_param))
|
||||||
|
m4_define([b4_parse_param], b4_parse_param))
|
||||||
|
|
||||||
|
# b4_lex_param_decl
|
||||||
|
# -------------------
|
||||||
|
# Extra formal arguments of the constructor.
|
||||||
|
m4_define([b4_lex_param_decl],
|
||||||
|
[m4_ifset([b4_lex_param],
|
||||||
|
[b4_remove_comma([$1],
|
||||||
|
b4_param_decls(b4_lex_param))],
|
||||||
|
[$1])])
|
||||||
|
|
||||||
|
m4_define([b4_param_decls],
|
||||||
|
[m4_map([b4_param_decl], [$@])])
|
||||||
|
m4_define([b4_param_decl], [, $1])
|
||||||
|
|
||||||
|
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_parse_param_decl
|
||||||
|
# -------------------
|
||||||
|
# Extra formal arguments of the constructor.
|
||||||
|
m4_define([b4_parse_param_decl],
|
||||||
|
[m4_ifset([b4_parse_param],
|
||||||
|
[b4_remove_comma([$1],
|
||||||
|
b4_param_decls(b4_parse_param))],
|
||||||
|
[$1])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_lex_param_call
|
||||||
|
# -------------------
|
||||||
|
# Delegating the lexer parameters to the lexer constructor.
|
||||||
|
m4_define([b4_lex_param_call],
|
||||||
|
[m4_ifset([b4_lex_param],
|
||||||
|
[b4_remove_comma([$1],
|
||||||
|
b4_param_calls(b4_lex_param))],
|
||||||
|
[$1])])
|
||||||
|
m4_define([b4_param_calls],
|
||||||
|
[m4_map([b4_param_call], [$@])])
|
||||||
|
m4_define([b4_param_call], [, $2])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_parse_param_cons
|
||||||
|
# -------------------
|
||||||
|
# Extra initialisations of the constructor.
|
||||||
|
m4_define([b4_parse_param_cons],
|
||||||
|
[m4_ifset([b4_parse_param],
|
||||||
|
[b4_constructor_calls(b4_parse_param)])])
|
||||||
|
|
||||||
|
m4_define([b4_constructor_calls],
|
||||||
|
[m4_map([b4_constructor_call], [$@])])
|
||||||
|
m4_define([b4_constructor_call],
|
||||||
|
[this.$2 = $2;
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_parse_param_vars
|
||||||
|
# -------------------
|
||||||
|
# Extra instance variables.
|
||||||
|
m4_define([b4_parse_param_vars],
|
||||||
|
[m4_ifset([b4_parse_param],
|
||||||
|
[
|
||||||
|
/* User arguments. */
|
||||||
|
b4_var_decls(b4_parse_param)])])
|
||||||
|
|
||||||
|
m4_define([b4_var_decls],
|
||||||
|
[m4_map_sep([b4_var_decl], [
|
||||||
|
], [$@])])
|
||||||
|
m4_define([b4_var_decl],
|
||||||
|
[ protected $1;])
|
||||||
+427
-363
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
# C++ GLR skeleton for Bison
|
# C++ GLR skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
# We require a pure interface.
|
# We require a pure interface.
|
||||||
m4_define([b4_pure_flag], [1])
|
m4_define([b4_pure_flag], [1])
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c++.m4])
|
m4_include(b4_skeletonsdir/[c++.m4])
|
||||||
b4_bison_locations_if([m4_include(b4_pkgdatadir/[location.cc])])
|
b4_bison_locations_if([m4_include(b4_skeletonsdir/[location.cc])])
|
||||||
|
|
||||||
m4_define([b4_parser_class_name],
|
m4_define([b4_parser_class],
|
||||||
[b4_percent_define_get([[parser_class_name]])])
|
[b4_percent_define_get([[api.parser.class]])])
|
||||||
|
|
||||||
# Save the parse parameters.
|
# Save the parse parameters.
|
||||||
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
||||||
@@ -60,10 +60,10 @@ m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
|||||||
# New ones.
|
# New ones.
|
||||||
m4_ifset([b4_parse_param],
|
m4_ifset([b4_parse_param],
|
||||||
[m4_define([b4_parse_param_wrap],
|
[m4_define([b4_parse_param_wrap],
|
||||||
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
|
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]],]
|
||||||
m4_defn([b4_parse_param]))],
|
m4_defn([b4_parse_param]))],
|
||||||
[m4_define([b4_parse_param_wrap],
|
[m4_define([b4_parse_param_wrap],
|
||||||
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
|
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -81,10 +81,10 @@ m4_define([b4_yy_symbol_print_define],
|
|||||||
[static void],
|
[static void],
|
||||||
[[FILE *], []],
|
[[FILE *], []],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],
|
[[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep],
|
||||||
[yyvaluep]][]dnl
|
[yyvaluep]][]dnl
|
||||||
b4_locations_if([,
|
b4_locations_if([,
|
||||||
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||||
[yylocationp]]]),
|
[yylocationp]]]),
|
||||||
b4_parse_param)[
|
b4_parse_param)[
|
||||||
{
|
{
|
||||||
@@ -98,18 +98,15 @@ b4_locations_if([,
|
|||||||
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
||||||
m4_defn([b4_initial_action])]))])[
|
m4_defn([b4_initial_action])]))])[
|
||||||
|
|
||||||
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
|
# Hijack the post prologue to declare yyerror.
|
||||||
# and declaration of yyerror.
|
|
||||||
]m4_append([b4_post_prologue],
|
]m4_append([b4_post_prologue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])dnl
|
||||||
]b4_yylloc_default_define[
|
b4_function_declare([yyerror],
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
|
||||||
]b4_function_declare([yyerror],
|
|
||||||
[static void],b4_locations_if([
|
[static void],b4_locations_if([
|
||||||
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||||
[yylocationp]],])
|
[yylocationp]],])
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])])
|
[[const char* msg], [msg]])])[
|
||||||
|
|
||||||
|
|
||||||
#undef yynerrs
|
#undef yynerrs
|
||||||
@@ -122,8 +119,7 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
#define yyparse ]b4_prefix[parse
|
#define yyparse ]b4_prefix[parse
|
||||||
#define yylex ]b4_prefix[lex
|
#define yylex ]b4_prefix[lex
|
||||||
#define yyerror ]b4_prefix[error
|
#define yyerror ]b4_prefix[error
|
||||||
#define yydebug ]b4_prefix[debug
|
#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
|
||||||
]]b4_pure_if([], [[
|
|
||||||
#define yylval ]b4_prefix[lval
|
#define yylval ]b4_prefix[lval
|
||||||
#define yychar ]b4_prefix[char
|
#define yychar ]b4_prefix[char
|
||||||
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
||||||
@@ -132,15 +128,15 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
# Hijack the epilogue to define implementations (yyerror, parser member
|
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||||
# functions etc.).
|
# functions etc.).
|
||||||
m4_append([b4_epilogue],
|
m4_append([b4_epilogue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])dnl
|
||||||
|
[
|
||||||
/*------------------.
|
/*------------------.
|
||||||
| Report an error. |
|
| Report an error. |
|
||||||
`------------------*/
|
`------------------*/
|
||||||
|
|
||||||
]b4_function_define([yyerror],
|
]b4_function_define([yyerror],
|
||||||
[static void],b4_locations_if([
|
[static void],b4_locations_if([
|
||||||
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||||
[yylocationp]],])
|
[yylocationp]],])
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])[
|
[[const char* msg], [msg]])[
|
||||||
@@ -154,26 +150,27 @@ m4_append([b4_epilogue],
|
|||||||
]dnl In this section, the parse params are the original parse_params.
|
]dnl In this section, the parse params are the original parse_params.
|
||||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||||
[ /// Build a parser object.
|
[ /// Build a parser object.
|
||||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||||
:])[
|
:])[
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||||
#endif]b4_parse_param_cons[
|
#endif]b4_parse_param_cons[
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
]b4_parser_class_name::~b4_parser_class_name[ ()
|
]b4_parser_class::~b4_parser_class[ ()
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||||
|
{}
|
||||||
|
|
||||||
int
|
int
|
||||||
]b4_parser_class_name[::operator() ()
|
]b4_parser_class[::operator() ()
|
||||||
{
|
{
|
||||||
return parse ();
|
return parse ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
]b4_parser_class_name[::parse ()
|
]b4_parser_class[::parse ()
|
||||||
{
|
{
|
||||||
return ::yyparse (*this]b4_user_args[);
|
return ::yyparse (*this]b4_user_args[);
|
||||||
}
|
}
|
||||||
@@ -184,7 +181,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
`--------------------*/
|
`--------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
|
]b4_parser_class[::yy_symbol_value_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||||
const location_type* yylocationp]])[)
|
const location_type* yylocationp]])[)
|
||||||
{]b4_locations_if([[
|
{]b4_locations_if([[
|
||||||
@@ -198,7 +195,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
|
]b4_parser_class[::yy_symbol_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||||
const location_type* yylocationp]])[)
|
const location_type* yylocationp]])[)
|
||||||
{
|
{
|
||||||
@@ -210,26 +207,26 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
]b4_parser_class_name[::debug_stream () const
|
]b4_parser_class[::debug_stream () const
|
||||||
{
|
{
|
||||||
return *yycdebug_;
|
return *yycdebug_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::set_debug_stream (std::ostream& o)
|
]b4_parser_class[::set_debug_stream (std::ostream& o)
|
||||||
{
|
{
|
||||||
yycdebug_ = &o;
|
yycdebug_ = &o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
]b4_parser_class_name[::debug_level_type
|
]b4_parser_class[::debug_level_type
|
||||||
]b4_parser_class_name[::debug_level () const
|
]b4_parser_class[::debug_level () const
|
||||||
{
|
{
|
||||||
return yydebug;
|
return yydebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
]b4_parser_class[::set_debug_level (debug_level_type l)
|
||||||
{
|
{
|
||||||
// Actually, it is yydebug which is really used.
|
// Actually, it is yydebug which is really used.
|
||||||
yydebug = l;
|
yydebug = l;
|
||||||
@@ -237,7 +234,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
]m4_popdef([b4_parse_param])dnl
|
]m4_popdef([b4_parse_param])dnl
|
||||||
b4_namespace_close
|
b4_namespace_close[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -252,26 +249,54 @@ b4_percent_code_get([[requires]])[
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
]m4_ifdef([b4_location_file],
|
]b4_cxx_portability[
|
||||||
|
]m4_ifdef([b4_location_include],
|
||||||
[[# include ]b4_location_include])[
|
[[# include ]b4_location_include])[
|
||||||
|
]b4_variant_if([b4_variant_includes])[
|
||||||
|
|
||||||
|
]b4_attribute_define[
|
||||||
]b4_null_define[
|
]b4_null_define[
|
||||||
|
|
||||||
|
// This skeleton is based on C, yet compiles it as C++.
|
||||||
|
// So expect warnings about C style casts.
|
||||||
|
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
|
||||||
|
# pragma clang diagnostic ignored "-Wold-style-cast"
|
||||||
|
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||||
|
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
||||||
|
// -pedantic reports as being a C++11 extension.
|
||||||
|
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
|
||||||
|
&& defined __clang__ && 4 <= __clang_major__
|
||||||
|
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Whether we are compiled with exception support.
|
||||||
|
#ifndef YY_EXCEPTIONS
|
||||||
|
# if defined __GNUC__ && !defined __EXCEPTIONS
|
||||||
|
# define YY_EXCEPTIONS 0
|
||||||
|
# else
|
||||||
|
# define YY_EXCEPTIONS 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
]b4_YYDEBUG_define[
|
]b4_YYDEBUG_define[
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
|
|
||||||
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||||
[b4_location_define])])[
|
[b4_location_define])])[
|
||||||
|
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
class ]b4_parser_class_name[
|
class ]b4_parser_class[
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
]b4_public_types_declare[
|
]b4_public_types_declare[
|
||||||
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
]b4_parser_class[ (]b4_parse_param_decl[);
|
||||||
virtual ~]b4_parser_class_name[ ();
|
virtual ~]b4_parser_class[ ();
|
||||||
|
|
||||||
/// Parse. An alias for parse ().
|
/// Parse. An alias for parse ().
|
||||||
/// \returns 0 iff parsing succeeded.
|
/// \returns 0 iff parsing succeeded.
|
||||||
@@ -281,6 +306,7 @@ b4_percent_code_get([[requires]])[
|
|||||||
/// \returns 0 iff parsing succeeded.
|
/// \returns 0 iff parsing succeeded.
|
||||||
virtual int parse ();
|
virtual int parse ();
|
||||||
|
|
||||||
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/// The current debugging stream.
|
/// The current debugging stream.
|
||||||
std::ostream& debug_stream () const;
|
std::ostream& debug_stream () const;
|
||||||
/// Set the current debugging stream.
|
/// Set the current debugging stream.
|
||||||
@@ -292,8 +318,8 @@ b4_percent_code_get([[requires]])[
|
|||||||
debug_level_type debug_level () const;
|
debug_level_type debug_level () const;
|
||||||
/// Set the current debugging level.
|
/// Set the current debugging level.
|
||||||
void set_debug_level (debug_level_type l);
|
void set_debug_level (debug_level_type l);
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
|
||||||
/// Report a syntax error.]b4_locations_if([[
|
/// Report a syntax error.]b4_locations_if([[
|
||||||
/// \param loc where the syntax error is found.]])[
|
/// \param loc where the syntax error is found.]])[
|
||||||
/// \param msg a description of the syntax error.
|
/// \param msg a description of the syntax error.
|
||||||
@@ -328,10 +354,10 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
|||||||
[b4_token_defines])
|
[b4_token_defines])
|
||||||
[
|
[
|
||||||
#ifndef ]b4_api_PREFIX[STYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
||||||
#endif
|
#endif
|
||||||
#ifndef ]b4_api_PREFIX[LTYPE
|
#ifndef ]b4_api_PREFIX[LTYPE
|
||||||
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
|
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
@@ -340,19 +366,19 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
|||||||
])
|
])
|
||||||
|
|
||||||
b4_defines_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++],
|
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||||
[2002-2015, 2018])[
|
[2002-2015, 2018-2020])[
|
||||||
// C++ GLR parser skeleton written by Akim Demaille.
|
// C++ GLR parser skeleton written by Akim Demaille.
|
||||||
|
|
||||||
]b4_disclaimer[
|
]b4_disclaimer[
|
||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_header_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]b4_cpp_guard_close([b4_spec_header_file])[
|
||||||
]b4_output_end])
|
]b4_output_end])
|
||||||
|
|
||||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||||
# arguments include the parser itself.
|
# arguments include the parser itself.
|
||||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap]))
|
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap]))
|
||||||
m4_include(b4_pkgdatadir/[glr.c])
|
m4_include(b4_skeletonsdir/[glr.c])
|
||||||
m4_popdef([b4_parse_param])
|
m4_popdef([b4_parse_param])
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
# Java skeleton dispatching for Bison.
|
# Java skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2007, 2009-2015, 2018-2020 Free Software Foundation,
|
||||||
|
# Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
b4_glr_if( [b4_complain([%%glr-parser not supported for Java])])
|
b4_glr_if( [b4_complain([%%glr-parser not supported for Java])])
|
||||||
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for Java])])
|
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for Java])])
|
||||||
|
|
||||||
m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.java]])
|
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.java]])
|
||||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||||
|
|
||||||
m4_include(b4_used_skeleton)
|
m4_include(b4_used_skeleton)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Java language support for Bison
|
# Java language support for Bison
|
||||||
|
|
||||||
# Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c-like.m4])
|
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||||
|
|
||||||
|
|
||||||
# b4_list2(LIST1, LIST2)
|
# b4_list2(LIST1, LIST2)
|
||||||
@@ -42,32 +42,24 @@ m4_define([b4_percent_define_get3],
|
|||||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||||
|
|
||||||
|
|
||||||
# b4_public_if(TRUE, FALSE)
|
# b4_parser_class_declaration
|
||||||
# -------------------------
|
|
||||||
b4_percent_define_default([[public]], [[false]])
|
|
||||||
m4_define([b4_public_if],
|
|
||||||
[b4_percent_define_flag_if([public], [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_abstract_if(TRUE, FALSE)
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
b4_percent_define_default([[abstract]], [[false]])
|
# The declaration of the parser class ("class YYParser"), with all its
|
||||||
m4_define([b4_abstract_if],
|
# qualifiers/annotations.
|
||||||
[b4_percent_define_flag_if([abstract], [$1], [$2])])
|
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||||
|
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||||
|
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||||
|
b4_percent_define_default([[api.parser.strictfp]], [[false]])
|
||||||
|
|
||||||
|
m4_define([b4_parser_class_declaration],
|
||||||
# b4_final_if(TRUE, FALSE)
|
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||||
# ---------------------------
|
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||||
b4_percent_define_default([[final]], [[false]])
|
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||||
m4_define([b4_final_if],
|
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||||
[b4_percent_define_flag_if([final], [$1], [$2])])
|
b4_percent_define_flag_if([api.parser.strictfp], [strictfp ])dnl
|
||||||
|
[class ]b4_parser_class[]dnl
|
||||||
|
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
||||||
# b4_strictfp_if(TRUE, FALSE)
|
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
||||||
# ---------------------------
|
|
||||||
b4_percent_define_default([[strictfp]], [[false]])
|
|
||||||
m4_define([b4_strictfp_if],
|
|
||||||
[b4_percent_define_flag_if([strictfp], [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_lexer_if(TRUE, FALSE)
|
# b4_lexer_if(TRUE, FALSE)
|
||||||
@@ -155,18 +147,20 @@ b4_symbol_foreach([b4_token_enum])])])
|
|||||||
# b4-case(ID, CODE)
|
# b4-case(ID, CODE)
|
||||||
# -----------------
|
# -----------------
|
||||||
# We need to fool Java's stupid unreachable code detection.
|
# We need to fool Java's stupid unreachable code detection.
|
||||||
m4_define([b4_case], [ case $1:
|
m4_define([b4_case],
|
||||||
|
[ case $1:
|
||||||
if (yyn == $1)
|
if (yyn == $1)
|
||||||
$2;
|
$2;
|
||||||
break;
|
break;
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_predicate_case(LABEL, CONDITIONS)
|
# b4_predicate_case(LABEL, CONDITIONS)
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
m4_define([b4_predicate_case], [ case $1:
|
m4_define([b4_predicate_case],
|
||||||
|
[ case $1:
|
||||||
if (! ($2)) YYERROR;
|
if (! ($2)) YYERROR;
|
||||||
break;
|
break;
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## -------- ##
|
## -------- ##
|
||||||
@@ -180,7 +174,7 @@ b4_percent_define_check_kind([[extends]], [code], [deprecated])
|
|||||||
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[parser_class_name]], [code], [deprecated])
|
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
||||||
|
|
||||||
|
|
||||||
@@ -192,11 +186,22 @@ b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
|||||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
||||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
b4_percent_define_default([[api.value.type]], [[Object]])
|
||||||
|
|
||||||
# %name-prefix
|
# b4_api_prefix, b4_api_PREFIX
|
||||||
m4_define_default([b4_prefix], [[YY]])
|
# ----------------------------
|
||||||
|
# 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_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])
|
# b4_prefix
|
||||||
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
|
# ---------
|
||||||
|
# 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]])])
|
||||||
|
|
||||||
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
|
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
|
||||||
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
||||||
@@ -219,21 +224,40 @@ m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
|
|||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_value([TYPE])
|
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||||
# --------------------
|
# ----------------------------------------------
|
||||||
# Expansion of $<TYPE>$.
|
# See README.
|
||||||
|
m4_define([b4_symbol_value],
|
||||||
|
[m4_ifval([$3],
|
||||||
|
[(($3)($1))],
|
||||||
|
[m4_ifval([$2],
|
||||||
|
[b4_symbol_if([$2], [has_type],
|
||||||
|
[((b4_symbol([$2], [type]))($1))],
|
||||||
|
[$1])],
|
||||||
|
[$1])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_lhs_value([SYMBOL-NUM], [TYPE])
|
||||||
|
# ----------------------------------
|
||||||
|
# See README.
|
||||||
m4_define([b4_lhs_value], [yyval])
|
m4_define([b4_lhs_value], [yyval])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_data(RULE-LENGTH, POS)
|
||||||
# --------------------------------------
|
# -----------------------------
|
||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# See README.
|
||||||
# symbols on RHS.
|
m4_define([b4_rhs_data],
|
||||||
|
[yystack.valueAt (b4_subtract($@))])
|
||||||
|
|
||||||
|
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||||
|
# --------------------------------------------------
|
||||||
|
# See README.
|
||||||
#
|
#
|
||||||
# In this simple implementation, %token and %type have class names
|
# In this simple implementation, %token and %type have class names
|
||||||
# between the angle brackets.
|
# between the angle brackets.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[(m4_ifval($3, [($3)])[](yystack.valueAt ($1-($2))))])
|
[b4_symbol_value([b4_rhs_data([$1], [$2])], [$3], [$4])])
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_location()
|
# b4_lhs_location()
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -242,12 +266,12 @@ m4_define([b4_lhs_location],
|
|||||||
[(yyloc)])
|
[(yyloc)])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
# b4_rhs_location(RULE-LENGTH, POS)
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||||
# on RHS.
|
# on RHS.
|
||||||
m4_define([b4_rhs_location],
|
m4_define([b4_rhs_location],
|
||||||
[yystack.locationAt ($1-($2))])
|
[yystack.locationAt (b4_subtract($@))])
|
||||||
|
|
||||||
|
|
||||||
# b4_lex_param
|
# b4_lex_param
|
||||||
@@ -339,4 +363,4 @@ m4_define([b4_var_decl],
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
# Expand to either an empty string or "throws THROWS".
|
# Expand to either an empty string or "throws THROWS".
|
||||||
m4_define([b4_maybe_throws],
|
m4_define([b4_maybe_throws],
|
||||||
[m4_ifval($1, [throws $1])])
|
[m4_ifval($1, [ throws $1])])
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,895 @@
|
|||||||
|
# D skeleton for Bison -*- autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2007-2012, 2019-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
m4_include(b4_skeletonsdir/[d.m4])
|
||||||
|
|
||||||
|
|
||||||
|
b4_output_begin([b4_parser_file_name])
|
||||||
|
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
|
||||||
|
[2007-2012, 2019-2020])[
|
||||||
|
|
||||||
|
]b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
||||||
|
])[
|
||||||
|
version(D_Version2) {
|
||||||
|
} else {
|
||||||
|
static assert(false, "need compiler for D Version 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
]b4_user_pre_prologue[
|
||||||
|
]b4_user_post_prologue[
|
||||||
|
]b4_percent_code_get([[imports]])[
|
||||||
|
import std.format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
||||||
|
*
|
||||||
|
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
||||||
|
* Port to D language was done by Oliver Mangold.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Communication interface between the scanner and the Bison-generated
|
||||||
|
* parser <tt>]b4_parser_class[</tt>.
|
||||||
|
*/
|
||||||
|
public interface Lexer
|
||||||
|
{]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 ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ();
|
||||||
|
|
||||||
|
]])[
|
||||||
|
/**
|
||||||
|
* Method to retrieve the semantic value of the last scanned token.
|
||||||
|
* @@return the semantic value of the last scanned token. */
|
||||||
|
@@property ]b4_yystype[ semanticVal ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point for the scanner. Returns the token identifier corresponding
|
||||||
|
* 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. */
|
||||||
|
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
|
||||||
|
* error message is related]])[
|
||||||
|
* @@param s The string for the error message. */
|
||||||
|
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[string s);
|
||||||
|
}
|
||||||
|
|
||||||
|
]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[ {
|
||||||
|
|
||||||
|
/** The column index within the line of input. */
|
||||||
|
public int column = 1;
|
||||||
|
/** The line number within an input file. */
|
||||||
|
public int line = 1;
|
||||||
|
/** The name of the input file. */
|
||||||
|
public string filename = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A string representation of the position. */
|
||||||
|
public string toString() const {
|
||||||
|
if (filename)
|
||||||
|
return format("%s:%d.%d", filename, line, column);
|
||||||
|
else
|
||||||
|
return format("%d.%d", line, column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]])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 "
|
||||||
|
"default constructor and constructors this(]b4_position_type[) and this(]b4_position_type[, ]b4_position_type[).");
|
||||||
|
static assert(__traits(compiles, (new ]b4_location_type[[1])[0].begin=(new ]b4_location_type[[1])[0].begin) &&
|
||||||
|
__traits(compiles, (new ]b4_location_type[[1])[0].begin=(new ]b4_location_type[[1])[0].end) &&
|
||||||
|
__traits(compiles, (new ]b4_location_type[[1])[0].end=(new ]b4_location_type[[1])[0].begin) &&
|
||||||
|
__traits(compiles, (new ]b4_location_type[[1])[0].end=(new ]b4_location_type[[1])[0].end),
|
||||||
|
"error: struct/class ]b4_location_type[ must have assignment-compatible "
|
||||||
|
"members/properties 'begin' and 'end'.");
|
||||||
|
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])));]], [[
|
||||||
|
/**
|
||||||
|
* A class defining a pair of positions. Positions, defined by the
|
||||||
|
* <code>]b4_position_type[</code> class, denote a point in the input.
|
||||||
|
* Locations represent a part of the input through the beginning
|
||||||
|
* and ending positions. */
|
||||||
|
public class ]b4_location_type[
|
||||||
|
{
|
||||||
|
/** The first, inclusive, position in the range. */
|
||||||
|
public ]b4_position_type[ begin;
|
||||||
|
|
||||||
|
/** The first position beyond the range. */
|
||||||
|
public ]b4_position_type[ end;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a <code>]b4_location_type[</code> denoting an empty range located at
|
||||||
|
* a given point.
|
||||||
|
* @@param loc The position at which the range is anchored. */
|
||||||
|
public this (]b4_position_type[ loc) {
|
||||||
|
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.
|
||||||
|
* @@param end The first position beyond the range. */
|
||||||
|
public this (]b4_position_type[ begin, ]b4_position_type[ end)
|
||||||
|
{
|
||||||
|
this.begin = begin;
|
||||||
|
this.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A representation of the location. For this to be correct,
|
||||||
|
* <code>]b4_position_type[</code> should override the <code>toString</code>
|
||||||
|
* method. */
|
||||||
|
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
|
||||||
|
{
|
||||||
|
b4_user_union_members
|
||||||
|
};],
|
||||||
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
|
[[private alias int YYSemanticType;]])])[
|
||||||
|
]b4_token_enums(b4_tokens)[
|
||||||
|
]b4_parser_class_declaration[
|
||||||
|
{
|
||||||
|
]b4_identification[
|
||||||
|
|
||||||
|
]b4_locations_if([[
|
||||||
|
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
|
||||||
|
{
|
||||||
|
static if (yy_location_is_class) {
|
||||||
|
if (n > 0)
|
||||||
|
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
||||||
|
else
|
||||||
|
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
||||||
|
} else {
|
||||||
|
if (n > 0)
|
||||||
|
return ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
||||||
|
else
|
||||||
|
return ]b4_location_type[ (rhs.locationAt (0).end);
|
||||||
|
}
|
||||||
|
}]])[
|
||||||
|
|
||||||
|
]b4_lexer_if([[ private class YYLexer implements Lexer {
|
||||||
|
]b4_percent_code_get([[lexer]])[
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
/** The object doing lexical analysis for us. */
|
||||||
|
private Lexer yylexer;
|
||||||
|
|
||||||
|
]b4_parse_param_vars[
|
||||||
|
|
||||||
|
]b4_lexer_if([[
|
||||||
|
/**
|
||||||
|
* Instantiate the Bison-generated parser.
|
||||||
|
*/
|
||||||
|
public this] (b4_parse_param_decl([b4_lex_param_decl])[) {
|
||||||
|
this (new YYLexer(]b4_lex_param_call[));
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;]b4_parse_trace_if([[
|
||||||
|
this.yyDebugStream = stderr;]])[
|
||||||
|
]b4_parse_param_cons[
|
||||||
|
}
|
||||||
|
]b4_parse_trace_if([[
|
||||||
|
private File yyDebugStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The <tt>File</tt> on which the debugging output is
|
||||||
|
* printed.
|
||||||
|
*/
|
||||||
|
public File getDebugStream () { return yyDebugStream; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the <tt>std.File</tt> on which the debug output is printed.
|
||||||
|
* @@param s The stream that is used for debugging output.
|
||||||
|
*/
|
||||||
|
public final void setDebugStream(File s) { yyDebugStream = s; }
|
||||||
|
|
||||||
|
private int yydebug = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answer the verbosity of the debugging output; 0 means that all kinds of
|
||||||
|
* output from the parser are suppressed.
|
||||||
|
*/
|
||||||
|
public final int getDebugLevel() { return yydebug; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the verbosity of the debugging output; 0 means that all kinds of
|
||||||
|
* output from the parser are suppressed.
|
||||||
|
* @@param level The verbosity level for debugging output.
|
||||||
|
*/
|
||||||
|
public final void setDebugLevel(int level) { yydebug = level; }
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returned by a Bison action in order to stop the parsing process and
|
||||||
|
* return success (<tt>true</tt>). */
|
||||||
|
public static immutable int YYACCEPT = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returned by a Bison action in order to stop the parsing process and
|
||||||
|
* return failure (<tt>false</tt>). */
|
||||||
|
public static immutable int YYABORT = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returned by a Bison action in order to start error recovery without
|
||||||
|
* printing an error message. */
|
||||||
|
public static immutable int YYERROR = 2;
|
||||||
|
|
||||||
|
// Internal return codes that are not supported for user semantic
|
||||||
|
// actions.
|
||||||
|
private static immutable int YYERRLAB = 3;
|
||||||
|
private static immutable int YYNEWSTATE = 4;
|
||||||
|
private static immutable int YYDEFAULT = 5;
|
||||||
|
private static immutable int YYREDUCE = 6;
|
||||||
|
private static immutable int YYERRLAB1 = 7;
|
||||||
|
private static immutable int YYRETURN = 8;
|
||||||
|
]b4_locations_if([
|
||||||
|
private static immutable YYSemanticType yy_semantic_null;])[
|
||||||
|
private int yyerrstatus_ = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ()
|
||||||
|
{
|
||||||
|
return yyerrstatus_ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);]])[
|
||||||
|
|
||||||
|
/* 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_parse_trace_if([[
|
||||||
|
yy_reduce_print (yyn, yystack);]])[
|
||||||
|
|
||||||
|
switch (yyn)
|
||||||
|
{
|
||||||
|
]b4_user_actions[
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
]b4_parse_trace_if([[
|
||||||
|
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);]])[
|
||||||
|
|
||||||
|
yystack.pop (yylen);
|
||||||
|
yylen = 0;
|
||||||
|
|
||||||
|
/* Shift the result of the reduction. */
|
||||||
|
yyn = yyr1_[yyn];
|
||||||
|
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
|
||||||
|
if (0 <= yystate && yystate <= yylast_
|
||||||
|
&& yycheck_[yystate] == yystack.stateAt (0))
|
||||||
|
yystate = yytable_[yystate];
|
||||||
|
else
|
||||||
|
yystate = yydefgoto_[yyn - yyntokens_];
|
||||||
|
|
||||||
|
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
|
||||||
|
return YYNEWSTATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return YYSTR after stripping away unnecessary quotes and
|
||||||
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||||
|
that double-quoting is unnecessary unless the string contains an
|
||||||
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||||
|
YYSTR is taken from yytname. */
|
||||||
|
private final string yytnamerr_ (string yystr)
|
||||||
|
{
|
||||||
|
if (yystr[0] == '"')
|
||||||
|
{
|
||||||
|
string yyr;
|
||||||
|
strip_quotes:
|
||||||
|
for (int i = 1; i < yystr.length; i++)
|
||||||
|
switch (yystr[i])
|
||||||
|
{
|
||||||
|
case '\'':
|
||||||
|
case ',':
|
||||||
|
break strip_quotes;
|
||||||
|
|
||||||
|
case '\\':
|
||||||
|
if (yystr[++i] != '\\')
|
||||||
|
break strip_quotes;
|
||||||
|
goto default;
|
||||||
|
default:
|
||||||
|
yyr ~= yystr[i];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '"':
|
||||||
|
return yyr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (yystr == "$end")
|
||||||
|
return "end of input";
|
||||||
|
|
||||||
|
return yystr;
|
||||||
|
}
|
||||||
|
]b4_parse_trace_if([[
|
||||||
|
/*--------------------------------.
|
||||||
|
| Print this symbol on YYOUTPUT. |
|
||||||
|
`--------------------------------*/
|
||||||
|
|
||||||
|
private final void yy_symbol_print (string s, int yytype,
|
||||||
|
ref ]b4_yystype[ yyvaluep]dnl
|
||||||
|
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||||
|
{
|
||||||
|
if (0 < yydebug)
|
||||||
|
{
|
||||||
|
string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
|
||||||
|
~ yytname_[yytype] ~ " ("]b4_locations_if([
|
||||||
|
~ yylocationp.toString() ~ ": "])[;
|
||||||
|
static if (__traits(compiles, message ~= yyvaluep.toString ()))
|
||||||
|
message ~= yyvaluep.toString ();
|
||||||
|
else
|
||||||
|
message ~= format ("%s", &yyvaluep);
|
||||||
|
message ~= ")";
|
||||||
|
yycdebug (message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
/**
|
||||||
|
* Parse input from the scanner that was specified at object construction
|
||||||
|
* time. Return whether the end of the input was reached successfully.
|
||||||
|
*
|
||||||
|
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||||
|
* imply that there were no syntax errors.
|
||||||
|
*/
|
||||||
|
public bool parse ()
|
||||||
|
{
|
||||||
|
/// Lookahead and lookahead in internal form.
|
||||||
|
int yychar = yyempty_;
|
||||||
|
int yytoken = 0;
|
||||||
|
|
||||||
|
/* State. */
|
||||||
|
int yyn = 0;
|
||||||
|
int yylen = 0;
|
||||||
|
int yystate = 0;
|
||||||
|
|
||||||
|
YYStack yystack;
|
||||||
|
|
||||||
|
/* Error handling. */
|
||||||
|
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;]])[
|
||||||
|
|
||||||
|
/// Semantic value of the lookahead.
|
||||||
|
]b4_yystype[ yylval;
|
||||||
|
|
||||||
|
int yyresult;]b4_parse_trace_if([[
|
||||||
|
|
||||||
|
yycdebug ("Starting parse\n");]])[
|
||||||
|
yyerrstatus_ = 0;
|
||||||
|
|
||||||
|
]m4_ifdef([b4_initial_action], [
|
||||||
|
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||||
|
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||||
|
/* User initialization code. */
|
||||||
|
b4_user_initial_action
|
||||||
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
|
m4_popdef([b4_at_dollar])])dnl
|
||||||
|
|
||||||
|
[ /* Initialize the stack. */
|
||||||
|
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||||
|
|
||||||
|
int label = YYNEWSTATE;
|
||||||
|
for (;;)
|
||||||
|
final switch (label)
|
||||||
|
{
|
||||||
|
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||||
|
pushed when we come here. */
|
||||||
|
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||||
|
yycdebug (format("Entering state %d\n", yystate));
|
||||||
|
if (0 < yydebug)
|
||||||
|
yystack.print (yyDebugStream);]])[
|
||||||
|
|
||||||
|
/* Accept? */
|
||||||
|
if (yystate == yyfinal_)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Take a decision. First try without lookahead. */
|
||||||
|
yyn = yypact_[yystate];
|
||||||
|
if (yy_pact_value_is_default_ (yyn))
|
||||||
|
{
|
||||||
|
label = YYDEFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read a lookahead token. */
|
||||||
|
if (yychar == yyempty_)
|
||||||
|
{]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 {
|
||||||
|
yylloc = ]b4_location_type[(yylexer.startPos, yylexer.endPos);
|
||||||
|
}]])
|
||||||
|
yylval = yylexer.semanticVal;[
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert token to internal form. */
|
||||||
|
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. */
|
||||||
|
yyn += yytoken;
|
||||||
|
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
||||||
|
label = YYDEFAULT;
|
||||||
|
|
||||||
|
/* <= 0 means reduce or error. */
|
||||||
|
else if ((yyn = yytable_[yyn]) <= 0)
|
||||||
|
{
|
||||||
|
if (yy_table_value_is_error_ (yyn))
|
||||||
|
label = YYERRLAB;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yyn = -yyn;
|
||||||
|
label = YYREDUCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||||
|
yy_symbol_print ("Shifting", yytoken,
|
||||||
|
yylval]b4_locations_if([, yylloc])[);]])[
|
||||||
|
|
||||||
|
/* Discard the token being shifted. */
|
||||||
|
yychar = yyempty_;
|
||||||
|
|
||||||
|
/* Count tokens shifted since error; after three, turn off error
|
||||||
|
* status. */
|
||||||
|
if (yyerrstatus_ > 0)
|
||||||
|
--yyerrstatus_;
|
||||||
|
|
||||||
|
yystate = yyn;
|
||||||
|
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||||
|
label = YYNEWSTATE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------.
|
||||||
|
| yydefault -- do the default action for the current state. |
|
||||||
|
`-----------------------------------------------------------*/
|
||||||
|
case YYDEFAULT:
|
||||||
|
yyn = yydefact_[yystate];
|
||||||
|
if (yyn == 0)
|
||||||
|
label = YYERRLAB;
|
||||||
|
else
|
||||||
|
label = YYREDUCE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*-----------------------------.
|
||||||
|
| yyreduce -- Do a reduction. |
|
||||||
|
`-----------------------------*/
|
||||||
|
case YYREDUCE:
|
||||||
|
yylen = yyr2_[yyn];
|
||||||
|
label = yyaction (yyn, yystack, yylen);
|
||||||
|
yystate = yystack.stateAt (0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*------------------------------------.
|
||||||
|
| yyerrlab -- here on detecting error |
|
||||||
|
`------------------------------------*/
|
||||||
|
case YYERRLAB:
|
||||||
|
/* If not already recovering from an error, report this error. */
|
||||||
|
if (yyerrstatus_ == 0)
|
||||||
|
{
|
||||||
|
++yynerrs_;
|
||||||
|
if (yychar == yyempty_)
|
||||||
|
yytoken = yyempty_;
|
||||||
|
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||||
|
}
|
||||||
|
|
||||||
|
]b4_locations_if([ yyerrloc = yylloc;])[
|
||||||
|
if (yyerrstatus_ == 3)
|
||||||
|
{
|
||||||
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
|
* error, discard it. */
|
||||||
|
|
||||||
|
if (yychar <= YYTokenType.EOF)
|
||||||
|
{
|
||||||
|
/* Return failure if at end of input. */
|
||||||
|
if (yychar == YYTokenType.EOF)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
yychar = yyempty_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Else will try to reuse lookahead token after shifting the error
|
||||||
|
* token. */
|
||||||
|
label = YYERRLAB1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*-------------------------------------------------.
|
||||||
|
| 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. */
|
||||||
|
yystack.pop (yylen);
|
||||||
|
yylen = 0;
|
||||||
|
yystate = yystack.stateAt (0);
|
||||||
|
label = YYERRLAB1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------.
|
||||||
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
||||||
|
`-------------------------------------------------------------*/
|
||||||
|
case YYERRLAB1:
|
||||||
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
yyn = yypact_[yystate];
|
||||||
|
if (!yy_pact_value_is_default_ (yyn))
|
||||||
|
{
|
||||||
|
yyn += yy_error_token_;
|
||||||
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
|
||||||
|
{
|
||||||
|
yyn = yytable_[yyn];
|
||||||
|
if (0 < yyn)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pop the current state because it cannot handle the error token. */
|
||||||
|
if (yystack.height == 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
]b4_locations_if([ yyerrloc = yystack.locationAt (0);])[
|
||||||
|
yystack.pop ();
|
||||||
|
yystate = yystack.stateAt (0);]b4_parse_trace_if([[
|
||||||
|
if (0 < yydebug)
|
||||||
|
yystack.print (yyDebugStream);]])[
|
||||||
|
}
|
||||||
|
|
||||||
|
]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. */]b4_parse_trace_if([[
|
||||||
|
yy_symbol_print ("Shifting", yystos_[yyn],
|
||||||
|
yylval]b4_locations_if([, yyloc])[);]])[
|
||||||
|
|
||||||
|
yystate = yyn;
|
||||||
|
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||||
|
label = YYNEWSTATE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Accept. */
|
||||||
|
case YYACCEPT:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Abort. */
|
||||||
|
case YYABORT:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate an error message.
|
||||||
|
private final string yysyntax_error (int yystate, int tok)
|
||||||
|
{]b4_error_verbose_if([[
|
||||||
|
/* There are many possibilities here to consider:
|
||||||
|
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||||
|
See
|
||||||
|
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||||
|
for details. YYERROR is fine as it does not invoke this
|
||||||
|
function.
|
||||||
|
- If this state is a consistent state with a default action,
|
||||||
|
then the only way this function was invoked is if the
|
||||||
|
default action is an error action. In that case, don't
|
||||||
|
check for expected tokens because there are none.
|
||||||
|
- The only way there can be no lookahead present (in tok) is
|
||||||
|
if this state is a consistent state with a default action.
|
||||||
|
Thus, detecting the absence of a lookahead is sufficient to
|
||||||
|
determine that there is no unexpected or expected token to
|
||||||
|
report. In that case, just report a simple "syntax error".
|
||||||
|
- Don't assume there isn't a lookahead just because this
|
||||||
|
state is a consistent state with a default action. There
|
||||||
|
might have been a previous inconsistent state, consistent
|
||||||
|
state with a non-default action, or user semantic action
|
||||||
|
that manipulated yychar. (However, yychar is currently out
|
||||||
|
of scope during semantic actions.)
|
||||||
|
- Of course, the expected token list depends on states to
|
||||||
|
have correct lookahead information, and it depends on the
|
||||||
|
parser not to perform extra reductions after fetching a
|
||||||
|
lookahead from the scanner and before detecting a syntax
|
||||||
|
error. Thus, state merging (from LALR or IELR) and default
|
||||||
|
reductions corrupt the expected token list. However, the
|
||||||
|
list is correct for canonical LR with one exception: it
|
||||||
|
will still contain any token that will not be accepted due
|
||||||
|
to an error action in a later state.
|
||||||
|
*/
|
||||||
|
if (tok != yyempty_)
|
||||||
|
{
|
||||||
|
// FIXME: This method of building the message is not compatible
|
||||||
|
// with internationalization.
|
||||||
|
string res = "syntax error, unexpected ";
|
||||||
|
res ~= yytnamerr_ (yytname_[tok]);
|
||||||
|
int yyn = yypact_[yystate];
|
||||||
|
if (!yy_pact_value_is_default_ (yyn))
|
||||||
|
{
|
||||||
|
/* Start YYX at -YYN if negative to avoid negative
|
||||||
|
indexes in YYCHECK. In other words, skip the first
|
||||||
|
-YYN actions for this state because they are default
|
||||||
|
actions. */
|
||||||
|
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||||
|
/* Stay within bounds of both yycheck and yytname. */
|
||||||
|
int yychecklim = yylast_ - yyn + 1;
|
||||||
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||||
|
int count = 0;
|
||||||
|
for (int x = yyxbegin; x < yyxend; ++x)
|
||||||
|
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||||
|
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||||
|
++count;
|
||||||
|
if (count < 5)
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
for (int x = yyxbegin; x < yyxend; ++x)
|
||||||
|
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||||
|
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||||
|
{
|
||||||
|
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||||
|
res ~= yytnamerr_ (yytname_[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}]])[
|
||||||
|
return "syntax error";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
||||||
|
* @@param yyvalue the value to check
|
||||||
|
*/
|
||||||
|
private static bool yy_pact_value_is_default_ (int yyvalue)
|
||||||
|
{
|
||||||
|
return yyvalue == yypact_ninf_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the given <code>yytable_</code> value indicates a syntax error.
|
||||||
|
* @@param yyvalue the value to check
|
||||||
|
*/
|
||||||
|
private static bool yy_table_value_is_error_ (int yyvalue)
|
||||||
|
{
|
||||||
|
return yyvalue == yytable_ninf_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||||
|
STATE-NUM. */
|
||||||
|
private static immutable ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
||||||
|
|
||||||
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||||
|
positive, shift that token. If negative, reduce the rule which
|
||||||
|
number is the opposite. If YYTABLE_NINF_, syntax error. */
|
||||||
|
private static immutable ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
||||||
|
|
||||||
|
]b4_parser_tables_define[
|
||||||
|
|
||||||
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||||
|
private static immutable string[] yytname_ =
|
||||||
|
@{
|
||||||
|
]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_ =
|
||||||
|
@{
|
||||||
|
]b4_rline[
|
||||||
|
@};
|
||||||
|
|
||||||
|
// Report on the debug stream that the rule yyrule is going to be reduced.
|
||||||
|
private final void yy_reduce_print (int yyrule, ref YYStack yystack)
|
||||||
|
{
|
||||||
|
if (yydebug == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int yylno = yyrline_[yyrule];
|
||||||
|
int yynrhs = yyr2_[yyrule];
|
||||||
|
/* Print the symbols being reduced, and their result. */
|
||||||
|
yycdebug (format("Reducing stack by rule %d (line %d), ",
|
||||||
|
yyrule - 1, yylno));
|
||||||
|
|
||||||
|
/* The symbols being reduced. */
|
||||||
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||||
|
yy_symbol_print (format(" $%d =", yyi + 1),
|
||||||
|
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||||
|
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
||||||
|
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
|
private static token_number_type yytranslate_ (int t)
|
||||||
|
{
|
||||||
|
]b4_api_token_raw_if(
|
||||||
|
[[ import std.conv : to;
|
||||||
|
return to!byte (t);]],
|
||||||
|
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
|
immutable token_number_type[] translate_table =
|
||||||
|
@{
|
||||||
|
]b4_translate[
|
||||||
|
@};
|
||||||
|
|
||||||
|
immutable int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
|
immutable token_number_type undef_token_ = ]b4_undef_token_number[;
|
||||||
|
|
||||||
|
if (t <= 0)
|
||||||
|
return YYTokenType.EOF;
|
||||||
|
else if (t <= user_token_number_max_)
|
||||||
|
return translate_table[t];
|
||||||
|
else
|
||||||
|
return undef_token_;]])[
|
||||||
|
}
|
||||||
|
|
||||||
|
alias ]b4_int_type_for([b4_translate])[ token_number_type;
|
||||||
|
|
||||||
|
private static immutable token_number_type yy_error_token_ = 1;
|
||||||
|
|
||||||
|
private static immutable int yylast_ = ]b4_last[;
|
||||||
|
private static immutable int yynnts_ = ]b4_nterms_number[;
|
||||||
|
private static immutable int yyempty_ = -2;
|
||||||
|
private static immutable int yyfinal_ = ]b4_final_state_number[;
|
||||||
|
private static immutable int yyntokens_ = ]b4_tokens_number[;
|
||||||
|
|
||||||
|
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[]dnl
|
||||||
|
b4_output_end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Java skeleton for Bison -*- autoconf -*-
|
# Java skeleton for Bison -*- autoconf -*-
|
||||||
|
|
||||||
# Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -15,20 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[java.m4])
|
m4_include(b4_skeletonsdir/[java.m4])
|
||||||
|
|
||||||
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
|
b4_defines_if([b4_complain([%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])
|
|
||||||
|
|
||||||
m4_define([b4_symbol_no_destructor_assert],
|
m4_define([b4_symbol_no_destructor_assert],
|
||||||
[b4_symbol_if([$1], [has_destructor],
|
[b4_symbol_if([$1], [has_destructor],
|
||||||
[b4_fatal([%s: %s: %%destructor does not make sense in Java],
|
[b4_complain_at(m4_unquote(b4_symbol([$1], [destructor_loc])),
|
||||||
[b4_skeleton],
|
[%destructor does not make sense in Java])])])
|
||||||
[b4_symbol_action_location([$1], [destructor])])])])
|
|
||||||
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
||||||
|
|
||||||
# Setup some macros for api.push-pull.
|
# Setup some macros for api.push-pull.
|
||||||
@@ -71,38 +65,31 @@ m4_define([b4_define_state],[[
|
|||||||
int label = YYNEWSTATE;
|
int label = YYNEWSTATE;
|
||||||
|
|
||||||
/* Error handling. */
|
/* Error handling. */
|
||||||
int yynerrs_ = 0;
|
int yynerrs_ = 0;]b4_locations_if([[
|
||||||
]b4_locations_if([/* The location where the error started. */
|
/* The location where the error started. */
|
||||||
b4_location_type yyerrloc = null;
|
]b4_location_type[ yyerrloc = null;
|
||||||
|
|
||||||
/* Location. */
|
/* 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. */
|
/* Semantic value of the lookahead. */
|
||||||
]b4_yystype[ yylval = null;
|
]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],
|
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||||
[2007-2015, 2018])[
|
[2007-2015, 2018-2020])[
|
||||||
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
|
||||||
]])[
|
]])[
|
||||||
]b4_user_pre_prologue[
|
]b4_user_pre_prologue[
|
||||||
]b4_user_post_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>.
|
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
||||||
*
|
*
|
||||||
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
||||||
*/
|
*/
|
||||||
]b4_percent_define_get3([annotations], [], [ ])dnl
|
]b4_parser_class_declaration[
|
||||||
b4_public_if([public ])dnl
|
|
||||||
b4_abstract_if([abstract ])dnl
|
|
||||||
b4_final_if([final ])dnl
|
|
||||||
b4_strictfp_if([strictfp ])dnl
|
|
||||||
[class ]b4_parser_class_name[]dnl
|
|
||||||
b4_percent_define_get3([extends], [ extends ])dnl
|
|
||||||
b4_percent_define_get3([implements], [ implements ])[
|
|
||||||
{
|
{
|
||||||
]b4_identification[
|
]b4_identification[
|
||||||
]b4_error_verbose_if([[
|
]b4_error_verbose_if([[
|
||||||
@@ -112,7 +99,7 @@ b4_percent_define_get3([implements], [ implements ])[
|
|||||||
private boolean yyErrorVerbose = true;
|
private boolean yyErrorVerbose = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether verbose error messages are enabled.
|
* Whether verbose error messages are enabled.
|
||||||
*/
|
*/
|
||||||
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
||||||
|
|
||||||
@@ -174,12 +161,12 @@ b4_locations_if([[
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]])
|
]])[
|
||||||
|
|
||||||
b4_locations_if([[
|
]b4_locations_if([[
|
||||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
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);
|
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
||||||
else
|
else
|
||||||
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
return new ]b4_location_type[ (rhs.locationAt (0).end);
|
||||||
@@ -187,7 +174,7 @@ b4_locations_if([[
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Communication interface between the scanner and the Bison-generated
|
* Communication interface between the scanner and the Bison-generated
|
||||||
* parser <tt>]b4_parser_class_name[</tt>.
|
* parser <tt>]b4_parser_class[</tt>.
|
||||||
*/
|
*/
|
||||||
public interface Lexer {
|
public interface Lexer {
|
||||||
/** Token returned by the scanner to signal the end of its input. */
|
/** Token returned by the scanner to signal the end of its input. */
|
||||||
@@ -195,7 +182,7 @@ b4_locations_if([[
|
|||||||
|
|
||||||
]b4_token_enums[
|
]b4_token_enums[
|
||||||
|
|
||||||
]b4_locations_if([[/**
|
]b4_locations_if([[/**
|
||||||
* Method to retrieve the beginning position of the last scanned token.
|
* Method to retrieve the beginning position of the last scanned token.
|
||||||
* @@return the position at which the last scanned token starts.
|
* @@return the position at which the last scanned token starts.
|
||||||
*/
|
*/
|
||||||
@@ -219,58 +206,60 @@ b4_locations_if([[
|
|||||||
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
||||||
* @@return the token identifier corresponding to the next token.
|
* @@return the token identifier corresponding to the next token.
|
||||||
*/
|
*/
|
||||||
int yylex () ]b4_maybe_throws([b4_lex_throws])[;
|
int yylex ()]b4_maybe_throws([b4_lex_throws])[;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for error reporting. Emits an error
|
* Entry point for error reporting. Emits an error
|
||||||
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
|
* ]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]])[
|
* error message is related]])[
|
||||||
* @@param msg The string for the error message.
|
* @@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]])[
|
]b4_percent_code_get([[lexer]])[
|
||||||
}
|
}
|
||||||
|
|
||||||
]])[/**
|
]])[
|
||||||
|
/**
|
||||||
* The object doing lexical analysis for us.
|
* The object doing lexical analysis for us.
|
||||||
*/
|
*/
|
||||||
private Lexer yylexer;
|
private Lexer yylexer;
|
||||||
]
|
|
||||||
b4_parse_param_vars
|
|
||||||
|
|
||||||
b4_lexer_if([[
|
]b4_parse_param_vars[
|
||||||
|
|
||||||
|
]b4_lexer_if([[
|
||||||
/**
|
/**
|
||||||
* Instantiates the Bison-generated parser.
|
* Instantiates the Bison-generated parser.
|
||||||
*/
|
*/
|
||||||
public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
|
public ]b4_parser_class (b4_parse_param_decl([b4_lex_param_decl])[)]b4_maybe_throws([b4_init_throws])[
|
||||||
{
|
{
|
||||||
]b4_percent_code_get([[init]])[
|
]b4_percent_code_get([[init]])[
|
||||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
||||||
]b4_parse_param_cons[
|
]b4_parse_param_cons[
|
||||||
}
|
}
|
||||||
]])
|
]])[
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates the Bison-generated parser.
|
* Instantiates the Bison-generated parser.
|
||||||
* @@param yylexer The scanner that will supply tokens to the parser.
|
* @@param yylexer The scanner that will supply tokens to the parser.
|
||||||
*/
|
*/
|
||||||
b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
]b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[)]b4_maybe_throws([b4_init_throws])[
|
||||||
{
|
{
|
||||||
]b4_percent_code_get([[init]])[
|
]b4_percent_code_get([[init]])[
|
||||||
this.yylexer = yylexer;
|
this.yylexer = yylexer;
|
||||||
]b4_parse_param_cons[
|
]b4_parse_param_cons[
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]b4_parse_trace_if([[
|
||||||
private java.io.PrintStream yyDebugStream = System.err;
|
private java.io.PrintStream yyDebugStream = System.err;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the <tt>PrintStream</tt> on which the debugging output is
|
* The <tt>PrintStream</tt> on which the debugging output is printed.
|
||||||
* printed.
|
|
||||||
*/
|
*/
|
||||||
public final java.io.PrintStream getDebugStream () { return yyDebugStream; }
|
public final java.io.PrintStream getDebugStream () { return yyDebugStream; }
|
||||||
|
|
||||||
@@ -294,6 +283,7 @@ b4_lexer_if([[
|
|||||||
* @@param level The verbosity level for debugging output.
|
* @@param level The verbosity level for debugging output.
|
||||||
*/
|
*/
|
||||||
public final void setDebugLevel(int level) { yydebug = level; }
|
public final void setDebugLevel(int level) { yydebug = level; }
|
||||||
|
]])[
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print an error message via the lexer.
|
* Print an error message via the lexer.
|
||||||
@@ -323,16 +313,16 @@ b4_lexer_if([[
|
|||||||
public final void yyerror (]b4_position_type[ pos, String msg)
|
public final void yyerror (]b4_position_type[ pos, String msg)
|
||||||
{
|
{
|
||||||
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
|
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
|
||||||
}]])
|
}]])[
|
||||||
|
]b4_parse_trace_if([[
|
||||||
[protected final void yycdebug (String s) {
|
protected final void yycdebug (String s) {
|
||||||
if (yydebug > 0)
|
if (0 < yydebug)
|
||||||
yyDebugStream.println (s);
|
yyDebugStream.println (s);
|
||||||
}
|
}]])[
|
||||||
|
|
||||||
private final class YYStack {
|
private final class YYStack {
|
||||||
private int[] stateStack = new int[16];
|
private int[] stateStack = new int[16];]b4_locations_if([[
|
||||||
]b4_locations_if([[private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[
|
private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[
|
||||||
private ]b4_yystype[[] valueStack = new ]b4_yystype[[16];
|
private ]b4_yystype[[] valueStack = new ]b4_yystype[[16];
|
||||||
|
|
||||||
public int size = 16;
|
public int size = 16;
|
||||||
@@ -345,8 +335,7 @@ b4_lexer_if([[
|
|||||||
{
|
{
|
||||||
int[] newStateStack = new int[size * 2];
|
int[] newStateStack = new int[size * 2];
|
||||||
System.arraycopy (stateStack, 0, newStateStack, 0, height);
|
System.arraycopy (stateStack, 0, newStateStack, 0, height);
|
||||||
stateStack = newStateStack;
|
stateStack = newStateStack;]b4_locations_if([[
|
||||||
]b4_locations_if([[
|
|
||||||
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
|
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
|
||||||
System.arraycopy (locStack, 0, newLocStack, 0, height);
|
System.arraycopy (locStack, 0, newLocStack, 0, height);
|
||||||
locStack = newLocStack;]])
|
locStack = newLocStack;]])
|
||||||
@@ -358,8 +347,8 @@ b4_lexer_if([[
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
stateStack[height] = state;
|
stateStack[height] = state;]b4_locations_if([[
|
||||||
]b4_locations_if([[locStack[height] = loc;]])[
|
locStack[height] = loc;]])[
|
||||||
valueStack[height] = value;
|
valueStack[height] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,9 +358,9 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
public final void pop (int num) {
|
public final void pop (int num) {
|
||||||
// Avoid memory leaks... garbage collection is a white lie!
|
// 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);
|
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);]b4_locations_if([[
|
||||||
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
||||||
}
|
}
|
||||||
height -= num;
|
height -= num;
|
||||||
}
|
}
|
||||||
@@ -379,8 +368,9 @@ b4_lexer_if([[
|
|||||||
public final int stateAt (int i) {
|
public final int stateAt (int i) {
|
||||||
return stateStack[height - i];
|
return stateStack[height - i];
|
||||||
}
|
}
|
||||||
|
]b4_locations_if([[
|
||||||
|
|
||||||
]b4_locations_if([[public final ]b4_location_type[ locationAt (int i) {
|
public final ]b4_location_type[ locationAt (int i) {
|
||||||
return locStack[height - i];
|
return locStack[height - i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,8 +379,7 @@ b4_lexer_if([[
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print the state stack on the debug stream.
|
// Print the state stack on the debug stream.
|
||||||
public void print (java.io.PrintStream out)
|
public void print (java.io.PrintStream out) {
|
||||||
{
|
|
||||||
out.print ("Stack now");
|
out.print ("Stack now");
|
||||||
|
|
||||||
for (int i = 0; i <= height; i++)
|
for (int i = 0; i <= height; i++)
|
||||||
@@ -440,10 +429,9 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
private int yyerrstatus_ = 0;
|
private int yyerrstatus_ = 0;
|
||||||
|
|
||||||
]b4_push_if([dnl
|
]b4_push_if([b4_define_state])[
|
||||||
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
|
* reads token until it reaches a known state, and then restarts normal
|
||||||
* operation.
|
* operation.
|
||||||
*/
|
*/
|
||||||
@@ -456,7 +444,7 @@ b4_define_state])[
|
|||||||
* @@param yystate the current state
|
* @@param yystate the current state
|
||||||
* @@param yysym the nonterminal to push on the stack
|
* @@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;
|
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
|
||||||
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
||||||
@@ -465,37 +453,32 @@ b4_define_state])[
|
|||||||
return yydefgoto_[yysym - yyntokens_];
|
return yydefgoto_[yysym - yyntokens_];
|
||||||
}
|
}
|
||||||
|
|
||||||
private int yyaction (int yyn, YYStack yystack, int yylen) ]b4_maybe_throws([b4_throws])[
|
private int yyaction (int yyn, YYStack yystack, int yylen)]b4_maybe_throws([b4_throws])[
|
||||||
{
|
{
|
||||||
]b4_yystype[ yyval;
|
|
||||||
]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[
|
|
||||||
|
|
||||||
/* If YYLEN is nonzero, implement the default value of the action:
|
/* If YYLEN is nonzero, implement the default value of the action:
|
||||||
'$$ = $1'. Otherwise, use the top of the stack.
|
'$$ = $1'. Otherwise, use the top of the stack.
|
||||||
|
|
||||||
Otherwise, the following line sets YYVAL to garbage.
|
Otherwise, the following line sets YYVAL to garbage.
|
||||||
This behavior is undocumented and Bison
|
This behavior is undocumented and Bison
|
||||||
users should not rely upon it. */
|
users should not rely upon it. */
|
||||||
if (yylen > 0)
|
]b4_yystype[ yyval = (0 < yylen) ? yystack.valueAt (yylen - 1) : yystack.valueAt (0);]b4_locations_if([[
|
||||||
yyval = yystack.valueAt (yylen - 1);
|
]b4_location_type[ yyloc = yylloc (yystack, yylen);]])[]b4_parse_trace_if([[
|
||||||
else
|
|
||||||
yyval = yystack.valueAt (0);
|
|
||||||
|
|
||||||
yy_reduce_print (yyn, yystack);
|
yyReducePrint (yyn, yystack);]])[
|
||||||
|
|
||||||
switch (yyn)
|
switch (yyn)
|
||||||
{
|
{
|
||||||
]b4_user_actions[
|
]b4_user_actions[
|
||||||
default: break;
|
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);
|
yystack.pop (yylen);
|
||||||
yylen = 0;
|
yylen = 0;
|
||||||
|
|
||||||
/* Shift the result of the reduction. */
|
/* 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])[);
|
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
|
||||||
return YYNEWSTATE;
|
return YYNEWSTATE;
|
||||||
}
|
}
|
||||||
@@ -536,21 +519,20 @@ b4_define_state])[
|
|||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
]])[
|
]])[
|
||||||
|
]b4_parse_trace_if([[
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
private void yy_symbol_print (String s, int yytype,
|
private void yySymbolPrint (String s, int yytype,
|
||||||
]b4_yystype[ yyvaluep]dnl
|
]b4_yystype[ yyvaluep]dnl
|
||||||
b4_locations_if([, Object yylocationp])[)
|
b4_locations_if([, Object yylocationp])[)
|
||||||
{
|
{
|
||||||
if (yydebug > 0)
|
|
||||||
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
|
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
|
||||||
+ yytname_[yytype] + " ("]b4_locations_if([
|
+ yytname_[yytype] + " ("]b4_locations_if([
|
||||||
+ yylocationp + ": "])[
|
+ yylocationp + ": "])[
|
||||||
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
|
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
|
||||||
}
|
}]])[
|
||||||
|
|
||||||
]b4_push_if([],[[
|
]b4_push_if([],[[
|
||||||
/**
|
/**
|
||||||
@@ -560,31 +542,30 @@ b4_define_state])[
|
|||||||
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||||
* imply that there were no syntax errors.
|
* 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([
|
]b4_push_if([
|
||||||
/**
|
/**
|
||||||
* Push Parse input from external lexer
|
* Push Parse input from external lexer
|
||||||
*
|
*
|
||||||
* @@param yylextoken current token
|
* @@param yylextoken current token
|
||||||
* @@param yylexval current lval
|
* @@param yylexval current lval]b4_locations_if([[
|
||||||
]b4_locations_if([ * @@param yylexloc current position])[
|
* @@param yylexloc current position]])[
|
||||||
*
|
*
|
||||||
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
||||||
*/
|
*/
|
||||||
public int push_parse (int yylextoken, b4_yystype yylexval[]b4_locations_if([, b4_location_type yylexloc]))
|
public int push_parse (int yylextoken, b4_yystype yylexval[]b4_locations_if([, b4_location_type yylexloc]))b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])])[
|
||||||
b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])])[
|
{]b4_locations_if([[
|
||||||
{
|
/* @@$. */
|
||||||
]b4_locations_if([/* @@$. */
|
]b4_location_type[ yyloc;]])[
|
||||||
b4_location_type yyloc;])[
|
|
||||||
]b4_push_if([],[[
|
]b4_push_if([],[[
|
||||||
]b4_define_state[
|
]b4_define_state[]b4_parse_trace_if([[
|
||||||
yycdebug ("Starting parse\n");
|
yycdebug ("Starting parse\n");]])[
|
||||||
yyerrstatus_ = 0;
|
yyerrstatus_ = 0;
|
||||||
|
|
||||||
/* Initialize the stack. */
|
/* Initialize the stack. */
|
||||||
yystack.push (yystate, yylval ]b4_locations_if([, yylloc])[);
|
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||||
]m4_ifdef([b4_initial_action], [
|
]m4_ifdef([b4_initial_action], [
|
||||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
||||||
b4_user_initial_action
|
b4_user_initial_action
|
||||||
b4_dollar_popdef[]dnl
|
b4_dollar_popdef[]dnl
|
||||||
])[
|
])[
|
||||||
@@ -594,11 +575,11 @@ b4_dollar_popdef[]dnl
|
|||||||
{
|
{
|
||||||
push_parse_initialize ();
|
push_parse_initialize ();
|
||||||
]m4_ifdef([b4_initial_action], [
|
]m4_ifdef([b4_initial_action], [
|
||||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
||||||
b4_user_initial_action
|
b4_user_initial_action
|
||||||
b4_dollar_popdef[]dnl
|
b4_dollar_popdef[]dnl
|
||||||
])[
|
])[]b4_parse_trace_if([[
|
||||||
yycdebug ("Starting parse\n");
|
yycdebug ("Starting parse\n");]])[
|
||||||
yyerrstatus_ = 0;
|
yyerrstatus_ = 0;
|
||||||
} else
|
} else
|
||||||
label = YYGETTOKEN;
|
label = YYGETTOKEN;
|
||||||
@@ -610,10 +591,10 @@ b4_dollar_popdef[]dnl
|
|||||||
{
|
{
|
||||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||||
pushed when we come here. */
|
pushed when we come here. */
|
||||||
case YYNEWSTATE:
|
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||||
yycdebug ("Entering state " + yystate + "\n");
|
yycdebug ("Entering state " + yystate + "\n");
|
||||||
if (yydebug > 0)
|
if (0 < yydebug)
|
||||||
yystack.print (yyDebugStream);
|
yystack.print (yyDebugStream);]])[
|
||||||
|
|
||||||
/* Accept? */
|
/* Accept? */
|
||||||
if (yystate == yyfinal_)
|
if (yystate == yyfinal_)
|
||||||
@@ -622,7 +603,7 @@ b4_dollar_popdef[]dnl
|
|||||||
|
|
||||||
/* Take a decision. First try without lookahead. */
|
/* Take a decision. First try without lookahead. */
|
||||||
yyn = yypact_[yystate];
|
yyn = yypact_[yystate];
|
||||||
if (yy_pact_value_is_default_ (yyn))
|
if (yyPactValueIsDefault (yyn))
|
||||||
{
|
{
|
||||||
label = YYDEFAULT;
|
label = YYDEFAULT;
|
||||||
break;
|
break;
|
||||||
@@ -635,14 +616,13 @@ b4_dollar_popdef[]dnl
|
|||||||
{
|
{
|
||||||
]b4_push_if([[
|
]b4_push_if([[
|
||||||
if (!push_token_consumed)
|
if (!push_token_consumed)
|
||||||
return YYPUSH_MORE;
|
return YYPUSH_MORE;]b4_parse_trace_if([[
|
||||||
yycdebug ("Reading a token: ");
|
yycdebug ("Reading a token: ");]])[
|
||||||
yychar = yylextoken;
|
yychar = yylextoken;
|
||||||
yylval = yylexval;]b4_locations_if([
|
yylval = yylexval;]b4_locations_if([
|
||||||
yylloc = yylexloc;])[
|
yylloc = yylexloc;])[
|
||||||
push_token_consumed = false;]])[
|
push_token_consumed = false;]], [b4_parse_trace_if([[
|
||||||
]b4_push_if([],[[
|
yycdebug ("Reading a token: ");]])[
|
||||||
yycdebug ("Reading a token: ");
|
|
||||||
yychar = yylexer.yylex ();
|
yychar = yylexer.yylex ();
|
||||||
yylval = yylexer.getLVal ();]b4_locations_if([
|
yylval = yylexer.getLVal ();]b4_locations_if([
|
||||||
yylloc = new b4_location_type (yylexer.getStartPos (),
|
yylloc = new b4_location_type (yylexer.getStartPos (),
|
||||||
@@ -651,17 +631,9 @@ b4_dollar_popdef[]dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert token to internal form. */
|
/* Convert token to internal form. */
|
||||||
if (yychar <= Lexer.EOF)
|
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||||
{
|
yySymbolPrint ("Next token is", yytoken,
|
||||||
yychar = yytoken = Lexer.EOF;
|
yylval]b4_locations_if([, yylloc])[);]])[
|
||||||
yycdebug ("Now at end of input.\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yytoken = yytranslate_ (yychar);
|
|
||||||
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
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||||
detect an error, take that action. */
|
detect an error, take that action. */
|
||||||
@@ -672,7 +644,7 @@ b4_dollar_popdef[]dnl
|
|||||||
/* <= 0 means reduce or error. */
|
/* <= 0 means reduce or error. */
|
||||||
else if ((yyn = yytable_[yyn]) <= 0)
|
else if ((yyn = yytable_[yyn]) <= 0)
|
||||||
{
|
{
|
||||||
if (yy_table_value_is_error_ (yyn))
|
if (yyTableValueIsError (yyn))
|
||||||
label = YYERRLAB;
|
label = YYERRLAB;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -683,10 +655,10 @@ b4_dollar_popdef[]dnl
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Shift the lookahead token. */
|
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||||
yy_symbol_print ("Shifting", yytoken,
|
yySymbolPrint ("Shifting", yytoken,
|
||||||
yylval]b4_locations_if([, yylloc])[);
|
yylval]b4_locations_if([, yylloc])[);
|
||||||
|
]])[
|
||||||
/* Discard the token being shifted. */
|
/* Discard the token being shifted. */
|
||||||
yychar = yyempty_;
|
yychar = yyempty_;
|
||||||
|
|
||||||
@@ -734,20 +706,21 @@ b4_dollar_popdef[]dnl
|
|||||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([yyerrloc = yylloc;])[
|
]b4_locations_if([[
|
||||||
|
yyerrloc = yylloc;]])[
|
||||||
if (yyerrstatus_ == 3)
|
if (yyerrstatus_ == 3)
|
||||||
{
|
{
|
||||||
/* If just tried and failed to reuse lookahead token after an
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
error, discard it. */
|
error, discard it. */
|
||||||
|
|
||||||
if (yychar <= Lexer.EOF)
|
if (yychar <= Lexer.EOF)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == Lexer.EOF)
|
if (yychar == Lexer.EOF)
|
||||||
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
]b4_push_if([{label = YYABORT; break;}], [return false;])[
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yychar = yyempty_;
|
yychar = yyempty_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* Else will try to reuse lookahead token after shifting the error
|
||||||
@@ -758,9 +731,8 @@ b4_dollar_popdef[]dnl
|
|||||||
/*-------------------------------------------------.
|
/*-------------------------------------------------.
|
||||||
| errorlab -- error raised explicitly by YYERROR. |
|
| errorlab -- error raised explicitly by YYERROR. |
|
||||||
`-------------------------------------------------*/
|
`-------------------------------------------------*/
|
||||||
case YYERROR:
|
case YYERROR:]b4_locations_if([[
|
||||||
|
yyerrloc = yystack.locationAt (yylen - 1);]])[
|
||||||
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
|
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
yystack.pop (yylen);
|
yystack.pop (yylen);
|
||||||
@@ -778,10 +750,10 @@ b4_dollar_popdef[]dnl
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
yyn = yypact_[yystate];
|
yyn = yypact_[yystate];
|
||||||
if (!yy_pact_value_is_default_ (yyn))
|
if (!yyPactValueIsDefault (yyn))
|
||||||
{
|
{
|
||||||
yyn += yyterror_;
|
yyn += yy_error_token_;
|
||||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
|
||||||
{
|
{
|
||||||
yyn = yytable_[yyn];
|
yyn = yytable_[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
@@ -794,27 +766,28 @@ b4_dollar_popdef[]dnl
|
|||||||
if (yystack.height == 0)
|
if (yystack.height == 0)
|
||||||
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
||||||
|
|
||||||
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
|
]b4_locations_if([[
|
||||||
|
yyerrloc = yystack.locationAt (0);]])[
|
||||||
yystack.pop ();
|
yystack.pop ();
|
||||||
yystate = yystack.stateAt (0);
|
yystate = yystack.stateAt (0);]b4_parse_trace_if([[
|
||||||
if (yydebug > 0)
|
if (0 < yydebug)
|
||||||
yystack.print (yyDebugStream);
|
yystack.print (yyDebugStream);]])[
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label == YYABORT)
|
if (label == YYABORT)
|
||||||
/* Leave the switch. */
|
/* Leave the switch. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
]b4_locations_if([
|
]b4_locations_if([[
|
||||||
/* Muck with the stack to setup for yylloc. */
|
/* Muck with the stack to setup for yylloc. */
|
||||||
yystack.push (0, null, yylloc);
|
yystack.push (0, null, yylloc);
|
||||||
yystack.push (0, null, yyerrloc);
|
yystack.push (0, null, yyerrloc);
|
||||||
yyloc = yylloc (yystack, 2);
|
yyloc = yylloc (yystack, 2);
|
||||||
yystack.pop (2);])[
|
yystack.pop (2);]])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */]b4_parse_trace_if([[
|
||||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
yySymbolPrint ("Shifting", yystos_[yyn],
|
||||||
yylval]b4_locations_if([, yyloc])[);
|
yylval]b4_locations_if([, yyloc])[);]])[
|
||||||
|
|
||||||
yystate = yyn;
|
yystate = yyn;
|
||||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||||
@@ -852,10 +825,10 @@ b4_dollar_popdef[]dnl
|
|||||||
this.label = YYNEWSTATE;
|
this.label = YYNEWSTATE;
|
||||||
|
|
||||||
/* Error handling. */
|
/* Error handling. */
|
||||||
this.yynerrs_ = 0;
|
this.yynerrs_ = 0;]b4_locations_if([[
|
||||||
]b4_locations_if([/* The location where the error started. */
|
/* The location where the error started. */
|
||||||
this.yyerrloc = null;
|
this.yyerrloc = null;
|
||||||
this.yylloc = new b4_location_type (null, null);])[
|
this.yylloc = new ]b4_location_type[ (null, null);]])[
|
||||||
|
|
||||||
/* Semantic value of the lookahead. */
|
/* Semantic value of the lookahead. */
|
||||||
this.yylval = null;
|
this.yylval = null;
|
||||||
@@ -875,14 +848,13 @@ b4_dollar_popdef[]dnl
|
|||||||
*
|
*
|
||||||
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
||||||
*/
|
*/
|
||||||
public int push_parse (int yylextoken, b4_yystype yylexval, b4_position_type yylexpos)
|
public int push_parse (int yylextoken, b4_yystype yylexval, b4_position_type yylexpos)b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])
|
||||||
b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])
|
|
||||||
{
|
{
|
||||||
return push_parse (yylextoken, yylexval, new b4_location_type (yylexpos));
|
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
|
* Parse input from the scanner that was specified at object construction
|
||||||
* time. Return whether the end of the input was reached successfully.
|
* time. Return whether the end of the input was reached successfully.
|
||||||
@@ -891,21 +863,21 @@ b4_both_if([[
|
|||||||
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
||||||
* imply that there were no syntax errors.
|
* imply that there were no syntax errors.
|
||||||
*/
|
*/
|
||||||
public boolean parse () ]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[
|
public boolean parse ()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[
|
||||||
{
|
{
|
||||||
if (yylexer == null)
|
if (yylexer == null)
|
||||||
throw new NullPointerException("Null Lexer");
|
throw new NullPointerException("Null Lexer");
|
||||||
int status;
|
int status;
|
||||||
do {
|
do {
|
||||||
int token = yylexer.yylex();
|
int token = yylexer.yylex();
|
||||||
]b4_yystype[ lval = yylexer.getLVal();
|
]b4_yystype[ lval = yylexer.getLVal();
|
||||||
]b4_locations_if([dnl
|
]b4_locations_if([dnl
|
||||||
b4_location_type yyloc = new b4_location_type (yylexer.getStartPos (),
|
b4_location_type yyloc = new b4_location_type (yylexer.getStartPos (),
|
||||||
yylexer.getEndPos ());])[
|
yylexer.getEndPos ());])[]b4_locations_if([[
|
||||||
]b4_locations_if([status = push_parse(token,lval,yyloc);],[
|
status = push_parse(token,lval,yyloc);]], [[
|
||||||
status = push_parse(token,lval);])[
|
status = push_parse(token,lval);]])[
|
||||||
} while (status == YYPUSH_MORE);
|
} while (status == YYPUSH_MORE);
|
||||||
return (status == YYACCEPT);
|
return (status == YYACCEPT);
|
||||||
}
|
}
|
||||||
]])[
|
]])[
|
||||||
|
|
||||||
@@ -948,7 +920,7 @@ b4_both_if([[
|
|||||||
new StringBuffer ("syntax error, unexpected ");
|
new StringBuffer ("syntax error, unexpected ");
|
||||||
res.append (yytnamerr_ (yytname_[tok]));
|
res.append (yytnamerr_ (yytname_[tok]));
|
||||||
int yyn = yypact_[yystate];
|
int yyn = yypact_[yystate];
|
||||||
if (!yy_pact_value_is_default_ (yyn))
|
if (!yyPactValueIsDefault (yyn))
|
||||||
{
|
{
|
||||||
/* Start YYX at -YYN if negative to avoid negative
|
/* Start YYX at -YYN if negative to avoid negative
|
||||||
indexes in YYCHECK. In other words, skip the first
|
indexes in YYCHECK. In other words, skip the first
|
||||||
@@ -960,15 +932,15 @@ b4_both_if([[
|
|||||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int x = yyxbegin; x < yyxend; ++x)
|
for (int x = yyxbegin; x < yyxend; ++x)
|
||||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||||
++count;
|
++count;
|
||||||
if (count < 5)
|
if (count < 5)
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
for (int x = yyxbegin; x < yyxend; ++x)
|
for (int x = yyxbegin; x < yyxend; ++x)
|
||||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
if (yycheck_[x + yyn] == x && x != yy_error_token_
|
||||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
&& !yyTableValueIsError (yytable_[x + yyn]))
|
||||||
{
|
{
|
||||||
res.append (count++ == 0 ? ", expecting " : " or ");
|
res.append (count++ == 0 ? ", expecting " : " or ");
|
||||||
res.append (yytnamerr_ (yytname_[x]));
|
res.append (yytnamerr_ (yytname_[x]));
|
||||||
@@ -986,7 +958,7 @@ b4_both_if([[
|
|||||||
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
||||||
* @@param yyvalue the value to check
|
* @@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_;
|
return yyvalue == yypact_ninf_;
|
||||||
}
|
}
|
||||||
@@ -996,7 +968,7 @@ b4_both_if([[
|
|||||||
* value indicates a syntax error.
|
* value indicates a syntax error.
|
||||||
* @@param yyvalue the value to check
|
* @@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_;
|
return yyvalue == yytable_ninf_;
|
||||||
}
|
}
|
||||||
@@ -1005,20 +977,18 @@ b4_both_if([[
|
|||||||
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
||||||
|
|
||||||
]b4_parser_tables_define[
|
]b4_parser_tables_define[
|
||||||
]b4_integral_parser_table_define([token_number], [b4_toknum],
|
|
||||||
[[YYTOKEN_NUMBER[YYLEX-NUM] -- Internal symbol number corresponding
|
|
||||||
to YYLEX-NUM.]])[
|
|
||||||
|
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||||
|
|
||||||
|
]b4_parse_trace_if([[
|
||||||
]b4_integral_parser_table_define([rline], [b4_rline],
|
]b4_integral_parser_table_define([rline], [b4_rline],
|
||||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
||||||
|
|
||||||
|
|
||||||
// Report on the debug stream that the rule yyrule is going to be reduced.
|
// 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)
|
if (yydebug == 0)
|
||||||
return;
|
return;
|
||||||
@@ -1031,36 +1001,44 @@ b4_both_if([[
|
|||||||
|
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||||
yy_symbol_print (" $" + (yyi + 1) + " =",
|
yySymbolPrint (" $" + (yyi + 1) + " =",
|
||||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||||
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||||
}
|
}]])[
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
|
||||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
|
||||||
|
|
||||||
|
/* YYTRANSLATE_(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||||
|
as returned by yylex, with out-of-bounds checking. */
|
||||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||||
{
|
]b4_api_token_raw_if(dnl
|
||||||
if (t >= 0 && t <= yyuser_token_number_max_)
|
[[ {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
]],
|
||||||
|
[[ {
|
||||||
|
int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
|
]b4_int_type_for([b4_translate])[ undef_token_ = ]b4_undef_token_number[;
|
||||||
|
|
||||||
|
if (t <= 0)
|
||||||
|
return Lexer.EOF;
|
||||||
|
else if (t <= user_token_number_max_)
|
||||||
return yytranslate_table_[t];
|
return yytranslate_table_[t];
|
||||||
else
|
else
|
||||||
return yyundef_token_;
|
return undef_token_;
|
||||||
}
|
}
|
||||||
|
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||||
|
]])[
|
||||||
|
|
||||||
|
private static final ]b4_int_type_for([b4_translate])[ yy_error_token_ = 1;
|
||||||
|
|
||||||
private static final int yylast_ = ]b4_last[;
|
private static final int yylast_ = ]b4_last[;
|
||||||
private static final int yynnts_ = ]b4_nterms_number[;
|
private static final int yynnts_ = ]b4_nterms_number[;
|
||||||
private static final int yyempty_ = -2;
|
private static final int yyempty_ = -2;
|
||||||
private static final int yyfinal_ = ]b4_final_state_number[;
|
private static final int yyfinal_ = ]b4_final_state_number[;
|
||||||
private static final int yyterror_ = 1;
|
|
||||||
private static final int yyerrcode_ = 256;
|
|
||||||
private static final int yyntokens_ = ]b4_tokens_number[;
|
private static final int yyntokens_ = ]b4_tokens_number[;
|
||||||
|
|
||||||
private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
/* User implementation code. */
|
||||||
private static final int yyundef_token_ = ]b4_undef_token_number[;
|
]b4_percent_code_get[]dnl
|
||||||
|
|
||||||
]/* User implementation code. */
|
|
||||||
b4_percent_code_get[]dnl
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
m4_pushdef([b4_copyright_years],
|
m4_pushdef([b4_copyright_years],
|
||||||
[2002-2015, 2018])
|
[2002-2015, 2018-2020])
|
||||||
|
|
||||||
|
|
||||||
# b4_position_file
|
# b4_position_file
|
||||||
@@ -62,11 +62,14 @@ m4_define([b4_location_define],
|
|||||||
[[ /// A point in a source file.
|
[[ /// A point in a source file.
|
||||||
class position
|
class position
|
||||||
{
|
{
|
||||||
public:]m4_ifdef([b4_location_constructors], [[
|
public:
|
||||||
|
/// Type for line and column numbers.
|
||||||
|
typedef int counter_type;
|
||||||
|
]m4_ifdef([b4_location_constructors], [[
|
||||||
/// Construct a position.
|
/// Construct a position.
|
||||||
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
: filename (f)
|
: filename (f)
|
||||||
, line (l)
|
, line (l)
|
||||||
, column (c)
|
, column (c)
|
||||||
@@ -75,8 +78,8 @@ m4_define([b4_location_define],
|
|||||||
]])[
|
]])[
|
||||||
/// Initialization.
|
/// Initialization.
|
||||||
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
|
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
{
|
{
|
||||||
filename = fn;
|
filename = fn;
|
||||||
line = l;
|
line = l;
|
||||||
@@ -86,17 +89,17 @@ m4_define([b4_location_define],
|
|||||||
/** \name Line and Column related manipulators
|
/** \name Line and Column related manipulators
|
||||||
** \{ */
|
** \{ */
|
||||||
/// (line related) Advance to the COUNT next lines.
|
/// (line related) Advance to the COUNT next lines.
|
||||||
void lines (int count = 1)
|
void lines (counter_type count = 1)
|
||||||
{
|
{
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
column = ]b4_location_initial_column[u;
|
column = ]b4_location_initial_column[;
|
||||||
line = add_ (line, count, ]b4_location_initial_line[);
|
line = add_ (line, count, ]b4_location_initial_line[);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// (column related) Advance to the COUNT next columns.
|
/// (column related) Advance to the COUNT next columns.
|
||||||
void columns (int count = 1)
|
void columns (counter_type count = 1)
|
||||||
{
|
{
|
||||||
column = add_ (column, count, ]b4_location_initial_column[);
|
column = add_ (column, count, ]b4_location_initial_column[);
|
||||||
}
|
}
|
||||||
@@ -105,22 +108,21 @@ m4_define([b4_location_define],
|
|||||||
/// File name to which this position refers.
|
/// File name to which this position refers.
|
||||||
]b4_percent_define_get([[filename_type]])[* filename;
|
]b4_percent_define_get([[filename_type]])[* filename;
|
||||||
/// Current line number.
|
/// Current line number.
|
||||||
unsigned line;
|
counter_type line;
|
||||||
/// Current column number.
|
/// Current column number.
|
||||||
unsigned column;
|
counter_type column;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Compute max (min, lhs+rhs).
|
/// Compute max (min, lhs+rhs).
|
||||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
||||||
{
|
{
|
||||||
return static_cast<unsigned> (std::max (min,
|
return lhs + rhs < min ? min : lhs + rhs;
|
||||||
static_cast<int> (lhs) + rhs));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Add \a width columns, in place.
|
/// Add \a width columns, in place.
|
||||||
inline position&
|
inline position&
|
||||||
operator+= (position& res, int width)
|
operator+= (position& res, position::counter_type width)
|
||||||
{
|
{
|
||||||
res.columns (width);
|
res.columns (width);
|
||||||
return res;
|
return res;
|
||||||
@@ -128,21 +130,21 @@ m4_define([b4_location_define],
|
|||||||
|
|
||||||
/// Add \a width columns.
|
/// Add \a width columns.
|
||||||
inline position
|
inline position
|
||||||
operator+ (position res, int width)
|
operator+ (position res, position::counter_type width)
|
||||||
{
|
{
|
||||||
return res += width;
|
return res += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns, in place.
|
/// Subtract \a width columns, in place.
|
||||||
inline position&
|
inline position&
|
||||||
operator-= (position& res, int width)
|
operator-= (position& res, position::counter_type width)
|
||||||
{
|
{
|
||||||
return res += -width;
|
return res += -width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns.
|
/// Subtract \a width columns.
|
||||||
inline position
|
inline position
|
||||||
operator- (position res, int width)
|
operator- (position res, position::counter_type width)
|
||||||
{
|
{
|
||||||
return res -= width;
|
return res -= width;
|
||||||
}
|
}
|
||||||
@@ -182,6 +184,8 @@ m4_define([b4_location_define],
|
|||||||
class location
|
class location
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// Type for line and column numbers.
|
||||||
|
typedef position::counter_type counter_type;
|
||||||
]m4_ifdef([b4_location_constructors], [
|
]m4_ifdef([b4_location_constructors], [
|
||||||
/// Construct a location from \a b to \a e.
|
/// Construct a location from \a b to \a e.
|
||||||
location (const position& b, const position& e)
|
location (const position& b, const position& e)
|
||||||
@@ -197,8 +201,8 @@ m4_define([b4_location_define],
|
|||||||
|
|
||||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||||
explicit location (]b4_percent_define_get([[filename_type]])[* f,
|
explicit location (]b4_percent_define_get([[filename_type]])[* f,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
: begin (f, l, c)
|
: begin (f, l, c)
|
||||||
, end (f, l, c)
|
, end (f, l, c)
|
||||||
{}
|
{}
|
||||||
@@ -206,8 +210,8 @@ m4_define([b4_location_define],
|
|||||||
])[
|
])[
|
||||||
/// Initialization.
|
/// Initialization.
|
||||||
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
{
|
{
|
||||||
begin.initialize (f, l, c);
|
begin.initialize (f, l, c);
|
||||||
end = begin;
|
end = begin;
|
||||||
@@ -223,13 +227,13 @@ m4_define([b4_location_define],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next columns.
|
/// Extend the current location to the COUNT next columns.
|
||||||
void columns (int count = 1)
|
void columns (counter_type count = 1)
|
||||||
{
|
{
|
||||||
end += count;
|
end += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next lines.
|
/// Extend the current location to the COUNT next lines.
|
||||||
void lines (int count = 1)
|
void lines (counter_type count = 1)
|
||||||
{
|
{
|
||||||
end.lines (count);
|
end.lines (count);
|
||||||
}
|
}
|
||||||
@@ -244,39 +248,45 @@ m4_define([b4_location_define],
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Join two locations, in place.
|
/// Join two locations, in place.
|
||||||
inline location& operator+= (location& res, const location& end)
|
inline location&
|
||||||
|
operator+= (location& res, const location& end)
|
||||||
{
|
{
|
||||||
res.end = end.end;
|
res.end = end.end;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Join two locations.
|
/// Join two locations.
|
||||||
inline location operator+ (location res, const location& end)
|
inline location
|
||||||
|
operator+ (location res, const location& end)
|
||||||
{
|
{
|
||||||
return res += end;
|
return res += end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add \a width columns to the end position, in place.
|
/// Add \a width columns to the end position, in place.
|
||||||
inline location& operator+= (location& res, int width)
|
inline location&
|
||||||
|
operator+= (location& res, location::counter_type width)
|
||||||
{
|
{
|
||||||
res.columns (width);
|
res.columns (width);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add \a width columns to the end position.
|
/// Add \a width columns to the end position.
|
||||||
inline location operator+ (location res, int width)
|
inline location
|
||||||
|
operator+ (location res, location::counter_type width)
|
||||||
{
|
{
|
||||||
return res += width;
|
return res += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns to the end position, in place.
|
/// Subtract \a width columns to the end position, in place.
|
||||||
inline location& operator-= (location& res, int width)
|
inline location&
|
||||||
|
operator-= (location& res, location::counter_type width)
|
||||||
{
|
{
|
||||||
return res += -width;
|
return res += -width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns to the end position.
|
/// Subtract \a width columns to the end position.
|
||||||
inline location operator- (location res, int width)
|
inline location
|
||||||
|
operator- (location res, location::counter_type width)
|
||||||
{
|
{
|
||||||
return res -= width;
|
return res -= width;
|
||||||
}
|
}
|
||||||
@@ -305,7 +315,8 @@ m4_define([b4_location_define],
|
|||||||
std::basic_ostream<YYChar>&
|
std::basic_ostream<YYChar>&
|
||||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||||
{
|
{
|
||||||
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
location::counter_type end_col
|
||||||
|
= 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||||
ostr << loc.begin;
|
ostr << loc.begin;
|
||||||
if (loc.end.filename
|
if (loc.end.filename
|
||||||
&& (!loc.begin.filename
|
&& (!loc.begin.filename
|
||||||
@@ -327,7 +338,7 @@ m4_ifdef([b4_position_file], [[
|
|||||||
// used to define is now defined in "]b4_location_file[".
|
// used to define is now defined in "]b4_location_file[".
|
||||||
//
|
//
|
||||||
// To get rid of this 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
|
// 2. remove references to this file from your build system
|
||||||
// 3. if you used to include it, include "]b4_location_file[" instead.
|
// 3. if you used to include it, include "]b4_location_file[" instead.
|
||||||
|
|
||||||
@@ -346,7 +357,6 @@ m4_ifdef([b4_location_file], [[
|
|||||||
|
|
||||||
]b4_cpp_guard_open([b4_location_path])[
|
]b4_cpp_guard_open([b4_location_path])[
|
||||||
|
|
||||||
# include <algorithm> // std::max
|
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <string>
|
# include <string>
|
||||||
|
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
|
||||||
|
# b4_stack_file
|
||||||
|
# -------------
|
||||||
|
# Name of the file containing the stack class, if we want this file.
|
||||||
|
b4_defines_if([b4_required_version_if([302], [],
|
||||||
|
[m4_define([b4_stack_file], [stack.hh])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_stack_define
|
||||||
|
# ---------------
|
||||||
|
m4_define([b4_stack_define],
|
||||||
|
[[ /// A stack with random access from its top.
|
||||||
|
template <typename T, typename S = std::vector<T> >
|
||||||
|
class stack
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Hide our reversed order.
|
||||||
|
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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/// Random access.
|
||||||
|
///
|
||||||
|
/// Index 0 returns the topmost element.
|
||||||
|
const T&
|
||||||
|
operator[] (index_type i) const
|
||||||
|
{
|
||||||
|
return seq_[size_type (size () - 1 - i)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Random access.
|
||||||
|
///
|
||||||
|
/// Index 0 returns the topmost element.
|
||||||
|
T&
|
||||||
|
operator[] (index_type i)
|
||||||
|
{
|
||||||
|
return seq_[size_type (size () - 1 - i)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Steal the contents of \a t.
|
||||||
|
///
|
||||||
|
/// Close to move-semantics.
|
||||||
|
void
|
||||||
|
push (YY_MOVE_REF (T) t)
|
||||||
|
{
|
||||||
|
seq_.push_back (T ());
|
||||||
|
operator[] (0).move (t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pop elements from the stack.
|
||||||
|
void
|
||||||
|
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
for (; 0 < n; --n)
|
||||||
|
seq_.pop_back ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pop all elements from the stack.
|
||||||
|
void
|
||||||
|
clear () YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
seq_.clear ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Number of elements on the stack.
|
||||||
|
index_type
|
||||||
|
size () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return index_type (seq_.size ());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ptrdiff_t
|
||||||
|
ssize () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return std::ptrdiff_t (size ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Iterator on top of the stack (going downwards).
|
||||||
|
const_iterator
|
||||||
|
begin () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return seq_.rbegin ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bottom of the stack.
|
||||||
|
const_iterator
|
||||||
|
end () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
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_;
|
||||||
|
};
|
||||||
|
]])
|
||||||
|
|
||||||
|
m4_ifdef([b4_stack_file],
|
||||||
|
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
||||||
|
]b4_generated_by[
|
||||||
|
// Starting with Bison 3.2, this file is useless: the structure it
|
||||||
|
// used to define is now defined with the parser itself.
|
||||||
|
//
|
||||||
|
// To get rid of this file:
|
||||||
|
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||||
|
// 2. remove references to this file from your build system.
|
||||||
|
]b4_output_end[
|
||||||
|
]])
|
||||||
@@ -0,0 +1,453 @@
|
|||||||
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
|
||||||
|
## --------- ##
|
||||||
|
## variant. ##
|
||||||
|
## --------- ##
|
||||||
|
|
||||||
|
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
||||||
|
# YYTYPE.
|
||||||
|
m4_define([b4_symbol_variant],
|
||||||
|
[m4_pushdef([b4_dollar_dollar],
|
||||||
|
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
||||||
|
switch ($1)
|
||||||
|
{
|
||||||
|
b4_type_foreach([_b4_type_action])[]dnl
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# _b4_char_sizeof_counter
|
||||||
|
# -----------------------
|
||||||
|
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
|
||||||
|
m4_define([_b4_char_sizeof_counter],
|
||||||
|
[0])
|
||||||
|
|
||||||
|
# _b4_char_sizeof_dummy
|
||||||
|
# ---------------------
|
||||||
|
# At each call return a new C++ identifier.
|
||||||
|
m4_define([_b4_char_sizeof_dummy],
|
||||||
|
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
|
||||||
|
dummy[]_b4_char_sizeof_counter])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_char_sizeof(SYMBOL-NUMS)
|
||||||
|
# ---------------------------
|
||||||
|
# To be mapped on the list of type names to produce:
|
||||||
|
#
|
||||||
|
# char dummy1[sizeof (type_name_1)];
|
||||||
|
# char dummy2[sizeof (type_name_2)];
|
||||||
|
#
|
||||||
|
# for defined type names.
|
||||||
|
m4_define([b4_char_sizeof],
|
||||||
|
[b4_symbol_if([$1], [has_type],
|
||||||
|
[
|
||||||
|
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
||||||
|
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
|
||||||
|
])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_variant_includes
|
||||||
|
# -------------------
|
||||||
|
# The needed includes for variants support.
|
||||||
|
m4_define([b4_variant_includes],
|
||||||
|
[b4_parse_assert_if([[#include <typeinfo>]])[
|
||||||
|
#ifndef YY_ASSERT
|
||||||
|
# include <cassert>
|
||||||
|
# define YY_ASSERT assert
|
||||||
|
#endif
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## -------------------------- ##
|
||||||
|
## Adjustments for variants. ##
|
||||||
|
## -------------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_value_type_declare
|
||||||
|
# ---------------------
|
||||||
|
# Define semantic_type.
|
||||||
|
m4_define([b4_value_type_declare],
|
||||||
|
[[ /// A buffer to store and retrieve objects.
|
||||||
|
///
|
||||||
|
/// Sort of a variant, but does not keep track of the nature
|
||||||
|
/// of the stored data, since that knowledge is available
|
||||||
|
/// via the current parser state.
|
||||||
|
class semantic_type
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Type of *this.
|
||||||
|
typedef semantic_type self_type;
|
||||||
|
|
||||||
|
/// Empty construction.
|
||||||
|
semantic_type () YY_NOEXCEPT
|
||||||
|
: yybuffer_ ()]b4_parse_assert_if([
|
||||||
|
, yytypeid_ (YY_NULLPTR)])[
|
||||||
|
{}
|
||||||
|
|
||||||
|
/// Construct and fill.
|
||||||
|
template <typename T>
|
||||||
|
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||||
|
: yytypeid_ (&typeid (T))])[
|
||||||
|
{
|
||||||
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
|
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destruction, allowed only if empty.
|
||||||
|
~semantic_type () YY_NOEXCEPT
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (!yytypeid_);
|
||||||
|
])[}
|
||||||
|
|
||||||
|
# if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Instantiate a \a T in here from \a t.
|
||||||
|
template <typename T, typename... U>
|
||||||
|
T&
|
||||||
|
emplace (U&&... u)
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (!yytypeid_);
|
||||||
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
|
yytypeid_ = & typeid (T);])[
|
||||||
|
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
/// Instantiate an empty \a T in here.
|
||||||
|
template <typename T>
|
||||||
|
T&
|
||||||
|
emplace ()
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (!yytypeid_);
|
||||||
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
|
yytypeid_ = & typeid (T);])[
|
||||||
|
return *new (yyas_<T> ()) T ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Instantiate a \a T in here from \a t.
|
||||||
|
template <typename T>
|
||||||
|
T&
|
||||||
|
emplace (const T& t)
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (!yytypeid_);
|
||||||
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
|
yytypeid_ = & typeid (T);])[
|
||||||
|
return *new (yyas_<T> ()) T (t);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/// Instantiate an empty \a T in here.
|
||||||
|
/// Obsolete, use emplace.
|
||||||
|
template <typename T>
|
||||||
|
T&
|
||||||
|
build ()
|
||||||
|
{
|
||||||
|
return emplace<T> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Instantiate a \a T in here from \a t.
|
||||||
|
/// Obsolete, use emplace.
|
||||||
|
template <typename T>
|
||||||
|
T&
|
||||||
|
build (const T& t)
|
||||||
|
{
|
||||||
|
return emplace<T> (t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Accessor to a built \a T.
|
||||||
|
template <typename T>
|
||||||
|
T&
|
||||||
|
as () YY_NOEXCEPT
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (yytypeid_);
|
||||||
|
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||||
|
YY_ASSERT (sizeof (T) <= size);])[
|
||||||
|
return *yyas_<T> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Const accessor to a built \a T (for %printer).
|
||||||
|
template <typename T>
|
||||||
|
const T&
|
||||||
|
as () const YY_NOEXCEPT
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (yytypeid_);
|
||||||
|
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||||
|
YY_ASSERT (sizeof (T) <= size);])[
|
||||||
|
return *yyas_<T> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Swap the content with \a that, of same type.
|
||||||
|
///
|
||||||
|
/// Both variants must be built beforehand, because swapping the actual
|
||||||
|
/// data requires reading it (with as()), and this is not possible on
|
||||||
|
/// unconstructed variants: it would require some dynamic testing, which
|
||||||
|
/// should not be the variant's responsibility.
|
||||||
|
/// Swapping between built and (possibly) non-built is done with
|
||||||
|
/// self_type::move ().
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
swap (self_type& that) YY_NOEXCEPT
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
YY_ASSERT (yytypeid_);
|
||||||
|
YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
|
||||||
|
std::swap (as<T> (), that.as<T> ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move the content of \a that to this.
|
||||||
|
///
|
||||||
|
/// Destroys \a that.
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
move (self_type& that)
|
||||||
|
{
|
||||||
|
# if 201103L <= YY_CPLUSPLUS
|
||||||
|
emplace<T> (std::move (that.as<T> ()));
|
||||||
|
# else
|
||||||
|
emplace<T> ();
|
||||||
|
swap<T> (that);
|
||||||
|
# endif
|
||||||
|
that.destroy<T> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
# if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Move the content of \a that to this.
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
move (self_type&& that)
|
||||||
|
{
|
||||||
|
emplace<T> (std::move (that.as<T> ()));
|
||||||
|
that.destroy<T> ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Copy the content of \a that to this.
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
copy (const self_type& that)
|
||||||
|
{
|
||||||
|
emplace<T> (that.as<T> ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destroy the stored \a T.
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
destroy ()
|
||||||
|
{
|
||||||
|
as<T> ().~T ();]b4_parse_assert_if([
|
||||||
|
yytypeid_ = YY_NULLPTR;])[
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Prohibit blind copies.
|
||||||
|
self_type& operator= (const self_type&);
|
||||||
|
semantic_type (const self_type&);
|
||||||
|
|
||||||
|
/// Accessor to raw memory as \a T.
|
||||||
|
template <typename T>
|
||||||
|
T*
|
||||||
|
yyas_ () YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
void *yyp = yybuffer_.yyraw;
|
||||||
|
return static_cast<T*> (yyp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Const accessor to raw memory as \a T.
|
||||||
|
template <typename T>
|
||||||
|
const T*
|
||||||
|
yyas_ () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
const void *yyp = yybuffer_.yyraw;
|
||||||
|
return static_cast<const T*> (yyp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An auxiliary type to compute the largest semantic type.
|
||||||
|
union union_type
|
||||||
|
{]b4_type_foreach([b4_char_sizeof])[ };
|
||||||
|
|
||||||
|
/// The size of the largest semantic type.
|
||||||
|
enum { size = sizeof (union_type) };
|
||||||
|
|
||||||
|
/// A buffer to store semantic values.
|
||||||
|
union
|
||||||
|
{
|
||||||
|
/// Strongest alignment constraints.
|
||||||
|
long double yyalign_me;
|
||||||
|
/// A buffer large enough to store any of the semantic values.
|
||||||
|
char yyraw[size];
|
||||||
|
} yybuffer_;]b4_parse_assert_if([
|
||||||
|
|
||||||
|
/// Whether the content is built: if defined, the name of the stored type.
|
||||||
|
const std::type_info *yytypeid_;])[
|
||||||
|
};
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
# How the semantic value is extracted when using variants.
|
||||||
|
|
||||||
|
# b4_symbol_value(VAL, SYMBOL-NUM, [TYPE])
|
||||||
|
# ----------------------------------------
|
||||||
|
# See README.
|
||||||
|
m4_define([b4_symbol_value],
|
||||||
|
[m4_ifval([$3],
|
||||||
|
[$1.as< $3 > ()],
|
||||||
|
[m4_ifval([$2],
|
||||||
|
[b4_symbol_if([$2], [has_type],
|
||||||
|
[$1.as < b4_symbol([$2], [type]) > ()],
|
||||||
|
[$1])],
|
||||||
|
[$1])])])
|
||||||
|
|
||||||
|
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
|
||||||
|
# -------------------------------------------------
|
||||||
|
# Same as b4_symbol_value, but used in a template method.
|
||||||
|
m4_define([b4_symbol_value_template],
|
||||||
|
[m4_ifval([$3],
|
||||||
|
[$1.template as< $3 > ()],
|
||||||
|
[m4_ifval([$2],
|
||||||
|
[b4_symbol_if([$2], [has_type],
|
||||||
|
[$1.template as < b4_symbol([$2], [type]) > ()],
|
||||||
|
[$1])],
|
||||||
|
[$1])])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------- ##
|
||||||
|
## make_SYMBOL. ##
|
||||||
|
## ------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# _b4_includes_tokens(SYMBOL-NUM...)
|
||||||
|
# ----------------------------------
|
||||||
|
# Expands to non-empty iff one of the SYMBOL-NUM denotes
|
||||||
|
# a token.
|
||||||
|
m4_define([_b4_is_token],
|
||||||
|
[b4_symbol_if([$1], [is_token], [1])])
|
||||||
|
m4_define([_b4_includes_tokens],
|
||||||
|
[m4_map([_b4_is_token], [$@])])
|
||||||
|
|
||||||
|
|
||||||
|
# _b4_token_maker_define(SYMBOL-NUM)
|
||||||
|
# ----------------------------------
|
||||||
|
# Declare make_SYMBOL for SYMBOL-NUM. Use at class-level.
|
||||||
|
m4_define([_b4_token_maker_define],
|
||||||
|
[b4_token_visible_if([$1],
|
||||||
|
[#if 201103L <= YY_CPLUSPLUS
|
||||||
|
static
|
||||||
|
symbol_type
|
||||||
|
make_[]_b4_symbol([$1], [id]) (b4_join(
|
||||||
|
b4_symbol_if([$1], [has_type],
|
||||||
|
[b4_symbol([$1], [type]) v]),
|
||||||
|
b4_locations_if([location_type l])))
|
||||||
|
{
|
||||||
|
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||||
|
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||||
|
b4_locations_if([std::move (l)])));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static
|
||||||
|
symbol_type
|
||||||
|
make_[]_b4_symbol([$1], [id]) (b4_join(
|
||||||
|
b4_symbol_if([$1], [has_type],
|
||||||
|
[const b4_symbol([$1], [type])& v]),
|
||||||
|
b4_locations_if([const location_type& l])))
|
||||||
|
{
|
||||||
|
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||||
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
|
b4_locations_if([l])));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
])])
|
||||||
|
|
||||||
|
|
||||||
|
m4_define([_b4_type_clause],
|
||||||
|
[b4_symbol_if([$1], [is_token],
|
||||||
|
[b4_symbol_if([$1], [has_id],
|
||||||
|
[tok == token::b4_symbol([$1], [id])],
|
||||||
|
[tok == b4_symbol([$1], [user_number])])])])
|
||||||
|
|
||||||
|
|
||||||
|
# _b4_token_constructor_define(SYMBOL-NUM...)
|
||||||
|
# -------------------------------------------
|
||||||
|
# Define a unique make_symbol for all the SYMBOL-NUM (they
|
||||||
|
# have the same type). Use at class-level.
|
||||||
|
m4_define([_b4_token_constructor_define],
|
||||||
|
[m4_ifval(_b4_includes_tokens($@),
|
||||||
|
[[#if 201103L <= YY_CPLUSPLUS
|
||||||
|
symbol_type (]b4_join(
|
||||||
|
[int tok],
|
||||||
|
b4_symbol_if([$1], [has_type],
|
||||||
|
[b4_symbol([$1], [type]) v]),
|
||||||
|
b4_locations_if([location_type l]))[)
|
||||||
|
: super_type(]b4_join([token_type (tok)],
|
||||||
|
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||||
|
b4_locations_if([std::move (l)]))[)
|
||||||
|
{
|
||||||
|
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
symbol_type (]b4_join(
|
||||||
|
[int tok],
|
||||||
|
b4_symbol_if([$1], [has_type],
|
||||||
|
[const b4_symbol([$1], [type])& v]),
|
||||||
|
b4_locations_if([const location_type& l]))[)
|
||||||
|
: super_type(]b4_join([token_type (tok)],
|
||||||
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
|
b4_locations_if([l]))[)
|
||||||
|
{
|
||||||
|
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
]])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_basic_symbol_constructor_define(SYMBOL-NUM)
|
||||||
|
# ----------------------------------------------
|
||||||
|
# Generate a constructor for basic_symbol from given type.
|
||||||
|
m4_define([b4_basic_symbol_constructor_define],
|
||||||
|
[[#if 201103L <= YY_CPLUSPLUS
|
||||||
|
basic_symbol (]b4_join(
|
||||||
|
[typename Base::kind_type t],
|
||||||
|
b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
|
||||||
|
b4_locations_if([location_type&& l]))[)
|
||||||
|
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||||
|
, value (std::move (v))])[]b4_locations_if([
|
||||||
|
, location (std::move (l))])[
|
||||||
|
{}
|
||||||
|
#else
|
||||||
|
basic_symbol (]b4_join(
|
||||||
|
[typename Base::kind_type t],
|
||||||
|
b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
|
||||||
|
b4_locations_if([const location_type& l]))[)
|
||||||
|
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||||
|
, value (v)])[]b4_locations_if([
|
||||||
|
, location (l)])[
|
||||||
|
{}
|
||||||
|
#endif
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_token_constructor_define
|
||||||
|
# ---------------------------
|
||||||
|
# Define the overloaded versions of make_symbol for all the value types.
|
||||||
|
m4_define([b4_token_constructor_define],
|
||||||
|
[ // Implementation of make_symbol for each symbol type.
|
||||||
|
b4_symbol_foreach([_b4_token_maker_define])])
|
||||||
+342
-288
File diff suppressed because it is too large
Load Diff
-159
@@ -1,159 +0,0 @@
|
|||||||
# C++ skeleton for Bison
|
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
# b4_stack_file
|
|
||||||
# -------------
|
|
||||||
# Name of the file containing the stack class, if we want this file.
|
|
||||||
b4_defines_if([b4_required_version_if([302], [],
|
|
||||||
[m4_define([b4_stack_file], [stack.hh])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_stack_define
|
|
||||||
# ---------------
|
|
||||||
m4_define([b4_stack_define],
|
|
||||||
[[ /// A stack with random access from its top.
|
|
||||||
template <typename T, typename S = std::vector<T> >
|
|
||||||
class stack
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Hide our reversed order.
|
|
||||||
typedef typename S::reverse_iterator iterator;
|
|
||||||
typedef typename S::const_reverse_iterator const_iterator;
|
|
||||||
typedef typename S::size_type size_type;
|
|
||||||
|
|
||||||
stack (size_type n = 200)
|
|
||||||
: seq_ (n)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// Random access.
|
|
||||||
///
|
|
||||||
/// Index 0 returns the topmost element.
|
|
||||||
T&
|
|
||||||
operator[] (size_type i)
|
|
||||||
{
|
|
||||||
return seq_[size () - 1 - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Random access.
|
|
||||||
///
|
|
||||||
/// Index 0 returns the topmost element.
|
|
||||||
T&
|
|
||||||
operator[] (int i)
|
|
||||||
{
|
|
||||||
return operator[] (size_type (i));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Random access.
|
|
||||||
///
|
|
||||||
/// 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Steal the contents of \a t.
|
|
||||||
///
|
|
||||||
/// Close to move-semantics.
|
|
||||||
void
|
|
||||||
push (YY_MOVE_REF (T) t)
|
|
||||||
{
|
|
||||||
seq_.push_back (T ());
|
|
||||||
operator[](0).move (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pop (int n = 1)
|
|
||||||
{
|
|
||||||
for (; 0 < n; --n)
|
|
||||||
seq_.pop_back ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
clear ()
|
|
||||||
{
|
|
||||||
seq_.clear ();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_type
|
|
||||||
size () const
|
|
||||||
{
|
|
||||||
return seq_.size ();
|
|
||||||
}
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
begin () const
|
|
||||||
{
|
|
||||||
return seq_.rbegin ();
|
|
||||||
}
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
end () const
|
|
||||||
{
|
|
||||||
return seq_.rend ();
|
|
||||||
}
|
|
||||||
|
|
||||||
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],
|
|
||||||
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
|
||||||
]b4_generated_by[
|
|
||||||
// Starting with Bison 3.2, this file is useless: the structure it
|
|
||||||
// used to define is now defined with the parser itself.
|
|
||||||
//
|
|
||||||
// To get rid of this file:
|
|
||||||
// 1. add 'require "3.2"' (or newer) to your grammar file
|
|
||||||
// 2. remove references to this file from your build system.
|
|
||||||
]b4_output_end[
|
|
||||||
]])
|
|
||||||
-427
@@ -1,427 +0,0 @@
|
|||||||
# C++ skeleton for Bison
|
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
## --------- ##
|
|
||||||
## variant. ##
|
|
||||||
## --------- ##
|
|
||||||
|
|
||||||
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
|
||||||
# ------------------------------------------------
|
|
||||||
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
|
||||||
# YYTYPE.
|
|
||||||
m4_define([b4_symbol_variant],
|
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
|
||||||
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
|
||||||
switch ($1)
|
|
||||||
{
|
|
||||||
b4_type_foreach([_b4_type_action])[]dnl
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# _b4_char_sizeof_counter
|
|
||||||
# -----------------------
|
|
||||||
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
|
|
||||||
m4_define([_b4_char_sizeof_counter],
|
|
||||||
[0])
|
|
||||||
|
|
||||||
# _b4_char_sizeof_dummy
|
|
||||||
# ---------------------
|
|
||||||
# At each call return a new C++ identifier.
|
|
||||||
m4_define([_b4_char_sizeof_dummy],
|
|
||||||
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
|
|
||||||
dummy[]_b4_char_sizeof_counter])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_char_sizeof(SYMBOL-NUMS)
|
|
||||||
# ---------------------------
|
|
||||||
# To be mapped on the list of type names to produce:
|
|
||||||
#
|
|
||||||
# char dummy1[sizeof (type_name_1)];
|
|
||||||
# char dummy2[sizeof (type_name_2)];
|
|
||||||
#
|
|
||||||
# for defined type names.
|
|
||||||
m4_define([b4_char_sizeof],
|
|
||||||
[b4_symbol_if([$1], [has_type],
|
|
||||||
[
|
|
||||||
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
|
||||||
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
|
|
||||||
])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_variant_includes
|
|
||||||
# -------------------
|
|
||||||
# The needed includes for variants support.
|
|
||||||
m4_define([b4_variant_includes],
|
|
||||||
[b4_parse_assert_if([[#include <typeinfo>]])[
|
|
||||||
#ifndef YYASSERT
|
|
||||||
# include <cassert>
|
|
||||||
# define YYASSERT assert
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
# b4_variant_define
|
|
||||||
# -----------------
|
|
||||||
# Define "variant".
|
|
||||||
m4_define([b4_variant_define],
|
|
||||||
[[ /// A char[S] buffer to store and retrieve objects.
|
|
||||||
///
|
|
||||||
/// Sort of a variant, but does not keep track of the nature
|
|
||||||
/// of the stored data, since that knowledge is available
|
|
||||||
/// via the current state.
|
|
||||||
template <size_t S>
|
|
||||||
struct variant
|
|
||||||
{
|
|
||||||
/// Type of *this.
|
|
||||||
typedef variant<S> self_type;
|
|
||||||
|
|
||||||
/// Empty construction.
|
|
||||||
variant ()
|
|
||||||
: yybuffer_ ()]b4_parse_assert_if([
|
|
||||||
, yytypeid_ (YY_NULLPTR)])[
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// Construct and fill.
|
|
||||||
template <typename T>
|
|
||||||
variant (YY_RVREF (T) t)]b4_parse_assert_if([
|
|
||||||
: yytypeid_ (&typeid (T))])[
|
|
||||||
{
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destruction, allowed only if empty.
|
|
||||||
~variant ()
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!yytypeid_);
|
|
||||||
])[}
|
|
||||||
|
|
||||||
/// Instantiate an empty \a T in here.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
emplace ()
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!yytypeid_);
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
yytypeid_ = & typeid (T);])[
|
|
||||||
return *new (yyas_<T> ()) T ();
|
|
||||||
}
|
|
||||||
|
|
||||||
# if 201103L <= YY_CPLUSPLUS
|
|
||||||
/// Instantiate a \a T in here from \a t.
|
|
||||||
template <typename T, typename U>
|
|
||||||
T&
|
|
||||||
emplace (U&& u)
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!yytypeid_);
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
yytypeid_ = & typeid (T);])[
|
|
||||||
return *new (yyas_<T> ()) T (std::forward <U>(u));
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
/// Instantiate a \a T in here from \a t.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
emplace (const T& t)
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!yytypeid_);
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
yytypeid_ = & typeid (T);])[
|
|
||||||
return *new (yyas_<T> ()) T (t);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/// Instantiate an empty \a T in here.
|
|
||||||
/// Obsolete, use emplace.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
build ()
|
|
||||||
{
|
|
||||||
return emplace<T> ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Instantiate a \a T in here from \a t.
|
|
||||||
/// Obsolete, use emplace.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
build (const T& t)
|
|
||||||
{
|
|
||||||
return emplace<T> (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Accessor to a built \a T.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
as ()
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (yytypeid_);
|
|
||||||
YYASSERT (*yytypeid_ == typeid (T));
|
|
||||||
YYASSERT (sizeof (T) <= S);])[
|
|
||||||
return *yyas_<T> ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Const accessor to a built \a T (for %printer).
|
|
||||||
template <typename T>
|
|
||||||
const T&
|
|
||||||
as () const
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (yytypeid_);
|
|
||||||
YYASSERT (*yytypeid_ == typeid (T));
|
|
||||||
YYASSERT (sizeof (T) <= S);])[
|
|
||||||
return *yyas_<T> ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Swap the content with \a other, of same type.
|
|
||||||
///
|
|
||||||
/// Both variants must be built beforehand, because swapping the actual
|
|
||||||
/// data requires reading it (with as()), and this is not possible on
|
|
||||||
/// unconstructed variants: it would require some dynamic testing, which
|
|
||||||
/// should not be the variant's responsibility.
|
|
||||||
/// Swapping between built and (possibly) non-built is done with
|
|
||||||
/// variant::move ().
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
swap (self_type& other)
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (yytypeid_);
|
|
||||||
YYASSERT (*yytypeid_ == *other.yytypeid_);])[
|
|
||||||
std::swap (as<T> (), other.as<T> ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Move the content of \a other to this.
|
|
||||||
///
|
|
||||||
/// Destroys \a other.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
move (self_type& other)
|
|
||||||
{
|
|
||||||
# if 201103L <= YY_CPLUSPLUS
|
|
||||||
emplace<T> (std::move (other.as<T> ()));
|
|
||||||
# else
|
|
||||||
emplace<T> ();
|
|
||||||
swap<T> (other);
|
|
||||||
# endif
|
|
||||||
other.destroy<T> ();
|
|
||||||
}
|
|
||||||
|
|
||||||
# if 201103L <= YY_CPLUSPLUS
|
|
||||||
/// Move the content of \a other to this.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
move (self_type&& other)
|
|
||||||
{
|
|
||||||
emplace<T> (std::move (other.as<T> ()));
|
|
||||||
other.destroy<T> ();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Copy the content of \a other to this.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
copy (const self_type& other)
|
|
||||||
{
|
|
||||||
emplace<T> (other.as<T> ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destroy the stored \a T.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
destroy ()
|
|
||||||
{
|
|
||||||
as<T> ().~T ();]b4_parse_assert_if([
|
|
||||||
yytypeid_ = YY_NULLPTR;])[
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Prohibit blind copies.
|
|
||||||
self_type& operator= (const self_type&);
|
|
||||||
variant (const self_type&);
|
|
||||||
|
|
||||||
/// Accessor to raw memory as \a T.
|
|
||||||
template <typename T>
|
|
||||||
T*
|
|
||||||
yyas_ ()
|
|
||||||
{
|
|
||||||
void *yyp = yybuffer_.yyraw;
|
|
||||||
return static_cast<T*> (yyp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Const accessor to raw memory as \a T.
|
|
||||||
template <typename T>
|
|
||||||
const T*
|
|
||||||
yyas_ () const
|
|
||||||
{
|
|
||||||
const void *yyp = yybuffer_.yyraw;
|
|
||||||
return static_cast<const T*> (yyp);
|
|
||||||
}
|
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
/// Strongest alignment constraints.
|
|
||||||
long double yyalign_me;
|
|
||||||
/// A buffer large enough to store any of the semantic values.
|
|
||||||
char yyraw[S];
|
|
||||||
} yybuffer_;]b4_parse_assert_if([
|
|
||||||
|
|
||||||
/// Whether the content is built: if defined, the name of the stored type.
|
|
||||||
const std::type_info *yytypeid_;])[
|
|
||||||
};
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
## -------------------------- ##
|
|
||||||
## Adjustments for variants. ##
|
|
||||||
## -------------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_value_type_declare
|
|
||||||
# ---------------------
|
|
||||||
# Declare semantic_type.
|
|
||||||
m4_define([b4_value_type_declare],
|
|
||||||
[[ /// An auxiliary type to compute the largest semantic type.
|
|
||||||
union union_type
|
|
||||||
{]b4_type_foreach([b4_char_sizeof])[};
|
|
||||||
|
|
||||||
/// Symbol semantic values.
|
|
||||||
typedef variant<sizeof (union_type)> semantic_type;][]dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# How the semantic value is extracted when using variants.
|
|
||||||
|
|
||||||
# b4_symbol_value(VAL, [TYPE])
|
|
||||||
# ----------------------------
|
|
||||||
m4_define([b4_symbol_value],
|
|
||||||
[m4_ifval([$2],
|
|
||||||
[$1.as< $2 > ()],
|
|
||||||
[$1])])
|
|
||||||
|
|
||||||
# b4_symbol_value_template(VAL, [TYPE])
|
|
||||||
# -------------------------------------
|
|
||||||
# Same as b4_symbol_value, but used in a template method.
|
|
||||||
m4_define([b4_symbol_value_template],
|
|
||||||
[m4_ifval([$2],
|
|
||||||
[$1.template as< $2 > ()],
|
|
||||||
[$1])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------- ##
|
|
||||||
## make_SYMBOL. ##
|
|
||||||
## ------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# _b4_symbol_constructor_declare(SYMBOL-NUMBER)
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Declare the overloaded version of make_symbol for the (common) type of
|
|
||||||
# these SYMBOL-NUMBERS. Use at class-level.
|
|
||||||
m4_define([_b4_symbol_constructor_declare],
|
|
||||||
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
|
||||||
[ static
|
|
||||||
symbol_type
|
|
||||||
make_[]_b4_symbol([$1], [id]) (dnl
|
|
||||||
b4_join(b4_symbol_if([$1], [has_type],
|
|
||||||
[YY_COPY (b4_symbol([$1], [type])) v]),
|
|
||||||
b4_locations_if([YY_COPY (location_type) l])));
|
|
||||||
|
|
||||||
])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_constructor_declare
|
|
||||||
# -----------------------------
|
|
||||||
# Declare symbol constructors for all the value types.
|
|
||||||
# Use at class-level.
|
|
||||||
m4_define([b4_symbol_constructor_declare],
|
|
||||||
[ // Symbol constructors declarations.
|
|
||||||
b4_symbol_foreach([_b4_symbol_constructor_declare])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# _b4_symbol_constructor_define(SYMBOL-NUMBER)
|
|
||||||
# --------------------------------------------
|
|
||||||
# Define symbol constructor for this SYMBOL-NUMBER.
|
|
||||||
m4_define([_b4_symbol_constructor_define],
|
|
||||||
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
|
||||||
[ inline
|
|
||||||
b4_parser_class_name::symbol_type
|
|
||||||
b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl
|
|
||||||
b4_join(b4_symbol_if([$1], [has_type],
|
|
||||||
[YY_COPY (b4_symbol([$1], [type])) v]),
|
|
||||||
b4_locations_if([YY_COPY (location_type) l])))
|
|
||||||
{
|
|
||||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
|
||||||
b4_symbol_if([$1], [has_type], [YY_MOVE (v)]),
|
|
||||||
b4_locations_if([YY_MOVE (l)])));
|
|
||||||
}
|
|
||||||
|
|
||||||
])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_basic_symbol_constructor_declare
|
|
||||||
# -----------------------------------
|
|
||||||
# Generate a constructor declaration for basic_symbol from given type.
|
|
||||||
m4_define([b4_basic_symbol_constructor_declare],
|
|
||||||
[[# if 201103L <= YY_CPLUSPLUS
|
|
||||||
basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
|
|
||||||
b4_locations_if([location_type&& l]))[);
|
|
||||||
#else
|
|
||||||
basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
|
|
||||||
b4_locations_if([const location_type& l]))[);
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
# b4_basic_symbol_constructor_define
|
|
||||||
# ----------------------------------
|
|
||||||
# Generate a constructor implementation for basic_symbol from given type.
|
|
||||||
m4_define([b4_basic_symbol_constructor_define],
|
|
||||||
[[# if 201103L <= YY_CPLUSPLUS
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
|
|
||||||
b4_locations_if([location_type&& l]))[)
|
|
||||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
|
||||||
, value (std::move (v))])[]b4_locations_if([
|
|
||||||
, location (std::move (l))])[
|
|
||||||
{}
|
|
||||||
#else
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
|
|
||||||
b4_locations_if([const location_type& l]))[)
|
|
||||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
|
||||||
, value (v)])[]b4_locations_if([
|
|
||||||
, location (l)])[
|
|
||||||
{}
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
# b4_symbol_constructor_define
|
|
||||||
# ----------------------------
|
|
||||||
# Define the overloaded versions of make_symbol for all the value types.
|
|
||||||
m4_define([b4_symbol_constructor_define],
|
|
||||||
[ // Implementation of make_symbol for each symbol type.
|
|
||||||
b4_symbol_foreach([_b4_symbol_constructor_define])])
|
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
bison.xsl - common templates for Bison XSLT.
|
bison.xsl - common templates for Bison XSLT.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
xml2dot.xsl - transform Bison XML Report into DOT.
|
xml2dot.xsl - transform Bison XML Report into DOT.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
xml2text.xsl - transform Bison XML Report into plain text.
|
xml2text.xsl - transform Bison XML Report into plain text.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
xml2html.xsl - transform Bison XML Report into XHTML.
|
xml2html.xsl - transform Bison XML Report into XHTML.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# DJGPP Maintainer's Makefile -*-Makefile-*-
|
|
||||||
# Requires GNU sed
|
|
||||||
|
|
||||||
## Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
top_srcdir = ..
|
|
||||||
srcdir = .
|
|
||||||
|
|
||||||
SHELL = /bin/sh
|
|
||||||
|
|
||||||
all: README
|
|
||||||
|
|
||||||
README: README.in $(top_srcdir)/configure
|
|
||||||
PACKAGE=`grep "^[ ]*PACKAGE=" $(top_srcdir)/configure | sed -e 's/^[ ]*PACKAGE=//' -e s/[\"\']//g`; \
|
|
||||||
VERSION=`grep "^[ ]*VERSION=" $(top_srcdir)/configure | sed -e 's/^[ ]*VERSION=//' -e s/[\"\']//g`; \
|
|
||||||
package_version=`echo "$${VERSION}" | sed 's/\.//g'`; \
|
|
||||||
tree_version=`echo "$${VERSION}" | sed 's/\.//2g'`; \
|
|
||||||
sed \
|
|
||||||
-e "s/@V@/$${PACKAGE}-$${VERSION}/g" \
|
|
||||||
-e "s/@VERSION@/$${VERSION}/g" \
|
|
||||||
-e "s/@PACKAGE_VERSION@/$$package_version/g" \
|
|
||||||
-e "s/@TREE_VERSION@/$$tree_version/g" \
|
|
||||||
$(srcdir)/README.in > t-$@
|
|
||||||
mv t-$@ $@
|
|
||||||
-195
@@ -1,195 +0,0 @@
|
|||||||
This is a port of GNU Bison @VERSION@ to MSDOS/DJGPP.
|
|
||||||
|
|
||||||
Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
1.: DJGPP specific changes.
|
|
||||||
=======================
|
|
||||||
|
|
||||||
The DJGPP port of Bison offers LFN and SFN support depending on which
|
|
||||||
OS it is running. If LFN support is available or not is determined at
|
|
||||||
run time. If LFN support is available (DOS session under Win9X, Win2K,
|
|
||||||
WinXP, etc.) the standard posix file name extensions will be used.
|
|
||||||
These are: y.tab.c, y.tab.c++, y.tab.h, y.output, etc. If only SFN
|
|
||||||
support is available (plain DOS), then the standard MSDOS short file
|
|
||||||
names will be used. These are: y_tab.c, y_tab.h, y.out, etc.
|
|
||||||
It should be noticed that this bison version needs the m4 program as
|
|
||||||
back end to generate the parser file (y.tab.c etc.) from the skeleton
|
|
||||||
files. This implies that m4 must always be installed to get bison
|
|
||||||
working. m4 will use a couple of m4 scripts that will be installed in
|
|
||||||
/dev/env/DJDIR/share/bison and shall not be removed.
|
|
||||||
It should also be noticed that the skeleton files bison.simple and
|
|
||||||
bison.hairy are no longer supported. This applies also to the environ-
|
|
||||||
ment variables BISON_HAIRY and BISON_SIMPLE. Those variables are *no*
|
|
||||||
longer honored at all.
|
|
||||||
The kind of skeleton file bison.hairy is no longer supported at all.
|
|
||||||
The skeleton file bison.simple is now called yacc.c and is an m4 script.
|
|
||||||
The other two skeleton files supported by this bison version are glr.c
|
|
||||||
and lalr1.cc. The first one is a generalized LR C parser based on
|
|
||||||
Bison's LALR(1) tables and the second one is a experimental C++ parser
|
|
||||||
class.
|
|
||||||
As has been told before, bison uses m4 to generate the parser file.
|
|
||||||
This is done by forking and using pipes for the IPC. MSDOS does not
|
|
||||||
support this functionality so this has been reproduced in the usual
|
|
||||||
way by redirecting stdin and stdout of bison and m4 to temporary files
|
|
||||||
and processing these files in sequence.
|
|
||||||
It should be noticed that due to the great amount of file names that do
|
|
||||||
not cleanly map to 8.3 file names, you will need an OS with LFN support
|
|
||||||
to configure and compile the sources. On Win98 this implies that the
|
|
||||||
generation of numeric tails for 8.3 file name aliases must be enabled
|
|
||||||
or the compilation will fail.
|
|
||||||
|
|
||||||
|
|
||||||
Please **read** the docs.
|
|
||||||
|
|
||||||
|
|
||||||
2.: Installing the binary package.
|
|
||||||
==============================
|
|
||||||
|
|
||||||
2.1.: Copy the binary distribution into the top DJGPP installation directory,
|
|
||||||
just unzip it preserving the directory structure running *ONE* of the
|
|
||||||
following commands:
|
|
||||||
unzip32 bsn@[email protected] or
|
|
||||||
djtarx bsn@[email protected] or
|
|
||||||
pkunzip -d bsn@[email protected]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3.: Building the binaries from sources.
|
|
||||||
===================================
|
|
||||||
|
|
||||||
3.1.: Create a temporary directory and copy the source package into the
|
|
||||||
directory. If you download the source distribution from one of the
|
|
||||||
DJGPP sites, just unzip it preserving the directory structure
|
|
||||||
running *ONE* of the following commands:
|
|
||||||
unzip32 bsn@[email protected] or
|
|
||||||
djtarx bsn@[email protected] or
|
|
||||||
pkunzip -d bsn@[email protected]
|
|
||||||
and proceed to the paragraph 3.3, below.
|
|
||||||
|
|
||||||
3.2.: Source distributions downloaded from one of the GNU FTP sites need
|
|
||||||
some more work to unpack, if LFN support is not available. If LFN is
|
|
||||||
available then you can extract the source files from the archive with
|
|
||||||
any unzip program and proceed to the paragraph 3.3, below. Any file
|
|
||||||
name issue will be handled by the DJGPP configuration files.
|
|
||||||
To unpack the source distribution on SFN systems, first, you MUST use
|
|
||||||
the `djunpack' batch file to unzip the package. That is because some
|
|
||||||
file names in the official distributions need to be changed to avoid
|
|
||||||
problems on the various platforms supported by DJGPP.
|
|
||||||
`djunpack' invokes the `djtar' program (that is part of the basic DJGPP
|
|
||||||
development kit) to rename these files on the fly given a file with
|
|
||||||
name mappings; the distribution includes a file `djgpp/fnchange.lst'
|
|
||||||
with the necessary mappings. So you need first to retrieve that batch
|
|
||||||
file, and then invoke it to unpack the distribution. Here's how:
|
|
||||||
|
|
||||||
djtar -x -p -o bison-@VERSION@/djgpp/djunpack.bat bison-@[email protected] > djunpack.bat
|
|
||||||
djunpack bison-@[email protected]
|
|
||||||
|
|
||||||
(The name of the distribution archive and the leading directory of the
|
|
||||||
path to `djunpack.bat' in the distribution will be different for
|
|
||||||
versions of Bison other than @VERSION@.)
|
|
||||||
|
|
||||||
If the argument to `djunpack.bat' include leading directories, it MUST
|
|
||||||
be given with the DOS-style backslashes; Unix-style forward slashes
|
|
||||||
will NOT work.
|
|
||||||
|
|
||||||
If the distribution comes as a .tar.bz2 archive, and your version of
|
|
||||||
`djtar' doesn't support bzip2 decompression, you need to unpack it as
|
|
||||||
follows:
|
|
||||||
|
|
||||||
bnzip2 bison-@[email protected]
|
|
||||||
djtar -x -p -o bison-@VERSION@/djgpp/djunpack.bat bison-@[email protected] > djunpack.bat
|
|
||||||
djunpack bison-@[email protected]
|
|
||||||
|
|
||||||
3.3.: To build the binaries you will need the following binary packages:
|
|
||||||
djdev203.zip (or a later but NOT a prior version)
|
|
||||||
bsh204b.zip (or a later but NOT a prior version)
|
|
||||||
gccNNNb.zip, gppNNN.zip, bnuNNNb.zip, makNNNb.zip, filNNNb.zip,
|
|
||||||
perlNNNb.zip, shlNNNb.zip, txtNNNb.zip, txiNNNb.zip, grepNNNb.zip,
|
|
||||||
sedNNNb.zip and m4NNN.zip
|
|
||||||
|
|
||||||
If you want to run the check you will need also:
|
|
||||||
difNNNb.zip
|
|
||||||
|
|
||||||
NNN represents the latest version number of the binary packages. All
|
|
||||||
this packages can be found in the /v2gnu directory of any
|
|
||||||
ftp.delorie.com mirror.
|
|
||||||
You will need bsh204b.zip or later and *NOT* a prior version or
|
|
||||||
the build will fail. The same applies to djdev203.zip. Please note
|
|
||||||
that Bison requires m4-144b.zip or later to work properly.
|
|
||||||
|
|
||||||
3.4.: If for some reason you want to reconfigure the package cd into the top
|
|
||||||
srcdir (bison-@TREE_VERSION@) and run the following commands:
|
|
||||||
del djgpp\config.cache
|
|
||||||
make clean
|
|
||||||
djgpp\config
|
|
||||||
|
|
||||||
Please note that you *MUST* delete the config.cache file in the djgpp
|
|
||||||
subdir or you will not really reconfigure the sources because the
|
|
||||||
configuration informations will be read from the cache file instead
|
|
||||||
of being newly computed.
|
|
||||||
To build the programs in a directory other than where the sources are,
|
|
||||||
you must add the parameter that specifies the source directory,
|
|
||||||
e.g:
|
|
||||||
x:\src\gnu\bison-@TREE_VERSION@\djgpp\config x:/src/gnu/bison-@TREE_VERSION@
|
|
||||||
|
|
||||||
Lets assume you want to build the binaries in a directory placed on a
|
|
||||||
different drive (z:\build in this case) from where the sources are,
|
|
||||||
then you will run the following commands:
|
|
||||||
z:
|
|
||||||
md \build
|
|
||||||
cd \build
|
|
||||||
x:\src\gnu\bison-@TREE_VERSION@\djgpp\config x:/src/gnu/bison-@TREE_VERSION@
|
|
||||||
|
|
||||||
The order of the options and the srcdir option does not matter. You
|
|
||||||
*MUST* use forward slashes to specify the source directory.
|
|
||||||
|
|
||||||
The batch file will set same environment variables, make MSDOS specific
|
|
||||||
modifications to the Makefile.in's and supply all other needed options
|
|
||||||
to the configure script.
|
|
||||||
|
|
||||||
3.5.: To compile the package run from the top srcdir the command:
|
|
||||||
make
|
|
||||||
|
|
||||||
3.6.: Now you can run the tests if you like. From the top srcdir run the
|
|
||||||
command:
|
|
||||||
make check
|
|
||||||
|
|
||||||
No test should fail but the tests #131 (Doxygen Public Documentation)
|
|
||||||
and #132 (Doxygen Private Documentation) will be skipped. Please note
|
|
||||||
that the testsuite only works with LFN available. On plain DOS, most
|
|
||||||
of the tests will fail due to invalid DOS names.
|
|
||||||
|
|
||||||
3.7.: To install the binaries, header, library, catalogs, and info docs
|
|
||||||
run the following command from the top srcdir:
|
|
||||||
make install
|
|
||||||
|
|
||||||
This will install the products into your DJGPP installation tree given
|
|
||||||
by the default prefix "/dev/env/DJDIR". If you prefer to install them
|
|
||||||
into some other directory you will have to set prefix to the appropriate
|
|
||||||
value:
|
|
||||||
make install prefix=z:/some/other/place
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Send GNU bison specific bug reports to <[email protected]>.
|
|
||||||
Send suggestions and bug reports concerning the DJGPP port to
|
|
||||||
comp.os.msdos.djgpp or <[email protected]>.
|
|
||||||
|
|
||||||
|
|
||||||
Enjoy.
|
|
||||||
|
|
||||||
Guerrero, Juan Manuel <[email protected]>
|
|
||||||
@@ -1,547 +0,0 @@
|
|||||||
@echo off
|
|
||||||
Rem Configure Bison for DJGPP.
|
|
||||||
|
|
||||||
Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line
|
|
||||||
Rem format, or else stock DOS/Windows shells will refuse to run it.
|
|
||||||
|
|
||||||
Rem Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
Rem This program is free software: you can redistribute it and/or modify
|
|
||||||
Rem it under the terms of the GNU General Public License as published by
|
|
||||||
Rem the Free Software Foundation, either version 3 of the License, or
|
|
||||||
Rem (at your option) any later version.
|
|
||||||
Rem
|
|
||||||
Rem This program is distributed in the hope that it will be useful,
|
|
||||||
Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
Rem GNU General Public License for more details.
|
|
||||||
Rem
|
|
||||||
Rem You should have received a copy of the GNU General Public License
|
|
||||||
Rem along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
echo Configuring Bison for DJGPP v2.x...
|
|
||||||
|
|
||||||
Rem The SmallEnv tests protect against fixed and too small size
|
|
||||||
Rem of the environment in stock DOS shell.
|
|
||||||
|
|
||||||
Rem Find out if NLS is wanted or not,
|
|
||||||
Rem if dependency-tracking is wanted or not,
|
|
||||||
Rem if caching is wanted or not
|
|
||||||
Rem and where the sources are.
|
|
||||||
Rem We always default to NLS support,
|
|
||||||
Rem no dependency tracking
|
|
||||||
Rem and to in place configuration.
|
|
||||||
set ARGS=
|
|
||||||
set NLS=enabled
|
|
||||||
if not "%NLS%" == "enabled" goto SmallEnv
|
|
||||||
set CACHING=enabled
|
|
||||||
if not "%CACHING%" == "enabled" goto SmallEnv
|
|
||||||
set DEPENDENCY_TRACKING=disabled
|
|
||||||
if not "%DEPENDENCY_TRACKING%" == "disabled" goto SmallEnv
|
|
||||||
set LIBICONV_PREFIX=disabled
|
|
||||||
if not "%LIBICONV_PREFIX%" == "disabled" goto SmallEnv
|
|
||||||
set LIBINTL_PREFIX=disabled
|
|
||||||
if not "%LIBINTL_PREFIX%" == "disabled" goto SmallEnv
|
|
||||||
set HTML=enabled
|
|
||||||
if not "%HTML%" == "enabled" goto SmallEnv
|
|
||||||
set XSRC=.
|
|
||||||
if not "%XSRC%" == "." goto SmallEnv
|
|
||||||
|
|
||||||
Rem Loop over all arguments.
|
|
||||||
Rem Special arguments are: NLS, XSRC, CACHE, STATIC_LIBS, LIBICONV_PREFIX, LIBINTL_PREFIX and DEPS.
|
|
||||||
Rem All other arguments are stored into ARGS.
|
|
||||||
:ArgLoop
|
|
||||||
if "%1" == "nls" goto NextArgument
|
|
||||||
if "%1" == "NLS" goto NextArgument
|
|
||||||
if "%1" == "no-nls" goto NoNLS
|
|
||||||
if "%1" == "no-NLS" goto NoNLS
|
|
||||||
if "%1" == "NO-NLS" goto NoNLS
|
|
||||||
goto CachingOption
|
|
||||||
:NoNLS
|
|
||||||
if "%1" == "no-nls" set NLS=disabled
|
|
||||||
if "%1" == "no-NLS" set NLS=disabled
|
|
||||||
if "%1" == "NO-NLS" set NLS=disabled
|
|
||||||
if not "%NLS%" == "disabled" goto SmallEnv
|
|
||||||
goto NextArgument
|
|
||||||
:CachingOption
|
|
||||||
if "%1" == "cache" goto NextArgument
|
|
||||||
if "%1" == "CACHE" goto NextArgument
|
|
||||||
if "%1" == "no-cache" goto NoCaching
|
|
||||||
if "%1" == "no-CACHE" goto NoCaching
|
|
||||||
if "%1" == "NO-CACHE" goto NoCaching
|
|
||||||
goto DependencyOption
|
|
||||||
:NoCaching
|
|
||||||
if "%1" == "no-cache" set CACHING=disabled
|
|
||||||
if "%1" == "no-CACHE" set CACHING=disabled
|
|
||||||
if "%1" == "NO-CACHE" set CACHING=disabled
|
|
||||||
if not "%CACHING%" == "disabled" goto SmallEnv
|
|
||||||
goto NextArgument
|
|
||||||
:DependencyOption
|
|
||||||
if "%1" == "no-dep" goto NextArgument
|
|
||||||
if "%1" == "no-DEP" goto NextArgument
|
|
||||||
if "%1" == "NO-DEP" goto NextArgument
|
|
||||||
if "%1" == "dep" goto DependecyTracking
|
|
||||||
if "%1" == "DEP" goto DependecyTracking
|
|
||||||
goto LibiconvPrefixOption
|
|
||||||
:DependecyTracking
|
|
||||||
if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
|
|
||||||
if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
|
|
||||||
if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
|
|
||||||
goto NextArgument
|
|
||||||
:LibiconvPrefixOption
|
|
||||||
if "%1" == "no-libiconvprefix" goto NextArgument
|
|
||||||
if "%1" == "no-LIBICONVPREFIX" goto NextArgument
|
|
||||||
if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
|
|
||||||
if "%1" == "libiconvprefix" goto WithLibiconvPrefix
|
|
||||||
if "%1" == "LIBICONVPREFIX" goto WithLibiconvPrefix
|
|
||||||
goto LibintlPrefixOption
|
|
||||||
:WithLibiconvPrefix
|
|
||||||
if "%1" == "libiconvprefix" set LIBICONV_PREFIX=enabled
|
|
||||||
if "%1" == "LIBICONVPREFIX" set LIBICONV_PREFIX=enabled
|
|
||||||
if not "%LIBICONV_PREFIX%" == "enabled" goto SmallEnv
|
|
||||||
goto NextArgument
|
|
||||||
:LibintlPrefixOption
|
|
||||||
if "%1" == "no-libiconvprefix" goto NextArgument
|
|
||||||
if "%1" == "no-LIBICONVPREFIX" goto NextArgument
|
|
||||||
if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
|
|
||||||
if "%1" == "libintlprefix" goto _WithLibintlPrefix
|
|
||||||
if "%1" == "LIBINTLPREFIX" goto _WithLibintlPrefix
|
|
||||||
goto HTMLOption
|
|
||||||
:_WithLibintlPrefix
|
|
||||||
if "%1" == "libintlprefix" set LIBINTL_PREFIX=enabled
|
|
||||||
if "%1" == "LIBINTLPREFIX" set LIBINTL_PREFIX=enabled
|
|
||||||
if not "%LIBINTL_PREFIX%" == "enabled" goto SmallEnv
|
|
||||||
:HTMLOption
|
|
||||||
if "%1" == "withhtml" goto NextArgument
|
|
||||||
if "%1" == "withHTML" goto NextArgument
|
|
||||||
if "%1" == "WITHHTML" goto NextArgument
|
|
||||||
if "%1" == "withouthtml" goto _WithoutHTML
|
|
||||||
if "%1" == "withoutHTML" goto _WithoutHTML
|
|
||||||
if "%1" == "WITHOUTHTML" goto _WithoutHTML
|
|
||||||
goto SrcDirOption
|
|
||||||
:_WithoutHTML
|
|
||||||
if "%1" == "withouthtml" set HTML=disabled
|
|
||||||
if "%1" == "withoutHTML" set HTML=disabled
|
|
||||||
if "%1" == "WITHOUTHTML" set HTML=disabled
|
|
||||||
if not "%HTML%" == "disabled" goto SmallEnv
|
|
||||||
goto NextArgument
|
|
||||||
:SrcDirOption
|
|
||||||
echo %1 | grep -q "/"
|
|
||||||
if errorlevel 1 goto CollectArgument
|
|
||||||
set XSRC=%1
|
|
||||||
if not "%XSRC%" == "%1" goto SmallEnv
|
|
||||||
goto NextArgument
|
|
||||||
:CollectArgument
|
|
||||||
set _ARGS=%ARGS% %1
|
|
||||||
if not "%_ARGS%" == "%ARGS% %1" if not "%_ARGS%" == "%ARGS%%1" goto SmallEnv
|
|
||||||
echo %_ARGS% | grep -q "[^ ]"
|
|
||||||
if not errorlevel 0 set ARGS=%_ARGS%
|
|
||||||
set _ARGS=
|
|
||||||
:NextArgument
|
|
||||||
shift
|
|
||||||
if not "%1" == "" goto ArgLoop
|
|
||||||
|
|
||||||
Rem Create an arguments file for the configure script.
|
|
||||||
echo --srcdir=%XSRC% > args
|
|
||||||
if "%CACHING%" == "enabled" echo --cache-file=%XSRC%/djgpp/config.cache >> args
|
|
||||||
if "%DEPENDENCY_TRACKING%" == "enabled" echo --enable-dependency-tracking >> args
|
|
||||||
if "%DEPENDENCY_TRACKING%" == "disabled" echo --disable-dependency-tracking >> args
|
|
||||||
if "%LIBICONV_PREFIX%" == "enabled" echo --with-libiconv-prefix >> args
|
|
||||||
if "%LIBICONV_PREFIX%" == "disabled" echo --without-libiconv-prefix >> args
|
|
||||||
if "%LIBINTL_PREFIX%" == "enabled" echo --with-libintl-prefix >> args
|
|
||||||
if "%LIBINTL_PREFIX%" == "disabled" echo --without-libintl-prefix >> args
|
|
||||||
if "%HTML%" == "enabled" echo --enable-html >> args
|
|
||||||
if "%HTML%" == "disabled" echo --disable-html >> args
|
|
||||||
if not "%ARGS%" == "" echo %ARGS% >> args
|
|
||||||
set ARGS=
|
|
||||||
set CACHING=
|
|
||||||
set DEPENDENCY_TRACKING=
|
|
||||||
set LIBICONV_PREFIX=
|
|
||||||
set LIBINTL_PREFIX=
|
|
||||||
set HTML=
|
|
||||||
|
|
||||||
if "%XSRC%" == "." goto InPlace
|
|
||||||
|
|
||||||
:NotInPlace
|
|
||||||
redir -e /dev/null update %XSRC%/configure.org ./configure
|
|
||||||
test -f ./configure
|
|
||||||
if errorlevel 1 update %XSRC%/configure ./configure
|
|
||||||
|
|
||||||
:InPlace
|
|
||||||
Rem Update configuration files
|
|
||||||
echo Updating configuration scripts...
|
|
||||||
test -f ./configure.org
|
|
||||||
if errorlevel 1 update configure configure.org
|
|
||||||
sed -f %XSRC%/djgpp/config.sed configure.org > configure
|
|
||||||
if errorlevel 1 goto SedError
|
|
||||||
|
|
||||||
Rem Make sure they have a config.site file
|
|
||||||
set CONFIG_SITE=%XSRC%/djgpp/config.site
|
|
||||||
if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto SmallEnv
|
|
||||||
|
|
||||||
Rem inttypes_.h and inttypes.h map to the same 8.3 alias.
|
|
||||||
test -f %XSRC%/lib/inttypes_.h
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/lib/inttypes_.h %XSRC%/lib/_inttypes.h
|
|
||||||
|
|
||||||
Rem Make sure crucial file names are not munged by unpacking
|
|
||||||
test -f %XSRC%/po/Makefile.in.in
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/po/Makefile.in.in %XSRC%/po/Makefile.in-in
|
|
||||||
test -f %XSRC%/po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/po/Makefile.in %XSRC%/po/Makefile.in-in
|
|
||||||
test -f %XSRC%/po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/po/Makefile.inin %XSRC%/po/Makefile.in-in
|
|
||||||
test -f %XSRC%/po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/po/Makefile.in_in %XSRC%/po/Makefile.in-in
|
|
||||||
test -f %XSRC%/po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/po/Makefile_in.in %XSRC%/po/Makefile.in-in
|
|
||||||
test -f %XSRC%/runtime-po/Makefile.in.in
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/runtime-po/Makefile.in.in %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
test -f %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/runtime-po/Makefile.in %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
test -f %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/runtime-po/Makefile.inin %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
test -f %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/runtime-po/Makefile.in_in %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
test -f %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/runtime-po/Makefile_in.in %XSRC%/runtime-po/Makefile.in-in
|
|
||||||
test -f %XSRC%/data/c++.m4
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/data/c++.m4 %XSRC%/data/cxx.m4
|
|
||||||
test -f %XSRC%/data/cxx.m4
|
|
||||||
if errorlevel 1 mv -f %XSRC%/data/cpp.m4 %XSRC%/data/cxx.m4
|
|
||||||
test -f %XSRC%/data/c++-skel.m4
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/data/c++-skel.m4 %XSRC%/data/cxx-skel.m4
|
|
||||||
test -f %XSRC%/data/cxx-skel.m4
|
|
||||||
if errorlevel 1 mv -f %XSRC%/data/cpp-skel.m4 %XSRC%/data/cxx-skel.m4
|
|
||||||
test -f %XSRC%/build-aux/javacomp.sh.in
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/build-aux/javacomp.sh.in %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javacomp.sh %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javacomp.shin %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javacomp.sh_in %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javacomp.sh.in %XSRC%/build-aux/javacomp.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javaexec.sh.in
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/build-aux/javaexec.sh.in %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javaexec.sh %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javaexec.shin %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javaexec.sh_in %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
test -f %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/build-aux/javaexec_sh.in %XSRC%/build-aux/javaexec.sh-in
|
|
||||||
test -f %XSRC%/doc/yacc.1.in
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/doc/yacc.1.in %XSRC%/doc/yacc.1-in
|
|
||||||
test -f %XSRC%/doc/yacc.1-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/doc/yacc.1 %XSRC%/doc/yacc.1-in
|
|
||||||
test -f %XSRC%/doc/yacc.1-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/doc/yacc.1in %XSRC%/doc/yacc.1-in
|
|
||||||
test -f %XSRC%/doc/yacc.1-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/doc/yacc.1_in %XSRC%/doc/yacc.1-in
|
|
||||||
test -f %XSRC%/doc/yacc.1-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/doc/yacc_1.in %XSRC%/doc/yacc.1-in
|
|
||||||
test -f %XSRC%/etc/bench.pl.in
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/etc/bench.pl.in %XSRC%/etc/bench.pl-in
|
|
||||||
test -f %XSRC%/etc/bench.pl-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/etc/bench.pl %XSRC%/etc/bench.pl-in
|
|
||||||
test -f %XSRC%/etc/bench.pl-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/etc/bench.plin %XSRC%/etc/bench.pl-in
|
|
||||||
test -f %XSRC%/etc/bench.pl-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/etc/bench.pl_in %XSRC%/etc/bench.pl-in
|
|
||||||
test -f %XSRC%/etc/bench.pl-in
|
|
||||||
if errorlevel 1 mv -f %XSRC%/etc/bench_pl.in %XSRC%/etc/bench.pl-in
|
|
||||||
|
|
||||||
:scan_gram_c_Test
|
|
||||||
test -f %XSRC%/src/c-scan-gram.c
|
|
||||||
if not errorlevel 1 goto scan_skel_c_Test
|
|
||||||
test -f %XSRC%/src/scan-gram-c.c
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/src/scan-gram-c.c %XSRC%/src/c-scan-gram.c
|
|
||||||
:scan_skel_c_Test
|
|
||||||
test -f %XSRC%/src/c-scan-skel.c
|
|
||||||
if not errorlevel 1 goto FixFiles
|
|
||||||
test -f %XSRC%/src/scan-skel-c.c
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/src/scan-skel-c.c %XSRC%/src/c-scan-skel.c
|
|
||||||
|
|
||||||
:FixFiles
|
|
||||||
Rem Fix data/lalr1.cc and data/location.cc to reflect the renaming of c++.m4
|
|
||||||
sed "s/c++\.m4/cxx.m4/" %XSRC%/data/lalr1.cc > lalr1.cc
|
|
||||||
if errorlevel 1 goto lalr1_ccFileError
|
|
||||||
mv ./lalr1.cc %XSRC%/data/lalr1.cc
|
|
||||||
sed "s/c++\.m4/cxx.m4/" %XSRC%/data/location.cc > location.cc
|
|
||||||
if errorlevel 1 goto location_ccFileError
|
|
||||||
mv ./location.cc %XSRC%/data/location.cc
|
|
||||||
sed "s/c++\.m4/cxx.m4/" %XSRC%/data/glr.cc > glr.cc
|
|
||||||
if errorlevel 1 goto glr_ccFileError
|
|
||||||
mv ./glr.cc %XSRC%/data/glr.cc
|
|
||||||
|
|
||||||
Rem Fix src/getargs.c to reflect the renaming of c++-skel.m4
|
|
||||||
sed "s/c++-skel\.m4/cxx-skel.m4/" %XSRC%/src/getargs.c > getargs.c
|
|
||||||
if errorlevel 1 goto getargs_cFileError
|
|
||||||
mv ./getargs.c %XSRC%/src/getargs.c
|
|
||||||
|
|
||||||
Rem Define DJGPP specific defs in config.hin
|
|
||||||
echo Editing config.hin...
|
|
||||||
test -f %XSRC%/lib/config_h.org
|
|
||||||
if errorlevel 1 update %XSRC%/lib/config.hin %XSRC%/lib/config_h.org
|
|
||||||
sed -f %XSRC%/djgpp/config_h.sed %XSRC%/lib/config_h.org > config.hin
|
|
||||||
if errorlevel 1 goto SedError2
|
|
||||||
mv -f config.hin %XSRC%/lib/config.hin
|
|
||||||
|
|
||||||
|
|
||||||
Rem Fixing illicit testsuite file name.
|
|
||||||
test -f %XSRC%/tests/c++.at
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.at
|
|
||||||
|
|
||||||
test -f %XSRC%/tests/testsuite.org
|
|
||||||
if errorlevel 1 update %XSRC%/tests/testsuite %XSRC%/tests/testsuite.org
|
|
||||||
sed -f %XSRC%/djgpp/testsuite.sed %XSRC%/tests/testsuite.org > testsuite.tmp
|
|
||||||
if errorlevel 1 goto SedError3
|
|
||||||
mv -f ./testsuite.tmp %XSRC%/tests/testsuite
|
|
||||||
|
|
||||||
Rem Fixing illicit calc++ file names in the calc++ directory.
|
|
||||||
test -d %XSRC%/examples/calc++
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
|
|
||||||
test -d %XSRC%/examples/calcxx
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcpp %XSRC%/examples/calcxx
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-scanner.cc
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-scanner.cc
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-scanner.ll
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-scanner.ll
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-driver.cc
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-driver.cc
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-driver.hh
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-driver.hh
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-parser.cc
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-parser.cc
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-parser.hh
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-parser.hh
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-parser.stamp
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.stamp %XSRC%/examples/calcxx/calcxx-parser.stamp
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-parser.stamp
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.stamp %XSRC%/examples/calcxx/calcxx-parser.stamp
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++-parser.yy
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx-parser.yy
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
|
|
||||||
test -f %XSRC%/examples/calcxx/calc++.cc
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++.cc %XSRC%/examples/calcxx/calcxx.cc
|
|
||||||
test -f %XSRC%/examples/calcxx/calcxx.cc
|
|
||||||
if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp.cc %XSRC%/examples/calcxx/calcxx.cc
|
|
||||||
|
|
||||||
Rem Fixing #include lines in calcxx files.
|
|
||||||
sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx.cc > calcxx.cc
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./calcxx.cc %XSRC%/examples/calcxx/calcxx.cc
|
|
||||||
sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-driver.cc > calcxx-driver.cc
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./calcxx-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
|
|
||||||
sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-driver.hh > calcxx-driver.hh
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./calcxx-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
|
|
||||||
sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.cc > calcxx-parser.cc
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./calcxx-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
|
|
||||||
sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.hh > calcxx-parser.hh
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./calcxx-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
|
|
||||||
:sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.yy > calcxx-parser.yy
|
|
||||||
:if errorlevel 1 goto calcxxFileError
|
|
||||||
:mv ./calcxx-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
|
|
||||||
sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-scanner.cc > calcxx-scanner.cc
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./calcxx-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
|
|
||||||
:sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-scanner.ll > calcxx-scanner.ll
|
|
||||||
:if errorlevel 1 goto calcxxFileError
|
|
||||||
:mv ./calcxx-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
|
|
||||||
sed "s/calc++/calcxx/" %XSRC%/examples/calcxx/test > test
|
|
||||||
if errorlevel 1 goto calcxxFileError
|
|
||||||
mv ./test %XSRC%/examples/calcxx/test
|
|
||||||
|
|
||||||
|
|
||||||
Rem Fixing the scanner files to make file names 8.3 valid.
|
|
||||||
Rem Use only if you want to change the scan-gram.l and scan-skel.l files.
|
|
||||||
: sed "/outfile=/s/\.yy/yy/" %XSRC%/src/scan-gram.l > scan-gram.l
|
|
||||||
: if errorlevel 1 goto ScannerFileError
|
|
||||||
: mv ./scan-gram.l %XSRC%/src/scan-gram.l
|
|
||||||
: sed "/outfile=/s/\.yy/yy/" %XSRC%/src/scan-skel.l > scan-skel.l
|
|
||||||
: if errorlevel 1 goto ScannerFileError
|
|
||||||
: mv ./scan-skel.l %XSRC%/src/scan-skel.l
|
|
||||||
|
|
||||||
|
|
||||||
Rem This is required because DOS/Windows are case-insensitive
|
|
||||||
Rem to file names, and "make install" will do nothing if Make
|
|
||||||
Rem finds a file called `install'.
|
|
||||||
if exist INSTALL ren INSTALL INSTALL.txt
|
|
||||||
|
|
||||||
Rem Set SHELL to a sane default or some configure tests stop working
|
|
||||||
Rem if the package is configured across partitions.
|
|
||||||
if not "%SHELL%" == "" goto HomeName
|
|
||||||
set SHELL=/bin/sh
|
|
||||||
if not "%SHELL%" == "/bin/sh" goto SmallEnv
|
|
||||||
echo No SHELL found in the environment, using default value
|
|
||||||
|
|
||||||
:HomeName
|
|
||||||
Rem Set HOME to a sane default so configure stops complaining.
|
|
||||||
if not "%HOME%" == "" goto HostName
|
|
||||||
set HOME=%XSRC%/djgpp
|
|
||||||
if not "%HOME%" == "%XSRC%/djgpp" goto SmallEnv
|
|
||||||
echo No HOME found in the environment, using default value
|
|
||||||
|
|
||||||
:HostName
|
|
||||||
Rem Set HOSTNAME so it shows in config.status
|
|
||||||
if not "%HOSTNAME%" == "" goto hostdone
|
|
||||||
if "%windir%" == "" goto msdos
|
|
||||||
set OS=MS-Windows
|
|
||||||
if not "%OS%" == "MS-Windows" goto SmallEnv
|
|
||||||
goto haveos
|
|
||||||
:msdos
|
|
||||||
set OS=MS-DOS
|
|
||||||
if not "%OS%" == "MS-DOS" goto SmallEnv
|
|
||||||
:haveos
|
|
||||||
if not "%USERNAME%" == "" goto haveuname
|
|
||||||
if not "%USER%" == "" goto haveuser
|
|
||||||
echo No USERNAME and no USER found in the environment, using default values
|
|
||||||
set HOSTNAME=Unknown PC
|
|
||||||
if not "%HOSTNAME%" == "Unknown PC" goto SmallEnv
|
|
||||||
goto userdone
|
|
||||||
:haveuser
|
|
||||||
set HOSTNAME=%USER%'s PC
|
|
||||||
if not "%HOSTNAME%" == "%USER%'s PC" goto SmallEnv
|
|
||||||
goto userdone
|
|
||||||
:haveuname
|
|
||||||
set HOSTNAME=%USERNAME%'s PC
|
|
||||||
if not "%HOSTNAME%" == "%USERNAME%'s PC" goto SmallEnv
|
|
||||||
:userdone
|
|
||||||
set _HOSTNAME=%HOSTNAME%, %OS%
|
|
||||||
if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto SmallEnv
|
|
||||||
set HOSTNAME=%_HOSTNAME%
|
|
||||||
:hostdone
|
|
||||||
set _HOSTNAME=
|
|
||||||
set OS=
|
|
||||||
|
|
||||||
Rem install-sh is required by the configure script but clashes with the
|
|
||||||
Rem various Makefile install-foo targets, so we MUST have it before the
|
|
||||||
Rem script runs and rename it afterwards
|
|
||||||
test -f %XSRC%/install-sh
|
|
||||||
if not errorlevel 1 goto NoRen0
|
|
||||||
test -f %XSRC%/install-sh.sh
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
|
|
||||||
:NoRen0
|
|
||||||
|
|
||||||
if "%NLS%" == "disabled" goto WithoutNLS
|
|
||||||
|
|
||||||
:WithNLS
|
|
||||||
Rem Check for the needed libraries and binaries.
|
|
||||||
test -x /dev/env/DJDIR/bin/msgfmt.exe
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -x /dev/env/DJDIR/bin/xgettext.exe
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -f /dev/env/DJDIR/include/libcharset.h
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -f /dev/env/DJDIR/lib/libcharset.a
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -f /dev/env/DJDIR/include/iconv.h
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -f /dev/env/DJDIR/lib/libiconv.a
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -f /dev/env/DJDIR/include/libintl.h
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
test -f /dev/env/DJDIR/lib/libintl.a
|
|
||||||
if errorlevel 1 goto MissingNLSTools
|
|
||||||
|
|
||||||
Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
|
|
||||||
redir -e /dev/null rm %XSRC%/po/*.gmo
|
|
||||||
redir -e /dev/null rm %XSRC%/po/bison.pot
|
|
||||||
redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
|
|
||||||
redir -e /dev/null rm %XSRC%/po/stamp-cat-id
|
|
||||||
|
|
||||||
Rem Update the arguments file for the configure script.
|
|
||||||
Rem We prefer without-included-gettext because libintl.a from gettext package
|
|
||||||
Rem is the only one that is guaranteed to have been ported to DJGPP.
|
|
||||||
echo --enable-nls --without-included-gettext >> args
|
|
||||||
goto ConfigurePackage
|
|
||||||
|
|
||||||
:MissingNLSTools
|
|
||||||
echo Needed libs/tools for NLS not found. Configuring without NLS.
|
|
||||||
:WithoutNLS
|
|
||||||
Rem Update the arguments file for the configure script.
|
|
||||||
echo --disable-nls >> args
|
|
||||||
|
|
||||||
:ConfigurePackage
|
|
||||||
echo Running the ./configure script...
|
|
||||||
sh ./configure @args
|
|
||||||
if errorlevel 1 goto CfgError
|
|
||||||
rm args
|
|
||||||
echo Done.
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:lalr1_ccFileError
|
|
||||||
echo ./data/lalr1.cc file editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:glr_ccFileError
|
|
||||||
echo ./data/glr.cc file editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:getargs_cFileError
|
|
||||||
echo ./src/getargs.c file editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:location_ccFileError
|
|
||||||
echo ./data/location.cc file editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:calcxxFileError
|
|
||||||
echo ./examples/calcxx file editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:ScannerFileError
|
|
||||||
echo ./scanner file editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:SedError
|
|
||||||
echo ./configure script editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:SedError2
|
|
||||||
echo ./lib/config.hin editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:SedError3
|
|
||||||
echo ./tests/testsuite editing failed!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:CfgError
|
|
||||||
echo ./configure script exited abnormally!
|
|
||||||
goto End
|
|
||||||
|
|
||||||
:SmallEnv
|
|
||||||
echo Your environment size is too small. Enlarge it and run me again.
|
|
||||||
echo Configuration NOT done!
|
|
||||||
|
|
||||||
:End
|
|
||||||
test -f %XSRC%/install-sh.sh
|
|
||||||
if not errorlevel 1 goto NoRen1
|
|
||||||
test -f %XSRC%/install-sh
|
|
||||||
if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
|
|
||||||
:NoRen1
|
|
||||||
if "%SHELL%" == "/bin/sh" set SHELL=
|
|
||||||
if "%HOME%" == "%XSRC%/djgpp" set HOME=
|
|
||||||
set CONFIG_SITE=
|
|
||||||
set HOSTNAME=
|
|
||||||
set NLS=
|
|
||||||
set XSRC=
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
# DJGPP specific configuration file.
|
|
||||||
# Sed script for additional DJGPP specific editing
|
|
||||||
# of the configure script generated by autoconf 2.62.
|
|
||||||
|
|
||||||
# Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
# Additional editing of Makefiles
|
|
||||||
/^eval sed.*ac_file_inputs.*tmp\/out \\$/ {
|
|
||||||
:loop
|
|
||||||
n
|
|
||||||
/^$/!b loop
|
|
||||||
a\
|
|
||||||
cat > "$tmp/subs-djgpp.sed" << eof_djgpp\
|
|
||||||
# DJGPP specific Makefile changes.\
|
|
||||||
s,\\.deps,_deps,g\
|
|
||||||
s,\\.libs,_libs,g\
|
|
||||||
s,\\.new\\.,_new.,g\
|
|
||||||
s,\\.old\\.,_old.,g\
|
|
||||||
s,\\.tab\\.,_tab.,g\
|
|
||||||
s,c++\\.at,cxx.at,g\
|
|
||||||
s,c++\\.m4,cxx.m4,g\
|
|
||||||
s,c++-skel\\.m4,cxx-skel.m4,g\
|
|
||||||
s,calc++,calcxx,g\
|
|
||||||
s,scan-gram-c,c-scan-gram,g\
|
|
||||||
s,scan-skel-c,c-scan-skel,g\
|
|
||||||
s,inttypes_,_inttypes,g\
|
|
||||||
s,javacomp\\.sh\\.in,javacomp.sh-in,g\
|
|
||||||
s,javaexec\\.sh\\.in,javaexec.sh-in,g\
|
|
||||||
s,yacc\\.1\\.in,yacc.1-in,g\
|
|
||||||
s,bench\\.pl\\.in,bench.pl-in,g\
|
|
||||||
s,Makefile\\.am\\.in,Makefile.am-in,g\
|
|
||||||
s,Makefile\\.in\\.in,Makefile.in-in,g\
|
|
||||||
/^\\.y\\.c:/,/^$/ {\
|
|
||||||
/\\\$(YACCCOMPILE)/ {\
|
|
||||||
a\\\\\
|
|
||||||
-@test -f y.tab.c && mv -f y.tab.c y_tab.c\\\\\
|
|
||||||
-@test -f y.tab.h && mv -f y.tab.h y_tab.h\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
/^libbison.a:/ i\\\\\
|
|
||||||
\\$(top_srcdir)/djgpp/subpipe.c: \\$(top_srcdir)/djgpp/subpipe.h\\\\\
|
|
||||||
subpipe.o: \\$(top_srcdir)/djgpp/subpipe.c \\$(top_srcdir)/djgpp/subpipe.h\\\\\
|
|
||||||
\\$(COMPILE) -c \\$<\
|
|
||||||
/^yacc:/ i\\\\\
|
|
||||||
yacc.bat:\\\\\
|
|
||||||
echo "bison\\$(EXEEXT) -y %1 %2 %3 %4 %5 %6 %7 %8 %9" >\\$@\
|
|
||||||
/^bin_SCRIPTS =/s/$/ yacc.bat/\
|
|
||||||
/^MOSTLYCLEANFILES = yacc/s/$/ yacc.bat/\
|
|
||||||
/cross-options.texi:/,/^$/ s|bison|&.exe|g\
|
|
||||||
/^\\.x\\.1:/,/^$/ s|\\$program|&.exe|g\
|
|
||||||
eof_djgpp\
|
|
||||||
sed -f "\$tmp/subs-djgpp.sed" \$tmp/out > \$tmp/out.djgpp\
|
|
||||||
mv -f \$tmp/out.djgpp \$tmp/out
|
|
||||||
}
|
|
||||||
|
|
||||||
# Makefile.in.in is renamed to Makefile.in-in.
|
|
||||||
/ac_config_files=/ {
|
|
||||||
/runtime-po/!s|po/Makefile\.in|&:po/Makefile.in-in|
|
|
||||||
s|runtime-po/Makefile\.in|&:runtime-po/Makefile.in-in|
|
|
||||||
s|javacomp\.sh\.in|javacomp.sh-in|
|
|
||||||
s|javaexec\.sh\.in|javaexec.sh-in|
|
|
||||||
s|doc/yacc\.1|&:doc/yacc.1-in|
|
|
||||||
s|etc/bench.pl|&:etc/bench.pl-in|
|
|
||||||
}
|
|
||||||
|
|
||||||
/CONFIG_FILES=/ {
|
|
||||||
/runtime-po/!s|po/Makefile\.in|&:po/Makefile.in-in|2
|
|
||||||
s|runtime-po/Makefile\.in|&:runtime-po/Makefile.in-in|2
|
|
||||||
s|javacomp\.sh\.in|javacomp.sh-in|
|
|
||||||
s|javaexec\.sh\.in|javaexec.sh-in|
|
|
||||||
s|doc/yacc\.1|&:doc/yacc.1-in|2
|
|
||||||
s|etc/bench\.pl|&:etc/bench.pl-in|2
|
|
||||||
}
|
|
||||||
|
|
||||||
# We always use _deps and _libs instead of .deps and .libs, because
|
|
||||||
# the latter is an invalid name on 8+3 MS-DOS file system. This makes
|
|
||||||
# the generated Makefiles good for every DJGPP installation, not only
|
|
||||||
# the one where the package was configured (which could happen to be
|
|
||||||
# a Windows box, where leading dots in file names are allowed).
|
|
||||||
/^rmdir[ ]*\.tst/ i\
|
|
||||||
am__leading_dot=_
|
|
||||||
|
|
||||||
# Replace (command) > /dev/null with `command > /dev/null`, since
|
|
||||||
# parenthesized commands always return zero status in the ported Bash,
|
|
||||||
# even if the named command doesn't exist
|
|
||||||
/if ([^|;`]*null/{
|
|
||||||
s,(,`,
|
|
||||||
s,),,
|
|
||||||
/null[ ]*2>&1/ s,2>&1,&`,
|
|
||||||
/null.*null/ s,null.*null,&`,
|
|
||||||
/null.*null/ !{
|
|
||||||
/null[ ]*2>&1/ !s,null,&`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# DOS-style absolute file names should be supported as well
|
|
||||||
/\*) top_srcdir=/s,/\*,[\\\\/]* | ?:[\\\\/]*,
|
|
||||||
|
|
||||||
# The following two items are changes needed for configuring
|
|
||||||
# and compiling across partitions.
|
|
||||||
# 1) The given srcdir value is always translated from the
|
|
||||||
# "x:" syntax into "/dev/x" syntax while we run configure.
|
|
||||||
/^[ ]*-srcdir=\*.*$/ a\
|
|
||||||
ac_optarg=`echo "$ac_optarg" | sed "s,^\\([A-Za-z]\\):,/dev/\\1,"`
|
|
||||||
/set X `ls -Lt \$srcdir/ i\
|
|
||||||
if `echo $srcdir | grep "^/dev/" - > /dev/null`; then\
|
|
||||||
srcdir=`echo "$srcdir" | sed -e "s%^/dev/%%" -e "s%/%:/%"`\
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Autoconf 2.52e generated configure scripts
|
|
||||||
# write absolute paths into Makefiles and bison.in
|
|
||||||
# making them useless for DJGPP installations for
|
|
||||||
# which the package has not been configured for.
|
|
||||||
/MISSING=/,/^$/ {
|
|
||||||
/^fi$/ a\
|
|
||||||
am_missing_run=`echo "$am_missing_run" | sed 's%/dev/.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%${top_srcdir}%;s%.:.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%${top_srcdir}%'`
|
|
||||||
}
|
|
||||||
/^install_sh=/a\
|
|
||||||
install_sh=`echo "$install_sh" | sed 's%/dev/.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%${top_srcdir}%;s%.:.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%${top_srcdir}%'`
|
|
||||||
|
|
||||||
# This will only work if the assumption that the
|
|
||||||
# testsuite is ran from the following path:
|
|
||||||
# ${top_srcdir}/tests/testsuite.dir
|
|
||||||
# holds. The explicit names are of no importance.
|
|
||||||
# ../../. == ${top_srcdir}
|
|
||||||
#/^esac$/,/^ac_abs_srcdir=/ {
|
|
||||||
/^ac_abs_srcdir=/ i\
|
|
||||||
ac_abs_builddir=`echo "$ac_abs_builddir" | sed "s%/dev/.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%;s%.:.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%"`\
|
|
||||||
ac_abs_top_builddir=`echo "$ac_abs_top_builddir" | sed "s%/dev/.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%;s%.:.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%"`\
|
|
||||||
ac_abs_top_srcdir=`echo "$ac_abs_top_srcdir" | sed "s%/dev/.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%;s%.:.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%"`
|
|
||||||
#ac_abs_srcdir=`echo "$ac_abs_srcdir" | sed "s%/dev/.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%;s%.:.*/bison[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%"`
|
|
||||||
/^ac_abs_srcdir=/ a\
|
|
||||||
for dj_dir in $ac_abs_builddir $ac_abs_top_builddir $ac_abs_top_srcdir $ac_abs_srcdir\
|
|
||||||
do\
|
|
||||||
ac_abs_builddir=`echo "$ac_abs_builddir" | sed "s%//%/%g"`\
|
|
||||||
ac_abs_top_builddir=`echo "$ac_abs_top_builddir" | sed "s%//%/%g"`\
|
|
||||||
ac_abs_top_srcdir=`echo "$ac_abs_top_srcdir" | sed "s%//%/%g"`\
|
|
||||||
ac_abs_srcdir=`echo "$ac_abs_srcdir" | sed "s%//%/%g"`\
|
|
||||||
done
|
|
||||||
|
|
||||||
# Add DJGPP version information.
|
|
||||||
/^#define VERSION/ s/\$VERSION/& (DJGPP port (r1))/
|
|
||||||
|
|
||||||
# We need makeinfo to make the html formated docs.
|
|
||||||
/\$am_missing_run[ ]*makeinfo/ s,\$am_missing_run,,
|
|
||||||
|
|
||||||
# The path to the FORTRAN compiler and libraries
|
|
||||||
# shall contain no absolute path reference so it
|
|
||||||
# will be good for all djgpp installations.
|
|
||||||
/^FLIBS="\$ac_cv_flibs"/ i\
|
|
||||||
ac_djgpp_path=`echo "$DJDIR" | sed 's%\\\\\\%/%g' | tr $as_cr_LETTERS $as_cr_letters`\
|
|
||||||
ac_cv_flibs=`echo "$ac_cv_flibs" | sed "s%-L$ac_djgpp_path%-L/dev/env/DJDIR%g"`
|
|
||||||
|
|
||||||
# Autoconf generated configure scripts write absolute
|
|
||||||
# paths of certain header files into Makefiles making
|
|
||||||
# them useless for DJGPP installations for which the
|
|
||||||
# package has not been configured for.
|
|
||||||
/^.*echo "\$as_me:\$LINENO: result: \$gl_cv_absolute_.*$/ {
|
|
||||||
h
|
|
||||||
s,^.*\(gl_cv_absolute_\)\([a-z0-9_]*\)\(_h\).*$,\1\2\3=`echo $\1\2\3 | sed "s%[^:]:.*/include/%/dev/env/DJDIR/include/%"`,
|
|
||||||
G
|
|
||||||
}
|
|
||||||
/^.*echo "\$as_me:\$LINENO: result: \$gl_cv_full_.*$/ {
|
|
||||||
h
|
|
||||||
s,^.*\(gl_cv_full_\)\([a-z0-9_]*\)\(_h\).*$,\1\2\3=`echo $\1\2\3 | sed "s%[^:]:.*/include/%/dev/env/DJDIR/include/%"`,
|
|
||||||
G
|
|
||||||
}
|
|
||||||
|
|
||||||
# The following is not a valid DOS file name
|
|
||||||
s/calc++/calcxx/g
|
|
||||||
|
|
||||||
# The CR test for awk does not work for DJGPP.
|
|
||||||
/^ac_cs_awk_cr=/,/^$/ {
|
|
||||||
/^fi$/ a\
|
|
||||||
ac_cs_awk_cr=$ac_cr
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
|
|
||||||
# This is the config.site file for configuring GNU packages
|
|
||||||
# which are to be built with DJGPP tools.
|
|
||||||
|
|
||||||
# Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
# Include the djgpp subdirectory in PATH, so that getconf is found
|
|
||||||
PATH="$srcdir/djgpp:$PATH"
|
|
||||||
|
|
||||||
# These two variables are required, otherwise looking for
|
|
||||||
# programs along the PATH will not work.
|
|
||||||
PATH_SEPARATOR=:
|
|
||||||
PATH_EXPAND=y
|
|
||||||
|
|
||||||
# This is required in for "test -f foo" to find foo.exe
|
|
||||||
export TEST_FINDS_EXE=y
|
|
||||||
|
|
||||||
# The root of the DJGPP tree serves as the default prefix
|
|
||||||
test "x$prefix" = xNONE && prefix='/dev/env/DJDIR'
|
|
||||||
|
|
||||||
# This is required for config.status script to be run, since
|
|
||||||
# ./configure runs it by invoking ${CONFIG_SHELL-/bin/sh}
|
|
||||||
CONFIG_SHELL=${CONFIG_SHELL='sh'}
|
|
||||||
|
|
||||||
# These are set here so the generated Makefile's will be good
|
|
||||||
# for every DJGPP installation, not only the one where the
|
|
||||||
# package was configured.
|
|
||||||
# $INSTALL must be an absolute path name, otherwise config.status
|
|
||||||
# will try to prepend ./ and ../ to it when it goes into subdirs.
|
|
||||||
INSTALL=${INSTALL='/dev/env/DJDIR/bin/ginstall -c'}
|
|
||||||
RANLIB=${RANLIB='ranlib'}
|
|
||||||
GMSGFMT=${GMSGFMT='/dev/env/DJDIR/bin/msgfmt'}
|
|
||||||
MSGFMT=${MSGFMT='/dev/env/DJDIR/bin/msgfmt'}
|
|
||||||
XGETTEXT=${XGETTEXT='/dev/env/DJDIR/bin/xgettext'}
|
|
||||||
AWK=${AWK='gawk'}
|
|
||||||
|
|
||||||
# A sane default for emacs.
|
|
||||||
ac_cv_path_EMACS=${EMACS='/dev/env/DJDIR/gnu/emacs/bin/emacs'}
|
|
||||||
|
|
||||||
# A sane default for m4.
|
|
||||||
ac_cv_path_M4=${M4='/dev/env/DJDIR/bin/m4'}
|
|
||||||
|
|
||||||
# A sane default for grep.
|
|
||||||
ac_cv_path_GREP=${GREP='/dev/env/DJDIR/bin/grep'}
|
|
||||||
|
|
||||||
# A sane default for egrep.
|
|
||||||
ac_cv_path_EGREP=${EGREP='/dev/env/DJDIR/bin/egrep'}
|
|
||||||
|
|
||||||
# A sane default for fgrep.
|
|
||||||
ac_cv_path_FGREP=${FGREP='/dev/env/DJDIR/bin/fgrep'}
|
|
||||||
|
|
||||||
# A sane default for sed.
|
|
||||||
ac_cv_path_SED=${SED='/dev/env/DJDIR/bin/sed'}
|
|
||||||
|
|
||||||
# A sane default for mkdir.
|
|
||||||
ac_cv_path_mkdir=${MKDIR_P='/dev/env/DJDIR/bin/mkdir -p'}
|
|
||||||
|
|
||||||
# These are set here so the generated libtool will be good
|
|
||||||
# for every DJGPP installation, not only the one where the
|
|
||||||
# package was configured.
|
|
||||||
NM=${NM='nm'}
|
|
||||||
LD=${LD='ld'}
|
|
||||||
|
|
||||||
# Force the test for 'ln -s' to report 'cp -pf'.
|
|
||||||
ac_cv_prog_LN_S='cp -pf'
|
|
||||||
|
|
||||||
# There is no fork and vfork functionality.
|
|
||||||
ac_cv_func_fork=no
|
|
||||||
ac_cv_func_vfork=no
|
|
||||||
ac_cv_func_pipe=no
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
@echo off
|
|
||||||
Rem
|
|
||||||
Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line
|
|
||||||
Rem format, or else stock DOS/Windows shells will refuse to run it.
|
|
||||||
Rem
|
|
||||||
Rem This batch file unpacks the Bison distribution while simultaneously
|
|
||||||
Rem renaming some of the files whose names are invalid on DOS or conflict
|
|
||||||
Rem with other file names after truncation to DOS 8+3 namespace.
|
|
||||||
Rem
|
|
||||||
Rem Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
Rem
|
|
||||||
Rem This program is free software: you can redistribute it and/or modify
|
|
||||||
Rem it under the terms of the GNU General Public License as published by
|
|
||||||
Rem the Free Software Foundation, either version 3 of the License, or
|
|
||||||
Rem (at your option) any later version.
|
|
||||||
Rem
|
|
||||||
Rem This program is distributed in the hope that it will be useful,
|
|
||||||
Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
Rem GNU General Public License for more details.
|
|
||||||
Rem
|
|
||||||
Rem You should have received a copy of the GNU General Public License
|
|
||||||
Rem along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
Rem
|
|
||||||
Rem
|
|
||||||
Rem Invoke like this:
|
|
||||||
Rem
|
|
||||||
Rem djunpack bison-XYZ.tar.gz
|
|
||||||
Rem or
|
|
||||||
Rem djunpack bison-XYZ.tar.bz2
|
|
||||||
Rem
|
|
||||||
Rem where XYZ is the version number. If the argument includes leading
|
|
||||||
Rem directories, it MUST use backslashes, not forward slashes.
|
|
||||||
Rem
|
|
||||||
|
|
||||||
set ENVIRONMENT_SIZE_TEST_STRING=ENVIRONMENT_SIZE_TEST_STRING
|
|
||||||
if "%ENVIRONMENT_SIZE_TEST_STRING%"=="ENVIRONMENT_SIZE_TEST_STRING" GoTo EnvOk
|
|
||||||
Rem If their environment space is too small, re-exec with a larger one
|
|
||||||
command.com /e:4096 /c %0 %1
|
|
||||||
GoTo End
|
|
||||||
|
|
||||||
:EnvOk
|
|
||||||
set ENVIRONMENT_SIZE_TEST_STRING=
|
|
||||||
if "%1" == "" GoTo NoArgument
|
|
||||||
if not exist %1 GoTo NoArchive
|
|
||||||
Rem Extract top src dir from archive file.
|
|
||||||
djtar -t %1 > top_src.dir
|
|
||||||
Rem The following uses a feature of COPY whereby it does not copy
|
|
||||||
Rem empty files. We need that because the previous line will create
|
|
||||||
Rem an empty fnchange.tmp even if the command failed for some reason.
|
|
||||||
copy top_src.dir junk.tmp > nul
|
|
||||||
if not exist junk.tmp GoTo NoDjTar
|
|
||||||
del junk.tmp
|
|
||||||
sed "1{s/^.*bison-/djtar -x -p -o bison-/;s|$|djgpp/fnchange.lst %%1 > fnchange.tmp|};2,$d" top_src.dir > ext_list.bat
|
|
||||||
Rem See the comment above about the reason for using COPY.
|
|
||||||
copy ext_list.bat junk.tmp > nul
|
|
||||||
if not exist junk.tmp GoTo NoSed
|
|
||||||
del junk.tmp
|
|
||||||
Rem Extract fnchange.lst from archive.
|
|
||||||
call ext_list.bat %1
|
|
||||||
del ext_list.bat
|
|
||||||
sed "1{s|^.*bison-|s/@V@/bison-|;s|$|g|};2,$d" top_src.dir > version.sed
|
|
||||||
sed -f version.sed < fnchange.tmp > fnchange.lst
|
|
||||||
del version.sed
|
|
||||||
del fnchange.tmp
|
|
||||||
del top_src.dir
|
|
||||||
Rem unpack the source distribution
|
|
||||||
djtar -x -n fnchange.lst %1
|
|
||||||
del fnchange.lst
|
|
||||||
GoTo End
|
|
||||||
|
|
||||||
:NoSed
|
|
||||||
del junk.tmp
|
|
||||||
echo FAIL: Sed is not available.
|
|
||||||
GoTo End
|
|
||||||
:NoDjTar
|
|
||||||
del junk.tmp
|
|
||||||
echo FAIL: DJTAR is not available or no fnchange.lst file in %1.
|
|
||||||
GoTo End
|
|
||||||
:NoArchive
|
|
||||||
echo FAIL: the file %1 does not seem to exist.
|
|
||||||
echo Remember that %1 cannot use forward slashes, only backslashes.
|
|
||||||
GoTo End
|
|
||||||
:NoArgument
|
|
||||||
echo FAIL: no archive file has been specified.
|
|
||||||
echo Remember that the file name cannot use forward slashes, only backslashes.
|
|
||||||
:End
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
@V@/build-aux/javacomp.sh.in @V@/build-aux/javacomp.sh-in
|
|
||||||
@V@/build-aux/javaexec.sh.in @V@/build-aux/javaexec.sh-in
|
|
||||||
@V@/data/c++-skel.m4 @V@/data/cxx-skel.m4
|
|
||||||
@V@/data/c++.m4 @V@/data/cxx.m4
|
|
||||||
@V@/doc/yacc.1.in @V@/doc/yacc.1-in
|
|
||||||
@V@/etc/bench.pl.in @V@/etc/bench.pl-in
|
|
||||||
@V@/examples/calc++/ @V@/examples/calcxx/
|
|
||||||
@V@/examples/calc++/Makefile.am @V@/examples/calcxx/Makefile.am
|
|
||||||
@V@/examples/calc++/Makefile.in @V@/examples/calcxx/Makefile.in
|
|
||||||
@V@/examples/calc++/calc++-scanner.cc @V@/examples/calcxx/calcxx-scanner.cc
|
|
||||||
@V@/examples/calc++/calc++-scanner.ll @V@/examples/calcxx/calcxx-scanner.ll
|
|
||||||
@V@/examples/calc++/calc++.cc @V@/examples/calcxx/calcxx.cc
|
|
||||||
@V@/examples/calc++/calc++-driver.hh @V@/examples/calcxx/calcxx-driver.hh
|
|
||||||
@V@/examples/calc++/calc++-driver.cc @V@/examples/calcxx/calcxx-driver.cc
|
|
||||||
@V@/examples/calc++/stack.hh @V@/examples/calcxx/stack.hh
|
|
||||||
@V@/examples/calc++/position.hh @V@/examples/calcxx/position.hh
|
|
||||||
@V@/examples/calc++/location.hh @V@/examples/calcxx/location.hh
|
|
||||||
@V@/examples/calc++/calc++-parser.hh @V@/examples/calcxx/calcxx-parser.hh
|
|
||||||
@V@/examples/calc++/calc++-parser.cc @V@/examples/calcxx/calcxx-parser.cc
|
|
||||||
@V@/examples/calc++/calc++-parser.stamp @V@/examples/calcxx/calcxx-parser.stamp
|
|
||||||
@V@/examples/calc++/calc++-parser.yy @V@/examples/calcxx/calcxx-parser.yy
|
|
||||||
@V@/examples/calc++/test @V@/examples/calcxx/test
|
|
||||||
@V@/po/Makefile.in.in @V@/po/Makefile.in-in
|
|
||||||
@V@/runtime-po/Makefile.in.in @V@/runtime-po/Makefile.in-in
|
|
||||||
@V@/src/scan-gram-c.c @V@/src/c-scan-gram.c
|
|
||||||
@V@/src/scan-skel-c.c @V@/src/c-scan-skel.c
|
|
||||||
@V@/tests/c++.at @V@/tests/cxx.at
|
|
||||||
-293
@@ -1,293 +0,0 @@
|
|||||||
/* Subprocesses with pipes.
|
|
||||||
|
|
||||||
Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/* Written by Juan Manuel Guerrero <[email protected]>. */
|
|
||||||
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "subpipe.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "xalloc.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef STDIN_FILENO
|
|
||||||
# define STDIN_FILENO 0
|
|
||||||
#endif
|
|
||||||
#ifndef STDOUT_FILENO
|
|
||||||
# define STDOUT_FILENO 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include "gettext.h"
|
|
||||||
#define _(Msgid) gettext (Msgid)
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialize this module. */
|
|
||||||
|
|
||||||
|
|
||||||
static int old_stdin;
|
|
||||||
static int old_stdout;
|
|
||||||
static char **arguments;
|
|
||||||
static char tmp_file_name[2][L_tmpnam];
|
|
||||||
|
|
||||||
#define remove_tmp_file(fd, name) \
|
|
||||||
do { \
|
|
||||||
close ((fd)); \
|
|
||||||
if (unlink ((name))) \
|
|
||||||
error (EXIT_FAILURE, 0, _("removing of '%s' failed"), (name)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
init_subpipe(void)
|
|
||||||
{
|
|
||||||
char *tmpdir;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
tmpdir = getenv("TMPDIR");
|
|
||||||
if (tmpdir == NULL)
|
|
||||||
tmpdir = getenv("TMP");
|
|
||||||
if (tmpdir == NULL)
|
|
||||||
tmpdir = getenv("TEMP");
|
|
||||||
if (access(tmpdir, D_OK))
|
|
||||||
tmpdir = ".";
|
|
||||||
|
|
||||||
strcpy(tmp_file_name[0], tmpdir);
|
|
||||||
strcat(tmp_file_name[0], "/bnXXXXXX");
|
|
||||||
fd = mkstemp(tmp_file_name[0]);
|
|
||||||
if (fd < 0)
|
|
||||||
error(EXIT_FAILURE, 0, _("creation of a temporary file failed"));
|
|
||||||
close (fd);
|
|
||||||
|
|
||||||
strcpy(tmp_file_name[1], tmpdir);
|
|
||||||
strcat(tmp_file_name[1], "/bnXXXXXX");
|
|
||||||
fd = mkstemp(tmp_file_name[1]);
|
|
||||||
if (fd < 0)
|
|
||||||
error(EXIT_FAILURE, 0, _("creation of a temporary file failed"));
|
|
||||||
close (fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Create a subprocess that is run as a filter. ARGV is the
|
|
||||||
NULL-terminated argument vector for the subprocess. Store read and
|
|
||||||
write file descriptors for communication with the subprocess into
|
|
||||||
FD[0] and FD[1]: input meant for the process can be written into
|
|
||||||
FD[0], and output from the process can be read from FD[1]. Return
|
|
||||||
the subprocess id.
|
|
||||||
|
|
||||||
Because DOS has neither fork nor pipe functionality to run the subprocess
|
|
||||||
as a filter, the filter is reproduced using temporary files. First bison's
|
|
||||||
stdout is redirected to a temporary file. After bison has produced all of
|
|
||||||
is output, this file is closed and connected to m4's stdin. All m4's output
|
|
||||||
is redirected from m4's stdout to a second temporary file and reopened as
|
|
||||||
bison's stdin. */
|
|
||||||
|
|
||||||
pid_t
|
|
||||||
create_subpipe(char const *const *argv, int fd[2])
|
|
||||||
{
|
|
||||||
int argc;
|
|
||||||
int from_in_fd; /* pipe from bison to m4. */
|
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
|
|
||||||
pid = getpid();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save original stdin and stdout
|
|
||||||
* for later restauration.
|
|
||||||
*/
|
|
||||||
old_stdin = dup(STDIN_FILENO);
|
|
||||||
if (old_stdin < 0)
|
|
||||||
error(EXIT_FAILURE, 0, _("saving stdin failed"));
|
|
||||||
|
|
||||||
old_stdout = dup(STDOUT_FILENO);
|
|
||||||
if (old_stdout < 0)
|
|
||||||
error(EXIT_FAILURE, 0, _("saving stdout failed"));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save argv for later use.
|
|
||||||
*/
|
|
||||||
for (argc = 0; argv[argc]; argc++)
|
|
||||||
;
|
|
||||||
argc++;
|
|
||||||
arguments = xmalloc(argc * sizeof(arguments[0]));
|
|
||||||
for (argc = 0; argv[argc]; argc++)
|
|
||||||
{
|
|
||||||
arguments[argc] = xmalloc((strlen(argv[argc]) + 1) * sizeof(arguments[0][0]));
|
|
||||||
strcpy(arguments[argc], argv[argc]);
|
|
||||||
}
|
|
||||||
arguments[argc] = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All bison's output will be gathered in this temporary file
|
|
||||||
* and will be redirected to m4's stdin.
|
|
||||||
*/
|
|
||||||
from_in_fd = open(tmp_file_name[0], O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR);
|
|
||||||
if (from_in_fd < 0)
|
|
||||||
error(EXIT_FAILURE, 0, _("opening of tmpfile failed"));
|
|
||||||
if (dup2(from_in_fd, STDOUT_FILENO) < 0)
|
|
||||||
{
|
|
||||||
remove_tmp_file(from_in_fd, tmp_file_name[0]);
|
|
||||||
error(EXIT_FAILURE, 0, _("redirecting bison's stdout to the temporary file failed"));
|
|
||||||
}
|
|
||||||
close(from_in_fd);
|
|
||||||
|
|
||||||
|
|
||||||
fd[0] = STDOUT_FILENO;
|
|
||||||
return pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* A signal handler that just records that a signal has happened. */
|
|
||||||
static int child_interrupted;
|
|
||||||
|
|
||||||
static void
|
|
||||||
signal_catcher(int signo)
|
|
||||||
{
|
|
||||||
child_interrupted++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
end_of_output_subpipe(pid_t pid, int fd[2])
|
|
||||||
{
|
|
||||||
char *program;
|
|
||||||
int from_out_fd = open(tmp_file_name[0], O_RDONLY, S_IRUSR); /* pipe from bison to m4. */
|
|
||||||
int to_in_fd = open(tmp_file_name[1], O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR); /* pipe from m4 to bison. */
|
|
||||||
int status;
|
|
||||||
void (*previous_handler)(int);
|
|
||||||
|
|
||||||
|
|
||||||
program = strrchr(arguments[0], '/');
|
|
||||||
if (program)
|
|
||||||
program++;
|
|
||||||
else
|
|
||||||
program = arguments[0];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Redirect bison's output to m4's stdin.
|
|
||||||
*/
|
|
||||||
if (from_out_fd < 0)
|
|
||||||
error(EXIT_FAILURE, 0, _("opening of tmpfile failed"));
|
|
||||||
if (dup2(from_out_fd, STDIN_FILENO) < 0)
|
|
||||||
{
|
|
||||||
remove_tmp_file(from_out_fd, tmp_file_name[0]);
|
|
||||||
error(EXIT_FAILURE, 0, _("redirecting m4's stdin from the temporary file failed"));
|
|
||||||
}
|
|
||||||
close(from_out_fd);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All m4's output will be gathered in this temporary file
|
|
||||||
* and will be redirected to bison's stdin.
|
|
||||||
*/
|
|
||||||
if (to_in_fd < 0)
|
|
||||||
{
|
|
||||||
remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
|
|
||||||
error(EXIT_FAILURE, 0, _("opening of a temporary file failed"));
|
|
||||||
}
|
|
||||||
if (dup2(to_in_fd, STDOUT_FILENO) < 0)
|
|
||||||
{
|
|
||||||
remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
|
|
||||||
remove_tmp_file(to_in_fd, tmp_file_name[1]);
|
|
||||||
error(EXIT_FAILURE, 0, _("redirecting m4's stdout to a temporary file failed"));
|
|
||||||
}
|
|
||||||
close(to_in_fd);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Run m4.
|
|
||||||
*/
|
|
||||||
child_interrupted = 0;
|
|
||||||
errno = 0;
|
|
||||||
previous_handler = signal(SIGINT, signal_catcher);
|
|
||||||
status = spawnvp(P_WAIT, program, arguments);
|
|
||||||
signal(SIGINT, previous_handler);
|
|
||||||
if (child_interrupted)
|
|
||||||
{
|
|
||||||
remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
|
|
||||||
remove_tmp_file(STDOUT_FILENO, tmp_file_name[1]);
|
|
||||||
error(EXIT_FAILURE, 0, _("subsidiary program '%s' interrupted"), program);
|
|
||||||
}
|
|
||||||
if (status)
|
|
||||||
{
|
|
||||||
remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
|
|
||||||
remove_tmp_file(STDOUT_FILENO, tmp_file_name[1]);
|
|
||||||
error(EXIT_FAILURE, 0, _(errno == ENOENT
|
|
||||||
? "subsidiary program '%s' not found"
|
|
||||||
: status < 1
|
|
||||||
? "subsidiary program '%s' failed"
|
|
||||||
: "subsidiary program '%s' failed (status=%i, errno=%i)"), program, status, errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Redirect m4's output to bison's stdin.
|
|
||||||
*/
|
|
||||||
if (dup2(old_stdout, STDOUT_FILENO) < 0)
|
|
||||||
error(EXIT_FAILURE, 0, "restore of bison's stdout failed");
|
|
||||||
close(old_stdout);
|
|
||||||
to_in_fd = open(tmp_file_name[1], O_RDONLY, S_IRUSR); /* pipe from m4 to bison. */
|
|
||||||
if (to_in_fd < 0)
|
|
||||||
{
|
|
||||||
remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
|
|
||||||
error(EXIT_FAILURE, 0, _("opening of tmpfile failed"));
|
|
||||||
}
|
|
||||||
if (dup2(to_in_fd, STDIN_FILENO) < 0)
|
|
||||||
{
|
|
||||||
remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
|
|
||||||
remove_tmp_file(to_in_fd, tmp_file_name[1]);
|
|
||||||
error(EXIT_FAILURE, -1, "dup2");
|
|
||||||
error(EXIT_FAILURE, 0, _("redirecting bison's stdin from the temporary file failed"));
|
|
||||||
}
|
|
||||||
close(to_in_fd);
|
|
||||||
|
|
||||||
|
|
||||||
fd[1] = STDIN_FILENO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Free resources, unlink temporary files and restore stdin and stdout. */
|
|
||||||
|
|
||||||
void
|
|
||||||
reap_subpipe(pid_t pid, char const *program)
|
|
||||||
{
|
|
||||||
int argc;
|
|
||||||
|
|
||||||
for (argc = 0; arguments[argc]; argc++)
|
|
||||||
free(arguments[argc]);
|
|
||||||
free(arguments);
|
|
||||||
|
|
||||||
if (unlink(tmp_file_name[0]))
|
|
||||||
error(EXIT_FAILURE, 0, _("removing of '%s' failed"), tmp_file_name[0]);
|
|
||||||
if (unlink(tmp_file_name[1]))
|
|
||||||
error(EXIT_FAILURE, 0, _("removing of '%s' failed"), tmp_file_name[1]);
|
|
||||||
|
|
||||||
if (dup2(old_stdin, STDIN_FILENO) < 0)
|
|
||||||
error(EXIT_FAILURE, 0, "restore of bison's stdin failed");
|
|
||||||
close(old_stdin);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/* Subprocesses with pipes.
|
|
||||||
|
|
||||||
Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/* Written by Juan Manuel Guerrero <[email protected]>. */
|
|
||||||
|
|
||||||
#if HAVE_SYS_TYPES_H
|
|
||||||
# include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void init_subpipe(void);
|
|
||||||
pid_t create_subpipe(char const * const *, int[2]);
|
|
||||||
void end_of_output_subpipe(pid_t, int[2]);
|
|
||||||
void reap_subpipe(pid_t, char const *);
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
/bison.help
|
/bison.help
|
||||||
/bison.html
|
/bison.html
|
||||||
/bison.info
|
/bison.info
|
||||||
|
/bison.info.bak
|
||||||
/bison.log
|
/bison.log
|
||||||
/bison.pdf
|
/bison.pdf
|
||||||
/bison.ps
|
/bison.ps
|
||||||
@@ -30,3 +31,6 @@
|
|||||||
/stamp-vti
|
/stamp-vti
|
||||||
/version.texi
|
/version.texi
|
||||||
/yacc.1
|
/yacc.1
|
||||||
|
/relocatable.texi
|
||||||
|
/figs/*.eps
|
||||||
|
/figs/*.svg
|
||||||
|
|||||||
+368
-186
File diff suppressed because it is too large
Load Diff
+1752
-1101
File diff suppressed because it is too large
Load Diff
+39
-14
@@ -1,5 +1,5 @@
|
|||||||
## Copyright (C) 2001-2003, 2005-2015, 2018 Free Software Foundation,
|
## Copyright (C) 2001-2003, 2005-2015, 2018-2020 Free Software
|
||||||
## Inc.
|
## Foundation, Inc.
|
||||||
|
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,12 +14,18 @@
|
|||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
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
|
info_TEXINFOS = doc/bison.texi
|
||||||
doc_bison_TEXINFOS = \
|
doc_bison_TEXINFOS = \
|
||||||
$(CROSS_OPTIONS_TEXI) \
|
$(CROSS_OPTIONS_TEXI) \
|
||||||
doc/fdl.texi \
|
doc/fdl.texi \
|
||||||
doc/gpl-3.0.texi
|
doc/gpl-3.0.texi \
|
||||||
|
doc/relocatable.texi
|
||||||
|
|
||||||
# Cannot express dependencies directly on file names because of Automake.
|
# Cannot express dependencies directly on file names because of Automake.
|
||||||
# Obfuscate with a variable.
|
# Obfuscate with a variable.
|
||||||
@@ -27,7 +33,7 @@ doc_bison = doc/bison
|
|||||||
$(doc_bison).dvi: $(FIGS_GV:.gv=.eps)
|
$(doc_bison).dvi: $(FIGS_GV:.gv=.eps)
|
||||||
$(doc_bison).info: $(FIGS_GV:.gv=.txt)
|
$(doc_bison).info: $(FIGS_GV:.gv=.txt)
|
||||||
$(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
$(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
|
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
||||||
CLEANDIRS += doc/bison.t2d
|
CLEANDIRS += doc/bison.t2d
|
||||||
@@ -48,6 +54,23 @@ $(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
|||||||
$(AM_V_at)mv $@.tmp $@
|
$(AM_V_at)mv $@.tmp $@
|
||||||
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||||
|
|
||||||
|
|
||||||
|
# Fix Info's @code in @deftype
|
||||||
|
# https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html
|
||||||
|
all: $(srcdir)/$(doc_bison).info.bak
|
||||||
|
$(srcdir)/$(doc_bison).info.bak: $(srcdir)/$(doc_bison).info
|
||||||
|
$(AM_V_GEN) $(PERL) -pi.bak -0777 \
|
||||||
|
-e 's{(^ --.*\n(?: {10}.*\n)*)}' \
|
||||||
|
-e '{' \
|
||||||
|
-e ' $$def = $$1;' \
|
||||||
|
-e ' $$def =~ s/‘|’//g;' \
|
||||||
|
-e ' $$def;' \
|
||||||
|
-e '}gem;' $(srcdir)/$(doc_bison).info
|
||||||
|
@ touch $@
|
||||||
|
EXTRA_DIST += $(srcdir)/$(doc_bison).info.bak
|
||||||
|
MAINTAINERCLEANFILES += $(srcdir)/$(doc_bison).info.bak
|
||||||
|
|
||||||
|
|
||||||
## ---------- ##
|
## ---------- ##
|
||||||
## Ref card. ##
|
## Ref card. ##
|
||||||
## ---------- ##
|
## ---------- ##
|
||||||
@@ -87,11 +110,13 @@ EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
|||||||
if ! CROSS_COMPILING
|
if ! CROSS_COMPILING
|
||||||
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
||||||
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
||||||
$(AM_V_GEN)LC_ALL=C src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
$(AM_V_GEN)LC_ALL=C tests/bison --version >doc/bison.help.tmp
|
||||||
$(AM_V_at) LC_ALL=C src/bison$(EXEEXT) --help | \
|
$(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
|
## Avoid variations in the output depending on whether we are
|
||||||
## on a glibc system.
|
## 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 $@
|
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
||||||
endif ! CROSS_COMPILING
|
endif ! CROSS_COMPILING
|
||||||
|
|
||||||
@@ -117,7 +142,7 @@ endif
|
|||||||
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
||||||
$(AM_V_GEN)$(HELP2MAN) \
|
$(AM_V_GEN)$(HELP2MAN) \
|
||||||
--include=$(top_srcdir)/doc/bison.x \
|
--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 && \
|
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.tmp 2>/dev/null && \
|
||||||
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
|
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
|
||||||
touch $@; \
|
touch $@; \
|
||||||
@@ -134,14 +159,14 @@ endif
|
|||||||
## Graphviz examples generation. ##
|
## 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 = \
|
FIGS_GV = \
|
||||||
doc/figs/example.gv \
|
doc/figs/example.gv \
|
||||||
doc/figs/example-reduce.gv doc/figs/example-shift.gv
|
doc/figs/example-reduce.gv doc/figs/example-shift.gv
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
|
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
|
||||||
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
|
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||||
SUFFIXES += .gv .eps .pdf .png
|
SUFFIXES += .gv .eps .pdf .svg
|
||||||
|
|
||||||
.gv.eps:
|
.gv.eps:
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||||
@@ -153,9 +178,9 @@ SUFFIXES += .gv .eps .pdf .png
|
|||||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
||||||
$(AM_V_at) mv $@.tmp $@
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
.gv.png:
|
.gv.svg:
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
$(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 $@
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|||||||
+9
-9
@@ -19,8 +19,8 @@
|
|||||||
\def\finalout{\overfullrule=0pt}
|
\def\finalout{\overfullrule=0pt}
|
||||||
%\finalout
|
%\finalout
|
||||||
|
|
||||||
% Copyright (c) 1998, 2001, 2009-2015, 2018 Free Software Foundation,
|
% Copyright (c) 1998, 2001, 2009--2015, 2018--2020 Free Software
|
||||||
% Inc.
|
% Foundation, Inc.
|
||||||
%
|
%
|
||||||
% This file is part of Bison.
|
% This file is part of Bison.
|
||||||
%
|
%
|
||||||
@@ -358,7 +358,7 @@ otherwise it will have the format {\tt {\it name}.tab.h}, where
|
|||||||
|
|
||||||
In the above, {\it t} is a {\it type} defined in the {\tt \%union}
|
In the above, {\it t} is a {\it type} defined in the {\tt \%union}
|
||||||
definition, {\it n} is a {\it terminal} symbol name, {\it m} is a
|
definition, {\it n} is a {\it terminal} symbol name, {\it m} is a
|
||||||
{\it non-terminal} symbol name, and {\it association} can be one of
|
{\it nonterminal} symbol name, and {\it association} can be one of
|
||||||
{\tt \%left}, {\tt \%right}, or {\tt \%nonassoc}.
|
{\tt \%left}, {\tt \%right}, or {\tt \%nonassoc}.
|
||||||
|
|
||||||
\vskip .10truein
|
\vskip .10truein
|
||||||
@@ -401,16 +401,16 @@ Rules take the form:
|
|||||||
|
|
||||||
\vskip -\baselineskip
|
\vskip -\baselineskip
|
||||||
\beginexample
|
\beginexample
|
||||||
non-terminal : {\it statement} 1
|
nonterminal : {\it statement} 1
|
||||||
| {\it statement} 2
|
| {\it statement} 2
|
||||||
\vdots
|
\vdots
|
||||||
| {\it statement n}
|
| {\it statement n}
|
||||||
;
|
;
|
||||||
\endexample
|
\endexample
|
||||||
|
|
||||||
Where {\it statements} can be either empty, or contain
|
Where {\it statements} can be either empty, or contain
|
||||||
a mixture of C code (enclosed in {\tt \{...\}}), and the
|
a mixture of C code (enclosed in {\tt \{...\}}), and the
|
||||||
symbols that make up the non-terminal. For example:
|
symbols that make up the nonterminal. For example:
|
||||||
|
|
||||||
\vskip -\baselineskip
|
\vskip -\baselineskip
|
||||||
\beginexample
|
\beginexample
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ straightforward use of _build/src/bison would.)
|
|||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
Copyright (C) 2006, 2009-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2006, 2009-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
#! /usr/bin/perl -w
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
# Copyright (C) 2006, 2008-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2006, 2008-2015, 2018-2020 Free Software Foundation,
|
||||||
|
# Inc.
|
||||||
#
|
#
|
||||||
# This file is part of Bison, the GNU Compiler Compiler.
|
# This file is part of Bison, the GNU Compiler Compiler.
|
||||||
#
|
#
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
## Copyright (C) 2006, 2008-2015, 2018 Free Software Foundation, Inc.
|
## Copyright (C) 2006, 2008-2015, 2018-2020 Free Software Foundation,
|
||||||
|
## Inc.
|
||||||
|
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
This directory contains examples of Bison grammar files.
|
|
||||||
|
|
||||||
Most of them come from the documentation, which should be installed together
|
|
||||||
with Bison. The URLs are provided for convenience.
|
|
||||||
|
|
||||||
|
|
||||||
* Examples in C
|
|
||||||
|
|
||||||
** rpcalc - Reverse Polish Notation Calculator
|
|
||||||
The first example is that of a simple double-precision Reverse Polish
|
|
||||||
Notation calculator (a calculator using postfix operators). This example
|
|
||||||
provides a good starting point, since operator precedence is not an issue.
|
|
||||||
|
|
||||||
Extracted from the documentation: "Reverse Polish Notation Calculator"
|
|
||||||
https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
|
|
||||||
|
|
||||||
** mfcalc - Multi-Function Calculator
|
|
||||||
A more complete C example: a multi-function calculator.
|
|
||||||
|
|
||||||
Extracted from the documentation: "Multi-Function Calculator: mfcalc".
|
|
||||||
https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Examples in C++
|
|
||||||
|
|
||||||
** c++ - A directory of simple C++ examples
|
|
||||||
|
|
||||||
** calc++ - A Complete C++ Example
|
|
||||||
A fully featured C++ version of the canonical example for parsers: a
|
|
||||||
calculator. Also uses Flex for the scanner.
|
|
||||||
|
|
||||||
Extracted from the documentation: "A Complete C++ Example".
|
|
||||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
|
||||||
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
Local Variables:
|
|
||||||
mode: outline
|
|
||||||
fill-column: 76
|
|
||||||
ispell-dictionary: "american"
|
|
||||||
End:
|
|
||||||
|
|
||||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
||||||
any later version published by the Free Software Foundation; with no
|
|
||||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license is included in the "GNU Free
|
|
||||||
Documentation License" file as part of this distribution.
|
|
||||||
|
|
||||||
# LocalWords: mfcalc calc parsers yy
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
This directory contains examples of Bison grammar files, sorted per
|
||||||
|
language.
|
||||||
|
|
||||||
|
Several of them come from the documentation, which should be installed
|
||||||
|
together with Bison. The URLs are provided for convenience.
|
||||||
|
|
||||||
|
These examples come with a README and a Makefile. Not only can they be used
|
||||||
|
to toy with Bison, they can also be starting points for your own grammars.
|
||||||
|
|
||||||
|
Please, be sure to read the C examples before looking at the other
|
||||||
|
languages, as these examples are simpler.
|
||||||
|
|
||||||
|
<!---
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
--->
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/simple.yy
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
This directory contains examples of Bison grammar files in C++.
|
# Examples in C++
|
||||||
|
|
||||||
* Examples in C++
|
This directory contains examples of Bison grammar files in C++.
|
||||||
|
|
||||||
You can run `make` to compile these examples. And `make clean` to tidy
|
You can run `make` to compile these examples. And `make clean` to tidy
|
||||||
afterwards.
|
afterwards.
|
||||||
|
|
||||||
** simple.yy - Simple example in C++14
|
## simple.yy - Simple example in C++14
|
||||||
A very simple example in C++, based on variants and symbol constructors.
|
A very simple example in C++, based on variants and symbol constructors.
|
||||||
Variants allow to use any C++ type as semantic value type, and symbol
|
Variants allow to use any C++ type as semantic value type, and symbol
|
||||||
constructors ensure consistency between declared token type and effective
|
constructors ensure consistency between declared token type and effective
|
||||||
@@ -16,26 +16,37 @@ Run as `./simple`.
|
|||||||
Extracted from the documentation: "A Simple C++ Example".
|
Extracted from the documentation: "A Simple C++ Example".
|
||||||
https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html
|
https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html
|
||||||
|
|
||||||
** variant.yy - Self-contained example in C++98
|
## variant.yy - Self-contained example in C++98
|
||||||
A variation of simple.yy, in C++98.
|
A variation of simple.yy, in C++98.
|
||||||
|
|
||||||
Run as `./variant`.
|
Run as `./variant`.
|
||||||
|
|
||||||
** variant-11.yy - Self-contained example in modern C++
|
## variant-11.yy - Self-contained example in modern C++
|
||||||
Another variation of simple.yy, closely related to the previous one, but
|
Another variation of simple.yy, closely related to the previous one, but
|
||||||
exhibiting support for C++11's move semantics.
|
exhibiting support for C++11's move semantics.
|
||||||
|
|
||||||
Run as `./variant` or `./variant NUMBER`.
|
Run as `./variant` or `./variant NUMBER`.
|
||||||
|
|
||||||
-----
|
## calc++ - A Complete C++ Example
|
||||||
|
A fully featured C++ version of the canonical example for parsers: a
|
||||||
|
calculator. Also uses Flex for the scanner.
|
||||||
|
|
||||||
|
Don't look at this example first: it is fully featured and can serve as a
|
||||||
|
starting point for a clean parser in C++. The previous examples are better
|
||||||
|
introductory examples, and the C examples are also useful introductory
|
||||||
|
examples.
|
||||||
|
|
||||||
|
Extracted from the documentation: "A Complete C++ Example".
|
||||||
|
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
||||||
|
|
||||||
|
<!---
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
|
||||||
fill-column: 76
|
fill-column: 76
|
||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
@@ -45,3 +56,4 @@ Texts. A copy of the license is included in the "GNU Free
|
|||||||
Documentation License" file as part of this distribution.
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
# LocalWords: mfcalc calc parsers yy ispell american
|
# LocalWords: mfcalc calc parsers yy ispell american
|
||||||
|
--->
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# This Makefile is designed to be simple and readable. It does not
|
||||||
|
# aim at portability. It requires GNU Make.
|
||||||
|
|
||||||
|
BASE = calc++
|
||||||
|
BISON = bison
|
||||||
|
CXX = g++
|
||||||
|
FLEX = flex
|
||||||
|
XSLTPROC = xsltproc
|
||||||
|
|
||||||
|
all: $(BASE)
|
||||||
|
|
||||||
|
%.cc %.hh %.xml %.gv: %.yy
|
||||||
|
$(BISON) $(BISONFLAGS) --xml --graph=$*.gv -o $*.cc $<
|
||||||
|
|
||||||
|
%.cc: %.ll
|
||||||
|
$(FLEX) $(FLEXFLAGS) -o$@ $<
|
||||||
|
|
||||||
|
%.o: %.cc
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o$@ $<
|
||||||
|
|
||||||
|
$(BASE): $(BASE).o driver.o parser.o scanner.o
|
||||||
|
$(CXX) -o $@ $^
|
||||||
|
|
||||||
|
$(BASE).o: parser.hh
|
||||||
|
parser.o: parser.hh
|
||||||
|
scanner.o: parser.hh
|
||||||
|
|
||||||
|
run: $(BASE)
|
||||||
|
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||||
|
./$< -
|
||||||
|
|
||||||
|
html: parser.html
|
||||||
|
%.html: %.xml
|
||||||
|
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(BASE) *.o \
|
||||||
|
parser.hh parser.cc parser.output parser.xml parser.html parser.gv location.hh \
|
||||||
|
scanner.cc
|
||||||
|
clean:
|
||||||
|
rm -f $(CLEANFILES)
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
This directory contains calc++, a simple Bison grammar file in C++.
|
# calc++ - A Flex+Bison calculator
|
||||||
|
|
||||||
Please, read the corresponding chapter in the documentation: "A Complete C++
|
This directory contains calc++, a Bison grammar file in C++. If you never
|
||||||
|
saw the traditional implementation in C, please first read
|
||||||
|
examples/c/lexcalc, which can be seen as a C precursor of this example.
|
||||||
|
|
||||||
|
Read the corresponding chapter in the documentation: "A Complete C++
|
||||||
Example". It is also available on line (maybe with a different version of
|
Example". It is also available on line (maybe with a different version of
|
||||||
Bison):
|
Bison):
|
||||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
||||||
@@ -13,6 +17,7 @@ evaluate.
|
|||||||
The program calc++ expects the file to parse as argument; pass `-` to read
|
The program calc++ expects the file to parse as argument; pass `-` to read
|
||||||
the standard input (and then hit <Ctrl-d>, control-d, to end your input).
|
the standard input (and then hit <Ctrl-d>, control-d, to end your input).
|
||||||
|
|
||||||
|
```
|
||||||
$ ./calc++ -
|
$ ./calc++ -
|
||||||
one := 1
|
one := 1
|
||||||
two := 2
|
two := 2
|
||||||
@@ -20,19 +25,18 @@ three := 3
|
|||||||
(one + two * three) * two * three
|
(one + two * three) * two * three
|
||||||
<Ctrl-d>
|
<Ctrl-d>
|
||||||
42
|
42
|
||||||
|
```
|
||||||
|
|
||||||
You may pass `-p` to activate the parser debug traces, and `-s` to activate
|
You may pass `-p` to activate the parser debug traces, and `-s` to activate
|
||||||
the scanner's.
|
the scanner's.
|
||||||
|
|
||||||
-----
|
<!---
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
|
||||||
fill-column: 76
|
fill-column: 76
|
||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -49,4 +53,5 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# LocalWords: mfcalc calc parsers yy MERCHANTABILITY Ctrl ispell american
|
# LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||||
|
--->
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2005-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
## Copyright (C) 2005-2006, 2008-2015, 2018 Free Software Foundation,
|
## Copyright (C) 2005-2006, 2008-2015, 2018-2020 Free Software
|
||||||
## Inc.
|
## Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,9 +18,7 @@
|
|||||||
## Parser generation. ##
|
## Parser generation. ##
|
||||||
## ------------------- ##
|
## ------------------- ##
|
||||||
|
|
||||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
%D%/parser.stamp: $(dependencies)
|
||||||
# in srcdir, including during distcheck, which is forbidden.
|
|
||||||
%D%/parser.stamp: $(BISON_IN)
|
|
||||||
SUFFIXES += .yy .stamp
|
SUFFIXES += .yy .stamp
|
||||||
.yy.stamp:
|
.yy.stamp:
|
||||||
$(AM_V_YACC)rm -f $@
|
$(AM_V_YACC)rm -f $@
|
||||||
@@ -33,6 +31,7 @@ $(calcxx_sources_generated): %D%/parser.stamp
|
|||||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/parser.stamp
|
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/parser.stamp
|
||||||
CLEANFILES += \
|
CLEANFILES += \
|
||||||
$(calcxx_sources_generated) \
|
$(calcxx_sources_generated) \
|
||||||
|
%D%/parser.dot \
|
||||||
%D%/parser.output \
|
%D%/parser.output \
|
||||||
%D%/parser.stamp \
|
%D%/parser.stamp \
|
||||||
%D%/scanner.cc
|
%D%/scanner.cc
|
||||||
@@ -79,6 +78,6 @@ EXTRA_DIST += %D%/calc++.test
|
|||||||
## Installing. ##
|
## Installing. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
|
|
||||||
calcxxdir = $(docdir)/examples/calc++
|
calcxxdir = $(docdir)/%D%
|
||||||
calcxx_DATA = $(calcxx_extracted)
|
calcxx_DATA = $(calcxx_extracted)
|
||||||
dist_calcxx_DATA = %D%/README %D%/Makefile
|
dist_calcxx_DATA = %D%/README.md %D%/Makefile
|
||||||
+10
-7
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2018 Free Software Foundation, Inc.
|
## Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
cxxdir = $(examplesdir)/c++
|
cxxdir = $(docdir)/%D%
|
||||||
|
include %D%/calc++/local.mk
|
||||||
|
|
||||||
## -------- ##
|
## -------- ##
|
||||||
## Simple. ##
|
## Simple. ##
|
||||||
@@ -36,7 +37,7 @@ if ENABLE_CXX14
|
|||||||
# Don't use gnulib's system headers.
|
# Don't use gnulib's system headers.
|
||||||
%C%_simple_CPPFLAGS = -I$(top_builddir)
|
%C%_simple_CPPFLAGS = -I$(top_builddir)
|
||||||
TESTS += %D%/simple.test
|
TESTS += %D%/simple.test
|
||||||
%D%/simple.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
%D%/simple.cc: $(dependencies)
|
||||||
endif
|
endif
|
||||||
EXTRA_DIST += %D%/simple.test
|
EXTRA_DIST += %D%/simple.test
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ if ENABLE_CXX
|
|||||||
# Don't use gnulib's system headers.
|
# Don't use gnulib's system headers.
|
||||||
%C%_variant_CPPFLAGS = -I$(top_builddir)
|
%C%_variant_CPPFLAGS = -I$(top_builddir)
|
||||||
TESTS += %D%/variant.test
|
TESTS += %D%/variant.test
|
||||||
%D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
%D%/variant.cc: $(dependencies)
|
||||||
endif
|
endif
|
||||||
EXTRA_DIST += %D%/variant.test
|
EXTRA_DIST += %D%/variant.test
|
||||||
|
|
||||||
@@ -62,9 +63,11 @@ if ENABLE_CXX11
|
|||||||
# Don't use gnulib's system headers.
|
# Don't use gnulib's system headers.
|
||||||
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
|
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
|
||||||
TESTS += %D%/variant-11.test
|
TESTS += %D%/variant-11.test
|
||||||
%D%/variant-11.cc: $(BISON_IN) $(dist_pkgdata_DATA)
|
%D%/variant-11.cc: $(dependencies)
|
||||||
endif
|
endif
|
||||||
EXTRA_DIST += %D%/variant-11.test
|
EXTRA_DIST += %D%/variant-11.test
|
||||||
|
|
||||||
dist_cxx_DATA = %D%/README %D%/Makefile %D%/variant.yy %D%/variant-11.yy
|
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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2008-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -117,7 +117,7 @@ namespace yy
|
|||||||
static int count = 0;
|
static int count = 0;
|
||||||
const int stage = count;
|
const int stage = count;
|
||||||
++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)
|
if (stage == 0)
|
||||||
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
||||||
else if (stage < max)
|
else if (stage < max)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2018 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2008-2015, 2018 Free Software Foundation, Inc.
|
Copyright (C) 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -117,7 +117,7 @@ namespace yy
|
|||||||
static int count = 0;
|
static int count = 0;
|
||||||
const int stage = count;
|
const int stage = count;
|
||||||
++count;
|
++count;
|
||||||
parser::location_type loc (NULLPTR, unsigned (stage + 1), unsigned (stage + 1));
|
parser::location_type loc (NULLPTR, stage + 1, stage + 1);
|
||||||
switch (stage)
|
switch (stage)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# Examples in C
|
||||||
|
|
||||||
|
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
|
||||||
|
The first example is that of a simple double-precision Reverse Polish
|
||||||
|
Notation calculator (a calculator using postfix operators). This example
|
||||||
|
provides a good starting point, since operator precedence is not an issue.
|
||||||
|
|
||||||
|
Extracted from the documentation: "Reverse Polish Notation Calculator"
|
||||||
|
https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
|
||||||
|
<!---
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
|
# LocalWords: mfcalc calc parsers yy 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-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--->
|
||||||
@@ -1,23 +1,37 @@
|
|||||||
# DJGPP specific configuration file.
|
#! /bin/sh
|
||||||
# Sed script for additional DJGPP specific editing
|
|
||||||
# of the testsuite script generated by autoconf 2.61.
|
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
# Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
# it under the terms of the GNU General Public License as published by
|
# (at your option) any later version.
|
||||||
# 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
|
||||||
# This program is distributed in the hope that it will be useful,
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# GNU General Public License for more details.
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
#
|
||||||
# GNU General Public License for more details.
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
cat >input <<EOF
|
||||||
|
1+2*3
|
||||||
|
EOF
|
||||||
# Remove disallowed characters from file names.
|
run 0 7
|
||||||
|
|
||||||
s/~!@#\\\$%^&\*()-=_+{}\[\]|\\\\:;<>, ./~!@#\\$%^\&()-=_+{}[];, ./g
|
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-2020 Free Software Foundation, Inc.
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# This Makefile is designed to be simple and readable. It does not
|
||||||
|
# aim at portability. It requires GNU Make.
|
||||||
|
|
||||||
|
BASE = lexcalc
|
||||||
|
BISON = bison
|
||||||
|
FLEX = flex
|
||||||
|
XSLTPROC = xsltproc
|
||||||
|
|
||||||
|
all: $(BASE)
|
||||||
|
|
||||||
|
%.c %.h %.xml %.gv: %.y
|
||||||
|
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||||
|
|
||||||
|
%.c: %.l
|
||||||
|
$(FLEX) $(FLEXFLAGS) -o$@ $<
|
||||||
|
|
||||||
|
scan.o: parse.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.c
|
||||||
|
clean:
|
||||||
|
rm -f $(CLEANFILES)
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# lexcalc - calculator with Flex and Bison
|
||||||
|
|
||||||
|
This directory contains lexcalc, the traditional example of using Flex and
|
||||||
|
Bison to build a simple calculator.
|
||||||
|
|
||||||
|
<!---
|
||||||
|
Local Variables:
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--->
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# sed script for DJGPP specific editing of config.hin
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -15,14 +15,18 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1+2*3
|
||||||
|
EOF
|
||||||
|
run 0 7
|
||||||
|
|
||||||
$ a\
|
cat >input <<EOF
|
||||||
\
|
(1+2) * 3
|
||||||
\
|
EOF
|
||||||
/* DJGPP specific defines. */\
|
run 0 9
|
||||||
\
|
run -noerr 0 9 -p
|
||||||
#include <unistd.h>\
|
|
||||||
#define TAB_EXT ((pathconf(NULL, _PC_NAME_MAX) > 12) ? ".tab" : "_tab")\
|
cat >input <<EOF
|
||||||
#define OUTPUT_EXT ((pathconf(NULL, _PC_NAME_MAX) > 12) ? ".output" : ".out")\
|
(1+2) *
|
||||||
\
|
EOF
|
||||||
#define DEFAULT_TMPDIR "/dev/env/DJDIR/tmp"
|
run 1 'err: syntax error, unexpected end-of-line, expecting ( or number'
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
## Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## 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/>.
|
||||||
|
|
||||||
|
lexcalcdir = $(docdir)/%D%
|
||||||
|
|
||||||
|
## --------- ##
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
EXTRA_DIST += %D%/lexcalc.test
|
||||||
|
dist_lexcalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
|
||||||
|
CLEANFILES += %D%/parse.[ch] %D%/scan.c %D%/parse.output
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
// Prologue (directives).
|
||||||
|
%expect 0
|
||||||
|
|
||||||
|
// Emitted in the header file, after the definition of YYSTYPE.
|
||||||
|
%code provides
|
||||||
|
{
|
||||||
|
// Tell Flex the expected prototype of yylex.
|
||||||
|
#define YY_DECL \
|
||||||
|
enum yytokentype yylex (YYSTYPE* yylval, int *nerrs)
|
||||||
|
YY_DECL;
|
||||||
|
|
||||||
|
void yyerror (int *nerrs, const char *msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emitted on top of the implementation file.
|
||||||
|
%code top
|
||||||
|
{
|
||||||
|
#include <stdio.h> // printf.
|
||||||
|
#include <stdlib.h> // getenv.
|
||||||
|
}
|
||||||
|
|
||||||
|
%define api.pure full
|
||||||
|
%define api.token.prefix {TOK_}
|
||||||
|
%define api.value.type union
|
||||||
|
%define parse.error verbose
|
||||||
|
%define parse.trace
|
||||||
|
// Error count, exchanged between main, yyparse and yylex.
|
||||||
|
%param {int *nerrs}
|
||||||
|
|
||||||
|
%token
|
||||||
|
PLUS "+"
|
||||||
|
MINUS "-"
|
||||||
|
STAR "*"
|
||||||
|
SLASH "/"
|
||||||
|
LPAREN "("
|
||||||
|
RPAREN ")"
|
||||||
|
EOL "end-of-line"
|
||||||
|
EOF 0 "end-of-file"
|
||||||
|
;
|
||||||
|
|
||||||
|
%token <int> NUM "number"
|
||||||
|
%type <int> exp
|
||||||
|
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||||
|
|
||||||
|
// Precedence (from lowest to highest) and associativity.
|
||||||
|
%left "+" "-"
|
||||||
|
%left "*" "/"
|
||||||
|
|
||||||
|
%%
|
||||||
|
// Rules.
|
||||||
|
input:
|
||||||
|
%empty
|
||||||
|
| input line
|
||||||
|
;
|
||||||
|
|
||||||
|
line:
|
||||||
|
exp EOL { printf ("%d\n", $exp); }
|
||||||
|
| error EOL { yyerrok; }
|
||||||
|
;
|
||||||
|
|
||||||
|
exp:
|
||||||
|
exp "+" exp { $$ = $1 + $3; }
|
||||||
|
| exp "-" exp { $$ = $1 - $3; }
|
||||||
|
| exp "*" exp { $$ = $1 * $3; }
|
||||||
|
| exp "/" exp
|
||||||
|
{
|
||||||
|
if ($3 == 0)
|
||||||
|
{
|
||||||
|
yyerror (nerrs, "invalid division by zero");
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$$ = $1 / $3;
|
||||||
|
}
|
||||||
|
| "(" exp ")" { $$ = $2; }
|
||||||
|
| NUM { $$ = $1; }
|
||||||
|
;
|
||||||
|
%%
|
||||||
|
// Epilogue (C code).
|
||||||
|
void yyerror (int *nerrs, const char *msg)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s\n", msg);
|
||||||
|
++*nerrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
int nerrs = 0;
|
||||||
|
// Possibly enable parser runtime debugging.
|
||||||
|
yydebug = !!getenv ("YYDEBUG");
|
||||||
|
yyparse (&nerrs);
|
||||||
|
// Exit on failure if there were errors.
|
||||||
|
return !!nerrs;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/* Prologue (directives). -*- C++ -*- */
|
||||||
|
|
||||||
|
/* Disable Flex features we don't need, to avoid warnings. */
|
||||||
|
%option nodefault noinput nounput noyywrap
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <errno.h> /* errno, ERANGE */
|
||||||
|
#include <limits.h> /* INT_MIN */
|
||||||
|
#include <stdlib.h> /* strtol */
|
||||||
|
|
||||||
|
#include "parse.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%%
|
||||||
|
/* Rules. */
|
||||||
|
|
||||||
|
"+" return TOK_PLUS;
|
||||||
|
"-" return TOK_MINUS;
|
||||||
|
"*" return TOK_STAR;
|
||||||
|
"/" return TOK_SLASH;
|
||||||
|
|
||||||
|
"(" return TOK_LPAREN;
|
||||||
|
")" return TOK_RPAREN;
|
||||||
|
|
||||||
|
/* Scan an integer. */
|
||||||
|
[0-9]+ {
|
||||||
|
errno = 0;
|
||||||
|
long n = strtol (yytext, NULL, 10);
|
||||||
|
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||||
|
yyerror (nerrs, "integer is out of range");
|
||||||
|
yylval->TOK_NUM = (int) n;
|
||||||
|
return TOK_NUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore white spaces. */
|
||||||
|
[ \t]+ continue;
|
||||||
|
|
||||||
|
"\n" return TOK_EOL;
|
||||||
|
|
||||||
|
. yyerror (nerrs, "syntax error, invalid character");
|
||||||
|
|
||||||
|
<<EOF>> return TOK_EOF;
|
||||||
|
%%
|
||||||
|
/* Epilogue (C code). */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user