mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-17 14:45:15 +00:00
Compare commits
795
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ca964032 | ||
|
|
485b319598 | ||
|
|
1ed94b7c84 | ||
|
|
b119971aef | ||
|
|
2a0f5b17b4 | ||
|
|
b611359d90 | ||
|
|
3eb4f1a3e6 | ||
|
|
9553083c72 | ||
|
|
8f064948c5 | ||
|
|
60aa04a236 | ||
|
|
ccdc1577ef | ||
|
|
ff34897041 | ||
|
|
dcb366b103 | ||
|
|
5458913aba | ||
|
|
73370a9daa | ||
|
|
b640317060 | ||
|
|
3e153163c7 | ||
|
|
5ff5cf6700 | ||
|
|
415b88231a | ||
|
|
6fb8b25619 | ||
|
|
d0f11c1b62 | ||
|
|
327db05b22 | ||
|
|
f124616490 | ||
|
|
7aaaad6c6d | ||
|
|
22b081deb7 | ||
|
|
297e263a00 | ||
|
|
ea9a35c605 | ||
|
|
9641b918ba | ||
|
|
423ca9b50e | ||
|
|
6cf3716c31 | ||
|
|
6a0655d9cd | ||
|
|
71da68b366 | ||
|
|
dfe292c695 | ||
|
|
9fd33c2b6e | ||
|
|
3b0b682fd6 | ||
|
|
0d4b994cc2 | ||
|
|
e97965c022 | ||
|
|
6dc4663d5c | ||
|
|
b921d92fcb | ||
|
|
dda2c1adba | ||
|
|
71bff31edd | ||
|
|
0dd59ce3b4 | ||
|
|
e436fa677c | ||
|
|
22539284f3 | ||
|
|
aed41cf9a0 | ||
|
|
c0beb08772 | ||
|
|
5237cd1ac8 | ||
|
|
9ce27ab013 | ||
|
|
4896ede89c | ||
|
|
84526bf3d1 | ||
|
|
d9a7c07c5a | ||
|
|
28126202a5 | ||
|
|
527187137a | ||
|
|
398c298c88 | ||
|
|
c547693afd | ||
|
|
775673717f | ||
|
|
520144aadc | ||
|
|
72cd9a913f | ||
|
|
c50263271d | ||
|
|
93c150b666 | ||
|
|
abcd36ca1b | ||
|
|
746ac9aa81 | ||
|
|
e3fd1dcb8b | ||
|
|
830e733076 | ||
|
|
5aaad6c431 | ||
|
|
8e15fef554 | ||
|
|
ed0e63dc0a | ||
|
|
45d4c012d3 | ||
|
|
da83f83821 | ||
|
|
d243e0241f | ||
|
|
c850546ab3 | ||
|
|
ed3c2b915f | ||
|
|
544b863511 | ||
|
|
eeaf1dc646 | ||
|
|
3e75a2c92b | ||
|
|
24d84dd26c | ||
|
|
8ec3110a9e | ||
|
|
ac3f2e33b4 | ||
|
|
ff9684b720 | ||
|
|
70986d84bc | ||
|
|
62243aa576 | ||
|
|
29e20e22e0 | ||
|
|
5a321748e2 | ||
|
|
0860e38311 | ||
|
|
1d280c0999 | ||
|
|
5e9b6624d7 | ||
|
|
c93f22fcf7 | ||
|
|
aaaa2aaef4 | ||
|
|
1e5d654019 | ||
|
|
fc25770394 | ||
|
|
35880c82dc | ||
|
|
67218723a0 | ||
|
|
260cee2ded | ||
|
|
fca5693b76 | ||
|
|
dd31e17d7e | ||
|
|
16d94f45c9 | ||
|
|
a17187e563 | ||
|
|
39ac121457 | ||
|
|
4663cb4d0c | ||
|
|
2a55930762 | ||
|
|
59fba180a5 | ||
|
|
2191bb749b | ||
|
|
f518dbaf46 | ||
|
|
71b52b1342 | ||
|
|
baf22389ef | ||
|
|
6f8f253b15 | ||
|
|
459a57a90f | ||
|
|
4c4d35394d | ||
|
|
a6b2f4fc02 | ||
|
|
d4fca42763 | ||
|
|
24ec083743 | ||
|
|
e7b94cc360 | ||
|
|
762caaf639 | ||
|
|
db3458d6ea | ||
|
|
4d699f44e6 | ||
|
|
222342aa67 | ||
|
|
a7497ca6b6 | ||
|
|
f483f4f8ec | ||
|
|
d9b968d8d6 | ||
|
|
d0f2b7f856 | ||
|
|
eff97eb54a | ||
|
|
108df813c4 | ||
|
|
831a4fdb5e | ||
|
|
578e34133a | ||
|
|
5a9c6b89d0 | ||
|
|
c3a2e0e6dd | ||
|
|
dfd31acea7 | ||
|
|
c1192f8af3 | ||
|
|
2e4986a88d | ||
|
|
aeb57fb68d | ||
|
|
f9c75dd016 | ||
|
|
0bb5783b38 | ||
|
|
292402a9b2 | ||
|
|
3d6ca33908 | ||
|
|
737406a32c | ||
|
|
609b3d8096 | ||
|
|
7726724a70 | ||
|
|
360ae94ebc | ||
|
|
72c12bfa1b | ||
|
|
bdf66d1db4 | ||
|
|
3272a7256f | ||
|
|
3b4d62d526 | ||
|
|
a6552c5d2a | ||
|
|
199a2d6d72 | ||
|
|
a8c5aaa53e | ||
|
|
9bfbf75bdf | ||
|
|
beadb220d5 | ||
|
|
f86a780785 | ||
|
|
4a9cd8f24a | ||
|
|
62a87154b3 | ||
|
|
01d25b42dc | ||
|
|
f67c0a1c35 | ||
|
|
acb5895680 | ||
|
|
888b6ddfe4 | ||
|
|
36021b239d | ||
|
|
d115aad911 | ||
|
|
2c7f50be62 | ||
|
|
93ebddb11f | ||
|
|
1890a2a816 | ||
|
|
da1eb15bc9 | ||
|
|
071ca141ec | ||
|
|
fb9eea8885 | ||
|
|
219139f521 | ||
|
|
8bd2f687b6 | ||
|
|
5ef4a3c71c | ||
|
|
4aa9d1ff9c | ||
|
|
ae93e4e4b8 | ||
|
|
728415f885 | ||
|
|
85ad742d4e | ||
|
|
77f114dd6e | ||
|
|
cf33c228e0 | ||
|
|
e7f5dbf82d | ||
|
|
aebc430361 | ||
|
|
da5462d42a | ||
|
|
b87414a05e | ||
|
|
411614fac4 | ||
|
|
2d404819d0 | ||
|
|
78e365574e | ||
|
|
3ca445da25 | ||
|
|
6116a98165 | ||
|
|
59420cd716 | ||
|
|
09aa8a885b | ||
|
|
a64b1f68b1 | ||
|
|
34136e65fc | ||
|
|
2a2b748569 | ||
|
|
139c548a02 | ||
|
|
89d4466b6b | ||
|
|
f3bd3f7876 | ||
|
|
d63311dfb9 | ||
|
|
765e1bd4fc | ||
|
|
e969014232 | ||
|
|
c12aa01f82 | ||
|
|
b55b68608f | ||
|
|
1769eb3011 | ||
|
|
303834ccb0 | ||
|
|
a7b15ab99c | ||
|
|
a40e77ebf6 | ||
|
|
378e917c55 | ||
|
|
df6e3db055 | ||
|
|
28801043bb | ||
|
|
84f6a6ca70 | ||
|
|
1f36f54446 | ||
|
|
ba60c39547 | ||
|
|
7262f54fea | ||
|
|
4b568fc020 | ||
|
|
9fc4c025fd | ||
|
|
67b8cfbd94 | ||
|
|
a801089ca3 | ||
|
|
2f658d530b | ||
|
|
786743d5eb | ||
|
|
e4a148796a | ||
|
|
c39014ae2b | ||
|
|
bf0e44e87c | ||
|
|
86408959da | ||
|
|
709c7d1148 | ||
|
|
f0ad1b2fb2 | ||
|
|
f9d52903f1 | ||
|
|
a4d1bf6a9c | ||
|
|
17d7bf83d0 | ||
|
|
02803d55cd | ||
|
|
1a33f4f608 | ||
|
|
3f8ffd15ee | ||
|
|
15e46f2df4 | ||
|
|
cc09e5beb9 | ||
|
|
32493bc84d | ||
|
|
7fceb615a5 | ||
|
|
5e528941f4 | ||
|
|
6771a463cd | ||
|
|
aa3bcdf35e | ||
|
|
8407249529 | ||
|
|
51151d9171 | ||
|
|
35c1e5f0cd | ||
|
|
e0c072223c | ||
|
|
ff7571c04d | ||
|
|
679e9935fd | ||
|
|
af28d414f3 | ||
|
|
82f3355eaf | ||
|
|
676997e53b | ||
|
|
fe3cae17a1 | ||
|
|
bf3e44fe46 | ||
|
|
3c9b20ff5a | ||
|
|
5c9efc755e | ||
|
|
8a4281b987 | ||
|
|
e0319547b6 | ||
|
|
15fe6bb421 | ||
|
|
355bdbdc72 | ||
|
|
575619af5e | ||
|
|
cb3f7f335a | ||
|
|
1eb6350451 | ||
|
|
d397d9f08c | ||
|
|
f1b238df18 | ||
|
|
fcf834f9ec | ||
|
|
107844a3ee | ||
|
|
bf35c71c58 | ||
|
|
10bae98af2 | ||
|
|
d2060f0634 | ||
|
|
25a648d8a6 | ||
|
|
b4bbc4a03c | ||
|
|
71431084d1 | ||
|
|
34db451c37 | ||
|
|
9d6bc5c402 | ||
|
|
e503b9cbbe | ||
|
|
8ff146cd31 | ||
|
|
95aed8db15 | ||
|
|
771a7fb869 | ||
|
|
39f5757a95 | ||
|
|
d467f443df | ||
|
|
c49784f5f5 | ||
|
|
64877e5e04 | ||
|
|
83af658521 | ||
|
|
93d7dde97a | ||
|
|
2bfcac9a2b | ||
|
|
20be2f9227 | ||
|
|
c61d4fa1d0 | ||
|
|
825c88e831 | ||
|
|
343c3db8a5 | ||
|
|
42765f8e7d | ||
|
|
e35bc778cb | ||
|
|
b6ca79e859 | ||
|
|
ca2a6d1587 | ||
|
|
804e83b26d | ||
|
|
7d424de14c | ||
|
|
38435078b1 | ||
|
|
27290b6035 | ||
|
|
e944aaff36 | ||
|
|
86e5b4402f | ||
|
|
bb9191dd31 | ||
|
|
f38ae16f37 | ||
|
|
8aec287e64 | ||
|
|
c826013fb3 | ||
|
|
7789b6e3e7 | ||
|
|
19ad326be4 | ||
|
|
f5da8149a2 | ||
|
|
49976d5c45 | ||
|
|
bc81de36b7 | ||
|
|
b7666378f5 | ||
|
|
56e92e0bff | ||
|
|
9b5049bd07 | ||
|
|
02354690ee | ||
|
|
a7ddefd1c2 | ||
|
|
c1bd4b2b6f | ||
|
|
67f1a2c254 | ||
|
|
4f756f887b | ||
|
|
24bb8c8c25 | ||
|
|
af129079f0 | ||
|
|
36dc3637a4 | ||
|
|
c499231de4 | ||
|
|
7799ef1594 | ||
|
|
06cb07d517 | ||
|
|
4586c8cdb7 | ||
|
|
44c2b42dbb | ||
|
|
218287f567 | ||
|
|
8176ab33c8 | ||
|
|
4ad3921d3b | ||
|
|
10a697de00 | ||
|
|
d6b347e433 | ||
|
|
b867584028 | ||
|
|
8b9e021fd1 | ||
|
|
96a381c502 | ||
|
|
e19a049cce | ||
|
|
890aeb28f6 | ||
|
|
f39ab2869c | ||
|
|
e32050b0c7 | ||
|
|
efc4ed4a0f | ||
|
|
95611b5617 | ||
|
|
d6e40cba9d | ||
|
|
80b70223b1 | ||
|
|
3320a276d2 | ||
|
|
e30c0477a8 | ||
|
|
a538eeb110 | ||
|
|
d6bdb90a2a | ||
|
|
326e5cf81e | ||
|
|
fca9c5eff1 | ||
|
|
e141f4d4bb | ||
|
|
882be728b2 | ||
|
|
8bb3a2e7df | ||
|
|
505e155199 | ||
|
|
b8d19cf8c1 | ||
|
|
df222dfaf4 | ||
|
|
4395a9ff4f | ||
|
|
1625df5b18 | ||
|
|
5335b65a79 | ||
|
|
d59beda068 | ||
|
|
387b4d5047 | ||
|
|
a603c6e0bb | ||
|
|
19750d310c | ||
|
|
c938d650db | ||
|
|
fcd32abd3a | ||
|
|
ae93128c96 | ||
|
|
c843aaab35 | ||
|
|
5c99151aeb | ||
|
|
75f94c6ddf | ||
|
|
ca01f454f0 | ||
|
|
9dc3ee6d54 | ||
|
|
d013372c3f | ||
|
|
5297ebb3bc | ||
|
|
175620d3c6 | ||
|
|
786578e394 | ||
|
|
416a9da61e | ||
|
|
10659d0ec9 | ||
|
|
3c5362b825 | ||
|
|
b143f4048f | ||
|
|
7439c5c0f9 | ||
|
|
45319f1365 | ||
|
|
52cea04ad3 | ||
|
|
37318e2fe9 | ||
|
|
f74d6d2591 | ||
|
|
5b1ff42379 | ||
|
|
47eced3099 | ||
|
|
d8f68fc295 | ||
|
|
43aabb70a9 | ||
|
|
298e8ad91a | ||
|
|
66381412d9 | ||
|
|
5ad90d528d | ||
|
|
a6ca4ce229 | ||
|
|
3cdc21cfd7 | ||
|
|
f50bfcd6a1 | ||
|
|
6b5a0de960 | ||
|
|
2b08bcebf0 | ||
|
|
c981ce9b2b | ||
|
|
00d80a9ced | ||
|
|
f64e406b80 | ||
|
|
bb31eb56ab | ||
|
|
2d39988807 | ||
|
|
ff60136654 | ||
|
|
2966006237 | ||
|
|
2055a44ed2 | ||
|
|
dd875058b2 | ||
|
|
f71db70bce | ||
|
|
eaca4c1103 | ||
|
|
b18cdd91e8 | ||
|
|
a7706735d1 | ||
|
|
c6abeab182 | ||
|
|
9789acf091 | ||
|
|
61bc57e533 | ||
|
|
f4c75eaf2a | ||
|
|
82db7cdb69 | ||
|
|
2755de8fec | ||
|
|
1deef26d0c | ||
|
|
2646cd540b | ||
|
|
cf499cff31 | ||
|
|
6ba9640406 | ||
|
|
4413bbd3d1 | ||
|
|
b70c7fb4e1 | ||
|
|
d1cc31c5f0 | ||
|
|
3bed3a757f | ||
|
|
aa0cb40d61 | ||
|
|
f2b30bdf37 | ||
|
|
53f036ce02 | ||
|
|
8741288212 | ||
|
|
e6c849d82a | ||
|
|
b0778bdd0c | ||
|
|
d8911864c2 | ||
|
|
c2724603c9 | ||
|
|
17aed602c6 | ||
|
|
9142239a59 | ||
|
|
171ad99d64 | ||
|
|
d59e456dbf | ||
|
|
ceb8b8e6b5 | ||
|
|
7580c37942 | ||
|
|
c4dc4c4671 | ||
|
|
c67e466f9d | ||
|
|
af6d235843 | ||
|
|
91a2b9b1b2 | ||
|
|
13bcafb580 | ||
|
|
585935e895 | ||
|
|
83b60c97ee | ||
|
|
28169bab1f | ||
|
|
9f14e18736 | ||
|
|
d1b55e8115 | ||
|
|
838205d547 | ||
|
|
67af719840 | ||
|
|
c467dc420d | ||
|
|
dfaa48602d | ||
|
|
ce268795cc | ||
|
|
401b73afdf | ||
|
|
a1a9422d4a | ||
|
|
0b61a8ec18 | ||
|
|
269e222e24 | ||
|
|
35905f2b45 | ||
|
|
b30e18dc8a | ||
|
|
8d90395dd7 | ||
|
|
5add20ab89 | ||
|
|
ba4184ec91 | ||
|
|
91a2af9753 | ||
|
|
3208e3f4d9 | ||
|
|
13cdf208ed | ||
|
|
e459fb0e3c | ||
|
|
c4be551734 | ||
|
|
feeb56cd36 | ||
|
|
629e4def0c | ||
|
|
f7c0fe197b | ||
|
|
872b52bc24 | ||
|
|
83ea2423f5 | ||
|
|
5ece73eaa1 | ||
|
|
ad597a7877 | ||
|
|
2f5b478e4b | ||
|
|
31b850d2d4 | ||
|
|
d70059ec73 | ||
|
|
b9f1d9a47a | ||
|
|
b5c212b61a | ||
|
|
6750106107 | ||
|
|
4197678606 | ||
|
|
44bb908485 | ||
|
|
04d1e39dd3 | ||
|
|
a887366955 | ||
|
|
b584460cc3 | ||
|
|
8893145a0c | ||
|
|
92d7a23ace | ||
|
|
12cf133f34 | ||
|
|
796a2b0ab0 | ||
|
|
0b6d43c52f | ||
|
|
de5ab9400a | ||
|
|
f8e7258f7f | ||
|
|
b987342bab | ||
|
|
4977e0a7d9 | ||
|
|
9b04dad70a | ||
|
|
4c6622c2dd | ||
|
|
3c248d705d | ||
|
|
99c08fb662 | ||
|
|
ab2a9f5793 | ||
|
|
84a1cb5ad0 | ||
|
|
cdf3f11338 | ||
|
|
98a345a219 | ||
|
|
6721294104 | ||
|
|
ba5c6d94b6 | ||
|
|
5bab9d0862 | ||
|
|
d521ee19f8 | ||
|
|
c9aded4b88 | ||
|
|
8f0d265e9d | ||
|
|
f49097730e | ||
|
|
110ef36a1a | ||
|
|
746ee38c7c | ||
|
|
eb45ef3ba6 | ||
|
|
db34f79889 | ||
|
|
7fe11bb55c | ||
|
|
7254f6a840 | ||
|
|
72e727f2ec | ||
|
|
90462b8dd9 | ||
|
|
71b00ed874 | ||
|
|
1c72905811 | ||
|
|
4f646c3794 | ||
|
|
184e317956 | ||
|
|
41253c3a9d | ||
|
|
197b82ba54 | ||
|
|
16dc0d9025 | ||
|
|
0c90a1f5e9 | ||
|
|
fa81950916 | ||
|
|
f7dae1ea51 | ||
|
|
3535c0714e | ||
|
|
cf48f6755c | ||
|
|
50cca36825 | ||
|
|
3583d96b77 | ||
|
|
00f5d57533 | ||
|
|
76bf510242 | ||
|
|
bc0f573730 | ||
|
|
697c912fa4 | ||
|
|
4920ae8b66 | ||
|
|
1d5b3c08fe | ||
|
|
62c99cf4ea | ||
|
|
1c93f35bfa | ||
|
|
86cfae0a48 | ||
|
|
ba061fa6f2 | ||
|
|
b19ebeb335 | ||
|
|
001a16a9cd | ||
|
|
0ce615753e | ||
|
|
dc450175c0 | ||
|
|
b3a2272a73 | ||
|
|
92822affc5 | ||
|
|
e021191bcf | ||
|
|
78f654185a | ||
|
|
f7e241f4af | ||
|
|
1f9d82480e | ||
|
|
31d3e51094 | ||
|
|
81535bfa35 | ||
|
|
56f772e95e | ||
|
|
11c073b7e5 | ||
|
|
91be6b283e | ||
|
|
cbf25ce74f | ||
|
|
882f02ed83 | ||
|
|
0623bacc05 | ||
|
|
5f5a90dff6 | ||
|
|
b47b6ff7fd | ||
|
|
1d6b689b26 | ||
|
|
4f84717d23 | ||
|
|
b9e4eb5b72 | ||
|
|
6a6e7f0c65 | ||
|
|
e9e61b0002 | ||
|
|
3eead995a4 | ||
|
|
87f28efe7e | ||
|
|
9be2a009c4 | ||
|
|
07a6e87d46 | ||
|
|
33c78bd23e | ||
|
|
49572920dd | ||
|
|
88654b47c9 | ||
|
|
4524c55bcf | ||
|
|
6ceccee88d | ||
|
|
9c6a89660e | ||
|
|
507aa0e2a8 | ||
|
|
51bacae6b5 | ||
|
|
06c3084fb5 | ||
|
|
253192e69a | ||
|
|
0ea583d250 | ||
|
|
402b123d0c | ||
|
|
74553c98a2 | ||
|
|
84eedf86fe | ||
|
|
5860cc8c1c | ||
|
|
2b008529ed | ||
|
|
2cd1af957a | ||
|
|
eeb2942237 | ||
|
|
e5fa6147ef | ||
|
|
6617622c9a | ||
|
|
2ca1136c7c | ||
|
|
6c63b895fb | ||
|
|
417e31d2c3 | ||
|
|
97abf54412 | ||
|
|
e8cd1ad655 | ||
|
|
ce9447fc6a | ||
|
|
d333175f63 | ||
|
|
215b40ac9e | ||
|
|
30c10fafcc | ||
|
|
3bb211139b | ||
|
|
fb7c5b1f23 | ||
|
|
cf6fb2226d | ||
|
|
e3c52a6362 | ||
|
|
2bde91138d | ||
|
|
44494bf684 | ||
|
|
fad814bd0c | ||
|
|
feda5527b3 | ||
|
|
56ddee7f8d | ||
|
|
728e89a09b | ||
|
|
2c1bf9bd68 | ||
|
|
ba206cf40a | ||
|
|
d12f8e4940 | ||
|
|
0991e29b75 | ||
|
|
3d3bc1fe30 | ||
|
|
08c81469c6 | ||
|
|
932b0c960a | ||
|
|
8452c667e6 | ||
|
|
783aa653f4 | ||
|
|
6130b75585 | ||
|
|
95a7b1c934 | ||
|
|
b4f1840114 | ||
|
|
c265fd6beb | ||
|
|
68dbdee86a | ||
|
|
6ab1adbe1e | ||
|
|
0fddb3d59f | ||
|
|
c4ddc0fb0b | ||
|
|
e0c653e7e6 | ||
|
|
4182a0a186 | ||
|
|
01466c3ebe | ||
|
|
a7c09cba09 | ||
|
|
6c88b51e83 | ||
|
|
1e03480793 | ||
|
|
e3dda35c52 | ||
|
|
bd187d7b65 | ||
|
|
6085ab0d78 | ||
|
|
9ce405ce1d | ||
|
|
a8beef7e6a | ||
|
|
d50eea6df5 | ||
|
|
f5f419debe | ||
|
|
d73e55e022 | ||
|
|
68c989dea9 | ||
|
|
90290ce5dd | ||
|
|
23ce6f4cb3 | ||
|
|
c5fc95d688 | ||
|
|
dd704c3561 | ||
|
|
dab244d548 | ||
|
|
4b4da9fb83 | ||
|
|
4ea3f53d26 | ||
|
|
b06df3c2c7 | ||
|
|
cb823b6f0c | ||
|
|
7b6e67533e | ||
|
|
dddec53788 | ||
|
|
7d3e21ba7b | ||
|
|
4fc55348e5 | ||
|
|
070e650956 | ||
|
|
0078681b6b | ||
|
|
ff084799a3 | ||
|
|
b0d79ec65d | ||
|
|
d4977ce3e7 | ||
|
|
87f1149ae2 | ||
|
|
3641590697 | ||
|
|
e2c2f69650 | ||
|
|
2ead32e61c | ||
|
|
2df9ec3774 | ||
|
|
0305d25eb0 | ||
|
|
5277c0a304 | ||
|
|
6a5aa0cdbb | ||
|
|
7cb794dcdd | ||
|
|
cd409e3b50 | ||
|
|
9a1e42148a | ||
|
|
0634493cdd | ||
|
|
fe1b448ada | ||
|
|
5679f31101 | ||
|
|
3204049e31 | ||
|
|
202598d3ab | ||
|
|
fc2476c7cd | ||
|
|
865f1e9f85 | ||
|
|
cb0b136a63 | ||
|
|
2c086d2959 | ||
|
|
1c4af3813e | ||
|
|
e51b0a82be | ||
|
|
788355718f | ||
|
|
c1e6c88ca3 | ||
|
|
4654b0c0a8 | ||
|
|
dd735e4ee6 | ||
|
|
6659366cda | ||
|
|
e9805e5743 | ||
|
|
aea10ef46f | ||
|
|
086fd1137d | ||
|
|
2ea7730c56 | ||
|
|
7ca2266adc | ||
|
|
1a7a65f9d5 | ||
|
|
c944f7f22d | ||
|
|
dada3cd19e | ||
|
|
422c18f48d | ||
|
|
a0ffc1751e | ||
|
|
00a8a0832d | ||
|
|
0927787504 | ||
|
|
64c1b92a4f | ||
|
|
2722aa42bd | ||
|
|
918eb7c5ae | ||
|
|
39be90223b | ||
|
|
a2e3fa7768 | ||
|
|
aba12ad162 | ||
|
|
27cb5b5901 | ||
|
|
fce629c0ef | ||
|
|
ce6719605b | ||
|
|
2873fdf8b1 | ||
|
|
8be046d7b8 | ||
|
|
de62edee66 | ||
|
|
11707b2b48 | ||
|
|
905f069774 | ||
|
|
09ccae9b18 | ||
|
|
1979121c96 | ||
|
|
42f832d680 | ||
|
|
247efe346c | ||
|
|
5d73144067 | ||
|
|
21db118b64 | ||
|
|
6ed15cde29 | ||
|
|
30bb2edccf | ||
|
|
b3a28fd4e9 | ||
|
|
914202bdac | ||
|
|
c17f9a4a62 | ||
|
|
b9855ea55b | ||
|
|
6e0977873a | ||
|
|
4c3cc7da5d | ||
|
|
d69c9694a7 | ||
|
|
5263bea9f7 | ||
|
|
4175f6bba2 | ||
|
|
1de69d6a33 | ||
|
|
36db78a733 | ||
|
|
e5eb92e794 | ||
|
|
763074102b | ||
|
|
f7398526b6 | ||
|
|
d78f0ac9d8 | ||
|
|
c85be41a07 | ||
|
|
db65ca1f12 | ||
|
|
9b0efa5bc2 | ||
|
|
432ac57aaa | ||
|
|
deef2a0a4d | ||
|
|
df72984aa5 | ||
|
|
f10e19fd1a | ||
|
|
5de9c59301 | ||
|
|
757f8f98fc | ||
|
|
d3be4f6d42 | ||
|
|
1f7d007bf6 | ||
|
|
bc0b0477e2 | ||
|
|
57295d14f9 | ||
|
|
e9b0834e18 | ||
|
|
6082531abb | ||
|
|
33c195cc37 | ||
|
|
e1f93869da | ||
|
|
2935744b3a | ||
|
|
bbf9ca3740 | ||
|
|
d9a9b96bb5 | ||
|
|
5136519230 | ||
|
|
9380cfd008 | ||
|
|
8901f32e4a | ||
|
|
8cdabf02ea | ||
|
|
5a893c2b26 | ||
|
|
58697c6d89 | ||
|
|
9fe5a4571e | ||
|
|
56c5eca973 | ||
|
|
9b9e0a7d46 | ||
|
|
74eae918c3 | ||
|
|
a3d4c6fbb1 | ||
|
|
2d32fc9fe2 | ||
|
|
f6038cb8c3 | ||
|
|
ccde1f98b0 | ||
|
|
58bd33b7fc | ||
|
|
639867b52f | ||
|
|
3c26260608 | ||
|
|
a2b93d5278 | ||
|
|
3a2803df74 | ||
|
|
a0d4650a09 | ||
|
|
cac9e09bbf | ||
|
|
4af4348a3f | ||
|
|
ef05c4d6f9 | ||
|
|
9718cfa902 | ||
|
|
a6df593dfe | ||
|
|
006a030300 | ||
|
|
faef34664a | ||
|
|
2141adedf4 | ||
|
|
e426d17bc5 | ||
|
|
a9ce3f5413 | ||
|
|
59c544c268 | ||
|
|
96b15448b9 | ||
|
|
f063317430 | ||
|
|
417b80040b | ||
|
|
1a5246c66f | ||
|
|
f8a95c9c12 | ||
|
|
d7f4d82382 | ||
|
|
8b9c89fb65 | ||
|
|
83243c24ba | ||
|
|
429b4848d4 | ||
|
|
414c76a461 | ||
|
|
8a5783fd0c | ||
|
|
0cc5bead40 | ||
|
|
5b421a4e8e | ||
|
|
d11ee647c3 | ||
|
|
e1b74b92a0 | ||
|
|
7e5f9c54c0 | ||
|
|
7109a18d18 | ||
|
|
922730fe36 | ||
|
|
7484f1d4f3 | ||
|
|
15129f2525 | ||
|
|
0e0ed236ab | ||
|
|
7dedf26e55 | ||
|
|
c4585f1e2d | ||
|
|
56017c172b | ||
|
|
5ab8c47bcf | ||
|
|
1fa5d8bbf9 | ||
|
|
91ba8a55b1 |
+2892
-445
File diff suppressed because it is too large
Load Diff
+44
-22
@@ -1,7 +1,7 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
## Process this file with automake to produce Makefile.in.
|
||||||
|
|
||||||
## Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2012 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,29 +15,51 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
SUBDIRS = build-aux po runtime-po lib data src doc examples tests etc
|
SUBDIRS = po runtime-po .
|
||||||
|
|
||||||
# Files installed for use by Automake.
|
# Files installed for use by Automake.
|
||||||
aclocaldir = @aclocaldir@
|
aclocaldir = @aclocaldir@
|
||||||
aclocal_DATA = m4/bison-i18n.m4
|
aclocal_DATA = m4/bison-i18n.m4
|
||||||
|
|
||||||
EXTRA_DIST = .prev-version .version \
|
EXTRA_DIST = .prev-version .version \
|
||||||
cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING \
|
cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING
|
||||||
djgpp/Makefile.maint djgpp/README.in djgpp/config.bat \
|
|
||||||
djgpp/config.sed djgpp/config.site djgpp/config_h.sed \
|
|
||||||
djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \
|
|
||||||
djgpp/fnchange.lst djgpp/testsuite.sed
|
|
||||||
|
|
||||||
MAINTAINER_CHECKS = \
|
## Running the bison from this tarball. To generate our own parser,
|
||||||
maintainer-check \
|
## but also to run the tests. Of course, you ought to keep a sane
|
||||||
maintainer-push-check \
|
## version of Bison nearby...
|
||||||
maintainer-xml-check \
|
BISON = $(top_builddir)/tests/bison
|
||||||
maintainer-release-check
|
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||||
.PHONY: $(MAINTAINER_CHECKS)
|
YACC = $(BISON) -y
|
||||||
$(MAINTAINER_CHECKS):
|
AM_YFLAGS = -d -v --warnings=all,error --report=all
|
||||||
$(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
|
|
||||||
|
# Initialization before completion by local.mk's.
|
||||||
|
AM_CFLAGS = $(WARN_CFLAGS)
|
||||||
|
# Find builddir/src/scan-code.c etc.
|
||||||
|
AM_CPPFLAGS = -I. -Ilib -I$(top_srcdir) -I$(top_srcdir)/lib
|
||||||
|
BUILT_SOURCES =
|
||||||
|
CLEANFILES =
|
||||||
|
DISTCLEANFILES =
|
||||||
|
EXTRA_DIST += $(dist_TESTS)
|
||||||
|
MOSTLYCLEANDIRS =
|
||||||
|
MOSTLYCLEANFILES =
|
||||||
|
SUFFIXES =
|
||||||
|
TESTS = $(dist_TESTS)
|
||||||
|
check_PROGRAMS =
|
||||||
|
dist_TESTS =
|
||||||
|
noinst_LIBRARIES =
|
||||||
|
|
||||||
|
include build-aux/local.mk
|
||||||
|
include data/local.mk
|
||||||
|
include djgpp/local.mk
|
||||||
|
include doc/local.mk
|
||||||
|
include etc/local.mk
|
||||||
|
include examples/local.mk
|
||||||
|
include lib/local.mk
|
||||||
|
include src/local.mk
|
||||||
|
include tests/local.mk
|
||||||
|
|
||||||
# See comments in build-aux/git-version-gen. However, we make .version depend
|
# See comments in build-aux/git-version-gen. However, we make .version depend
|
||||||
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
|
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
|
||||||
@@ -48,20 +70,20 @@ $(MAINTAINER_CHECKS):
|
|||||||
# a developer might naively reference .version in a test case while the bison
|
# a developer might naively reference .version in a test case while the bison
|
||||||
# executable still compiles with VERSION, and so the test case might fail or
|
# executable still compiles with VERSION, and so the test case might fail or
|
||||||
# pass incorrectly.
|
# pass incorrectly.
|
||||||
BUILT_SOURCES = $(top_srcdir)/.version
|
BUILT_SOURCES += $(top_srcdir)/.version
|
||||||
$(top_srcdir)/.version: configure
|
$(top_srcdir)/.version: configure
|
||||||
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
|
echo $(VERSION) > $@-t && mv $@-t $@
|
||||||
dist-hook: gen-ChangeLog
|
dist-hook: gen-ChangeLog
|
||||||
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
|
echo $(VERSION) > $(distdir)/.tarball-version
|
||||||
|
|
||||||
.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 data -type f \
|
find data -type f \
|
||||||
| grep -v -E '^data/bison.m4$$' \
|
| grep -v -E '^data/bison.m4$$' \
|
||||||
| xargs $(build_aux)/$@
|
| xargs $(build_aux)/$@
|
||||||
@echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
|
@echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
|
||||||
update-package-copyright-year:
|
update-package-copyright-year:
|
||||||
$(AM_V_GEN)$(build_aux)/$@ configure.ac
|
$(build_aux)/$@ configure.ac
|
||||||
|
|
||||||
gen_start_date = 2012-01-16
|
gen_start_date = 2012-01-16
|
||||||
.PHONY: gen-ChangeLog
|
.PHONY: gen-ChangeLog
|
||||||
|
|||||||
@@ -2,10 +2,129 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||||
|
|
||||||
|
** Warnings
|
||||||
|
|
||||||
|
*** Warning categories are now displayed in warnings
|
||||||
|
|
||||||
|
For instance:
|
||||||
|
|
||||||
|
foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
|
||||||
|
|
||||||
|
*** Useless semantic types
|
||||||
|
|
||||||
|
Bison now warns about useless (uninhabited) semantic types. Since
|
||||||
|
semantic types are not declared to Bison (they are defined in the opaque
|
||||||
|
%union structure), it is %printer/%destructor directives about useless
|
||||||
|
types that trigger the warning:
|
||||||
|
|
||||||
|
%token <type1> term
|
||||||
|
%type <type2> nterm
|
||||||
|
%printer {} <type1> <type3>
|
||||||
|
%destructor {} <type2> <type4>
|
||||||
|
%%
|
||||||
|
nterm: term { $$ = $1; };
|
||||||
|
|
||||||
|
3.28-34: warning: type <type3> is used, but is not associated to any symbol
|
||||||
|
4.28-34: warning: type <type4> is used, but is not associated to any symbol
|
||||||
|
|
||||||
|
*** Undeclared symbols
|
||||||
|
|
||||||
|
Bison used to raise an error for %printer and %destructor directives for
|
||||||
|
undefined symbols.
|
||||||
|
|
||||||
|
%printer {} symbol1
|
||||||
|
%destructor {} symbol2
|
||||||
|
%%
|
||||||
|
exp: "a";
|
||||||
|
|
||||||
|
This is now only a warning.
|
||||||
|
|
||||||
|
*** Useless destructors or printers
|
||||||
|
|
||||||
|
Bison now warns about useless destructors or printers. In the following
|
||||||
|
example, the printer for <type1>, and the destructor for <type2> are
|
||||||
|
useless: all symbols of <type1> (token1) already have a printer, and all
|
||||||
|
symbols of type <type2> (token2) already have a destructor.
|
||||||
|
|
||||||
|
%token <type1> token1
|
||||||
|
<type2> token2
|
||||||
|
<type3> token3
|
||||||
|
<type4> token4
|
||||||
|
%printer {} token1 <type1> <type3>
|
||||||
|
%destructor {} token2 <type2> <type4>
|
||||||
|
|
||||||
|
** Additional yylex/yyparse arguments
|
||||||
|
|
||||||
|
The new directive %param declares additional arguments to both yylex and
|
||||||
|
yyparse. The %lex-param, %parse-param, and %param directives support one
|
||||||
|
or more arguments. Instead of
|
||||||
|
|
||||||
|
%lex-param {arg1_type *arg1}
|
||||||
|
%lex-param {arg2_type *arg2}
|
||||||
|
%parse-param {arg1_type *arg1}
|
||||||
|
%parse-param {arg2_type *arg2}
|
||||||
|
|
||||||
|
one may now declare
|
||||||
|
|
||||||
|
%param {arg1_type *arg1} {arg2_type *arg2}
|
||||||
|
|
||||||
|
** Java skeleton improvements
|
||||||
|
|
||||||
|
The constants for token names were moved to the Lexer interface.
|
||||||
|
Also, it is possible to add code to the parser's constructors using
|
||||||
|
"%code init" and "%define init_throws".
|
||||||
|
|
||||||
|
** C++ skeleton improvements
|
||||||
|
|
||||||
|
The C++ parser features a syntax_error exception, which can be
|
||||||
|
thrown from the scanner or from user rules to raise syntax errors.
|
||||||
|
This facilitates reporting errors caught in sub-functions (e.g.,
|
||||||
|
rejecting too large integral literals from a conversion function
|
||||||
|
used by the scanner, or rejecting invalid combinations from a
|
||||||
|
factory invoked by the user actions).
|
||||||
|
|
||||||
|
** Variable api.tokens.prefix
|
||||||
|
|
||||||
|
The variable api.tokens.prefix changes the way tokens are identified in
|
||||||
|
the generated files. This is especially useful to avoid collisions
|
||||||
|
with identifiers in the target language. For instance
|
||||||
|
|
||||||
|
%token FILE for ERROR
|
||||||
|
%define api.tokens.prefix "TOK_"
|
||||||
|
%%
|
||||||
|
start: FILE for ERROR;
|
||||||
|
|
||||||
|
will generate the definition of the symbols TOK_FILE, TOK_for, and
|
||||||
|
TOK_ERROR in the generated sources. In particular, the scanner must
|
||||||
|
use these prefixed token names, although the grammar itself still
|
||||||
|
uses the short names (as in the sample rule given above).
|
||||||
|
|
||||||
|
** Variable api.namespace
|
||||||
|
|
||||||
|
The "namespace" variable is renamed "api.namespace". Backward
|
||||||
|
compatibility is ensured, but upgrading is recommended.
|
||||||
|
|
||||||
|
** Variable parse.error
|
||||||
|
|
||||||
|
The variable error controls the verbosity of error messages. The
|
||||||
|
use of the %error-verbose directive is deprecated in favor of
|
||||||
|
%define parse.error "verbose".
|
||||||
|
|
||||||
|
** Semantic predicates
|
||||||
|
|
||||||
|
The new, experimental, semantic-predicate feature allows actions of
|
||||||
|
the form %?{ BOOLEAN-EXPRESSION }, which cause syntax errors (as for
|
||||||
|
YYERROR) if the expression evaluates to 0, and are evaluated immediately
|
||||||
|
in GLR parsers, rather than being deferred. The result is that they
|
||||||
|
allow the programmer to prune possible parses based on the values of
|
||||||
|
run-time expressions.
|
||||||
|
|
||||||
|
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||||
|
|
||||||
|
|
||||||
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
|
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
|
||||||
|
|
||||||
** Future Changes
|
** Future changes:
|
||||||
|
|
||||||
The next major release of Bison will drop support for the following
|
The next major release of Bison will drop support for the following
|
||||||
deprecated features. Please report disagreements to [email protected].
|
deprecated features. Please report disagreements to [email protected].
|
||||||
@@ -1806,7 +1925,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
||||||
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
||||||
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
||||||
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp
|
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
|
||||||
|
LocalWords: TOK
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ of the .output file etc. This excludes impossible error messages
|
|||||||
(comparable to assert/abort), and all the --trace output which is
|
(comparable to assert/abort), and all the --trace output which is
|
||||||
meant for the maintainers only.
|
meant for the maintainers only.
|
||||||
|
|
||||||
|
** Horizontal tabs
|
||||||
|
Do not add horizontal tab characters to any file in Bison's repository
|
||||||
|
except where required. For example, do not use tabs to format C code.
|
||||||
|
However, make files, ChangeLog, and some regular expressions require
|
||||||
|
tabs. Also, test cases might need to contain tabs to check that Bison
|
||||||
|
properly processes tabs in its input.
|
||||||
|
|
||||||
|
|
||||||
* Working from the repository
|
* Working from the repository
|
||||||
|
|
||||||
@@ -226,6 +233,9 @@ release:
|
|||||||
that it does not make sense for glr.c, which should be ANSI, but
|
that it does not make sense for glr.c, which should be ANSI, but
|
||||||
currently is actually GNU C, nor for lalr1.cc.
|
currently is actually GNU C, nor for lalr1.cc.
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
|
||||||
|
|
||||||
* Release Procedure
|
* Release Procedure
|
||||||
This section needs to be updated to take into account features from
|
This section needs to be updated to take into account features from
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ Matt Kraai [email protected]
|
|||||||
Matt Rosing [email protected]
|
Matt Rosing [email protected]
|
||||||
Michael Hayes [email protected]
|
Michael Hayes [email protected]
|
||||||
Michael Raskin [email protected]
|
Michael Raskin [email protected]
|
||||||
|
Michiel De Wilde [email protected]
|
||||||
Mickael Labau [email protected]
|
Mickael Labau [email protected]
|
||||||
Mike Castle [email protected]
|
Mike Castle [email protected]
|
||||||
Neil Booth [email protected]
|
Neil Booth [email protected]
|
||||||
@@ -87,6 +88,7 @@ Per Allansson [email protected]
|
|||||||
Peter Fales [email protected]
|
Peter Fales [email protected]
|
||||||
Peter Hamorsky [email protected]
|
Peter Hamorsky [email protected]
|
||||||
Piotr Gackiewicz [email protected]
|
Piotr Gackiewicz [email protected]
|
||||||
|
Quentin Hocquet [email protected]
|
||||||
Quoc Peyrot [email protected]
|
Quoc Peyrot [email protected]
|
||||||
R Blake [email protected]
|
R Blake [email protected]
|
||||||
Raja R Harinath [email protected]
|
Raja R Harinath [email protected]
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
** Variable names.
|
** Variable names.
|
||||||
What should we name `variant' and `lex_symbol'?
|
What should we name `variant' and `lex_symbol'?
|
||||||
|
|
||||||
** Use b4_symbol in all the skeleton
|
|
||||||
Move its definition in the more standard places and deploy it in other
|
|
||||||
skeletons. Then remove the older system, including the tables
|
|
||||||
generated by output.c
|
|
||||||
|
|
||||||
** Update the documentation on gnu.org
|
** Update the documentation on gnu.org
|
||||||
|
|
||||||
** Get rid of fake #lines [Bison: ...]
|
** Get rid of fake #lines [Bison: ...]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2012-07-10.09; # UTC
|
scriptversion=2012-07-19.14; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
@@ -214,6 +214,8 @@ use_git=true
|
|||||||
# otherwise find the first of the NAMES that can be run (i.e.,
|
# otherwise find the first of the NAMES that can be run (i.e.,
|
||||||
# supports --version). If found, set ENVVAR to the program name,
|
# supports --version). If found, set ENVVAR to the program name,
|
||||||
# die otherwise.
|
# die otherwise.
|
||||||
|
#
|
||||||
|
# FIXME: code duplication, see also gnu-web-doc-update.
|
||||||
find_tool ()
|
find_tool ()
|
||||||
{
|
{
|
||||||
find_tool_envvar=$1
|
find_tool_envvar=$1
|
||||||
|
|||||||
+12
-5
@@ -23,7 +23,7 @@ gnulib_modules='
|
|||||||
error extensions fdl fopen-safer getopt-gnu
|
error extensions fdl fopen-safer getopt-gnu
|
||||||
gettext git-version-gen gitlog-to-changelog
|
gettext git-version-gen gitlog-to-changelog
|
||||||
gpl-3.0 hash inttypes isnan javacomp-script
|
gpl-3.0 hash inttypes isnan javacomp-script
|
||||||
javaexec-script ldexpl malloc-gnu mbschr mbsrchr
|
javaexec-script ldexpl malloc-gnu
|
||||||
mbswidth obstack perror progname
|
mbswidth obstack perror progname
|
||||||
quote quotearg
|
quote quotearg
|
||||||
readme-release
|
readme-release
|
||||||
@@ -31,7 +31,11 @@ gnulib_modules='
|
|||||||
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
|
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
|
||||||
unistd unistd-safer unlocked-io update-copyright unsetenv verify
|
unistd unistd-safer unlocked-io update-copyright unsetenv verify
|
||||||
warnings
|
warnings
|
||||||
xalloc xalloc-die xmemdup0 xstrndup
|
xalloc
|
||||||
|
xalloc-die
|
||||||
|
xconcat-filename
|
||||||
|
xmemdup0
|
||||||
|
xstrndup
|
||||||
|
|
||||||
fprintf-posix printf-posix snprintf-posix sprintf-posix
|
fprintf-posix printf-posix snprintf-posix sprintf-posix
|
||||||
vsnprintf-posix vsprintf-posix
|
vsnprintf-posix vsprintf-posix
|
||||||
@@ -41,9 +45,9 @@ gnulib_modules='
|
|||||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||||
--from-code=UTF-8\\\
|
--from-code=UTF-8\\\
|
||||||
--flag=asprintf:2:c-format\\\
|
--flag=asprintf:2:c-format\\\
|
||||||
--flag=complain:1:c-format --flag=complain_at:2:c-format\\\
|
--flag=complain:2:c-format\\\
|
||||||
--flag=fatal:1:c-format --flag=fatal_at:2:c-format\\\
|
--flag=complain_at:3:c-format\\\
|
||||||
--flag=warn:1:c-format --flag=warn_at:2:c-format\\\
|
--flag=complain_at_indent:4:c-format\\\
|
||||||
--flag=unexpected_end:2:c-format\\\
|
--flag=unexpected_end:2:c-format\\\
|
||||||
'
|
'
|
||||||
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
||||||
@@ -71,6 +75,9 @@ gnulib_tool_option_extras='--symlink --makefile-name=gnulib.mk'
|
|||||||
|
|
||||||
bootstrap_post_import_hook()
|
bootstrap_post_import_hook()
|
||||||
{
|
{
|
||||||
|
# Massage lib/gnulib.mk before using it later in the bootstrapping process.
|
||||||
|
etc/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
|
||||||
|
|
||||||
# Ensure that ChangeLog exists, for automake.
|
# Ensure that ChangeLog exists, for automake.
|
||||||
test -f ChangeLog || touch ChangeLog
|
test -f ChangeLog || touch ChangeLog
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
/announce-gen
|
/announce-gen
|
||||||
/arg-nonnull.h
|
/arg-nonnull.h
|
||||||
/c++defs.h
|
/c++defs.h
|
||||||
/compile
|
/compile
|
||||||
/config.guess
|
/config.guess
|
||||||
/config.rpath
|
/config.rpath
|
||||||
|
/config.rpath~
|
||||||
/config.sub
|
/config.sub
|
||||||
/depcomp
|
/depcomp
|
||||||
/do-release-commit-and-tag
|
/do-release-commit-and-tag
|
||||||
@@ -20,6 +19,7 @@
|
|||||||
/link-warning.h
|
/link-warning.h
|
||||||
/mdate-sh
|
/mdate-sh
|
||||||
/missing
|
/missing
|
||||||
|
/test-driver
|
||||||
/texinfo.tex
|
/texinfo.tex
|
||||||
/update-copyright
|
/update-copyright
|
||||||
/useless-if-before-free
|
/useless-if-before-free
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
## Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
|
## Makefile for Bison testsuite.
|
||||||
|
|
||||||
|
# Copyright (C) 2000-2012 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
|
||||||
@@ -13,8 +15,9 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST += \
|
||||||
cross-options.pl \
|
build-aux/cross-options.pl \
|
||||||
darwin11.4.0.valgrind \
|
build-aux/darwin11.4.0.valgrind \
|
||||||
prev-version.txt \
|
build-aux/move-if-change \
|
||||||
update-b4-copyright
|
build-aux/prev-version.txt \
|
||||||
|
build-aux/update-b4-copyright
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../gnulib/build-aux/move-if-change
|
||||||
@@ -36,15 +36,9 @@ url_dir_list = \
|
|||||||
ftp://$(gnu_rel_host)/gnu/bison
|
ftp://$(gnu_rel_host)/gnu/bison
|
||||||
|
|
||||||
# Tests not to run as part of "make distcheck".
|
# Tests not to run as part of "make distcheck".
|
||||||
# Exclude changelog-check here so that there's less churn in ChangeLog
|
|
||||||
# files -- otherwise, you'd need to have the upcoming version number
|
|
||||||
# at the top of the file for each `make distcheck' run.
|
|
||||||
local-checks-to-skip = \
|
local-checks-to-skip = \
|
||||||
changelog-check \
|
|
||||||
sc_immutable_NEWS \
|
sc_immutable_NEWS \
|
||||||
sc_prohibit_always_true_header_tests \
|
sc_prohibit_atoi_atof
|
||||||
sc_prohibit_atoi_atof \
|
|
||||||
sc_prohibit_strcmp
|
|
||||||
|
|
||||||
# The local directory containing the checked-out copy of gnulib used in
|
# The local directory containing the checked-out copy of gnulib used in
|
||||||
# this release. Used solely to get a date for the "announcement" target.
|
# this release. Used solely to get a date for the "announcement" target.
|
||||||
@@ -70,9 +64,9 @@ $(call exclude, \
|
|||||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||||
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||||
prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \
|
prohibit_empty_lines_at_EOF=^src/parse-gram.h$$ \
|
||||||
|
prohibit_strcmp=^doc/bison\.texi$$ \
|
||||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
||||||
space_tab=^tests/(input|c\+\+)\.at$$ \
|
space_tab=^tests/(input|c\+\+)\.at$$ \
|
||||||
trailing_blank=^src/parse-gram.[ch]$$ \
|
|
||||||
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$) \
|
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$) \
|
||||||
)
|
)
|
||||||
|
|||||||
+25
-12
@@ -45,7 +45,9 @@ AC_CONFIG_MACRO_DIR([m4])
|
|||||||
# releases, we want to be able run make dist without being required to
|
# releases, we want to be able run make dist without being required to
|
||||||
# add a bogus NEWS entry. In that case, the version string
|
# add a bogus NEWS entry. In that case, the version string
|
||||||
# automatically contains a dash, which we also let disable gnits.
|
# automatically contains a dash, which we also let disable gnits.
|
||||||
AM_INIT_AUTOMAKE([1.11.1 dist-xz silent-rules]
|
AM_INIT_AUTOMAKE([1.11.1 dist-xz nostdinc
|
||||||
|
color-tests parallel-tests
|
||||||
|
silent-rules]
|
||||||
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
||||||
[gnu], [gnits]))
|
[gnu], [gnits]))
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
@@ -71,6 +73,7 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
|
warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
|
||||||
-Wshadow -Wstrict-prototypes'
|
-Wshadow -Wstrict-prototypes'
|
||||||
warn_cxx='-Wnoexcept'
|
warn_cxx='-Wnoexcept'
|
||||||
|
|
||||||
AC_LANG_PUSH([C])
|
AC_LANG_PUSH([C])
|
||||||
for i in $warn_common $warn_c;
|
for i in $warn_common $warn_c;
|
||||||
do
|
do
|
||||||
@@ -105,8 +108,8 @@ AC_ARG_ENABLE([yacc],
|
|||||||
, [enable_yacc=yes])
|
, [enable_yacc=yes])
|
||||||
case $enable_yacc in
|
case $enable_yacc in
|
||||||
yes)
|
yes)
|
||||||
YACC_SCRIPT=yacc
|
YACC_SCRIPT=src/yacc
|
||||||
YACC_LIBRARY=liby.a;;
|
YACC_LIBRARY=lib/liby.a;;
|
||||||
*)
|
*)
|
||||||
YACC_SCRIPT=
|
YACC_SCRIPT=
|
||||||
YACC_LIBRARY=;;
|
YACC_LIBRARY=;;
|
||||||
@@ -123,6 +126,10 @@ AC_PROG_GNU_M4
|
|||||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
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])
|
||||||
|
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])
|
||||||
@@ -160,7 +167,7 @@ AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
|
|||||||
|
|
||||||
# Initialize the test suite.
|
# Initialize the test suite.
|
||||||
AC_CONFIG_TESTDIR(tests)
|
AC_CONFIG_TESTDIR(tests)
|
||||||
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
AC_CONFIG_FILES([tests/atlocal])
|
||||||
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
||||||
AC_CHECK_PROGS([VALGRIND], [valgrind])
|
AC_CHECK_PROGS([VALGRIND], [valgrind])
|
||||||
case $VALGRIND:$host_os in
|
case $VALGRIND:$host_os in
|
||||||
@@ -177,17 +184,23 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
|||||||
# Needed by tests/atlocal.in.
|
# Needed by tests/atlocal.in.
|
||||||
AC_SUBST([GCC])
|
AC_SUBST([GCC])
|
||||||
|
|
||||||
gt_JAVACOMP([1.3])
|
gt_JAVACOMP([1.3], [1.4])
|
||||||
gt_JAVAEXEC
|
gt_JAVAEXEC
|
||||||
|
|
||||||
|
# We use gnulib, but from lib/local.mk instead of lib/Makefile.am.
|
||||||
|
# So prefix paths with lib/. See also etc/prefix-gnulib-mk.
|
||||||
|
gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, , lib/,g'`
|
||||||
|
# Listing the names of the variables to prefix is error-prone.
|
||||||
|
# Rather, adjust all the AC_SUBST variables whose name ends in '_H',
|
||||||
|
# and whose content ends in '.h'.
|
||||||
|
for ac_var in $ac_subst_vars
|
||||||
|
do
|
||||||
|
eval "ac_val=\$$ac_var"
|
||||||
|
case $ac_var=$ac_val in
|
||||||
|
(*_H=*.h) eval "$ac_var=lib/\$$ac_var";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
build-aux/Makefile
|
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
data/Makefile
|
|
||||||
etc/Makefile
|
|
||||||
examples/Makefile
|
|
||||||
examples/calc++/Makefile
|
|
||||||
lib/Makefile src/Makefile
|
|
||||||
doc/Makefile
|
|
||||||
doc/yacc.1])
|
doc/yacc.1])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
Makefile.in
|
|
||||||
Makefile
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/Makefile.in
|
|
||||||
/Makefile
|
|
||||||
+304
-12
@@ -22,14 +22,17 @@
|
|||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# b4_copyright(TITLE, YEARS)
|
# b4_copyright(TITLE, [YEARS])
|
||||||
# --------------------------
|
# ----------------------------
|
||||||
|
# If YEARS are not defined, use b4_copyright_years.
|
||||||
m4_define([b4_copyright],
|
m4_define([b4_copyright],
|
||||||
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
||||||
|
|
||||||
b4_comment([$1
|
b4_comment([$1
|
||||||
|
|
||||||
m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
|
]m4_dquote(m4_text_wrap([Copyright (C)
|
||||||
|
]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[
|
||||||
|
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
|
||||||
@@ -194,6 +197,87 @@ m4_define([b4_ints_in],
|
|||||||
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_subtract(LHS, RHS)
|
||||||
|
# ---------------------
|
||||||
|
# Evaluate LHS - RHS if they are integer literals, otherwise expand
|
||||||
|
# to (LHS) - (RHS).
|
||||||
|
m4_define([b4_subtract],
|
||||||
|
[m4_bmatch([$1$2], [^[0123456789]*$],
|
||||||
|
[m4_eval([$1 - $2])],
|
||||||
|
[($1) - ($2)])])
|
||||||
|
|
||||||
|
# b4_args(ARG1, ...)
|
||||||
|
# _b4_args(ARG1, ...)
|
||||||
|
# -------------------
|
||||||
|
# Join with comma, skipping empty arguments.
|
||||||
|
# b4_args calls itself recursively until it sees the first non-empty
|
||||||
|
# argument, then calls _b4_args which prepends each non-empty argument
|
||||||
|
# with a comma.
|
||||||
|
m4_define([b4_args],
|
||||||
|
[m4_if([$#$1],
|
||||||
|
[1], [],
|
||||||
|
[m4_ifval([$1],
|
||||||
|
[$1[]_$0(m4_shift($@))],
|
||||||
|
[$0(m4_shift($@))])])])
|
||||||
|
|
||||||
|
# _b4_args(ARGS1, ...)
|
||||||
|
# --------------------
|
||||||
|
m4_define([_b4_args],
|
||||||
|
[m4_if([$#$1],
|
||||||
|
[1], [],
|
||||||
|
[m4_ifval([$1], [, $1])[]$0(m4_shift($@))])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_integral_parser_tables_map(MACRO)
|
||||||
|
# -------------------------------------
|
||||||
|
# Map MACRO on all the integral tables. MACRO is expected to have
|
||||||
|
# the signature MACRO(TABLE-NAME, CONTENT, COMMENT).
|
||||||
|
m4_define([b4_integral_parser_tables_map],
|
||||||
|
[$1([pact], [b4_pact],
|
||||||
|
[[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||||
|
STATE-NUM.]])
|
||||||
|
|
||||||
|
$1([defact], [b4_defact],
|
||||||
|
[[YYDEFACT[S] -- default reduction number in state S. Performed when
|
||||||
|
YYTABLE does not specify something else to do. Zero means the default
|
||||||
|
is an error.]])
|
||||||
|
|
||||||
|
$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]])
|
||||||
|
|
||||||
|
$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]])
|
||||||
|
|
||||||
|
$1([table], [b4_table],
|
||||||
|
[[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.]])
|
||||||
|
|
||||||
|
$1([check], [b4_check])
|
||||||
|
|
||||||
|
$1([stos], [b4_stos],
|
||||||
|
[[STOS_[STATE-NUM] -- The (internal number of the) accessing
|
||||||
|
symbol of state STATE-NUM.]])
|
||||||
|
|
||||||
|
$1([r1], [b4_r1],
|
||||||
|
[[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]])
|
||||||
|
|
||||||
|
$1([r2], [b4_r2],
|
||||||
|
[[YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.]])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_parser_tables_declare
|
||||||
|
# b4_parser_tables_define
|
||||||
|
# ------------------------
|
||||||
|
# Define/declare the (deterministic) parser tables.
|
||||||
|
m4_define([b4_parser_tables_declare],
|
||||||
|
[b4_integral_parser_tables_map([b4_integral_parser_table_declare])])
|
||||||
|
|
||||||
|
m4_define([b4_parser_tables_define],
|
||||||
|
[b4_integral_parser_tables_map([b4_integral_parser_table_define])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
## ------------------ ##
|
||||||
## Decoding options. ##
|
## Decoding options. ##
|
||||||
@@ -232,15 +316,166 @@ m4_define([b4_$3_if],
|
|||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||||
b4_define_flag_if([error_verbose]) # Whether error are verbose.
|
|
||||||
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||||
b4_define_flag_if([locations]) # Whether locations are tracked.
|
|
||||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||||
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
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.
|
||||||
|
|
||||||
# yytoken_table is needed to support verbose errors.
|
|
||||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
## --------- ##
|
||||||
|
## Symbols. ##
|
||||||
|
## --------- ##
|
||||||
|
|
||||||
|
# In order to unify the handling of the various aspects of symbols
|
||||||
|
# (tag, type_name, whether terminal, etc.), bison.exe defines one
|
||||||
|
# macro per (token, field), where field can has_id, id, etc.: see
|
||||||
|
# src/output.c:prepare_symbols_definitions().
|
||||||
|
#
|
||||||
|
# The following macros provide access to these values.
|
||||||
|
|
||||||
|
# b4_symbol_(NUM, FIELD)
|
||||||
|
# ----------------------
|
||||||
|
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||||
|
# undefined.
|
||||||
|
m4_define([b4_symbol_],
|
||||||
|
[m4_indir([b4_symbol($1, $2)])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol(NUM, FIELD)
|
||||||
|
# ---------------------
|
||||||
|
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||||
|
# undefined. If FIELD = id, prepend the prefix.
|
||||||
|
m4_define([b4_symbol],
|
||||||
|
[m4_case([$2],
|
||||||
|
[id], [m4_do([b4_percent_define_get([api.tokens.prefix])],
|
||||||
|
[b4_symbol_([$1], [id])])],
|
||||||
|
[b4_symbol_($@)])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
||||||
|
# -------------------------------------------
|
||||||
|
# If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE.
|
||||||
|
# Otherwise an error.
|
||||||
|
m4_define([b4_symbol_if],
|
||||||
|
[m4_case(b4_symbol([$1], [$2]),
|
||||||
|
[1], [$3],
|
||||||
|
[0], [$4],
|
||||||
|
[m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_action_location(SYMBOL-NUM, KIND)
|
||||||
|
# -------------------------------------------
|
||||||
|
# Report the location of the KIND action as FILE:LINE.
|
||||||
|
m4_define([b4_symbol_action_location],
|
||||||
|
[b4_symbol([$1], [$2_file]):b4_syncline([b4_symbol([$1], [$2_line])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||||
|
# ----------------------------------
|
||||||
|
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
||||||
|
# Same as in C, but using references instead of pointers.
|
||||||
|
m4_define([b4_symbol_action],
|
||||||
|
[b4_symbol_if([$1], [has_$2],
|
||||||
|
[m4_pushdef([b4_dollar_dollar],
|
||||||
|
[b4_symbol_value([(*yyvaluep)],
|
||||||
|
b4_symbol_if([$1], [has_type],
|
||||||
|
[b4_symbol([$1], [type])]))])dnl
|
||||||
|
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
||||||
|
b4_symbol_case_([$1])
|
||||||
|
b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
|
||||||
|
b4_symbol([$1], [$2])
|
||||||
|
b4_syncline([@oline@], [@ofile@])
|
||||||
|
break;
|
||||||
|
|
||||||
|
m4_popdef([b4_at_dollar])dnl
|
||||||
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
|
])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_destructor(SYMBOL-NUM)
|
||||||
|
# b4_symbol_printer(SYMBOL-NUM)
|
||||||
|
# --------------------------------
|
||||||
|
m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
|
||||||
|
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_case_(SYMBOL-NUM)
|
||||||
|
# ---------------------------
|
||||||
|
# Issue a "case NUM" for SYMBOL-NUM.
|
||||||
|
m4_define([b4_symbol_case_],
|
||||||
|
[ case b4_symbol([$1], [number]): // b4_symbol([$1], [tag])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_foreach(MACRO)
|
||||||
|
# ------------------------
|
||||||
|
# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM.
|
||||||
|
m4_define([b4_symbol_foreach],
|
||||||
|
[m4_map([$1], m4_defn([b4_symbol_numbers]))])
|
||||||
|
|
||||||
|
# b4_symbol_map(MACRO)
|
||||||
|
# --------------------
|
||||||
|
# Return a list (possibly empty elements) of MACRO invoked for each
|
||||||
|
# SYMBOL-NUM.
|
||||||
|
m4_define([b4_symbol_map],
|
||||||
|
[m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
||||||
|
# -------------------------------------------
|
||||||
|
# Whether NUM denotes a token that has an exported definition (i.e.,
|
||||||
|
# shows in enum yytokentype).
|
||||||
|
m4_define([b4_token_visible_if],
|
||||||
|
[b4_symbol_if([$1], [is_token],
|
||||||
|
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
||||||
|
[$3])])
|
||||||
|
|
||||||
|
# b4_token_has_definition(NUM)
|
||||||
|
# ----------------------------
|
||||||
|
# 1 if NUM is visible, nothing otherwise.
|
||||||
|
m4_define([b4_token_has_definition],
|
||||||
|
[b4_token_visible_if([$1], [1])])
|
||||||
|
|
||||||
|
# b4_any_token_visible_if([IF-TRUE], [IF-FALSE])
|
||||||
|
# ----------------------------------------------
|
||||||
|
# Whether there is a token that needs to be defined.
|
||||||
|
m4_define([b4_any_token_visible_if],
|
||||||
|
[m4_ifval(b4_symbol_foreach([b4_token_has_definition]),
|
||||||
|
[$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_token_format(FORMAT, NUM)
|
||||||
|
# ----------------------------
|
||||||
|
m4_define([b4_token_format],
|
||||||
|
[b4_token_visible_if([$2],
|
||||||
|
[m4_quote(m4_format([$1],
|
||||||
|
[b4_symbol([$2], [id])],
|
||||||
|
[b4_symbol([$2], [user_number])]))])])
|
||||||
|
|
||||||
|
|
||||||
|
## ------- ##
|
||||||
|
## Types. ##
|
||||||
|
## ------- ##
|
||||||
|
|
||||||
|
# b4_type_action_(NUMS)
|
||||||
|
# ---------------------
|
||||||
|
# Run actions for the symbol NUMS that all have the same type-name.
|
||||||
|
# Skip NUMS that have no type-name.
|
||||||
|
m4_define([b4_type_action_],
|
||||||
|
[b4_symbol_if([$1], [has_type],
|
||||||
|
[m4_map_args([b4_symbol_case_], $@)[]dnl
|
||||||
|
b4_dollar_dollar([b4_symbol([$1], [number])],
|
||||||
|
[b4_symbol([$1], [tag])],
|
||||||
|
[b4_symbol([$1], [type])]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
])])
|
||||||
|
|
||||||
|
# b4_type_foreach(MACRO)
|
||||||
|
# ----------------------
|
||||||
|
# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set.
|
||||||
|
m4_define([b4_type_foreach],
|
||||||
|
[m4_map([$1], m4_defn([b4_type_names]))])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -259,8 +494,8 @@ m4_define([b4_basename],
|
|||||||
# b4_syncline(LINE, FILE)
|
# b4_syncline(LINE, FILE)
|
||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([b4_syncline],
|
m4_define([b4_syncline],
|
||||||
[b4_flag_if([synclines], [
|
[b4_flag_if([synclines],
|
||||||
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||||
b4_sync_start([$1], [$2])])])
|
b4_sync_start([$1], [$2])])])
|
||||||
|
|
||||||
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
||||||
@@ -349,7 +584,6 @@ m4_popdef([b4_end])dnl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## b4_percent_define_*. ##
|
## b4_percent_define_*. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
@@ -379,7 +613,6 @@ m4_ifdef([b4_percent_define(]$1[)],
|
|||||||
[m4_indir([b4_percent_define(]$1[)])],
|
[m4_indir([b4_percent_define(]$1[)])],
|
||||||
[$2])])
|
[$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_get_loc(VARIABLE)
|
# b4_percent_define_get_loc(VARIABLE)
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
||||||
@@ -428,9 +661,15 @@ m4_define([b4_percent_define_get_syncline],
|
|||||||
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||||
m4_define([b4_percent_define_ifdef],
|
m4_define([b4_percent_define_ifdef],
|
||||||
[m4_ifdef([b4_percent_define(]$1[)],
|
[m4_ifdef([b4_percent_define(]$1[)],
|
||||||
[m4_define([b4_percent_define_bison_variables(]$1[)])$2],
|
[b4_percent_define_use([$1])$2],
|
||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
|
## --------- ##
|
||||||
|
## Options. ##
|
||||||
|
## --------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
|
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
|
||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is,
|
# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is,
|
||||||
@@ -454,6 +693,7 @@ m4_define([b4_percent_define_flag_if],
|
|||||||
[[b4_percent_define_flag_if($1)]])])],
|
[[b4_percent_define_flag_if($1)]])])],
|
||||||
[b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])
|
[b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_default(VARIABLE, DEFAULT)
|
# b4_percent_define_default(VARIABLE, DEFAULT)
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,
|
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,
|
||||||
@@ -472,6 +712,20 @@ m4_define([b4_percent_define_default],
|
|||||||
[[<skeleton default value>:-1.-1]]]])dnl
|
[[<skeleton default value>:-1.-1]]]])dnl
|
||||||
m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
|
m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_percent_define_if_define(VARIABLE)
|
||||||
|
# -------------------------------------
|
||||||
|
# Define b4_VARIABLE_if that executes its $1 or $2 depending whether
|
||||||
|
# VARIABLE was %defined. The characters `.' and `-' in VARIABLE are mapped
|
||||||
|
# to `_'.
|
||||||
|
m4_define([b4_percent_define_if_define_],
|
||||||
|
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
||||||
|
[b4_percent_define_flag_if([$1], [$2], [$3])])])
|
||||||
|
m4_define([b4_percent_define_if_define],
|
||||||
|
[b4_percent_define_default([[$1]], [[false]])
|
||||||
|
b4_percent_define_if_define_([$1], $[1], $[2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_check_values(VALUES)
|
# b4_percent_define_check_values(VALUES)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
|
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
|
||||||
@@ -546,6 +800,44 @@ m4_define([b4_percent_code_ifdef],
|
|||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------ ##
|
||||||
|
## Common variables. ##
|
||||||
|
## ------------------ ##
|
||||||
|
|
||||||
|
# Default values for %define.
|
||||||
|
# ---------------------------
|
||||||
|
# If the api.tokens.prefix, it is empty.
|
||||||
|
m4_percent_define_default([[api.tokens.prefix]], [[]])
|
||||||
|
|
||||||
|
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
|
||||||
|
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||||
|
# b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
|
||||||
|
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
||||||
|
# ----------------------------------------------
|
||||||
|
b4_percent_define_if_define([lex_symbol])
|
||||||
|
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||||
|
b4_percent_define_if_define([parse.assert])
|
||||||
|
b4_percent_define_if_define([parse.trace])
|
||||||
|
b4_percent_define_if_define([variant])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
|
||||||
|
# ------------------------------------------------------
|
||||||
|
# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and
|
||||||
|
# b4_error_verbose_flag.
|
||||||
|
b4_percent_define_default([[parse.error]], [[simple]])
|
||||||
|
b4_percent_define_check_values([[[[parse.error]],
|
||||||
|
[[simple]], [[verbose]]]])
|
||||||
|
m4_define([b4_error_verbose_flag],
|
||||||
|
[m4_case(b4_percent_define_get([[parse.error]]),
|
||||||
|
[simple], [[0]],
|
||||||
|
[verbose], [[1]])])
|
||||||
|
b4_define_flag_if([error_verbose])
|
||||||
|
|
||||||
|
# yytoken_table is needed to support verbose errors.
|
||||||
|
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
||||||
|
|
||||||
|
|
||||||
## ----------------------------------------------------------- ##
|
## ----------------------------------------------------------- ##
|
||||||
## After processing the skeletons, check that all the user's ##
|
## After processing the skeletons, check that all the user's ##
|
||||||
## %define variables and %code qualifiers were used by Bison. ##
|
## %define variables and %code qualifiers were used by Bison. ##
|
||||||
|
|||||||
+270
-16
@@ -23,7 +23,6 @@ m4_include(b4_pkgdatadir/[c.m4])
|
|||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# Default parser class name.
|
|
||||||
b4_percent_define_default([[parser_class_name]], [[parser]])
|
b4_percent_define_default([[parser_class_name]], [[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
|
||||||
@@ -32,18 +31,21 @@ b4_percent_define_default([[parser_class_name]], [[parser]])
|
|||||||
# b4_percent_define_default([[location_type]], [[location]])
|
# b4_percent_define_default([[location_type]], [[location]])
|
||||||
|
|
||||||
b4_percent_define_default([[filename_type]], [[std::string]])
|
b4_percent_define_default([[filename_type]], [[std::string]])
|
||||||
b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
|
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
|
||||||
|
|
||||||
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
||||||
b4_percent_define_default([[define_location_comparison]],
|
b4_percent_define_default([[define_location_comparison]],
|
||||||
[m4_if(b4_percent_define_get([[filename_type]]),
|
[m4_if(b4_percent_define_get([[filename_type]]),
|
||||||
[std::string], [[true]], [[false]])])
|
[std::string], [[true]], [[false]])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
## Namespace. ##
|
## Namespace. ##
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
|
|
||||||
m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])])
|
m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
|
||||||
|
|
||||||
|
|
||||||
# Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it
|
# Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it
|
||||||
# would compile as an absolute reference with `parser' in the global namespace.
|
# would compile as an absolute reference with `parser' in the global namespace.
|
||||||
@@ -53,7 +55,7 @@ m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])])
|
|||||||
# include the header, which is always generated. If we ever need to permit
|
# include the header, which is always generated. If we ever need to permit
|
||||||
# internal linkage somehow, surely we can find a cleaner approach.
|
# internal linkage somehow, surely we can find a cleaner approach.
|
||||||
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
||||||
[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
|
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||||
[[namespace reference is empty]])])
|
[[namespace reference is empty]])])
|
||||||
|
|
||||||
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
||||||
@@ -64,37 +66,37 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
|||||||
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
||||||
# those into anonymous namespaces, and that might tempt some users.
|
# those into anonymous namespaces, and that might tempt some users.
|
||||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
||||||
[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
|
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||||
[[namespace reference has consecutive "::"]])])
|
[[namespace reference has consecutive "::"]])])
|
||||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
||||||
[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
|
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||||
[[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([[namespace]])
|
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
||||||
[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([[namespace]])
|
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
||||||
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||||
[\1])),
|
[\1])),
|
||||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# b4_token_enums
|
||||||
# -----------------------------------------------------
|
# --------------
|
||||||
# Output the definition of the tokens as enums.
|
# Output the definition of the tokens as enums.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[/* Tokens. */
|
[[/* Tokens. */
|
||||||
enum yytokentype {
|
enum yytokentype {
|
||||||
m4_map_sep([ b4_token_enum], [,
|
]m4_join([,
|
||||||
],
|
],
|
||||||
[$@])
|
b4_symbol_map([b4_token_enum]))[
|
||||||
};
|
};
|
||||||
])
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -103,12 +105,263 @@ m4_map_sep([ b4_token_enum], [,
|
|||||||
## Semantic Values. ##
|
## Semantic Values. ##
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
|
# b4_semantic_type_declare
|
||||||
|
# ------------------------
|
||||||
|
# Declare semantic_type.
|
||||||
|
m4_define([b4_semantic_type_declare],
|
||||||
|
[ /// Symbol semantic values.
|
||||||
|
m4_ifdef([b4_stype],
|
||||||
|
[ union semantic_type
|
||||||
|
{b4_user_stype
|
||||||
|
};],
|
||||||
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
|
[[ typedef int semantic_type;]],
|
||||||
|
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_public_types_declare
|
||||||
|
# -----------------------
|
||||||
|
# Define the public types: token, semantic value, location, and so forth.
|
||||||
|
# Depending on %define token_lex, may be output in the header or source file.
|
||||||
|
m4_define([b4_public_types_declare],
|
||||||
|
[[#ifndef ]b4_api_PREFIX[STYPE
|
||||||
|
]b4_semantic_type_declare[
|
||||||
|
#else
|
||||||
|
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
||||||
|
#endif]b4_locations_if([
|
||||||
|
/// Symbol locations.
|
||||||
|
typedef b4_percent_define_get([[location_type]],
|
||||||
|
[[location]]) location_type;])[
|
||||||
|
|
||||||
|
/// Syntax errors thrown from user actions.
|
||||||
|
struct syntax_error : std::runtime_error
|
||||||
|
{
|
||||||
|
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m);]b4_locations_if([
|
||||||
|
location_type location;])[
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Tokens.
|
||||||
|
struct token
|
||||||
|
{
|
||||||
|
]b4_token_enums[
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Token type.
|
||||||
|
typedef token::yytokentype token_type;
|
||||||
|
|
||||||
|
/// A complete symbol, with its type.
|
||||||
|
template <typename Exact>
|
||||||
|
struct symbol_base_type
|
||||||
|
{
|
||||||
|
/// Default constructor.
|
||||||
|
inline symbol_base_type ();
|
||||||
|
|
||||||
|
/// Constructor.]b4_locations_if([
|
||||||
|
inline symbol_base_type (const location_type& l)])[;
|
||||||
|
inline symbol_base_type (]b4_args(
|
||||||
|
[const semantic_type& v],
|
||||||
|
b4_locations_if([const location_type& l]))[);
|
||||||
|
|
||||||
|
/// Return this with its exact type.
|
||||||
|
const Exact& self () const;
|
||||||
|
Exact& self ();
|
||||||
|
|
||||||
|
/// Return the type of this symbol.
|
||||||
|
int type_get () const;
|
||||||
|
|
||||||
|
/// The semantic value.
|
||||||
|
semantic_type value;]b4_locations_if([
|
||||||
|
|
||||||
|
/// The location.
|
||||||
|
location_type location;])[
|
||||||
|
};
|
||||||
|
|
||||||
|
/// External form of a symbol: its type and attributes.
|
||||||
|
struct symbol_type : symbol_base_type<symbol_type>
|
||||||
|
{
|
||||||
|
/// The parent class.
|
||||||
|
typedef symbol_base_type<symbol_type> super_type;
|
||||||
|
|
||||||
|
/// Default constructor.
|
||||||
|
inline symbol_type ();
|
||||||
|
|
||||||
|
/// Constructor for tokens with semantic value.
|
||||||
|
inline symbol_type (]b4_args([token_type t],
|
||||||
|
[const semantic_type& v],
|
||||||
|
b4_locations_if([const location_type& l]))[);
|
||||||
|
|
||||||
|
/// Constructor for valueless tokens.
|
||||||
|
inline symbol_type (]b4_args([token_type t],
|
||||||
|
b4_locations_if([const location_type& l]))[);
|
||||||
|
|
||||||
|
/// The symbol type.
|
||||||
|
int type;
|
||||||
|
|
||||||
|
/// The symbol type.
|
||||||
|
inline int type_get_ () const;
|
||||||
|
|
||||||
|
/// The token.
|
||||||
|
inline token_type token () const;
|
||||||
|
};
|
||||||
|
]b4_symbol_constructor_declare])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_public_types_define
|
||||||
|
# ----------------------
|
||||||
|
# Provide the implementation needed by the public types.
|
||||||
|
m4_define([b4_public_types_define],
|
||||||
|
[[ inline
|
||||||
|
]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
||||||
|
: std::runtime_error (m)]b4_locations_if([
|
||||||
|
, location (l)])[
|
||||||
|
{}
|
||||||
|
|
||||||
|
// symbol_base_type.
|
||||||
|
template <typename Exact>
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
|
||||||
|
: value()]b4_locations_if([
|
||||||
|
, location()])[
|
||||||
|
{
|
||||||
|
}]b4_locations_if([[
|
||||||
|
|
||||||
|
template <typename Exact>
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
|
||||||
|
: value()
|
||||||
|
, location(l)
|
||||||
|
{
|
||||||
|
}]])[
|
||||||
|
|
||||||
|
template <typename Exact>
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
|
||||||
|
[const semantic_type& v],
|
||||||
|
b4_locations_if([const location_type& l]))[)
|
||||||
|
: value(v)]b4_locations_if([
|
||||||
|
, location(l)])[
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Exact>
|
||||||
|
inline
|
||||||
|
const Exact&
|
||||||
|
]b4_parser_class_name[::symbol_base_type<Exact>::self () const
|
||||||
|
{
|
||||||
|
return static_cast<const Exact&>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Exact>
|
||||||
|
inline
|
||||||
|
Exact&
|
||||||
|
]b4_parser_class_name[::symbol_base_type<Exact>::self ()
|
||||||
|
{
|
||||||
|
return static_cast<Exact&>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Exact>
|
||||||
|
inline
|
||||||
|
int
|
||||||
|
]b4_parser_class_name[::symbol_base_type<Exact>::type_get () const
|
||||||
|
{
|
||||||
|
return self ().type_get_ ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// symbol_type.
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::symbol_type::symbol_type ()
|
||||||
|
: super_type ()
|
||||||
|
, type ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
|
||||||
|
[token_type t],
|
||||||
|
b4_locations_if([const location_type& l]))[)
|
||||||
|
: super_type (]b4_locations_if([l])[)
|
||||||
|
, type (yytranslate_ (t))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
|
||||||
|
[token_type t],
|
||||||
|
[const semantic_type& v],
|
||||||
|
b4_locations_if([const location_type& l]))[)
|
||||||
|
: super_type (v]b4_locations_if([, l])[)
|
||||||
|
, type (yytranslate_ (t))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
int
|
||||||
|
]b4_parser_class_name[::symbol_type::type_get_ () const
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
]b4_lex_symbol_if([[
|
||||||
|
inline
|
||||||
|
]b4_parser_class_name[::token_type
|
||||||
|
]b4_parser_class_name[::symbol_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_symbol_constructor_define
|
||||||
|
# -----------------------------
|
||||||
|
# Declare/define symbol constructors for all the value types.
|
||||||
|
# Use at class-level. Redefined in variant.hh.
|
||||||
|
m4_define([b4_symbol_constructor_declare], [])
|
||||||
|
m4_define([b4_symbol_constructor_define], [])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_yytranslate_define
|
||||||
|
# ---------------------
|
||||||
|
# Define yytranslate_. Sometimes used in the header file,
|
||||||
|
# sometimes in the cc file.
|
||||||
|
m4_define([b4_yytranslate_define],
|
||||||
|
[[ // Symbol number corresponding to token number t.
|
||||||
|
]b4_parser_class_name[::token_number_type
|
||||||
|
]b4_parser_class_name[::yytranslate_ (]b4_lex_symbol_if([token_type],
|
||||||
|
[int])[ t)
|
||||||
|
{
|
||||||
|
static
|
||||||
|
const token_number_type
|
||||||
|
translate_table[] =
|
||||||
|
{
|
||||||
|
]b4_translate[
|
||||||
|
};
|
||||||
|
const unsigned int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
|
const token_number_type undef_token_ = ]b4_undef_token_number[;
|
||||||
|
|
||||||
|
if (static_cast<int>(t) <= yyeof_)
|
||||||
|
return yyeof_;
|
||||||
|
else if (static_cast<unsigned int> (t) <= user_token_number_max_)
|
||||||
|
return translate_table[t];
|
||||||
|
else
|
||||||
|
return undef_token_;
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_value([TYPE])
|
# b4_lhs_value([TYPE])
|
||||||
# --------------------
|
# --------------------
|
||||||
# Expansion of $<TYPE>$.
|
# Expansion of $<TYPE>$.
|
||||||
m4_define([b4_lhs_value],
|
m4_define([b4_lhs_value],
|
||||||
[(yyval[]m4_ifval([$1], [.$1]))])
|
[b4_symbol_value([yyval], [$1])])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||||
@@ -116,7 +369,8 @@ m4_define([b4_lhs_value],
|
|||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
|
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_location()
|
# b4_lhs_location()
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
@@ -48,11 +48,34 @@ m4_define([b4_cpp_guard_close],
|
|||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# b4_comment(TEXT)
|
# b4_comment_(TEXT, OPEN, CONTINUE, END)
|
||||||
# ----------------
|
# -------------------------------------
|
||||||
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
# 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([$1], [
|
||||||
|
\(.\)], [
|
||||||
|
$3\1])$4])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_comment(TEXT, [PREFIX])
|
||||||
|
# ----------------------------
|
||||||
|
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||||
|
# Avoid adding indentation to the first line, as the indentation comes
|
||||||
|
# from "/*". That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||||
|
#
|
||||||
|
# Prefix all the output lines with PREFIX.
|
||||||
|
m4_define([b4_c_comment],
|
||||||
|
[b4_comment_([$1], [$2/* ], [$2 ], [$2 */])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_comment(TEXT, [PREFIX])
|
||||||
|
# --------------------------
|
||||||
|
# By default, C comments.
|
||||||
|
m4_define([b4_comment], [b4_c_comment($@)])
|
||||||
|
|
||||||
|
|
||||||
# b4_identification
|
# b4_identification
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -134,11 +157,13 @@ m4_popdef([$2])dnl
|
|||||||
m4_popdef([$1])dnl
|
m4_popdef([$1])dnl
|
||||||
])])
|
])])
|
||||||
|
|
||||||
# b4_parse_param_use
|
# b4_parse_param_use([VAL], [LOC])
|
||||||
# ------------------
|
# --------------------------------
|
||||||
# `YYUSE' all the parse-params.
|
# `YYUSE' VAL, LOC if locations are enabled, and all the parse-params.
|
||||||
m4_define([b4_parse_param_use],
|
m4_define([b4_parse_param_use],
|
||||||
[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
[m4_ifvaln([$1], [ YYUSE([$1]);])dnl
|
||||||
|
b4_locations_if([m4_ifvaln([$2], [ YYUSE ([$2]);])])dnl
|
||||||
|
b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
||||||
])dnl
|
])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -209,63 +234,83 @@ m4_define([b4_null_define],
|
|||||||
# Return a null pointer constant.
|
# Return a null pointer constant.
|
||||||
m4_define([b4_null], [YY_NULL])
|
m4_define([b4_null], [YY_NULL])
|
||||||
|
|
||||||
|
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
# Define "yy<TABLE-NAME>" which contents is CONTENT.
|
||||||
|
m4_define([b4_integral_parser_table_define],
|
||||||
|
[m4_ifvaln([$3], [b4_c_comment([$3], [ ])])dnl
|
||||||
|
static const b4_int_type_for([$2]) yy$1[[]] =
|
||||||
|
{
|
||||||
|
$2
|
||||||
|
};dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
## Assigning token numbers. ##
|
## Assigning token numbers. ##
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
|
|
||||||
# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
|
# b4_token_define(TOKEN-NUM)
|
||||||
# -----------------------------------------
|
# --------------------------
|
||||||
# Output the definition of this token as #define.
|
# Output the definition of this token as #define.
|
||||||
m4_define([b4_token_define],
|
m4_define([b4_token_define],
|
||||||
[#define $1 $2
|
[b4_token_format([#define %s %s], [$1])])
|
||||||
])
|
|
||||||
|
|
||||||
|
# b4_token_defines
|
||||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# ----------------
|
||||||
# -------------------------------------------------------
|
# Output the definition of the tokens.
|
||||||
# Output the definition of the tokens (if there are) as #defines.
|
|
||||||
m4_define([b4_token_defines],
|
m4_define([b4_token_defines],
|
||||||
[m4_if([$#$1], [1], [],
|
[b4_any_token_visible_if([/* Tokens. */
|
||||||
[/* Tokens. */
|
m4_join([
|
||||||
m4_map([b4_token_define], [$@])])
|
], b4_symbol_map([b4_token_define]))])])
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
# b4_token_enum(TOKEN-NUM)
|
||||||
# ---------------------------------------
|
# ------------------------
|
||||||
# Output the definition of this token as an enum.
|
# Output the definition of this token as an enum.
|
||||||
m4_define([b4_token_enum],
|
m4_define([b4_token_enum],
|
||||||
[$1 = $2])
|
[b4_token_format([ %s = %s], [$1])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# b4_token_enums
|
||||||
# -----------------------------------------------------
|
# --------------
|
||||||
# Output the definition of the tokens (if there are) as enums.
|
# Output the definition of the tokens (if there are) as enums.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[m4_if([$#$1], [1], [],
|
[b4_any_token_visible_if([[/* Tokens. */
|
||||||
[[/* Tokens. */
|
|
||||||
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||||
# define ]b4_api_PREFIX[TOKENTYPE
|
# define ]b4_api_PREFIX[TOKENTYPE
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
know about them. */
|
know about them. */
|
||||||
enum ]b4_api_prefix[tokentype {
|
enum ]b4_api_prefix[tokentype {
|
||||||
]m4_map_sep([ b4_token_enum], [,
|
]m4_join([,
|
||||||
],
|
],
|
||||||
[$@])[
|
b4_symbol_map([b4_token_enum]))[
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# b4_token_enums_defines
|
||||||
# -------------------------------------------------------------
|
# ----------------------
|
||||||
# Output the definition of the tokens (if there are any) as enums and, if POSIX
|
# Output the definition of the tokens (if there are any) as enums and,
|
||||||
# Yacc is enabled, as #defines.
|
# if POSIX Yacc is enabled, as #defines.
|
||||||
m4_define([b4_token_enums_defines],
|
m4_define([b4_token_enums_defines],
|
||||||
[b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], [])
|
[b4_token_enums[]b4_yacc_if([b4_token_defines])])
|
||||||
])
|
|
||||||
|
|
||||||
|
## ----------------- ##
|
||||||
|
## Semantic Values. ##
|
||||||
|
## ----------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_value(VAL, [TYPE])
|
||||||
|
# ----------------------------
|
||||||
|
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
|
||||||
|
# TYPE if TYPE is given, otherwise just return VAL. The result can be
|
||||||
|
# used safetly, it is put in parens to avoid nasty precedence issues.
|
||||||
|
# TYPE is *not* put in braces, provide some if needed.
|
||||||
|
m4_define([b4_symbol_value],
|
||||||
|
[($1[]m4_ifval([$2], [.$2]))])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -356,7 +401,7 @@ m4_define([b4_c_knr_formal_decl],
|
|||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
# Declare the function NAME.
|
# Declare the function NAME.
|
||||||
m4_define([b4_c_function_decl],
|
m4_define([b4_c_function_decl],
|
||||||
[#if defined __STDC__ || defined __cplusplus
|
[#if b4_c_modern
|
||||||
b4_c_ansi_function_decl($@)
|
b4_c_ansi_function_decl($@)
|
||||||
#else
|
#else
|
||||||
$2 $1 ();
|
$2 $1 ();
|
||||||
@@ -415,24 +460,17 @@ 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@])
|
||||||
break;])
|
break;])
|
||||||
|
|
||||||
# b4_symbol_actions(FILENAME, LINENO,
|
|
||||||
# SYMBOL-TAG, SYMBOL-NUM,
|
# b4_predicate_case(LABEL, CONDITIONS)
|
||||||
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
# ------------------------------------
|
||||||
# -------------------------------------------------
|
m4_define([b4_predicate_case],
|
||||||
m4_define([b4_symbol_actions],
|
[ case $1:
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
if (! ($2)) YYERROR;
|
||||||
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
|
|
||||||
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
|
||||||
case $4: /* $3 */
|
|
||||||
b4_syncline([$2], [$1])
|
|
||||||
$5;
|
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])
|
||||||
break;
|
break;])
|
||||||
m4_popdef([b4_at_dollar])dnl
|
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
|
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
|
||||||
@@ -454,19 +492,15 @@ m4_define_default([b4_yydestruct_generate],
|
|||||||
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
YYUSE (yyvaluep);
|
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
||||||
]b4_locations_if([ YYUSE (yylocationp);
|
[ if (!yymsg)
|
||||||
])dnl
|
|
||||||
b4_parse_param_use[]dnl
|
|
||||||
[
|
|
||||||
if (!yymsg)
|
|
||||||
yymsg = "Deleting";
|
yymsg = "Deleting";
|
||||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||||
|
|
||||||
switch (yytype)
|
switch (yytype)
|
||||||
{
|
{
|
||||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
|
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||||
default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}]dnl
|
}]dnl
|
||||||
@@ -494,21 +528,19 @@ b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
|||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
FILE *yyo = yyoutput;
|
FILE *yyo = yyoutput;
|
||||||
YYUSE (yyo);
|
]b4_parse_param_use([yyo], [yylocationp])dnl
|
||||||
if (!yyvaluep)
|
[ if (!yyvaluep)
|
||||||
return;
|
return;]
|
||||||
]b4_locations_if([ YYUSE (yylocationp);
|
dnl glr.c does not feature yytoknum.
|
||||||
])dnl
|
m4_if(b4_skeleton, ["yacc.c"],
|
||||||
b4_parse_param_use[]dnl
|
[[# ifdef YYPRINT
|
||||||
[# ifdef YYPRINT
|
|
||||||
if (yytype < YYNTOKENS)
|
if (yytype < YYNTOKENS)
|
||||||
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
||||||
# else
|
|
||||||
YYUSE (yyoutput);
|
|
||||||
# endif
|
# endif
|
||||||
switch (yytype)
|
]])dnl
|
||||||
|
[ switch (yytype)
|
||||||
{
|
{
|
||||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
]b4_symbol_foreach([b4_symbol_printer])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -587,7 +619,7 @@ m4_define([b4_YYDEBUG_define],
|
|||||||
[[/* Enabling traces. */
|
[[/* Enabling traces. */
|
||||||
]m4_if(b4_api_prefix, [yy],
|
]m4_if(b4_api_prefix, [yy],
|
||||||
[[#ifndef YYDEBUG
|
[[#ifndef YYDEBUG
|
||||||
# define YYDEBUG ]b4_debug_flag[
|
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
|
||||||
#endif]],
|
#endif]],
|
||||||
[[#ifndef ]b4_api_PREFIX[DEBUG
|
[[#ifndef ]b4_api_PREFIX[DEBUG
|
||||||
# if defined YYDEBUG
|
# if defined YYDEBUG
|
||||||
@@ -597,7 +629,7 @@ m4_define([b4_YYDEBUG_define],
|
|||||||
# define ]b4_api_PREFIX[DEBUG 0
|
# define ]b4_api_PREFIX[DEBUG 0
|
||||||
# endif
|
# endif
|
||||||
# else /* ! defined YYDEBUG */
|
# else /* ! defined YYDEBUG */
|
||||||
# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
|
# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[
|
||||||
# endif /* ! defined ]b4_api_PREFIX[DEBUG */
|
# endif /* ! defined ]b4_api_PREFIX[DEBUG */
|
||||||
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
||||||
])
|
])
|
||||||
|
|||||||
+202
-212
@@ -126,7 +126,15 @@ m4_define([b4_locuser_args],
|
|||||||
# --------------------
|
# --------------------
|
||||||
# Expansion of $<TYPE>$.
|
# Expansion of $<TYPE>$.
|
||||||
m4_define([b4_lhs_value],
|
m4_define([b4_lhs_value],
|
||||||
[((*yyvalp)[]m4_ifval([$1], [.$1]))])
|
[b4_symbol_value([(*yyvalp)], [$1])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_rhs_data(RULE-LENGTH, NUM)
|
||||||
|
# -----------------------------
|
||||||
|
# Expand to the semantic stack place that contains value and location
|
||||||
|
# of symbol number NUM in a rule of length RULE-LENGTH.
|
||||||
|
m4_define([b4_rhs_data],
|
||||||
|
[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||||
@@ -134,7 +142,7 @@ m4_define([b4_lhs_value],
|
|||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
|
[b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yysval], [$3])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -154,7 +162,7 @@ m4_define([b4_lhs_location],
|
|||||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||||
# on RHS.
|
# on RHS.
|
||||||
m4_define([b4_rhs_location],
|
m4_define([b4_rhs_location],
|
||||||
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
|
[(b4_rhs_data([$1], [$2]).yyloc)])
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
@@ -168,7 +176,7 @@ m4_define([b4_rhs_location],
|
|||||||
m4_define([b4_shared_declarations],
|
m4_define([b4_shared_declarations],
|
||||||
[b4_declare_yydebug[
|
[b4_declare_yydebug[
|
||||||
]b4_percent_code_get([[requires]])[
|
]b4_percent_code_get([[requires]])[
|
||||||
]b4_token_enums(b4_tokens)[
|
]b4_token_enums[
|
||||||
]b4_declare_yylstype[
|
]b4_declare_yylstype[
|
||||||
]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
||||||
]b4_percent_code_get([[provides]])[]dnl
|
]b4_percent_code_get([[provides]])[]dnl
|
||||||
@@ -219,7 +227,7 @@ b4_percent_code_get([[top]])[
|
|||||||
# undef YYERROR_VERBOSE
|
# undef YYERROR_VERBOSE
|
||||||
# define YYERROR_VERBOSE 1
|
# define YYERROR_VERBOSE 1
|
||||||
#else
|
#else
|
||||||
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Default (constant) value used for initialization for null
|
/* Default (constant) value used for initialization for null
|
||||||
@@ -349,19 +357,6 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
|
||||||
YYRHS. */
|
|
||||||
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
|
||||||
{
|
|
||||||
]b4_prhs[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
|
||||||
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
|
||||||
{
|
|
||||||
]b4_rhs[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
||||||
{
|
{
|
||||||
@@ -378,17 +373,10 @@ static const char *const yytname[] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
#define YYPACT_NINF ]b4_pact_ninf[
|
||||||
static const ]b4_int_type_for([b4_r1])[ yyr1[] =
|
#define YYTABLE_NINF ]b4_table_ninf[
|
||||||
{
|
|
||||||
]b4_r1[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
]b4_parser_tables_define[
|
||||||
static const ]b4_int_type_for([b4_r2])[ yyr2[] =
|
|
||||||
{
|
|
||||||
]b4_r2[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
|
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
|
||||||
static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
|
static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
|
||||||
@@ -402,41 +390,11 @@ static const ]b4_int_type_for([b4_merger])[ yymerger[] =
|
|||||||
]b4_merger[
|
]b4_merger[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYDEFACT[S] -- default reduction number in state S. Performed when
|
/* YYIMMEDIATE[RULE-NUM] -- True iff rule #RULE-NUM is not to be deferred, as
|
||||||
YYTABLE doesn't specify something else to do. Zero means the default
|
in the case of predicates. */
|
||||||
is an error. */
|
static const yybool yyimmediate[] =
|
||||||
static const ]b4_int_type_for([b4_defact])[ yydefact[] =
|
|
||||||
{
|
{
|
||||||
]b4_defact[
|
]b4_immediate[
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPDEFGOTO[NTERM-NUM]. */
|
|
||||||
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
|
||||||
{
|
|
||||||
]b4_defgoto[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
|
||||||
STATE-NUM. */
|
|
||||||
#define YYPACT_NINF ]b4_pact_ninf[
|
|
||||||
static const ]b4_int_type_for([b4_pact])[ yypact[] =
|
|
||||||
{
|
|
||||||
]b4_pact[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPGOTO[NTERM-NUM]. */
|
|
||||||
static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
|
|
||||||
{
|
|
||||||
]b4_pgoto[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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. */
|
|
||||||
#define YYTABLE_NINF ]b4_table_ninf[
|
|
||||||
static const ]b4_int_type_for([b4_table])[ yytable[] =
|
|
||||||
{
|
|
||||||
]b4_table[
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
|
/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
|
||||||
@@ -457,19 +415,7 @@ dnl We probably ought to introduce a type for confl.
|
|||||||
{
|
{
|
||||||
]b4_conflicting_rules[
|
]b4_conflicting_rules[
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ]b4_int_type_for([b4_check])[ yycheck[] =
|
|
||||||
{
|
|
||||||
]b4_check[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
|
||||||
symbol of state STATE-NUM. */
|
|
||||||
static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
|
||||||
{
|
|
||||||
]b4_stos[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Error token number */
|
/* Error token number */
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
|
|
||||||
@@ -527,8 +473,11 @@ static const int YYEMPTY = -2;
|
|||||||
typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
||||||
|
|
||||||
#define YYCHK(YYE) \
|
#define YYCHK(YYE) \
|
||||||
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
|
do { \
|
||||||
while (YYID (0))
|
YYRESULTTAG yychk_flag = YYE; \
|
||||||
|
if (yychk_flag != yyok) \
|
||||||
|
return yychk_flag; \
|
||||||
|
} while (YYID (0))
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
|
||||||
@@ -589,13 +538,7 @@ int yydebug;
|
|||||||
#define YYHEADROOM 2
|
#define YYHEADROOM 2
|
||||||
|
|
||||||
#ifndef YYSTACKEXPANDABLE
|
#ifndef YYSTACKEXPANDABLE
|
||||||
# if (! defined __cplusplus \
|
|
||||||
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
|
|
||||||
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))
|
|
||||||
# define YYSTACKEXPANDABLE 1
|
# define YYSTACKEXPANDABLE 1
|
||||||
# else
|
|
||||||
# define YYSTACKEXPANDABLE 0
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if YYSTACKEXPANDABLE
|
#if YYSTACKEXPANDABLE
|
||||||
@@ -692,7 +635,7 @@ typedef int yyStateNum;
|
|||||||
typedef int yyRuleNum;
|
typedef int yyRuleNum;
|
||||||
|
|
||||||
/** Grammar symbol */
|
/** Grammar symbol */
|
||||||
typedef short int yySymbol;
|
typedef int yySymbol;
|
||||||
|
|
||||||
/** Item references, as in LALR(1) machine */
|
/** Item references, as in LALR(1) machine */
|
||||||
typedef short int yyItemNum;
|
typedef short int yyItemNum;
|
||||||
@@ -713,7 +656,7 @@ struct yyGLRState {
|
|||||||
yyStateNum yylrState;
|
yyStateNum yylrState;
|
||||||
/** Preceding state in this stack */
|
/** Preceding state in this stack */
|
||||||
yyGLRState* yypred;
|
yyGLRState* yypred;
|
||||||
/** Source position of the first token produced by my symbol */
|
/** Source position of the last token produced by my symbol */
|
||||||
size_t yyposn;
|
size_t yyposn;
|
||||||
union {
|
union {
|
||||||
/** First in a chain of alternative reductions producing the
|
/** First in a chain of alternative reductions producing the
|
||||||
@@ -825,9 +768,16 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
|||||||
yyGLRState *s = yyvsp[yylow0].yystate.yypred;
|
yyGLRState *s = yyvsp[yylow0].yystate.yypred;
|
||||||
for (i = yylow0-1; i >= yylow1; i -= 1)
|
for (i = yylow0-1; i >= yylow1; i -= 1)
|
||||||
{
|
{
|
||||||
YYASSERT (s->yyresolved);
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
yyvsp[i].yystate.yyresolved = yytrue;
|
yyvsp[i].yystate.yylrState = s->yylrState;
|
||||||
yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[
|
#endif
|
||||||
|
yyvsp[i].yystate.yyresolved = s->yyresolved;
|
||||||
|
if (s->yyresolved)
|
||||||
|
yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
|
||||||
|
else
|
||||||
|
/* The effect of using yysval or yyloc (in an immediate rule) is
|
||||||
|
* undefined. */
|
||||||
|
yyvsp[i].yystate.yysemantics.yyfirstVal = YY_NULL;]b4_locations_if([[
|
||||||
yyvsp[i].yystate.yyloc = s->yyloc;]])[
|
yyvsp[i].yystate.yyloc = s->yyloc;]])[
|
||||||
s = yyvsp[i].yystate.yypred = s->yypred;
|
s = yyvsp[i].yystate.yypred = s->yypred;
|
||||||
}
|
}
|
||||||
@@ -862,7 +812,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
|||||||
yybool yynormal __attribute__ ((__unused__)) =
|
yybool yynormal __attribute__ ((__unused__)) =
|
||||||
(yystackp->yysplitPoint == YY_NULL);
|
(yystackp->yysplitPoint == YY_NULL);
|
||||||
int yylow;
|
int yylow;
|
||||||
]b4_parse_param_use[]dnl
|
]b4_parse_param_use([yyvalp], [yylocp])dnl
|
||||||
[# undef yyerrok
|
[# undef yyerrok
|
||||||
# define yyerrok (yystackp->yyerrState = 0)
|
# define yyerrok (yystackp->yyerrState = 0)
|
||||||
# undef YYACCEPT
|
# undef YYACCEPT
|
||||||
@@ -965,7 +915,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Left-hand-side symbol for rule #RULE. */
|
/** Left-hand-side symbol for rule #YYRULE. */
|
||||||
static inline yySymbol
|
static inline yySymbol
|
||||||
yylhsNonterm (yyRuleNum yyrule)
|
yylhsNonterm (yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
@@ -975,7 +925,7 @@ yylhsNonterm (yyRuleNum yyrule)
|
|||||||
#define yypact_value_is_default(yystate) \
|
#define yypact_value_is_default(yystate) \
|
||||||
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
|
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
|
||||||
|
|
||||||
/** True iff LR state STATE has only a default reduction (regardless
|
/** True iff LR state YYSTATE has only a default reduction (regardless
|
||||||
* of token). */
|
* of token). */
|
||||||
static inline yybool
|
static inline yybool
|
||||||
yyisDefaultedState (yyStateNum yystate)
|
yyisDefaultedState (yyStateNum yystate)
|
||||||
@@ -983,7 +933,7 @@ yyisDefaultedState (yyStateNum yystate)
|
|||||||
return yypact_value_is_default (yypact[yystate]);
|
return yypact_value_is_default (yypact[yystate]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The default reduction for STATE, assuming it has one. */
|
/** The default reduction for YYSTATE, assuming it has one. */
|
||||||
static inline yyRuleNum
|
static inline yyRuleNum
|
||||||
yydefaultAction (yyStateNum yystate)
|
yydefaultAction (yyStateNum yystate)
|
||||||
{
|
{
|
||||||
@@ -998,8 +948,8 @@ yydefaultAction (yyStateNum yystate)
|
|||||||
* R < 0: Reduce on rule -R.
|
* R < 0: Reduce on rule -R.
|
||||||
* R = 0: Error.
|
* R = 0: Error.
|
||||||
* R > 0: Shift to state R.
|
* R > 0: Shift to state R.
|
||||||
* Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
|
* Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
|
||||||
* conflicting reductions.
|
* of conflicting reductions.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
yygetLRActions (yyStateNum yystate, int yytoken,
|
yygetLRActions (yyStateNum yystate, int yytoken,
|
||||||
@@ -1027,8 +977,7 @@ yygetLRActions (yyStateNum yystate, int yytoken,
|
|||||||
static inline yyStateNum
|
static inline yyStateNum
|
||||||
yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
|
yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
|
||||||
{
|
{
|
||||||
int yyr;
|
int yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
|
||||||
yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
|
|
||||||
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
|
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
|
||||||
return yytable[yyr];
|
return yytable[yyr];
|
||||||
else
|
else
|
||||||
@@ -1049,7 +998,8 @@ yyisErrorAction (int yyaction)
|
|||||||
|
|
||||||
/* GLRStates */
|
/* GLRStates */
|
||||||
|
|
||||||
/** Return a fresh GLRStackItem. Callers should call
|
/** Return a fresh GLRStackItem in YYSTACKP. The item is an LR state
|
||||||
|
* if YYISSTATE, and otherwise a semantic option. Callers should call
|
||||||
* YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
|
* YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
|
||||||
* headroom. */
|
* headroom. */
|
||||||
|
|
||||||
@@ -1064,16 +1014,16 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Add a new semantic action that will execute the action for rule
|
/** Add a new semantic action that will execute the action for rule
|
||||||
* RULENUM on the semantic values in RHS to the list of
|
* YYRULE on the semantic values in YYRHS to the list of
|
||||||
* alternative actions for STATE. Assumes that RHS comes from
|
* alternative actions for YYSTATE. Assumes that YYRHS comes from
|
||||||
* stack #K of *STACKP. */
|
* stack #YYK of *YYSTACKP. */
|
||||||
static void
|
static void
|
||||||
yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
||||||
yyGLRState* rhs, yyRuleNum yyrule)
|
yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
yySemanticOption* yynewOption =
|
yySemanticOption* yynewOption =
|
||||||
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
|
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
|
||||||
yynewOption->yystate = rhs;
|
yynewOption->yystate = yyrhs;
|
||||||
yynewOption->yyrule = yyrule;
|
yynewOption->yyrule = yyrule;
|
||||||
if (yystackp->yytops.yylookaheadNeeds[yyk])
|
if (yystackp->yytops.yylookaheadNeeds[yyk])
|
||||||
{
|
{
|
||||||
@@ -1091,7 +1041,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
|||||||
|
|
||||||
/* GLRStacks */
|
/* GLRStacks */
|
||||||
|
|
||||||
/** Initialize SET to a singleton set containing an empty stack. */
|
/** Initialize YYSET to a singleton set containing an empty stack. */
|
||||||
static yybool
|
static yybool
|
||||||
yyinitStateSet (yyGLRStateSet* yyset)
|
yyinitStateSet (yyGLRStateSet* yyset)
|
||||||
{
|
{
|
||||||
@@ -1117,8 +1067,8 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
|
|||||||
YYFREE (yyset->yylookaheadNeeds);
|
YYFREE (yyset->yylookaheadNeeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize STACK to a single empty stack, with total maximum
|
/** Initialize *YYSTACKP to a single empty stack, with total maximum
|
||||||
* capacity for all stacks of SIZE. */
|
* capacity for all stacks of YYSIZE. */
|
||||||
static yybool
|
static yybool
|
||||||
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
||||||
{
|
{
|
||||||
@@ -1140,7 +1090,7 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
|||||||
# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
||||||
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
|
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
|
||||||
|
|
||||||
/** If STACK is expandable, extend it. WARNING: Pointers into the
|
/** If *YYSTACKP is expandable, extend it. WARNING: Pointers into the
|
||||||
stack from outside should be considered invalid after this call.
|
stack from outside should be considered invalid after this call.
|
||||||
We always expand when there are 1 or fewer items left AFTER an
|
We always expand when there are 1 or fewer items left AFTER an
|
||||||
allocation, so that we can avoid having external pointers exist
|
allocation, so that we can avoid having external pointers exist
|
||||||
@@ -1210,9 +1160,9 @@ yyfreeGLRStack (yyGLRStack* yystackp)
|
|||||||
yyfreeStateSet (&yystackp->yytops);
|
yyfreeStateSet (&yystackp->yytops);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Assuming that S is a GLRState somewhere on STACK, update the
|
/** Assuming that YYS is a GLRState somewhere on *YYSTACKP, update the
|
||||||
* splitpoint of STACK, if needed, so that it is at least as deep as
|
* splitpoint of *YYSTACKP, if needed, so that it is at least as deep as
|
||||||
* S. */
|
* YYS. */
|
||||||
static inline void
|
static inline void
|
||||||
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
||||||
{
|
{
|
||||||
@@ -1220,7 +1170,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
|||||||
yystackp->yysplitPoint = yys;
|
yystackp->yysplitPoint = yys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Invalidate stack #K in STACK. */
|
/** Invalidate stack #YYK in *YYSTACKP. */
|
||||||
static inline void
|
static inline void
|
||||||
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
||||||
{
|
{
|
||||||
@@ -1229,8 +1179,8 @@ yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
|||||||
yystackp->yytops.yystates[yyk] = YY_NULL;
|
yystackp->yytops.yystates[yyk] = YY_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Undelete the last stack that was marked as deleted. Can only be
|
/** Undelete the last stack in *YYSTACKP that was marked as deleted. Can
|
||||||
done once after a deletion, and only when all other stacks have
|
only be done once after a deletion, and only when all other stacks have
|
||||||
been deleted. */
|
been deleted. */
|
||||||
static void
|
static void
|
||||||
yyundeleteLastStack (yyGLRStack* yystackp)
|
yyundeleteLastStack (yyGLRStack* yystackp)
|
||||||
@@ -1279,8 +1229,9 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shift to a new state on stack #K of STACK, corresponding to LR state
|
/** Shift to a new state on stack #YYK of *YYSTACKP, corresponding to LR
|
||||||
* LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
|
* state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
|
||||||
|
* value *YYVALP and source location *YYLOCP. */
|
||||||
static inline void
|
static inline void
|
||||||
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||||
size_t yyposn,
|
size_t yyposn,
|
||||||
@@ -1299,12 +1250,12 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
|||||||
YY_RESERVE_GLRSTACK (yystackp);
|
YY_RESERVE_GLRSTACK (yystackp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shift stack #K of YYSTACK, to a new state corresponding to LR
|
/** Shift stack #YYK of *YYSTACKP, to a new state corresponding to LR
|
||||||
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
||||||
* semantic value of YYRHS under the action for YYRULE. */
|
* semantic value of YYRHS under the action for YYRULE. */
|
||||||
static inline void
|
static inline void
|
||||||
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||||
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
|
size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||||
|
|
||||||
@@ -1316,14 +1267,55 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
|||||||
yystackp->yytops.yystates[yyk] = yynewState;
|
yystackp->yytops.yystates[yyk] = yynewState;
|
||||||
|
|
||||||
/* Invokes YY_RESERVE_GLRSTACK. */
|
/* Invokes YY_RESERVE_GLRSTACK. */
|
||||||
yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule);
|
yyaddDeferredAction (yystackp, yyk, yynewState, yyrhs, yyrule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pop the symbols consumed by reduction #RULE from the top of stack
|
#if !]b4_api_PREFIX[DEBUG
|
||||||
* #K of STACK, and perform the appropriate semantic action on their
|
# define YY_REDUCE_PRINT(Args)
|
||||||
|
#else
|
||||||
|
# define YY_REDUCE_PRINT(Args) \
|
||||||
|
do { \
|
||||||
|
if (yydebug) \
|
||||||
|
yy_reduce_print Args; \
|
||||||
|
} while (YYID (0))
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------.
|
||||||
|
| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
|
||||||
|
`----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*ARGSUSED*/ static inline void
|
||||||
|
yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||||
|
yyRuleNum yyrule]b4_user_formals[)
|
||||||
|
{
|
||||||
|
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
||||||
|
int yylow = 1;])[
|
||||||
|
int yyi;
|
||||||
|
YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
|
||||||
|
(unsigned long int) yyk, yyrule - 1,
|
||||||
|
(unsigned long int) yyrline[yyrule]);
|
||||||
|
if (! yynormal)
|
||||||
|
yyfillin (yyvsp, 1, -yynrhs);
|
||||||
|
/* The symbols being reduced. */
|
||||||
|
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||||
|
{
|
||||||
|
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||||
|
yy_symbol_print (stderr,
|
||||||
|
yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
|
||||||
|
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
|
||||||
|
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||||
|
b4_user_args[);
|
||||||
|
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
|
||||||
|
YYFPRINTF (stderr, " (unresolved)");
|
||||||
|
YYFPRINTF (stderr, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Pop the symbols consumed by reduction #YYRULE from the top of stack
|
||||||
|
* #YYK of *YYSTACKP, and perform the appropriate semantic action on their
|
||||||
* semantic values. Assumes that all ambiguities in semantic values
|
* semantic values. Assumes that all ambiguities in semantic values
|
||||||
* have been previously resolved. Set *VALP to the resulting value,
|
* have been previously resolved. Set *YYVALP to the resulting value,
|
||||||
* and *LOCP to the computed location (if any). Return value is as
|
* and *YYLOCP to the computed location (if any). Return value is as
|
||||||
* for userAction. */
|
* for userAction. */
|
||||||
static inline YYRESULTTAG
|
static inline YYRESULTTAG
|
||||||
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||||
@@ -1334,20 +1326,17 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
if (yystackp->yysplitPoint == YY_NULL)
|
if (yystackp->yysplitPoint == YY_NULL)
|
||||||
{
|
{
|
||||||
/* Standard special case: single stack. */
|
/* Standard special case: single stack. */
|
||||||
yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
||||||
YYASSERT (yyk == 0);
|
YYASSERT (yyk == 0);
|
||||||
yystackp->yynextFree -= yynrhs;
|
yystackp->yynextFree -= yynrhs;
|
||||||
yystackp->yyspaceLeft += yynrhs;
|
yystackp->yyspaceLeft += yynrhs;
|
||||||
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
||||||
return yyuserAction (yyrule, yynrhs, rhs, yystackp,
|
YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
|
||||||
|
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
|
||||||
yyvalp]b4_locuser_args[);
|
yyvalp]b4_locuser_args[);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* At present, doAction is never called in nondeterministic
|
|
||||||
* mode, so this branch is never taken. It is here in
|
|
||||||
* anticipation of a future feature that will allow immediate
|
|
||||||
* evaluation of selected actions in nondeterministic mode. */
|
|
||||||
int yyi;
|
int yyi;
|
||||||
yyGLRState* yys;
|
yyGLRState* yys;
|
||||||
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
||||||
@@ -1363,62 +1352,21 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
}
|
}
|
||||||
yyupdateSplit (yystackp, yys);
|
yyupdateSplit (yystackp, yys);
|
||||||
yystackp->yytops.yystates[yyk] = yys;
|
yystackp->yytops.yystates[yyk] = yys;
|
||||||
|
YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
|
||||||
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
||||||
yystackp, yyvalp]b4_locuser_args[);
|
yystackp, yyvalp]b4_locuser_args[);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !]b4_api_PREFIX[DEBUG
|
/** Pop items off stack #YYK of *YYSTACKP according to grammar rule YYRULE,
|
||||||
# define YY_REDUCE_PRINT(Args)
|
|
||||||
#else
|
|
||||||
# define YY_REDUCE_PRINT(Args) \
|
|
||||||
do { \
|
|
||||||
if (yydebug) \
|
|
||||||
yy_reduce_print Args; \
|
|
||||||
} while (YYID (0))
|
|
||||||
|
|
||||||
/*----------------------------------------------------------.
|
|
||||||
| Report that the RULE is going to be reduced on stack #K. |
|
|
||||||
`----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*ARGSUSED*/ static inline void
|
|
||||||
yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|
||||||
YYSTYPE* yyvalp]b4_locuser_formals[)
|
|
||||||
{
|
|
||||||
int yynrhs = yyrhsLength (yyrule);
|
|
||||||
yybool yynormal __attribute__ ((__unused__)) =
|
|
||||||
(yystackp->yysplitPoint == YY_NULL);
|
|
||||||
yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
|
||||||
int yylow = 1;
|
|
||||||
int yyi;
|
|
||||||
YYUSE (yyvalp);]b4_locations_if([
|
|
||||||
YYUSE (yylocp);])[
|
|
||||||
]b4_parse_param_use[]dnl
|
|
||||||
[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
|
|
||||||
(unsigned long int) yyk, yyrule - 1,
|
|
||||||
(unsigned long int) yyrline[yyrule]);
|
|
||||||
/* The symbols being reduced. */
|
|
||||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
|
||||||
{
|
|
||||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
|
||||||
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
|
||||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
|
||||||
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
|
||||||
b4_user_args[);
|
|
||||||
YYFPRINTF (stderr, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Pop items off stack #K of STACK according to grammar rule RULE,
|
|
||||||
* and push back on the resulting nonterminal symbol. Perform the
|
* and push back on the resulting nonterminal symbol. Perform the
|
||||||
* semantic action associated with RULE and store its value with the
|
* semantic action associated with YYRULE and store its value with the
|
||||||
* newly pushed state, if FORCEEVAL or if STACK is currently
|
* newly pushed state, if YYFORCEEVAL or if *YYSTACKP is currently
|
||||||
* unambiguous. Otherwise, store the deferred semantic action with
|
* unambiguous. Otherwise, store the deferred semantic action with
|
||||||
* the new state. If the new state would have an identical input
|
* the new state. If the new state would have an identical input
|
||||||
* position, LR state, and predecessor to an existing state on the stack,
|
* position, LR state, and predecessor to an existing state on the stack,
|
||||||
* it is identified with that existing state, eliminating stack #K from
|
* it is identified with that existing state, eliminating stack #YYK from
|
||||||
* the STACK. In this case, the (necessarily deferred) semantic value is
|
* *YYSTACKP. In this case, the semantic value is
|
||||||
* added to the options for the existing state's semantic value.
|
* added to the options for the existing state's semantic value.
|
||||||
*/
|
*/
|
||||||
static inline YYRESULTTAG
|
static inline YYRESULTTAG
|
||||||
@@ -1429,11 +1377,18 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
|
|
||||||
if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
|
if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
|
||||||
{
|
{
|
||||||
|
YYRESULTTAG yyflag;
|
||||||
YYSTYPE yysval;]b4_locations_if([
|
YYSTYPE yysval;]b4_locations_if([
|
||||||
YYLTYPE yyloc;])[
|
YYLTYPE yyloc;])[
|
||||||
|
|
||||||
YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
|
yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
|
||||||
YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
|
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULL)
|
||||||
|
{
|
||||||
|
YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
|
||||||
|
(unsigned long int) yyk, yyrule - 1));
|
||||||
|
}
|
||||||
|
if (yyflag != yyok)
|
||||||
|
return yyflag;
|
||||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
|
||||||
yyglrShift (yystackp, yyk,
|
yyglrShift (yystackp, yyk,
|
||||||
yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
|
yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
|
||||||
@@ -1456,7 +1411,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
yyupdateSplit (yystackp, yys);
|
yyupdateSplit (yystackp, yys);
|
||||||
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
||||||
YYDPRINTF ((stderr,
|
YYDPRINTF ((stderr,
|
||||||
"Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
|
"Reduced stack %lu by rule #%d; action deferred. "
|
||||||
|
"Now in state %d.\n",
|
||||||
(unsigned long int) yyk, yyrule - 1, yynewLRState));
|
(unsigned long int) yyk, yyrule - 1, yynewLRState));
|
||||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||||
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
|
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
|
||||||
@@ -1527,7 +1483,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
|||||||
return yystackp->yytops.yysize-1;
|
return yystackp->yytops.yysize-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** True iff Y0 and Y1 represent identical options at the top level.
|
/** True iff YYY0 and YYY1 represent identical options at the top level.
|
||||||
* That is, they represent the same rule applied to RHS symbols
|
* That is, they represent the same rule applied to RHS symbols
|
||||||
* that produce the same terminal symbols. */
|
* that produce the same terminal symbols. */
|
||||||
static yybool
|
static yybool
|
||||||
@@ -1549,8 +1505,8 @@ yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
|||||||
return yyfalse;
|
return yyfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Assuming identicalOptions (Y0,Y1), destructively merge the
|
/** Assuming identicalOptions (YYY0,YYY1), destructively merge the
|
||||||
* alternative semantic values for the RHS-symbols of Y1 and Y0. */
|
* alternative semantic values for the RHS-symbols of YYY1 and YYY0. */
|
||||||
static void
|
static void
|
||||||
yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
||||||
{
|
{
|
||||||
@@ -1629,11 +1585,11 @@ static YYRESULTTAG yyresolveValue (yyGLRState* yys,
|
|||||||
yyGLRStack* yystackp]b4_user_formals[);
|
yyGLRStack* yystackp]b4_user_formals[);
|
||||||
|
|
||||||
|
|
||||||
/** Resolve the previous N states starting at and including state S. If result
|
/** Resolve the previous YYN states starting at and including state YYS
|
||||||
* != yyok, some states may have been left unresolved possibly with empty
|
* on *YYSTACKP. If result != yyok, some states may have been left
|
||||||
* semantic option chains. Regardless of whether result = yyok, each state
|
* unresolved possibly with empty semantic option chains. Regardless
|
||||||
* has been left with consistent data so that yydestroyGLRState can be invoked
|
* of whether result = yyok, each state has been left with consistent
|
||||||
* if necessary. */
|
* data so that yydestroyGLRState can be invoked if necessary. */
|
||||||
static YYRESULTTAG
|
static YYRESULTTAG
|
||||||
yyresolveStates (yyGLRState* yys, int yyn,
|
yyresolveStates (yyGLRState* yys, int yyn,
|
||||||
yyGLRStack* yystackp]b4_user_formals[)
|
yyGLRStack* yystackp]b4_user_formals[)
|
||||||
@@ -1648,9 +1604,10 @@ yyresolveStates (yyGLRState* yys, int yyn,
|
|||||||
return yyok;
|
return yyok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resolve the states for the RHS of OPT, perform its user action, and return
|
/** Resolve the states for the RHS of YYOPT on *YYSTACKP, perform its
|
||||||
* the semantic value and location. Regardless of whether result = yyok, all
|
* user action, and return the semantic value and location in *YYVALP
|
||||||
* RHS states have been destroyed (assuming the user action destroys all RHS
|
* and *YYLOCP. Regardless of whether result = yyok, all RHS states
|
||||||
|
* have been destroyed (assuming the user action destroys all RHS
|
||||||
* semantic values if invoked). */
|
* semantic values if invoked). */
|
||||||
static YYRESULTTAG
|
static YYRESULTTAG
|
||||||
yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
|
yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
|
||||||
@@ -1724,10 +1681,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
|
|||||||
{
|
{
|
||||||
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
|
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
|
||||||
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
|
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
|
||||||
yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
|
yytokenName (yystos[yystates[yyi]->yylrState]));
|
||||||
else
|
else
|
||||||
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
|
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
|
||||||
yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
|
yytokenName (yystos[yystates[yyi]->yylrState]),
|
||||||
(unsigned long int) (yystates[yyi-1]->yyposn + 1),
|
(unsigned long int) (yystates[yyi-1]->yyposn + 1),
|
||||||
(unsigned long int) yystates[yyi]->yyposn);
|
(unsigned long int) yystates[yyi]->yyposn);
|
||||||
}
|
}
|
||||||
@@ -1757,9 +1714,9 @@ yyreportAmbiguity (yySemanticOption* yyx0,
|
|||||||
return yyabort;
|
return yyabort;
|
||||||
}]b4_locations_if([[
|
}]b4_locations_if([[
|
||||||
|
|
||||||
/** Starting at and including state S1, resolve the location for each of the
|
/** Resolve the locations for each of the YYN1 states in *YYSTACKP,
|
||||||
* previous N1 states that is unresolved. The first semantic option of a state
|
* ending at YYS1. Has no effect on previously resolved states.
|
||||||
* is always chosen. */
|
* The first semantic option of a state is always chosen. */
|
||||||
static void
|
static void
|
||||||
yyresolveLocations (yyGLRState* yys1, int yyn1,
|
yyresolveLocations (yyGLRState* yys1, int yyn1,
|
||||||
yyGLRStack *yystackp]b4_user_formals[)
|
yyGLRStack *yystackp]b4_user_formals[)
|
||||||
@@ -1813,11 +1770,12 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
|
|||||||
}
|
}
|
||||||
}]])[
|
}]])[
|
||||||
|
|
||||||
/** Resolve the ambiguity represented in state S, perform the indicated
|
/** Resolve the ambiguity represented in state YYS in *YYSTACKP,
|
||||||
* actions, and set the semantic value of S. If result != yyok, the chain of
|
* perform the indicated actions, and set the semantic value of YYS.
|
||||||
* semantic options in S has been cleared instead or it has been left
|
* If result != yyok, the chain of semantic options in YYS has been
|
||||||
* unmodified except that redundant options may have been removed. Regardless
|
* cleared instead or it has been left unmodified except that
|
||||||
* of whether result = yyok, S has been left with consistent data so that
|
* redundant options may have been removed. Regardless of whether
|
||||||
|
* result = yyok, YYS has been left with consistent data so that
|
||||||
* yydestroyGLRState can be invoked if necessary. */
|
* yydestroyGLRState can be invoked if necessary. */
|
||||||
static YYRESULTTAG
|
static YYRESULTTAG
|
||||||
yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
|
yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
|
||||||
@@ -1955,10 +1913,6 @@ static YYRESULTTAG
|
|||||||
yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||||
size_t yyposn]b4_pure_formals[)
|
size_t yyposn]b4_pure_formals[)
|
||||||
{
|
{
|
||||||
int yyaction;
|
|
||||||
const short int* yyconflicts;
|
|
||||||
yyRuleNum yyrule;
|
|
||||||
|
|
||||||
while (yystackp->yytops.yystates[yyk] != YY_NULL)
|
while (yystackp->yytops.yystates[yyk] != YY_NULL)
|
||||||
{
|
{
|
||||||
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
|
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
|
||||||
@@ -1969,7 +1923,8 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
|||||||
|
|
||||||
if (yyisDefaultedState (yystate))
|
if (yyisDefaultedState (yystate))
|
||||||
{
|
{
|
||||||
yyrule = yydefaultAction (yystate);
|
YYRESULTTAG yyflag;
|
||||||
|
yyRuleNum yyrule = yydefaultAction (yystate);
|
||||||
if (yyrule == 0)
|
if (yyrule == 0)
|
||||||
{
|
{
|
||||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||||
@@ -1977,11 +1932,25 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
|||||||
yymarkStackDeleted (yystackp, yyk);
|
yymarkStackDeleted (yystackp, yyk);
|
||||||
return yyok;
|
return yyok;
|
||||||
}
|
}
|
||||||
YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[));
|
yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[);
|
||||||
|
if (yyflag == yyerr)
|
||||||
|
{
|
||||||
|
YYDPRINTF ((stderr,
|
||||||
|
"Stack %lu dies "
|
||||||
|
"(predicate failure or explicit user error).\n",
|
||||||
|
(unsigned long int) yyk));
|
||||||
|
yymarkStackDeleted (yystackp, yyk);
|
||||||
|
return yyok;
|
||||||
|
}
|
||||||
|
if (yyflag != yyok)
|
||||||
|
return yyflag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yySymbol yytoken;
|
yySymbol yytoken;
|
||||||
|
int yyaction;
|
||||||
|
const short int* yyconflicts;
|
||||||
|
|
||||||
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
||||||
if (yychar == YYEMPTY)
|
if (yychar == YYEMPTY)
|
||||||
{
|
{
|
||||||
@@ -2004,14 +1973,25 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
|||||||
|
|
||||||
while (*yyconflicts != 0)
|
while (*yyconflicts != 0)
|
||||||
{
|
{
|
||||||
|
YYRESULTTAG yyflag;
|
||||||
size_t yynewStack = yysplitStack (yystackp, yyk);
|
size_t yynewStack = yysplitStack (yystackp, yyk);
|
||||||
YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
|
YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
|
||||||
(unsigned long int) yynewStack,
|
(unsigned long int) yynewStack,
|
||||||
(unsigned long int) yyk));
|
(unsigned long int) yyk));
|
||||||
YYCHK (yyglrReduce (yystackp, yynewStack,
|
yyflag = yyglrReduce (yystackp, yynewStack,
|
||||||
*yyconflicts, yyfalse]b4_user_args[));
|
*yyconflicts,
|
||||||
|
yyimmediate[*yyconflicts]]b4_user_args[);
|
||||||
|
if (yyflag == yyok)
|
||||||
YYCHK (yyprocessOneStack (yystackp, yynewStack,
|
YYCHK (yyprocessOneStack (yystackp, yynewStack,
|
||||||
yyposn]b4_pure_args[));
|
yyposn]b4_pure_args[));
|
||||||
|
else if (yyflag == yyerr)
|
||||||
|
{
|
||||||
|
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||||
|
(unsigned long int) yynewStack));
|
||||||
|
yymarkStackDeleted (yystackp, yynewStack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return yyflag;
|
||||||
yyconflicts += 1;
|
yyconflicts += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2025,8 +2005,21 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
YYCHK (yyglrReduce (yystackp, yyk, -yyaction,
|
{
|
||||||
yyfalse]b4_user_args[));
|
YYRESULTTAG yyflag = yyglrReduce (yystackp, yyk, -yyaction,
|
||||||
|
yyimmediate[-yyaction]]b4_user_args[);
|
||||||
|
if (yyflag == yyerr)
|
||||||
|
{
|
||||||
|
YYDPRINTF ((stderr,
|
||||||
|
"Stack %lu dies "
|
||||||
|
"(predicate failure or explicit user error).\n",
|
||||||
|
(unsigned long int) yyk));
|
||||||
|
yymarkStackDeleted (yystackp, yyk);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (yyflag != yyok)
|
||||||
|
return yyflag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return yyok;
|
return yyok;
|
||||||
@@ -2279,7 +2272,6 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
} \
|
} \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
/*----------.
|
/*----------.
|
||||||
| yyparse. |
|
| yyparse. |
|
||||||
`----------*/
|
`----------*/
|
||||||
@@ -2601,9 +2593,7 @@ yypdumpstack (yyGLRStack* yystackp)
|
|||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
]
|
]b4_epilogue[]dnl
|
||||||
|
|
||||||
b4_epilogue
|
|
||||||
dnl
|
dnl
|
||||||
dnl glr.cc produces its own header.
|
dnl glr.cc produces its own header.
|
||||||
dnl
|
dnl
|
||||||
|
|||||||
+11
-40
@@ -1,5 +1,3 @@
|
|||||||
-*- C -*-
|
|
||||||
|
|
||||||
# C++ GLR skeleton for Bison
|
# C++ GLR skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
|
||||||
@@ -29,7 +27,7 @@
|
|||||||
#
|
#
|
||||||
# The additional arguments are stored as members of the parser
|
# The additional arguments are stored as members of the parser
|
||||||
# object, yyparser. The C routines need to carry yyparser
|
# object, yyparser. The C routines need to carry yyparser
|
||||||
# throughout the C parser; that easy: just let yyparser become an
|
# throughout the C parser; that's easy: make yyparser an
|
||||||
# additional parse-param. But because the C++ skeleton needs to
|
# additional parse-param. But because the C++ skeleton needs to
|
||||||
# know the "real" original parse-param, we save them
|
# know the "real" original parse-param, we save them
|
||||||
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
|
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
|
||||||
@@ -39,14 +37,14 @@
|
|||||||
# The locations
|
# The locations
|
||||||
#
|
#
|
||||||
# We use location.cc just like lalr1.cc, but because glr.c stores
|
# We use location.cc just like lalr1.cc, but because glr.c stores
|
||||||
# the locations in a (C++) union, the position and location classes
|
# the locations in a union, the position and location classes
|
||||||
# must not have a constructor. Therefore, contrary to lalr1.cc, we
|
# must not have a constructor. Therefore, contrary to lalr1.cc, we
|
||||||
# must not define "b4_location_constructors". As a consequence the
|
# must not define "b4_location_constructors". As a consequence the
|
||||||
# user must initialize the first positions (in particular the
|
# user must initialize the first positions (in particular the
|
||||||
# filename member).
|
# filename member).
|
||||||
|
|
||||||
# We require a pure interface using locations.
|
# We require a pure interface using locations.
|
||||||
m4_define([b4_locations_flag], [1])
|
m4_define([b4_percent_define(locations)], [])
|
||||||
m4_define([b4_pure_flag], [1])
|
m4_define([b4_pure_flag], [1])
|
||||||
|
|
||||||
# The header is mandatory.
|
# The header is mandatory.
|
||||||
@@ -131,8 +129,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||||
:])[
|
:])[
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||||
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
|
||||||
#endif]b4_parse_param_cons[
|
#endif]b4_parse_param_cons[
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -164,7 +161,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
YYUSE (yyo);
|
YYUSE (yyo);
|
||||||
switch (yytype)
|
switch (yytype)
|
||||||
{
|
{
|
||||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
]b4_symbol_foreach([b4_symbol_printer])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -199,19 +196,18 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
]b4_parser_class_name[::debug_level_type
|
]b4_parser_class_name[::debug_level_type
|
||||||
]b4_parser_class_name[::debug_level () const
|
]b4_parser_class_name[::debug_level () const
|
||||||
{
|
{
|
||||||
return yydebug_;
|
return yydebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
||||||
{
|
{
|
||||||
yydebug_ = l;
|
yydebug = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
]m4_popdef([b4_parse_param])dnl
|
]m4_popdef([b4_parse_param])dnl
|
||||||
b4_namespace_close[
|
b4_namespace_close[
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +225,7 @@ m4_popdef([b4_parse_param])
|
|||||||
m4_divert_push(0)
|
m4_divert_push(0)
|
||||||
@output(b4_spec_defines_file@)@
|
@output(b4_spec_defines_file@)@
|
||||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||||
[2002-2006, 2009-2012])[
|
[2002-2012])[
|
||||||
|
|
||||||
/* C++ GLR parser skeleton written by Akim Demaille. */
|
/* C++ GLR parser skeleton written by Akim Demaille. */
|
||||||
|
|
||||||
@@ -237,6 +233,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
|
|
||||||
]b4_percent_code_get([[requires]])[
|
]b4_percent_code_get([[requires]])[
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
]b4_percent_define_ifdef([[location_type]], [],
|
]b4_percent_define_ifdef([[location_type]], [],
|
||||||
@@ -249,29 +246,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
class ]b4_parser_class_name[
|
class ]b4_parser_class_name[
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Symbol semantic values.
|
]b4_public_types_declare[
|
||||||
# ifndef ]b4_api_PREFIX[STYPE
|
|
||||||
]m4_ifdef([b4_stype],
|
|
||||||
[ union semantic_type
|
|
||||||
{
|
|
||||||
b4_user_stype
|
|
||||||
};],
|
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
|
||||||
[[ typedef int semantic_type;]],
|
|
||||||
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[
|
|
||||||
# else
|
|
||||||
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
|
||||||
# endif
|
|
||||||
/// Symbol locations.
|
|
||||||
typedef ]b4_percent_define_get([[location_type]],
|
|
||||||
[[location]])[ location_type;
|
|
||||||
/// Tokens.
|
|
||||||
struct token
|
|
||||||
{
|
|
||||||
]b4_token_enums(b4_tokens)[
|
|
||||||
};
|
|
||||||
/// Token type.
|
|
||||||
typedef token::yytokentype token_type;
|
|
||||||
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
||||||
@@ -293,14 +268,11 @@ b4_user_stype
|
|||||||
/// 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);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Report a syntax error.
|
/// Report a syntax error.
|
||||||
/// \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.
|
||||||
virtual void error (const location_type& loc, const std::string& msg);
|
virtual void error (const location_type& loc, const std::string& msg);
|
||||||
private:
|
|
||||||
|
|
||||||
# if ]b4_api_PREFIX[DEBUG
|
# if ]b4_api_PREFIX[DEBUG
|
||||||
public:
|
public:
|
||||||
@@ -320,7 +292,6 @@ b4_user_stype
|
|||||||
const location_type* yylocationp);
|
const location_type* yylocationp);
|
||||||
private:
|
private:
|
||||||
/* Debugging. */
|
/* Debugging. */
|
||||||
int yydebug_;
|
|
||||||
std::ostream* yycdebug_;
|
std::ostream* yycdebug_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -329,7 +300,7 @@ b4_user_stype
|
|||||||
|
|
||||||
]dnl Redirections for glr.c.
|
]dnl Redirections for glr.c.
|
||||||
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||||
[b4_token_defines(b4_tokens)])
|
[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_name[::semantic_type
|
||||||
|
|||||||
+54
-26
@@ -117,27 +117,45 @@ m4_define([b4_int_type_for],
|
|||||||
m4_define([b4_null], [null])
|
m4_define([b4_null], [null])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
||||||
|
# -------------------------------------------------------
|
||||||
|
m4_define([b4_typed_parser_table_define],
|
||||||
|
[m4_ifval([$4], [b4_comment([$4])
|
||||||
|
])dnl
|
||||||
|
[private static final ]$1[ yy$2_[] = yy$2_init();
|
||||||
|
private static final ]$1[[] yy$2_init()
|
||||||
|
{
|
||||||
|
return new ]$1[[]
|
||||||
|
{
|
||||||
|
]$3[
|
||||||
|
};
|
||||||
|
}]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
||||||
|
#-----------------------------------------------------
|
||||||
|
m4_define([b4_integral_parser_table_define],
|
||||||
|
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
## Assigning token numbers. ##
|
## Assigning token numbers. ##
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
# b4_token_enum(TOKEN-NUM)
|
||||||
# ---------------------------------------
|
# ------------------------
|
||||||
# Output the definition of this token as an enum.
|
# Output the definition of this token as an enum.
|
||||||
m4_define([b4_token_enum],
|
m4_define([b4_token_enum],
|
||||||
[ /** Token number, to be returned by the scanner. */
|
[b4_token_format([ /** Token number, to be returned by the scanner. */
|
||||||
public static final int $1 = $2;
|
static final int %s = %s;
|
||||||
])
|
], [$1])])
|
||||||
|
|
||||||
|
# b4_token_enums
|
||||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# --------------
|
||||||
# -----------------------------------------------------
|
|
||||||
# Output the definition of the tokens (if there are) as enums.
|
# Output the definition of the tokens (if there are) as enums.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[m4_if([$#$1], [1], [],
|
[b4_any_token_visible_if([/* Tokens. */
|
||||||
[/* Tokens. */
|
b4_symbol_foreach([b4_token_enum])])])
|
||||||
m4_map([b4_token_enum], [$@])])
|
|
||||||
])
|
|
||||||
|
|
||||||
# b4-case(ID, CODE)
|
# b4-case(ID, CODE)
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -148,30 +166,40 @@ m4_define([b4_case], [ case $1:
|
|||||||
break;
|
break;
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# b4_predicate_case(LABEL, CONDITIONS)
|
||||||
|
# ------------------------------------
|
||||||
|
m4_define([b4_predicate_case], [ case $1:
|
||||||
|
if (! ($2)) YYERROR;
|
||||||
|
break;
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
||||||
b4_percent_define_default([[stype]], [[Object]])])
|
b4_percent_define_default([[stype]], [[Object]])
|
||||||
|
|
||||||
# %name-prefix
|
# %name-prefix
|
||||||
m4_define_default([b4_prefix], [[YY]])
|
m4_define_default([b4_prefix], [[YY]])
|
||||||
|
|
||||||
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])])
|
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])
|
||||||
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
|
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
|
||||||
|
|
||||||
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]])])
|
||||||
|
|
||||||
b4_percent_define_default([[throws]], [])])
|
b4_percent_define_default([[throws]], [])
|
||||||
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
||||||
|
|
||||||
b4_percent_define_default([[location_type]], [Location])])
|
b4_percent_define_default([[init_throws]], [])
|
||||||
|
m4_define([b4_init_throws], [b4_percent_define_get([[init_throws]])])
|
||||||
|
|
||||||
|
b4_percent_define_default([[location_type]], [Location])
|
||||||
m4_define([b4_location_type], [b4_percent_define_get([[location_type]])])
|
m4_define([b4_location_type], [b4_percent_define_get([[location_type]])])
|
||||||
|
|
||||||
b4_percent_define_default([[position_type]], [Position])])
|
b4_percent_define_default([[position_type]], [Position])
|
||||||
m4_define([b4_position_type], [b4_percent_define_get([[position_type]])])
|
m4_define([b4_position_type], [b4_percent_define_get([[position_type]])])
|
||||||
|
|
||||||
|
|
||||||
@@ -218,12 +246,12 @@ m4_define([b4_rhs_location],
|
|||||||
# it to be single quoted. Same for b4_parse_param.
|
# it to be single quoted. Same for b4_parse_param.
|
||||||
|
|
||||||
# TODO: should be in bison.m4
|
# TODO: should be in bison.m4
|
||||||
m4_define_default([b4_lex_param], [[]]))
|
m4_define_default([b4_lex_param], [[]])
|
||||||
m4_define([b4_lex_param], b4_lex_param))
|
m4_define([b4_lex_param], b4_lex_param)
|
||||||
m4_define([b4_parse_param], b4_parse_param))
|
m4_define([b4_parse_param], b4_parse_param)
|
||||||
|
|
||||||
# b4_lex_param_decl
|
# b4_lex_param_decl
|
||||||
# -------------------
|
# -----------------
|
||||||
# Extra formal arguments of the constructor.
|
# Extra formal arguments of the constructor.
|
||||||
m4_define([b4_lex_param_decl],
|
m4_define([b4_lex_param_decl],
|
||||||
[m4_ifset([b4_lex_param],
|
[m4_ifset([b4_lex_param],
|
||||||
@@ -232,7 +260,7 @@ m4_define([b4_lex_param_decl],
|
|||||||
[$1])])
|
[$1])])
|
||||||
|
|
||||||
m4_define([b4_param_decls],
|
m4_define([b4_param_decls],
|
||||||
[m4_map([b4_param_decl], [$@])])
|
[m4_map_args([b4_param_decl], $@)])
|
||||||
m4_define([b4_param_decl], [, $1])
|
m4_define([b4_param_decl], [, $1])
|
||||||
|
|
||||||
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||||
@@ -251,7 +279,7 @@ m4_define([b4_parse_param_decl],
|
|||||||
|
|
||||||
|
|
||||||
# b4_lex_param_call
|
# b4_lex_param_call
|
||||||
# -------------------
|
# -----------------
|
||||||
# Delegating the lexer parameters to the lexer constructor.
|
# Delegating the lexer parameters to the lexer constructor.
|
||||||
m4_define([b4_lex_param_call],
|
m4_define([b4_lex_param_call],
|
||||||
[m4_ifset([b4_lex_param],
|
[m4_ifset([b4_lex_param],
|
||||||
@@ -259,7 +287,7 @@ m4_define([b4_lex_param_call],
|
|||||||
b4_param_calls(b4_lex_param))],
|
b4_param_calls(b4_lex_param))],
|
||||||
[$1])])
|
[$1])])
|
||||||
m4_define([b4_param_calls],
|
m4_define([b4_param_calls],
|
||||||
[m4_map([b4_param_call], [$@])])
|
[m4_map_args([b4_param_call], $@)])
|
||||||
m4_define([b4_param_call], [, $2])
|
m4_define([b4_param_call], [, $2])
|
||||||
|
|
||||||
|
|
||||||
@@ -272,7 +300,7 @@ m4_define([b4_parse_param_cons],
|
|||||||
[b4_constructor_calls(b4_parse_param)])])
|
[b4_constructor_calls(b4_parse_param)])])
|
||||||
|
|
||||||
m4_define([b4_constructor_calls],
|
m4_define([b4_constructor_calls],
|
||||||
[m4_map([b4_constructor_call], [$@])])
|
[m4_map_args([b4_constructor_call], $@)])
|
||||||
m4_define([b4_constructor_call],
|
m4_define([b4_constructor_call],
|
||||||
[this.$2 = $2;
|
[this.$2 = $2;
|
||||||
])
|
])
|
||||||
|
|||||||
+459
-459
File diff suppressed because it is too large
Load Diff
+90
-136
@@ -17,10 +17,18 @@
|
|||||||
|
|
||||||
m4_include(b4_pkgdatadir/[java.m4])
|
m4_include(b4_pkgdatadir/[java.m4])
|
||||||
|
|
||||||
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])])
|
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
|
||||||
m4_ifval(m4_defn([b4_symbol_destructors]),
|
[b4_skeleton])])
|
||||||
[b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
|
|
||||||
[])
|
# We don't 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],
|
||||||
|
[b4_symbol_if([$1], [has_destructor],
|
||||||
|
[b4_fatal([%s: %s: %%destructor does not make sense in Java],
|
||||||
|
[b4_skeleton],
|
||||||
|
[b4_symbol_action_location([$1], [destructor])])])])
|
||||||
|
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
||||||
|
|
||||||
m4_divert_push(0)dnl
|
m4_divert_push(0)dnl
|
||||||
@output(b4_parser_file_name@)@
|
@output(b4_parser_file_name@)@
|
||||||
@@ -29,14 +37,16 @@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
|||||||
|
|
||||||
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
|
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
|
||||||
])[/* First part of user declarations. */
|
])[/* First part of user declarations. */
|
||||||
]b4_pre_prologue
|
]b4_user_pre_prologue
|
||||||
|
b4_user_post_prologue
|
||||||
b4_percent_code_get([[imports]])
|
b4_percent_code_get([[imports]])
|
||||||
[/**
|
[/**
|
||||||
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
* 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_public_if([public ])dnl
|
]b4_percent_define_get3([annotations], [], [ ])dnl
|
||||||
|
b4_public_if([public ])dnl
|
||||||
b4_abstract_if([abstract ])dnl
|
b4_abstract_if([abstract ])dnl
|
||||||
b4_final_if([final ])dnl
|
b4_final_if([final ])dnl
|
||||||
b4_strictfp_if([strictfp ])dnl
|
b4_strictfp_if([strictfp ])dnl
|
||||||
@@ -45,9 +55,22 @@ b4_percent_define_get3([extends], [ extends ])dnl
|
|||||||
b4_percent_define_get3([implements], [ implements ])[
|
b4_percent_define_get3([implements], [ implements ])[
|
||||||
{
|
{
|
||||||
]b4_identification[
|
]b4_identification[
|
||||||
|
]b4_error_verbose_if([[
|
||||||
/** True if verbose error messages are enabled. */
|
/** True if verbose error messages are enabled. */
|
||||||
public boolean errorVerbose = ]b4_flag_value([error_verbose]);
|
private boolean yyErrorVerbose = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether verbose error messages are enabled.
|
||||||
|
*/
|
||||||
|
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the verbosity of error messages.
|
||||||
|
* @@param verbose True to request verbose error messages.
|
||||||
|
*/
|
||||||
|
public final void setErrorVerbose(boolean verbose)
|
||||||
|
{ yyErrorVerbose = verbose; }
|
||||||
|
]])
|
||||||
|
|
||||||
b4_locations_if([[
|
b4_locations_if([[
|
||||||
/**
|
/**
|
||||||
@@ -93,11 +116,6 @@ b4_locations_if([[
|
|||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
[ /** Token returned by the scanner to signal the end of its input. */
|
|
||||||
public static final int EOF = 0;]
|
|
||||||
|
|
||||||
b4_token_enums(b4_tokens)
|
|
||||||
|
|
||||||
b4_locations_if([[
|
b4_locations_if([[
|
||||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
||||||
{
|
{
|
||||||
@@ -112,6 +130,11 @@ b4_token_enums(b4_tokens)
|
|||||||
* parser <tt>]b4_parser_class_name[</tt>.
|
* parser <tt>]b4_parser_class_name[</tt>.
|
||||||
*/
|
*/
|
||||||
public interface Lexer {
|
public interface Lexer {
|
||||||
|
/** Token returned by the scanner to signal the end of its input. */
|
||||||
|
public static final int EOF = 0;
|
||||||
|
|
||||||
|
]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. */
|
||||||
@@ -140,8 +163,8 @@ b4_token_enums(b4_tokens)
|
|||||||
*
|
*
|
||||||
* ]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 s The string for the error message. */
|
* @@param msg The string for the error message. */
|
||||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s);]
|
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 {
|
||||||
@@ -157,7 +180,9 @@ 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])[) {
|
public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
|
||||||
|
{
|
||||||
|
]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[
|
||||||
}
|
}
|
||||||
@@ -167,7 +192,9 @@ b4_lexer_if([[
|
|||||||
* 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_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
||||||
|
{
|
||||||
|
]b4_percent_code_get([[init]])[
|
||||||
this.yylexer = yylexer;
|
this.yylexer = yylexer;
|
||||||
]b4_parse_param_cons[
|
]b4_parse_param_cons[
|
||||||
}
|
}
|
||||||
@@ -201,20 +228,35 @@ b4_lexer_if([[
|
|||||||
*/
|
*/
|
||||||
public final void setDebugLevel(int level) { yydebug = level; }
|
public final void setDebugLevel(int level) { yydebug = level; }
|
||||||
|
|
||||||
private final int yylex () ]b4_maybe_throws([b4_lex_throws]) [{
|
/**
|
||||||
return yylexer.yylex ();
|
* Print an error message via the lexer.
|
||||||
|
*]b4_locations_if([[ Use a <code>null</code> location.]])[
|
||||||
|
* @@param msg The error message.
|
||||||
|
*/
|
||||||
|
public final void yyerror (String msg)
|
||||||
|
{
|
||||||
|
yylexer.yyerror (]b4_locations_if([[(]b4_location_type[)null, ]])[msg);
|
||||||
}
|
}
|
||||||
protected final void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s) {
|
]b4_locations_if([[
|
||||||
yylexer.yyerror (]b4_locations_if([loc, ])[s);
|
/**
|
||||||
|
* Print an error message via the lexer.
|
||||||
|
* @@param loc The location associated with the message.
|
||||||
|
* @@param msg The error message.
|
||||||
|
*/
|
||||||
|
public final void yyerror (]b4_location_type[ loc, String msg)
|
||||||
|
{
|
||||||
|
yylexer.yyerror (loc, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([
|
/**
|
||||||
protected final void yyerror (String s) {
|
* Print an error message via the lexer.
|
||||||
yylexer.yyerror ((]b4_location_type[)null, s);
|
* @@param pos The position associated with the message.
|
||||||
}
|
* @@param msg The error message.
|
||||||
protected final void yyerror (]b4_position_type[ loc, String s) {
|
*/
|
||||||
yylexer.yyerror (new ]b4_location_type[ (loc), s);
|
public final void yyerror (]b4_position_type[ pos, String msg)
|
||||||
}])
|
{
|
||||||
|
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
|
||||||
|
}]])
|
||||||
|
|
||||||
[protected final void yycdebug (String s) {
|
[protected final void yycdebug (String s) {
|
||||||
if (yydebug > 0)
|
if (yydebug > 0)
|
||||||
@@ -370,6 +412,7 @@ b4_lexer_if([[
|
|||||||
return YYNEWSTATE;
|
return YYNEWSTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]b4_error_verbose_if([[
|
||||||
/* Return YYSTR after stripping away unnecessary quotes and
|
/* Return YYSTR after stripping away unnecessary quotes and
|
||||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||||
that double-quoting is unnecessary unless the string contains an
|
that double-quoting is unnecessary unless the string contains an
|
||||||
@@ -404,6 +447,7 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
@@ -495,7 +539,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
if (yychar == yyempty_)
|
if (yychar == yyempty_)
|
||||||
{
|
{
|
||||||
yycdebug ("Reading a token: ");
|
yycdebug ("Reading a token: ");
|
||||||
yychar = yylex ();]
|
yychar = yylexer.yylex ();]
|
||||||
b4_locations_if([[
|
b4_locations_if([[
|
||||||
yylloc = new ]b4_location_type[(yylexer.getStartPos (),
|
yylloc = new ]b4_location_type[(yylexer.getStartPos (),
|
||||||
yylexer.getEndPos ());]])
|
yylexer.getEndPos ());]])
|
||||||
@@ -503,9 +547,9 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert token to internal form. */
|
/* Convert token to internal form. */
|
||||||
if (yychar <= EOF)
|
if (yychar <= Lexer.EOF)
|
||||||
{
|
{
|
||||||
yychar = yytoken = EOF;
|
yychar = yytoken = Lexer.EOF;
|
||||||
yycdebug ("Now at end of input.\n");
|
yycdebug ("Now at end of input.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -592,10 +636,10 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
/* 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 <= EOF)
|
if (yychar <= Lexer.EOF)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == EOF)
|
if (yychar == Lexer.EOF)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -680,8 +724,8 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
|
|
||||||
// Generate an error message.
|
// Generate an error message.
|
||||||
private String yysyntax_error (int yystate, int tok)
|
private String yysyntax_error (int yystate, int tok)
|
||||||
{
|
{]b4_error_verbose_if([[
|
||||||
if (errorVerbose)
|
if (yyErrorVerbose)
|
||||||
{
|
{
|
||||||
/* There are many possibilities here to consider:
|
/* There are many possibilities here to consider:
|
||||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||||
@@ -752,7 +796,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
return res.toString ();
|
return res.toString ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
return "syntax error";
|
return "syntax error";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -774,107 +818,20 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
return yyvalue == yytable_ninf_;
|
return yyvalue == yytable_ninf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
|
||||||
STATE-NUM. */
|
|
||||||
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
||||||
private static final ]b4_int_type_for([b4_pact])[ yypact_[] =
|
|
||||||
{
|
|
||||||
]b4_pact[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYDEFACT[S] -- default reduction number in state S. Performed when
|
|
||||||
YYTABLE doesn't specify something else to do. Zero means the
|
|
||||||
default is an error. */
|
|
||||||
private static final ]b4_int_type_for([b4_defact])[ yydefact_[] =
|
|
||||||
{
|
|
||||||
]b4_defact[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPGOTO[NTERM-NUM]. */
|
|
||||||
private static final ]b4_int_type_for([b4_pgoto])[ yypgoto_[] =
|
|
||||||
{
|
|
||||||
]b4_pgoto[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYDEFGOTO[NTERM-NUM]. */
|
|
||||||
private static final ]b4_int_type_for([b4_defgoto])[
|
|
||||||
yydefgoto_[] =
|
|
||||||
{
|
|
||||||
]b4_defgoto[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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 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[;
|
||||||
private static final ]b4_int_type_for([b4_table])[
|
|
||||||
yytable_[] =
|
|
||||||
{
|
|
||||||
]b4_table[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYCHECK. */
|
]b4_parser_tables_define[
|
||||||
private static final ]b4_int_type_for([b4_check])[
|
]b4_integral_parser_table_define([token_number], [b4_toknum],
|
||||||
yycheck_[] =
|
[TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
||||||
{
|
to YYLEX-NUM.])[
|
||||||
]b4_check[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
|
||||||
symbol of state STATE-NUM. */
|
|
||||||
private static final ]b4_int_type_for([b4_stos])[
|
|
||||||
yystos_[] =
|
|
||||||
{
|
|
||||||
]b4_stos[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
|
||||||
to YYLEX-NUM. */
|
|
||||||
private static final ]b4_int_type_for([b4_toknum])[
|
|
||||||
yytoken_number_[] =
|
|
||||||
{
|
|
||||||
]b4_toknum[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
|
||||||
private static final ]b4_int_type_for([b4_r1])[
|
|
||||||
yyr1_[] =
|
|
||||||
{
|
|
||||||
]b4_r1[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
|
||||||
private static final ]b4_int_type_for([b4_r2])[
|
|
||||||
yyr2_[] =
|
|
||||||
{
|
|
||||||
]b4_r2[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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. */
|
||||||
private static final String yytname_[] =
|
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||||
{
|
|
||||||
]b4_tname[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
]b4_integral_parser_table_define([rline], [b4_rline],
|
||||||
private static final ]b4_int_type_for([b4_rhs])[ yyrhs_[] =
|
[YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
|
||||||
{
|
|
||||||
]b4_rhs[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
|
||||||
YYRHS. */
|
|
||||||
private static final ]b4_int_type_for([b4_prhs])[ yyprhs_[] =
|
|
||||||
{
|
|
||||||
]b4_prhs[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
|
||||||
private static final ]b4_int_type_for([b4_rline])[ yyrline_[] =
|
|
||||||
{
|
|
||||||
]b4_rline[
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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 yy_reduce_print (int yyrule, YYStack yystack)
|
||||||
@@ -891,16 +848,13 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
/* 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) + " =",
|
yy_symbol_print (" $" + (yyi + 1) + " =",
|
||||||
yyrhs_[yyprhs_[yyrule] + yyi],
|
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
||||||
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
]b4_rhs_value(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. */
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_table_[] =
|
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||||
{
|
|
||||||
]b4_translate[
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||||
{
|
{
|
||||||
@@ -926,5 +880,5 @@ b4_percent_code_get[]dnl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b4_epilogue
|
b4_epilogue[]dnl
|
||||||
m4_divert_pop(0)dnl
|
m4_divert_pop(0)dnl
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
## Copyright (C) 2002, 2005-2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
dist_pkgdata_DATA = \
|
||||||
|
data/README \
|
||||||
|
data/bison.m4 \
|
||||||
|
data/c++-skel.m4 \
|
||||||
|
data/c++.m4 \
|
||||||
|
data/c-skel.m4 \
|
||||||
|
data/c.m4 \
|
||||||
|
data/glr.c \
|
||||||
|
data/glr.cc \
|
||||||
|
data/java-skel.m4 \
|
||||||
|
data/java.m4 \
|
||||||
|
data/lalr1.cc \
|
||||||
|
data/lalr1.java \
|
||||||
|
data/location.cc \
|
||||||
|
data/stack.hh \
|
||||||
|
data/variant.hh \
|
||||||
|
data/yacc.c
|
||||||
|
|
||||||
|
m4sugardir = $(pkgdatadir)/m4sugar
|
||||||
|
dist_m4sugar_DATA = \
|
||||||
|
data/m4sugar/foreach.m4 \
|
||||||
|
data/m4sugar/m4sugar.m4
|
||||||
|
|
||||||
|
xsltdir = $(pkgdatadir)/xslt
|
||||||
|
dist_xslt_DATA = \
|
||||||
|
data/xslt/bison.xsl \
|
||||||
|
data/xslt/xml2dot.xsl \
|
||||||
|
data/xslt/xml2text.xsl \
|
||||||
|
data/xslt/xml2xhtml.xsl
|
||||||
+7
-5
@@ -1,6 +1,6 @@
|
|||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2012 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,12 +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_pushdef([b4_copyright_years],
|
||||||
|
[2002-2012])
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
# We do want M4 expansion after # for CPP macros.
|
||||||
m4_changecom()
|
m4_changecom()
|
||||||
m4_divert_push(0)dnl
|
m4_divert_push(0)dnl
|
||||||
@output(b4_dir_prefix[]position.hh@)@
|
@output(b4_dir_prefix[]position.hh@)@
|
||||||
b4_copyright([Positions for Bison parsers in C++],
|
b4_copyright([Positions for Bison parsers in C++])[
|
||||||
[2002-2007, 2009-2012])[
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** \file ]b4_dir_prefix[position.hh
|
** \file ]b4_dir_prefix[position.hh
|
||||||
@@ -149,8 +151,7 @@ b4_copyright([Positions for Bison parsers in C++],
|
|||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
||||||
@output(b4_dir_prefix[]location.hh@)@
|
@output(b4_dir_prefix[]location.hh@)@
|
||||||
b4_copyright([Locations for Bison parsers in C++],
|
b4_copyright([Locations for Bison parsers in C++])[
|
||||||
[2002-2007, 2009-2012])[
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** \file ]b4_dir_prefix[location.hh
|
** \file ]b4_dir_prefix[location.hh
|
||||||
@@ -295,4 +296,5 @@ b4_copyright([Locations for Bison parsers in C++],
|
|||||||
|
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
||||||
m4_divert_pop(0)
|
m4_divert_pop(0)
|
||||||
|
m4_popdef([b4_copyright_years])dnl
|
||||||
m4_changecom([#])
|
m4_changecom([#])
|
||||||
|
|||||||
+21
-8
@@ -22,8 +22,7 @@ m4_pushdef([b4_copyright_years],
|
|||||||
m4_changecom()
|
m4_changecom()
|
||||||
m4_divert_push(0)dnl
|
m4_divert_push(0)dnl
|
||||||
@output(b4_dir_prefix[]stack.hh@)@
|
@output(b4_dir_prefix[]stack.hh@)@
|
||||||
b4_copyright([Stack handling for Bison parsers in C++],
|
b4_copyright([Stack handling for Bison parsers in C++])[
|
||||||
[2002-2012])[
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** \file ]b4_dir_prefix[stack.hh
|
** \file ]b4_dir_prefix[stack.hh
|
||||||
@@ -43,11 +42,13 @@ b4_copyright([Stack handling for Bison parsers in C++],
|
|||||||
typedef typename S::reverse_iterator iterator;
|
typedef typename S::reverse_iterator iterator;
|
||||||
typedef typename S::const_reverse_iterator const_iterator;
|
typedef typename S::const_reverse_iterator const_iterator;
|
||||||
|
|
||||||
stack () : seq_ ()
|
stack ()
|
||||||
|
: seq_ ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
stack (unsigned int n) : seq_ (n)
|
stack (unsigned int n)
|
||||||
|
: seq_ (n)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,16 +82,28 @@ b4_copyright([Stack handling for Bison parsers in C++],
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
unsigned int
|
typename S::size_type
|
||||||
height () const
|
size () const
|
||||||
{
|
{
|
||||||
return seq_.size ();
|
return seq_.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const_iterator begin () const { return seq_.rbegin (); }
|
inline
|
||||||
inline const_iterator end () const { return seq_.rend (); }
|
const_iterator
|
||||||
|
begin () const
|
||||||
|
{
|
||||||
|
return seq_.rbegin ();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
const_iterator
|
||||||
|
end () const
|
||||||
|
{
|
||||||
|
return seq_.rend ();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// The wrapped container.
|
||||||
S seq_;
|
S seq_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+277
@@ -0,0 +1,277 @@
|
|||||||
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
|
# Copyright (C) 2002-2012 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-NUM)
|
||||||
|
# ---------------------------
|
||||||
|
# A comment describing this symbol.
|
||||||
|
m4_define([b4_char_sizeof_],
|
||||||
|
[ // b4_symbol([$1], [tag])
|
||||||
|
])
|
||||||
|
|
||||||
|
# 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_args([b4_char_sizeof_], $@)dnl
|
||||||
|
char _b4_char_sizeof_dummy@{sizeof([b4_symbol([$1], [type])])@};
|
||||||
|
])])
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
/// Whether something is contained.
|
||||||
|
bool built;
|
||||||
|
])[
|
||||||
|
/// Empty construction.
|
||||||
|
inline
|
||||||
|
variant ()]b4_parse_assert_if([
|
||||||
|
: built (false)])[
|
||||||
|
{}
|
||||||
|
|
||||||
|
/// Instantiate a \a T in here.
|
||||||
|
template <typename T>
|
||||||
|
inline T&
|
||||||
|
build ()
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
assert (!built);
|
||||||
|
built = true;])[
|
||||||
|
return *new (buffer.raw) T;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Instantiate a \a T in here from \a t.
|
||||||
|
template <typename T>
|
||||||
|
inline T&
|
||||||
|
build (const T& t)
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
assert(!built);
|
||||||
|
built = true;])[
|
||||||
|
return *new (buffer.raw) T(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Construct and fill.
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
variant (const T& t)]b4_parse_assert_if([
|
||||||
|
: built (true)])[
|
||||||
|
{
|
||||||
|
new (buffer.raw) T(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Accessor to a built \a T.
|
||||||
|
template <typename T>
|
||||||
|
inline T&
|
||||||
|
as ()
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
assert (built);])[
|
||||||
|
return reinterpret_cast<T&>(buffer.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Const accessor to a built \a T (for %printer).
|
||||||
|
template <typename T>
|
||||||
|
inline const T&
|
||||||
|
as () const
|
||||||
|
{]b4_parse_assert_if([
|
||||||
|
assert(built);])[
|
||||||
|
return reinterpret_cast<const T&>(buffer.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Swap the content with \a other.
|
||||||
|
template <typename T>
|
||||||
|
inline void
|
||||||
|
swap (variant<S>& other)
|
||||||
|
{
|
||||||
|
std::swap (as<T>(), other.as<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assign the content of \a other to this.
|
||||||
|
/// Destroys \a other.
|
||||||
|
template <typename T>
|
||||||
|
inline void
|
||||||
|
build (variant<S>& other)
|
||||||
|
{
|
||||||
|
build<T>();
|
||||||
|
swap<T>(other);
|
||||||
|
other.destroy<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destroy the stored \a T.
|
||||||
|
template <typename T>
|
||||||
|
inline void
|
||||||
|
destroy ()
|
||||||
|
{
|
||||||
|
as<T>().~T();]b4_parse_assert_if([
|
||||||
|
built = false;])[
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A buffer large enough to store any of the semantic values.
|
||||||
|
/// Long double is chosen as it has the strongest alignment
|
||||||
|
/// constraints.
|
||||||
|
union
|
||||||
|
{
|
||||||
|
long double align_me;
|
||||||
|
char raw[S];
|
||||||
|
} buffer;
|
||||||
|
};
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
## -------------------------- ##
|
||||||
|
## Adjustments for variants. ##
|
||||||
|
## -------------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_semantic_type_declare
|
||||||
|
# ------------------------
|
||||||
|
# Declare semantic_type.
|
||||||
|
m4_define([b4_semantic_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;])
|
||||||
|
|
||||||
|
|
||||||
|
# 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 inline
|
||||||
|
symbol_type
|
||||||
|
make_[]b4_symbol_([$1], [id]) (dnl
|
||||||
|
b4_args(b4_symbol_if([$1], [has_type],
|
||||||
|
[const b4_symbol([$1], [type])& v]),
|
||||||
|
b4_locations_if([const 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],
|
||||||
|
[ b4_parser_class_name::symbol_type
|
||||||
|
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
|
||||||
|
b4_args(b4_symbol_if([$1], [has_type],
|
||||||
|
[const b4_symbol([$1], [type])& v]),
|
||||||
|
b4_locations_if([const location_type& l])))
|
||||||
|
{
|
||||||
|
return symbol_type (b4_args([token::b4_symbol([$1], [id])],
|
||||||
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
|
b4_locations_if([l])));
|
||||||
|
}
|
||||||
|
|
||||||
|
])])])
|
||||||
|
|
||||||
|
|
||||||
|
# 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_])])
|
||||||
+30
-98
@@ -1,10 +1,12 @@
|
|||||||
-*- C -*-
|
-*- C -*-
|
||||||
|
|
||||||
# Yacc compatible skeleton for Bison
|
# Yacc compatible skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation,
|
# Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation,
|
||||||
# Inc.
|
# Inc.
|
||||||
|
|
||||||
|
m4_pushdef([b4_copyright_years],
|
||||||
|
[1984, 1989-1990, 2000-2012])
|
||||||
|
|
||||||
# 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
|
||||||
@@ -127,7 +129,7 @@ m4_define([b4_int_type],
|
|||||||
# --------------------
|
# --------------------
|
||||||
# Expansion of $<TYPE>$.
|
# Expansion of $<TYPE>$.
|
||||||
m4_define([b4_lhs_value],
|
m4_define([b4_lhs_value],
|
||||||
[(yyval[]m4_ifval([$1], [.$1]))])
|
[b4_symbol_value(yyval, [$1])])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||||
@@ -135,7 +137,7 @@ m4_define([b4_lhs_value],
|
|||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
|
[b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -155,7 +157,7 @@ m4_define([b4_lhs_location],
|
|||||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||||
# on RHS.
|
# on RHS.
|
||||||
m4_define([b4_rhs_location],
|
m4_define([b4_rhs_location],
|
||||||
[(yylsp@{($2) - ($1)@})])
|
[(yylsp@{b4_subtract([$2], [$1])@})])
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
@@ -282,7 +284,7 @@ m4_define([b4_shared_declarations],
|
|||||||
[b4_cpp_guard_open([b4_spec_defines_file])[
|
[b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_declare_yydebug[
|
]b4_declare_yydebug[
|
||||||
]b4_percent_code_get([[requires]])[
|
]b4_percent_code_get([[requires]])[
|
||||||
]b4_token_enums_defines(b4_tokens)[
|
]b4_token_enums_defines[
|
||||||
]b4_declare_yylstype[
|
]b4_declare_yylstype[
|
||||||
]b4_declare_yyparse[
|
]b4_declare_yyparse[
|
||||||
]b4_percent_code_get([[provides]])[
|
]b4_percent_code_get([[provides]])[
|
||||||
@@ -297,8 +299,7 @@ m4_define([b4_shared_declarations],
|
|||||||
m4_changecom()
|
m4_changecom()
|
||||||
m4_divert_push(0)dnl
|
m4_divert_push(0)dnl
|
||||||
@output(b4_parser_file_name@)@
|
@output(b4_parser_file_name@)@
|
||||||
b4_copyright([Bison implementation for Yacc-like parsers in C],
|
b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||||
[1984, 1989-1990, 2000-2012])[
|
|
||||||
|
|
||||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||||
simplifying the original so-called "semantic" parser. */
|
simplifying the original so-called "semantic" parser. */
|
||||||
@@ -342,7 +343,7 @@ m4_if(b4_api_prefix, [yy], [],
|
|||||||
# undef YYERROR_VERBOSE
|
# undef YYERROR_VERBOSE
|
||||||
# define YYERROR_VERBOSE 1
|
# define YYERROR_VERBOSE 1
|
||||||
#else
|
#else
|
||||||
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* In a future release of Bison, this section will be replaced
|
/* In a future release of Bison, this section will be replaced
|
||||||
@@ -574,41 +575,27 @@ union yyalloc
|
|||||||
#define YYNNTS ]b4_nterms_number[
|
#define YYNNTS ]b4_nterms_number[
|
||||||
/* YYNRULES -- Number of rules. */
|
/* YYNRULES -- Number of rules. */
|
||||||
#define YYNRULES ]b4_rules_number[
|
#define YYNRULES ]b4_rules_number[
|
||||||
/* YYNRULES -- Number of states. */
|
/* YYNSTATES -- Number of states. */
|
||||||
#define YYNSTATES ]b4_states_number[
|
#define YYNSTATES ]b4_states_number[
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
|
||||||
|
by yylex, with out-of-bounds checking. */
|
||||||
#define YYUNDEFTOK ]b4_undef_token_number[
|
#define YYUNDEFTOK ]b4_undef_token_number[
|
||||||
#define YYMAXUTOK ]b4_user_token_number_max[
|
#define YYMAXUTOK ]b4_user_token_number_max[
|
||||||
|
|
||||||
#define YYTRANSLATE(YYX) \
|
#define YYTRANSLATE(YYX) \
|
||||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||||
|
|
||||||
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||||
|
as returned by yylex, without out-of-bounds checking. */
|
||||||
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
||||||
{
|
{
|
||||||
]b4_translate[
|
]b4_translate[
|
||||||
};
|
};
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
]b4_integral_parser_table_define([rline], [b4_rline],
|
||||||
YYRHS. */
|
[YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
|
||||||
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
|
||||||
{
|
|
||||||
]b4_prhs[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
|
||||||
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
|
||||||
{
|
|
||||||
]b4_rhs[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
|
||||||
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
|
||||||
{
|
|
||||||
]b4_rline[
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
||||||
@@ -621,80 +608,25 @@ static const char *const yytname[] =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef YYPRINT
|
# ifdef YYPRINT
|
||||||
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
||||||
token YYLEX-NUM. */
|
(internal) symbol number NUM (which must be that of a token). */
|
||||||
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
||||||
{
|
{
|
||||||
]b4_toknum[
|
]b4_toknum[
|
||||||
};
|
};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
|
||||||
static const ]b4_int_type_for([b4_r1])[ yyr1[] =
|
|
||||||
{
|
|
||||||
]b4_r1[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
|
||||||
static const ]b4_int_type_for([b4_r2])[ yyr2[] =
|
|
||||||
{
|
|
||||||
]b4_r2[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
|
|
||||||
Performed when YYTABLE doesn't specify something else to do. Zero
|
|
||||||
means the default is an error. */
|
|
||||||
static const ]b4_int_type_for([b4_defact])[ yydefact[] =
|
|
||||||
{
|
|
||||||
]b4_defact[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYDEFGOTO[NTERM-NUM]. */
|
|
||||||
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
|
||||||
{
|
|
||||||
]b4_defgoto[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
|
||||||
STATE-NUM. */
|
|
||||||
#define YYPACT_NINF ]b4_pact_ninf[
|
#define YYPACT_NINF ]b4_pact_ninf[
|
||||||
static const ]b4_int_type_for([b4_pact])[ yypact[] =
|
|
||||||
{
|
|
||||||
]b4_pact[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPGOTO[NTERM-NUM]. */
|
|
||||||
static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
|
|
||||||
{
|
|
||||||
]b4_pgoto[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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. */
|
|
||||||
#define YYTABLE_NINF ]b4_table_ninf[
|
|
||||||
static const ]b4_int_type_for([b4_table])[ yytable[] =
|
|
||||||
{
|
|
||||||
]b4_table[
|
|
||||||
};
|
|
||||||
|
|
||||||
#define yypact_value_is_default(yystate) \
|
#define yypact_value_is_default(yystate) \
|
||||||
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
|
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
|
||||||
|
|
||||||
|
#define YYTABLE_NINF ]b4_table_ninf[
|
||||||
|
|
||||||
#define yytable_value_is_error(yytable_value) \
|
#define yytable_value_is_error(yytable_value) \
|
||||||
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
|
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
|
||||||
|
|
||||||
static const ]b4_int_type_for([b4_check])[ yycheck[] =
|
]b4_parser_tables_define[
|
||||||
{
|
|
||||||
]b4_check[
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
|
||||||
symbol of state STATE-NUM. */
|
|
||||||
static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
|
||||||
{
|
|
||||||
]b4_stos[
|
|
||||||
};
|
|
||||||
|
|
||||||
#define yyerrok (yyerrstatus = 0)
|
#define yyerrok (yyerrstatus = 0)
|
||||||
#define yyclearin (yychar = YYEMPTY)
|
#define yyclearin (yychar = YYEMPTY)
|
||||||
@@ -745,10 +677,9 @@ while (YYID (0))
|
|||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
#define YYERRCODE 256
|
#define YYERRCODE 256
|
||||||
|
|
||||||
|
]b4_locations_if([[
|
||||||
]b4_yylloc_default_define[
|
]b4_yylloc_default_define[
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||||
]b4_locations_if([[
|
|
||||||
|
|
||||||
|
|
||||||
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
@@ -838,21 +769,23 @@ do { \
|
|||||||
`------------------------------------------------*/
|
`------------------------------------------------*/
|
||||||
|
|
||||||
]b4_c_function_def([yy_reduce_print], [static void],
|
]b4_c_function_def([yy_reduce_print], [static void],
|
||||||
|
[[yytype_int16 *yyssp], [yyssp]],
|
||||||
[[YYSTYPE *yyvsp], [yyvsp]],
|
[[YYSTYPE *yyvsp], [yyvsp]],
|
||||||
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
||||||
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
||||||
b4_parse_param]))[
|
b4_parse_param]))[
|
||||||
{
|
{
|
||||||
|
unsigned long int yylno = yyrline[yyrule];
|
||||||
int yynrhs = yyr2[yyrule];
|
int yynrhs = yyr2[yyrule];
|
||||||
int yyi;
|
int yyi;
|
||||||
unsigned long int yylno = yyrline[yyrule];
|
|
||||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||||
yyrule - 1, yylno);
|
yyrule - 1, yylno);
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||||
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
yy_symbol_print (stderr,
|
||||||
|
yystos[yyssp[yyi + 1 - yynrhs]],
|
||||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
&]b4_rhs_value(yynrhs, yyi + 1)[
|
||||||
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||||
b4_user_args[);
|
b4_user_args[);
|
||||||
@@ -863,7 +796,7 @@ do { \
|
|||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
@@ -2045,13 +1978,12 @@ yypushreturn:]])[
|
|||||||
return YYID (yyresult);
|
return YYID (yyresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]b4_epilogue[]dnl
|
||||||
]b4_epilogue
|
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[@output(b4_spec_defines_file@)@
|
[@output(b4_spec_defines_file@)@
|
||||||
b4_copyright([Bison interface for Yacc-like parsers in C],
|
b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||||
[1984, 1989-1990, 2000-2012])[
|
|
||||||
|
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]])dnl b4_defines_if
|
]])dnl b4_defines_if
|
||||||
m4_divert_pop(0)
|
m4_divert_pop(0)
|
||||||
|
m4_popdef([b4_copyright_years])
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
## Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
djgpp/Makefile.maint \
|
||||||
|
djgpp/README.in \
|
||||||
|
djgpp/config.bat \
|
||||||
|
djgpp/config.sed \
|
||||||
|
djgpp/config.site \
|
||||||
|
djgpp/config_h.sed \
|
||||||
|
djgpp/djunpack.bat \
|
||||||
|
djgpp/fnchange.lst \
|
||||||
|
djgpp/subpipe.c \
|
||||||
|
djgpp/subpipe.h \
|
||||||
|
djgpp/testsuite.sed
|
||||||
+1
-2
@@ -1,14 +1,13 @@
|
|||||||
/*.info*
|
/*.info*
|
||||||
/*~
|
/*~
|
||||||
/.dirstamp
|
/.dirstamp
|
||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
/bison.1
|
/bison.1
|
||||||
/bison.aux
|
/bison.aux
|
||||||
/bison.cp
|
/bison.cp
|
||||||
/bison.cps
|
/bison.cps
|
||||||
/bison.dvi
|
/bison.dvi
|
||||||
/bison.fn
|
/bison.fn
|
||||||
|
/bison.help
|
||||||
/bison.html
|
/bison.html
|
||||||
/bison.ky
|
/bison.ky
|
||||||
/bison.log
|
/bison.log
|
||||||
|
|||||||
+871
-152
File diff suppressed because it is too large
Load Diff
-124
@@ -1,124 +0,0 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
|
||||||
|
|
||||||
## Copyright (C) 2001-2003, 2005-2012 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/>.
|
|
||||||
|
|
||||||
AM_MAKEINFOFLAGS = --no-split
|
|
||||||
info_TEXINFOS = bison.texi
|
|
||||||
bison_TEXINFOS = $(srcdir)/cross-options.texi gpl-3.0.texi fdl.texi
|
|
||||||
|
|
||||||
CLEANFILES = bison.fns
|
|
||||||
CLEANDIRS = *.t2d
|
|
||||||
clean-local:
|
|
||||||
rm -rf $(CLEANDIRS)
|
|
||||||
|
|
||||||
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
|
||||||
$(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL)
|
|
||||||
$(AM_V_GEN)mv -f $@ $@~ || : >$@~
|
|
||||||
$(AM_V_at)rm -f $@.tmp
|
|
||||||
$(AM_V_at)cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) bison
|
|
||||||
$(AM_V_at)$(top_builddir)/src/bison --help \
|
|
||||||
| perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
|
||||||
$(AM_V_at)diff -u $@~ $@.tmp || true
|
|
||||||
$(AM_V_at)mv $@.tmp $@
|
|
||||||
MAINTAINERCLEANFILES = $(srcdir)/cross-options.texi
|
|
||||||
|
|
||||||
## ---------- ##
|
|
||||||
## Ref card. ##
|
|
||||||
## ---------- ##
|
|
||||||
|
|
||||||
EXTRA_DIST = refcard.tex
|
|
||||||
CLEANFILES += refcard.dvi refcard.log refcard.ps
|
|
||||||
|
|
||||||
refcard.dvi: refcard.tex
|
|
||||||
$(AM_V_GEN)tex refcard.tex
|
|
||||||
|
|
||||||
refcard.ps: refcard.dvi
|
|
||||||
|
|
||||||
|
|
||||||
## ----------- ##
|
|
||||||
## Man Pages. ##
|
|
||||||
## ----------- ##
|
|
||||||
|
|
||||||
dist_man_MANS = $(srcdir)/bison.1
|
|
||||||
|
|
||||||
EXTRA_DIST += $(dist_man_MANS:.1=.x) common.x
|
|
||||||
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
|
||||||
|
|
||||||
# Depend on configure to get version number changes.
|
|
||||||
common_dep = $(top_srcdir)/configure $(srcdir)/common.x
|
|
||||||
srcsrcdir = $(top_srcdir)/bin
|
|
||||||
$(srcdir)/bison.1: $(common_dep) $(top_srcdir)/src/getargs.c
|
|
||||||
|
|
||||||
# Differences to ignore when comparing the man page (the date).
|
|
||||||
remove_time_stamp = \
|
|
||||||
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES = $(srcdir)/*.t
|
|
||||||
|
|
||||||
SUFFIXES = .x .1
|
|
||||||
|
|
||||||
PREPATH = $(top_builddir)/src
|
|
||||||
.x.1:
|
|
||||||
$(AM_V_GEN)program=`expr "/$*" : '.*/\(.*\)'` && \
|
|
||||||
save_IFS=$IFS; \
|
|
||||||
IFS=$(PATH_SEPARATOR); \
|
|
||||||
for dir in $(PREPATH); do \
|
|
||||||
IFS=$save_IFS; \
|
|
||||||
echo cd $$dir '&&' $(MAKE) $(AM_MAKEFLAGS) $$program && \
|
|
||||||
(cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $$program) || exit; \
|
|
||||||
done
|
|
||||||
$(AM_V_at)PATH="$(PREPATH)$(PATH_SEPARATOR)$$PATH"; \
|
|
||||||
export PATH; \
|
|
||||||
$(HELP2MAN) \
|
|
||||||
--include=$*.x \
|
|
||||||
--include=$(srcdir)/common.x \
|
|
||||||
--output=$@.t `echo '$*' | sed 's,.*/,,'`
|
|
||||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
|
|
||||||
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
|
|
||||||
touch $@; \
|
|
||||||
else \
|
|
||||||
mv $@.t $@; \
|
|
||||||
fi
|
|
||||||
$(AM_V_at)rm -f $@*.t
|
|
||||||
|
|
||||||
nodist_man_MANS = yacc.1
|
|
||||||
|
|
||||||
## -------------- ##
|
|
||||||
## Doxygenation. ##
|
|
||||||
## -------------- ##
|
|
||||||
|
|
||||||
DOXYGEN = doxygen
|
|
||||||
|
|
||||||
.PHONY: doc html
|
|
||||||
|
|
||||||
doc: html
|
|
||||||
|
|
||||||
html-local: Doxyfile
|
|
||||||
$(DOXYGEN)
|
|
||||||
|
|
||||||
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
|
||||||
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
|
||||||
-e 's,@top_builddir\@,$(top_builddir),g' \
|
|
||||||
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
|
||||||
|
|
||||||
EXTRA_DIST += Doxyfile.in
|
|
||||||
CLEANFILES += Doxyfile
|
|
||||||
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
|
||||||
# configure, because the former is way faster than the latter.
|
|
||||||
Doxyfile: $(srcdir)/Doxyfile.in
|
|
||||||
$(AM_V_GEN)$(edit) $(srcdir)/Doxyfile.in >Doxyfile
|
|
||||||
|
|
||||||
CLEANDIRS += html latex
|
|
||||||
+1021
-350
File diff suppressed because it is too large
Load Diff
+6
-1
@@ -39,7 +39,7 @@ This description of the options that can be given to
|
|||||||
is adapted from the node
|
is adapted from the node
|
||||||
.B Invocation
|
.B Invocation
|
||||||
in the
|
in the
|
||||||
.B bison.texinfo
|
.B bison.texi
|
||||||
manual, which should be taken as authoritative.
|
manual, which should be taken as authoritative.
|
||||||
.PP
|
.PP
|
||||||
.I Bison
|
.I Bison
|
||||||
@@ -53,3 +53,8 @@ are unique. When a long option takes an argument, like
|
|||||||
.BR \-\-file-prefix ,
|
.BR \-\-file-prefix ,
|
||||||
connect the option name and the argument with
|
connect the option name and the argument with
|
||||||
.BR = .
|
.BR = .
|
||||||
|
|
||||||
|
[see also]
|
||||||
|
.BR lex (1),
|
||||||
|
.BR flex (1),
|
||||||
|
.BR yacc (1).
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
[see also]
|
|
||||||
.BR lex (1),
|
|
||||||
.BR flex (1),
|
|
||||||
.BR yacc (1).
|
|
||||||
+141
@@ -0,0 +1,141 @@
|
|||||||
|
## Copyright (C) 2001-2003, 2005-2012 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/>.
|
||||||
|
|
||||||
|
AM_MAKEINFOFLAGS = --no-split
|
||||||
|
info_TEXINFOS = doc/bison.texi
|
||||||
|
doc_bison_TEXINFOS = \
|
||||||
|
$(CROSS_OPTIONS_TEXI) \
|
||||||
|
doc/fdl.texi \
|
||||||
|
doc/gpl-3.0.texi
|
||||||
|
|
||||||
|
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d
|
||||||
|
CLEANDIRS = doc/bison.t2d
|
||||||
|
clean-local:
|
||||||
|
rm -rf $(CLEANDIRS)
|
||||||
|
|
||||||
|
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
|
||||||
|
|
||||||
|
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
||||||
|
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
|
||||||
|
$(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
||||||
|
# Create $@~ which is the previous contents. Don't use `mv' here so
|
||||||
|
# that even if we are interrupted, the file is still available for
|
||||||
|
# diff in the next run. Note that $@ might not exist yet.
|
||||||
|
$(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~
|
||||||
|
$(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp
|
||||||
|
$(AM_V_at)src/bison$(EXEEXT) --help | \
|
||||||
|
$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
||||||
|
$(AM_V_at)diff -u $@~ $@.tmp || true
|
||||||
|
$(AM_V_at)mv $@.tmp $@
|
||||||
|
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||||
|
|
||||||
|
## ---------- ##
|
||||||
|
## Ref card. ##
|
||||||
|
## ---------- ##
|
||||||
|
|
||||||
|
EXTRA_DIST += doc/refcard.tex
|
||||||
|
CLEANFILES += doc/refcard.pdf
|
||||||
|
|
||||||
|
doc/refcard.pdf: doc/refcard.tex
|
||||||
|
$(AM_V_GEN) cd doc && pdftex $(abs_top_srcdir)/doc/refcard.tex
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## doc/bison.help. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# Some of our targets (cross-option.texi, bison.1) use "bison --help".
|
||||||
|
# Since we want to ship the generated file to avoid additional
|
||||||
|
# requirements over the user environment, we used not depend on
|
||||||
|
# src/bison itself, but on src/getargs.c and other files. Yet, we
|
||||||
|
# need "bison --help" to work to make help2man happy, so we used to
|
||||||
|
# include "make src/bison" in the commands. Then we may have a
|
||||||
|
# problem with concurrent builds, since one make might be aiming one
|
||||||
|
# of its jobs at compiling src/bison, and another job at generating
|
||||||
|
# the man page. If the latter is faster than the former, then we have
|
||||||
|
# two makes that concurrently try to compile src/bison. Doomed to
|
||||||
|
# failure.
|
||||||
|
#
|
||||||
|
# As a simple scheme to get our way out, make a stamp file,
|
||||||
|
# bison.help, which contains --version then --help. This file can
|
||||||
|
# depend on bison, which ensures its correctness. But update it
|
||||||
|
# *only* if needed (content changes). This way, we avoid useless
|
||||||
|
# compilations of cross-option.texi and bison.1. At the cost of
|
||||||
|
# repeated builds of bison.help.
|
||||||
|
|
||||||
|
EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
||||||
|
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
||||||
|
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
||||||
|
$(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
||||||
|
$(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp
|
||||||
|
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
||||||
|
|
||||||
|
|
||||||
|
## ----------- ##
|
||||||
|
## Man Pages. ##
|
||||||
|
## ----------- ##
|
||||||
|
|
||||||
|
dist_man_MANS = $(top_srcdir)/doc/bison.1
|
||||||
|
|
||||||
|
EXTRA_DIST += $(dist_man_MANS:.1=.x)
|
||||||
|
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
||||||
|
|
||||||
|
# Differences to ignore when comparing the man page (the date).
|
||||||
|
remove_time_stamp = \
|
||||||
|
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
||||||
|
|
||||||
|
# Depend on configure to get version number changes.
|
||||||
|
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
|
||||||
|
$(AM_V_GEN)$(HELP2MAN) \
|
||||||
|
--include=$(top_srcdir)/doc/bison.x \
|
||||||
|
--output=$@.t src/bison$(EXEEXT)
|
||||||
|
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
|
||||||
|
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
|
||||||
|
touch $@; \
|
||||||
|
else \
|
||||||
|
mv $@.t $@; \
|
||||||
|
fi
|
||||||
|
$(AM_V_at)rm -f $@*.t
|
||||||
|
|
||||||
|
nodist_man_MANS = doc/yacc.1
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Doxygenation. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
DOXYGEN = doxygen
|
||||||
|
|
||||||
|
.PHONY: doc html
|
||||||
|
|
||||||
|
doc: html
|
||||||
|
|
||||||
|
html-local: doc/Doxyfile
|
||||||
|
$(AM_V_GEN) $(DOXYGEN) doc/Doxyfile
|
||||||
|
|
||||||
|
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
||||||
|
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
||||||
|
-e 's,@PERL\@,$(PERL),g' \
|
||||||
|
-e 's,@top_builddir\@,$(top_builddir),g' \
|
||||||
|
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
||||||
|
|
||||||
|
EXTRA_DIST += doc/Doxyfile.in
|
||||||
|
CLEANFILES += doc/Doxyfile
|
||||||
|
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
||||||
|
# configure, because the former is way faster than the latter.
|
||||||
|
doc/Doxyfile: $(top_srcdir)/doc/Doxyfile.in
|
||||||
|
$(AM_V_GEN) $(edit) $(top_srcdir)/doc/Doxyfile.in >doc/Doxyfile
|
||||||
|
|
||||||
|
CLEANDIRS += doc/html
|
||||||
@@ -1,3 +1 @@
|
|||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
/bench.pl
|
/bench.pl
|
||||||
|
|||||||
+791
-34
@@ -17,23 +17,235 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
use IO::File;
|
=head1 NAME
|
||||||
use Benchmark qw (:all);
|
|
||||||
|
|
||||||
my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison';
|
bench.pl - bench marks for Bison parsers.
|
||||||
my $cc = $ENV{'CC'} || 'gcc';
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
./bench.pl [OPTIONS]... DIRECTIVES
|
||||||
|
|
||||||
|
=head1 DIRECTIVES
|
||||||
|
|
||||||
|
Specify the set of benches to run. The following grammar defines the
|
||||||
|
I<directives>:
|
||||||
|
|
||||||
|
directives ::=
|
||||||
|
directives | directives -- Alternation
|
||||||
|
| directives & directives -- Concatenation
|
||||||
|
| [ directives> ] -- Optional
|
||||||
|
| ( directives> ) -- Parentheses
|
||||||
|
| #d NAME[=VALUE] -- %code { #define NAME [VALUE] }
|
||||||
|
| %d NAME[=VALUE] -- %define NAME ["VALUE"]
|
||||||
|
| %s skeleton -- %skeleton "skeleton"
|
||||||
|
| directive
|
||||||
|
|
||||||
|
Parentheses only group to override precedence. For instance:
|
||||||
|
|
||||||
|
[ %debug ] & [ %error-verbose ] & [ %define variant ]
|
||||||
|
|
||||||
|
will generate eight different cases.
|
||||||
|
|
||||||
|
=head1 OPTIONS
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item B<-b>, B<--bench>
|
||||||
|
|
||||||
|
Predefined benches, that is, combimation between a grammar and a I<directives>
|
||||||
|
request.
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item I<push>
|
||||||
|
|
||||||
|
Test the push parser vs. the pull interface. Use the C parser.
|
||||||
|
|
||||||
|
=item I<variant>
|
||||||
|
|
||||||
|
Test the use of variants instead of union in the C++ parser.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=item B<-c>, B<--cflags>=I<flags>
|
||||||
|
|
||||||
|
Flags to pass to the C or C++ compiler. Defaults to -O2.
|
||||||
|
|
||||||
|
=item B<-d>, B<--directive>=I<directives>
|
||||||
|
|
||||||
|
Add a set of Bison directives to bench against each other.
|
||||||
|
|
||||||
|
=item B<-g>, B<--grammar>=I<grammar>
|
||||||
|
|
||||||
|
Select the base I<grammar> to use. Defaults to I<calc>.
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item I<calc>
|
||||||
|
|
||||||
|
Traditional calculator.
|
||||||
|
|
||||||
|
=item I<list>
|
||||||
|
|
||||||
|
C++ grammar that uses std::string and std::list. Can be used with
|
||||||
|
or without %define variant.
|
||||||
|
|
||||||
|
=item I<triangular>
|
||||||
|
|
||||||
|
Artificial grammar with very long rules.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=item B<-h>, B<--help>
|
||||||
|
|
||||||
|
Display this message and exit succesfully. The more verbose, the more
|
||||||
|
details.
|
||||||
|
|
||||||
|
=item B<-i>, B<--iterations>=I<integer>
|
||||||
|
|
||||||
|
Say how many times a single test of the bench must be run. If
|
||||||
|
negative, specify the minimum number of CPU seconds to run. Defaults
|
||||||
|
to -1.
|
||||||
|
|
||||||
|
=item B<-q>, B<--quiet>
|
||||||
|
|
||||||
|
Decrease the verbosity level (defaults to 1).
|
||||||
|
|
||||||
|
=item B<-v>, B<--verbose>
|
||||||
|
|
||||||
|
Raise the verbosity level (defaults to 1).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use IO::File;
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
sub triangular_grammar ($$$)
|
=head1 VARIABLES
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item C<@bench>
|
||||||
|
|
||||||
|
The list of benches to run.
|
||||||
|
|
||||||
|
=item C<$bison>
|
||||||
|
|
||||||
|
The Bison program to use to compile the grammar.
|
||||||
|
|
||||||
|
=item C<$cc>
|
||||||
|
|
||||||
|
The C compiler.
|
||||||
|
|
||||||
|
=item C<$cxx>
|
||||||
|
|
||||||
|
The C++ compiler.
|
||||||
|
|
||||||
|
=item C<$cflags>
|
||||||
|
|
||||||
|
Compiler flags (C or C++).
|
||||||
|
|
||||||
|
=item C<@directive>
|
||||||
|
|
||||||
|
A list of directive sets to measure against each other.
|
||||||
|
|
||||||
|
=item C<$iterations>
|
||||||
|
|
||||||
|
The number of times the parser is run for a bench.
|
||||||
|
|
||||||
|
=item C<$verbose>
|
||||||
|
|
||||||
|
Verbosity level.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
my $bench;
|
||||||
|
my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison';
|
||||||
|
my $cc = $ENV{'CC'} || 'gcc';
|
||||||
|
my $cxx = $ENV{'CXX'} || 'g++';
|
||||||
|
my $cflags = '-O2';
|
||||||
|
my @directive = ();
|
||||||
|
my $grammar = 'calc';
|
||||||
|
my $iterations = -1;
|
||||||
|
my $verbose = 1;
|
||||||
|
|
||||||
|
=head1 FUNCTIONS
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item C<verbose($level, $message)>
|
||||||
|
|
||||||
|
Report the C<$message> is C<$level> E<lt>= C<$verbose>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub verbose($$)
|
||||||
{
|
{
|
||||||
my ($base, $max, $directives) = @_;
|
my ($level, $message) = @_;
|
||||||
|
print STDERR $message
|
||||||
|
if $level <= $verbose;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
=item C<directives($bench, @directive)>
|
||||||
|
|
||||||
|
Format the list of directives for Bison for bench named C<$bench>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub directives($@)
|
||||||
|
{
|
||||||
|
my ($bench, @directive) = @_;
|
||||||
|
my $res = "/* Directives for bench `$bench'. */\n";
|
||||||
|
$res .= join ("\n", @directive) . "\n";
|
||||||
|
$res .= "/* End of directives for bench `$bench'. */\n";
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
=item C<generate_grammar_triangular ($base, $max, @directive)>
|
||||||
|
|
||||||
|
Create a large triangular grammar which looks like :
|
||||||
|
|
||||||
|
input:
|
||||||
|
exp { if ($1 != 0) abort (); $$ = $1; }
|
||||||
|
| input exp { if ($2 != $1 + 1) abort (); $$ = $2; }
|
||||||
|
;
|
||||||
|
|
||||||
|
exp:
|
||||||
|
END { $$ = 0; }
|
||||||
|
| "1" END { $$ = 1; }
|
||||||
|
| "1" "2" END { $$ = 2; }
|
||||||
|
| "1" "2" "3" END { $$ = 3; }
|
||||||
|
| "1" "2" "3" "4" END { $$ = 4; }
|
||||||
|
| "1" "2" "3" "4" "5" END { $$ = 5; }
|
||||||
|
;
|
||||||
|
|
||||||
|
C<$base> is the base name for the file to create (F<$base.y>).
|
||||||
|
C<$max> is the number of such rules (here, 5). You may pass
|
||||||
|
additional Bison C<@directive>.
|
||||||
|
|
||||||
|
The created parser is self contained: it includes its scanner, and
|
||||||
|
source of input.
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub generate_grammar_triangular ($$@)
|
||||||
|
{
|
||||||
|
my ($base, $max, @directive) = @_;
|
||||||
|
my $directives = directives ($base, @directive);
|
||||||
|
|
||||||
my $out = new IO::File ">$base.y"
|
my $out = new IO::File ">$base.y"
|
||||||
or die;
|
or die;
|
||||||
print $out <<EOF;
|
print $out <<EOF;
|
||||||
%error-verbose
|
%error-verbose
|
||||||
%debug
|
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -41,6 +253,7 @@ sub triangular_grammar ($$$)
|
|||||||
static int yylex (void);
|
static int yylex (void);
|
||||||
static void yyerror (const char *msg);
|
static void yyerror (const char *msg);
|
||||||
%}
|
%}
|
||||||
|
$directives
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
@@ -104,7 +317,9 @@ yyerror (const char *msg)
|
|||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
|
#if YYDEBUG
|
||||||
yydebug = !!getenv ("YYDEBUG");
|
yydebug = !!getenv ("YYDEBUG");
|
||||||
|
#endif
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@@ -112,6 +327,15 @@ EOF
|
|||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
|
=item C<calc_input ($base, $max)>
|
||||||
|
|
||||||
|
Generate the input file F<$base.input> for the calc parser. The input
|
||||||
|
is composed of two expressions. The first one is using left recursion
|
||||||
|
only and consumes no stack. The second one requires a deep stack.
|
||||||
|
These two expressions are repeated C<$max> times in the output file.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub calc_input ($$)
|
sub calc_input ($$)
|
||||||
{
|
{
|
||||||
my ($base, $max) = @_;
|
my ($base, $max) = @_;
|
||||||
@@ -126,9 +350,22 @@ sub calc_input ($$)
|
|||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
sub calc_grammar ($$$)
|
=item C<generate_grammar_calc ($base, $max, @directive)>
|
||||||
|
|
||||||
|
Generate a Bison file F<$base.y> for a calculator parser in C. Pass
|
||||||
|
the additional Bison C<@directive>. C<$max> is ignored, but left to
|
||||||
|
have the same interface as C<triangular_grammar>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub generate_grammar_calc ($$@)
|
||||||
{
|
{
|
||||||
my ($base, $max, $directives) = @_;
|
my ($base, $max, @directive) = @_;
|
||||||
|
my $directives = directives ($base, @directive);
|
||||||
|
|
||||||
|
# Putting this request here is stupid, since the input will be
|
||||||
|
# generated each time we generate a grammar.
|
||||||
|
calc_input ('calc', 200);
|
||||||
|
|
||||||
my $out = new IO::File ">$base.y"
|
my $out = new IO::File ">$base.y"
|
||||||
or die;
|
or die;
|
||||||
@@ -148,9 +385,9 @@ static semantic_value global_result = 0;
|
|||||||
static int global_count = 0;
|
static int global_count = 0;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Exercise %union. */
|
|
||||||
$directives
|
$directives
|
||||||
%error-verbose
|
%error-verbose
|
||||||
|
/* Exercise %union. */
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
semantic_value ival;
|
semantic_value ival;
|
||||||
@@ -306,6 +543,10 @@ main (int argc, const char **argv)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
yydebug = !!getenv ("YYDEBUG");
|
||||||
|
#endif
|
||||||
|
|
||||||
input = fopen ("calc.input", "r");
|
input = fopen ("calc.input", "r");
|
||||||
if (!input)
|
if (!input)
|
||||||
{
|
{
|
||||||
@@ -326,44 +567,560 @@ EOF
|
|||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
|
=item C<generate_grammar_list ($base, $max, @directive)>
|
||||||
|
|
||||||
|
Generate a Bison file F<$base.y> for a C++ parser that uses C++
|
||||||
|
objects (std::string, std::list). Tailored for using %define variant.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub generate_grammar_list ($$@)
|
||||||
|
{
|
||||||
|
my ($base, $max, @directive) = @_;
|
||||||
|
my $directives = directives ($base, @directive);
|
||||||
|
my $variant = grep { /%define "?variant"?/ } @directive;
|
||||||
|
my $lex_symbol = grep { /%define "?lex_symbol"?/ } @directive;
|
||||||
|
my $out = new IO::File ">$base.y"
|
||||||
|
or die;
|
||||||
|
print $out <<EOF;
|
||||||
|
%language "C++"
|
||||||
|
%defines
|
||||||
|
%locations
|
||||||
|
$directives
|
||||||
|
|
||||||
|
%code requires // *.h
|
||||||
|
{
|
||||||
|
#include <string>
|
||||||
|
}
|
||||||
|
|
||||||
|
%code // *.c
|
||||||
|
{
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#define STAGE_MAX ($max * 10) // max = $max
|
||||||
|
|
||||||
|
#define USE_LEX_SYMBOL $lex_symbol
|
||||||
|
#define USE_VARIANTS $variant
|
||||||
|
|
||||||
|
// Prototype of the yylex function providing subsequent tokens.
|
||||||
|
static
|
||||||
|
#if USE_LEX_SYMBOL
|
||||||
|
yy::parser::symbol_type yylex();
|
||||||
|
#else
|
||||||
|
yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
|
||||||
|
yy::parser::location_type* yylloc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Conversion to string.
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
std::string
|
||||||
|
string_cast (const T& t)
|
||||||
|
{
|
||||||
|
std::ostringstream o;
|
||||||
|
o << t;
|
||||||
|
return o.str ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%token END_OF_FILE 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if ($variant)
|
||||||
|
{
|
||||||
|
print $out <<'EOF';
|
||||||
|
%token <std::string> TEXT
|
||||||
|
%token <int> NUMBER
|
||||||
|
%printer { std::cerr << "Number: " << $$; } <int>
|
||||||
|
%printer { std::cerr << "Text: " << $$; } <std::string>
|
||||||
|
%type <std::string> text result
|
||||||
|
|
||||||
|
%%
|
||||||
|
result:
|
||||||
|
text { /* Throw away the result. */ }
|
||||||
|
;
|
||||||
|
|
||||||
|
text:
|
||||||
|
/* nothing */ { /* This will generate an empty string */ }
|
||||||
|
| text TEXT { std::swap ($$, $2); }
|
||||||
|
| text NUMBER { $$ = string_cast($2); }
|
||||||
|
;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# Not using Bison variants.
|
||||||
|
print $out <<'EOF';
|
||||||
|
%union {int ival; std::string* sval;}
|
||||||
|
%token <sval> TEXT
|
||||||
|
%token <ival> NUMBER
|
||||||
|
%printer { std::cerr << "Number: " << $$; } <ival>
|
||||||
|
%printer { std::cerr << "Text: " << *$$; } <sval>
|
||||||
|
%type <sval> text result
|
||||||
|
|
||||||
|
%%
|
||||||
|
result:
|
||||||
|
text { delete $1; }
|
||||||
|
;
|
||||||
|
|
||||||
|
text:
|
||||||
|
/* nothing */ { $$ = new std::string; }
|
||||||
|
| text TEXT { delete $1; $$ = $2; }
|
||||||
|
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
|
||||||
|
;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
print $out <<'EOF';
|
||||||
|
%%
|
||||||
|
#
|
||||||
|
|
||||||
|
static
|
||||||
|
#if USE_LEX_SYMBOL
|
||||||
|
yy::parser::symbol_type yylex()
|
||||||
|
#else
|
||||||
|
yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
|
||||||
|
yy::parser::location_type* yylloc)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
typedef yy::parser::location_type location_type;
|
||||||
|
typedef yy::parser::token token;
|
||||||
|
static int stage = -1;
|
||||||
|
++stage;
|
||||||
|
if (stage == STAGE_MAX)
|
||||||
|
{
|
||||||
|
#if USE_LEX_SYMBOL
|
||||||
|
return yy::parser::make_END_OF_FILE (location_type ());
|
||||||
|
#else
|
||||||
|
*yylloc = location_type ();
|
||||||
|
return token::END_OF_FILE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (stage % 2)
|
||||||
|
{
|
||||||
|
#if USE_LEX_SYMBOL
|
||||||
|
return yy::parser::make_NUMBER (stage, location_type ());
|
||||||
|
#else
|
||||||
|
# if defined ONE_STAGE_BUILD
|
||||||
|
yylval->build(stage);
|
||||||
|
# elif USE_VARIANTS
|
||||||
|
yylval->build<int>() = stage;
|
||||||
|
# else
|
||||||
|
yylval->ival = stage;
|
||||||
|
# endif
|
||||||
|
*yylloc = location_type ();
|
||||||
|
return token::NUMBER;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if USE_LEX_SYMBOL
|
||||||
|
return yy::parser::make_TEXT ("A string.", location_type ());
|
||||||
|
#else
|
||||||
|
# if defined ONE_STAGE_BUILD
|
||||||
|
yylval->build(std::string("A string."));
|
||||||
|
# elif USE_VARIANTS
|
||||||
|
yylval->build<std::string>() = std::string("A string.");
|
||||||
|
# else
|
||||||
|
yylval->sval = new std::string("A string.");
|
||||||
|
# endif
|
||||||
|
*yylloc = location_type ();
|
||||||
|
return token::TEXT;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mandatory error function
|
||||||
|
void
|
||||||
|
yy::parser::error(const yy::parser::location_type& loc, const std::string& msg)
|
||||||
|
{
|
||||||
|
std::cerr << loc << ": " << msg << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
yy::parser p;
|
||||||
|
#if YYDEBUG
|
||||||
|
p.set_debug_level(!!getenv("YYDEBUG"));
|
||||||
|
#endif
|
||||||
|
p.parse();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
=item C<generate_grammar ($name, $base, @directive)>
|
||||||
|
|
||||||
|
Generate F<$base.y> by calling C<&generate_grammar_$name>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub generate_grammar ($$@)
|
||||||
|
{
|
||||||
|
my ($name, $base, @directive) = @_;
|
||||||
|
verbose 3, "Generating $base.y\n";
|
||||||
|
my %generator =
|
||||||
|
(
|
||||||
|
"calc" => \&generate_grammar_calc,
|
||||||
|
"list" => \&generate_grammar_list,
|
||||||
|
"triangular" => \&generate_grammar_triangular,
|
||||||
|
);
|
||||||
|
&{$generator{$name}}($base, 200, @directive);
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
=item C<run ($command)>
|
||||||
|
|
||||||
|
Run, possibly verbosely, the shell C<$command>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub run ($)
|
||||||
|
{
|
||||||
|
my ($command) = @_;
|
||||||
|
verbose 3, "$command\n";
|
||||||
|
system ("$command") == 0
|
||||||
|
or die "$command failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
=item C<compile ($base)>
|
||||||
|
|
||||||
|
Compile C<$base.y> to an executable C, Using the C or C++ compiler
|
||||||
|
depending on the %language specification in C<$base.y>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub compile ($)
|
sub compile ($)
|
||||||
{
|
{
|
||||||
my ($base) = @_;
|
my ($base) = @_;
|
||||||
system ("$bison $base.y -o $base.c") == 0
|
my $language = `sed -ne '/%language "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
|
||||||
or die;
|
chomp $language;
|
||||||
system ("$cc -o $base $base.c") == 0
|
|
||||||
or die;
|
my $compiler = $language eq 'C++' ? $cxx : $cc;
|
||||||
|
|
||||||
|
run "$bison $base.y -o $base.c";
|
||||||
|
run "$compiler -o $base $cflags $base.c";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub bench_grammar ($)
|
######################################################################
|
||||||
{
|
|
||||||
my ($gram) = @_;
|
|
||||||
my %test =
|
|
||||||
(
|
|
||||||
"pull-impure" => '',
|
|
||||||
"pull-pure" => '%define api.pure',
|
|
||||||
"push-impure" => '%define api.push-pull "both"',
|
|
||||||
"push-pure" => '%define api.push-pull "both" %define api.pure',
|
|
||||||
);
|
|
||||||
|
|
||||||
my %bench;
|
=item C<bench ($grammar, @token)>
|
||||||
while (my ($name, $directives) = each %test)
|
|
||||||
|
Generate benches for the C<$grammar> and the directive specification
|
||||||
|
given in the list of C<@token>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub bench ($@)
|
||||||
{
|
{
|
||||||
print STDERR "$name\n";
|
my ($grammar, @token) = @_;
|
||||||
my $generator = "$gram" . "_grammar";
|
use Benchmark qw (:all :hireswallclock);
|
||||||
&$generator ($name, 200, $directives);
|
|
||||||
|
my @directive = parse (@token);
|
||||||
|
|
||||||
|
# Set up the benches as expected by timethese.
|
||||||
|
my %bench;
|
||||||
|
# A counter of directive sets.
|
||||||
|
my $count = 1;
|
||||||
|
for my $d (@directive)
|
||||||
|
{
|
||||||
|
$bench{$count} = $d;
|
||||||
|
printf " %2d. %s\n", $count, join (' ', split ("\n", $d));
|
||||||
|
$count++;
|
||||||
|
};
|
||||||
|
|
||||||
|
# For each bench, capture the size.
|
||||||
|
my %size;
|
||||||
|
|
||||||
|
while (my ($name, $directives) = each %bench)
|
||||||
|
{
|
||||||
|
generate_grammar ($grammar, $name, $directives);
|
||||||
|
# Compile the executable.
|
||||||
compile ($name);
|
compile ($name);
|
||||||
$bench{$name} = "system ('./$name');";
|
$bench{$name} = "system ('./$name');";
|
||||||
|
chop($size{$name} = `wc -c <$name`);
|
||||||
}
|
}
|
||||||
|
|
||||||
print "$gram:\n";
|
# Run the benches.
|
||||||
my $res = timethese (50, \%bench, 'nop');
|
#
|
||||||
|
# STYLE can be any of 'all', 'none', 'noc', 'nop' or 'auto'. 'all'
|
||||||
|
# shows each of the 5 times available ('wallclock' time, user time,
|
||||||
|
# system time, user time of children, and system time of
|
||||||
|
# children). 'noc' shows all except the two children times. 'nop'
|
||||||
|
# shows only wallclock and the two children times. 'auto' (the
|
||||||
|
# default) will act as 'all' unless the children times are both
|
||||||
|
# zero, in which case it acts as 'noc'. 'none' prevents output.
|
||||||
|
verbose 3, "Running the benches for $grammar\n";
|
||||||
|
my $res = timethese ($iterations, \%bench, 'nop');
|
||||||
|
|
||||||
|
# Output the speed result.
|
||||||
cmpthese ($res, 'nop');
|
cmpthese ($res, 'nop');
|
||||||
|
|
||||||
|
# Display the sizes.
|
||||||
|
print "Sizes (decreasing):\n";
|
||||||
|
my $width = 10;
|
||||||
|
for my $bench (keys %size)
|
||||||
|
{
|
||||||
|
$width = length $bench
|
||||||
|
if $width < length $bench;
|
||||||
|
}
|
||||||
|
# Benches sorted by decreasing size.
|
||||||
|
my @benches_per_size = sort {$size{$b} <=> $size{$a}} keys %size;
|
||||||
|
for my $bench (@benches_per_size)
|
||||||
|
{
|
||||||
|
printf "%${width}s: %5.2fkB\n", $bench, $size{$bench} / 1024;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print STDERR "Using $bison, $cc.\n";
|
######################################################################
|
||||||
calc_input ('calc', 200);
|
|
||||||
bench_grammar ('calc');
|
=item C<bench_push_parser ()>
|
||||||
|
|
||||||
|
Bench the C push parser against the pull parser, pure and impure
|
||||||
|
interfaces.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub bench_push_parser ()
|
||||||
|
{
|
||||||
|
bench ('calc',
|
||||||
|
qw(
|
||||||
|
[ %d api.pure ]
|
||||||
|
&
|
||||||
|
[ %d api.push-pull=both ]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
=item C<bench_variant_parser ()>
|
||||||
|
|
||||||
|
Bench the C++ lalr1.cc parser using variants or %union.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub bench_variant_parser ()
|
||||||
|
{
|
||||||
|
bench ('list',
|
||||||
|
qw(
|
||||||
|
[
|
||||||
|
%d variant
|
||||||
|
&
|
||||||
|
[ #d ONE_STAGE_BUILD | %d lex_symbol ]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
sub help ($)
|
||||||
|
{
|
||||||
|
my ($verbose) = @_;
|
||||||
|
use Pod::Usage;
|
||||||
|
# See <URL:http://perldoc.perl.org/pod2man.html#NOTES>.
|
||||||
|
pod2usage( { -message => "Bench Bison parsers",
|
||||||
|
-exitval => 0,
|
||||||
|
-verbose => $verbose,
|
||||||
|
-output => \*STDOUT });
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# The end of the directives to parse.
|
||||||
|
my $eod = "end of directives";
|
||||||
|
# The list of tokens parsed by the following functions.
|
||||||
|
my @token;
|
||||||
|
|
||||||
|
# eat ($EXPECTED)
|
||||||
|
# ---------------
|
||||||
|
# Check that the current token is $EXPECTED, and move to the next.
|
||||||
|
sub eat ($)
|
||||||
|
{
|
||||||
|
my ($expected) = @_;
|
||||||
|
die "expected $expected, unexpected: $token[0] (@token)\n"
|
||||||
|
unless $token[0] eq $expected;
|
||||||
|
shift @token;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse directive specifications:
|
||||||
|
# expr: term (| term)*
|
||||||
|
# term: fact (& fact)*
|
||||||
|
# fact: ( expr ) | [ expr ] | dirs
|
||||||
|
# dirs: %s SKELETON | #d NAME[=VALUE] | %d NAME[=VALUE] | directive
|
||||||
|
sub parse (@)
|
||||||
|
{
|
||||||
|
@token = (@_, $eod);
|
||||||
|
verbose 3, "Parsing: @token\n";
|
||||||
|
my @res = parse_expr ();
|
||||||
|
eat ($eod);
|
||||||
|
return @res;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parse_expr ()
|
||||||
|
{
|
||||||
|
my @res = parse_term ();
|
||||||
|
while ($token[0] eq '|')
|
||||||
|
{
|
||||||
|
eat ('|');
|
||||||
|
# Alternation.
|
||||||
|
push @res, parse_term ();
|
||||||
|
}
|
||||||
|
return @res;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parse_term ()
|
||||||
|
{
|
||||||
|
my @res = parse_fact ();
|
||||||
|
while ($token[0] eq '&')
|
||||||
|
{
|
||||||
|
eat ('&');
|
||||||
|
# Cartesian product.
|
||||||
|
my @lhs = @res;
|
||||||
|
@res = ();
|
||||||
|
for my $rhs (parse_fact ())
|
||||||
|
{
|
||||||
|
for my $lhs (@lhs)
|
||||||
|
{
|
||||||
|
push @res, $lhs . ($lhs && $rhs ? "\n" : "") . $rhs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return @res;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parse_fact ()
|
||||||
|
{
|
||||||
|
my @res;
|
||||||
|
die "unexpected end of expression"
|
||||||
|
unless defined $token[0];
|
||||||
|
|
||||||
|
if ($token[0] eq '(')
|
||||||
|
{
|
||||||
|
eat ('(');
|
||||||
|
@res = parse_expr ();
|
||||||
|
eat (')');
|
||||||
|
}
|
||||||
|
elsif ($token[0] eq '[')
|
||||||
|
{
|
||||||
|
eat ('[');
|
||||||
|
@res = (parse_expr (), '');
|
||||||
|
eat (']');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@res = parse_dirs ();
|
||||||
|
}
|
||||||
|
return @res;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parse_dirs ()
|
||||||
|
{
|
||||||
|
my @res;
|
||||||
|
die "unexpected end of expression"
|
||||||
|
unless defined $token[0];
|
||||||
|
|
||||||
|
if ($token[0] eq '#d')
|
||||||
|
{
|
||||||
|
eat ('#d');
|
||||||
|
$token[0] =~ s/(.*?)=(.*)/$1 $2/;
|
||||||
|
@res = ("%code {\n#define $token[0]\n}");
|
||||||
|
shift @token;
|
||||||
|
}
|
||||||
|
elsif ($token[0] eq '%d')
|
||||||
|
{
|
||||||
|
shift @token;
|
||||||
|
$token[0] =~ s/(.*?)=(.*)/$1 "$2"/;
|
||||||
|
@res = ("%define $token[0]");
|
||||||
|
shift @token;
|
||||||
|
}
|
||||||
|
elsif ($token[0] eq '%s')
|
||||||
|
{
|
||||||
|
shift @token;
|
||||||
|
@res = ("%skeleton \"$token[0]\"");
|
||||||
|
shift @token;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@res = $token[0];
|
||||||
|
shift @token;
|
||||||
|
}
|
||||||
|
|
||||||
|
return @res;
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
sub getopt ()
|
||||||
|
{
|
||||||
|
use Getopt::Long;
|
||||||
|
my %option = (
|
||||||
|
"b|bench=s" => \$bench,
|
||||||
|
"c|cflags=s" => \$cflags,
|
||||||
|
"d|directive=s" => \@directive,
|
||||||
|
"g|grammar=s" => \$grammar,
|
||||||
|
"h|help" => sub { help ($verbose) },
|
||||||
|
"i|iterations=i" => \$iterations,
|
||||||
|
"q|quiet" => sub { --$verbose },
|
||||||
|
"v|verbose" => sub { ++$verbose },
|
||||||
|
);
|
||||||
|
Getopt::Long::Configure ("bundling", "pass_through");
|
||||||
|
GetOptions (%option)
|
||||||
|
or exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
getopt;
|
||||||
|
|
||||||
|
# Create the directory we work in.
|
||||||
|
mkdir "benches" or die "cannot create benches"
|
||||||
|
unless -d "benches";
|
||||||
|
my $count = 1;
|
||||||
|
++$count
|
||||||
|
while -d "benches/$count";
|
||||||
|
my $dir = "benches/$count";
|
||||||
|
mkdir $dir
|
||||||
|
or die "cannot create $dir";
|
||||||
|
chdir $dir
|
||||||
|
or die "cannot chdir $dir";
|
||||||
|
|
||||||
|
# The following message is tailored to please Emacs' compilation-mode.
|
||||||
|
verbose 1, "Entering directory `$dir'\n";
|
||||||
|
verbose 1, "Using bison=$bison.\n";
|
||||||
|
verbose 2, "Using cc=$cc.\n";
|
||||||
|
verbose 2, "Using cxx=$cxx.\n";
|
||||||
|
verbose 2, "Using cflags=$cflags.\n";
|
||||||
|
verbose 2, "Grammar: $grammar\n";
|
||||||
|
|
||||||
|
|
||||||
|
# Support -b: predefined benches.
|
||||||
|
my %bench =
|
||||||
|
(
|
||||||
|
"push" => \&bench_push_parser,
|
||||||
|
"variant" => \&bench_variant_parser,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (defined $bench)
|
||||||
|
{
|
||||||
|
die "invalid argument for --bench: $bench"
|
||||||
|
unless defined $bench{$bench};
|
||||||
|
&{$bench{$bench}}();
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# Launch the bench marking.
|
||||||
|
bench ($grammar, @ARGV);
|
||||||
|
}
|
||||||
|
|
||||||
### Setup "GNU" style for perl-mode and cperl-mode.
|
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||||
## Local Variables:
|
## Local Variables:
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
## Copyright (C) 2006, 2008-2012 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/>.
|
||||||
|
|
||||||
|
nodist_noinst_SCRIPTS = etc/bench.pl
|
||||||
Executable
+220
@@ -0,0 +1,220 @@
|
|||||||
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use IO::File;
|
||||||
|
use Getopt::Long;
|
||||||
|
use File::Basename; # for dirname
|
||||||
|
|
||||||
|
my $VERSION = '2012-01-21 17:13'; # UTC
|
||||||
|
(my $ME = $0) =~ s|.*/||;
|
||||||
|
|
||||||
|
my $prefix;
|
||||||
|
my $lib_name;
|
||||||
|
|
||||||
|
sub usage ($)
|
||||||
|
{
|
||||||
|
my ($exit_code) = @_;
|
||||||
|
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
|
||||||
|
if ($exit_code != 0)
|
||||||
|
{
|
||||||
|
print $STREAM "Try '$ME --help' for more information.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $STREAM <<EOF;
|
||||||
|
Usage: $ME --lib-name=NAME FILE
|
||||||
|
or: $ME [--help|--version]
|
||||||
|
Rewrite a gnulib-tool-generated FILE like lib/gnulib.mk to work with
|
||||||
|
automake's subdir-objects.
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
|
||||||
|
This option must be specified:
|
||||||
|
|
||||||
|
--lib-name=NAME library name, often "lib\$project"
|
||||||
|
|
||||||
|
The following are optional:
|
||||||
|
|
||||||
|
--help display this help and exit
|
||||||
|
--version output version information and exit
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
exit $exit_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
# contents ($FILE_NAME)
|
||||||
|
# ---------------------
|
||||||
|
sub contents ($)
|
||||||
|
{
|
||||||
|
my ($file) = @_;
|
||||||
|
local $/; # Turn on slurp-mode.
|
||||||
|
my $f = new IO::File "< $file" or die "$file";
|
||||||
|
my $contents = $f->getline or die "$file";
|
||||||
|
$f->close;
|
||||||
|
return $contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
# prefix_word ($WORD)
|
||||||
|
# -------------------
|
||||||
|
# Do not prefix special words such as variable dereferences. Also,
|
||||||
|
# "Makefile" is really "Makefile", since precisely there is no
|
||||||
|
# lib/Makefile.
|
||||||
|
sub prefix_word ($)
|
||||||
|
{
|
||||||
|
local ($_) = @_;
|
||||||
|
$_ = $prefix . $_
|
||||||
|
unless /^-/ || m{^\$\(\w+\)} || $_ eq "Makefile" || $_ eq '\\';
|
||||||
|
return $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# prefix_words ($TEXT)
|
||||||
|
# --------------------
|
||||||
|
sub prefix_words ($)
|
||||||
|
{
|
||||||
|
local ($_) = @_;
|
||||||
|
s{(\S+)}{prefix_word($1)}gem;
|
||||||
|
return $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# prefix_assignment ($LHS-AND-ASSIGN-OP, $RHS)
|
||||||
|
# --------------------------------------------
|
||||||
|
sub prefix_assignment ($$)
|
||||||
|
{
|
||||||
|
my ($lhs_and_assign_op, $rhs) = @_;
|
||||||
|
my $res;
|
||||||
|
|
||||||
|
# Some variables are initialized by gnulib.mk, and we don't want
|
||||||
|
# that. Change '=' to '+='.
|
||||||
|
if ($lhs_and_assign_op =~ /^(SUBDIRS|EXTRA_DIST|BUILT_SOURCES|SUFFIXES|MOSTLYCLEANFILES|CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES|AM_CFLAGS|AM_CPPFLAGS|AM_GNU_GETTEXT) =/)
|
||||||
|
{
|
||||||
|
$lhs_and_assign_op =~ s/=/+=/;
|
||||||
|
}
|
||||||
|
# We don't want to inherit gnulib's AUTOMAKE_OPTIONS, comment them.
|
||||||
|
elsif ($lhs_and_assign_op =~ /^AUTOMAKE_OPTIONS =/)
|
||||||
|
{
|
||||||
|
$lhs_and_assign_op =~ s/^/# /;
|
||||||
|
}
|
||||||
|
# Don't touch suffixes.
|
||||||
|
elsif ($lhs_and_assign_op =~ /^SUFFIXES /)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
# The words are (probably) paths to files in lib/: prefix them.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$rhs = prefix_words($rhs)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Variables which name depend on the location: libbison_a_SOURCES =>
|
||||||
|
# lib_libbison_a_SOURCES.
|
||||||
|
$lhs_and_assign_op =~ s/($lib_name)/lib_$1/g;
|
||||||
|
|
||||||
|
return $lhs_and_assign_op . $rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
# prefix $CONTENTS
|
||||||
|
# ----------------
|
||||||
|
# $CONTENTS is a Makefile content. Post-process it so that each file-name
|
||||||
|
# is prefixed with $prefix (e.g., "lib/").
|
||||||
|
#
|
||||||
|
# Relies heavily on the regularity of the file generated by gnulib-tool.
|
||||||
|
sub prefix ($)
|
||||||
|
{
|
||||||
|
# Work on $_.
|
||||||
|
local ($_) = @_;
|
||||||
|
|
||||||
|
# Prefix all the occurrence of files in rules. If there is nothing
|
||||||
|
# after in the :, it's probably a phony target, or a suffix rule.
|
||||||
|
# Don't touch it.
|
||||||
|
s{^([-\w+/]+\.[-\w.]+ *: *\S.*)$}
|
||||||
|
{prefix_words($1)}gem;
|
||||||
|
|
||||||
|
# Prefix files in variables.
|
||||||
|
s{^([\w.]+\s*\+?=)(.*)$}
|
||||||
|
{prefix_assignment($1, $2)}gem;
|
||||||
|
|
||||||
|
# These three guys escape all the other regular rules.
|
||||||
|
s{(charset\.alias|ref-add\.sed|ref-del\.sed)}{$prefix$1}g;
|
||||||
|
# Unfortunately, as a result we sometimes have lib/lib.
|
||||||
|
s{($prefix){2}}{$1}g;
|
||||||
|
|
||||||
|
# $(srcdir) is actually $(top_srcdir)/lib.
|
||||||
|
s{\$\(srcdir\)}{\$(top_srcdir)/lib}g;
|
||||||
|
|
||||||
|
# Sometimes, t-$@ is used instead of $@-t, which, of course, does
|
||||||
|
# not work when we have a $@ with a directory in it.
|
||||||
|
s{t-\$\@}{\$\@-t}g;
|
||||||
|
|
||||||
|
# Some AC_SUBST patterns remain and would better be Make macros.
|
||||||
|
s{\@(MKDIR_P)\@}{\$($1)}g;
|
||||||
|
|
||||||
|
# Adjust paths in mkdir.
|
||||||
|
s{(\$\(MKDIR_P\))\s*(\w+)}{$1 $prefix$2}g;
|
||||||
|
|
||||||
|
return $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
# process ($IN)
|
||||||
|
# -------------
|
||||||
|
sub process ($)
|
||||||
|
{
|
||||||
|
my ($file) = @_;
|
||||||
|
my ($bak) = "$file.bak";
|
||||||
|
rename ($file, $bak) or die;
|
||||||
|
my $contents = contents ($bak);
|
||||||
|
$contents = prefix ($contents);
|
||||||
|
my $out = new IO::File(">$file") or die;
|
||||||
|
print $out $contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
GetOptions
|
||||||
|
(
|
||||||
|
'lib-name=s' => \$lib_name,
|
||||||
|
help => sub { usage 0 },
|
||||||
|
version => sub { print "$ME version $VERSION\n"; exit },
|
||||||
|
) or usage 1;
|
||||||
|
|
||||||
|
my $fail = 0;
|
||||||
|
defined $lib_name
|
||||||
|
or (warn "$ME: no library name; use --lib-name=NAME\n"), $fail = 1;
|
||||||
|
|
||||||
|
# There must be exactly one argument.
|
||||||
|
@ARGV == 0
|
||||||
|
and (warn "$ME: missing FILE argument\n"), $fail = 1;
|
||||||
|
1 < @ARGV
|
||||||
|
and (warn "$ME: too many arguments:\n", join ("\n", @ARGV), "\n"),
|
||||||
|
$fail = 1;
|
||||||
|
$fail
|
||||||
|
and usage 1;
|
||||||
|
|
||||||
|
my $file = $ARGV[0];
|
||||||
|
$prefix = (dirname $file) . '/';
|
||||||
|
warn "prefix=$prefix\n";
|
||||||
|
|
||||||
|
process $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||||
|
## Local Variables:
|
||||||
|
## perl-indent-level: 2
|
||||||
|
## perl-continued-statement-offset: 2
|
||||||
|
## perl-continued-brace-offset: 0
|
||||||
|
## perl-brace-offset: 0
|
||||||
|
## perl-brace-imaginary-offset: 0
|
||||||
|
## perl-label-offset: -2
|
||||||
|
## cperl-indent-level: 2
|
||||||
|
## cperl-brace-offset: 0
|
||||||
|
## cperl-continued-brace-offset: 0
|
||||||
|
## cperl-label-offset: -2
|
||||||
|
## cperl-extra-newline-before-brace: t
|
||||||
|
## cperl-merge-trailing-else: nil
|
||||||
|
## cperl-continued-statement-offset: 2
|
||||||
|
## eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
## time-stamp-start: "my $VERSION = '"
|
||||||
|
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
|
||||||
|
## time-stamp-time-zone: "UTC"
|
||||||
|
## time-stamp-end: "'; # UTC"
|
||||||
|
## End:
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Makefile
|
|
||||||
Makefile.in
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
/*.cc
|
|
||||||
/*.hh
|
|
||||||
/*.ll
|
|
||||||
/*.o
|
/*.o
|
||||||
/*.output
|
|
||||||
/*.stamp
|
|
||||||
/*.tmp
|
/*.tmp
|
||||||
/*.yy
|
|
||||||
/.deps
|
/.deps
|
||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
/calc++
|
/calc++
|
||||||
|
/calc++-driver.cc
|
||||||
|
/calc++-driver.hh
|
||||||
|
/calc++-parser.cc
|
||||||
|
/calc++-parser.hh
|
||||||
|
/calc++-parser.output
|
||||||
|
/calc++-parser.stamp
|
||||||
|
/calc++-parser.yy
|
||||||
|
/calc++-scanner.cc
|
||||||
|
/calc++-scanner.ll
|
||||||
|
/calc++.cc
|
||||||
/calc++.exe
|
/calc++.exe
|
||||||
|
/calc.stamp
|
||||||
|
/location.hh
|
||||||
|
/position.hh
|
||||||
|
/stack.hh
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
|
||||||
## Copyright (C) 2005-2006, 2009-2012 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/>.
|
|
||||||
|
|
||||||
## ------------------------------------- ##
|
|
||||||
## Running the bison from this tarball. ##
|
|
||||||
## ------------------------------------- ##
|
|
||||||
|
|
||||||
BISON = $(top_builddir)/tests/bison
|
|
||||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
|
||||||
|
|
||||||
$(BISON): $(BISON_IN)
|
|
||||||
$(AM_V_GEN)cd $(top_builddir)/tests && $(MAKE) $(AM_MAKEFLAGS) bison
|
|
||||||
|
|
||||||
## ------------ ##
|
|
||||||
## Extracting. ##
|
|
||||||
## ------------ ##
|
|
||||||
|
|
||||||
doc = $(top_srcdir)/doc/bison.texi
|
|
||||||
extexi = $(top_srcdir)/examples/extexi
|
|
||||||
# Extract in src.
|
|
||||||
$(srcdir)/calc.stamp: $(doc) $(extexi)
|
|
||||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
|
||||||
$(AM_V_at)touch $@.tmp
|
|
||||||
$(AM_V_at)cd $(srcdir) && \
|
|
||||||
$(AWK) -f ../extexi -v VERSION="$(VERSION)" \
|
|
||||||
../../doc/bison.texi -- calc++-parser.yy \
|
|
||||||
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
|
|
||||||
$(AM_V_at)mv $@.tmp $@
|
|
||||||
|
|
||||||
$(calc_extracted): $(srcdir)/calc.stamp
|
|
||||||
|
|
||||||
## ------------------- ##
|
|
||||||
## Parser generation. ##
|
|
||||||
## ------------------- ##
|
|
||||||
|
|
||||||
DEFAULT_INCLUDES = -I. -I$(srcdir)
|
|
||||||
BUILT_SOURCES = $(calc_extracted) $(calc_sources_generated)
|
|
||||||
CLEANFILES = $(srcdir)/*.output *.tmp
|
|
||||||
MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES)
|
|
||||||
|
|
||||||
# Compile the parser and save cycles.
|
|
||||||
# This code comes from "Handling Tools that Produce Many Outputs",
|
|
||||||
# from the Automake documentation.
|
|
||||||
EXTRA_DIST = \
|
|
||||||
$(srcdir)/calc++-parser.stamp \
|
|
||||||
$(srcdir)/calc++-parser.yy \
|
|
||||||
$(srcdir)/calc.stamp
|
|
||||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
|
||||||
# in srcdir, including during distcheck, which is forbidden.
|
|
||||||
$(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN)
|
|
||||||
$(AM_V_GEN)rm -f calc++-parser.tmp
|
|
||||||
$(AM_V_at)touch calc++-parser.tmp
|
|
||||||
$(AM_V_at)$(BISON) -d -ra -S lalr1.cc -o $(srcdir)/calc++-parser.cc \
|
|
||||||
$(srcdir)/calc++-parser.yy
|
|
||||||
$(AM_V_at)mv -f calc++-parser.tmp $@
|
|
||||||
|
|
||||||
$(calc_sources_generated): $(srcdir)/calc++-parser.stamp
|
|
||||||
$(AM_V_GEN)if test -f $@; then :; else \
|
|
||||||
rm -f $(srcdir)/calc++-parser.stamp && \
|
|
||||||
$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------------- ##
|
|
||||||
## Building & testing calc++. ##
|
|
||||||
## --------------------------- ##
|
|
||||||
|
|
||||||
check_PROGRAMS = calc++
|
|
||||||
|
|
||||||
calc_sources_extracted = $(srcdir)/calc++-scanner.ll $(srcdir)/calc++.cc \
|
|
||||||
$(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc
|
|
||||||
calc_extracted = $(calc_sources_extracted) $(srcdir)/calc++-parser.yy
|
|
||||||
calc_sources_generated = \
|
|
||||||
$(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \
|
|
||||||
$(srcdir)/calc++-parser.hh $(srcdir)/calc++-parser.cc
|
|
||||||
|
|
||||||
calc___SOURCES = $(calc_sources_extracted) $(calc_sources_generated)
|
|
||||||
|
|
||||||
TESTS = test
|
|
||||||
EXTRA_DIST += $(TESTS)
|
|
||||||
@@ -15,10 +15,12 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
test -z "$VERBOSE" && {
|
cat >input <<EOF
|
||||||
exec > /dev/null 2>&1
|
toto := 1
|
||||||
set -x
|
toto
|
||||||
}
|
EOF
|
||||||
|
run 0 1 -s
|
||||||
|
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
a := 1
|
a := 1
|
||||||
@@ -27,20 +29,22 @@ c := 3
|
|||||||
d := a + b * c
|
d := a + b * c
|
||||||
d
|
d
|
||||||
EOF
|
EOF
|
||||||
|
run 0 7
|
||||||
|
run 0 7 -p
|
||||||
|
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
a := 1
|
||||||
|
b := 2
|
||||||
|
c := 3
|
||||||
|
d := (a + b) * c
|
||||||
|
d
|
||||||
|
EOF
|
||||||
|
run 0 9
|
||||||
|
|
||||||
./calc++ input
|
|
||||||
./calc++ -p input
|
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
a := 1
|
a := 1
|
||||||
d := a + b * c
|
d := a + b * c
|
||||||
EOF
|
EOF
|
||||||
./calc++ input
|
run 1 ''
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
toto := 1
|
|
||||||
toto
|
|
||||||
EOF
|
|
||||||
./calc++ -s input
|
|
||||||
|
|
||||||
rm input
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
## ------------------- ##
|
||||||
|
## Parser generation. ##
|
||||||
|
## ------------------- ##
|
||||||
|
|
||||||
|
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||||
|
# in srcdir, including during distcheck, which is forbidden.
|
||||||
|
examples/calc++/calc++-parser.stamp: $(BISON_IN)
|
||||||
|
SUFFIXES += .yy .stamp
|
||||||
|
.yy.stamp:
|
||||||
|
$(AM_V_YACC)rm -f $@
|
||||||
|
$(AM_V_at)touch $@.tmp
|
||||||
|
$(AM_V_at)$(YACCCOMPILE) -o $*.cc $<
|
||||||
|
$(AM_V_at)mv -f $@.tmp $@
|
||||||
|
|
||||||
|
$(calc_sources_generated): examples/calc++/calc++-parser.stamp
|
||||||
|
@test -f $@ || rm -f examples/calc++/calc++-parser.stamp
|
||||||
|
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) examples/calc++/calc++-parser.stamp
|
||||||
|
CLEANFILES += \
|
||||||
|
$(calc_sources_generated) \
|
||||||
|
examples/calc++/calc++-parser.output \
|
||||||
|
examples/calc++/calc++-parser.stamp \
|
||||||
|
examples/calc++/calc++-scanner.cc
|
||||||
|
|
||||||
|
|
||||||
|
## -------------------- ##
|
||||||
|
## Building & testing. ##
|
||||||
|
## -------------------- ##
|
||||||
|
|
||||||
|
# Avoid using BUILT_SOURCES which is too global.
|
||||||
|
$(examples_calc___calc___OBJECTS): $(calc_sources_generated)
|
||||||
|
|
||||||
|
calc_sources_extracted = \
|
||||||
|
examples/calc++/calc++-driver.cc \
|
||||||
|
examples/calc++/calc++-driver.hh \
|
||||||
|
examples/calc++/calc++-scanner.ll \
|
||||||
|
examples/calc++/calc++.cc
|
||||||
|
calc_extracted = \
|
||||||
|
$(calc_sources_extracted) \
|
||||||
|
examples/calc++/calc++-parser.yy
|
||||||
|
extracted += $(calc_extracted)
|
||||||
|
calc_sources_generated = \
|
||||||
|
examples/calc++/calc++-parser.cc \
|
||||||
|
examples/calc++/calc++-parser.hh \
|
||||||
|
examples/calc++/location.hh \
|
||||||
|
examples/calc++/position.hh \
|
||||||
|
examples/calc++/stack.hh
|
||||||
|
calc_sources = \
|
||||||
|
$(calc_sources_extracted) \
|
||||||
|
$(calc_sources_generated)
|
||||||
|
|
||||||
|
if BISON_CXX_WORKS
|
||||||
|
check_PROGRAMS += examples/calc++/calc++
|
||||||
|
nodist_examples_calc___calc___SOURCES = \
|
||||||
|
$(calc_sources)
|
||||||
|
|
||||||
|
examples_calc___calc___CPPFLAGS = -I$(top_builddir)/examples/calc++
|
||||||
|
dist_TESTS += examples/calc++/calc++.test
|
||||||
|
endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Work around an Automake 1.11.2 bug: it asks for the creation of
|
||||||
|
// y.tab.c and y.tab.h and then renames them as calc++-parser.cc and
|
||||||
|
// calc++-parser.h, but in the former it does not convert the
|
||||||
|
// #include "y.tab.h". We don't want this to show in the
|
||||||
|
// documentation.
|
||||||
|
#include "calc++-parser.hh"
|
||||||
Regular → Executable
+131
-98
@@ -1,4 +1,5 @@
|
|||||||
# Extract all examples from the manual source. -*- AWK -*-
|
#! /usr/bin/perl -w
|
||||||
|
# Extract all examples from the manual source.
|
||||||
|
|
||||||
# This file is part of GNU Bison
|
# This file is part of GNU Bison
|
||||||
|
|
||||||
@@ -18,122 +19,154 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
# This script is for use with any Awk that conforms to POSIX.
|
|
||||||
# It was derived from a similar script tests/generate.awk in GNU m4.
|
|
||||||
#
|
|
||||||
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
||||||
BEGIN {
|
|
||||||
if (!output_dir)
|
# Look for @example environments preceded with lines such as:
|
||||||
output_dir = ".";
|
#
|
||||||
for (argc = 1; argc < ARGC; ++argc)
|
# @comment file calc.y
|
||||||
if (ARGV[argc] == "--")
|
# or
|
||||||
break;
|
# @comment file calc.y: 3
|
||||||
for (i = argc + 1; i < ARGC; ++i)
|
#
|
||||||
file_wanted[ARGV[i]] = 1;
|
# and output their content in that file (calc.y). When numbers are
|
||||||
ARGC = argc;
|
# provided, use them to decide the output order (block numbered 1 is
|
||||||
|
# output before block 2, even if the latter appears before). The same
|
||||||
|
# number may be used several time, in which case the order of
|
||||||
|
# appearance is used.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# normalize($block)
|
||||||
|
# -----------------
|
||||||
|
# Remove Texinfo mark up.
|
||||||
|
sub normalize($)
|
||||||
|
{
|
||||||
|
local ($_) = @_;
|
||||||
|
|
||||||
|
s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*//mg;
|
||||||
|
s/\@value\{VERSION\}/$ENV{VERSION}/g;
|
||||||
|
s/^\@(error|result)\{\}//mg;
|
||||||
|
s/\@([{}@])/$1/g;
|
||||||
|
s/\@comment.*//;
|
||||||
|
$_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/^@node / {
|
# Print messages only once.
|
||||||
if (seq > 0)
|
my %msg;
|
||||||
print "AT_CLEANUP";
|
sub message($)
|
||||||
|
{
|
||||||
split ($0, tmp, ",");
|
my ($msg) = @_;
|
||||||
node = substr(tmp[1], 7);
|
if (! $msg{$msg})
|
||||||
seq = 0;
|
{
|
||||||
|
print STDERR "extexi: $msg\n";
|
||||||
|
$msg{$msg} = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/^@comment file: / {
|
# basename => full file name for files we should extract.
|
||||||
if (!file_wanted[$3])
|
my %file_wanted;
|
||||||
message("ignoring " $3);
|
|
||||||
|
sub process ($)
|
||||||
|
{
|
||||||
|
my ($in) = @_;
|
||||||
|
use IO::File;
|
||||||
|
my $f = new IO::File($in)
|
||||||
|
or die "$in: cannot open: $?";
|
||||||
|
# FILE-NAME => { BLOCK-NUM => CODE }
|
||||||
|
my %file;
|
||||||
|
|
||||||
|
# The latest "@comment file: FILE [BLOCK-NUM]" arguments.
|
||||||
|
my $file;
|
||||||
|
my $block;
|
||||||
|
# The @example block currently read.
|
||||||
|
my $input;
|
||||||
|
local $_;
|
||||||
|
while (<$f>)
|
||||||
|
{
|
||||||
|
if (/^\@comment file: ([^:\n]+)(?::\s*(\d+))?$/)
|
||||||
|
{
|
||||||
|
my $f = $1;
|
||||||
|
$block = $2 || 1;
|
||||||
|
if ($file_wanted{$f})
|
||||||
|
{
|
||||||
|
$file = $file_wanted{$f};
|
||||||
|
message(" GEN $file");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message("extracting " $3);
|
message("SKIP $f");
|
||||||
file = $3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ($file && /^\@(small)?example$/ .. /^\@end (small)?example$/)
|
||||||
/^@example$/, /^@end example$/ {
|
|
||||||
if (!file)
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ($0 ~ /^@example$/)
|
|
||||||
{
|
{
|
||||||
input = files_output[file] ? "\n" : "";
|
if (/^\@(small)?example$/)
|
||||||
|
{
|
||||||
# FNR is starting at 0 instead of 1, and
|
# Bison supports synclines, but not Flex.
|
||||||
# #line report the line number of the *next* line.
|
$input .= sprintf ("#line %s \"$in\"\n", $. + 1)
|
||||||
# => + 2.
|
if $file =~ /\.[chy]*$/;
|
||||||
# Note that recent Bison support it, but not Flex.
|
|
||||||
if (file ~ /\.[chy]*$/)
|
|
||||||
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
elsif (/^\@end (small)?example$/)
|
||||||
if ($0 ~ /^@end example$/)
|
|
||||||
{
|
{
|
||||||
if (input == "")
|
die "no contents: $file"
|
||||||
fatal("no contents: " file);
|
if $input eq "";
|
||||||
|
|
||||||
input = normalize(input);
|
$file{$file}{$block} .= normalize($input);
|
||||||
|
$file = $input = undef;
|
||||||
|
++$block;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$input .= $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Output the files.
|
||||||
|
for my $file (keys %file)
|
||||||
|
{
|
||||||
# No spurious end of line: use printf.
|
# No spurious end of line: use printf.
|
||||||
if (files_output[file])
|
my $o = new IO::File(">$file")
|
||||||
# The parens around the output file seem to be required
|
or die "$file: cannot create: $?";
|
||||||
# by awk on Mac OS X Tiger (darwin 8.4.6).
|
print $o $file{$file}{$_}
|
||||||
printf ("%s", input) >> (output_dir "/" file);
|
for sort keys %{$file{$file}};
|
||||||
else
|
}
|
||||||
printf ("%s", input) > (output_dir "/" file);
|
|
||||||
close (output_dir "/" file);
|
|
||||||
files_output[file] = 1;
|
|
||||||
|
|
||||||
file = input = "";
|
|
||||||
next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input = input $0 "\n";
|
my @input;
|
||||||
}
|
my $seen_dash = 0;
|
||||||
|
for my $arg (@ARGV)
|
||||||
|
|
||||||
# We have to handle CONTENTS line per line, since anchors in AWK are
|
|
||||||
# referring to the whole string, not the lines.
|
|
||||||
function normalize(contents, i, lines, n, line, res) {
|
|
||||||
# Remove the Texinfo tags.
|
|
||||||
n = split (contents, lines, "\n");
|
|
||||||
# We don't want the last field which empty: it's behind the last \n.
|
|
||||||
for (i = 1; i < n; ++i)
|
|
||||||
{
|
{
|
||||||
line = lines[i];
|
if ($arg eq '--')
|
||||||
|
|
||||||
# Whole line commands.
|
|
||||||
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
|
|
||||||
# Gperf accepts empty lines as valid input!!!
|
|
||||||
if (file ~ /\.gperf$/)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
line = "";
|
|
||||||
|
|
||||||
gsub (/"@value\{VERSION\}"/, "\"" VERSION "\"", line)
|
|
||||||
gsub (/^@result\{\}/, "", line);
|
|
||||||
gsub (/^@error\{\}/, "", line);
|
|
||||||
gsub ("@[{]", "{", line);
|
|
||||||
gsub ("@}", "}", line);
|
|
||||||
gsub ("@@", "@", line);
|
|
||||||
gsub ("@comment.*", "", line);
|
|
||||||
|
|
||||||
res = res line "\n";
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function message(msg) {
|
|
||||||
if (! message_printed[msg])
|
|
||||||
{
|
{
|
||||||
print "extexi: " msg > "/dev/stderr";
|
$seen_dash = 1;
|
||||||
message_printed[msg] = 1;
|
}
|
||||||
|
elsif ($seen_dash)
|
||||||
|
{
|
||||||
|
use File::Basename;
|
||||||
|
$file_wanted{basename($arg)} = $arg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
push @input, $arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
process $_
|
||||||
|
foreach @input;
|
||||||
|
|
||||||
function fatal(msg) {
|
|
||||||
message(msg);
|
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||||
exit 1
|
## Local Variables:
|
||||||
}
|
## perl-indent-level: 2
|
||||||
|
## perl-continued-statement-offset: 2
|
||||||
|
## perl-continued-brace-offset: 0
|
||||||
|
## perl-brace-offset: 0
|
||||||
|
## perl-brace-imaginary-offset: 0
|
||||||
|
## perl-label-offset: -2
|
||||||
|
## cperl-indent-level: 2
|
||||||
|
## cperl-brace-offset: 0
|
||||||
|
## cperl-continued-brace-offset: 0
|
||||||
|
## cperl-label-offset: -2
|
||||||
|
## cperl-extra-newline-before-brace: t
|
||||||
|
## cperl-merge-trailing-else: nil
|
||||||
|
## cperl-continued-statement-offset: 2
|
||||||
|
## End:
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# Copyright (C) 2005, 2008-2012 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
dist_noinst_SCRIPTS = examples/extexi examples/test
|
||||||
|
TEST_LOG_COMPILER = $(top_srcdir)/examples/test
|
||||||
|
|
||||||
|
## ------------ ##
|
||||||
|
## Extracting. ##
|
||||||
|
## ------------ ##
|
||||||
|
|
||||||
|
doc = $(top_srcdir)/doc/bison.texi
|
||||||
|
extexi = $(top_srcdir)/examples/extexi
|
||||||
|
extract = VERSION="$(VERSION)" $(PERL) -f $(extexi) $(doc) --
|
||||||
|
extracted =
|
||||||
|
CLEANFILES += $(extracted) examples/extracted.stamp
|
||||||
|
examples/extracted.stamp: $(doc) $(extexi)
|
||||||
|
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||||
|
$(AM_V_at)touch $@.tmp
|
||||||
|
$(AM_V_at)$(extract) $(extracted)
|
||||||
|
$(AM_V_at)mv $@.tmp $@
|
||||||
|
|
||||||
|
$(extracted): examples/extracted.stamp
|
||||||
|
@test -f $@ || rm -f examples/extracted.stamp
|
||||||
|
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) examples/extracted.stamp
|
||||||
|
|
||||||
|
include examples/calc++/local.mk
|
||||||
|
include examples/mfcalc/local.mk
|
||||||
|
include examples/rpcalc/local.mk
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
/*.o
|
||||||
|
/*.tmp
|
||||||
|
/.deps
|
||||||
|
/calc.h
|
||||||
|
/mfcalc
|
||||||
|
/mfcalc.c
|
||||||
|
/mfcalc.exe
|
||||||
|
/mfcalc.h
|
||||||
|
/mfcalc.output
|
||||||
|
/mfcalc.stamp
|
||||||
|
/mfcalc.y
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
## -------------------- ##
|
||||||
|
## Building & testing. ##
|
||||||
|
## -------------------- ##
|
||||||
|
|
||||||
|
BUILT_SOURCES += $(mfcalc_sources)
|
||||||
|
CLEANFILES += examples/mfcalc/mfcalc.[ch] examples/mfcalc/mfcalc.output
|
||||||
|
|
||||||
|
mfcalc_extracted = \
|
||||||
|
examples/mfcalc/calc.h \
|
||||||
|
examples/mfcalc/mfcalc.y
|
||||||
|
mfcalc_sources = \
|
||||||
|
$(mfcalc_extracted)
|
||||||
|
extracted += $(mfcalc_extracted)
|
||||||
|
|
||||||
|
check_PROGRAMS += examples/mfcalc/mfcalc
|
||||||
|
examples_mfcalc_mfcalc_LDADD = -lm
|
||||||
|
nodist_examples_mfcalc_mfcalc_SOURCES = \
|
||||||
|
$(mfcalc_sources)
|
||||||
|
|
||||||
|
examples_mfcalc_mfcalc_CPPFLAGS = -I$(top_builddir)/examples/mfcalc
|
||||||
|
dist_TESTS += examples/mfcalc/mfcalc.test
|
||||||
Regular → Executable
+13
-2
@@ -1,5 +1,7 @@
|
|||||||
## Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2005-2012 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
|
||||||
@@ -13,4 +15,13 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
nodist_noinst_SCRIPTS = bench.pl
|
cat >input <<EOF
|
||||||
|
1+2*3
|
||||||
|
EOF
|
||||||
|
run 0 7
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
(1+2) * 3
|
||||||
|
EOF
|
||||||
|
run 0 9
|
||||||
|
run 0 9 -p
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/calc.h
|
||||||
|
/rpcalc.c
|
||||||
|
/rpcalc.h
|
||||||
|
/rpcalc.output
|
||||||
|
/rpcalc.stamp
|
||||||
|
/rpcalc.y
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
## Copyright (C) 2002, 2005-2012 Free Software Foundation, Inc.
|
# Copyright (C) 2005-2006, 2008-2012 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
|
||||||
@@ -13,17 +13,23 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
dist_pkgdata_DATA = README bison.m4 \
|
## -------------------- ##
|
||||||
c-skel.m4 c.m4 yacc.c glr.c \
|
## Building & testing. ##
|
||||||
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
|
## -------------------- ##
|
||||||
java-skel.m4 java.m4 lalr1.java
|
|
||||||
|
|
||||||
m4sugardir = $(pkgdatadir)/m4sugar
|
BUILT_SOURCES += $(rpcalc_sources)
|
||||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/foreach.m4
|
CLEANFILES += examples/rpcalc/rpcalc.[ch] examples/rpcalc/rpcalc.output
|
||||||
|
|
||||||
xsltdir = $(pkgdatadir)/xslt
|
rpcalc_extracted = \
|
||||||
dist_xslt_DATA = \
|
examples/rpcalc/rpcalc.y
|
||||||
xslt/bison.xsl \
|
rpcalc_sources = \
|
||||||
xslt/xml2dot.xsl \
|
$(rpcalc_extracted)
|
||||||
xslt/xml2text.xsl \
|
extracted += $(rpcalc_extracted)
|
||||||
xslt/xml2xhtml.xsl
|
|
||||||
|
check_PROGRAMS += examples/rpcalc/rpcalc
|
||||||
|
examples_rpcalc_rpcalc_LDADD = -lm
|
||||||
|
nodist_examples_rpcalc_rpcalc_SOURCES = \
|
||||||
|
$(rpcalc_sources)
|
||||||
|
|
||||||
|
examples_rpcalc_rpcalc_CPPFLAGS = -I$(top_builddir)/examples/rpcalc
|
||||||
|
dist_TESTS += examples/rpcalc/rpcalc.test
|
||||||
Regular → Executable
+31
-6
@@ -1,6 +1,7 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
#! /bin/sh
|
||||||
## Copyright (C) 2005, 2009-2012 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
|
# Copyright (C) 2005-2012 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
|
||||||
@@ -14,8 +15,32 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
if BISON_CXX_WORKS
|
cat >input <<EOF
|
||||||
SUBDIRS = calc++
|
1 2 3 * +
|
||||||
endif
|
EOF
|
||||||
|
run 0 7
|
||||||
|
|
||||||
dist_noinst_SCRIPTS = extexi
|
cat >input <<EOF
|
||||||
|
1.1 2.2 3.3 * +
|
||||||
|
EOF
|
||||||
|
run 0 8.36
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 2 + 3 *
|
||||||
|
EOF
|
||||||
|
run 0 9
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 2 3 4 5 6 7 8 9 * * * * * * * *
|
||||||
|
EOF
|
||||||
|
run 0 362880
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
3 7 + 3 4 5 * + - n
|
||||||
|
EOF
|
||||||
|
run 0 13
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
3 4 ^
|
||||||
|
EOF
|
||||||
|
run 0 81
|
||||||
Executable
+82
@@ -0,0 +1,82 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2005-2012 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/>.
|
||||||
|
|
||||||
|
me=`basename $1 .test`
|
||||||
|
|
||||||
|
# Number of the current test.
|
||||||
|
number=1
|
||||||
|
|
||||||
|
# Exit status of this script.
|
||||||
|
exit=true
|
||||||
|
|
||||||
|
# top_buiddir.
|
||||||
|
cwd=`pwd`
|
||||||
|
|
||||||
|
# The exercised program.
|
||||||
|
prog=$cwd/examples/$me/$me
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
# -------
|
||||||
|
cleanup ()
|
||||||
|
{
|
||||||
|
local status=$?
|
||||||
|
if test -z "$DEBUG"; then
|
||||||
|
cd $cwd
|
||||||
|
rm -rf $$.dir
|
||||||
|
fi
|
||||||
|
exit $status
|
||||||
|
}
|
||||||
|
trap cleanup 0 1 2 13 15
|
||||||
|
mkdir $$.dir
|
||||||
|
cd $$.dir
|
||||||
|
|
||||||
|
# run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
run ()
|
||||||
|
{
|
||||||
|
# Expected exit status.
|
||||||
|
local sta_exp=$1
|
||||||
|
shift
|
||||||
|
# Expected output.
|
||||||
|
local out_exp=$1
|
||||||
|
shift
|
||||||
|
$prog "$@" - <input >out_eff
|
||||||
|
# Effective exit status.
|
||||||
|
local sta_eff=$?
|
||||||
|
# Effective output.
|
||||||
|
local out_eff=`cat out_eff`
|
||||||
|
if test $sta_eff -eq $sta_exp; then
|
||||||
|
if test "$out_eff" = "$out_exp"; then
|
||||||
|
echo "$me: PASS: $number"
|
||||||
|
else
|
||||||
|
echo "$me: FAIL: $number (expected output: $out_exp, effective: $out_eff)"
|
||||||
|
exit=false
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)"
|
||||||
|
exit=false
|
||||||
|
fi
|
||||||
|
number=`expr $number + 1`
|
||||||
|
}
|
||||||
|
|
||||||
|
# We have cd'd one level deeper.
|
||||||
|
case $1 in
|
||||||
|
/*) . "$1";;
|
||||||
|
*) . "../$1";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$exit
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2008-2012 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
%debug
|
||||||
|
%skeleton "lalr1.cc"
|
||||||
|
%defines
|
||||||
|
%define parse.assert
|
||||||
|
%define variant
|
||||||
|
%define lex_symbol
|
||||||
|
%locations
|
||||||
|
|
||||||
|
%code requires // *.hh
|
||||||
|
{
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
typedef std::list<std::string> strings_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
%code // *.cc
|
||||||
|
{
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// Prototype of the yylex function providing subsequent tokens.
|
||||||
|
static yy::parser::symbol_type yylex ();
|
||||||
|
|
||||||
|
// Printing a list of strings.
|
||||||
|
// Koening look up will look into std, since that's an std::list.
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
std::ostream&
|
||||||
|
operator<< (std::ostream& o, const strings_type& s)
|
||||||
|
{
|
||||||
|
std::copy (s.begin (), s.end (),
|
||||||
|
std::ostream_iterator<strings_type::value_type> (o, "\n"));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conversion to string.
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
std::string
|
||||||
|
string_cast (const T& t)
|
||||||
|
{
|
||||||
|
std::ostringstream o;
|
||||||
|
o << t;
|
||||||
|
return o.str ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%token <::std::string> TEXT;
|
||||||
|
%token <int> NUMBER;
|
||||||
|
%printer { debug_stream () << $$; }
|
||||||
|
<int> <::std::string> <::std::list<std::string>>;
|
||||||
|
%token END_OF_FILE 0;
|
||||||
|
|
||||||
|
%type <::std::string> item;
|
||||||
|
%type <::std::list<std::string>> list;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
result:
|
||||||
|
list { std::cout << $1 << std::endl; }
|
||||||
|
;
|
||||||
|
|
||||||
|
list:
|
||||||
|
/* nothing */ { /* Generates an empty string list */ }
|
||||||
|
| list item { std::swap ($$, $1); $$.push_back ($2); }
|
||||||
|
;
|
||||||
|
|
||||||
|
item:
|
||||||
|
TEXT { std::swap ($$, $1); }
|
||||||
|
| NUMBER { $$ = string_cast ($1); }
|
||||||
|
;
|
||||||
|
%%
|
||||||
|
|
||||||
|
// The yylex function providing subsequent tokens:
|
||||||
|
// TEXT "I have three numbers for you:"
|
||||||
|
// NUMBER 1
|
||||||
|
// NUMBER 2
|
||||||
|
// NUMBER 3
|
||||||
|
// TEXT " and that's all!"
|
||||||
|
// END_OF_FILE
|
||||||
|
|
||||||
|
static
|
||||||
|
yy::parser::symbol_type
|
||||||
|
yylex ()
|
||||||
|
{
|
||||||
|
static int stage = -1;
|
||||||
|
++stage;
|
||||||
|
yy::parser::location_type loc(0, stage + 1, stage + 1);
|
||||||
|
switch (stage)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return yy::parser::make_TEXT ("I have three numbers for you.", loc);
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
return yy::parser::make_NUMBER (stage, loc);
|
||||||
|
case 4:
|
||||||
|
return yy::parser::make_TEXT ("And that's all!", loc);
|
||||||
|
default:
|
||||||
|
return yy::parser::make_END_OF_FILE (loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mandatory error function
|
||||||
|
void
|
||||||
|
yy::parser::error (const yy::parser::location_type& loc, const std::string& msg)
|
||||||
|
{
|
||||||
|
std::cerr << loc << ": " << msg << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
yy::parser p;
|
||||||
|
p.set_debug_level (!!getenv ("YYDEBUG"));
|
||||||
|
return p.parse ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: C++
|
||||||
|
// End:
|
||||||
+4
-2
@@ -109,9 +109,7 @@
|
|||||||
/mbchar.c
|
/mbchar.c
|
||||||
/mbchar.h
|
/mbchar.h
|
||||||
/mbrtowc.c
|
/mbrtowc.c
|
||||||
/mbschr.c
|
|
||||||
/mbsinit.c
|
/mbsinit.c
|
||||||
/mbsrchr.c
|
|
||||||
/mbswidth.c
|
/mbswidth.c
|
||||||
/mbswidth.h
|
/mbswidth.h
|
||||||
/mbuiter.h
|
/mbuiter.h
|
||||||
@@ -268,3 +266,7 @@
|
|||||||
/xmemdup0.c
|
/xmemdup0.c
|
||||||
/xmemdup0.h
|
/xmemdup0.h
|
||||||
/sys_types.in.h
|
/sys_types.in.h
|
||||||
|
/concat-filename.c
|
||||||
|
/concat-filename.h
|
||||||
|
/filename.h
|
||||||
|
/xconcat-filename.c
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
# Make bison/lib.
|
|
||||||
|
|
||||||
# Copyright (C) 2001-2004, 2006, 2008-2012 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/>.
|
|
||||||
|
|
||||||
AM_CFLAGS =
|
|
||||||
AM_CPPFLAGS =
|
|
||||||
BUILT_SOURCES =
|
|
||||||
CLEANFILES =
|
|
||||||
EXTRA_DIST =
|
|
||||||
MOSTLYCLEANDIRS =
|
|
||||||
MOSTLYCLEANFILES =
|
|
||||||
SUFFIXES =
|
|
||||||
noinst_LIBRARIES =
|
|
||||||
|
|
||||||
include gnulib.mk
|
|
||||||
|
|
||||||
AM_CFLAGS += $(WARN_CFLAGS)
|
|
||||||
|
|
||||||
# Implementation of bitsets.
|
|
||||||
bitsets_sources = \
|
|
||||||
abitset.c abitset.h bbitset.h bitset.c bitset.h bitset_stats.c \
|
|
||||||
bitset_stats.h bitsetv.c bitsetv.h ebitset.c ebitset.h lbitset.c \
|
|
||||||
lbitset.h libiberty.h vbitset.c vbitset.h
|
|
||||||
|
|
||||||
# Additional bitset operations.
|
|
||||||
additional_bitsets_sources = \
|
|
||||||
bitsetv-print.h bitsetv-print.c
|
|
||||||
|
|
||||||
# timevars, stolen from GCC.
|
|
||||||
timevars_sources = \
|
|
||||||
timevar.h timevar.c timevar.def
|
|
||||||
|
|
||||||
# Non-gnulib sources in Bison's internal library.
|
|
||||||
libbison_a_SOURCES += \
|
|
||||||
get-errno.h get-errno.c \
|
|
||||||
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
|
|
||||||
|
|
||||||
# The Yacc compatibility library.
|
|
||||||
lib_LIBRARIES = $(YACC_LIBRARY)
|
|
||||||
EXTRA_LIBRARIES = liby.a
|
|
||||||
liby_a_SOURCES = main.c yyerror.c
|
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/* Functions to support link list bitsets.
|
/* Functions to support link list bitsets.
|
||||||
|
|
||||||
Copyright (C) 2002-2004, 2006, 2009-2012 Free Software Foundation,
|
Copyright (C) 2002-2004, 2006, 2009-2012 Free Software Foundation, Inc.
|
||||||
Inc.
|
|
||||||
|
|
||||||
Contributed by Michael Hayes ([email protected]).
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
include lib/gnulib.mk
|
||||||
|
|
||||||
|
# Implementation of bitsets.
|
||||||
|
lib_libbison_a_SOURCES += \
|
||||||
|
lib/abitset.c \
|
||||||
|
lib/abitset.h \
|
||||||
|
lib/bbitset.h \
|
||||||
|
lib/bitset.c \
|
||||||
|
lib/bitset.h \
|
||||||
|
lib/bitset_stats.c \
|
||||||
|
lib/bitset_stats.h \
|
||||||
|
lib/bitsetv.c \
|
||||||
|
lib/bitsetv.h \
|
||||||
|
lib/ebitset.c \
|
||||||
|
lib/ebitset.h \
|
||||||
|
lib/lbitset.c \
|
||||||
|
lib/lbitset.h \
|
||||||
|
lib/libiberty.h \
|
||||||
|
lib/vbitset.c \
|
||||||
|
lib/vbitset.h
|
||||||
|
|
||||||
|
# Additional bitset operations.
|
||||||
|
lib_libbison_a_SOURCES += \
|
||||||
|
lib/bitsetv-print.h \
|
||||||
|
lib/bitsetv-print.c
|
||||||
|
|
||||||
|
# timevars, stolen from GCC.
|
||||||
|
lib_libbison_a_SOURCES += \
|
||||||
|
lib/timevar.h \
|
||||||
|
lib/timevar.c \
|
||||||
|
lib/timevar.def
|
||||||
|
|
||||||
|
# Non-gnulib sources in Bison's internal library.
|
||||||
|
lib_libbison_a_SOURCES += \
|
||||||
|
lib/get-errno.h \
|
||||||
|
lib/get-errno.c
|
||||||
|
|
||||||
|
# The Yacc compatibility library.
|
||||||
|
lib_LIBRARIES = $(YACC_LIBRARY)
|
||||||
|
EXTRA_LIBRARIES = lib/liby.a
|
||||||
|
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
/inline.m4
|
/inline.m4
|
||||||
/intdiv0.m4
|
/intdiv0.m4
|
||||||
/intl.m4
|
/intl.m4
|
||||||
|
/intl.m4~
|
||||||
/intldir.m4
|
/intldir.m4
|
||||||
/intlmacosx.m4
|
/intlmacosx.m4
|
||||||
/intmax.m4
|
/intmax.m4
|
||||||
@@ -102,6 +103,7 @@
|
|||||||
/perror.m4
|
/perror.m4
|
||||||
/pipe2.m4
|
/pipe2.m4
|
||||||
/po.m4
|
/po.m4
|
||||||
|
/po.m4~
|
||||||
/posix_spawn.m4
|
/posix_spawn.m4
|
||||||
/printf-frexp.m4
|
/printf-frexp.m4
|
||||||
/printf-frexpl.m4
|
/printf-frexpl.m4
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
/Makefile
|
/Makefile
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
/Makefile.in.in
|
/Makefile.in.in
|
||||||
|
/Makefile.in.in~
|
||||||
/Makevars
|
/Makevars
|
||||||
/Makevars.template
|
/Makevars.template
|
||||||
/POTFILES
|
/POTFILES
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
/Makefile
|
/Makefile
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
/Makefile.in.in
|
/Makefile.in.in
|
||||||
|
/Makefile.in.in~
|
||||||
/Makevars
|
/Makevars
|
||||||
/Makevars.template
|
/Makevars.template
|
||||||
/POTFILES
|
/POTFILES
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
/*.output
|
/*.output
|
||||||
/.deps
|
/.deps
|
||||||
/.dirstamp
|
/.dirstamp
|
||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
/bison
|
/bison
|
||||||
/bison.exe
|
/bison.exe
|
||||||
/scan-code.c
|
/scan-code.c
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ typedef struct InadequacyList {
|
|||||||
* <tt>manifesting_state->reductions->num + 1</tt>.
|
* <tt>manifesting_state->reductions->num + 1</tt>.
|
||||||
* - If the set of all \c InadequacyList nodes with which the new
|
* - If the set of all \c InadequacyList nodes with which the new
|
||||||
* \c InadequacyList node might be compared is currently empty, then
|
* \c InadequacyList node might be compared is currently empty, then
|
||||||
* it is best if <tt>*node_count</t> is zero so that the node count
|
* it is best if <tt>*node_count</tt> is zero so that the node count
|
||||||
* does not eventually overflow. However, if that set is not
|
* does not eventually overflow. However, if that set is not
|
||||||
* currently empty, then <tt>*node_count</tt> has not been modified
|
* currently empty, then <tt>*node_count</tt> has not been modified
|
||||||
* by any function except \c InadequacyList__new_conflict since the
|
* by any function except \c InadequacyList__new_conflict since the
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* Generate the LR(0) parser states for Bison.
|
/* Generate the LR(0) parser states for Bison.
|
||||||
|
|
||||||
Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2007, 2009-2012 Free
|
Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2012 Free Software
|
||||||
Software Foundation, Inc.
|
Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "getargs.h"
|
#include "getargs.h"
|
||||||
#include "gram.h"
|
#include "gram.h"
|
||||||
#include "gram.h"
|
|
||||||
#include "lalr.h"
|
#include "lalr.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "reduce.h"
|
#include "reduce.h"
|
||||||
|
|||||||
-117
@@ -1,117 +0,0 @@
|
|||||||
# Make bison/src.
|
|
||||||
|
|
||||||
# Copyright (C) 2001-2012 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/>.
|
|
||||||
|
|
||||||
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/lib
|
|
||||||
BISON = ../tests/bison
|
|
||||||
# Use our own Bison to build the parser. Of course, you ought to
|
|
||||||
# keep a sane version of Bison nearby...
|
|
||||||
YACC = $(BISON) -y
|
|
||||||
AM_YFLAGS = -d -v --warnings=all,error --report=all
|
|
||||||
|
|
||||||
LDADD = ../lib/libbison.a $(LIBINTL)
|
|
||||||
|
|
||||||
bin_PROGRAMS = bison
|
|
||||||
bin_SCRIPTS = $(YACC_SCRIPT)
|
|
||||||
EXTRA_SCRIPTS = yacc
|
|
||||||
|
|
||||||
bison_SOURCES = \
|
|
||||||
AnnotationList.c AnnotationList.h \
|
|
||||||
InadequacyList.c InadequacyList.h \
|
|
||||||
LR0.c LR0.h \
|
|
||||||
Sbitset.c Sbitset.h \
|
|
||||||
assoc.c assoc.h \
|
|
||||||
closure.c closure.h \
|
|
||||||
complain.c complain.h \
|
|
||||||
conflicts.c conflicts.h \
|
|
||||||
derives.c derives.h \
|
|
||||||
files.c files.h \
|
|
||||||
flex-scanner.h \
|
|
||||||
getargs.c getargs.h \
|
|
||||||
gram.c gram.h \
|
|
||||||
lalr.h lalr.c \
|
|
||||||
ielr.h ielr.c \
|
|
||||||
location.c location.h \
|
|
||||||
main.c \
|
|
||||||
muscle-tab.c muscle-tab.h \
|
|
||||||
named-ref.c named-ref.h \
|
|
||||||
nullable.c nullable.h \
|
|
||||||
output.c output.h \
|
|
||||||
parse-gram.y \
|
|
||||||
print.c print.h \
|
|
||||||
print_graph.c print_graph.h \
|
|
||||||
print-xml.c print-xml.h \
|
|
||||||
reader.c reader.h \
|
|
||||||
reduce.c reduce.h \
|
|
||||||
relation.c relation.h \
|
|
||||||
scan-code.h scan-code-c.c \
|
|
||||||
scan-gram.h scan-gram-c.c \
|
|
||||||
scan-skel.h scan-skel-c.c \
|
|
||||||
state.c state.h \
|
|
||||||
symlist.c symlist.h \
|
|
||||||
symtab.c symtab.h \
|
|
||||||
system.h \
|
|
||||||
tables.h tables.c \
|
|
||||||
uniqstr.c uniqstr.h \
|
|
||||||
graphviz.c graphviz.h
|
|
||||||
|
|
||||||
EXTRA_bison_SOURCES = scan-code.l scan-skel.l scan-gram.l
|
|
||||||
|
|
||||||
BUILT_SOURCES = \
|
|
||||||
parse-gram.c parse-gram.h \
|
|
||||||
scan-code.c \
|
|
||||||
scan-skel.c \
|
|
||||||
scan-gram.c
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES = yacc
|
|
||||||
|
|
||||||
yacc:
|
|
||||||
$(AM_V_GEN)echo '#! /bin/sh' >$@
|
|
||||||
$(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
|
|
||||||
$(AM_V_at)chmod a+x $@
|
|
||||||
|
|
||||||
|
|
||||||
# The following rule is not designed to be portable,
|
|
||||||
# and relies on tools that not everyone has.
|
|
||||||
|
|
||||||
# Most functions in src/*.c should have static scope.
|
|
||||||
# Any that don't must be marked with `extern', but `main'
|
|
||||||
# and `usage' are exceptions. They're always extern, but
|
|
||||||
# don't need to be marked.
|
|
||||||
#
|
|
||||||
# The second nm|grep checks for file-scope variables with `extern' scope.
|
|
||||||
sc_tight_scope: $(all_programs)
|
|
||||||
@t=exceptions-$$$$; \
|
|
||||||
trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15; \
|
|
||||||
( printf '^main$$\n^usage$$\n'; \
|
|
||||||
grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
|
|
||||||
| grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
|
|
||||||
if nm -e *.$(OBJEXT) \
|
|
||||||
| sed -n 's/.* T //p' \
|
|
||||||
| grep -Ev -f $$t; then \
|
|
||||||
echo 'the above functions should have static scope' 1>&2; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
( printf '^program_name$$\n'; \
|
|
||||||
sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
|
|
||||||
$$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t; \
|
|
||||||
if nm -e *.$(OBJEXT) \
|
|
||||||
| sed -n 's/.* [BD] //p' \
|
|
||||||
| grep -Ev -f $$t; then \
|
|
||||||
echo 'the above variables should have static scope' 1>&2; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
+4
-1
@@ -1,6 +1,6 @@
|
|||||||
/* Associativity information.
|
/* Associativity information.
|
||||||
|
|
||||||
Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation,
|
Copyright (C) 2002, 2005-2006, 2008-2012 Free Software Foundation,
|
||||||
Inc.
|
Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
@@ -43,5 +43,8 @@ assoc_to_string (assoc a)
|
|||||||
|
|
||||||
case non_assoc:
|
case non_assoc:
|
||||||
return "%nonassoc";
|
return "%nonassoc";
|
||||||
|
|
||||||
|
case precedence_assoc:
|
||||||
|
return "%precedence";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -1,6 +1,6 @@
|
|||||||
/* Associativity information.
|
/* Associativity information.
|
||||||
|
|
||||||
Copyright (C) 2002, 2006, 2009-2012 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2006, 2008-2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -23,10 +23,11 @@
|
|||||||
/* Associativity values for tokens and rules. */
|
/* Associativity values for tokens and rules. */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
undef_assoc,
|
undef_assoc, /** Not defined. */
|
||||||
right_assoc,
|
right_assoc, /** %right */
|
||||||
left_assoc,
|
left_assoc, /** %left */
|
||||||
non_assoc
|
non_assoc, /** %nonassoc */
|
||||||
|
precedence_assoc /** %precedence */
|
||||||
} assoc;
|
} assoc;
|
||||||
|
|
||||||
char const *assoc_to_string (assoc a);
|
char const *assoc_to_string (assoc a);
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ print_fderives (void)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "\t\t%3d ", r);
|
fprintf (stderr, "\t\t%3d ", r);
|
||||||
rule_rhs_print (&rules[r], stderr);
|
rule_rhs_print (&rules[r], stderr);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n\n");
|
fprintf (stderr, "\n\n");
|
||||||
|
|||||||
+98
-117
@@ -29,15 +29,43 @@
|
|||||||
#include "files.h"
|
#include "files.h"
|
||||||
#include "getargs.h"
|
#include "getargs.h"
|
||||||
|
|
||||||
|
warnings warnings_flag = Wconflicts_sr | Wconflicts_rr | Wother;
|
||||||
|
|
||||||
bool complaint_issued;
|
bool complaint_issued;
|
||||||
static unsigned *indent_ptr = 0;
|
static unsigned *indent_ptr = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
warnings_print_categories (warnings warn_flags)
|
||||||
|
{
|
||||||
|
if (! (warn_flags & silent))
|
||||||
|
{
|
||||||
|
char const *warn_names[] =
|
||||||
|
{
|
||||||
|
"midrule-values",
|
||||||
|
"yacc",
|
||||||
|
"conflicts-sr",
|
||||||
|
"conflicts-rr",
|
||||||
|
"other"
|
||||||
|
};
|
||||||
|
|
||||||
|
bool any = false;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < ARRAY_CARDINALITY (warn_names); ++i)
|
||||||
|
if (warn_flags & 1 << i)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s-W%s", any ? ", " : " [", warn_names[i]);
|
||||||
|
any = true;
|
||||||
|
}
|
||||||
|
if (any)
|
||||||
|
fprintf (stderr, "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Report an error message.
|
/** Report an error message.
|
||||||
*
|
*
|
||||||
* \param loc the location, defaulting to the current file,
|
* \param loc the location, defaulting to the current file,
|
||||||
* or the program name.
|
* or the program name.
|
||||||
|
* \param flags the category for this message.
|
||||||
* \param prefix put before the message (e.g., "warning").
|
* \param prefix put before the message (e.g., "warning").
|
||||||
* \param message the error message, a printf format string. Iff it
|
* \param message the error message, a printf format string. Iff it
|
||||||
* ends with ": ", then no trailing newline is printed,
|
* ends with ": ", then no trailing newline is printed,
|
||||||
@@ -47,10 +75,10 @@ static unsigned *indent_ptr = 0;
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
error_message (location *loc,
|
error_message (const location *loc, warnings flags, const char *prefix,
|
||||||
const char *prefix,
|
|
||||||
const char *message, va_list args)
|
const char *message, va_list args)
|
||||||
{
|
{
|
||||||
|
(void) flags;
|
||||||
unsigned pos = 0;
|
unsigned pos = 0;
|
||||||
|
|
||||||
if (loc)
|
if (loc)
|
||||||
@@ -72,24 +100,82 @@ error_message (location *loc,
|
|||||||
fprintf (stderr, "%s: ", prefix);
|
fprintf (stderr, "%s: ", prefix);
|
||||||
|
|
||||||
vfprintf (stderr, message, args);
|
vfprintf (stderr, message, args);
|
||||||
|
warnings_print_categories (flags);
|
||||||
{
|
{
|
||||||
size_t l = strlen (message);
|
size_t l = strlen (message);
|
||||||
if (l < 2 || message[l-2] != ':' || message[l-1] != ' ') {
|
if (l < 2 || message[l-2] != ':' || message[l-1] != ' ')
|
||||||
|
{
|
||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wrap error_message() with varargs handling. */
|
/** Raise a complaint. That can be a fatal error, a complaint or just a
|
||||||
#define ERROR_MESSAGE(Loc, Prefix, Message) \
|
warning. */
|
||||||
{ \
|
|
||||||
va_list args; \
|
static inline void
|
||||||
va_start (args, Message); \
|
complains (const location *loc, warnings flags, const char *message,
|
||||||
error_message (Loc, Prefix, Message, args); \
|
va_list args)
|
||||||
va_end (args); \
|
{
|
||||||
|
if (flags & complaint)
|
||||||
|
{
|
||||||
|
error_message (loc, complaint, NULL, message, args);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
else if (flags & fatal)
|
||||||
|
{
|
||||||
|
error_message (loc, fatal, _("fatal error"), message, args);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
else if (flags & Wyacc)
|
||||||
|
{
|
||||||
|
if (yacc_flag)
|
||||||
|
{
|
||||||
|
error_message (loc, flags, NULL, message, args);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
else if (warnings_flag & Wyacc)
|
||||||
|
{
|
||||||
|
set_warning_issued ();
|
||||||
|
error_message (loc, flags, _("warning"), message, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (warnings_flag & flags)
|
||||||
|
{
|
||||||
|
set_warning_issued ();
|
||||||
|
error_message (loc, flags, _("warning"), message, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
complain (warnings flags, const char *message, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start (args, message);
|
||||||
|
complains (NULL, flags, message, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
complain_at (location loc, warnings flags, const char *message, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start (args, message);
|
||||||
|
complains (&loc, flags, message, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void complain_at_indent (location loc, warnings flags, unsigned *indent,
|
||||||
|
const char *message, ...)
|
||||||
|
{
|
||||||
|
indent_ptr = indent;
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start (args, message);
|
||||||
|
complains (&loc, flags, message, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Report a warning, and proceed. |
|
| Report a warning, and proceed. |
|
||||||
@@ -99,115 +185,10 @@ void
|
|||||||
set_warning_issued (void)
|
set_warning_issued (void)
|
||||||
{
|
{
|
||||||
static bool warning_issued = false;
|
static bool warning_issued = false;
|
||||||
if (!warning_issued && (warnings_flag & warnings_error))
|
if (!warning_issued && (warnings_flag & Werror))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
|
fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
|
||||||
complaint_issued = true;
|
complaint_issued = true;
|
||||||
}
|
}
|
||||||
warning_issued = true;
|
warning_issued = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
warn_at (location loc, const char *message, ...)
|
|
||||||
{
|
|
||||||
if (!(warnings_flag & warnings_other))
|
|
||||||
return;
|
|
||||||
set_warning_issued ();
|
|
||||||
ERROR_MESSAGE (&loc, _("warning"), message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
warn_at_indent (location loc, unsigned *indent,
|
|
||||||
const char *message, ...)
|
|
||||||
{
|
|
||||||
if (!(warnings_flag & warnings_other))
|
|
||||||
return;
|
|
||||||
set_warning_issued ();
|
|
||||||
indent_ptr = indent;
|
|
||||||
ERROR_MESSAGE (&loc, _("warning"), message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
warn (const char *message, ...)
|
|
||||||
{
|
|
||||||
if (!(warnings_flag & warnings_other))
|
|
||||||
return;
|
|
||||||
set_warning_issued ();
|
|
||||||
ERROR_MESSAGE (NULL, _("warning"), message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------.
|
|
||||||
| An error has occurred, but we can proceed, and die later. |
|
|
||||||
`-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
|
||||||
complain_at (location loc, const char *message, ...)
|
|
||||||
{
|
|
||||||
ERROR_MESSAGE (&loc, NULL, message);
|
|
||||||
complaint_issued = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
complain_at_indent (location loc, unsigned *indent,
|
|
||||||
const char *message, ...)
|
|
||||||
{
|
|
||||||
indent_ptr = indent;
|
|
||||||
ERROR_MESSAGE (&loc, NULL, message);
|
|
||||||
complaint_issued = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
complain (const char *message, ...)
|
|
||||||
{
|
|
||||||
ERROR_MESSAGE (NULL, NULL, message);
|
|
||||||
complaint_issued = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------.
|
|
||||||
| An incompatibility with POSIX Yacc: mapped either to warn* or |
|
|
||||||
| complain* depending on yacc_flag. |
|
|
||||||
`--------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
|
||||||
yacc_at (location loc, const char *message, ...)
|
|
||||||
{
|
|
||||||
if (yacc_flag)
|
|
||||||
{
|
|
||||||
ERROR_MESSAGE (&loc, NULL, message);
|
|
||||||
complaint_issued = true;
|
|
||||||
}
|
|
||||||
else if (warnings_flag & warnings_yacc)
|
|
||||||
{
|
|
||||||
set_warning_issued ();
|
|
||||||
ERROR_MESSAGE (&loc, _("warning"), message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
midrule_value_at (location loc, const char *message, ...)
|
|
||||||
{
|
|
||||||
if (!(warnings_flag & warnings_midrule_values))
|
|
||||||
return;
|
|
||||||
set_warning_issued ();
|
|
||||||
ERROR_MESSAGE (&loc, _("warning"), message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------------------.
|
|
||||||
| A severe error has occurred, we cannot proceed. |
|
|
||||||
`-------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
|
||||||
fatal_at (location loc, const char *message, ...)
|
|
||||||
{
|
|
||||||
ERROR_MESSAGE (&loc, _("fatal error"), message);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
fatal (const char *message, ...)
|
|
||||||
{
|
|
||||||
ERROR_MESSAGE (NULL, _("fatal error"), message);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|||||||
+35
-47
@@ -25,63 +25,51 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/*-------------.
|
||||||
|
| --warnings. |
|
||||||
|
`-------------*/
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Wnone = 0, /**< Issue no warnings. */
|
||||||
|
Wmidrule_values = 1 << 0, /**< Unset or unused midrule values. */
|
||||||
|
Wyacc = 1 << 1, /**< POSIXME. */
|
||||||
|
Wconflicts_sr = 1 << 2, /**< S/R conflicts. */
|
||||||
|
Wconflicts_rr = 1 << 3, /**< R/R conflicts. */
|
||||||
|
Wother = 1 << 4, /**< All other warnings. */
|
||||||
|
|
||||||
|
Werror = 1 << 10, /**< Warnings are treated as errors. */
|
||||||
|
complaint = 1 << 11, /**< All complaints. */
|
||||||
|
fatal = 1 << 12, /**< All fatal errors. */
|
||||||
|
silent = 1 << 13, /**< Do not display the warning type. */
|
||||||
|
Wall = ~Werror /**< All above warnings. */
|
||||||
|
} warnings;
|
||||||
|
|
||||||
|
/** What warnings are issued. */
|
||||||
|
extern warnings warnings_flag;
|
||||||
|
|
||||||
|
/** Display a "[-Wyacc]" like message on stderr. */
|
||||||
|
void warnings_print_categories (warnings warn_flags);
|
||||||
|
|
||||||
/** Record that a warning is about to be issued, and treat it as an
|
/** Record that a warning is about to be issued, and treat it as an
|
||||||
error if <tt>warnings_flag & warnings_error</tt>. This is exported
|
error if <tt>warnings_flag & Werror</tt>. This is exported
|
||||||
only for the sake of Yacc-compatible conflict reports in conflicts.c.
|
only for the sake of Yacc-compatible conflict reports in conflicts.c.
|
||||||
All other warnings should be implemented in complain.c and should use
|
All other warnings should be implemented in complain.c and should use
|
||||||
the normal warning format. */
|
the normal warning format. */
|
||||||
void set_warning_issued (void);
|
void set_warning_issued (void);
|
||||||
|
|
||||||
/** Informative messages, but we proceed. Report iff
|
/** Make a complaint, but don't specify any location. */
|
||||||
<tt>warnings_flag & warnings_other</tt>. */
|
void complain (warnings flags, char const *message, ...)
|
||||||
|
|
||||||
void warn (char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
|
||||||
|
|
||||||
void warn_at (location loc, char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
/* Generate a message aligned by an indent.
|
/** Make a complaint with location. */
|
||||||
When *indent == 0, assign message's indent to *indent,
|
void complain_at (location loc, warnings flags, char const *message, ...)
|
||||||
When *indent > 0, align the message by *indent value. */
|
|
||||||
void warn_at_indent (location loc, unsigned *indent,
|
|
||||||
char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
|
||||||
/** An error, but we continue and die later. */
|
/** Make a complaint with location and some indentation. */
|
||||||
|
void complain_at_indent (location loc, warnings flags, unsigned *indent,
|
||||||
void complain (char const *format, ...)
|
char const *message, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
void complain_at (location loc, char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
|
||||||
|
|
||||||
/* Generate a message aligned by an indent.
|
|
||||||
When *indent == 0, assign message's indent to *indent,
|
|
||||||
When *indent > 0, align the message by *indent value. */
|
|
||||||
void complain_at_indent (location loc, unsigned *indent,
|
|
||||||
char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
|
||||||
|
|
||||||
/** An incompatibility with POSIX Yacc: mapped either to warn* or
|
|
||||||
complain* depending on yacc_flag. */
|
|
||||||
|
|
||||||
void yacc_at (location loc, char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
|
||||||
|
|
||||||
/** A midrule-value warning. Report iff
|
|
||||||
<tt>warnings_flag & warnings_midrule_values</tt>. */
|
|
||||||
|
|
||||||
void midrule_value_at (location loc, char const *format, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
|
||||||
|
|
||||||
/** A fatal error, causing immediate exit. */
|
|
||||||
|
|
||||||
void fatal (char const *format, ...)
|
|
||||||
__attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)));
|
|
||||||
|
|
||||||
void fatal_at (location loc, char const *format, ...)
|
|
||||||
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
|
|
||||||
|
|
||||||
/** Whether an error was reported. */
|
/** Whether an error was reported. */
|
||||||
extern bool complaint_issued;
|
extern bool complaint_issued;
|
||||||
|
|||||||
+16
-11
@@ -1,7 +1,7 @@
|
|||||||
/* Find and resolve or report lookahead conflicts for bison,
|
/* Find and resolve or report lookahead conflicts for bison,
|
||||||
|
|
||||||
Copyright (C) 1984, 1989, 1992, 2000-2007, 2009-2012 Free Software
|
Copyright (C) 1984, 1989, 1992, 2000-2012 Free Software Foundation,
|
||||||
Foundation, Inc.
|
Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -286,15 +286,20 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Matching precedence levels.
|
/* Matching precedence levels.
|
||||||
For left association, keep only the reduction.
|
For non-defined associativity, keep both: unexpected
|
||||||
For right association, keep only the shift.
|
associativity conflict.
|
||||||
For nonassociation, keep neither. */
|
For left associativity, keep only the reduction.
|
||||||
|
For right associativity, keep only the shift.
|
||||||
|
For nonassociativity, keep neither. */
|
||||||
|
|
||||||
switch (symbols[i]->assoc)
|
switch (symbols[i]->assoc)
|
||||||
{
|
{
|
||||||
default:
|
case undef_assoc:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
|
case precedence_assoc:
|
||||||
|
break;
|
||||||
|
|
||||||
case right_assoc:
|
case right_assoc:
|
||||||
log_resolution (redrule, i, right_resolution);
|
log_resolution (redrule, i, right_resolution);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
@@ -579,7 +584,7 @@ conflicts_print (void)
|
|||||||
|
|
||||||
if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
|
if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
|
||||||
{
|
{
|
||||||
warn (_("%%expect-rr applies only to GLR parsers"));
|
complain (Wother, _("%%expect-rr applies only to GLR parsers"));
|
||||||
expected_rr_conflicts = -1;
|
expected_rr_conflicts = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,9 +601,9 @@ conflicts_print (void)
|
|||||||
/* Report the total number of conflicts on STDERR. */
|
/* Report the total number of conflicts on STDERR. */
|
||||||
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
|
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
|
||||||
{
|
{
|
||||||
if (!(warnings_flag & warnings_conflicts_sr))
|
if (!(warnings_flag & Wconflicts_sr))
|
||||||
src_total = 0;
|
src_total = 0;
|
||||||
if (!(warnings_flag & warnings_conflicts_rr))
|
if (!(warnings_flag & Wconflicts_rr))
|
||||||
rrc_total = 0;
|
rrc_total = 0;
|
||||||
}
|
}
|
||||||
if (src_total | rrc_total)
|
if (src_total | rrc_total)
|
||||||
@@ -613,12 +618,12 @@ conflicts_print (void)
|
|||||||
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
|
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
|
||||||
{
|
{
|
||||||
if (! src_ok)
|
if (! src_ok)
|
||||||
complain (ngettext ("expected %d shift/reduce conflict",
|
complain (complaint, ngettext ("expected %d shift/reduce conflict",
|
||||||
"expected %d shift/reduce conflicts",
|
"expected %d shift/reduce conflicts",
|
||||||
src_expected),
|
src_expected),
|
||||||
src_expected);
|
src_expected);
|
||||||
if (! rrc_ok)
|
if (! rrc_ok)
|
||||||
complain (ngettext ("expected %d reduce/reduce conflict",
|
complain (complaint, ngettext ("expected %d reduce/reduce conflict",
|
||||||
"expected %d reduce/reduce conflicts",
|
"expected %d reduce/reduce conflicts",
|
||||||
rrc_expected),
|
rrc_expected),
|
||||||
rrc_expected);
|
rrc_expected);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ print_derives (void)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
||||||
rule_rhs_print (*rp, stderr);
|
rule_rhs_print (*rp, stderr);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-9
@@ -134,6 +134,18 @@ xfclose (FILE *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FILE *
|
||||||
|
xfdopen (int fd, char const *mode)
|
||||||
|
{
|
||||||
|
FILE *res = fdopen (fd, mode);
|
||||||
|
if (! res)
|
||||||
|
error (EXIT_FAILURE, get_errno (),
|
||||||
|
// On a separate line to please the "unmarked_diagnostics"
|
||||||
|
// syntax-check.
|
||||||
|
"fdopen");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
|
| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
|
||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
@@ -142,7 +154,7 @@ xfclose (FILE *ptr)
|
|||||||
static void
|
static void
|
||||||
compute_exts_from_gf (const char *ext)
|
compute_exts_from_gf (const char *ext)
|
||||||
{
|
{
|
||||||
if (strcmp (ext, ".y") == 0)
|
if (STREQ (ext, ".y"))
|
||||||
{
|
{
|
||||||
src_extension = xstrdup (language->src_extension);
|
src_extension = xstrdup (language->src_extension);
|
||||||
header_extension = xstrdup (language->header_extension);
|
header_extension = xstrdup (language->header_extension);
|
||||||
@@ -207,7 +219,7 @@ file_name_split (const char *file_name,
|
|||||||
*base = last_component (file_name);
|
*base = last_component (file_name);
|
||||||
|
|
||||||
/* Look for the extension, i.e., look for the last dot. */
|
/* Look for the extension, i.e., look for the last dot. */
|
||||||
*ext = mbsrchr (*base, '.');
|
*ext = strrchr (*base, '.');
|
||||||
*tab = NULL;
|
*tab = NULL;
|
||||||
|
|
||||||
/* If there is an extension, check if there is a `.tab' part right
|
/* If there is an extension, check if there is a `.tab' part right
|
||||||
@@ -215,10 +227,9 @@ file_name_split (const char *file_name,
|
|||||||
if (*ext)
|
if (*ext)
|
||||||
{
|
{
|
||||||
size_t baselen = *ext - *base;
|
size_t baselen = *ext - *base;
|
||||||
size_t dottablen = 4;
|
size_t dottablen = sizeof (TAB_EXT) - 1;
|
||||||
if (dottablen < baselen
|
if (dottablen < baselen
|
||||||
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
&& STRPREFIX_LIT (TAB_EXT, *ext - dottablen))
|
||||||
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
|
||||||
*tab = *ext - dottablen;
|
*tab = *ext - dottablen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,9 +358,9 @@ void
|
|||||||
output_file_name_check (char **file_name)
|
output_file_name_check (char **file_name)
|
||||||
{
|
{
|
||||||
bool conflict = false;
|
bool conflict = false;
|
||||||
if (0 == strcmp (*file_name, grammar_file))
|
if (STREQ (*file_name, grammar_file))
|
||||||
{
|
{
|
||||||
complain (_("refusing to overwrite the input file %s"),
|
complain (complaint, _("refusing to overwrite the input file %s"),
|
||||||
quote (*file_name));
|
quote (*file_name));
|
||||||
conflict = true;
|
conflict = true;
|
||||||
}
|
}
|
||||||
@@ -357,9 +368,9 @@ output_file_name_check (char **file_name)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < file_names_count; i++)
|
for (i = 0; i < file_names_count; i++)
|
||||||
if (0 == strcmp (file_names[i], *file_name))
|
if (STREQ (file_names[i], *file_name))
|
||||||
{
|
{
|
||||||
warn (_("conflicting outputs to file %s"),
|
complain (Wother, _("conflicting outputs to file %s"),
|
||||||
quote (*file_name));
|
quote (*file_name));
|
||||||
conflict = true;
|
conflict = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -65,7 +65,8 @@ void compute_output_file_names (void);
|
|||||||
void output_file_names_free (void);
|
void output_file_names_free (void);
|
||||||
void output_file_name_check (char **file_name);
|
void output_file_name_check (char **file_name);
|
||||||
|
|
||||||
FILE *xfopen (const char *name, const char *mode);
|
FILE *xfopen (const char *name, char const *mode);
|
||||||
void xfclose (FILE *ptr);
|
void xfclose (FILE *ptr);
|
||||||
|
FILE *xfdopen (int fd, char const *mode);
|
||||||
|
|
||||||
#endif /* !FILES_H_ */
|
#endif /* !FILES_H_ */
|
||||||
|
|||||||
+27
-29
@@ -49,24 +49,18 @@
|
|||||||
#include "quote.h"
|
#include "quote.h"
|
||||||
#include "uniqstr.h"
|
#include "uniqstr.h"
|
||||||
|
|
||||||
bool debug_flag;
|
|
||||||
bool defines_flag;
|
bool defines_flag;
|
||||||
bool graph_flag;
|
bool graph_flag;
|
||||||
bool xml_flag;
|
bool xml_flag;
|
||||||
bool locations_flag;
|
|
||||||
bool no_lines_flag;
|
bool no_lines_flag;
|
||||||
bool token_table_flag;
|
bool token_table_flag;
|
||||||
bool yacc_flag; /* for -y */
|
bool yacc_flag; /* for -y */
|
||||||
|
|
||||||
bool error_verbose = false;
|
|
||||||
|
|
||||||
bool nondeterministic_parser = false;
|
bool nondeterministic_parser = false;
|
||||||
bool glr_parser = false;
|
bool glr_parser = false;
|
||||||
|
|
||||||
int report_flag = report_none;
|
int report_flag = report_none;
|
||||||
int trace_flag = trace_none;
|
int trace_flag = trace_none;
|
||||||
int warnings_flag = warnings_conflicts_sr | warnings_conflicts_rr
|
|
||||||
| warnings_other;
|
|
||||||
|
|
||||||
static struct bison_language const valid_languages[] = {
|
static struct bison_language const valid_languages[] = {
|
||||||
{ "c", "c-skel.m4", ".c", ".h", true },
|
{ "c", "c-skel.m4", ".c", ".h", true },
|
||||||
@@ -106,7 +100,7 @@ flags_argmatch (const char *option,
|
|||||||
args = strtok (args, ",");
|
args = strtok (args, ",");
|
||||||
while (args)
|
while (args)
|
||||||
{
|
{
|
||||||
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
|
int no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
|
||||||
int value = XARGMATCH (option, args + no, keys, values);
|
int value = XARGMATCH (option, args + no, keys, values);
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
@@ -133,15 +127,15 @@ flags_argmatch (const char *option,
|
|||||||
*
|
*
|
||||||
* \param FlagName the flag familly to update.
|
* \param FlagName the flag familly to update.
|
||||||
* \param Args the effective sub arguments to decode.
|
* \param Args the effective sub arguments to decode.
|
||||||
|
* \param All the "all" value.
|
||||||
*
|
*
|
||||||
* \arg FlagName_args the list of keys.
|
* \arg FlagName_args the list of keys.
|
||||||
* \arg FlagName_types the list of values.
|
* \arg FlagName_types the list of values.
|
||||||
* \arg FlagName_all the all value.
|
|
||||||
* \arg FlagName_flag the flag to update.
|
* \arg FlagName_flag the flag to update.
|
||||||
*/
|
*/
|
||||||
#define FLAGS_ARGMATCH(FlagName, Args) \
|
#define FLAGS_ARGMATCH(FlagName, Args, All) \
|
||||||
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
||||||
FlagName ## _all, &FlagName ## _flag, Args)
|
All, &FlagName ## _flag, Args)
|
||||||
|
|
||||||
|
|
||||||
/*----------------------.
|
/*----------------------.
|
||||||
@@ -245,19 +239,18 @@ static const char * const warnings_args[] =
|
|||||||
|
|
||||||
static const int warnings_types[] =
|
static const int warnings_types[] =
|
||||||
{
|
{
|
||||||
warnings_none,
|
Wnone,
|
||||||
warnings_midrule_values,
|
Wmidrule_values,
|
||||||
warnings_yacc,
|
Wyacc,
|
||||||
warnings_conflicts_sr,
|
Wconflicts_sr,
|
||||||
warnings_conflicts_rr,
|
Wconflicts_rr,
|
||||||
warnings_other,
|
Wother,
|
||||||
warnings_all,
|
Wall,
|
||||||
warnings_error
|
Werror
|
||||||
};
|
};
|
||||||
|
|
||||||
ARGMATCH_VERIFY (warnings_args, warnings_types);
|
ARGMATCH_VERIFY (warnings_args, warnings_types);
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------.
|
/*-------------------------------------------.
|
||||||
| Display the help message and exit STATUS. |
|
| Display the help message and exit STATUS. |
|
||||||
`-------------------------------------------*/
|
`-------------------------------------------*/
|
||||||
@@ -309,7 +302,8 @@ Parser:\n\
|
|||||||
-L, --language=LANGUAGE specify the output programming language\n\
|
-L, --language=LANGUAGE specify the output programming language\n\
|
||||||
(this is an experimental feature)\n\
|
(this is an experimental feature)\n\
|
||||||
-S, --skeleton=FILE specify the skeleton to use\n\
|
-S, --skeleton=FILE specify the skeleton to use\n\
|
||||||
-t, --debug instrument the parser for debugging\n\
|
-t, --debug instrument the parser for tracing\n\
|
||||||
|
same as `-Dparse.trace'\n\
|
||||||
--locations enable location support\n\
|
--locations enable location support\n\
|
||||||
-D, --define=NAME[=VALUE] similar to '%define NAME \"VALUE\"'\n\
|
-D, --define=NAME[=VALUE] similar to '%define NAME \"VALUE\"'\n\
|
||||||
-F, --force-define=NAME[=VALUE] override '%define NAME \"VALUE\"'\n\
|
-F, --force-define=NAME[=VALUE] override '%define NAME \"VALUE\"'\n\
|
||||||
@@ -407,7 +401,8 @@ skeleton_arg (char const *arg, int prio, location loc)
|
|||||||
skeleton = arg;
|
skeleton = arg;
|
||||||
}
|
}
|
||||||
else if (prio == skeleton_prio)
|
else if (prio == skeleton_prio)
|
||||||
complain_at (loc, _("multiple skeleton declarations are invalid"));
|
complain_at (loc, complaint,
|
||||||
|
_("multiple skeleton declarations are invalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -432,7 +427,7 @@ language_argmatch (char const *arg, int prio, location loc)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
complain_at (loc, msg, quotearg_colon (arg));
|
complain_at (loc, complaint, msg, quotearg_colon (arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------.
|
/*----------------------.
|
||||||
@@ -563,7 +558,7 @@ getargs (int argc, char *argv[])
|
|||||||
case 'F': /* -FNAME[=VALUE]. */
|
case 'F': /* -FNAME[=VALUE]. */
|
||||||
{
|
{
|
||||||
char* name = optarg;
|
char* name = optarg;
|
||||||
char* value = mbschr (optarg, '=');
|
char* value = strchr (optarg, '=');
|
||||||
if (value)
|
if (value)
|
||||||
*value++ = 0;
|
*value++ = 0;
|
||||||
muscle_percent_define_insert (name, command_line_location (),
|
muscle_percent_define_insert (name, command_line_location (),
|
||||||
@@ -588,7 +583,7 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
FLAGS_ARGMATCH (trace, optarg);
|
FLAGS_ARGMATCH (trace, optarg, trace_all);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
@@ -596,7 +591,7 @@ getargs (int argc, char *argv[])
|
|||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'W':
|
case 'W':
|
||||||
FLAGS_ARGMATCH (warnings, optarg);
|
FLAGS_ARGMATCH (warnings, optarg, Wall);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -642,11 +637,13 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
FLAGS_ARGMATCH (report, optarg);
|
FLAGS_ARGMATCH (report, optarg, report_all);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
debug_flag = true;
|
muscle_percent_define_insert ("parse.trace",
|
||||||
|
command_line_location (), "",
|
||||||
|
MUSCLE_PERCENT_DEFINE_D);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
@@ -667,7 +664,8 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LOCATIONS_OPTION:
|
case LOCATIONS_OPTION:
|
||||||
locations_flag = true;
|
muscle_percent_define_ensure ("locations",
|
||||||
|
command_line_location (), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRINT_LOCALEDIR_OPTION:
|
case PRINT_LOCALEDIR_OPTION:
|
||||||
@@ -675,7 +673,7 @@ getargs (int argc, char *argv[])
|
|||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case PRINT_DATADIR_OPTION:
|
case PRINT_DATADIR_OPTION:
|
||||||
printf ("%s\n", compute_pkgdatadir ());
|
printf ("%s\n", pkgdatadir ());
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case REPORT_FILE_OPTION:
|
case REPORT_FILE_OPTION:
|
||||||
|
|||||||
@@ -34,17 +34,13 @@ extern int skeleton_prio;
|
|||||||
/* for -I */
|
/* for -I */
|
||||||
extern char const *include;
|
extern char const *include;
|
||||||
|
|
||||||
extern bool debug_flag; /* for -t */
|
|
||||||
extern bool defines_flag; /* for -d */
|
extern bool defines_flag; /* for -d */
|
||||||
extern bool graph_flag; /* for -g */
|
extern bool graph_flag; /* for -g */
|
||||||
extern bool xml_flag; /* for -x */
|
extern bool xml_flag; /* for -x */
|
||||||
extern bool locations_flag;
|
|
||||||
extern bool no_lines_flag; /* for -l */
|
extern bool no_lines_flag; /* for -l */
|
||||||
extern bool token_table_flag; /* for -k */
|
extern bool token_table_flag; /* for -k */
|
||||||
extern bool yacc_flag; /* for -y */
|
extern bool yacc_flag; /* for -y */
|
||||||
|
|
||||||
extern bool error_verbose;
|
|
||||||
|
|
||||||
|
|
||||||
/* GLR_PARSER is true if the input file says to use the GLR
|
/* GLR_PARSER is true if the input file says to use the GLR
|
||||||
(Generalized LR) parser, and to output some additional information
|
(Generalized LR) parser, and to output some additional information
|
||||||
@@ -112,24 +108,6 @@ enum trace
|
|||||||
/** What debug items bison displays during its run. */
|
/** What debug items bison displays during its run. */
|
||||||
extern int trace_flag;
|
extern int trace_flag;
|
||||||
|
|
||||||
/*-------------.
|
|
||||||
| --warnings. |
|
|
||||||
`-------------*/
|
|
||||||
|
|
||||||
enum warnings
|
|
||||||
{
|
|
||||||
warnings_none = 0, /**< Issue no warnings. */
|
|
||||||
warnings_error = 1 << 0, /**< Warnings are treated as errors. */
|
|
||||||
warnings_midrule_values = 1 << 1, /**< Unset or unused midrule values. */
|
|
||||||
warnings_yacc = 1 << 2, /**< POSIXME. */
|
|
||||||
warnings_conflicts_sr = 1 << 3, /**< S/R conflicts. */
|
|
||||||
warnings_conflicts_rr = 1 << 4, /**< R/R conflicts. */
|
|
||||||
warnings_other = 1 << 5, /**< All other warnings. */
|
|
||||||
warnings_all = ~warnings_error /**< All above warnings. */
|
|
||||||
};
|
|
||||||
/** What warnings are issued. */
|
|
||||||
extern int warnings_flag;
|
|
||||||
|
|
||||||
|
|
||||||
/** Process the command line arguments.
|
/** Process the command line arguments.
|
||||||
*
|
*
|
||||||
|
|||||||
+12
-9
@@ -87,10 +87,10 @@ rule_lhs_print_xml (rule *r, FILE *out, int level)
|
|||||||
xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag);
|
xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
size_t
|
||||||
rule_rhs_length (rule *r)
|
rule_rhs_length (rule *r)
|
||||||
{
|
{
|
||||||
int res = 0;
|
size_t res = 0;
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
||||||
++res;
|
++res;
|
||||||
@@ -105,11 +105,10 @@ rule_rhs_print (rule *r, FILE *out)
|
|||||||
item_number *rp;
|
item_number *rp;
|
||||||
for (rp = r->rhs; *rp >= 0; rp++)
|
for (rp = r->rhs; *rp >= 0; rp++)
|
||||||
fprintf (out, " %s", symbols[*rp]->tag);
|
fprintf (out, " %s", symbols[*rp]->tag);
|
||||||
fputc ('\n', out);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (out, " /* %s */\n", _("empty"));
|
fprintf (out, " /* %s */", _("empty"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ rule_rhs_print_xml (rule *r, FILE *out, int level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
rule_print (rule *r, FILE *out)
|
rule_print (rule *r, FILE *out)
|
||||||
{
|
{
|
||||||
fprintf (out, "%s:", r->lhs->tag);
|
fprintf (out, "%s:", r->lhs->tag);
|
||||||
@@ -189,6 +188,7 @@ grammar_rules_partial_print (FILE *out, const char *title,
|
|||||||
first = false;
|
first = false;
|
||||||
rule_lhs_print (&rules[r], previous_lhs, out);
|
rule_lhs_print (&rules[r], previous_lhs, out);
|
||||||
rule_rhs_print (&rules[r], out);
|
rule_rhs_print (&rules[r], out);
|
||||||
|
fprintf (out, "\n");
|
||||||
previous_lhs = rules[r].lhs;
|
previous_lhs = rules[r].lhs;
|
||||||
}
|
}
|
||||||
if (!first)
|
if (!first)
|
||||||
@@ -296,6 +296,7 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
{
|
{
|
||||||
fprintf (out, "%-5d ", r);
|
fprintf (out, "%-5d ", r);
|
||||||
rule_print (&rules[r], out);
|
rule_print (&rules[r], out);
|
||||||
|
fprintf (out, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
@@ -303,16 +304,18 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
|
|
||||||
void
|
void
|
||||||
grammar_rules_useless_report (const char *message)
|
grammar_rules_useless_report (const char *message)
|
||||||
|
{
|
||||||
|
warnings w = Wother;
|
||||||
|
if (warnings_flag & w)
|
||||||
{
|
{
|
||||||
rule_number r;
|
rule_number r;
|
||||||
for (r = 0; r < nrules ; ++r)
|
for (r = 0; r < nrules ; ++r)
|
||||||
if (!rules[r].useful)
|
if (!rules[r].useful)
|
||||||
{
|
{
|
||||||
warn_at (rules[r].location, "%s: ", message);
|
complain_at (rules[r].location, w | silent, "%s: ", message);
|
||||||
if (warnings_flag & warnings_other)
|
|
||||||
{
|
|
||||||
rule_print (&rules[r], stderr);
|
rule_print (&rules[r], stderr);
|
||||||
fflush (stderr);
|
warnings_print_categories (w);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -194,6 +194,7 @@ typedef struct
|
|||||||
|
|
||||||
location location;
|
location location;
|
||||||
bool useful;
|
bool useful;
|
||||||
|
bool is_predicate;
|
||||||
|
|
||||||
const char *action;
|
const char *action;
|
||||||
location action_location;
|
location action_location;
|
||||||
@@ -223,14 +224,11 @@ void rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out);
|
|||||||
void rule_lhs_print_xml (rule *r, FILE *out, int level);
|
void rule_lhs_print_xml (rule *r, FILE *out, int level);
|
||||||
|
|
||||||
/* Return the length of the RHS. */
|
/* Return the length of the RHS. */
|
||||||
int rule_rhs_length (rule *r);
|
size_t rule_rhs_length (rule *r);
|
||||||
|
|
||||||
/* Print this rule's RHS on OUT. */
|
/* Print this rule's RHS on OUT. */
|
||||||
void rule_rhs_print (rule *r, FILE *out);
|
void rule_rhs_print (rule *r, FILE *out);
|
||||||
|
|
||||||
/* Print this rule on OUT. */
|
|
||||||
void rule_print (rule *r, FILE *out);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1095,11 +1095,11 @@ ielr (void)
|
|||||||
/* Examine user options. */
|
/* Examine user options. */
|
||||||
{
|
{
|
||||||
char *type = muscle_percent_define_get ("lr.type");
|
char *type = muscle_percent_define_get ("lr.type");
|
||||||
if (0 == strcmp (type, "lalr"))
|
if (STREQ (type, "lalr"))
|
||||||
lr_type = LR_TYPE__LALR;
|
lr_type = LR_TYPE__LALR;
|
||||||
else if (0 == strcmp (type, "ielr"))
|
else if (STREQ (type, "ielr"))
|
||||||
lr_type = LR_TYPE__IELR;
|
lr_type = LR_TYPE__IELR;
|
||||||
else if (0 == strcmp (type, "canonical-lr"))
|
else if (STREQ (type, "canonical-lr"))
|
||||||
lr_type = LR_TYPE__CANONICAL_LR;
|
lr_type = LR_TYPE__CANONICAL_LR;
|
||||||
else
|
else
|
||||||
aver (false);
|
aver (false);
|
||||||
|
|||||||
+1
-2
@@ -372,8 +372,7 @@ initialize_LA (void)
|
|||||||
{
|
{
|
||||||
char *default_reductions =
|
char *default_reductions =
|
||||||
muscle_percent_define_get ("lr.default-reductions");
|
muscle_percent_define_get ("lr.default-reductions");
|
||||||
default_reduction_only_for_accept =
|
default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
|
||||||
0 == strcmp (default_reductions, "accepting");
|
|
||||||
free (default_reductions);
|
free (default_reductions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
LDADD = lib/libbison.a $(LIBINTL)
|
||||||
|
|
||||||
|
bin_PROGRAMS = src/bison
|
||||||
|
# Prettify Automake-computed names of compiled objects.
|
||||||
|
src_bison_SHORTNAME = bison
|
||||||
|
|
||||||
|
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
|
||||||
|
src_bison_SOURCES = \
|
||||||
|
src/AnnotationList.c \
|
||||||
|
src/AnnotationList.h \
|
||||||
|
src/InadequacyList.c \
|
||||||
|
src/InadequacyList.h \
|
||||||
|
src/LR0.c \
|
||||||
|
src/LR0.h \
|
||||||
|
src/Sbitset.c \
|
||||||
|
src/Sbitset.h \
|
||||||
|
src/assoc.c \
|
||||||
|
src/assoc.h \
|
||||||
|
src/closure.c \
|
||||||
|
src/closure.h \
|
||||||
|
src/complain.c \
|
||||||
|
src/complain.h \
|
||||||
|
src/conflicts.c \
|
||||||
|
src/conflicts.h \
|
||||||
|
src/derives.c \
|
||||||
|
src/derives.h \
|
||||||
|
src/files.c \
|
||||||
|
src/files.h \
|
||||||
|
src/flex-scanner.h \
|
||||||
|
src/getargs.c \
|
||||||
|
src/getargs.h \
|
||||||
|
src/gram.c \
|
||||||
|
src/gram.h \
|
||||||
|
src/graphviz.c \
|
||||||
|
src/graphviz.h \
|
||||||
|
src/lalr.c \
|
||||||
|
src/lalr.h \
|
||||||
|
src/ielr.c \
|
||||||
|
src/ielr.h \
|
||||||
|
src/location.c \
|
||||||
|
src/location.h \
|
||||||
|
src/main.c \
|
||||||
|
src/muscle-tab.c \
|
||||||
|
src/muscle-tab.h \
|
||||||
|
src/named-ref.c \
|
||||||
|
src/named-ref.h \
|
||||||
|
src/nullable.c \
|
||||||
|
src/nullable.h \
|
||||||
|
src/output.c \
|
||||||
|
src/output.h \
|
||||||
|
src/parse-gram.y \
|
||||||
|
src/print-xml.c \
|
||||||
|
src/print-xml.h \
|
||||||
|
src/print.c \
|
||||||
|
src/print.h \
|
||||||
|
src/print_graph.c \
|
||||||
|
src/print_graph.h \
|
||||||
|
src/reader.c \
|
||||||
|
src/reader.h \
|
||||||
|
src/reduce.c \
|
||||||
|
src/reduce.h \
|
||||||
|
src/relation.c \
|
||||||
|
src/relation.h \
|
||||||
|
src/scan-code-c.c \
|
||||||
|
src/scan-code.h \
|
||||||
|
src/scan-gram-c.c \
|
||||||
|
src/scan-gram.h \
|
||||||
|
src/scan-skel-c.c \
|
||||||
|
src/scan-skel.h \
|
||||||
|
src/state.c \
|
||||||
|
src/state.h \
|
||||||
|
src/symlist.c \
|
||||||
|
src/symlist.h \
|
||||||
|
src/symtab.c \
|
||||||
|
src/symtab.h \
|
||||||
|
src/system.h \
|
||||||
|
src/tables.c \
|
||||||
|
src/tables.h \
|
||||||
|
src/uniqstr.c \
|
||||||
|
src/uniqstr.h
|
||||||
|
|
||||||
|
EXTRA_src_bison_SOURCES = \
|
||||||
|
src/scan-code.l \
|
||||||
|
src/scan-gram.l \
|
||||||
|
src/scan-skel.l
|
||||||
|
|
||||||
|
BUILT_SOURCES += \
|
||||||
|
src/parse-gram.c \
|
||||||
|
src/parse-gram.h \
|
||||||
|
src/scan-code.c \
|
||||||
|
src/scan-gram.c \
|
||||||
|
src/scan-skel.c
|
||||||
|
|
||||||
|
|
||||||
|
## ------ ##
|
||||||
|
## yacc. ##
|
||||||
|
## ------ ##
|
||||||
|
|
||||||
|
bin_SCRIPTS = $(YACC_SCRIPT)
|
||||||
|
EXTRA_SCRIPTS = src/yacc
|
||||||
|
MOSTLYCLEANFILES += src/yacc
|
||||||
|
|
||||||
|
src/yacc:
|
||||||
|
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||||
|
$(AM_V_at)echo '#! /bin/sh' >$@.tmp
|
||||||
|
$(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@.tmp
|
||||||
|
$(AM_V_at)chmod a+x $@.tmp
|
||||||
|
$(AM_V_at)mv $@.tmp $@
|
||||||
+4
-4
@@ -90,9 +90,9 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
|
|||||||
loc->end = *cur;
|
loc->end = *cur;
|
||||||
|
|
||||||
if (line == INT_MAX && loc->start.line != INT_MAX)
|
if (line == INT_MAX && loc->start.line != INT_MAX)
|
||||||
warn_at (*loc, _("line number overflow"));
|
complain_at (*loc, Wother, _("line number overflow"));
|
||||||
if (column == INT_MAX && loc->start.column != INT_MAX)
|
if (column == INT_MAX && loc->start.column != INT_MAX)
|
||||||
warn_at (*loc, _("column number overflow"));
|
complain_at (*loc, Wother, _("column number overflow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ boundary_set_from_string (boundary *bound, char *loc_str)
|
|||||||
{
|
{
|
||||||
/* Must search in reverse since the file name field may
|
/* Must search in reverse since the file name field may
|
||||||
* contain `.' or `:'. */
|
* contain `.' or `:'. */
|
||||||
char *delim = mbsrchr (loc_str, '.');
|
char *delim = strrchr (loc_str, '.');
|
||||||
aver (delim);
|
aver (delim);
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
bound->column = atoi (delim+1);
|
bound->column = atoi (delim+1);
|
||||||
delim = mbsrchr (loc_str, ':');
|
delim = strrchr (loc_str, ':');
|
||||||
aver (delim);
|
aver (delim);
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
bound->line = atoi (delim+1);
|
bound->line = atoi (delim+1);
|
||||||
|
|||||||
+2
-3
@@ -66,7 +66,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
{
|
{
|
||||||
char const *cp = getenv ("LC_CTYPE");
|
char const *cp = getenv ("LC_CTYPE");
|
||||||
if (cp && !strcmp (cp, "C"))
|
if (cp && STREQ (cp, "C"))
|
||||||
set_custom_quoting ("e_quoting_options, "'", "'");
|
set_custom_quoting ("e_quoting_options, "'", "'");
|
||||||
else
|
else
|
||||||
set_quoting_style ("e_quoting_options, locale_quoting_style);
|
set_quoting_style ("e_quoting_options, locale_quoting_style);
|
||||||
@@ -142,8 +142,7 @@ main (int argc, char *argv[])
|
|||||||
tables_generate ();
|
tables_generate ();
|
||||||
timevar_pop (TV_ACTIONS);
|
timevar_pop (TV_ACTIONS);
|
||||||
|
|
||||||
grammar_rules_useless_report
|
grammar_rules_useless_report (_("rule useless in parser due to conflicts"));
|
||||||
(_("rule useless in parser due to conflicts"));
|
|
||||||
|
|
||||||
/* Output file names. */
|
/* Output file names. */
|
||||||
compute_output_file_names ();
|
compute_output_file_names ();
|
||||||
|
|||||||
+64
-26
@@ -50,7 +50,7 @@ hash_compare_muscles (void const *x, void const *y)
|
|||||||
{
|
{
|
||||||
muscle_entry const *m1 = x;
|
muscle_entry const *m1 = x;
|
||||||
muscle_entry const *m2 = y;
|
muscle_entry const *m2 = y;
|
||||||
return strcmp (m1->key, m2->key) == 0;
|
return STREQ (m1->key, m2->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
@@ -388,25 +388,42 @@ muscle_user_name_list_grow (char const *key, char const *user_name,
|
|||||||
muscle_grow (key, "]]", "");
|
muscle_grow (key, "]]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** If the \a variable name is obsolete, return the name to use,
|
||||||
|
* otherwise \a variable. */
|
||||||
|
static
|
||||||
|
char const *
|
||||||
|
muscle_percent_variable_update (char const *variable)
|
||||||
|
{
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *obsolete;
|
||||||
|
const char *updated;
|
||||||
|
} conversion_type;
|
||||||
|
const conversion_type conversion[] =
|
||||||
|
{
|
||||||
|
{ "api.push_pull", "api.push-pull", },
|
||||||
|
{ "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
|
||||||
|
{ "namespace", "api.namespace", },
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < sizeof conversion / sizeof *conversion; ++i)
|
||||||
|
if (STREQ (conversion[i].obsolete, variable))
|
||||||
|
return conversion[i].updated;
|
||||||
|
return variable;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
muscle_percent_define_insert (char const *variable, location variable_loc,
|
muscle_percent_define_insert (char const *variable, location variable_loc,
|
||||||
char const *value,
|
char const *value,
|
||||||
muscle_percent_define_how how)
|
muscle_percent_define_how how)
|
||||||
{
|
{
|
||||||
char *variable_tr = NULL;
|
|
||||||
char const *name;
|
char const *name;
|
||||||
char const *loc_name;
|
char const *loc_name;
|
||||||
char const *syncline_name;
|
char const *syncline_name;
|
||||||
char const *how_name;
|
char const *how_name;
|
||||||
|
|
||||||
/* Permit certain names with underscores for backward compatibility. */
|
/* Permit certain names with underscores for backward compatibility. */
|
||||||
if (0 == strcmp (variable, "api.push_pull")
|
variable = muscle_percent_variable_update (variable);
|
||||||
|| 0 == strcmp (variable, "lr.keep_unreachable_states"))
|
|
||||||
{
|
|
||||||
variable_tr = strdup (variable);
|
|
||||||
tr (variable_tr, '_', '-');
|
|
||||||
variable = variable_tr;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
||||||
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
||||||
@@ -421,14 +438,11 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
|
|||||||
muscle_percent_define_how how_old =
|
muscle_percent_define_how how_old =
|
||||||
atoi (muscle_find_const (how_name));
|
atoi (muscle_find_const (how_name));
|
||||||
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
||||||
{
|
|
||||||
free (variable_tr);
|
|
||||||
return;
|
return;
|
||||||
}
|
complain_at (variable_loc, complaint, _("%%define variable %s redefined"),
|
||||||
complain_at (variable_loc, _("%%define variable %s redefined"),
|
|
||||||
quote (variable));
|
quote (variable));
|
||||||
complain_at (muscle_percent_define_get_loc (variable),
|
location loc = muscle_percent_define_get_loc (variable);
|
||||||
_("previous definition"));
|
complain_at (loc, complaint, _("previous definition"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MUSCLE_INSERT_STRING (name, value);
|
MUSCLE_INSERT_STRING (name, value);
|
||||||
@@ -439,8 +453,30 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
|
|||||||
muscle_user_name_list_grow ("percent_define_user_variables", variable,
|
muscle_user_name_list_grow ("percent_define_user_variables", variable,
|
||||||
variable_loc);
|
variable_loc);
|
||||||
MUSCLE_INSERT_INT (how_name, how);
|
MUSCLE_INSERT_INT (how_name, how);
|
||||||
|
}
|
||||||
|
|
||||||
free (variable_tr);
|
/* This is used for backward compatibility, e.g., "%define api.pure"
|
||||||
|
supersedes "%pure-parser". */
|
||||||
|
void
|
||||||
|
muscle_percent_define_ensure (char const *variable, location loc,
|
||||||
|
bool value)
|
||||||
|
{
|
||||||
|
char const *val = value ? "" : "false";
|
||||||
|
char const *name;
|
||||||
|
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
||||||
|
|
||||||
|
/* %pure-parser is deprecated in favor of `%define api.pure', so use
|
||||||
|
`%define api.pure' in a backward-compatible manner here. First,
|
||||||
|
don't complain if %pure-parser is specified multiple times. */
|
||||||
|
if (!muscle_find_const (name))
|
||||||
|
muscle_percent_define_insert (variable, loc, val,
|
||||||
|
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||||
|
/* In all cases, use api.pure now so that the backend doesn't complain if
|
||||||
|
the skeleton ignores api.pure, but do warn now if there's a previous
|
||||||
|
conflicting definition from an actual %define. */
|
||||||
|
if (muscle_percent_define_flag_if (variable) != value)
|
||||||
|
muscle_percent_define_insert (variable, loc, val,
|
||||||
|
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@@ -467,7 +503,7 @@ muscle_percent_define_get_loc (char const *variable)
|
|||||||
char const *loc_name;
|
char const *loc_name;
|
||||||
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
||||||
if (!muscle_find_const (loc_name))
|
if (!muscle_find_const (loc_name))
|
||||||
fatal(_("%s: undefined %%define variable %s"),
|
complain (fatal, _("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_get_loc", quote (variable));
|
"muscle_percent_define_get_loc", quote (variable));
|
||||||
return muscle_location_decode (loc_name);
|
return muscle_location_decode (loc_name);
|
||||||
}
|
}
|
||||||
@@ -481,7 +517,7 @@ muscle_percent_define_get_syncline (char const *variable)
|
|||||||
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
|
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
|
||||||
syncline = muscle_find_const (syncline_name);
|
syncline = muscle_find_const (syncline_name);
|
||||||
if (!syncline)
|
if (!syncline)
|
||||||
fatal(_("%s: undefined %%define variable %s"),
|
complain (fatal, _("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_get_syncline", quote (variable));
|
"muscle_percent_define_get_syncline", quote (variable));
|
||||||
return syncline;
|
return syncline;
|
||||||
}
|
}
|
||||||
@@ -519,21 +555,22 @@ muscle_percent_define_flag_if (char const *variable)
|
|||||||
if (muscle_percent_define_ifdef (variable))
|
if (muscle_percent_define_ifdef (variable))
|
||||||
{
|
{
|
||||||
char *value = muscle_percent_define_get (variable);
|
char *value = muscle_percent_define_get (variable);
|
||||||
if (value[0] == '\0' || 0 == strcmp (value, "true"))
|
if (value[0] == '\0' || STREQ (value, "true"))
|
||||||
result = true;
|
result = true;
|
||||||
else if (0 == strcmp (value, "false"))
|
else if (STREQ (value, "false"))
|
||||||
result = false;
|
result = false;
|
||||||
else if (!muscle_find_const (invalid_boolean_name))
|
else if (!muscle_find_const (invalid_boolean_name))
|
||||||
{
|
{
|
||||||
muscle_insert (invalid_boolean_name, "");
|
muscle_insert (invalid_boolean_name, "");
|
||||||
complain_at(muscle_percent_define_get_loc (variable),
|
location loc = muscle_percent_define_get_loc (variable);
|
||||||
|
complain_at (loc, complaint,
|
||||||
_("invalid value for %%define Boolean variable %s"),
|
_("invalid value for %%define Boolean variable %s"),
|
||||||
quote (variable));
|
quote (variable));
|
||||||
}
|
}
|
||||||
free (value);
|
free (value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fatal(_("%s: undefined %%define variable %s"),
|
complain (fatal, _("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_flag", quote (variable));
|
"muscle_percent_define_flag", quote (variable));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -578,17 +615,18 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
{
|
{
|
||||||
for (++values; *values; ++values)
|
for (++values; *values; ++values)
|
||||||
{
|
{
|
||||||
if (0 == strcmp (value, *values))
|
if (STREQ (value, *values))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!*values)
|
if (!*values)
|
||||||
{
|
{
|
||||||
location loc = muscle_percent_define_get_loc (*variablep);
|
location loc = muscle_percent_define_get_loc (*variablep);
|
||||||
complain_at(loc,
|
complain_at (loc, complaint,
|
||||||
_("invalid value for %%define variable %s: %s"),
|
_("invalid value for %%define variable %s: %s"),
|
||||||
quote (*variablep), quote_n (1, value));
|
quote (*variablep), quote_n (1, value));
|
||||||
for (values = variablep + 1; *values; ++values)
|
for (values = variablep + 1; *values; ++values)
|
||||||
complain_at (loc, _("accepted value: %s"), quote (*values));
|
complain_at (loc, complaint, _("accepted value: %s"),
|
||||||
|
quote (*values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -598,7 +636,7 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
free (value);
|
free (value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fatal (_("%s: undefined %%define variable %s"),
|
complain (fatal, _("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_check_values", quote (*variablep));
|
"muscle_percent_define_check_values", quote (*variablep));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-8
@@ -1,7 +1,6 @@
|
|||||||
/* Muscle table manager for Bison,
|
/* Muscle table manager for Bison,
|
||||||
|
|
||||||
Copyright (C) 2001-2003, 2006-2007, 2009-2012 Free Software
|
Copyright (C) 2001-2003, 2006-2012 Free Software Foundation, Inc.
|
||||||
Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -37,8 +36,8 @@ extern struct obstack muscle_obstack;
|
|||||||
|
|
||||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
int v = Value; \
|
int v__ = Value; \
|
||||||
MUSCLE_INSERT_INT (Key, v); \
|
MUSCLE_INSERT_INT (Key, v__); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||||
@@ -55,6 +54,7 @@ do { \
|
|||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
/* Key -> Value, but don't apply escaping to Value. */
|
||||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_sgrow (&muscle_obstack, Value); \
|
obstack_sgrow (&muscle_obstack, Value); \
|
||||||
@@ -62,6 +62,7 @@ do { \
|
|||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
/* Key -> Value, applying M4 escaping to Value. */
|
||||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
||||||
@@ -71,15 +72,15 @@ do { \
|
|||||||
|
|
||||||
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
||||||
do { \
|
do { \
|
||||||
char const *p; \
|
char const *p__; \
|
||||||
for (p = Value; *p; p++) \
|
for (p__ = Value; *p__; p__++) \
|
||||||
switch (*p) \
|
switch (*p__) \
|
||||||
{ \
|
{ \
|
||||||
case '$': obstack_sgrow (Obstack, "$]["); break; \
|
case '$': obstack_sgrow (Obstack, "$]["); break; \
|
||||||
case '@': obstack_sgrow (Obstack, "@@" ); break; \
|
case '@': obstack_sgrow (Obstack, "@@" ); break; \
|
||||||
case '[': obstack_sgrow (Obstack, "@{" ); break; \
|
case '[': obstack_sgrow (Obstack, "@{" ); break; \
|
||||||
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
||||||
default: obstack_1grow (Obstack, *p); break; \
|
default: obstack_1grow (Obstack, *p__); break; \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
@@ -146,6 +147,13 @@ void muscle_percent_define_insert (char const *variable, location variable_loc,
|
|||||||
char const *value,
|
char const *value,
|
||||||
muscle_percent_define_how how);
|
muscle_percent_define_how how);
|
||||||
|
|
||||||
|
/* Make sure that VARIABLE is set to the boolean VALUE. Warn on mismatches
|
||||||
|
only, but accept repeated declaration. Used for backward compatibility
|
||||||
|
between old directives such as %pure-parser, and the recommended use of
|
||||||
|
variables (%define api.pure). */
|
||||||
|
void muscle_percent_define_ensure (char const *variable, location variable_loc,
|
||||||
|
bool value);
|
||||||
|
|
||||||
/* Mimic b4_percent_define_get in ../data/bison.m4 exactly. That is, if the
|
/* Mimic b4_percent_define_get in ../data/bison.m4 exactly. That is, if the
|
||||||
%define variable VARIABLE is defined, return its value. Otherwise, return
|
%define variable VARIABLE is defined, return its value. Otherwise, return
|
||||||
the empty string. Also, record Bison's usage of VARIABLE by defining
|
the empty string. Also, record Bison's usage of VARIABLE by defining
|
||||||
|
|||||||
+195
-173
@@ -21,8 +21,9 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
|
#include <concat-filename.h>
|
||||||
#include <configmake.h>
|
#include <configmake.h>
|
||||||
#include <error.h>
|
#include <filename.h>
|
||||||
#include <get-errno.h>
|
#include <get-errno.h>
|
||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
#include <spawn-pipe.h>
|
#include <spawn-pipe.h>
|
||||||
@@ -41,8 +42,6 @@
|
|||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "tables.h"
|
#include "tables.h"
|
||||||
|
|
||||||
# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
|
|
||||||
|
|
||||||
static struct obstack format_obstack;
|
static struct obstack format_obstack;
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +105,6 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_int_table, int)
|
|||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_base_table, base_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_base_table, base_number)
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_rule_number_table, rule_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_rule_number_table, rule_number)
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
|
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
|
||||||
|
|
||||||
|
|
||||||
@@ -144,6 +142,7 @@ prepare_symbols (void)
|
|||||||
{
|
{
|
||||||
MUSCLE_INSERT_INT ("tokens_number", ntokens);
|
MUSCLE_INSERT_INT ("tokens_number", ntokens);
|
||||||
MUSCLE_INSERT_INT ("nterms_number", nvars);
|
MUSCLE_INSERT_INT ("nterms_number", nvars);
|
||||||
|
MUSCLE_INSERT_INT ("symbols_number", nsyms);
|
||||||
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
|
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
|
||||||
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
|
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
|
||||||
|
|
||||||
@@ -201,65 +200,54 @@ prepare_symbols (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------.
|
/*----------------------------------------------------------------.
|
||||||
| Prepare the muscles related to the rules: rhs, prhs, r1, r2, |
|
| Prepare the muscles related to the rules: r1, r2, rline, dprec, |
|
||||||
| rline, dprec, merger. |
|
| merger, immediate. |
|
||||||
`-------------------------------------------------------------*/
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prepare_rules (void)
|
prepare_rules (void)
|
||||||
{
|
{
|
||||||
rule_number r;
|
|
||||||
unsigned int i = 0;
|
|
||||||
item_number *rhs = xnmalloc (nritems, sizeof *rhs);
|
|
||||||
unsigned int *prhs = xnmalloc (nrules, sizeof *prhs);
|
|
||||||
unsigned int *rline = xnmalloc (nrules, sizeof *rline);
|
unsigned int *rline = xnmalloc (nrules, sizeof *rline);
|
||||||
symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
|
symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
|
||||||
unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
|
unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
|
||||||
int *dprec = xnmalloc (nrules, sizeof *dprec);
|
int *dprec = xnmalloc (nrules, sizeof *dprec);
|
||||||
int *merger = xnmalloc (nrules, sizeof *merger);
|
int *merger = xnmalloc (nrules, sizeof *merger);
|
||||||
|
int *immediate = xnmalloc (nrules, sizeof *immediate);
|
||||||
|
|
||||||
|
rule_number r;
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
{
|
{
|
||||||
item_number *rhsp = NULL;
|
|
||||||
/* Index of rule R in RHS. */
|
|
||||||
prhs[r] = i;
|
|
||||||
/* RHS of the rule R. */
|
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
|
||||||
rhs[i++] = *rhsp;
|
|
||||||
/* LHS of the rule R. */
|
/* LHS of the rule R. */
|
||||||
r1[r] = rules[r].lhs->number;
|
r1[r] = rules[r].lhs->number;
|
||||||
/* Length of rule R's RHS. */
|
/* Length of rule R's RHS. */
|
||||||
r2[r] = i - prhs[r];
|
r2[r] = rule_rhs_length(&rules[r]);
|
||||||
/* Separator in RHS. */
|
|
||||||
rhs[i++] = -1;
|
|
||||||
/* Line where rule was defined. */
|
/* Line where rule was defined. */
|
||||||
rline[r] = rules[r].location.start.line;
|
rline[r] = rules[r].location.start.line;
|
||||||
/* Dynamic precedence (GLR). */
|
/* Dynamic precedence (GLR). */
|
||||||
dprec[r] = rules[r].dprec;
|
dprec[r] = rules[r].dprec;
|
||||||
/* Merger-function index (GLR). */
|
/* Merger-function index (GLR). */
|
||||||
merger[r] = rules[r].merger;
|
merger[r] = rules[r].merger;
|
||||||
|
/* Immediate reduction flags (GLR). */
|
||||||
|
immediate[r] = rules[r].is_predicate;
|
||||||
}
|
}
|
||||||
aver (i == nritems);
|
|
||||||
|
|
||||||
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
|
|
||||||
muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
|
|
||||||
muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
|
muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
|
||||||
muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
|
muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
|
||||||
muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
|
muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
|
||||||
muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
|
muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
|
||||||
muscle_insert_int_table ("merger", merger, 0, 0, nrules);
|
muscle_insert_int_table ("merger", merger, 0, 0, nrules);
|
||||||
|
muscle_insert_int_table ("immediate", immediate, 0, 0, nrules);
|
||||||
|
|
||||||
MUSCLE_INSERT_INT ("rules_number", nrules);
|
MUSCLE_INSERT_INT ("rules_number", nrules);
|
||||||
MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
|
MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
|
||||||
|
|
||||||
free (rhs);
|
|
||||||
free (prhs);
|
|
||||||
free (rline);
|
free (rline);
|
||||||
free (r1);
|
free (r1);
|
||||||
free (r2);
|
free (r2);
|
||||||
free (dprec);
|
free (dprec);
|
||||||
free (merger);
|
free (merger);
|
||||||
|
free (immediate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------.
|
/*--------------------------------------------.
|
||||||
@@ -283,6 +271,73 @@ prepare_states (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------.
|
||||||
|
| Compare two symbols by type-name, and then by number. |
|
||||||
|
`-------------------------------------------------------*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
symbol_type_name_cmp (const symbol **lhs, const symbol **rhs)
|
||||||
|
{
|
||||||
|
int res = UNIQSTR_CMP((*lhs)->type_name, (*rhs)->type_name);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
return (*lhs)->number - (*rhs)->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------.
|
||||||
|
| Return a (malloc'ed) table of the symbols sorted by type-name. |
|
||||||
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static symbol **
|
||||||
|
symbols_by_type_name (void)
|
||||||
|
{
|
||||||
|
typedef int (*qcmp_type) (const void *, const void *);
|
||||||
|
symbol **res = xmemdup (symbols, nsyms * sizeof *res);
|
||||||
|
qsort (res, nsyms, sizeof *res, (qcmp_type) &symbol_type_name_cmp);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------.
|
||||||
|
| Define b4_type_names, which is a list of (lists of the numbers of |
|
||||||
|
| symbols with same type-name). |
|
||||||
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
type_names_output (FILE *out)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
symbol **syms = symbols_by_type_name ();
|
||||||
|
fputs ("m4_define([b4_type_names],\n[", out);
|
||||||
|
for (i = 0; i < nsyms; /* nothing */)
|
||||||
|
{
|
||||||
|
// The index of the first symbol of the current type-name.
|
||||||
|
int i0 = i;
|
||||||
|
fputs (i ? ",\n[" : "[", out);
|
||||||
|
for (; i < nsyms && syms[i]->type_name == syms[i0]->type_name; ++i)
|
||||||
|
fprintf (out, "%s%d", i != i0 ? ", " : "", syms[i]->number);
|
||||||
|
fputs ("]", out);
|
||||||
|
}
|
||||||
|
fputs ("])\n\n", out);
|
||||||
|
free (syms);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------.
|
||||||
|
| The list of all the symbol numbers. |
|
||||||
|
`-------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
symbol_numbers_output (FILE *out)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
fputs ("m4_define([b4_symbol_numbers],\n[", out);
|
||||||
|
for (i = 0; i < nsyms; ++i)
|
||||||
|
fprintf (out, "%s[%d]", i ? ", " : "", i);
|
||||||
|
fputs ("])\n\n", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------.
|
/*---------------------------------.
|
||||||
| Output the user actions to OUT. |
|
| Output the user actions to OUT. |
|
||||||
@@ -297,17 +352,18 @@ user_actions_output (FILE *out)
|
|||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
if (rules[r].action)
|
if (rules[r].action)
|
||||||
{
|
{
|
||||||
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
|
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
|
||||||
rules[r].action_location.start.line);
|
rules[r].is_predicate ? "predicate_" : "",
|
||||||
|
r + 1, rules[r].action_location.start.line);
|
||||||
escaped_output (out, rules[r].action_location.start.file);
|
escaped_output (out, rules[r].action_location.start.file);
|
||||||
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
||||||
}
|
}
|
||||||
fputs ("])\n\n", out);
|
fputs ("])\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------.
|
/*------------------------------------.
|
||||||
| Output the merge functions to OUT. |
|
| Output the merge functions to OUT. |
|
||||||
`--------------------------------------*/
|
`------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
merger_output (FILE *out)
|
merger_output (FILE *out)
|
||||||
@@ -328,93 +384,88 @@ merger_output (FILE *out)
|
|||||||
fputs ("]])\n\n", out);
|
fputs ("]])\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------.
|
|
||||||
| Output the tokens definition to OUT. |
|
/*---------------------------------------------.
|
||||||
`--------------------------------------*/
|
| Prepare the muscles for symbol definitions. |
|
||||||
|
`---------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
token_definitions_output (FILE *out)
|
prepare_symbol_definitions (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char const *sep = "";
|
|
||||||
|
|
||||||
fputs ("m4_define([b4_tokens], \n[", out);
|
|
||||||
for (i = 0; i < ntokens; ++i)
|
|
||||||
{
|
|
||||||
symbol *sym = symbols[i];
|
|
||||||
int number = sym->user_token_number;
|
|
||||||
|
|
||||||
/* At this stage, if there are literal string aliases, they are
|
|
||||||
part of SYMBOLS, so we should not find their aliased symbols
|
|
||||||
here. */
|
|
||||||
aver (number != USER_NUMBER_HAS_STRING_ALIAS);
|
|
||||||
|
|
||||||
/* Skip error token. */
|
|
||||||
if (sym == errtoken)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* If this string has an alias, then it is necessarily the alias
|
|
||||||
which is to be output. */
|
|
||||||
if (sym->alias)
|
|
||||||
sym = sym->alias;
|
|
||||||
|
|
||||||
/* Don't output literal chars or strings (when defined only as a
|
|
||||||
string). Note that must be done after the alias resolution:
|
|
||||||
think about `%token 'f' "f"'. */
|
|
||||||
if (sym->tag[0] == '\'' || sym->tag[0] == '\"')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Don't #define nonliteral tokens whose names contain periods,
|
|
||||||
dashes or '$' (as does the default value of the EOF token). */
|
|
||||||
if (mbschr (sym->tag, '.')
|
|
||||||
|| mbschr (sym->tag, '-')
|
|
||||||
|| mbschr (sym->tag, '$'))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
fprintf (out, "%s[[[%s]], %d]",
|
|
||||||
sep, sym->tag, number);
|
|
||||||
sep = ",\n";
|
|
||||||
}
|
|
||||||
fputs ("])\n\n", out);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------.
|
|
||||||
| Output the symbol destructors or printers to OUT. |
|
|
||||||
`---------------------------------------------------*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
symbol_code_props_output (FILE *out, char const *what,
|
|
||||||
code_props const *(*get)(symbol const *))
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char const *sep = "";
|
|
||||||
|
|
||||||
fputs ("m4_define([b4_symbol_", out);
|
|
||||||
fputs (what, out);
|
|
||||||
fputs ("], \n[", out);
|
|
||||||
for (i = 0; i < nsyms; ++i)
|
for (i = 0; i < nsyms; ++i)
|
||||||
{
|
{
|
||||||
symbol *sym = symbols[i];
|
symbol *sym = symbols[i];
|
||||||
char const *code = (*get) (sym)->code;
|
const char *key;
|
||||||
if (code)
|
const char *value;
|
||||||
|
|
||||||
|
#define SET_KEY(Entry) \
|
||||||
|
obstack_fgrow2 (&format_obstack, "symbol(%d, %s)", \
|
||||||
|
i, Entry); \
|
||||||
|
obstack_1grow (&format_obstack, 0); \
|
||||||
|
key = obstack_finish (&format_obstack);
|
||||||
|
|
||||||
|
#define SET_KEY2(Entry, Suffix) \
|
||||||
|
obstack_fgrow3 (&format_obstack, "symbol(%d, %s_%s)", \
|
||||||
|
i, Entry, Suffix); \
|
||||||
|
obstack_1grow (&format_obstack, 0); \
|
||||||
|
key = obstack_finish (&format_obstack);
|
||||||
|
|
||||||
|
// Whether the symbol has an identifier.
|
||||||
|
value = symbol_id_get (sym);
|
||||||
|
SET_KEY("has_id");
|
||||||
|
MUSCLE_INSERT_INT (key, !!value);
|
||||||
|
|
||||||
|
// Its identifier.
|
||||||
|
SET_KEY("id");
|
||||||
|
MUSCLE_INSERT_STRING (key, value ? value : "");
|
||||||
|
|
||||||
|
// Its tag. Typically for documentation purpose.
|
||||||
|
SET_KEY("tag");
|
||||||
|
MUSCLE_INSERT_STRING (key, sym->tag);
|
||||||
|
|
||||||
|
SET_KEY("user_number");
|
||||||
|
MUSCLE_INSERT_INT (key, sym->user_token_number);
|
||||||
|
|
||||||
|
SET_KEY("is_token");
|
||||||
|
MUSCLE_INSERT_INT (key,
|
||||||
|
i < ntokens && sym != errtoken && sym != undeftoken);
|
||||||
|
|
||||||
|
SET_KEY("number");
|
||||||
|
MUSCLE_INSERT_INT (key, sym->number);
|
||||||
|
|
||||||
|
SET_KEY("has_type");
|
||||||
|
MUSCLE_INSERT_INT (key, !!sym->type_name);
|
||||||
|
|
||||||
|
SET_KEY("type");
|
||||||
|
MUSCLE_INSERT_STRING (key, sym->type_name ? sym->type_name : "");
|
||||||
|
|
||||||
{
|
{
|
||||||
location loc = (*get) (sym)->location;
|
int j;
|
||||||
/* Filename, lineno,
|
for (j = 0; j < CODE_PROPS_SIZE; ++j)
|
||||||
Symbol-name, Symbol-number,
|
{
|
||||||
code, optional typename. */
|
/* "printer", not "%printer". */
|
||||||
fprintf (out, "%s[", sep);
|
char const *pname = code_props_type_string (j) + 1;
|
||||||
sep = ",\n";
|
code_props const *p = symbol_code_props_get (sym, j);
|
||||||
escaped_output (out, loc.start.file);
|
SET_KEY2("has", pname);
|
||||||
fprintf (out, ", %d, ", loc.start.line);
|
MUSCLE_INSERT_INT (key, !!p->code);
|
||||||
escaped_output (out, sym->tag);
|
|
||||||
fprintf (out, ", %d, [[%s]]", sym->number, code);
|
if (p->code)
|
||||||
if (sym->type_name)
|
{
|
||||||
fprintf (out, ", [[%s]]", sym->type_name);
|
SET_KEY2(pname, "file");
|
||||||
fputc (']', out);
|
MUSCLE_INSERT_STRING (key, p->location.start.file);
|
||||||
|
|
||||||
|
SET_KEY2(pname, "line");
|
||||||
|
MUSCLE_INSERT_INT (key, p->location.start.line);
|
||||||
|
|
||||||
|
SET_KEY(pname);
|
||||||
|
MUSCLE_INSERT_STRING_RAW (key, p->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fputs ("])\n\n", out);
|
}
|
||||||
|
#undef SET_KEY2
|
||||||
|
#undef SET_KEY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -465,6 +516,7 @@ prepare_actions (void)
|
|||||||
0, 1, conflict_list_cnt);
|
0, 1, conflict_list_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------.
|
/*--------------------------------------------.
|
||||||
| Output the definitions of all the muscles. |
|
| Output the definitions of all the muscles. |
|
||||||
`--------------------------------------------*/
|
`--------------------------------------------*/
|
||||||
@@ -473,13 +525,11 @@ static void
|
|||||||
muscles_output (FILE *out)
|
muscles_output (FILE *out)
|
||||||
{
|
{
|
||||||
fputs ("m4_init()\n", out);
|
fputs ("m4_init()\n", out);
|
||||||
|
|
||||||
user_actions_output (out);
|
|
||||||
merger_output (out);
|
merger_output (out);
|
||||||
token_definitions_output (out);
|
symbol_numbers_output (out);
|
||||||
symbol_code_props_output (out, "destructors", &symbol_destructor_get);
|
type_names_output (out);
|
||||||
symbol_code_props_output (out, "printers", &symbol_printer_get);
|
user_actions_output (out);
|
||||||
|
// Must be last.
|
||||||
muscles_m4_output (out);
|
muscles_m4_output (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,48 +540,28 @@ muscles_output (FILE *out)
|
|||||||
static void
|
static void
|
||||||
output_skeleton (void)
|
output_skeleton (void)
|
||||||
{
|
{
|
||||||
FILE *in;
|
|
||||||
int filter_fd[2];
|
int filter_fd[2];
|
||||||
char const *argv[10];
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
/* Compute the names of the package data dir and skeleton files. */
|
/* Compute the names of the package data dir and skeleton files. */
|
||||||
char const m4sugar[] = "m4sugar/m4sugar.m4";
|
char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
|
||||||
char const m4bison[] = "bison.m4";
|
char const *datadir = pkgdatadir ();
|
||||||
char *full_m4sugar;
|
char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
|
||||||
char *full_m4bison;
|
char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
|
||||||
char *full_skeleton;
|
char *skel = (IS_PATH_WITH_DIR (skeleton)
|
||||||
char const *p;
|
? xstrdup (skeleton)
|
||||||
char const *m4 = (p = getenv ("M4")) ? p : M4;
|
: xconcatenated_filename (datadir, skeleton, NULL));
|
||||||
char const *pkgdatadir = compute_pkgdatadir ();
|
|
||||||
size_t skeleton_size = strlen (skeleton) + 1;
|
|
||||||
size_t pkgdatadirlen = strlen (pkgdatadir);
|
|
||||||
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
|
|
||||||
pkgdatadirlen--;
|
|
||||||
full_skeleton = xmalloc (pkgdatadirlen + 1
|
|
||||||
+ (skeleton_size < sizeof m4sugar
|
|
||||||
? sizeof m4sugar : skeleton_size));
|
|
||||||
memcpy (full_skeleton, pkgdatadir, pkgdatadirlen);
|
|
||||||
full_skeleton[pkgdatadirlen] = '/';
|
|
||||||
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
|
||||||
full_m4sugar = xstrdup (full_skeleton);
|
|
||||||
strcpy (full_skeleton + pkgdatadirlen + 1, m4bison);
|
|
||||||
full_m4bison = xstrdup (full_skeleton);
|
|
||||||
if (mbschr (skeleton, '/'))
|
|
||||||
strcpy (full_skeleton, skeleton);
|
|
||||||
else
|
|
||||||
strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
|
|
||||||
|
|
||||||
/* Test whether m4sugar.m4 is readable, to check for proper
|
/* Test whether m4sugar.m4 is readable, to check for proper
|
||||||
installation. A faulty installation can cause deadlock, so a
|
installation. A faulty installation can cause deadlock, so a
|
||||||
cheap sanity check is worthwhile. */
|
cheap sanity check is worthwhile. */
|
||||||
xfclose (xfopen (full_m4sugar, "r"));
|
xfclose (xfopen (m4sugar, "r"));
|
||||||
|
|
||||||
/* Create an m4 subprocess connected to us via two pipes. */
|
/* Create an m4 subprocess connected to us via two pipes. */
|
||||||
|
|
||||||
if (trace_flag & trace_tools)
|
if (trace_flag & trace_tools)
|
||||||
fprintf (stderr, "running: %s %s - %s %s\n",
|
fprintf (stderr, "running: %s %s - %s %s\n",
|
||||||
m4, full_m4sugar, full_m4bison, full_skeleton);
|
m4, m4sugar, m4bison, skel);
|
||||||
|
|
||||||
/* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a
|
/* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a
|
||||||
position-dependent manner. Keep it as the first argument so that all
|
position-dependent manner. Keep it as the first argument so that all
|
||||||
@@ -541,6 +571,7 @@ output_skeleton (void)
|
|||||||
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
|
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
|
||||||
for details. */
|
for details. */
|
||||||
{
|
{
|
||||||
|
char const *argv[10];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
argv[i++] = m4;
|
argv[i++] = m4;
|
||||||
|
|
||||||
@@ -557,47 +588,44 @@ output_skeleton (void)
|
|||||||
argv[i++] = M4_GNU_OPTION;
|
argv[i++] = M4_GNU_OPTION;
|
||||||
|
|
||||||
argv[i++] = "-I";
|
argv[i++] = "-I";
|
||||||
argv[i++] = pkgdatadir;
|
argv[i++] = datadir;
|
||||||
if (trace_flag & trace_m4)
|
if (trace_flag & trace_m4)
|
||||||
argv[i++] = "-dV";
|
argv[i++] = "-dV";
|
||||||
argv[i++] = full_m4sugar;
|
argv[i++] = m4sugar;
|
||||||
argv[i++] = "-";
|
argv[i++] = "-";
|
||||||
argv[i++] = full_m4bison;
|
argv[i++] = m4bison;
|
||||||
argv[i++] = full_skeleton;
|
argv[i++] = skel;
|
||||||
argv[i++] = NULL;
|
argv[i++] = NULL;
|
||||||
aver (i <= ARRAY_CARDINALITY (argv));
|
aver (i <= ARRAY_CARDINALITY (argv));
|
||||||
}
|
|
||||||
|
|
||||||
/* The ugly cast is because gnulib gets the const-ness wrong. */
|
/* The ugly cast is because gnulib gets the const-ness wrong. */
|
||||||
pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
|
pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
|
||||||
true, filter_fd);
|
true, filter_fd);
|
||||||
free (full_m4sugar);
|
}
|
||||||
free (full_m4bison);
|
|
||||||
free (full_skeleton);
|
free (m4sugar);
|
||||||
|
free (m4bison);
|
||||||
|
free (skel);
|
||||||
|
|
||||||
if (trace_flag & trace_muscles)
|
if (trace_flag & trace_muscles)
|
||||||
muscles_output (stderr);
|
muscles_output (stderr);
|
||||||
{
|
{
|
||||||
FILE *out = fdopen (filter_fd[1], "w");
|
FILE *out = xfdopen (filter_fd[1], "w");
|
||||||
if (! out)
|
|
||||||
error (EXIT_FAILURE, get_errno (),
|
|
||||||
"fdopen");
|
|
||||||
muscles_output (out);
|
muscles_output (out);
|
||||||
xfclose (out);
|
xfclose (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read and process m4's output. */
|
/* Read and process m4's output. */
|
||||||
timevar_push (TV_M4);
|
timevar_push (TV_M4);
|
||||||
in = fdopen (filter_fd[0], "r");
|
{
|
||||||
if (! in)
|
FILE *in = xfdopen (filter_fd[0], "r");
|
||||||
error (EXIT_FAILURE, get_errno (),
|
|
||||||
"fdopen");
|
|
||||||
scan_skel (in);
|
scan_skel (in);
|
||||||
/* scan_skel should have read all of M4's output. Otherwise, when we
|
/* scan_skel should have read all of M4's output. Otherwise, when we
|
||||||
close the pipe, we risk letting M4 report a broken-pipe to the
|
close the pipe, we risk letting M4 report a broken-pipe to the
|
||||||
Bison user. */
|
Bison user. */
|
||||||
aver (feof (in));
|
aver (feof (in));
|
||||||
xfclose (in);
|
xfclose (in);
|
||||||
|
}
|
||||||
wait_subprocess (pid, "m4", false, false, true, true, NULL);
|
wait_subprocess (pid, "m4", false, false, true, true, NULL);
|
||||||
timevar_pop (TV_M4);
|
timevar_pop (TV_M4);
|
||||||
}
|
}
|
||||||
@@ -605,21 +633,14 @@ output_skeleton (void)
|
|||||||
static void
|
static void
|
||||||
prepare (void)
|
prepare (void)
|
||||||
{
|
{
|
||||||
/* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be documented
|
/* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be
|
||||||
for the user. */
|
documented for the user. */
|
||||||
char const *use_push_for_pull_env = getenv ("BISON_USE_PUSH_FOR_PULL");
|
char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
|
||||||
bool use_push_for_pull_flag = false;
|
bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
|
||||||
if (use_push_for_pull_env != NULL
|
|
||||||
&& use_push_for_pull_env[0] != '\0'
|
|
||||||
&& 0 != strcmp (use_push_for_pull_env, "0"))
|
|
||||||
use_push_for_pull_flag = true;
|
|
||||||
|
|
||||||
/* Flags. */
|
/* Flags. */
|
||||||
MUSCLE_INSERT_BOOL ("debug_flag", debug_flag);
|
|
||||||
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
||||||
MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose);
|
|
||||||
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
||||||
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
|
||||||
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
||||||
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
||||||
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
||||||
@@ -655,7 +676,7 @@ prepare (void)
|
|||||||
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
|
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
|
||||||
would never be expanded. Hopefully no one has M4-special characters in
|
would never be expanded. Hopefully no one has M4-special characters in
|
||||||
his Bison installation path. */
|
his Bison installation path. */
|
||||||
MUSCLE_INSERT_STRING_RAW ("pkgdatadir", compute_pkgdatadir ());
|
MUSCLE_INSERT_STRING_RAW ("pkgdatadir", pkgdatadir ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,6 +694,7 @@ output (void)
|
|||||||
prepare_rules ();
|
prepare_rules ();
|
||||||
prepare_states ();
|
prepare_states ();
|
||||||
prepare_actions ();
|
prepare_actions ();
|
||||||
|
prepare_symbol_definitions ();
|
||||||
|
|
||||||
prepare ();
|
prepare ();
|
||||||
|
|
||||||
@@ -683,8 +705,8 @@ output (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
char const *
|
||||||
compute_pkgdatadir (void)
|
pkgdatadir (void)
|
||||||
{
|
{
|
||||||
char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
|
char const *cp = getenv ("BISON_PKGDATADIR");
|
||||||
return pkgdatadir ? pkgdatadir : PKGDATADIR;
|
return cp ? cp : PKGDATADIR;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
/* Output the parsing tables and the parser code to FTABLE. */
|
/* Output the parsing tables and the parser code to FTABLE. */
|
||||||
void output (void);
|
void output (void);
|
||||||
char const *compute_pkgdatadir (void);
|
|
||||||
|
/* Where our data files are installed. */
|
||||||
|
char const *pkgdatadir (void);
|
||||||
|
|
||||||
#endif /* !OUTPUT_H_ */
|
#endif /* !OUTPUT_H_ */
|
||||||
|
|||||||
+1128
-840
File diff suppressed because it is too large
Load Diff
+117
-96
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 2.5.1.19-ced26-dirty. */
|
/* A Bison parser, made by GNU Bison 2.5.1.815-22b0. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
This special exception was added by the Free Software Foundation in
|
This special exception was added by the Free Software Foundation in
|
||||||
version 2.2 of Bison. */
|
version 2.2 of Bison. */
|
||||||
|
|
||||||
#ifndef GRAM__________SRC_PARSE_GRAM_H
|
#ifndef GRAM_______SRC_PARSE_GRAM_H
|
||||||
# define GRAM__________SRC_PARSE_GRAM_H
|
# define GRAM_______SRC_PARSE_GRAM_H
|
||||||
/* Enabling traces. */
|
/* Enabling traces. */
|
||||||
#ifndef YYDEBUG
|
#ifndef YYDEBUG
|
||||||
# define YYDEBUG 1
|
# define YYDEBUG 1
|
||||||
@@ -39,6 +39,24 @@
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
extern int gram_debug;
|
extern int gram_debug;
|
||||||
#endif
|
#endif
|
||||||
|
/* "%code requires" blocks. */
|
||||||
|
/* Line 1996 of yacc.c */
|
||||||
|
#line 221 "src/parse-gram.y"
|
||||||
|
|
||||||
|
# ifndef PARAM_TYPE
|
||||||
|
# define PARAM_TYPE
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
param_none = 0,
|
||||||
|
param_lex = 1 << 0,
|
||||||
|
param_parse = 1 << 1,
|
||||||
|
param_both = param_lex | param_parse
|
||||||
|
} param_type;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Line 1996 of yacc.c */
|
||||||
|
#line 60 "src/parse-gram.h"
|
||||||
|
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef YYTOKENTYPE
|
||||||
@@ -57,51 +75,50 @@ extern int gram_debug;
|
|||||||
PERCENT_LEFT = 265,
|
PERCENT_LEFT = 265,
|
||||||
PERCENT_RIGHT = 266,
|
PERCENT_RIGHT = 266,
|
||||||
PERCENT_NONASSOC = 267,
|
PERCENT_NONASSOC = 267,
|
||||||
PERCENT_PREC = 268,
|
PERCENT_PRECEDENCE = 268,
|
||||||
PERCENT_DPREC = 269,
|
PERCENT_PREC = 269,
|
||||||
PERCENT_MERGE = 270,
|
PERCENT_DPREC = 270,
|
||||||
PERCENT_CODE = 271,
|
PERCENT_MERGE = 271,
|
||||||
PERCENT_DEBUG = 272,
|
PERCENT_CODE = 272,
|
||||||
PERCENT_DEFAULT_PREC = 273,
|
PERCENT_DEFAULT_PREC = 273,
|
||||||
PERCENT_DEFINE = 274,
|
PERCENT_DEFINE = 274,
|
||||||
PERCENT_DEFINES = 275,
|
PERCENT_DEFINES = 275,
|
||||||
PERCENT_ERROR_VERBOSE = 276,
|
PERCENT_ERROR_VERBOSE = 276,
|
||||||
PERCENT_EXPECT = 277,
|
PERCENT_EXPECT = 277,
|
||||||
PERCENT_EXPECT_RR = 278,
|
PERCENT_EXPECT_RR = 278,
|
||||||
PERCENT_FILE_PREFIX = 279,
|
PERCENT_FLAG = 279,
|
||||||
PERCENT_GLR_PARSER = 280,
|
PERCENT_FILE_PREFIX = 280,
|
||||||
PERCENT_INITIAL_ACTION = 281,
|
PERCENT_GLR_PARSER = 281,
|
||||||
PERCENT_LANGUAGE = 282,
|
PERCENT_INITIAL_ACTION = 282,
|
||||||
PERCENT_LEX_PARAM = 283,
|
PERCENT_LANGUAGE = 283,
|
||||||
PERCENT_LOCATIONS = 284,
|
PERCENT_NAME_PREFIX = 284,
|
||||||
PERCENT_NAME_PREFIX = 285,
|
PERCENT_NO_DEFAULT_PREC = 285,
|
||||||
PERCENT_NO_DEFAULT_PREC = 286,
|
PERCENT_NO_LINES = 286,
|
||||||
PERCENT_NO_LINES = 287,
|
PERCENT_NONDETERMINISTIC_PARSER = 287,
|
||||||
PERCENT_NONDETERMINISTIC_PARSER = 288,
|
PERCENT_OUTPUT = 288,
|
||||||
PERCENT_OUTPUT = 289,
|
PERCENT_REQUIRE = 289,
|
||||||
PERCENT_PARSE_PARAM = 290,
|
PERCENT_SKELETON = 290,
|
||||||
PERCENT_PURE_PARSER = 291,
|
PERCENT_START = 291,
|
||||||
PERCENT_REQUIRE = 292,
|
PERCENT_TOKEN_TABLE = 292,
|
||||||
PERCENT_SKELETON = 293,
|
PERCENT_VERBOSE = 293,
|
||||||
PERCENT_START = 294,
|
PERCENT_YACC = 294,
|
||||||
PERCENT_TOKEN_TABLE = 295,
|
BRACED_CODE = 295,
|
||||||
PERCENT_VERBOSE = 296,
|
BRACED_PREDICATE = 296,
|
||||||
PERCENT_YACC = 297,
|
BRACKETED_ID = 297,
|
||||||
BRACED_CODE = 298,
|
CHAR = 298,
|
||||||
BRACKETED_ID = 299,
|
EPILOGUE = 299,
|
||||||
CHAR = 300,
|
EQUAL = 300,
|
||||||
EPILOGUE = 301,
|
ID = 301,
|
||||||
EQUAL = 302,
|
ID_COLON = 302,
|
||||||
ID = 303,
|
PERCENT_PERCENT = 303,
|
||||||
ID_COLON = 304,
|
PIPE = 304,
|
||||||
PERCENT_PERCENT = 305,
|
PROLOGUE = 305,
|
||||||
PIPE = 306,
|
SEMICOLON = 306,
|
||||||
PROLOGUE = 307,
|
TAG = 307,
|
||||||
SEMICOLON = 308,
|
TAG_ANY = 308,
|
||||||
TYPE = 309,
|
TAG_NONE = 309,
|
||||||
TYPE_TAG_ANY = 310,
|
PERCENT_PARAM = 310,
|
||||||
TYPE_TAG_NONE = 311,
|
PERCENT_UNION = 311
|
||||||
PERCENT_UNION = 312
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
@@ -116,75 +133,77 @@ extern int gram_debug;
|
|||||||
#define PERCENT_LEFT 265
|
#define PERCENT_LEFT 265
|
||||||
#define PERCENT_RIGHT 266
|
#define PERCENT_RIGHT 266
|
||||||
#define PERCENT_NONASSOC 267
|
#define PERCENT_NONASSOC 267
|
||||||
#define PERCENT_PREC 268
|
#define PERCENT_PRECEDENCE 268
|
||||||
#define PERCENT_DPREC 269
|
#define PERCENT_PREC 269
|
||||||
#define PERCENT_MERGE 270
|
#define PERCENT_DPREC 270
|
||||||
#define PERCENT_CODE 271
|
#define PERCENT_MERGE 271
|
||||||
#define PERCENT_DEBUG 272
|
#define PERCENT_CODE 272
|
||||||
#define PERCENT_DEFAULT_PREC 273
|
#define PERCENT_DEFAULT_PREC 273
|
||||||
#define PERCENT_DEFINE 274
|
#define PERCENT_DEFINE 274
|
||||||
#define PERCENT_DEFINES 275
|
#define PERCENT_DEFINES 275
|
||||||
#define PERCENT_ERROR_VERBOSE 276
|
#define PERCENT_ERROR_VERBOSE 276
|
||||||
#define PERCENT_EXPECT 277
|
#define PERCENT_EXPECT 277
|
||||||
#define PERCENT_EXPECT_RR 278
|
#define PERCENT_EXPECT_RR 278
|
||||||
#define PERCENT_FILE_PREFIX 279
|
#define PERCENT_FLAG 279
|
||||||
#define PERCENT_GLR_PARSER 280
|
#define PERCENT_FILE_PREFIX 280
|
||||||
#define PERCENT_INITIAL_ACTION 281
|
#define PERCENT_GLR_PARSER 281
|
||||||
#define PERCENT_LANGUAGE 282
|
#define PERCENT_INITIAL_ACTION 282
|
||||||
#define PERCENT_LEX_PARAM 283
|
#define PERCENT_LANGUAGE 283
|
||||||
#define PERCENT_LOCATIONS 284
|
#define PERCENT_NAME_PREFIX 284
|
||||||
#define PERCENT_NAME_PREFIX 285
|
#define PERCENT_NO_DEFAULT_PREC 285
|
||||||
#define PERCENT_NO_DEFAULT_PREC 286
|
#define PERCENT_NO_LINES 286
|
||||||
#define PERCENT_NO_LINES 287
|
#define PERCENT_NONDETERMINISTIC_PARSER 287
|
||||||
#define PERCENT_NONDETERMINISTIC_PARSER 288
|
#define PERCENT_OUTPUT 288
|
||||||
#define PERCENT_OUTPUT 289
|
#define PERCENT_REQUIRE 289
|
||||||
#define PERCENT_PARSE_PARAM 290
|
#define PERCENT_SKELETON 290
|
||||||
#define PERCENT_PURE_PARSER 291
|
#define PERCENT_START 291
|
||||||
#define PERCENT_REQUIRE 292
|
#define PERCENT_TOKEN_TABLE 292
|
||||||
#define PERCENT_SKELETON 293
|
#define PERCENT_VERBOSE 293
|
||||||
#define PERCENT_START 294
|
#define PERCENT_YACC 294
|
||||||
#define PERCENT_TOKEN_TABLE 295
|
#define BRACED_CODE 295
|
||||||
#define PERCENT_VERBOSE 296
|
#define BRACED_PREDICATE 296
|
||||||
#define PERCENT_YACC 297
|
#define BRACKETED_ID 297
|
||||||
#define BRACED_CODE 298
|
#define CHAR 298
|
||||||
#define BRACKETED_ID 299
|
#define EPILOGUE 299
|
||||||
#define CHAR 300
|
#define EQUAL 300
|
||||||
#define EPILOGUE 301
|
#define ID 301
|
||||||
#define EQUAL 302
|
#define ID_COLON 302
|
||||||
#define ID 303
|
#define PERCENT_PERCENT 303
|
||||||
#define ID_COLON 304
|
#define PIPE 304
|
||||||
#define PERCENT_PERCENT 305
|
#define PROLOGUE 305
|
||||||
#define PIPE 306
|
#define SEMICOLON 306
|
||||||
#define PROLOGUE 307
|
#define TAG 307
|
||||||
#define SEMICOLON 308
|
#define TAG_ANY 308
|
||||||
#define TYPE 309
|
#define TAG_NONE 309
|
||||||
#define TYPE_TAG_ANY 310
|
#define PERCENT_PARAM 310
|
||||||
#define TYPE_TAG_NONE 311
|
#define PERCENT_UNION 311
|
||||||
#define PERCENT_UNION 312
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
typedef union YYSTYPE
|
typedef union YYSTYPE
|
||||||
{
|
{
|
||||||
|
/* Line 1996 of yacc.c */
|
||||||
|
#line 107 "src/parse-gram.y"
|
||||||
|
|
||||||
/* Line 2063 of yacc.c */
|
assoc assoc;
|
||||||
#line 114 "parse-gram.y"
|
char *code;
|
||||||
|
char const *chars;
|
||||||
|
int integer;
|
||||||
|
named_ref *named_ref;
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
int integer;
|
|
||||||
char const *chars;
|
|
||||||
char *code;
|
|
||||||
assoc assoc;
|
|
||||||
uniqstr uniqstr;
|
uniqstr uniqstr;
|
||||||
unsigned char character;
|
unsigned char character;
|
||||||
named_ref *named_ref;
|
|
||||||
|
/* Line 1996 of yacc.c */
|
||||||
|
#line 245 "src/parse-gram.y"
|
||||||
|
|
||||||
|
param_type param;
|
||||||
|
|
||||||
|
|
||||||
|
/* Line 1996 of yacc.c */
|
||||||
/* Line 2063 of yacc.c */
|
#line 207 "src/parse-gram.h"
|
||||||
#line 188 "parse-gram.h"
|
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
@@ -204,19 +223,21 @@ typedef struct YYLTYPE
|
|||||||
# define YYLTYPE_IS_TRIVIAL 1
|
# define YYLTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef YYPARSE_PARAM
|
#ifdef YYPARSE_PARAM
|
||||||
#if defined __STDC__ || defined __cplusplus
|
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||||
|
|| defined __cplusplus || defined _MSC_VER)
|
||||||
int gram_parse (void *YYPARSE_PARAM);
|
int gram_parse (void *YYPARSE_PARAM);
|
||||||
#else
|
#else
|
||||||
int gram_parse ();
|
int gram_parse ();
|
||||||
#endif
|
#endif
|
||||||
#else /* ! YYPARSE_PARAM */
|
#else /* ! YYPARSE_PARAM */
|
||||||
#if defined __STDC__ || defined __cplusplus
|
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||||
|
|| defined __cplusplus || defined _MSC_VER)
|
||||||
int gram_parse (void);
|
int gram_parse (void);
|
||||||
#else
|
#else
|
||||||
int gram_parse ();
|
int gram_parse ();
|
||||||
#endif
|
#endif
|
||||||
#endif /* ! YYPARSE_PARAM */
|
#endif /* ! YYPARSE_PARAM */
|
||||||
|
|
||||||
|
#endif /* !GRAM_______SRC_PARSE_GRAM_H */
|
||||||
#endif /* !GRAM__________SRC_PARSE_GRAM_H */
|
|
||||||
|
|||||||
+129
-83
@@ -50,22 +50,16 @@ static void version_check (location const *loc, char const *version);
|
|||||||
static void gram_error (location const *, char const *);
|
static void gram_error (location const *, char const *);
|
||||||
|
|
||||||
static char const *char_name (char);
|
static char const *char_name (char);
|
||||||
|
%}
|
||||||
|
|
||||||
/** Add a lex-param or a parse-param.
|
%code
|
||||||
*
|
{
|
||||||
* \param type \a lex_param or \a parse_param
|
static int current_prec = 0;
|
||||||
* \param decl the formal argument
|
|
||||||
* \param loc the location in the source.
|
|
||||||
*/
|
|
||||||
static void add_param (char const *type, char *decl, location loc);
|
|
||||||
|
|
||||||
|
|
||||||
static symbol_class current_class = unknown_sym;
|
|
||||||
static uniqstr current_type = NULL;
|
|
||||||
static symbol *current_lhs_symbol;
|
|
||||||
static location current_lhs_location;
|
static location current_lhs_location;
|
||||||
static named_ref *current_lhs_named_ref;
|
static named_ref *current_lhs_named_ref;
|
||||||
static int current_prec = 0;
|
static symbol *current_lhs_symbol;
|
||||||
|
static symbol_class current_class = unknown_sym;
|
||||||
|
static uniqstr current_type = NULL;
|
||||||
|
|
||||||
/** Set the new current left-hand side symbol, possibly common
|
/** Set the new current left-hand side symbol, possibly common
|
||||||
* to several right-hand side parts of rule.
|
* to several right-hand side parts of rule.
|
||||||
@@ -85,19 +79,18 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
current_lhs_named_ref = ref;
|
current_lhs_named_ref = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define YYTYPE_INT16 int_fast16_t
|
#define YYTYPE_INT16 int_fast16_t
|
||||||
#define YYTYPE_INT8 int_fast8_t
|
#define YYTYPE_INT8 int_fast8_t
|
||||||
#define YYTYPE_UINT16 uint_fast16_t
|
#define YYTYPE_UINT16 uint_fast16_t
|
||||||
#define YYTYPE_UINT8 uint_fast8_t
|
#define YYTYPE_UINT8 uint_fast8_t
|
||||||
%}
|
}
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
%verbose
|
%verbose
|
||||||
%defines
|
%defines
|
||||||
%locations
|
%locations
|
||||||
%pure-parser
|
%pure-parser
|
||||||
%error-verbose
|
%define parse.error "verbose"
|
||||||
%define parse.lac full
|
%define parse.lac full
|
||||||
%name-prefix="gram_"
|
%name-prefix="gram_"
|
||||||
%expect 0
|
%expect 0
|
||||||
@@ -112,15 +105,15 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
|
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
|
assoc assoc;
|
||||||
|
char *code;
|
||||||
|
char const *chars;
|
||||||
|
int integer;
|
||||||
|
named_ref *named_ref;
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
int integer;
|
|
||||||
char const *chars;
|
|
||||||
char *code;
|
|
||||||
assoc assoc;
|
|
||||||
uniqstr uniqstr;
|
uniqstr uniqstr;
|
||||||
unsigned char character;
|
unsigned char character;
|
||||||
named_ref *named_ref;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Define the tokens together with their human representation. */
|
/* Define the tokens together with their human representation. */
|
||||||
@@ -138,39 +131,35 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
%token PERCENT_LEFT "%left"
|
%token PERCENT_LEFT "%left"
|
||||||
%token PERCENT_RIGHT "%right"
|
%token PERCENT_RIGHT "%right"
|
||||||
%token PERCENT_NONASSOC "%nonassoc"
|
%token PERCENT_NONASSOC "%nonassoc"
|
||||||
|
%token PERCENT_PRECEDENCE "%precedence"
|
||||||
|
|
||||||
%token PERCENT_PREC "%prec"
|
%token PERCENT_PREC "%prec"
|
||||||
%token PERCENT_DPREC "%dprec"
|
%token PERCENT_DPREC "%dprec"
|
||||||
%token PERCENT_MERGE "%merge"
|
%token PERCENT_MERGE "%merge"
|
||||||
|
|
||||||
|
|
||||||
/*----------------------.
|
/*----------------------.
|
||||||
| Global Declarations. |
|
| Global Declarations. |
|
||||||
`----------------------*/
|
`----------------------*/
|
||||||
|
|
||||||
%token
|
%token
|
||||||
PERCENT_CODE "%code"
|
PERCENT_CODE "%code"
|
||||||
PERCENT_DEBUG "%debug"
|
|
||||||
PERCENT_DEFAULT_PREC "%default-prec"
|
PERCENT_DEFAULT_PREC "%default-prec"
|
||||||
PERCENT_DEFINE "%define"
|
PERCENT_DEFINE "%define"
|
||||||
PERCENT_DEFINES "%defines"
|
PERCENT_DEFINES "%defines"
|
||||||
PERCENT_ERROR_VERBOSE "%error-verbose"
|
PERCENT_ERROR_VERBOSE "%error-verbose"
|
||||||
PERCENT_EXPECT "%expect"
|
PERCENT_EXPECT "%expect"
|
||||||
PERCENT_EXPECT_RR "%expect-rr"
|
PERCENT_EXPECT_RR "%expect-rr"
|
||||||
|
PERCENT_FLAG "%<flag>"
|
||||||
PERCENT_FILE_PREFIX "%file-prefix"
|
PERCENT_FILE_PREFIX "%file-prefix"
|
||||||
PERCENT_GLR_PARSER "%glr-parser"
|
PERCENT_GLR_PARSER "%glr-parser"
|
||||||
PERCENT_INITIAL_ACTION "%initial-action"
|
PERCENT_INITIAL_ACTION "%initial-action"
|
||||||
PERCENT_LANGUAGE "%language"
|
PERCENT_LANGUAGE "%language"
|
||||||
PERCENT_LEX_PARAM "%lex-param"
|
|
||||||
PERCENT_LOCATIONS "%locations"
|
|
||||||
PERCENT_NAME_PREFIX "%name-prefix"
|
PERCENT_NAME_PREFIX "%name-prefix"
|
||||||
PERCENT_NO_DEFAULT_PREC "%no-default-prec"
|
PERCENT_NO_DEFAULT_PREC "%no-default-prec"
|
||||||
PERCENT_NO_LINES "%no-lines"
|
PERCENT_NO_LINES "%no-lines"
|
||||||
PERCENT_NONDETERMINISTIC_PARSER
|
PERCENT_NONDETERMINISTIC_PARSER
|
||||||
"%nondeterministic-parser"
|
"%nondeterministic-parser"
|
||||||
PERCENT_OUTPUT "%output"
|
PERCENT_OUTPUT "%output"
|
||||||
PERCENT_PARSE_PARAM "%parse-param"
|
|
||||||
PERCENT_PURE_PARSER "%pure-parser"
|
|
||||||
PERCENT_REQUIRE "%require"
|
PERCENT_REQUIRE "%require"
|
||||||
PERCENT_SKELETON "%skeleton"
|
PERCENT_SKELETON "%skeleton"
|
||||||
PERCENT_START "%start"
|
PERCENT_START "%start"
|
||||||
@@ -180,6 +169,7 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
;
|
;
|
||||||
|
|
||||||
%token BRACED_CODE "{...}"
|
%token BRACED_CODE "{...}"
|
||||||
|
%token BRACED_PREDICATE "%?{...}"
|
||||||
%token BRACKETED_ID "[identifier]"
|
%token BRACKETED_ID "[identifier]"
|
||||||
%token CHAR "char"
|
%token CHAR "char"
|
||||||
%token EPILOGUE "epilogue"
|
%token EPILOGUE "epilogue"
|
||||||
@@ -190,9 +180,9 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
%token PIPE "|"
|
%token PIPE "|"
|
||||||
%token PROLOGUE "%{...%}"
|
%token PROLOGUE "%{...%}"
|
||||||
%token SEMICOLON ";"
|
%token SEMICOLON ";"
|
||||||
%token TYPE "type"
|
%token TAG "<tag>"
|
||||||
%token TYPE_TAG_ANY "<*>"
|
%token TAG_ANY "<*>"
|
||||||
%token TYPE_TAG_NONE "<>"
|
%token TAG_NONE "<>"
|
||||||
|
|
||||||
%type <character> CHAR
|
%type <character> CHAR
|
||||||
%printer { fputs (char_name ($$), stderr); } CHAR
|
%printer { fputs (char_name ($$), stderr); } CHAR
|
||||||
@@ -200,17 +190,18 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
/* braceless is not to be used for rule or symbol actions, as it
|
/* braceless is not to be used for rule or symbol actions, as it
|
||||||
calls code_props_plain_init. */
|
calls code_props_plain_init. */
|
||||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
||||||
%type <code> "{...}"
|
%type <code> "{...}" "%?{...}"
|
||||||
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||||
STRING
|
STRING
|
||||||
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
||||||
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
||||||
|
|
||||||
%type <uniqstr> BRACKETED_ID ID ID_COLON TYPE variable
|
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG variable
|
||||||
%printer { fputs ($$, stderr); } <uniqstr>
|
%printer { fputs ($$, stderr); } <uniqstr>
|
||||||
%printer { fprintf (stderr, "[%s]", $$); } BRACKETED_ID
|
%printer { fprintf (stderr, "[%s]", $$); } BRACKETED_ID
|
||||||
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
|
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
|
||||||
%printer { fprintf (stderr, "<%s>", $$); } TYPE
|
%printer { fprintf (stderr, "%%%s", $$); } PERCENT_FLAG
|
||||||
|
%printer { fprintf (stderr, "<%s>", $$); } TAG
|
||||||
|
|
||||||
%type <integer> INT
|
%type <integer> INT
|
||||||
%printer { fprintf (stderr, "%d", $$); } <integer>
|
%printer { fprintf (stderr, "%d", $$); } <integer>
|
||||||
@@ -223,6 +214,56 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
|
|||||||
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
|
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
|
||||||
%type <named_ref> named_ref.opt
|
%type <named_ref> named_ref.opt
|
||||||
|
|
||||||
|
/*---------.
|
||||||
|
| %param. |
|
||||||
|
`---------*/
|
||||||
|
%code requires
|
||||||
|
{
|
||||||
|
# ifndef PARAM_TYPE
|
||||||
|
# define PARAM_TYPE
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
param_none = 0,
|
||||||
|
param_lex = 1 << 0,
|
||||||
|
param_parse = 1 << 1,
|
||||||
|
param_both = param_lex | param_parse
|
||||||
|
} param_type;
|
||||||
|
# endif
|
||||||
|
};
|
||||||
|
%code
|
||||||
|
{
|
||||||
|
/** Add a lex-param and/or a parse-param.
|
||||||
|
*
|
||||||
|
* \param type where to push this formal argument.
|
||||||
|
* \param decl the formal argument. Destroyed.
|
||||||
|
* \param loc the location in the source.
|
||||||
|
*/
|
||||||
|
static void add_param (param_type type, char *decl, location loc);
|
||||||
|
static param_type current_param = param_none;
|
||||||
|
};
|
||||||
|
%union
|
||||||
|
{
|
||||||
|
param_type param;
|
||||||
|
}
|
||||||
|
%token <param> PERCENT_PARAM "%param";
|
||||||
|
%printer
|
||||||
|
{
|
||||||
|
switch ($$)
|
||||||
|
{
|
||||||
|
#define CASE(In, Out) \
|
||||||
|
case param_ ## In: fputs ("%" #Out, stderr); break
|
||||||
|
CASE(lex, lex-param);
|
||||||
|
CASE(parse, parse-param);
|
||||||
|
CASE(both, param);
|
||||||
|
#undef CASE
|
||||||
|
case param_none: aver (false); break;
|
||||||
|
}
|
||||||
|
} <param>;
|
||||||
|
|
||||||
|
|
||||||
|
/*==========\
|
||||||
|
| Grammar. |
|
||||||
|
\==========*/
|
||||||
%%
|
%%
|
||||||
|
|
||||||
input:
|
input:
|
||||||
@@ -251,7 +292,10 @@ prologue_declaration:
|
|||||||
plain_code.code, @1);
|
plain_code.code, @1);
|
||||||
code_scanner_last_string_free ();
|
code_scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
| "%debug" { debug_flag = true; }
|
| "%<flag>"
|
||||||
|
{
|
||||||
|
muscle_percent_define_ensure ($1, @1, true);
|
||||||
|
}
|
||||||
| "%define" variable content.opt
|
| "%define" variable content.opt
|
||||||
{
|
{
|
||||||
muscle_percent_define_insert ($2, @2, $3,
|
muscle_percent_define_insert ($2, @2, $3,
|
||||||
@@ -263,7 +307,11 @@ prologue_declaration:
|
|||||||
defines_flag = true;
|
defines_flag = true;
|
||||||
spec_defines_file = xstrdup ($2);
|
spec_defines_file = xstrdup ($2);
|
||||||
}
|
}
|
||||||
| "%error-verbose" { error_verbose = true; }
|
| "%error-verbose"
|
||||||
|
{
|
||||||
|
muscle_percent_define_insert ("parse.error", @1, "verbose",
|
||||||
|
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||||
|
}
|
||||||
| "%expect" INT { expected_sr_conflicts = $2; }
|
| "%expect" INT { expected_sr_conflicts = $2; }
|
||||||
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
||||||
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
||||||
@@ -283,35 +331,18 @@ prologue_declaration:
|
|||||||
code_scanner_last_string_free ();
|
code_scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
|
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
|
||||||
| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
|
|
||||||
| "%locations" { locations_flag = true; }
|
|
||||||
| "%name-prefix" STRING { spec_name_prefix = $2; }
|
| "%name-prefix" STRING { spec_name_prefix = $2; }
|
||||||
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
|
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
|
||||||
| "%no-lines" { no_lines_flag = true; }
|
| "%no-lines" { no_lines_flag = true; }
|
||||||
| "%nondeterministic-parser" { nondeterministic_parser = true; }
|
| "%nondeterministic-parser" { nondeterministic_parser = true; }
|
||||||
| "%output" STRING { spec_outfile = $2; }
|
| "%output" STRING { spec_outfile = $2; }
|
||||||
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
||||||
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
|
| "%param" { current_param = $1; } params { current_param = param_none; }
|
||||||
| "%pure-parser"
|
|
||||||
{
|
|
||||||
/* %pure-parser is deprecated in favor of `%define api.pure', so use
|
|
||||||
`%define api.pure' in a backward-compatible manner here. First, don't
|
|
||||||
complain if %pure-parser is specified multiple times. */
|
|
||||||
if (!muscle_find_const ("percent_define(api.pure)"))
|
|
||||||
muscle_percent_define_insert ("api.pure", @1, "",
|
|
||||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
|
||||||
/* In all cases, use api.pure now so that the backend doesn't complain if
|
|
||||||
the skeleton ignores api.pure, but do warn now if there's a previous
|
|
||||||
conflicting definition from an actual %define. */
|
|
||||||
if (!muscle_percent_define_flag_if ("api.pure"))
|
|
||||||
muscle_percent_define_insert ("api.pure", @1, "",
|
|
||||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
|
||||||
}
|
|
||||||
| "%require" STRING { version_check (&@2, $2); }
|
| "%require" STRING { version_check (&@2, $2); }
|
||||||
| "%skeleton" STRING
|
| "%skeleton" STRING
|
||||||
{
|
{
|
||||||
char const *skeleton_user = $2;
|
char const *skeleton_user = $2;
|
||||||
if (mbschr (skeleton_user, '/'))
|
if (strchr (skeleton_user, '/'))
|
||||||
{
|
{
|
||||||
size_t dir_length = strlen (current_file);
|
size_t dir_length = strlen (current_file);
|
||||||
char *skeleton_build;
|
char *skeleton_build;
|
||||||
@@ -338,6 +369,16 @@ prologue_declaration:
|
|||||||
| /*FIXME: Err? What is this horror doing here? */ ";"
|
| /*FIXME: Err? What is this horror doing here? */ ";"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
params:
|
||||||
|
params "{...}" { add_param (current_param, $2, @2); }
|
||||||
|
| "{...}" { add_param (current_param, $1, @1); }
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------.
|
||||||
|
| grammar_declaration. |
|
||||||
|
`----------------------*/
|
||||||
|
|
||||||
grammar_declaration:
|
grammar_declaration:
|
||||||
precedence_declaration
|
precedence_declaration
|
||||||
| symbol_declaration
|
| symbol_declaration
|
||||||
@@ -349,14 +390,14 @@ grammar_declaration:
|
|||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
symbol_list_destructor_set (list, $2, @2);
|
symbol_list_code_props_set (list, destructor, @2, $2);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
| "%printer" "{...}" generic_symlist
|
| "%printer" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
symbol_list_printer_set (list, $2, @2);
|
symbol_list_code_props_set (list, printer, @2, $2);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
| "%default-prec"
|
| "%default-prec"
|
||||||
@@ -382,9 +423,9 @@ grammar_declaration:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*----------*
|
/*---------.
|
||||||
| %union. |
|
| %union. |
|
||||||
*----------*/
|
`---------*/
|
||||||
|
|
||||||
%token PERCENT_UNION "%union";
|
%token PERCENT_UNION "%union";
|
||||||
|
|
||||||
@@ -416,7 +457,7 @@ symbol_declaration:
|
|||||||
current_class = unknown_sym;
|
current_class = unknown_sym;
|
||||||
current_type = NULL;
|
current_type = NULL;
|
||||||
}
|
}
|
||||||
| "%type" TYPE symbols.1
|
| "%type" TAG symbols.1
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
@@ -427,7 +468,7 @@ symbol_declaration:
|
|||||||
;
|
;
|
||||||
|
|
||||||
precedence_declaration:
|
precedence_declaration:
|
||||||
precedence_declarator type.opt symbols.prec
|
precedence_declarator tag.opt symbols.prec
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
++current_prec;
|
++current_prec;
|
||||||
@@ -445,11 +486,12 @@ precedence_declarator:
|
|||||||
"%left" { $$ = left_assoc; }
|
"%left" { $$ = left_assoc; }
|
||||||
| "%right" { $$ = right_assoc; }
|
| "%right" { $$ = right_assoc; }
|
||||||
| "%nonassoc" { $$ = non_assoc; }
|
| "%nonassoc" { $$ = non_assoc; }
|
||||||
|
| "%precedence" { $$ = precedence_assoc; }
|
||||||
;
|
;
|
||||||
|
|
||||||
type.opt:
|
tag.opt:
|
||||||
/* Nothing. */ { current_type = NULL; }
|
/* Nothing. */ { current_type = NULL; }
|
||||||
| TYPE { current_type = $1; tag_seen = true; }
|
| TAG { current_type = $1; tag_seen = true; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Just like symbols.1 but accept INT for the sake of POSIX. */
|
/* Just like symbols.1 but accept INT for the sake of POSIX. */
|
||||||
@@ -480,14 +522,14 @@ generic_symlist:
|
|||||||
|
|
||||||
generic_symlist_item:
|
generic_symlist_item:
|
||||||
symbol { $$ = symbol_list_sym_new ($1, @1); }
|
symbol { $$ = symbol_list_sym_new ($1, @1); }
|
||||||
| TYPE { $$ = symbol_list_type_new ($1, @1); }
|
| TAG { $$ = symbol_list_type_new ($1, @1); }
|
||||||
| "<*>" { $$ = symbol_list_default_tagged_new (@1); }
|
| "<*>" { $$ = symbol_list_default_tagged_new (@1); }
|
||||||
| "<>" { $$ = symbol_list_default_tagless_new (@1); }
|
| "<>" { $$ = symbol_list_default_tagless_new (@1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* One token definition. */
|
/* One token definition. */
|
||||||
symbol_def:
|
symbol_def:
|
||||||
TYPE
|
TAG
|
||||||
{
|
{
|
||||||
current_type = $1;
|
current_type = $1;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
@@ -566,12 +608,14 @@ rhs:
|
|||||||
| rhs symbol named_ref.opt
|
| rhs symbol named_ref.opt
|
||||||
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
||||||
| rhs "{...}" named_ref.opt
|
| rhs "{...}" named_ref.opt
|
||||||
{ grammar_current_rule_action_append ($2, @2, $3); }
|
{ grammar_current_rule_action_append ($2, @2, $3, false); }
|
||||||
|
| rhs "%?{...}"
|
||||||
|
{ grammar_current_rule_action_append ($2, @2, NULL, true); }
|
||||||
| rhs "%prec" symbol
|
| rhs "%prec" symbol
|
||||||
{ grammar_current_rule_prec_set ($3, @3); }
|
{ grammar_current_rule_prec_set ($3, @3); }
|
||||||
| rhs "%dprec" INT
|
| rhs "%dprec" INT
|
||||||
{ grammar_current_rule_dprec_set ($3, @3); }
|
{ grammar_current_rule_dprec_set ($3, @3); }
|
||||||
| rhs "%merge" TYPE
|
| rhs "%merge" TAG
|
||||||
{ grammar_current_rule_merge_set ($3, @3); }
|
{ grammar_current_rule_merge_set ($3, @3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -581,10 +625,9 @@ named_ref.opt:
|
|||||||
BRACKETED_ID { $$ = named_ref_new($1, @1); }
|
BRACKETED_ID { $$ = named_ref_new($1, @1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/*---------------------------.
|
||||||
/*----------------------------*
|
|
||||||
| variable and content.opt. |
|
| variable and content.opt. |
|
||||||
*---------------------------*/
|
`---------------------------*/
|
||||||
|
|
||||||
/* The STRING form of variable is deprecated and is not M4-friendly.
|
/* The STRING form of variable is deprecated and is not M4-friendly.
|
||||||
For example, M4 fails for `%define "[" "value"'. */
|
For example, M4 fails for `%define "[" "value"'. */
|
||||||
@@ -601,9 +644,9 @@ content.opt:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*-------------*
|
/*------------.
|
||||||
| braceless. |
|
| braceless. |
|
||||||
*-------------*/
|
`------------*/
|
||||||
|
|
||||||
braceless:
|
braceless:
|
||||||
"{...}"
|
"{...}"
|
||||||
@@ -618,9 +661,9 @@ braceless:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*---------------*
|
/*--------------.
|
||||||
| Identifiers. |
|
| Identifiers. |
|
||||||
*---------------*/
|
`--------------*/
|
||||||
|
|
||||||
/* Identifiers are returned as uniqstr values by the scanner.
|
/* Identifiers are returned as uniqstr values by the scanner.
|
||||||
Depending on their use, we may need to make them genuine symbols. */
|
Depending on their use, we may need to make them genuine symbols. */
|
||||||
@@ -701,20 +744,18 @@ lloc_default (YYLTYPE const *rhs, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Add a lex-param or a parse-param (depending on TYPE) with
|
|
||||||
declaration DECL and location LOC. */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_param (char const *type, char *decl, location loc)
|
add_param (param_type type, char *decl, location loc)
|
||||||
{
|
{
|
||||||
static char const alphanum[26 + 26 + 1 + 10] =
|
static char const alphanum[26 + 26 + 1 + 10] =
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"_"
|
"_"
|
||||||
"0123456789";
|
"0123456789";
|
||||||
char const *name_start = NULL;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
|
char const *name_start = NULL;
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
/* Stop on last actual character. */
|
/* Stop on last actual character. */
|
||||||
for (p = decl; p[1]; p++)
|
for (p = decl; p[1]; p++)
|
||||||
if ((p == decl
|
if ((p == decl
|
||||||
@@ -729,13 +770,18 @@ add_param (char const *type, char *decl, location loc)
|
|||||||
p[1] = '\0';
|
p[1] = '\0';
|
||||||
while (*++decl == ' ' || *decl == '\t')
|
while (*++decl == ' ' || *decl == '\t')
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (! name_start)
|
if (! name_start)
|
||||||
complain_at (loc, _("missing identifier in parameter declaration"));
|
complain_at (loc, complaint,
|
||||||
|
_("missing identifier in parameter declaration"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
|
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
|
||||||
muscle_pair_list_grow (type, decl, name);
|
if (type & param_lex)
|
||||||
|
muscle_pair_list_grow ("lex_param", decl, name);
|
||||||
|
if (type & param_parse)
|
||||||
|
muscle_pair_list_grow ("parse_param", decl, name);
|
||||||
free (name);
|
free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,7 +794,7 @@ version_check (location const *loc, char const *version)
|
|||||||
{
|
{
|
||||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||||
{
|
{
|
||||||
complain_at (*loc, "require bison %s, but have %s",
|
complain_at (*loc, complaint, "require bison %s, but have %s",
|
||||||
version, PACKAGE_VERSION);
|
version, PACKAGE_VERSION);
|
||||||
exit (EX_MISMATCH);
|
exit (EX_MISMATCH);
|
||||||
}
|
}
|
||||||
@@ -757,7 +803,7 @@ version_check (location const *loc, char const *version)
|
|||||||
static void
|
static void
|
||||||
gram_error (location const *loc, char const *msg)
|
gram_error (location const *loc, char const *msg)
|
||||||
{
|
{
|
||||||
complain_at (*loc, "%s", msg);
|
complain_at (*loc, complaint, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
char const *
|
||||||
|
|||||||
+2
-2
@@ -336,8 +336,8 @@ print_reductions (FILE *out, state *s)
|
|||||||
char *default_reductions =
|
char *default_reductions =
|
||||||
muscle_percent_define_get ("lr.default-reductions");
|
muscle_percent_define_get ("lr.default-reductions");
|
||||||
print_reduction (out, width, _("$default"), default_reduction, true);
|
print_reduction (out, width, _("$default"), default_reduction, true);
|
||||||
aver (0 == strcmp (default_reductions, "most")
|
aver (STREQ (default_reductions, "most")
|
||||||
|| (0 == strcmp (default_reductions, "consistent")
|
|| (STREQ (default_reductions, "consistent")
|
||||||
&& default_reduction_only)
|
&& default_reduction_only)
|
||||||
|| (reds->num == 1 && reds->rules[0]->number == 0));
|
|| (reds->num == 1 && reds->rules[0]->number == 0));
|
||||||
free (default_reductions);
|
free (default_reductions);
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ print_actions (state const *s, FILE *fgraph)
|
|||||||
: "dashed");
|
: "dashed");
|
||||||
|
|
||||||
if (TRANSITION_IS_ERROR (trans, i)
|
if (TRANSITION_IS_ERROR (trans, i)
|
||||||
&& strcmp (symbols[sym]->tag, "error") != 0)
|
&& STRNEQ (symbols[sym]->tag, "error"))
|
||||||
abort ();
|
abort ();
|
||||||
output_edge (s->number, s1->number,
|
output_edge (s->number, s1->number,
|
||||||
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
||||||
|
|||||||
+34
-27
@@ -59,7 +59,7 @@ void
|
|||||||
grammar_start_symbol_set (symbol *sym, location loc)
|
grammar_start_symbol_set (symbol *sym, location loc)
|
||||||
{
|
{
|
||||||
if (start_flag)
|
if (start_flag)
|
||||||
complain_at (loc, _("multiple %s declarations"), "%start");
|
complain_at (loc, complaint, _("multiple %s declarations"), "%start");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start_flag = true;
|
start_flag = true;
|
||||||
@@ -128,10 +128,10 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
|
|||||||
aver (merge_function != NULL && merger_find == merger);
|
aver (merge_function != NULL && merger_find == merger);
|
||||||
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
||||||
{
|
{
|
||||||
complain_at (declaration_loc,
|
complain_at (declaration_loc, complaint,
|
||||||
_("result type clash on merge function %s: <%s> != <%s>"),
|
_("result type clash on merge function %s: <%s> != <%s>"),
|
||||||
quote (merge_function->name), type, merge_function->type);
|
quote (merge_function->name), type, merge_function->type);
|
||||||
complain_at (merge_function->type_declaration_location,
|
complain_at (merge_function->type_declaration_location, complaint,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
merge_function->type = uniqstr_new (type);
|
merge_function->type = uniqstr_new (type);
|
||||||
@@ -197,7 +197,7 @@ assign_named_ref (symbol_list *p, named_ref *name)
|
|||||||
|
|
||||||
if (name->id == sym->tag)
|
if (name->id == sym->tag)
|
||||||
{
|
{
|
||||||
warn_at (name->loc,
|
complain_at (name->loc, Wother,
|
||||||
_("duplicated symbol name for %s ignored"),
|
_("duplicated symbol name for %s ignored"),
|
||||||
quote (sym->tag));
|
quote (sym->tag));
|
||||||
named_ref_free (name);
|
named_ref_free (name);
|
||||||
@@ -242,7 +242,8 @@ grammar_current_rule_begin (symbol *lhs, location loc,
|
|||||||
++nvars;
|
++nvars;
|
||||||
}
|
}
|
||||||
else if (lhs->class == token_sym)
|
else if (lhs->class == token_sym)
|
||||||
complain_at (loc, _("rule given for %s, which is a token"), lhs->tag);
|
complain_at (loc, complaint, _("rule given for %s, which is a token"),
|
||||||
|
lhs->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,7 +258,7 @@ grammar_current_rule_begin (symbol *lhs, location loc,
|
|||||||
static bool
|
static bool
|
||||||
symbol_should_be_used (symbol_list const *s, bool *midrule_warning)
|
symbol_should_be_used (symbol_list const *s, bool *midrule_warning)
|
||||||
{
|
{
|
||||||
if (symbol_destructor_get (s->content.sym)->code)
|
if (symbol_code_props_get (s->content.sym, destructor)->code)
|
||||||
return true;
|
return true;
|
||||||
if ((s->midrule && s->midrule->action_props.is_value_used)
|
if ((s->midrule && s->midrule->action_props.is_value_used)
|
||||||
|| (s->midrule_parent_rule
|
|| (s->midrule_parent_rule
|
||||||
@@ -296,13 +297,13 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
const char *rhs_type =
|
const char *rhs_type =
|
||||||
first_rhs->type_name ? first_rhs->type_name : "";
|
first_rhs->type_name ? first_rhs->type_name : "";
|
||||||
if (!UNIQSTR_EQ (lhs_type, rhs_type))
|
if (!UNIQSTR_EQ (lhs_type, rhs_type))
|
||||||
warn_at (r->location,
|
complain_at (r->location, Wother,
|
||||||
_("type clash on default action: <%s> != <%s>"),
|
_("type clash on default action: <%s> != <%s>"),
|
||||||
lhs_type, rhs_type);
|
lhs_type, rhs_type);
|
||||||
}
|
}
|
||||||
/* Warn if there is no default for $$ but we need one. */
|
/* Warn if there is no default for $$ but we need one. */
|
||||||
else
|
else
|
||||||
warn_at (r->location,
|
complain_at (r->location, Wother,
|
||||||
_("empty rule for typed nonterminal, and no action"));
|
_("empty rule for typed nonterminal, and no action"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,12 +319,11 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
/* The default action, $$ = $1, `uses' both. */
|
/* The default action, $$ = $1, `uses' both. */
|
||||||
&& (r->action_props.code || (n != 0 && n != 1)))
|
&& (r->action_props.code || (n != 0 && n != 1)))
|
||||||
{
|
{
|
||||||
void (*warn_at_ptr)(location, char const*, ...) =
|
warnings warn_flag = midrule_warning ? Wmidrule_values : Wother;
|
||||||
midrule_warning ? midrule_value_at : warn_at;
|
|
||||||
if (n)
|
if (n)
|
||||||
warn_at_ptr (r->location, _("unused value: $%d"), n);
|
complain_at (r->location, warn_flag, _("unused value: $%d"), n);
|
||||||
else
|
else
|
||||||
warn_at_ptr (r->location, _("unset value: $$"));
|
complain_at (r->location, warn_flag, _("unset value: $$"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,9 +333,9 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
it for char literals and strings, which are always tokens. */
|
it for char literals and strings, which are always tokens. */
|
||||||
if (r->ruleprec
|
if (r->ruleprec
|
||||||
&& r->ruleprec->tag[0] != '\'' && r->ruleprec->tag[0] != '"'
|
&& r->ruleprec->tag[0] != '\'' && r->ruleprec->tag[0] != '"'
|
||||||
&& !r->ruleprec->declared && !r->ruleprec->prec)
|
&& r->ruleprec->status != declared && !r->ruleprec->prec)
|
||||||
warn_at (r->location, _("token for %%prec is not defined: %s"),
|
complain_at (r->location, Wother,
|
||||||
r->ruleprec->tag);
|
_("token for %%prec is not defined: %s"), r->ruleprec->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -384,7 +384,8 @@ grammar_midrule_action (void)
|
|||||||
code_props_rule_action_init (&midrule->action_props,
|
code_props_rule_action_init (&midrule->action_props,
|
||||||
current_rule->action_props.code,
|
current_rule->action_props.code,
|
||||||
current_rule->action_props.location,
|
current_rule->action_props.location,
|
||||||
midrule, 0);
|
midrule, 0,
|
||||||
|
current_rule->action_props.is_predicate);
|
||||||
code_props_none_init (¤t_rule->action_props);
|
code_props_none_init (¤t_rule->action_props);
|
||||||
|
|
||||||
if (previous_rule_end)
|
if (previous_rule_end)
|
||||||
@@ -424,7 +425,7 @@ grammar_current_rule_prec_set (symbol *precsym, location loc)
|
|||||||
token. */
|
token. */
|
||||||
symbol_class_set (precsym, token_sym, loc, false);
|
symbol_class_set (precsym, token_sym, loc, false);
|
||||||
if (current_rule->ruleprec)
|
if (current_rule->ruleprec)
|
||||||
complain_at (loc, _("only one %s allowed per rule"), "%prec");
|
complain_at (loc, complaint, _("only one %s allowed per rule"), "%prec");
|
||||||
current_rule->ruleprec = precsym;
|
current_rule->ruleprec = precsym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,11 +435,13 @@ void
|
|||||||
grammar_current_rule_dprec_set (int dprec, location loc)
|
grammar_current_rule_dprec_set (int dprec, location loc)
|
||||||
{
|
{
|
||||||
if (! glr_parser)
|
if (! glr_parser)
|
||||||
warn_at (loc, _("%s affects only GLR parsers"), "%dprec");
|
complain_at (loc, Wother, _("%s affects only GLR parsers"),
|
||||||
|
"%dprec");
|
||||||
if (dprec <= 0)
|
if (dprec <= 0)
|
||||||
complain_at (loc, _("%s must be followed by positive number"), "%dprec");
|
complain_at (loc, complaint, _("%s must be followed by positive number"),
|
||||||
|
"%dprec");
|
||||||
else if (current_rule->dprec != 0)
|
else if (current_rule->dprec != 0)
|
||||||
complain_at (loc, _("only one %s allowed per rule"), "%dprec");
|
complain_at (loc, complaint, _("only one %s allowed per rule"), "%dprec");
|
||||||
current_rule->dprec = dprec;
|
current_rule->dprec = dprec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,9 +452,10 @@ void
|
|||||||
grammar_current_rule_merge_set (uniqstr name, location loc)
|
grammar_current_rule_merge_set (uniqstr name, location loc)
|
||||||
{
|
{
|
||||||
if (! glr_parser)
|
if (! glr_parser)
|
||||||
warn_at (loc, _("%s affects only GLR parsers"), "%merge");
|
complain_at (loc, Wother, _("%s affects only GLR parsers"),
|
||||||
|
"%merge");
|
||||||
if (current_rule->merger != 0)
|
if (current_rule->merger != 0)
|
||||||
complain_at (loc, _("only one %s allowed per rule"), "%merge");
|
complain_at (loc, complaint, _("only one %s allowed per rule"), "%merge");
|
||||||
current_rule->merger = get_merge_function (name);
|
current_rule->merger = get_merge_function (name);
|
||||||
current_rule->merger_declaration_location = loc;
|
current_rule->merger_declaration_location = loc;
|
||||||
}
|
}
|
||||||
@@ -469,20 +473,22 @@ grammar_current_rule_symbol_append (symbol *sym, location loc,
|
|||||||
p = grammar_symbol_append (sym, loc);
|
p = grammar_symbol_append (sym, loc);
|
||||||
if (name)
|
if (name)
|
||||||
assign_named_ref(p, name);
|
assign_named_ref(p, name);
|
||||||
|
if (sym->status == undeclared || sym->status == used)
|
||||||
|
sym->status = needed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach an ACTION to the current rule. */
|
/* Attach an ACTION to the current rule. */
|
||||||
|
|
||||||
void
|
void
|
||||||
grammar_current_rule_action_append (const char *action, location loc,
|
grammar_current_rule_action_append (const char *action, location loc,
|
||||||
named_ref *name)
|
named_ref *name, bool is_predicate)
|
||||||
{
|
{
|
||||||
if (current_rule->action_props.code)
|
if (current_rule->action_props.code)
|
||||||
grammar_midrule_action ();
|
grammar_midrule_action ();
|
||||||
/* After all symbol declarations have been parsed, packgram invokes
|
/* After all symbol declarations have been parsed, packgram invokes
|
||||||
code_props_translate_code. */
|
code_props_translate_code. */
|
||||||
code_props_rule_action_init (¤t_rule->action_props, action, loc,
|
code_props_rule_action_init (¤t_rule->action_props, action, loc,
|
||||||
current_rule, name);
|
current_rule, name, is_predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -523,6 +529,7 @@ packgram (void)
|
|||||||
rules[ruleno].useful = true;
|
rules[ruleno].useful = true;
|
||||||
rules[ruleno].action = p->action_props.code;
|
rules[ruleno].action = p->action_props.code;
|
||||||
rules[ruleno].action_location = p->action_props.location;
|
rules[ruleno].action_location = p->action_props.location;
|
||||||
|
rules[ruleno].is_predicate = p->action_props.is_predicate;
|
||||||
|
|
||||||
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
|
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
|
||||||
symbol name so that it's a user-defined symbol so that the default
|
symbol name so that it's a user-defined symbol so that the default
|
||||||
@@ -547,7 +554,7 @@ packgram (void)
|
|||||||
/* Don't allow rule_length == INT_MAX, since that might
|
/* Don't allow rule_length == INT_MAX, since that might
|
||||||
cause confusion with strtol if INT_MAX == LONG_MAX. */
|
cause confusion with strtol if INT_MAX == LONG_MAX. */
|
||||||
if (rule_length == INT_MAX)
|
if (rule_length == INT_MAX)
|
||||||
fatal_at (rules[ruleno].location, _("rule is too long"));
|
complain_at (rules[ruleno].location, fatal, _("rule is too long"));
|
||||||
|
|
||||||
/* item_number = symbol_number.
|
/* item_number = symbol_number.
|
||||||
But the former needs to contain more: negative rule numbers. */
|
But the former needs to contain more: negative rule numbers. */
|
||||||
@@ -636,7 +643,7 @@ prepare_percent_define_front_end_variables (void)
|
|||||||
default. */
|
default. */
|
||||||
muscle_percent_define_default ("lr.type", "lalr");
|
muscle_percent_define_default ("lr.type", "lalr");
|
||||||
lr_type = muscle_percent_define_get ("lr.type");
|
lr_type = muscle_percent_define_get ("lr.type");
|
||||||
if (0 != strcmp (lr_type, "canonical-lr"))
|
if (STRNEQ (lr_type, "canonical-lr"))
|
||||||
muscle_percent_define_default ("lr.default-reductions", "most");
|
muscle_percent_define_default ("lr.default-reductions", "most");
|
||||||
else
|
else
|
||||||
muscle_percent_define_default ("lr.default-reductions", "accepting");
|
muscle_percent_define_default ("lr.default-reductions", "accepting");
|
||||||
@@ -665,7 +672,7 @@ check_and_convert_grammar (void)
|
|||||||
{
|
{
|
||||||
/* Grammar has been read. Do some checking. */
|
/* Grammar has been read. Do some checking. */
|
||||||
if (nrules == 0)
|
if (nrules == 0)
|
||||||
fatal (_("no rules in the input grammar"));
|
complain (fatal, _("no rules in the input grammar"));
|
||||||
|
|
||||||
/* If the user did not define her ENDTOKEN, do it now. */
|
/* If the user did not define her ENDTOKEN, do it now. */
|
||||||
if (!endtoken)
|
if (!endtoken)
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ void grammar_current_rule_merge_set (uniqstr name, location loc);
|
|||||||
void grammar_current_rule_symbol_append (symbol *sym, location loc,
|
void grammar_current_rule_symbol_append (symbol *sym, location loc,
|
||||||
named_ref *named_ref);
|
named_ref *named_ref);
|
||||||
void grammar_current_rule_action_append (const char *action, location loc,
|
void grammar_current_rule_action_append (const char *action, location loc,
|
||||||
named_ref *named_ref);
|
named_ref *named_ref, bool);
|
||||||
void reader (void);
|
void reader (void);
|
||||||
void free_merger_functions (void);
|
void free_merger_functions (void);
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -285,13 +285,12 @@ reduce_grammar_tables (void)
|
|||||||
static void
|
static void
|
||||||
nonterminals_reduce (void)
|
nonterminals_reduce (void)
|
||||||
{
|
{
|
||||||
symbol_number i, n;
|
|
||||||
|
|
||||||
/* Map the nonterminals to their new index: useful first, useless
|
/* Map the nonterminals to their new index: useful first, useless
|
||||||
afterwards. Kept for later report. */
|
afterwards. Kept for later report. */
|
||||||
|
|
||||||
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
|
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
|
||||||
n = ntokens;
|
symbol_number n = ntokens;
|
||||||
|
symbol_number i;
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
if (bitset_test (V, i))
|
if (bitset_test (V, i))
|
||||||
nontermmap[i - ntokens] = n++;
|
nontermmap[i - ntokens] = n++;
|
||||||
@@ -299,7 +298,9 @@ nonterminals_reduce (void)
|
|||||||
if (!bitset_test (V, i))
|
if (!bitset_test (V, i))
|
||||||
{
|
{
|
||||||
nontermmap[i - ntokens] = n++;
|
nontermmap[i - ntokens] = n++;
|
||||||
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
|
if (symbols[i]->status != used)
|
||||||
|
complain_at (symbols[i]->location, Wother,
|
||||||
|
_("nonterminal useless in grammar: %s"),
|
||||||
symbols[i]->tag);
|
symbols[i]->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,12 +383,12 @@ static void
|
|||||||
reduce_print (void)
|
reduce_print (void)
|
||||||
{
|
{
|
||||||
if (nuseless_nonterminals > 0)
|
if (nuseless_nonterminals > 0)
|
||||||
warn (ngettext ("%d nonterminal useless in grammar",
|
complain (Wother, ngettext ("%d nonterminal useless in grammar",
|
||||||
"%d nonterminals useless in grammar",
|
"%d nonterminals useless in grammar",
|
||||||
nuseless_nonterminals),
|
nuseless_nonterminals),
|
||||||
nuseless_nonterminals);
|
nuseless_nonterminals);
|
||||||
if (nuseless_productions > 0)
|
if (nuseless_productions > 0)
|
||||||
warn (ngettext ("%d rule useless in grammar",
|
complain (Wother, ngettext ("%d rule useless in grammar",
|
||||||
"%d rules useless in grammar",
|
"%d rules useless in grammar",
|
||||||
nuseless_productions),
|
nuseless_productions),
|
||||||
nuseless_productions);
|
nuseless_productions);
|
||||||
@@ -415,7 +416,7 @@ reduce_grammar (void)
|
|||||||
reduce_print ();
|
reduce_print ();
|
||||||
|
|
||||||
if (!bitset_test (N, accept->number - ntokens))
|
if (!bitset_test (N, accept->number - ntokens))
|
||||||
fatal_at (startsymbol_location,
|
complain_at (startsymbol_location, fatal,
|
||||||
_("start symbol %s does not derive any sentence"),
|
_("start symbol %s does not derive any sentence"),
|
||||||
startsymbol->tag);
|
startsymbol->tag);
|
||||||
|
|
||||||
@@ -431,8 +432,8 @@ reduce_grammar (void)
|
|||||||
{
|
{
|
||||||
grammar_dump (stderr, "Reduced Grammar");
|
grammar_dump (stderr, "Reduced Grammar");
|
||||||
|
|
||||||
fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
|
fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals"
|
||||||
, and %d productions.\n",
|
", and %d productions.\n",
|
||||||
grammar_file, ntokens, nvars, nrules);
|
grammar_file, ntokens, nvars, nrules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "scan-code.c"
|
#include "src/scan-code.c"
|
||||||
|
|||||||
+22
-2
@@ -63,6 +63,17 @@ typedef struct code_props {
|
|||||||
*/
|
*/
|
||||||
bool is_value_used;
|
bool is_value_used;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \c true iff this code is an action that is not to be deferred in
|
||||||
|
* a non-deterministic parser.
|
||||||
|
*/
|
||||||
|
bool is_predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this is actually used (i.e., not completely masked by
|
||||||
|
* other code props). */
|
||||||
|
bool is_used;
|
||||||
|
|
||||||
/** \c NULL iff \c code_props::kind is not \c CODE_PROPS_RULE_ACTION. */
|
/** \c NULL iff \c code_props::kind is not \c CODE_PROPS_RULE_ACTION. */
|
||||||
struct symbol_list *rule;
|
struct symbol_list *rule;
|
||||||
|
|
||||||
@@ -80,7 +91,16 @@ void code_props_none_init (code_props *self);
|
|||||||
|
|
||||||
/** Equivalent to \c code_props_none_init. */
|
/** Equivalent to \c code_props_none_init. */
|
||||||
#define CODE_PROPS_NONE_INIT \
|
#define CODE_PROPS_NONE_INIT \
|
||||||
{CODE_PROPS_NONE, NULL, EMPTY_LOCATION_INIT, false, NULL, NULL}
|
{ \
|
||||||
|
/* .kind = */ CODE_PROPS_NONE, \
|
||||||
|
/* .code = */ NULL, \
|
||||||
|
/* .location = */ EMPTY_LOCATION_INIT, \
|
||||||
|
/* .is_value_used = */ false, \
|
||||||
|
/* .is_predicate = */ false, \
|
||||||
|
/* .is_used = */ false, \
|
||||||
|
/* .rule = */ NULL, \
|
||||||
|
/* .named_ref = */ NULL \
|
||||||
|
}
|
||||||
|
|
||||||
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
|
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
|
||||||
extern code_props const code_props_none;
|
extern code_props const code_props_none;
|
||||||
@@ -134,7 +154,7 @@ void code_props_symbol_action_init (code_props *self, char const *code,
|
|||||||
*/
|
*/
|
||||||
void code_props_rule_action_init (code_props *self, char const *code,
|
void code_props_rule_action_init (code_props *self, char const *code,
|
||||||
location code_loc, struct symbol_list *rule,
|
location code_loc, struct symbol_list *rule,
|
||||||
named_ref *name);
|
named_ref *name, bool is_predicate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \pre
|
* \pre
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user