mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-14 05:05:14 +00:00
Compare commits
891
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ca964032 | ||
|
|
485b319598 | ||
|
|
1ed94b7c84 | ||
|
|
b119971aef | ||
|
|
2a0f5b17b4 | ||
|
|
b611359d90 | ||
|
|
3eb4f1a3e6 | ||
|
|
d0d3313d10 | ||
|
|
a4107f24bc | ||
|
|
1505e8bb78 | ||
|
|
58c7e5ee2c | ||
|
|
ad6b775fc5 | ||
|
|
5d614dfa8c | ||
|
|
858c700fc0 | ||
|
|
c30717cafa | ||
|
|
0e98a81e00 | ||
|
|
d5c20d1a36 | ||
|
|
e6ae99fe75 | ||
|
|
bcbbf65486 | ||
|
|
1aa9fa823b | ||
|
|
321b8117a6 | ||
|
|
e4828e2384 | ||
|
|
a122efad8a | ||
|
|
15ffba51b0 | ||
|
|
ea6a2d96db | ||
|
|
ae63f0e8e2 | ||
|
|
41c11ce484 | ||
|
|
9553083c72 | ||
|
|
8f064948c5 | ||
|
|
60aa04a236 | ||
|
|
a59a6ddef4 | ||
|
|
aca4ddc75d | ||
|
|
47977a7e74 | ||
|
|
813f7d3482 | ||
|
|
7a9e6d65ea | ||
|
|
916f26b65a | ||
|
|
32ae07efde | ||
|
|
ad60e80f3d | ||
|
|
2a824fae30 | ||
|
|
c242519127 | ||
|
|
e358222ba8 | ||
|
|
9dcb193aeb | ||
|
|
ccdc1577ef | ||
|
|
faff3bef5b | ||
|
|
53ab797db7 | ||
|
|
426903aa75 | ||
|
|
9104636b03 | ||
|
|
1168b32295 | ||
|
|
771dc64324 | ||
|
|
a7385a21ce | ||
|
|
b142cfd128 | ||
|
|
5f108727a1 | ||
|
|
ff34897041 | ||
|
|
dcb366b103 | ||
|
|
5458913aba | ||
|
|
242cc08e8d | ||
|
|
4b3847c3c0 | ||
|
|
73370a9daa | ||
|
|
b640317060 | ||
|
|
3e153163c7 | ||
|
|
5ff5cf6700 | ||
|
|
415b88231a | ||
|
|
6fb8b25619 | ||
|
|
d0f11c1b62 | ||
|
|
327db05b22 | ||
|
|
f124616490 | ||
|
|
7aaaad6c6d | ||
|
|
087dcd7868 | ||
|
|
95361618de | ||
|
|
694af10cb7 | ||
|
|
258cddbc36 | ||
|
|
22b081deb7 | ||
|
|
9bcffa0c13 | ||
|
|
297e263a00 | ||
|
|
ea9a35c605 | ||
|
|
a32a2d57a5 | ||
|
|
8d6c1b5e85 | ||
|
|
77519a7d18 | ||
|
|
0e16927b48 | ||
|
|
91ce0b3a66 | ||
|
|
837b769659 | ||
|
|
5e01579ec0 | ||
|
|
9641b918ba | ||
|
|
55d1006fce | ||
|
|
423ca9b50e | ||
|
|
6cf3716c31 | ||
|
|
6a0655d9cd | ||
|
|
71da68b366 | ||
|
|
230a3db428 | ||
|
|
6d55954743 | ||
|
|
7490994123 | ||
|
|
eb46d61f4d | ||
|
|
05a7b6ec80 | ||
|
|
290a8ff2c0 | ||
|
|
6e2d7b0974 | ||
|
|
2d40532bf5 | ||
|
|
dfe292c695 | ||
|
|
9fd33c2b6e | ||
|
|
756257ee86 | ||
|
|
18ad57b384 | ||
|
|
3b0b682fd6 | ||
|
|
0d4b994cc2 | ||
|
|
e97965c022 | ||
|
|
6dc4663d5c | ||
|
|
b921d92fcb | ||
|
|
da402d1cae | ||
|
|
dda2c1adba | ||
|
|
71bff31edd | ||
|
|
0dd59ce3b4 | ||
|
|
e436fa677c | ||
|
|
e29f0771d7 | ||
|
|
71c7e24f2e | ||
|
|
5f7f1e210b | ||
|
|
eb83259dc1 | ||
|
|
55f48c4831 | ||
|
|
34d867d7d2 | ||
|
|
363bf73276 | ||
|
|
c8c220d19a | ||
|
|
56ca3d8fce | ||
|
|
c3e9f08f93 | ||
|
|
6aef2e01a4 | ||
|
|
3d8082ad27 | ||
|
|
9d67a52ad6 | ||
|
|
0f11eec272 | ||
|
|
22539284f3 | ||
|
|
aed41cf9a0 | ||
|
|
ae6bdabbf6 | ||
|
|
c0beb08772 | ||
|
|
5237cd1ac8 | ||
|
|
9ce27ab013 | ||
|
|
c0828abf9d | ||
|
|
e9807a7934 | ||
|
|
02287ec650 | ||
|
|
6537c71fcc | ||
|
|
6733d02476 | ||
|
|
cc9fb4f6b6 | ||
|
|
f763e6ef67 | ||
|
|
c4576b484a | ||
|
|
91aadcc7a9 | ||
|
|
4896ede89c | ||
|
|
84526bf3d1 | ||
|
|
d9a7c07c5a | ||
|
|
28126202a5 | ||
|
|
527187137a | ||
|
|
dfaac27242 | ||
|
|
ed7658fe17 | ||
|
|
4d4777c786 | ||
|
|
cbdb6d9145 | ||
|
|
398c298c88 | ||
|
|
c547693afd | ||
|
|
6a4f5c6ea0 | ||
|
|
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 |
@@ -31,3 +31,4 @@
|
|||||||
/patches
|
/patches
|
||||||
/releases
|
/releases
|
||||||
/stamp-h*
|
/stamp-h*
|
||||||
|
/README-release
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
2.3b
|
2.6
|
||||||
|
|||||||
+2898
-451
File diff suppressed because it is too large
Load Diff
+56
-32
@@ -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,31 +70,33 @@ $(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
|
||||||
gen-ChangeLog:
|
gen-ChangeLog:
|
||||||
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
|
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
|
||||||
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
cl=$(distdir)/ChangeLog && \
|
||||||
--strip-tab \
|
rm -f $$cl.tmp && \
|
||||||
--strip-cherry-picked \
|
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
||||||
--no-cluster \
|
--strip-tab \
|
||||||
--amend=$(srcdir)/build-aux/git-log-fix \
|
--strip-cherry-pick \
|
||||||
--since=$(gen_start_date) > $(distdir)/cl-t; \
|
--no-cluster \
|
||||||
rm -f $(distdir)/ChangeLog; \
|
--amend=$(srcdir)/build-aux/git-log-fix \
|
||||||
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
--srcdir=$(srcdir) \
|
||||||
|
--since=$(gen_start_date) > $$cl.tmp && \
|
||||||
|
mv -f $$cl.tmp $$cl; \
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,7 +1,261 @@
|
|||||||
Bison News
|
GNU Bison NEWS
|
||||||
----------
|
|
||||||
|
|
||||||
* Changes in version 2.5.1_rc2 (2012-05-23):
|
* 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]
|
||||||
|
|
||||||
|
** Future changes:
|
||||||
|
|
||||||
|
The next major release of Bison will drop support for the following
|
||||||
|
deprecated features. Please report disagreements to [email protected].
|
||||||
|
|
||||||
|
*** K&C parsers
|
||||||
|
|
||||||
|
Support for generating parsers in K&R C will be removed. Parsers
|
||||||
|
generated for C support ISO C90, and are tested with ISO C99 and ISO C11
|
||||||
|
compilers.
|
||||||
|
|
||||||
|
*** Features deprecated since Bison 1.875
|
||||||
|
|
||||||
|
The definitions of yystype and yyltype will be removed; use YYSTYPE and
|
||||||
|
YYLTYPE.
|
||||||
|
|
||||||
|
YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
|
||||||
|
%lex-param, will no longer be supported.
|
||||||
|
|
||||||
|
Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
|
||||||
|
%error-verbose.
|
||||||
|
|
||||||
|
*** The generated header will be included (yacc.c)
|
||||||
|
|
||||||
|
Instead of duplicating the content of the generated header (definition of
|
||||||
|
YYSTYPE, yyparse declaration etc.), the generated parser will include it,
|
||||||
|
as is already the case for GLR or C++ parsers. This change is deferred
|
||||||
|
because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
|
||||||
|
it.
|
||||||
|
|
||||||
|
** Generated Parser Headers
|
||||||
|
|
||||||
|
*** Guards (yacc.c, glr.c, glr.cc)
|
||||||
|
|
||||||
|
The generated headers are now guarded, as is already the case for C++
|
||||||
|
parsers (lalr1.cc). For instance, with --defines=foo.h:
|
||||||
|
|
||||||
|
#ifndef YY_FOO_H
|
||||||
|
# define YY_FOO_H
|
||||||
|
...
|
||||||
|
#endif /* !YY_FOO_H */
|
||||||
|
|
||||||
|
*** New declarations (yacc.c, glr.c)
|
||||||
|
|
||||||
|
The generated header now declares yydebug and yyparse. Both honor
|
||||||
|
--name-prefix=bar_, and yield
|
||||||
|
|
||||||
|
int bar_parse (void);
|
||||||
|
|
||||||
|
rather than
|
||||||
|
|
||||||
|
#define yyparse bar_parse
|
||||||
|
int yyparse (void);
|
||||||
|
|
||||||
|
in order to facilitate the inclusion of several parser headers inside a
|
||||||
|
single compilation unit.
|
||||||
|
|
||||||
|
*** Exported symbols in C++
|
||||||
|
|
||||||
|
The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
|
||||||
|
header, are removed, as they prevent the possibility of including several
|
||||||
|
generated headers from a single compilation unit.
|
||||||
|
|
||||||
|
*** YYLSP_NEEDED
|
||||||
|
|
||||||
|
For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
|
||||||
|
longer defined.
|
||||||
|
|
||||||
|
** New %define variable: api.prefix
|
||||||
|
|
||||||
|
Now that the generated headers are more complete and properly protected
|
||||||
|
against multiple inclusions, constant names, such as YYSTYPE are a
|
||||||
|
problem. While yyparse and others are properly renamed by %name-prefix,
|
||||||
|
YYSTYPE, YYDEBUG and others have never been affected by it. Because it
|
||||||
|
would introduce backward compatibility issues in projects not expecting
|
||||||
|
YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
|
||||||
|
it is deprecated in favor of a new %define variable: api.prefix.
|
||||||
|
|
||||||
|
The following examples compares both:
|
||||||
|
|
||||||
|
%name-prefix "bar_" | %define api.prefix "bar_"
|
||||||
|
%token <ival> FOO %token <ival> FOO
|
||||||
|
%union { int ival; } %union { int ival; }
|
||||||
|
%% %%
|
||||||
|
exp: 'a'; exp: 'a';
|
||||||
|
|
||||||
|
bison generates:
|
||||||
|
|
||||||
|
#ifndef BAR_FOO_H #ifndef BAR_FOO_H
|
||||||
|
# define BAR_FOO_H # define BAR_FOO_H
|
||||||
|
|
||||||
|
/* Enabling traces. */ /* Enabling traces. */
|
||||||
|
# ifndef YYDEBUG | # ifndef BAR_DEBUG
|
||||||
|
> # if defined YYDEBUG
|
||||||
|
> # if YYDEBUG
|
||||||
|
> # define BAR_DEBUG 1
|
||||||
|
> # else
|
||||||
|
> # define BAR_DEBUG 0
|
||||||
|
> # endif
|
||||||
|
> # else
|
||||||
|
# define YYDEBUG 0 | # define BAR_DEBUG 0
|
||||||
|
> # endif
|
||||||
|
# endif | # endif
|
||||||
|
|
||||||
|
# if YYDEBUG | # if BAR_DEBUG
|
||||||
|
extern int bar_debug; extern int bar_debug;
|
||||||
|
# endif # endif
|
||||||
|
|
||||||
|
/* Tokens. */ /* Tokens. */
|
||||||
|
# ifndef YYTOKENTYPE | # ifndef BAR_TOKENTYPE
|
||||||
|
# define YYTOKENTYPE | # define BAR_TOKENTYPE
|
||||||
|
enum yytokentype { | enum bar_tokentype {
|
||||||
|
FOO = 258 FOO = 258
|
||||||
|
}; };
|
||||||
|
# endif # endif
|
||||||
|
|
||||||
|
#if ! defined YYSTYPE \ | #if ! defined BAR_STYPE \
|
||||||
|
&& ! defined YYSTYPE_IS_DECLARED | && ! defined BAR_STYPE_IS_DECLARED
|
||||||
|
typedef union YYSTYPE | typedef union BAR_STYPE
|
||||||
|
{ {
|
||||||
|
int ival; int ival;
|
||||||
|
} YYSTYPE; | } BAR_STYPE;
|
||||||
|
# define YYSTYPE_IS_DECLARED 1 | # define BAR_STYPE_IS_DECLARED 1
|
||||||
|
#endif #endif
|
||||||
|
|
||||||
|
extern YYSTYPE bar_lval; | extern BAR_STYPE bar_lval;
|
||||||
|
|
||||||
|
int bar_parse (void); int bar_parse (void);
|
||||||
|
|
||||||
|
#endif /* !BAR_FOO_H */ #endif /* !BAR_FOO_H */
|
||||||
|
|
||||||
|
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
|
||||||
|
|
||||||
** Future changes:
|
** Future changes:
|
||||||
|
|
||||||
@@ -38,10 +292,10 @@ Bison News
|
|||||||
The header files such as "parser.hh", "location.hh", etc. used a constant
|
The header files such as "parser.hh", "location.hh", etc. used a constant
|
||||||
name for preprocessor guards, for instance:
|
name for preprocessor guards, for instance:
|
||||||
|
|
||||||
#ifndef BISON_LOCATION_HH
|
#ifndef BISON_LOCATION_HH
|
||||||
# define BISON_LOCATION_HH
|
# define BISON_LOCATION_HH
|
||||||
...
|
...
|
||||||
#endif // !BISON_LOCATION_HH
|
#endif // !BISON_LOCATION_HH
|
||||||
|
|
||||||
The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
|
The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
|
||||||
case characters are converted to upper case, and series of
|
case characters are converted to upper case, and series of
|
||||||
@@ -49,10 +303,10 @@ Bison News
|
|||||||
|
|
||||||
With "bison -o lang++/parser.cc", "location.hh" would now include:
|
With "bison -o lang++/parser.cc", "location.hh" would now include:
|
||||||
|
|
||||||
#ifndef YY_LANG_LOCATION_HH
|
#ifndef YY_LANG_LOCATION_HH
|
||||||
# define YY_LANG_LOCATION_HH
|
# define YY_LANG_LOCATION_HH
|
||||||
...
|
...
|
||||||
#endif // !YY_LANG_LOCATION_HH
|
#endif // !YY_LANG_LOCATION_HH
|
||||||
|
|
||||||
*** C++ locations:
|
*** C++ locations:
|
||||||
|
|
||||||
@@ -93,7 +347,7 @@ Bison News
|
|||||||
This includes warnings with some compilers, unexpected behavior of tools
|
This includes warnings with some compilers, unexpected behavior of tools
|
||||||
such as diff, warning messages from the test suite itself, etc.
|
such as diff, warning messages from the test suite itself, etc.
|
||||||
|
|
||||||
*** The install-pdf target work properly:
|
*** The install-pdf target works properly:
|
||||||
|
|
||||||
Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
|
Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
|
||||||
halts in the middle of its course.
|
halts in the middle of its course.
|
||||||
@@ -283,33 +537,33 @@ Bison News
|
|||||||
to use it. If, for instance, your location structure has "first"
|
to use it. If, for instance, your location structure has "first"
|
||||||
and "last" members, instead of
|
and "last" members, instead of
|
||||||
|
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (N) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = (Rhs)[1].location.first; \
|
(Current).first = (Rhs)[1].location.first; \
|
||||||
(Current).last = (Rhs)[N].location.last; \
|
(Current).last = (Rhs)[N].location.last; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = (Current).last = (Rhs)[0].location.last; \
|
(Current).first = (Current).last = (Rhs)[0].location.last; \
|
||||||
} \
|
} \
|
||||||
while (false)
|
while (false)
|
||||||
|
|
||||||
use:
|
use:
|
||||||
|
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (N) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = YYRHSLOC (Rhs, 1).first; \
|
(Current).first = YYRHSLOC (Rhs, 1).first; \
|
||||||
(Current).last = YYRHSLOC (Rhs, N).last; \
|
(Current).last = YYRHSLOC (Rhs, N).last; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
|
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
|
||||||
} \
|
} \
|
||||||
while (false)
|
while (false)
|
||||||
|
|
||||||
** YYLLOC_DEFAULT in C++:
|
** YYLLOC_DEFAULT in C++:
|
||||||
|
|
||||||
@@ -928,26 +1182,26 @@ Bison News
|
|||||||
if the symbols have destructors. For instance:
|
if the symbols have destructors. For instance:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
|
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
|
||||||
| exp "+" exp
|
| exp "+" exp
|
||||||
;
|
;
|
||||||
|
|
||||||
will trigger a warning about $$ and $5 in the first rule, and $3 in
|
will trigger a warning about $$ and $5 in the first rule, and $3 in
|
||||||
the second ($1 is copied to $$ by the default rule). This example
|
the second ($1 is copied to $$ by the default rule). This example
|
||||||
most likely contains three errors, and could be rewritten as:
|
most likely contains three errors, and could be rewritten as:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp
|
exp: exp "?" exp ":" exp
|
||||||
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
|
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
|
||||||
| exp "+" exp
|
| exp "+" exp
|
||||||
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
|
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
However, if the original actions were really intended, memory leaks
|
However, if the original actions were really intended, memory leaks
|
||||||
and all, the warnings can be suppressed by letting Bison believe the
|
and all, the warnings can be suppressed by letting Bison believe the
|
||||||
values are used, e.g.:
|
values are used, e.g.:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
|
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
|
||||||
| exp "+" exp { $$ = $1; (void) $3; }
|
| exp "+" exp { $$ = $1; (void) $3; }
|
||||||
;
|
;
|
||||||
|
|
||||||
If there are mid-rule actions, the warning is issued if no action
|
If there are mid-rule actions, the warning is issued if no action
|
||||||
uses it. The following triggers no warning: $1 and $3 are used.
|
uses it. The following triggers no warning: $1 and $3 are used.
|
||||||
@@ -1162,6 +1416,33 @@ Bison News
|
|||||||
- "parsing stack overflow..." -> "parser stack overflow"
|
- "parsing stack overflow..." -> "parser stack overflow"
|
||||||
GLR parsers now report "parser stack overflow" as per the Bison manual.
|
GLR parsers now report "parser stack overflow" as per the Bison manual.
|
||||||
|
|
||||||
|
** %parse-param and %lex-param
|
||||||
|
The macros YYPARSE_PARAM and YYLEX_PARAM provide a means to pass
|
||||||
|
additional context to yyparse and yylex. They suffer from several
|
||||||
|
shortcomings:
|
||||||
|
|
||||||
|
- a single argument only can be added,
|
||||||
|
- their types are weak (void *),
|
||||||
|
- this context is not passed to ancillary functions such as yyerror,
|
||||||
|
- only yacc.c parsers support them.
|
||||||
|
|
||||||
|
The new %parse-param/%lex-param directives provide a more precise control.
|
||||||
|
For instance:
|
||||||
|
|
||||||
|
%parse-param {int *nastiness}
|
||||||
|
%lex-param {int *nastiness}
|
||||||
|
%parse-param {int *randomness}
|
||||||
|
|
||||||
|
results in the following signatures:
|
||||||
|
|
||||||
|
int yylex (int *nastiness);
|
||||||
|
int yyparse (int *nastiness, int *randomness);
|
||||||
|
|
||||||
|
or, if both %pure-parser and %locations are used:
|
||||||
|
|
||||||
|
int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
|
||||||
|
int yyparse (int *nastiness, int *randomness);
|
||||||
|
|
||||||
** Bison now warns if it detects conflicting outputs to the same file,
|
** Bison now warns if it detects conflicting outputs to the same file,
|
||||||
e.g., it generates a warning for "bison -d -o foo.h foo.y" since
|
e.g., it generates a warning for "bison -d -o foo.h foo.y" since
|
||||||
that command outputs both code and header to foo.h.
|
that command outputs both code and header to foo.h.
|
||||||
@@ -1191,16 +1472,16 @@ Bison News
|
|||||||
In agreement with POSIX and with other Yaccs, leaving a default
|
In agreement with POSIX and with other Yaccs, leaving a default
|
||||||
action is valid when $$ is untyped, and $1 typed:
|
action is valid when $$ is untyped, and $1 typed:
|
||||||
|
|
||||||
untyped: ... typed;
|
untyped: ... typed;
|
||||||
|
|
||||||
but the converse remains an error:
|
but the converse remains an error:
|
||||||
|
|
||||||
typed: ... untyped;
|
typed: ... untyped;
|
||||||
|
|
||||||
** Values of mid-rule actions
|
** Values of mid-rule actions
|
||||||
The following code:
|
The following code:
|
||||||
|
|
||||||
foo: { ... } { $$ = $1; } ...
|
foo: { ... } { $$ = $1; } ...
|
||||||
|
|
||||||
was incorrectly rejected: $1 is defined in the second mid-rule
|
was incorrectly rejected: $1 is defined in the second mid-rule
|
||||||
action, and is equal to the $$ of the first mid-rule action.
|
action, and is equal to the $$ of the first mid-rule action.
|
||||||
@@ -1282,9 +1563,9 @@ Bison News
|
|||||||
** Incorrect "Token not used"
|
** Incorrect "Token not used"
|
||||||
On a grammar such as
|
On a grammar such as
|
||||||
|
|
||||||
%token useless useful
|
%token useless useful
|
||||||
%%
|
%%
|
||||||
exp: '0' %prec useful;
|
exp: '0' %prec useful;
|
||||||
|
|
||||||
where a token was used to set the precedence of the last rule,
|
where a token was used to set the precedence of the last rule,
|
||||||
bison reported both "useful" and "useless" as useless tokens.
|
bison reported both "useful" and "useless" as useless tokens.
|
||||||
@@ -1303,9 +1584,9 @@ Bison News
|
|||||||
the user symbol is used in the reports, the graphs, and the verbose
|
the user symbol is used in the reports, the graphs, and the verbose
|
||||||
error messages instead of "$end", which remains being the default.
|
error messages instead of "$end", which remains being the default.
|
||||||
For instance
|
For instance
|
||||||
%token MYEOF 0
|
%token MYEOF 0
|
||||||
or
|
or
|
||||||
%token MYEOF 0 "end of file"
|
%token MYEOF 0 "end of file"
|
||||||
|
|
||||||
** Semantic parser
|
** Semantic parser
|
||||||
This old option, which has been broken for ages, is removed.
|
This old option, which has been broken for ages, is removed.
|
||||||
@@ -1341,9 +1622,9 @@ Bison News
|
|||||||
Previous versions don't complain when there is a type clash on
|
Previous versions don't complain when there is a type clash on
|
||||||
the default action if the rule has a mid-rule action, such as in:
|
the default action if the rule has a mid-rule action, such as in:
|
||||||
|
|
||||||
%type <foo> bar
|
%type <foo> bar
|
||||||
%%
|
%%
|
||||||
bar: '0' {} '0';
|
bar: '0' {} '0';
|
||||||
|
|
||||||
This is fixed.
|
This is fixed.
|
||||||
|
|
||||||
@@ -1640,9 +1921,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
|
LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
|
||||||
LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
|
LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
|
||||||
LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
|
LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
|
||||||
LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG
|
LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG YY
|
||||||
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
||||||
LocalWords: Automake TMPDIR LESSEQ
|
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
||||||
|
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
||||||
|
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
|
||||||
|
LocalWords: TOK
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
|
|||||||
+105
-73
@@ -1,5 +1,3 @@
|
|||||||
-*- outline -*-
|
|
||||||
|
|
||||||
This file attempts to describe the rules to use when hacking Bison.
|
This file attempts to describe the rules to use when hacking Bison.
|
||||||
Don't put this file into the distribution.
|
Don't put this file into the distribution.
|
||||||
|
|
||||||
@@ -37,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
|
||||||
|
|
||||||
@@ -60,8 +65,8 @@ tools we depend upon, including:
|
|||||||
- Rsync <http://samba.anu.edu.au/rsync/>
|
- Rsync <http://samba.anu.edu.au/rsync/>
|
||||||
- Tar <http://www.gnu.org/software/tar/>
|
- Tar <http://www.gnu.org/software/tar/>
|
||||||
|
|
||||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
|
||||||
Valgrind supports your architecture.
|
your architecture.
|
||||||
|
|
||||||
Bison is written using Bison grammars, so there are bootstrapping
|
Bison is written using Bison grammars, so there are bootstrapping
|
||||||
issues. The bootstrap script attempts to discover when the C code
|
issues. The bootstrap script attempts to discover when the C code
|
||||||
@@ -70,8 +75,9 @@ out-of-date version of the C code, but the process is not foolproof.
|
|||||||
Also, you may run into similar problems yourself if you modify Bison.
|
Also, you may run into similar problems yourself if you modify Bison.
|
||||||
|
|
||||||
Only building the initial full source tree will be a bit painful.
|
Only building the initial full source tree will be a bit painful.
|
||||||
Later, after synchronizing from the repository a plain `make' should
|
Later, after synchronizing from the repository a plain 'make' should
|
||||||
be sufficient.
|
be sufficient. Note, however, that when gnulib is updated, running
|
||||||
|
'./bootstrap' again might be needed.
|
||||||
|
|
||||||
** First checkout
|
** First checkout
|
||||||
|
|
||||||
@@ -118,14 +124,14 @@ explicitly by the user.
|
|||||||
|
|
||||||
*** Updating Bison
|
*** Updating Bison
|
||||||
|
|
||||||
If you pull a newer version of a branch, say via `git pull', you might
|
If you pull a newer version of a branch, say via "git pull", you might
|
||||||
import requests for updated submodules. A simple `git diff' will
|
import requests for updated submodules. A simple "git diff" will
|
||||||
reveal if the current version of the submodule (i.e., the actual
|
reveal if the current version of the submodule (i.e., the actual
|
||||||
contents of the gnulib directory) and the current request from the
|
contents of the gnulib directory) and the current request from the
|
||||||
subscriber (i.e., the reference of the version of gnulib that the
|
subscriber (i.e., the reference of the version of gnulib that the
|
||||||
Bison reporitory requests) differ. To upgrade the submodules (i.e.,
|
Bison repository requests) differ. To upgrade the submodules (i.e.,
|
||||||
to check out the version that is actually requested by the subscriber,
|
to check out the version that is actually requested by the subscriber,
|
||||||
run `git submodule update'.
|
run "git submodule update".
|
||||||
|
|
||||||
$ git pull
|
$ git pull
|
||||||
$ git submodule update
|
$ git submodule update
|
||||||
@@ -154,7 +160,7 @@ formal release, see the ChangeLog in the latest gnulib snapshot at:
|
|||||||
|
|
||||||
http://erislabs.net/ianb/projects/gnulib/
|
http://erislabs.net/ianb/projects/gnulib/
|
||||||
|
|
||||||
The autoconf files we use are currently:
|
The Autoconf files we use are currently:
|
||||||
|
|
||||||
m4/m4.m4
|
m4/m4.m4
|
||||||
lib/m4sugar/m4sugar.m4
|
lib/m4sugar/m4sugar.m4
|
||||||
@@ -169,6 +175,23 @@ decide whether to update.
|
|||||||
** make check
|
** make check
|
||||||
Use liberally.
|
Use liberally.
|
||||||
|
|
||||||
|
** make maintainer-check-valgrind
|
||||||
|
This target uses valgrind both to check bison, and the generated parsers.
|
||||||
|
|
||||||
|
This is not mature on Mac OS X. First, Valgrind does support the way bison
|
||||||
|
calls m4, so Valgrind cannot be used to check bison on Mac OS X.
|
||||||
|
|
||||||
|
Second, there are many errors that come from the platform itself, not from
|
||||||
|
bison. build-aux/darwin11.4.0.valgrind addresses some of them.
|
||||||
|
|
||||||
|
Third, valgrind issues warnings such as:
|
||||||
|
|
||||||
|
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
|
||||||
|
|
||||||
|
which cause the test to fail uselessly. It is hard to ignore these errors
|
||||||
|
with a major overhaul of the way instrumentation is performed in the test
|
||||||
|
suite. So currently, do not try to run valgrind on Mac OS X.
|
||||||
|
|
||||||
** Release checks
|
** Release checks
|
||||||
Try to run the test suite with more severe conditions before a
|
Try to run the test suite with more severe conditions before a
|
||||||
release:
|
release:
|
||||||
@@ -177,39 +200,46 @@ release:
|
|||||||
that 1. Bison compiles cleanly, 2. the parsers it produces compile
|
that 1. Bison compiles cleanly, 2. the parsers it produces compile
|
||||||
cleanly too.
|
cleanly too.
|
||||||
|
|
||||||
- Build with -DGNULIB_POSIXCHECK. It suggests gnulib modules that can
|
- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules
|
||||||
fix portability issues.
|
that can fix portability issues. See if you really want to pay
|
||||||
|
attention to its warnings; there's no need to obey blindly to it
|
||||||
|
(<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
|
||||||
|
|
||||||
- Check with `make syntax-check' if there are issues diagnosed by
|
- Check with "make syntax-check" if there are issues diagnosed by
|
||||||
gnulib.
|
gnulib.
|
||||||
|
|
||||||
- run `make maintainer-check' which:
|
- run "make maintainer-check" which:
|
||||||
- runs `valgrind -q bison' to run Bison under Valgrind.
|
- runs "valgrind -q bison" to run Bison under Valgrind.
|
||||||
- runs the parsers under Valgrind.
|
- runs the parsers under Valgrind.
|
||||||
- runs the test suite with G++ as C compiler...
|
- runs the test suite with G++ as C compiler...
|
||||||
|
|
||||||
- run `make maintainer-push-check', which runs `make maintainer-check'
|
- run "make maintainer-push-check", which runs "make maintainer-check"
|
||||||
while activating the push implementation and its pull interface wrappers
|
while activating the push implementation and its pull interface wrappers
|
||||||
in many test cases that were originally written to exercise only the
|
in many test cases that were originally written to exercise only the
|
||||||
pull implementation. This makes certain the push implementation can
|
pull implementation. This makes certain the push implementation can
|
||||||
perform every task the pull implementation can.
|
perform every task the pull implementation can.
|
||||||
|
|
||||||
- run `make maintainer-xml-check', which runs `make maintainer-check'
|
- run "make maintainer-xml-check", which runs "make maintainer-check"
|
||||||
while checking Bison's XML automaton report for every working grammar
|
while checking Bison's XML automaton report for every working grammar
|
||||||
passed to Bison in the test suite. The check just diffs the output of
|
passed to Bison in the test suite. The check just diffs the output of
|
||||||
Bison's included XSLT style sheets with the output of --report=all and
|
Bison's included XSLT style sheets with the output of --report=all and
|
||||||
--graph.
|
--graph.
|
||||||
|
|
||||||
- running `make maintainer-release-check' takes care of running
|
- running "make maintainer-release-check" takes care of running
|
||||||
maintainer-check, maintainer-push-check and maintainer-xml-check.
|
maintainer-check, maintainer-push-check and maintainer-xml-check.
|
||||||
|
|
||||||
- Change tests/atlocal/CFLAGS to add your preferred options. For
|
- Change tests/atlocal/CFLAGS to add your preferred options. For
|
||||||
instance, `-traditional' to check that the parsers are K&R. Note
|
instance, "-traditional" to check that the parsers are K&R. Note
|
||||||
that it does not make sense for glr.c, which should be ANSI,
|
that it does not make sense for glr.c, which should be ANSI, but
|
||||||
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
|
||||||
|
gnulib. In particular, be sure to read README-release.
|
||||||
|
|
||||||
** Update the submodules. See above.
|
** Update the submodules. See above.
|
||||||
|
|
||||||
@@ -225,7 +255,7 @@ This helps: grep -l '\<_(' *
|
|||||||
See above.
|
See above.
|
||||||
|
|
||||||
** Update the foreign files
|
** Update the foreign files
|
||||||
Running `./bootstrap' in the top level should update them all for you.
|
Running "./bootstrap" in the top level should update them all for you.
|
||||||
This covers PO files too. Sometimes a PO file contains problems that
|
This covers PO files too. Sometimes a PO file contains problems that
|
||||||
causes it to be rejected by recent Gettext releases; please report
|
causes it to be rejected by recent Gettext releases; please report
|
||||||
these to the Translation Project.
|
these to the Translation Project.
|
||||||
@@ -237,66 +267,56 @@ Bison sources.
|
|||||||
|
|
||||||
** Check copyright years.
|
** Check copyright years.
|
||||||
We update years in copyright statements throughout Bison once at the
|
We update years in copyright statements throughout Bison once at the
|
||||||
start of every year by running `make update-copyright'. However, before
|
start of every year by running "make update-copyright". However, before
|
||||||
a release, it's good to verify that it's actually been run. Besides the
|
a release, it's good to verify that it's actually been run. Besides the
|
||||||
copyright statement for each Bison file, check the copyright statements
|
copyright statement for each Bison file, check the copyright statements
|
||||||
that the skeletons insert into generated parsers, and check all
|
that the skeletons insert into generated parsers, and check all
|
||||||
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
||||||
|
|
||||||
** Update NEWS
|
** Update NEWS, commit and tag.
|
||||||
The version number, *and* the date of the release (including for
|
See do-release-commit-and-tag in README-release. For a while, we used
|
||||||
betas).
|
beta names such as "2.6_rc1". Now that we use gnulib in the release
|
||||||
|
procedure, we must use "2.5.90", which has the additional benefit of
|
||||||
|
being properly sorted in "git tag -l".
|
||||||
|
|
||||||
** Mention the release name in a commit message
|
** make alpha, beta, or stable
|
||||||
Should have an entry similar to `Version 2.3b.'.
|
See README-release.
|
||||||
|
|
||||||
** Tag the release
|
|
||||||
Before Bison will build with the right version number, you must tag
|
|
||||||
the release in git. Do this after all other changes. The command is
|
|
||||||
similar to:
|
|
||||||
|
|
||||||
git tag -a v2.3b
|
|
||||||
|
|
||||||
The commit message can be simply:
|
|
||||||
|
|
||||||
Bison 2.3b
|
|
||||||
|
|
||||||
** Push
|
|
||||||
Once `make distcheck' passes, push your changes and the tag.
|
|
||||||
`git push' without arguments will not push the tag.
|
|
||||||
|
|
||||||
** make alpha
|
|
||||||
FIXME: `make alpha' is not maintained and is broken. These
|
|
||||||
instructions need to be replaced or removed.
|
|
||||||
|
|
||||||
Running `make alpha' is absolutely perfect for beta releases: it makes
|
|
||||||
the tarballs, the xdeltas, and prepares (in /tmp/) a proto
|
|
||||||
announcement. It is so neat, that that's what I use anyway for
|
|
||||||
genuine releases, but adjusting things by hand (e.g., the urls in the
|
|
||||||
announcement file, the ChangeLog which is not needed etc.).
|
|
||||||
|
|
||||||
If it fails, you're on your own...
|
|
||||||
|
|
||||||
It requires GNU Make.
|
|
||||||
|
|
||||||
** Upload
|
** Upload
|
||||||
The generic GNU upload procedure is at:
|
There are two ways to upload the tarballs to the GNU servers: using
|
||||||
|
gnupload (from gnulib), or by hand. Obviously prefer the former. But
|
||||||
|
in either case, be sure to read the following paragraph.
|
||||||
|
|
||||||
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads
|
*** Setup
|
||||||
|
You need "gnupg".
|
||||||
|
|
||||||
Follow the instructions there to register your information so you're permitted
|
Make sure your public key has been uploaded at least to
|
||||||
to upload. Make sure your public key has been uploaded at least to
|
|
||||||
keys.gnupg.net. You can upload it with:
|
keys.gnupg.net. You can upload it with:
|
||||||
|
|
||||||
gpg --keyserver keys.gnupg.net --send-keys F125BDF3
|
gpg --keyserver keys.gnupg.net --send-keys F125BDF3
|
||||||
|
|
||||||
where F125BDF3 should be replaced with your key ID.
|
where F125BDF3 should be replaced with your key ID.
|
||||||
|
|
||||||
|
*** Using gnupload
|
||||||
|
You need "ncftp".
|
||||||
|
|
||||||
|
At the end "make stable" (or alpha/beta) will display the procedure to
|
||||||
|
run. Just copy and paste it in your shell.
|
||||||
|
|
||||||
|
*** By hand
|
||||||
|
|
||||||
|
The generic GNU upload procedure is at:
|
||||||
|
|
||||||
|
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads
|
||||||
|
|
||||||
|
Follow the instructions there to register your information so you're permitted
|
||||||
|
to upload.
|
||||||
|
|
||||||
Here's a brief reminder of how to roll the tarballs and upload them:
|
Here's a brief reminder of how to roll the tarballs and upload them:
|
||||||
|
|
||||||
*** make distcheck
|
*** make distcheck
|
||||||
*** gpg -b bison-2.3b.tar.gz
|
*** gpg -b bison-2.3b.tar.gz
|
||||||
*** In a file named `bison-2.3b.tar.gz.directive', type:
|
*** In a file named "bison-2.3b.tar.gz.directive", type:
|
||||||
|
|
||||||
version: 1.1
|
version: 1.1
|
||||||
directory: bison
|
directory: bison
|
||||||
@@ -352,7 +372,8 @@ function 'index', once for the table of contents); you can ignore this
|
|||||||
issue.
|
issue.
|
||||||
|
|
||||||
** Announce
|
** Announce
|
||||||
To generate a template announcement file:
|
The "make stable" (or alpha/beta) command just created a template,
|
||||||
|
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
|
||||||
|
|
||||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
||||||
|
|
||||||
@@ -362,25 +383,25 @@ replaced with your key ID.
|
|||||||
Complete/fix the announcement file. The generated list of recipients
|
Complete/fix the announcement file. The generated list of recipients
|
||||||
([email protected], [email protected], [email protected],
|
([email protected], [email protected], [email protected],
|
||||||
[email protected], and [email protected]) is
|
[email protected], and [email protected]) is
|
||||||
appropriate for a stable release or a ``serious beta''. For any other
|
appropriate for a stable release or a "serious beta". For any other
|
||||||
release, drop at least [email protected]. For an example of how to fill
|
release, drop at least [email protected]. For an example of how to
|
||||||
out the rest of the template, search the mailing list archives for the
|
fill out the rest of the template, search the mailing list archives
|
||||||
most recent release announcement.
|
for the most recent release announcement.
|
||||||
|
|
||||||
For a stable release, send the same announcement on the comp.compilers
|
For a stable release, send the same announcement on the comp.compilers
|
||||||
newsgroup by sending email to [email protected]. Do not make any Cc as
|
newsgroup by sending email to [email protected]. Do not make any Cc as
|
||||||
the moderator will throw away anything cross-posted or Cc'ed. It really
|
the moderator will throw away anything cross-posted or Cc'ed. It really
|
||||||
needs to be a separate message.
|
needs to be a separate message.
|
||||||
|
|
||||||
** Bump the version number
|
** Prepare NEWS
|
||||||
In configure.ac. Run `make'. So that developers don't accidentally add new
|
So that developers don't accidentally add new items to the old NEWS
|
||||||
items to the old NEWS entry, create a new empty NEWS entry something like:
|
entry, create a new empty entry in line 3 (without the two leading
|
||||||
|
spaces):
|
||||||
|
|
||||||
Changes in version ?.? (????-??-??):
|
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||||
|
|
||||||
Push these changes.
|
Push these changes.
|
||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
|
Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
|
||||||
@@ -399,3 +420,14 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
||||||
|
LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
|
||||||
|
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||||
|
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||||
|
LocalWords: symlinks vti html lt POSIX Cc'ed
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
mode: outline
|
||||||
|
fill-column: 76
|
||||||
|
End:
|
||||||
|
|||||||
+2
-2
@@ -25,8 +25,8 @@ LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
|
|||||||
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
||||||
technique is the standard one now.)
|
technique is the standard one now.)
|
||||||
|
|
||||||
paul rubin
|
paul rubin
|
||||||
free software foundation
|
free software foundation
|
||||||
|
|
||||||
|
|
||||||
[DeRemer-Pennello reference corrected by Paul Eggert <[email protected]>,
|
[DeRemer-Pennello reference corrected by Paul Eggert <[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: ...]
|
||||||
@@ -126,12 +121,6 @@ The code bw glr.c and yacc.c is really alike, we can certainly factor
|
|||||||
some parts.
|
some parts.
|
||||||
|
|
||||||
|
|
||||||
* Yacc.c: CPP Macros
|
|
||||||
|
|
||||||
Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
|
|
||||||
They should not: it is not documented. But if they need to, let's
|
|
||||||
find something clean (not like YYLSP_NEEDED...).
|
|
||||||
|
|
||||||
* Report
|
* Report
|
||||||
|
|
||||||
** Figures
|
** Figures
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2012-05-15.06; # UTC
|
scriptversion=2012-07-19.14; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
@@ -77,6 +77,33 @@ Running without arguments will suffice in most cases.
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# warnf_ FORMAT-STRING ARG1...
|
||||||
|
warnf_ ()
|
||||||
|
{
|
||||||
|
warnf_format_=$1
|
||||||
|
shift
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
case $* in
|
||||||
|
*$nl*) me_=$(printf "$me"|tr "$nl|" '??')
|
||||||
|
printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
|
||||||
|
*) printf "$me: $warnf_format_" "$@" ;;
|
||||||
|
esac >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# warn_ WORD1...
|
||||||
|
warn_ ()
|
||||||
|
{
|
||||||
|
# If IFS does not start with ' ', set it and emit the warning in a subshell.
|
||||||
|
case $IFS in
|
||||||
|
' '*) warnf_ '%s\n' "$*";;
|
||||||
|
*) (IFS=' '; warn_ "$@");;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# die WORD1...
|
||||||
|
die() { warn_ "$@"; exit 1; }
|
||||||
|
|
||||||
# Configuration.
|
# Configuration.
|
||||||
|
|
||||||
# Name of the Makefile.am
|
# Name of the Makefile.am
|
||||||
@@ -130,7 +157,8 @@ extract_package_name='
|
|||||||
p
|
p
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
package=$(sed -n "$extract_package_name" configure.ac) || exit
|
package=$(sed -n "$extract_package_name" configure.ac) \
|
||||||
|
|| die 'cannot find package name in configure.ac'
|
||||||
gnulib_name=lib$package
|
gnulib_name=lib$package
|
||||||
|
|
||||||
build_aux=build-aux
|
build_aux=build-aux
|
||||||
@@ -186,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
|
||||||
@@ -203,19 +233,15 @@ find_tool ()
|
|||||||
else
|
else
|
||||||
find_tool_error_prefix="\$$find_tool_envvar: "
|
find_tool_error_prefix="\$$find_tool_envvar: "
|
||||||
fi
|
fi
|
||||||
if test x"$find_tool_res" = x; then
|
test x"$find_tool_res" != x \
|
||||||
echo >&2 "$me: one of these is required: $find_tool_names"
|
|| die "one of these is required: $find_tool_names"
|
||||||
exit 1
|
($find_tool_res --version </dev/null) >/dev/null 2>&1 \
|
||||||
fi
|
|| die "${find_tool_error_prefix}cannot run $find_tool_res --version"
|
||||||
($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
|
|
||||||
echo >&2 "$me: ${find_tool_error_prefix}cannot run $find_tool_res --version"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
eval "$find_tool_envvar=\$find_tool_res"
|
eval "$find_tool_envvar=\$find_tool_res"
|
||||||
eval "export $find_tool_envvar"
|
eval "export $find_tool_envvar"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
|
# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6.
|
||||||
find_tool SHA1SUM sha1sum gsha1sum shasum
|
find_tool SHA1SUM sha1sum gsha1sum shasum
|
||||||
|
|
||||||
# Override the default configuration, if necessary.
|
# Override the default configuration, if necessary.
|
||||||
@@ -230,7 +256,6 @@ esac
|
|||||||
test -z "${gnulib_extra_files}" && \
|
test -z "${gnulib_extra_files}" && \
|
||||||
gnulib_extra_files="
|
gnulib_extra_files="
|
||||||
$build_aux/install-sh
|
$build_aux/install-sh
|
||||||
$build_aux/missing
|
|
||||||
$build_aux/mdate-sh
|
$build_aux/mdate-sh
|
||||||
$build_aux/texinfo.tex
|
$build_aux/texinfo.tex
|
||||||
$build_aux/depcomp
|
$build_aux/depcomp
|
||||||
@@ -270,21 +295,15 @@ do
|
|||||||
--no-git)
|
--no-git)
|
||||||
use_git=false;;
|
use_git=false;;
|
||||||
*)
|
*)
|
||||||
echo >&2 "$0: $option: unknown option"
|
die "$option: unknown option";;
|
||||||
exit 1;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if $use_git || test -d "$GNULIB_SRCDIR"; then
|
$use_git || test -d "$GNULIB_SRCDIR" \
|
||||||
:
|
|| die "Error: --no-git requires --gnulib-srcdir"
|
||||||
else
|
|
||||||
echo "$0: Error: --no-git requires --gnulib-srcdir" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
||||||
echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
|
die "Bootstrapping from a non-checked-out distribution is risky."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure that lines starting with ! sort last, per gitignore conventions
|
# Ensure that lines starting with ! sort last, per gitignore conventions
|
||||||
@@ -310,7 +329,7 @@ insert_sorted_if_absent() {
|
|||||||
echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|
echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|
||||||
|| { echo "$str" | sort_patterns - $file > $file.bak \
|
|| { echo "$str" | sort_patterns - $file > $file.bak \
|
||||||
&& mv $file.bak $file; } \
|
&& mv $file.bak $file; } \
|
||||||
|| exit 1
|
|| die "insert_sorted_if_absent $file $str: failed"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
||||||
@@ -334,11 +353,8 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
|
|||||||
>/dev/null && found_aux_dir=yes
|
>/dev/null && found_aux_dir=yes
|
||||||
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
|
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
|
||||||
>/dev/null && found_aux_dir=yes
|
>/dev/null && found_aux_dir=yes
|
||||||
if test $found_aux_dir = no; then
|
test $found_aux_dir = yes \
|
||||||
echo "$0: expected line not found in configure.ac. Add the following:" >&2
|
|| die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
|
||||||
echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If $build_aux doesn't exist, create it now, otherwise some bits
|
# If $build_aux doesn't exist, create it now, otherwise some bits
|
||||||
# below will malfunction. If creating it, also mark it as ignored.
|
# below will malfunction. If creating it, also mark it as ignored.
|
||||||
@@ -444,7 +460,7 @@ check_versions() {
|
|||||||
automake-ng|aclocal-ng)
|
automake-ng|aclocal-ng)
|
||||||
app=${app%-ng}
|
app=${app%-ng}
|
||||||
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
|
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
|
||||||
echo "$me: Error: '$app' not found or not from Automake-NG" >&2
|
warn_ "Error: '$app' not found or not from Automake-NG"
|
||||||
ret=1
|
ret=1
|
||||||
continue
|
continue
|
||||||
} ;;
|
} ;;
|
||||||
@@ -454,20 +470,21 @@ check_versions() {
|
|||||||
# so we have to rely on $? rather than get_version.
|
# so we have to rely on $? rather than get_version.
|
||||||
$app --version >/dev/null 2>&1
|
$app --version >/dev/null 2>&1
|
||||||
if [ 126 -le $? ]; then
|
if [ 126 -le $? ]; then
|
||||||
echo "$me: Error: '$app' not found" >&2
|
warn_ "Error: '$app' not found"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Require app to produce a new enough version string.
|
# Require app to produce a new enough version string.
|
||||||
inst_ver=$(get_version $app)
|
inst_ver=$(get_version $app)
|
||||||
if [ ! "$inst_ver" ]; then
|
if [ ! "$inst_ver" ]; then
|
||||||
echo "$me: Error: '$app' not found" >&2
|
warn_ "Error: '$app' not found"
|
||||||
ret=1
|
ret=1
|
||||||
else
|
else
|
||||||
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
||||||
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
||||||
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
|
warnf_ '%s\n' \
|
||||||
echo " '$app' version >= $req_ver is required" >&2
|
"Error: '$app' version == $inst_ver is too old" \
|
||||||
|
" '$app' version >= $req_ver is required"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -524,11 +541,10 @@ fi
|
|||||||
if ! printf "$buildreq" | check_versions; then
|
if ! printf "$buildreq" | check_versions; then
|
||||||
echo >&2
|
echo >&2
|
||||||
if test -f README-prereq; then
|
if test -f README-prereq; then
|
||||||
echo "$0: See README-prereq for how to get the prerequisite programs" >&2
|
die "See README-prereq for how to get the prerequisite programs"
|
||||||
else
|
else
|
||||||
echo "$0: Please install the prerequisite programs" >&2
|
die "Please install the prerequisite programs"
|
||||||
fi
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$0: Bootstrapping from checked-out $package sources..."
|
echo "$0: Bootstrapping from checked-out $package sources..."
|
||||||
@@ -739,11 +755,10 @@ symlink_to_dir()
|
|||||||
*)
|
*)
|
||||||
case /$dst/ in
|
case /$dst/ in
|
||||||
*//* | */../* | */./* | /*/*/*/*/*/)
|
*//* | */../* | */./* | /*/*/*/*/*/)
|
||||||
echo >&2 "$me: invalid symlink calculation: $src -> $dst"
|
die "invalid symlink calculation: $src -> $dst";;
|
||||||
exit 1;;
|
/*/*/*/*/) dot_dots=../../../;;
|
||||||
/*/*/*/*/) dot_dots=../../../;;
|
/*/*/*/) dot_dots=../../;;
|
||||||
/*/*/*/) dot_dots=../../;;
|
/*/*/) dot_dots=../;;
|
||||||
/*/*/) dot_dots=../;;
|
|
||||||
esac;;
|
esac;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -765,7 +780,7 @@ version_controlled_file() {
|
|||||||
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
|
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
|
||||||
grep '^/[^/]*/[0-9]' > /dev/null
|
grep '^/[^/]*/[0-9]' > /dev/null
|
||||||
else
|
else
|
||||||
echo "$me: no version control for $file?" >&2
|
warn_ "no version control for $file?"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -855,11 +870,12 @@ echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
|
|||||||
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
|
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
|
||||||
|
|
||||||
for file in $gnulib_files; do
|
for file in $gnulib_files; do
|
||||||
symlink_to_dir "$GNULIB_SRCDIR" $file || exit
|
symlink_to_dir "$GNULIB_SRCDIR" $file \
|
||||||
|
|| die "failed to symlink $file"
|
||||||
done
|
done
|
||||||
|
|
||||||
bootstrap_post_import_hook \
|
bootstrap_post_import_hook \
|
||||||
|| { echo >&2 "$me: bootstrap_post_import_hook failed"; exit 1; }
|
|| die "bootstrap_post_import_hook failed"
|
||||||
|
|
||||||
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
||||||
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
||||||
@@ -887,7 +903,7 @@ echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
|
|||||||
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
|
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
|
||||||
AUTOPOINT=true LIBTOOLIZE=true \
|
AUTOPOINT=true LIBTOOLIZE=true \
|
||||||
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
|
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
|
||||||
|| exit 1
|
|| die "autoreconf failed"
|
||||||
|
|
||||||
# Get some extra files from gnulib, overriding existing files.
|
# Get some extra files from gnulib, overriding existing files.
|
||||||
for file in $gnulib_extra_files; do
|
for file in $gnulib_extra_files; do
|
||||||
@@ -896,7 +912,8 @@ for file in $gnulib_extra_files; do
|
|||||||
build-aux/*) dst=$build_aux/${file#build-aux/};;
|
build-aux/*) dst=$build_aux/${file#build-aux/};;
|
||||||
*) dst=$file;;
|
*) dst=$file;;
|
||||||
esac
|
esac
|
||||||
symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
|
symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
|
||||||
|
|| die "failed to symlink $file"
|
||||||
done
|
done
|
||||||
|
|
||||||
if test $with_gettext = yes; then
|
if test $with_gettext = yes; then
|
||||||
@@ -912,7 +929,8 @@ if test $with_gettext = yes; then
|
|||||||
a\
|
a\
|
||||||
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
|
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
|
||||||
}
|
}
|
||||||
' po/Makevars.template >po/Makevars || exit 1
|
' po/Makevars.template >po/Makevars \
|
||||||
|
|| die 'cannot generate po/Makevars'
|
||||||
|
|
||||||
# If the 'gettext' module is in use, grab the latest Makefile.in.in.
|
# If the 'gettext' module is in use, grab the latest Makefile.in.in.
|
||||||
# If only the 'gettext-h' module is in use, assume autopoint already
|
# If only the 'gettext-h' module is in use, assume autopoint already
|
||||||
@@ -920,7 +938,8 @@ if test $with_gettext = yes; then
|
|||||||
case $gnulib_modules in
|
case $gnulib_modules in
|
||||||
*gettext-h*) ;;
|
*gettext-h*) ;;
|
||||||
*gettext*)
|
*gettext*)
|
||||||
cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1
|
cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
|
||||||
|
|| die "cannot create po/Makefile.in.in"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -936,7 +955,8 @@ if test $with_gettext = yes; then
|
|||||||
a\
|
a\
|
||||||
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
|
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
|
||||||
}
|
}
|
||||||
' po/Makevars.template >runtime-po/Makevars || exit 1
|
' po/Makevars.template >runtime-po/Makevars \
|
||||||
|
|| die 'cannot generate runtime-po/Makevars'
|
||||||
|
|
||||||
# Copy identical files from po to runtime-po.
|
# Copy identical files from po to runtime-po.
|
||||||
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
||||||
|
|||||||
+21
-8
@@ -17,17 +17,25 @@
|
|||||||
|
|
||||||
# gnulib modules used by this package.
|
# gnulib modules used by this package.
|
||||||
gnulib_modules='
|
gnulib_modules='
|
||||||
announce-gen argmatch assert calloc-posix close closeout config-h c-strcase
|
argmatch assert calloc-posix close closeout config-h c-strcase
|
||||||
configmake dirname error extensions fdl fopen-safer gendocs getopt-gnu
|
configmake
|
||||||
|
dirname
|
||||||
|
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 maintainer-makefile malloc-gnu mbschr mbsrchr
|
javaexec-script ldexpl malloc-gnu
|
||||||
mbswidth obstack perror progname
|
mbswidth obstack perror progname
|
||||||
quote quotearg realloc-posix
|
quote quotearg
|
||||||
|
readme-release
|
||||||
|
realloc-posix
|
||||||
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
|
||||||
@@ -37,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'\\\
|
||||||
@@ -67,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
|
||||||
}
|
}
|
||||||
@@ -76,6 +87,8 @@ bootstrap_epilogue()
|
|||||||
# Make sure we don't need src/bison, which usually doesn't exist at
|
# Make sure we don't need src/bison, which usually doesn't exist at
|
||||||
# the time of a bootstrap.
|
# the time of a bootstrap.
|
||||||
touch src/parse-gram.[ch]
|
touch src/parse-gram.[ch]
|
||||||
|
|
||||||
|
perl -pi -e "s/\@PACKAGE\@/$package/g" README-release
|
||||||
}
|
}
|
||||||
|
|
||||||
# Keep our bootstrap script in sync with gnulib's. If we ever need to
|
# Keep our bootstrap script in sync with gnulib's. If we ever need to
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
/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
|
||||||
/gendocs.sh
|
/gendocs.sh
|
||||||
/git-version-gen
|
/git-version-gen
|
||||||
/gitlog-to-changelog
|
/gitlog-to-changelog
|
||||||
|
/gnu-web-doc-update
|
||||||
|
/gnupload
|
||||||
/install-sh
|
/install-sh
|
||||||
/javacomp.sh.in
|
/javacomp.sh.in
|
||||||
/javaexec.sh.in
|
/javaexec.sh.in
|
||||||
/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,2 +0,0 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
|
||||||
EXTRA_DIST = prev-version.txt cross-options.pl update-b4-copyright
|
|
||||||
+37
-37
@@ -18,50 +18,50 @@ while (<STDIN>)
|
|||||||
\s # Spaces.
|
\s # Spaces.
|
||||||
/x)
|
/x)
|
||||||
{
|
{
|
||||||
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
||||||
$short = '' if ! defined $short;
|
$short = '' if ! defined $short;
|
||||||
$short = '-d' if $long eq '--defines' && ! $short;
|
$short = '-d' if $long eq '--defines' && ! $short;
|
||||||
my $dir = '%' . substr($long, 2);
|
my $dir = '%' . substr($long, 2);
|
||||||
if (index ($scanner, "\"$dir\"") < 0)
|
if (index ($scanner, "\"$dir\"") < 0)
|
||||||
{
|
{
|
||||||
if ($long eq '--force-define') { $dir = '%define'; }
|
if ($long eq '--force-define') { $dir = '%define'; }
|
||||||
else { $dir = ''; }
|
else { $dir = ''; }
|
||||||
}
|
}
|
||||||
if ($arg)
|
if ($arg)
|
||||||
{
|
{
|
||||||
# if $opt, $arg contains the closing ].
|
# if $opt, $arg contains the closing ].
|
||||||
substr ($arg, -1) = ''
|
substr ($arg, -1) = ''
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
$arg =~ s/^=//;
|
$arg =~ s/^=//;
|
||||||
$arg = lc ($arg);
|
$arg = lc ($arg);
|
||||||
my $dir_arg = $arg;
|
my $dir_arg = $arg;
|
||||||
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
|
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
|
||||||
# put each word in @var, to build @var{name}[=@var{value}], not
|
# put each word in @var, to build @var{name}[=@var{value}], not
|
||||||
# @var{name[=value]}].
|
# @var{name[=value]}].
|
||||||
$arg =~ s/(\w+)/\@var{$1}/g;
|
$arg =~ s/(\w+)/\@var{$1}/g;
|
||||||
my $long_arg = "=$arg";
|
my $long_arg = "=$arg";
|
||||||
if ($opt eq '[') {
|
if ($opt eq '[') {
|
||||||
$long_arg = "[$long_arg]";
|
$long_arg = "[$long_arg]";
|
||||||
$arg = "[$arg]";
|
$arg = "[$arg]";
|
||||||
}
|
}
|
||||||
# For arguments of directives: this only works if all arguments
|
# For arguments of directives: this only works if all arguments
|
||||||
# are strings and have the same syntax as on the command line.
|
# are strings and have the same syntax as on the command line.
|
||||||
if ($dir_arg eq 'name[=value]')
|
if ($dir_arg eq 'name[=value]')
|
||||||
{
|
{
|
||||||
$dir_arg = '@var{name} ["@var{value}"]';
|
$dir_arg = '@var{name} ["@var{value}"]';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dir_arg =~ s/(\w+)/\@var{"$1"}/g;
|
$dir_arg =~ s/(\w+)/\@var{"$1"}/g;
|
||||||
$dir_arg = '[' . $dir_arg . ']'
|
$dir_arg = '[' . $dir_arg . ']'
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
}
|
}
|
||||||
$long = "$long$long_arg";
|
$long = "$long$long_arg";
|
||||||
$short = "$short $arg" if $short && $short ne '-d';
|
$short = "$short $arg" if $short && $short ne '-d';
|
||||||
$dir = "$dir $dir_arg" if $dir;
|
$dir = "$dir $dir_arg" if $dir;
|
||||||
}
|
}
|
||||||
$option{$long} = $short;
|
$option{$long} = $short;
|
||||||
$directive{$long} = $dir;
|
$directive{$long} = $dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Copyright (C) 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/>.
|
||||||
|
|
||||||
|
# Valgrind suppression file for Bison.
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:?alloc*
|
||||||
|
...
|
||||||
|
fun:*ImageLoader*
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:?alloc*
|
||||||
|
...
|
||||||
|
fun:*dyld*
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:?alloc*
|
||||||
|
...
|
||||||
|
fun:__CFInitialize
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X I/O buffer
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
fun:__smakebuf
|
||||||
|
fun:__swsetup
|
||||||
|
fun:__sfvwrite
|
||||||
|
fun:fwrite
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X I/O buffer
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
fun:__smakebuf
|
||||||
|
fun:__swsetup
|
||||||
|
fun:__swbuf
|
||||||
|
fun:putchar
|
||||||
|
}
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
## Copyright (C) 2002, 2005-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,17 +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/>.
|
||||||
|
|
||||||
dist_pkgdata_DATA = README bison.m4 \
|
EXTRA_DIST += \
|
||||||
c-skel.m4 c.m4 yacc.c glr.c \
|
build-aux/cross-options.pl \
|
||||||
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
|
build-aux/darwin11.4.0.valgrind \
|
||||||
java-skel.m4 java.m4 lalr1.java
|
build-aux/move-if-change \
|
||||||
|
build-aux/prev-version.txt \
|
||||||
m4sugardir = $(pkgdatadir)/m4sugar
|
build-aux/update-b4-copyright
|
||||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/foreach.m4
|
|
||||||
|
|
||||||
xsltdir = $(pkgdatadir)/xslt
|
|
||||||
dist_xslt_DATA = \
|
|
||||||
xslt/bison.xsl \
|
|
||||||
xslt/xml2dot.xsl \
|
|
||||||
xslt/xml2text.xsl \
|
|
||||||
xslt/xml2xhtml.xsl
|
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../gnulib/build-aux/move-if-change
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/_Noreturn.h
|
||||||
|
/arg-nonnull.h
|
||||||
|
/c++defs.h
|
||||||
|
/warn-on-use.h
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# Customize maint.mk -*- makefile -*-
|
# Customize maint.mk -*- makefile -*-
|
||||||
|
|
||||||
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
# Copyright (C) 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
|
||||||
@@ -15,6 +14,17 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
|
# Update version, then recompile so that tests/bison --version be
|
||||||
|
# up-to-date, then compile our parser again with our up-to-date bison.
|
||||||
|
.PHONY: regen
|
||||||
|
regen: _version
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS)
|
||||||
|
touch $(srcdir)/src/parse-gram.y
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS)
|
||||||
|
|
||||||
|
# Used in maint.mk's web-manual rule
|
||||||
|
manual_title = The Yacc-compatible Parser Generator
|
||||||
|
|
||||||
# It's useful to run maintainer-*check* targets during development, but we
|
# It's useful to run maintainer-*check* targets during development, but we
|
||||||
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
||||||
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
|
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
|
||||||
@@ -22,26 +32,13 @@
|
|||||||
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
|
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
|
||||||
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
||||||
|
|
||||||
# Use alpha.gnu.org for alpha and beta releases.
|
|
||||||
# Use ftp.gnu.org for major releases.
|
|
||||||
gnu_ftp_host-alpha = alpha.gnu.org
|
|
||||||
gnu_ftp_host-beta = alpha.gnu.org
|
|
||||||
gnu_ftp_host-major = ftp.gnu.org
|
|
||||||
gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
|
|
||||||
|
|
||||||
url_dir_list = \
|
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
|
local-checks-to-skip = \
|
||||||
# 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 = \
|
|
||||||
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.
|
||||||
@@ -57,7 +54,8 @@ update-copyright: update-b4-copyright update-package-copyright-year
|
|||||||
update-copyright-env = \
|
update-copyright-env = \
|
||||||
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
|
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
|
||||||
|
|
||||||
exclude = $(foreach a,$(1),$(eval exclude_file_name_regexp--sc_$(a)))
|
exclude = \
|
||||||
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
$(call exclude, \
|
$(call exclude, \
|
||||||
bindtextdomain=^lib/main.c$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
program_name=^lib/main.c$$ \
|
program_name=^lib/main.c$$ \
|
||||||
@@ -65,9 +63,10 @@ $(call exclude, \
|
|||||||
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
||||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||||
prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \
|
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||||
|
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/ \
|
|
||||||
)
|
)
|
||||||
|
|||||||
+38
-15
@@ -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
|
||||||
@@ -87,7 +90,7 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
do
|
do
|
||||||
gl_WARN_ADD([$i], [WARN_CXXFLAGS])
|
gl_WARN_ADD([$i], [WARN_CXXFLAGS])
|
||||||
done
|
done
|
||||||
gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
||||||
[AC_LANG_PROGRAM([], [nullptr])])
|
[AC_LANG_PROGRAM([], [nullptr])])
|
||||||
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
||||||
# Warnings for the test suite only.
|
# Warnings for the test suite only.
|
||||||
@@ -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,24 +167,40 @@ 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
|
||||||
|
'':*) ;;
|
||||||
|
*:darwin*)
|
||||||
|
# See README-hacking.
|
||||||
|
# VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
|
||||||
|
VALGRIND=;;
|
||||||
|
*:*)
|
||||||
|
AC_SUBST([VALGRIND_PREBISON], [$VALGRIND -q]);;
|
||||||
|
esac
|
||||||
|
|
||||||
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
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
|
doc/yacc.1])
|
||||||
data/Makefile
|
|
||||||
etc/Makefile
|
|
||||||
examples/Makefile
|
|
||||||
examples/calc++/Makefile
|
|
||||||
lib/Makefile src/Makefile
|
|
||||||
doc/Makefile
|
|
||||||
doc/yacc.1])
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
Makefile.in
|
|
||||||
Makefile
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/Makefile.in
|
|
||||||
/Makefile
|
|
||||||
+339
-39
@@ -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
|
||||||
@@ -183,21 +186,6 @@ m4_define([b4_fatal_at],
|
|||||||
m4_exit(1)])
|
m4_exit(1)])
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
|
||||||
## Default values. ##
|
|
||||||
## ---------------- ##
|
|
||||||
|
|
||||||
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
|
||||||
m4_define_default([b4_pre_prologue], [])
|
|
||||||
m4_define_default([b4_post_prologue], [])
|
|
||||||
m4_define_default([b4_epilogue], [])
|
|
||||||
m4_define_default([b4_parse_param], [])
|
|
||||||
|
|
||||||
# The initial column and line.
|
|
||||||
m4_define_default([b4_location_initial_column], [1])
|
|
||||||
m4_define_default([b4_location_initial_line], [1])
|
|
||||||
|
|
||||||
|
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
## Data Types. ##
|
## Data Types. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
@@ -209,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. ##
|
||||||
@@ -220,8 +289,8 @@ m4_define([b4_ints_in],
|
|||||||
m4_define([b4_flag_if],
|
m4_define([b4_flag_if],
|
||||||
[m4_case(b4_$1_flag,
|
[m4_case(b4_$1_flag,
|
||||||
[0], [$3],
|
[0], [$3],
|
||||||
[1], [$2],
|
[1], [$2],
|
||||||
[m4_fatal([invalid $1 value: ]$1)])])
|
[m4_fatal([invalid $1 value: ]$1)])])
|
||||||
|
|
||||||
|
|
||||||
# b4_define_flag_if(FLAG)
|
# b4_define_flag_if(FLAG)
|
||||||
@@ -233,9 +302,9 @@ m4_define([b4_define_flag_if],
|
|||||||
|
|
||||||
# _b4_define_flag_if($1, $2, FLAG)
|
# _b4_define_flag_if($1, $2, FLAG)
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# This macro works around the impossibility to define macros
|
# Work around the impossibility to define macros inside macros,
|
||||||
# inside macros, because issuing `[$1]' is not possible in M4 :(.
|
# because issuing `[$1]' is not possible in M4. GNU M4 should provide
|
||||||
# This sucks hard, GNU M4 should really provide M5 like $$1.
|
# $$1 a la M5/TeX.
|
||||||
m4_define([_b4_define_flag_if],
|
m4_define([_b4_define_flag_if],
|
||||||
[m4_if([$1$2], $[1]$[2], [],
|
[m4_if([$1$2], $[1]$[2], [],
|
||||||
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
||||||
@@ -246,17 +315,168 @@ m4_define([b4_$3_if],
|
|||||||
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# 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([nondeterministic]) # Whether conflicts should be handled.
|
||||||
b4_define_flag_if([locations]) # Whether locations are tracked.
|
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## --------- ##
|
||||||
## Assigning token numbers. ##
|
## 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]))])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
@@ -274,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])])
|
||||||
@@ -364,7 +584,6 @@ m4_popdef([b4_end])dnl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## b4_percent_define_*. ##
|
## b4_percent_define_*. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
@@ -394,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,
|
||||||
@@ -443,8 +661,14 @@ 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])
|
||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
@@ -469,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,
|
||||||
@@ -487,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
|
||||||
@@ -558,7 +797,45 @@ m4_popdef([b4_macro_name])])
|
|||||||
m4_define([b4_percent_code_ifdef],
|
m4_define([b4_percent_code_ifdef],
|
||||||
[m4_ifdef([b4_percent_code(]$1[)],
|
[m4_ifdef([b4_percent_code(]$1[)],
|
||||||
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
|
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
|
||||||
[$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])])
|
||||||
|
|
||||||
|
|
||||||
## ----------------------------------------------------------- ##
|
## ----------------------------------------------------------- ##
|
||||||
@@ -576,3 +853,26 @@ m4_wrap_lifo([
|
|||||||
b4_check_user_names_wrap([[define]], [[variable]])
|
b4_check_user_names_wrap([[define]], [[variable]])
|
||||||
b4_check_user_names_wrap([[code]], [[qualifier]])
|
b4_check_user_names_wrap([[code]], [[qualifier]])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
||||||
|
m4_define_default([b4_pre_prologue], [])
|
||||||
|
m4_define_default([b4_post_prologue], [])
|
||||||
|
m4_define_default([b4_epilogue], [])
|
||||||
|
m4_define_default([b4_parse_param], [])
|
||||||
|
|
||||||
|
# The initial column and line.
|
||||||
|
m4_define_default([b4_location_initial_column], [1])
|
||||||
|
m4_define_default([b4_location_initial_line], [1])
|
||||||
|
|
||||||
|
# Sanity checks.
|
||||||
|
b4_percent_define_ifdef([api.prefix],
|
||||||
|
[m4_ifdef([b4_prefix],
|
||||||
|
[b4_complain_at(b4_percent_define_get_loc([api.prefix]),
|
||||||
|
[['%s' and '%s' cannot be used together]],
|
||||||
|
[%name-prefix],
|
||||||
|
[%define api.prefix])])])
|
||||||
|
|||||||
+308
-25
@@ -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()
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -153,24 +407,53 @@ m4_define([b4_parse_param_decl_1],
|
|||||||
# Extra initialisations of the constructor.
|
# Extra initialisations of the constructor.
|
||||||
m4_define([b4_parse_param_cons],
|
m4_define([b4_parse_param_cons],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[
|
[
|
||||||
b4_cc_constructor_calls(b4_parse_param)])])
|
b4_cc_constructor_calls(b4_parse_param)])])
|
||||||
m4_define([b4_cc_constructor_calls],
|
m4_define([b4_cc_constructor_calls],
|
||||||
[m4_map_sep([b4_cc_constructor_call], [,
|
[m4_map_sep([b4_cc_constructor_call], [,
|
||||||
], [$@])])
|
], [$@])])
|
||||||
m4_define([b4_cc_constructor_call],
|
m4_define([b4_cc_constructor_call],
|
||||||
[$2 ($2_yyarg)])
|
[$2 ($2_yyarg)])
|
||||||
|
|
||||||
# b4_parse_param_vars
|
# b4_parse_param_vars
|
||||||
# -------------------
|
# -------------------
|
||||||
# Extra instance variables.
|
# Extra instance variables.
|
||||||
m4_define([b4_parse_param_vars],
|
m4_define([b4_parse_param_vars],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[
|
[
|
||||||
/* User arguments. */
|
/* User arguments. */
|
||||||
b4_cc_var_decls(b4_parse_param)])])
|
b4_cc_var_decls(b4_parse_param)])])
|
||||||
m4_define([b4_cc_var_decls],
|
m4_define([b4_cc_var_decls],
|
||||||
[m4_map_sep([b4_cc_var_decl], [
|
[m4_map_sep([b4_cc_var_decl], [
|
||||||
], [$@])])
|
], [$@])])
|
||||||
m4_define([b4_cc_var_decl],
|
m4_define([b4_cc_var_decl],
|
||||||
[ $1;])
|
[ $1;])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------##
|
||||||
|
## Values. ##
|
||||||
|
## ---------##
|
||||||
|
|
||||||
|
# b4_yylloc_default_define
|
||||||
|
# ------------------------
|
||||||
|
# Define YYLLOC_DEFAULT.
|
||||||
|
m4_define([b4_yylloc_default_define],
|
||||||
|
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||||
|
If N is 0, then set CURRENT to the empty location which ends
|
||||||
|
the previous symbol: RHS[0] (always defined). */
|
||||||
|
|
||||||
|
# ifndef YYLLOC_DEFAULT
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
do \
|
||||||
|
if (N) \
|
||||||
|
{ \
|
||||||
|
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
||||||
|
(Current).end = YYRHSLOC (Rhs, N).end; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||||
|
} \
|
||||||
|
while (/*CONSTCOND*/ false)
|
||||||
|
# endif
|
||||||
|
]])
|
||||||
|
|||||||
@@ -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
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -77,9 +100,6 @@ m4_define([b4_identification],
|
|||||||
|
|
||||||
/* Pull parsers. */
|
/* Pull parsers. */
|
||||||
#define YYPULL ]b4_pull_flag])[
|
#define YYPULL ]b4_pull_flag])[
|
||||||
|
|
||||||
/* Using locations. */
|
|
||||||
#define YYLSP_NEEDED ]b4_locations_flag[
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
@@ -87,11 +107,24 @@ m4_define([b4_identification],
|
|||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# If the %union is not named, its name is YYSTYPE.
|
# b4_api_prefix, b4_api_PREFIX
|
||||||
m4_define_default([b4_union_name], [YYSTYPE])
|
# ----------------------------
|
||||||
|
# Corresponds to %define api.prefix
|
||||||
|
b4_percent_define_default([[api.prefix]], [[yy]])
|
||||||
|
m4_define([b4_api_prefix],
|
||||||
|
[b4_percent_define_get([[api.prefix]])])
|
||||||
|
m4_define([b4_api_PREFIX],
|
||||||
|
[m4_toupper(b4_api_prefix)])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_prefix
|
||||||
|
# ---------
|
||||||
|
# If the %name-prefix is not given, it is api.prefix.
|
||||||
|
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||||
|
|
||||||
|
# If the %union is not named, its name is YYSTYPE.
|
||||||
|
m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])
|
||||||
|
|
||||||
# If the %name-prefix is not given, it is yy.
|
|
||||||
m4_define_default([b4_prefix], [yy])
|
|
||||||
|
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
## Pure/impure interfaces. ##
|
## Pure/impure interfaces. ##
|
||||||
@@ -124,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
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -150,7 +185,7 @@ m4_define([b4_int_type],
|
|||||||
|
|
||||||
m4_eval([0 <= $1]), [1], [unsigned int],
|
m4_eval([0 <= $1]), [1], [unsigned int],
|
||||||
|
|
||||||
[int])])
|
[int])])
|
||||||
|
|
||||||
|
|
||||||
# b4_int_type_for(NAME)
|
# b4_int_type_for(NAME)
|
||||||
@@ -199,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 YYTOKENTYPE
|
# define ]b4_api_PREFIX[TOKENTYPE
|
||||||
# define YYTOKENTYPE
|
/* 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 yytokentype {
|
]m4_join([,
|
||||||
m4_map_sep([ b4_token_enum], [,
|
],
|
||||||
],
|
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]))])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -307,7 +362,7 @@ $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
|
|||||||
m4_define([b4_c_ansi_formals],
|
m4_define([b4_c_ansi_formals],
|
||||||
[m4_if([$#], [0], [void],
|
[m4_if([$#], [0], [void],
|
||||||
[$#$1], [1], [void],
|
[$#$1], [1], [void],
|
||||||
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
||||||
|
|
||||||
m4_define([b4_c_ansi_formal],
|
m4_define([b4_c_ansi_formal],
|
||||||
[$1])
|
[$1])
|
||||||
@@ -328,9 +383,9 @@ m4_define([b4_c_knr_formal_name],
|
|||||||
# Output the K&R argument declarations.
|
# Output the K&R argument declarations.
|
||||||
m4_define([b4_c_knr_formal_decls],
|
m4_define([b4_c_knr_formal_decls],
|
||||||
[m4_map_sep([b4_c_knr_formal_decl],
|
[m4_map_sep([b4_c_knr_formal_decl],
|
||||||
[
|
[
|
||||||
],
|
],
|
||||||
[$@])])
|
[$@])])
|
||||||
|
|
||||||
m4_define([b4_c_knr_formal_decl],
|
m4_define([b4_c_knr_formal_decl],
|
||||||
[ $1;])
|
[ $1;])
|
||||||
@@ -346,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 ();
|
||||||
@@ -405,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)
|
||||||
@@ -444,20 +492,16 @@ 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
|
||||||
])
|
])
|
||||||
@@ -477,30 +521,28 @@ m4_define_default([b4_yy_symbol_print_generate],
|
|||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
]$1([yy_symbol_value_print],
|
]$1([yy_symbol_value_print],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,9 +553,9 @@ b4_parse_param_use[]dnl
|
|||||||
|
|
||||||
]$1([yy_symbol_print],
|
]$1([yy_symbol_print],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
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]))[
|
||||||
{
|
{
|
||||||
@@ -530,3 +572,102 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
|
|||||||
YYFPRINTF (yyoutput, ")");
|
YYFPRINTF (yyoutput, ")");
|
||||||
}]dnl
|
}]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Declarations. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
# b4_declare_yylstype
|
||||||
|
# -------------------
|
||||||
|
# Declarations that might either go into the header (if --defines) or
|
||||||
|
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
|
||||||
|
m4_define([b4_declare_yylstype],
|
||||||
|
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||||
|
]m4_ifdef([b4_stype],
|
||||||
|
[[typedef union ]b4_union_name[
|
||||||
|
{
|
||||||
|
]b4_user_stype[
|
||||||
|
} ]b4_api_PREFIX[STYPE;
|
||||||
|
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]],
|
||||||
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
|
[[typedef int ]b4_api_PREFIX[STYPE;
|
||||||
|
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]])])[
|
||||||
|
# define ]b4_api_prefix[stype ]b4_api_PREFIX[STYPE /* obsolescent; will be withdrawn */
|
||||||
|
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||||
|
#endif]b4_locations_if([[
|
||||||
|
|
||||||
|
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||||
|
typedef struct ]b4_api_PREFIX[LTYPE
|
||||||
|
{
|
||||||
|
int first_line;
|
||||||
|
int first_column;
|
||||||
|
int last_line;
|
||||||
|
int last_column;
|
||||||
|
} ]b4_api_PREFIX[LTYPE;
|
||||||
|
# define ]b4_api_prefix[ltype ]b4_api_PREFIX[LTYPE /* obsolescent; will be withdrawn */
|
||||||
|
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
||||||
|
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
||||||
|
#endif]])
|
||||||
|
|
||||||
|
b4_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval;
|
||||||
|
]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_YYDEBUG_define
|
||||||
|
# ------------------
|
||||||
|
m4_define([b4_YYDEBUG_define],
|
||||||
|
[[/* Enabling traces. */
|
||||||
|
]m4_if(b4_api_prefix, [yy],
|
||||||
|
[[#ifndef YYDEBUG
|
||||||
|
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
|
||||||
|
#endif]],
|
||||||
|
[[#ifndef ]b4_api_PREFIX[DEBUG
|
||||||
|
# if defined YYDEBUG
|
||||||
|
#if YYDEBUG
|
||||||
|
# define ]b4_api_PREFIX[DEBUG 1
|
||||||
|
# else
|
||||||
|
# define ]b4_api_PREFIX[DEBUG 0
|
||||||
|
# endif
|
||||||
|
# else /* ! defined YYDEBUG */
|
||||||
|
# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[
|
||||||
|
# endif /* ! defined ]b4_api_PREFIX[DEBUG */
|
||||||
|
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_declare_yydebug
|
||||||
|
# ------------------
|
||||||
|
m4_define([b4_declare_yydebug],
|
||||||
|
[b4_YYDEBUG_define[
|
||||||
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
extern int ]b4_prefix[debug;
|
||||||
|
#endif][]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_yylloc_default_define
|
||||||
|
# ------------------------
|
||||||
|
# Define YYLLOC_DEFAULT.
|
||||||
|
m4_define([b4_yylloc_default_define],
|
||||||
|
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||||
|
If N is 0, then set CURRENT to the empty location which ends
|
||||||
|
the previous symbol: RHS[0] (always defined). */
|
||||||
|
|
||||||
|
#ifndef YYLLOC_DEFAULT
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
do \
|
||||||
|
if (YYID (N)) \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||||
|
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||||
|
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||||
|
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = (Current).last_line = \
|
||||||
|
YYRHSLOC (Rhs, 0).last_line; \
|
||||||
|
(Current).first_column = (Current).last_column = \
|
||||||
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
|
} \
|
||||||
|
while (YYID (0))
|
||||||
|
#endif
|
||||||
|
]])
|
||||||
|
|||||||
+276
-338
File diff suppressed because it is too large
Load Diff
+38
-92
@@ -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.
|
||||||
@@ -78,9 +76,9 @@ m4_define([b4_yy_symbol_print_generate],
|
|||||||
[static void],
|
[static void],
|
||||||
[[FILE *], []],
|
[[FILE *], []],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],
|
||||||
[yyvaluep]],
|
[yyvaluep]],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param)[
|
b4_parse_param)[
|
||||||
{
|
{
|
||||||
@@ -90,19 +88,22 @@ m4_define([b4_yy_symbol_print_generate],
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
# Declare yyerror.
|
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
|
||||||
|
# and declaration of yyerror.
|
||||||
m4_append([b4_post_prologue],
|
m4_append([b4_post_prologue],
|
||||||
[b4_syncline([@oline@], [@ofile@])
|
[b4_syncline([@oline@], [@ofile@])[
|
||||||
|
]b4_yylloc_default_define[
|
||||||
b4_c_ansi_function_decl([yyerror],
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
||||||
|
]b4_c_ansi_function_decl([yyerror],
|
||||||
[static void],
|
[static void],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])])
|
[[const char* msg], [msg]])])
|
||||||
|
|
||||||
|
|
||||||
# Define yyerror.
|
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||||
|
# functions etc.).
|
||||||
m4_append([b4_epilogue],
|
m4_append([b4_epilogue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])[
|
||||||
/*------------------.
|
/*------------------.
|
||||||
@@ -111,7 +112,7 @@ m4_append([b4_epilogue],
|
|||||||
|
|
||||||
]b4_c_ansi_function_def([yyerror],
|
]b4_c_ansi_function_def([yyerror],
|
||||||
[static void],
|
[static void],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])[
|
[[const char* msg], [msg]])[
|
||||||
@@ -127,9 +128,8 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
[ /// Build a parser object.
|
[ /// Build a parser object.
|
||||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||||
:])[
|
:])[
|
||||||
#if YYDEBUG
|
#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[
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
return ::yyparse (*this]b4_user_args[);
|
return ::yyparse (*this]b4_user_args[);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/*--------------------.
|
/*--------------------.
|
||||||
| Print this symbol. |
|
| Print this symbol. |
|
||||||
`--------------------*/
|
`--------------------*/
|
||||||
@@ -161,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;
|
||||||
}
|
}
|
||||||
@@ -196,29 +196,28 @@ 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[
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
# Let glr.c believe that the user arguments include the parser itself.
|
# Let glr.c believe that the user arguments include the parser itself.
|
||||||
m4_ifset([b4_parse_param],
|
m4_ifset([b4_parse_param],
|
||||||
[m4_pushdef([b4_parse_param],
|
[m4_pushdef([b4_parse_param],
|
||||||
m4_dquote([[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]],]
|
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
|
||||||
m4_defn([b4_parse_param])))],
|
m4_defn([b4_parse_param]))],
|
||||||
[m4_pushdef([b4_parse_param],
|
[m4_pushdef([b4_parse_param],
|
||||||
[[[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]]]])
|
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
|
||||||
])
|
])
|
||||||
m4_include(b4_pkgdatadir/[glr.c])
|
m4_include(b4_pkgdatadir/[glr.c])
|
||||||
m4_popdef([b4_parse_param])
|
m4_popdef([b4_parse_param])
|
||||||
@@ -226,75 +225,28 @@ 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. */
|
||||||
|
|
||||||
#ifndef PARSER_HEADER_H
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
# define PARSER_HEADER_H
|
|
||||||
|
|
||||||
]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]], [],
|
||||||
[[#include "location.hh"]])[
|
[[#include "location.hh"]])[
|
||||||
|
|
||||||
/* Using locations. */
|
]b4_YYDEBUG_define[
|
||||||
#define YYLSP_NEEDED ]b4_locations_flag[
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# define YYDEBUG ]b4_debug_flag[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
||||||
If N is 0, then set CURRENT to the empty location which ends
|
|
||||||
the previous symbol: RHS[0] (always defined). */
|
|
||||||
|
|
||||||
#ifndef YYLLOC_DEFAULT
|
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
||||||
do \
|
|
||||||
if (N) \
|
|
||||||
{ \
|
|
||||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
|
||||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
|
||||||
} \
|
|
||||||
while (/*CONSTCOND*/ 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
class ]b4_parser_class_name[
|
class ]b4_parser_class_name[
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Symbol semantic values.
|
]b4_public_types_declare[
|
||||||
#ifndef YYSTYPE
|
|
||||||
]m4_ifdef([b4_stype],
|
|
||||||
[ union semantic_type
|
|
||||||
{
|
|
||||||
b4_user_stype
|
|
||||||
};],
|
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
|
||||||
[[ typedef int semantic_type;]],
|
|
||||||
[[ typedef YYSTYPE semantic_type;]])])[
|
|
||||||
#else
|
|
||||||
typedef YYSTYPE 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[);
|
||||||
@@ -316,16 +268,13 @@ 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 YYDEBUG
|
# if ]b4_api_PREFIX[DEBUG
|
||||||
public:
|
public:
|
||||||
/// \brief Report a symbol value on the debug stream.
|
/// \brief Report a symbol value on the debug stream.
|
||||||
/// \param yytype The token type.
|
/// \param yytype The token type.
|
||||||
@@ -343,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
|
||||||
|
|
||||||
@@ -352,18 +300,16 @@ 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 YYSTYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
# define YYSTYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
||||||
#endif
|
#endif
|
||||||
#ifndef YYLTYPE
|
#ifndef ]b4_api_PREFIX[LTYPE
|
||||||
# define YYLTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
|
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
|
]b4_percent_code_get([[provides]])[
|
||||||
]b4_percent_code_get([[provides]])[]dnl
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
|
]m4_divert_pop(0)
|
||||||
[#endif /* ! defined PARSER_HEADER_H */]
|
|
||||||
m4_divert_pop(0)
|
|
||||||
|
|||||||
+72
-44
@@ -29,7 +29,7 @@ m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Join two lists with a comma if necessary.
|
# Join two lists with a comma if necessary.
|
||||||
m4_define([b4_list2],
|
m4_define([b4_list2],
|
||||||
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
||||||
@@ -37,8 +37,8 @@ m4_define([b4_list2],
|
|||||||
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
||||||
# otherwise NOT.
|
# otherwise NOT.
|
||||||
m4_define([b4_percent_define_get3],
|
m4_define([b4_percent_define_get3],
|
||||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||||
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ m4_define([b4_identification],
|
|||||||
m4_define([b4_int_type],
|
m4_define([b4_int_type],
|
||||||
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
||||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||||
[int])])
|
[int])])
|
||||||
|
|
||||||
# b4_int_type_for(NAME)
|
# b4_int_type_for(NAME)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
@@ -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,21 +246,21 @@ 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],
|
||||||
[b4_remove_comma([$1],
|
[b4_remove_comma([$1],
|
||||||
b4_param_decls(b4_lex_param))],
|
b4_param_decls(b4_lex_param))],
|
||||||
[$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($@)])
|
||||||
@@ -245,21 +273,21 @@ m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
|||||||
m4_define([b4_parse_param_decl],
|
m4_define([b4_parse_param_decl],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[b4_remove_comma([$1],
|
[b4_remove_comma([$1],
|
||||||
b4_param_decls(b4_parse_param))],
|
b4_param_decls(b4_parse_param))],
|
||||||
[$1])])
|
[$1])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 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],
|
||||||
[b4_remove_comma([$1],
|
[b4_remove_comma([$1],
|
||||||
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])
|
||||||
|
|
||||||
|
|
||||||
@@ -269,13 +297,13 @@ m4_define([b4_param_call], [, $2])
|
|||||||
# Extra initialisations of the constructor.
|
# Extra initialisations of the constructor.
|
||||||
m4_define([b4_parse_param_cons],
|
m4_define([b4_parse_param_cons],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[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;
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -284,15 +312,15 @@ m4_define([b4_constructor_call],
|
|||||||
# Extra instance variables.
|
# Extra instance variables.
|
||||||
m4_define([b4_parse_param_vars],
|
m4_define([b4_parse_param_vars],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[
|
[
|
||||||
/* User arguments. */
|
/* User arguments. */
|
||||||
b4_var_decls(b4_parse_param)])])
|
b4_var_decls(b4_parse_param)])])
|
||||||
|
|
||||||
m4_define([b4_var_decls],
|
m4_define([b4_var_decls],
|
||||||
[m4_map_sep([b4_var_decl], [
|
[m4_map_sep([b4_var_decl], [
|
||||||
], [$@])])
|
], [$@])])
|
||||||
m4_define([b4_var_decl],
|
m4_define([b4_var_decl],
|
||||||
[ protected final $1;])
|
[ protected final $1;])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -300,4 +328,4 @@ m4_define([b4_var_decl],
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
# Expand to either an empty string or "throws THROWS".
|
# Expand to either an empty string or "throws THROWS".
|
||||||
m4_define([b4_maybe_throws],
|
m4_define([b4_maybe_throws],
|
||||||
[m4_ifval($1, [throws $1])])
|
[m4_ifval($1, [throws $1])])
|
||||||
|
|||||||
+545
-581
File diff suppressed because it is too large
Load Diff
+172
-218
@@ -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)
|
||||||
@@ -230,24 +272,24 @@ b4_lexer_if([[
|
|||||||
public int height = -1;
|
public int height = -1;
|
||||||
|
|
||||||
public final void push (int state, ]b4_yystype[ value]dnl
|
public final void push (int state, ]b4_yystype[ value]dnl
|
||||||
b4_locations_if([, ]b4_location_type[ loc])[) {
|
b4_locations_if([, ]b4_location_type[ loc])[) {
|
||||||
height++;
|
height++;
|
||||||
if (size == height)
|
if (size == height)
|
||||||
{
|
{
|
||||||
int[] newStateStack = new int[size * 2];
|
int[] newStateStack = new int[size * 2];
|
||||||
System.arraycopy (stateStack, 0, newStateStack, 0, height);
|
System.arraycopy (stateStack, 0, newStateStack, 0, height);
|
||||||
stateStack = newStateStack;
|
stateStack = newStateStack;
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
|
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
|
||||||
System.arraycopy (locStack, 0, newLocStack, 0, height);
|
System.arraycopy (locStack, 0, newLocStack, 0, height);
|
||||||
locStack = newLocStack;]])
|
locStack = newLocStack;]])
|
||||||
|
|
||||||
b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
|
b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
|
||||||
System.arraycopy (valueStack, 0, newValueStack, 0, height);
|
System.arraycopy (valueStack, 0, newValueStack, 0, height);
|
||||||
valueStack = newValueStack;
|
valueStack = newValueStack;
|
||||||
|
|
||||||
size *= 2;
|
size *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
stateStack[height] = state;
|
stateStack[height] = state;
|
||||||
]b4_locations_if([[locStack[height] = loc;]])[
|
]b4_locations_if([[locStack[height] = loc;]])[
|
||||||
@@ -261,7 +303,7 @@ b4_lexer_if([[
|
|||||||
public final void pop (int num) {
|
public final void pop (int num) {
|
||||||
// Avoid memory leaks... garbage collection is a white lie!
|
// Avoid memory leaks... garbage collection is a white lie!
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
|
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
|
||||||
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
|
||||||
}
|
}
|
||||||
height -= num;
|
height -= num;
|
||||||
@@ -286,8 +328,8 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
for (int i = 0; i <= height; i++)
|
for (int i = 0; i <= height; i++)
|
||||||
{
|
{
|
||||||
out.print (' ');
|
out.print (' ');
|
||||||
out.print (stateStack[i]);
|
out.print (stateStack[i]);
|
||||||
}
|
}
|
||||||
out.println ();
|
out.println ();
|
||||||
}
|
}
|
||||||
@@ -348,8 +390,8 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
switch (yyn)
|
switch (yyn)
|
||||||
{
|
{
|
||||||
]b4_user_actions[
|
]b4_user_actions[
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
||||||
@@ -361,7 +403,7 @@ b4_lexer_if([[
|
|||||||
yyn = yyr1_[yyn];
|
yyn = yyr1_[yyn];
|
||||||
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
|
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
|
||||||
if (0 <= yystate && yystate <= yylast_
|
if (0 <= yystate && yystate <= yylast_
|
||||||
&& yycheck_[yystate] == yystack.stateAt (0))
|
&& yycheck_[yystate] == yystack.stateAt (0))
|
||||||
yystate = yytable_[yystate];
|
yystate = yytable_[yystate];
|
||||||
else
|
else
|
||||||
yystate = yydefgoto_[yyn - yyntokens_];
|
yystate = yydefgoto_[yyn - yyntokens_];
|
||||||
@@ -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
|
||||||
@@ -388,7 +431,7 @@ b4_lexer_if([[
|
|||||||
break strip_quotes;
|
break strip_quotes;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
if (yystr.charAt(++i) != '\\')
|
if (yystr.charAt(++i) != '\\')
|
||||||
break strip_quotes;
|
break strip_quotes;
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
default:
|
default:
|
||||||
@@ -404,20 +447,21 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
private void yy_symbol_print (String s, int yytype,
|
private void yy_symbol_print (String s, int yytype,
|
||||||
]b4_yystype[ yyvaluep]dnl
|
]b4_yystype[ yyvaluep]dnl
|
||||||
b4_locations_if([, Object yylocationp])[)
|
b4_locations_if([, Object yylocationp])[)
|
||||||
{
|
{
|
||||||
if (yydebug > 0)
|
if (yydebug > 0)
|
||||||
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
|
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
|
||||||
+ yytname_[yytype] + " ("]b4_locations_if([
|
+ yytname_[yytype] + " ("]b4_locations_if([
|
||||||
+ yylocationp + ": "])[
|
+ yylocationp + ": "])[
|
||||||
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
|
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -473,7 +517,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
switch (label)
|
switch (label)
|
||||||
{
|
{
|
||||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||||
pushed when we come here. */
|
pushed when we come here. */
|
||||||
case YYNEWSTATE:
|
case YYNEWSTATE:
|
||||||
yycdebug ("Entering state " + yystate + "\n");
|
yycdebug ("Entering state " + yystate + "\n");
|
||||||
if (yydebug > 0)
|
if (yydebug > 0)
|
||||||
@@ -488,31 +532,31 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
if (yy_pact_value_is_default_ (yyn))
|
if (yy_pact_value_is_default_ (yyn))
|
||||||
{
|
{
|
||||||
label = YYDEFAULT;
|
label = YYDEFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a lookahead token. */
|
/* Read a lookahead token. */
|
||||||
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 ());]])
|
||||||
yylval = yylexer.getLVal ();[
|
yylval = yylexer.getLVal ();[
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
{
|
{
|
||||||
yytoken = yytranslate_ (yychar);
|
yytoken = yytranslate_ (yychar);
|
||||||
yy_symbol_print ("Next token is", yytoken,
|
yy_symbol_print ("Next token is", yytoken,
|
||||||
yylval]b4_locations_if([, yylloc])[);
|
yylval]b4_locations_if([, yylloc])[);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||||
@@ -524,20 +568,20 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
/* <= 0 means reduce or error. */
|
/* <= 0 means reduce or error. */
|
||||||
else if ((yyn = yytable_[yyn]) <= 0)
|
else if ((yyn = yytable_[yyn]) <= 0)
|
||||||
{
|
{
|
||||||
if (yy_table_value_is_error_ (yyn))
|
if (yy_table_value_is_error_ (yyn))
|
||||||
label = YYERRLAB;
|
label = YYERRLAB;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yyn = -yyn;
|
yyn = -yyn;
|
||||||
label = YYREDUCE;
|
label = YYREDUCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Shift the lookahead token. */
|
/* Shift the lookahead token. */
|
||||||
yy_symbol_print ("Shifting", yytoken,
|
yy_symbol_print ("Shifting", yytoken,
|
||||||
yylval]b4_locations_if([, yylloc])[);
|
yylval]b4_locations_if([, yylloc])[);
|
||||||
|
|
||||||
/* Discard the token being shifted. */
|
/* Discard the token being shifted. */
|
||||||
yychar = yyempty_;
|
yychar = yyempty_;
|
||||||
@@ -570,7 +614,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
case YYREDUCE:
|
case YYREDUCE:
|
||||||
yylen = yyr2_[yyn];
|
yylen = yyr2_[yyn];
|
||||||
label = yyaction (yyn, yystack, yylen);
|
label = yyaction (yyn, yystack, yylen);
|
||||||
yystate = yystack.stateAt (0);
|
yystate = yystack.stateAt (0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*------------------------------------.
|
/*------------------------------------.
|
||||||
@@ -589,17 +633,17 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
]b4_locations_if([yyerrloc = yylloc;])[
|
]b4_locations_if([yyerrloc = yylloc;])[
|
||||||
if (yyerrstatus_ == 3)
|
if (yyerrstatus_ == 3)
|
||||||
{
|
{
|
||||||
/* If just tried and failed to reuse lookahead token after an
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
error, discard it. */
|
error, discard it. */
|
||||||
|
|
||||||
if (yychar <= 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
|
||||||
yychar = yyempty_;
|
yychar = yyempty_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* Else will try to reuse lookahead token after shifting the error
|
||||||
@@ -625,46 +669,46 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
case YYERRLAB1:
|
case YYERRLAB1:
|
||||||
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
yyn = yypact_[yystate];
|
yyn = yypact_[yystate];
|
||||||
if (!yy_pact_value_is_default_ (yyn))
|
if (!yy_pact_value_is_default_ (yyn))
|
||||||
{
|
{
|
||||||
yyn += yyterror_;
|
yyn += yyterror_;
|
||||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||||
{
|
{
|
||||||
yyn = yytable_[yyn];
|
yyn = yytable_[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pop the current state because it cannot handle the error token. */
|
/* Pop the current state because it cannot handle the error token. */
|
||||||
if (yystack.height == 0)
|
if (yystack.height == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
|
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
|
||||||
yystack.pop ();
|
yystack.pop ();
|
||||||
yystate = yystack.stateAt (0);
|
yystate = yystack.stateAt (0);
|
||||||
if (yydebug > 0)
|
if (yydebug > 0)
|
||||||
yystack.print (yyDebugStream);
|
yystack.print (yyDebugStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([
|
]b4_locations_if([
|
||||||
/* Muck with the stack to setup for yylloc. */
|
/* Muck with the stack to setup for yylloc. */
|
||||||
yystack.push (0, null, yylloc);
|
yystack.push (0, null, yylloc);
|
||||||
yystack.push (0, null, yyerrloc);
|
yystack.push (0, null, yyerrloc);
|
||||||
yyloc = yylloc (yystack, 2);
|
yyloc = yylloc (yystack, 2);
|
||||||
yystack.pop (2);])[
|
yystack.pop (2);])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
yy_symbol_print ("Shifting", yystos_[yyn],
|
||||||
yylval]b4_locations_if([, yyloc])[);
|
yylval]b4_locations_if([, yyloc])[);
|
||||||
|
|
||||||
yystate = yyn;
|
yystate = yyn;
|
||||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||||
label = YYNEWSTATE;
|
label = YYNEWSTATE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -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)
|
||||||
@@ -886,21 +843,18 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
int yynrhs = yyr2_[yyrule];
|
int yynrhs = yyr2_[yyrule];
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
yycdebug ("Reducing stack by rule " + (yyrule - 1)
|
yycdebug ("Reducing stack by rule " + (yyrule - 1)
|
||||||
+ " (line " + yylno + "), ");
|
+ " (line " + yylno + "), ");
|
||||||
|
|
||||||
/* 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
|
||||||
+11
-9
@@ -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
|
||||||
@@ -29,9 +31,9 @@ b4_copyright([Positions for Bison parsers in C++],
|
|||||||
|
|
||||||
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
||||||
|
|
||||||
# include <iostream>
|
# include <algorithm> // std::max
|
||||||
|
# include <iosfwd>
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <algorithm>
|
|
||||||
|
|
||||||
]b4_null_define[
|
]b4_null_define[
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -281,8 +282,8 @@ b4_copyright([Locations for Bison parsers in C++],
|
|||||||
position last = loc.end - 1;
|
position last = loc.end - 1;
|
||||||
ostr << loc.begin;
|
ostr << loc.begin;
|
||||||
if (last.filename
|
if (last.filename
|
||||||
&& (!loc.begin.filename
|
&& (!loc.begin.filename
|
||||||
|| *loc.begin.filename != *last.filename))
|
|| *loc.begin.filename != *last.filename))
|
||||||
ostr << '-' << last;
|
ostr << '-' << last;
|
||||||
else if (loc.begin.line != last.line)
|
else if (loc.begin.line != last.line)
|
||||||
ostr << '-' << last.line << '.' << last.column;
|
ostr << '-' << last.line << '.' << last.column;
|
||||||
@@ -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_])])
|
||||||
+10
-10
@@ -124,20 +124,20 @@
|
|||||||
<xsl:with-param name="dst" select="@state"/>
|
<xsl:with-param name="dst" select="@state"/>
|
||||||
<xsl:with-param name="style">
|
<xsl:with-param name="style">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@symbol = 'error'">
|
<xsl:when test="@symbol = 'error'">
|
||||||
<xsl:text>dotted</xsl:text>
|
<xsl:text>dotted</xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'shift'">
|
<xsl:when test="@type = 'shift'">
|
||||||
<xsl:text>solid</xsl:text>
|
<xsl:text>solid</xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:text>dashed</xsl:text>
|
<xsl:text>dashed</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
<xsl:with-param name="label">
|
<xsl:with-param name="label">
|
||||||
<xsl:if test="not(@symbol = 'error')">
|
<xsl:if test="not(@symbol = 'error')">
|
||||||
<xsl:value-of select="@symbol"/>
|
<xsl:value-of select="@symbol"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
|
|||||||
+19
-19
@@ -253,9 +253,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="transition[@type = $type]">
|
<xsl:apply-templates select="transition[@type = $type]">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -266,9 +266,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="error">
|
<xsl:apply-templates select="error">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="error"/>
|
<xsl:with-param name="node" select="error"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -279,9 +279,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="reduction">
|
<xsl:apply-templates select="reduction">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="reduction"/>
|
<xsl:with-param name="node" select="reduction"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
<xsl:template match="item">
|
<xsl:template match="item">
|
||||||
<xsl:param name="pad"/>
|
<xsl:param name="pad"/>
|
||||||
<xsl:param name="prev-rule-number"
|
<xsl:param name="prev-rule-number"
|
||||||
select="preceding-sibling::item[1]/@rule-number"/>
|
select="preceding-sibling::item[1]/@rule-number"/>
|
||||||
<xsl:apply-templates
|
<xsl:apply-templates
|
||||||
select="key('bison:ruleByNumber', current()/@rule-number)"
|
select="key('bison:ruleByNumber', current()/@rule-number)"
|
||||||
>
|
>
|
||||||
@@ -329,14 +329,14 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
@@ -442,7 +442,7 @@
|
|||||||
<xsl:value-of select="@rule"/>
|
<xsl:value-of select="@rule"/>
|
||||||
<xsl:text> (</xsl:text>
|
<xsl:text> (</xsl:text>
|
||||||
<xsl:value-of
|
<xsl:value-of
|
||||||
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
|
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
|
||||||
<xsl:text>)</xsl:text>
|
<xsl:text>)</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@@ -479,9 +479,9 @@
|
|||||||
<xsl:variable name="longest">
|
<xsl:variable name="longest">
|
||||||
<xsl:for-each select="$node">
|
<xsl:for-each select="$node">
|
||||||
<xsl:sort data-type="number" select="string-length(@symbol)"
|
<xsl:sort data-type="number" select="string-length(@symbol)"
|
||||||
order="descending"/>
|
order="descending"/>
|
||||||
<xsl:if test="position() = 1">
|
<xsl:if test="position() = 1">
|
||||||
<xsl:value-of select="string-length(@symbol)"/>
|
<xsl:value-of select="string-length(@symbol)"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
@@ -498,7 +498,7 @@
|
|||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
@@ -516,7 +516,7 @@
|
|||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
|||||||
+68
-68
@@ -31,32 +31,32 @@
|
|||||||
<xsl:import href="bison.xsl"/>
|
<xsl:import href="bison.xsl"/>
|
||||||
|
|
||||||
<xsl:output method="xml" encoding="UTF-8"
|
<xsl:output method="xml" encoding="UTF-8"
|
||||||
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
||||||
indent="yes"/>
|
indent="yes"/>
|
||||||
|
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>
|
<title>
|
||||||
<xsl:value-of select="bison-xml-report/filename"/>
|
<xsl:value-of select="bison-xml-report/filename"/>
|
||||||
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
||||||
</title>
|
</title>
|
||||||
<style type="text/css"><![CDATA[
|
<style type="text/css"><![CDATA[
|
||||||
body {
|
body {
|
||||||
font-family: "Nimbus Sans L", Arial, sans-serif;
|
font-family: "Nimbus Sans L", Arial, sans-serif;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
}
|
}
|
||||||
a:link {
|
a:link {
|
||||||
color: #1f00ff;
|
color: #1f00ff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
a:visited {
|
a:visited {
|
||||||
color: #1f00ff;
|
color: #1f00ff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
a:hover {
|
a:hover {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
#menu a {
|
#menu a {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
@@ -109,21 +109,21 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#reductions">Reductions</a>
|
<a href="#reductions">Reductions</a>
|
||||||
<ul class="lower-alpha">
|
<ul class="lower-alpha">
|
||||||
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
|
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
|
||||||
<li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
|
<li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
|
||||||
<li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
|
<li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
|
||||||
<xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
|
<xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
|
||||||
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
|
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#conflicts">Conflicts</a></li>
|
<li><a href="#conflicts">Conflicts</a></li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#grammar">Grammar</a>
|
<a href="#grammar">Grammar</a>
|
||||||
<ul class="lower-alpha">
|
<ul class="lower-alpha">
|
||||||
<li><a href="#grammar">Itemset</a></li>
|
<li><a href="#grammar">Itemset</a></li>
|
||||||
<li><a href="#terminals">Terminal symbols</a></li>
|
<li><a href="#terminals">Terminal symbols</a></li>
|
||||||
<li><a href="#nonterminals">Nonterminal symbols</a></li>
|
<li><a href="#nonterminals">Nonterminal symbols</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#automaton">Automaton</a></li>
|
<li><a href="#automaton">Automaton</a></li>
|
||||||
@@ -154,9 +154,9 @@
|
|||||||
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
||||||
<p class="pre">
|
<p class="pre">
|
||||||
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</p>
|
</p>
|
||||||
@@ -173,9 +173,9 @@
|
|||||||
<p class="pre">
|
<p class="pre">
|
||||||
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
||||||
<xsl:sort select="@symbol-number" data-type="number"/>
|
<xsl:sort select="@symbol-number" data-type="number"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</p>
|
</p>
|
||||||
@@ -381,7 +381,7 @@
|
|||||||
<h3>
|
<h3>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="concat('state_', @number)"/>
|
<xsl:value-of select="concat('state_', @number)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</a>
|
</a>
|
||||||
<xsl:text>state </xsl:text>
|
<xsl:text>state </xsl:text>
|
||||||
@@ -410,9 +410,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="transition[@type = $type]">
|
<xsl:apply-templates select="transition[@type = $type]">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -423,9 +423,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="error">
|
<xsl:apply-templates select="error">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="error"/>
|
<xsl:with-param name="node" select="error"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -436,9 +436,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="reduction">
|
<xsl:apply-templates select="reduction">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="reduction"/>
|
<xsl:with-param name="node" select="reduction"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -447,7 +447,7 @@
|
|||||||
<xsl:template match="item">
|
<xsl:template match="item">
|
||||||
<xsl:param name="pad"/>
|
<xsl:param name="pad"/>
|
||||||
<xsl:param name="prev-rule-number"
|
<xsl:param name="prev-rule-number"
|
||||||
select="preceding-sibling::item[1]/@rule-number"/>
|
select="preceding-sibling::item[1]/@rule-number"/>
|
||||||
<xsl:apply-templates
|
<xsl:apply-templates
|
||||||
select="key('bison:ruleByNumber', current()/@rule-number)"
|
select="key('bison:ruleByNumber', current()/@rule-number)"
|
||||||
>
|
>
|
||||||
@@ -477,7 +477,7 @@
|
|||||||
<xsl:if test="$itemset != 'true'">
|
<xsl:if test="$itemset != 'true'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="concat('rule_', @number)"/>
|
<xsl:value-of select="concat('rule_', @number)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</a>
|
</a>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -486,19 +486,19 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$itemset = 'true'">
|
<xsl:when test="$itemset = 'true'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#rule_', @number)"/>
|
<xsl:value-of select="concat('#rule_', @number)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="string(@number)"/>
|
<xsl:with-param name="str" select="string(@number)"/>
|
||||||
<xsl:with-param name="pad" select="number($pad)"/>
|
<xsl:with-param name="pad" select="number($pad)"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="string(@number)"/>
|
<xsl:with-param name="str" select="string(@number)"/>
|
||||||
<xsl:with-param name="pad" select="number($pad)"/>
|
<xsl:with-param name="pad" select="number($pad)"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@@ -508,19 +508,19 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<span class="i">
|
<span class="i">
|
||||||
<xsl:value-of select="lhs"/>
|
<xsl:value-of select="lhs"/>
|
||||||
</span>
|
</span>
|
||||||
<xsl:text> →</xsl:text>
|
<xsl:text> →</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
@@ -589,18 +589,18 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@type = 'shift'">
|
<xsl:when test="@type = 'shift'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#state_', @state)"/>
|
<xsl:value-of select="concat('#state_', @state)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
|
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'goto'">
|
<xsl:when test="@type = 'goto'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#state_', @state)"/>
|
<xsl:value-of select="concat('#state_', @state)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="concat('go to state ', @state)"/>
|
<xsl:value-of select="concat('go to state ', @state)"/>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@@ -637,10 +637,10 @@
|
|||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#rule_', @rule)"/>
|
<xsl:value-of select="concat('#rule_', @rule)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
|
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
|
||||||
</a>
|
</a>
|
||||||
<xsl:text> (</xsl:text>
|
<xsl:text> (</xsl:text>
|
||||||
<xsl:value-of
|
<xsl:value-of
|
||||||
@@ -687,9 +687,9 @@
|
|||||||
<xsl:variable name="longest">
|
<xsl:variable name="longest">
|
||||||
<xsl:for-each select="$node">
|
<xsl:for-each select="$node">
|
||||||
<xsl:sort data-type="number" select="string-length(@symbol)"
|
<xsl:sort data-type="number" select="string-length(@symbol)"
|
||||||
order="descending"/>
|
order="descending"/>
|
||||||
<xsl:if test="position() = 1">
|
<xsl:if test="position() = 1">
|
||||||
<xsl:value-of select="string-length(@symbol)"/>
|
<xsl:value-of select="string-length(@symbol)"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
@@ -706,7 +706,7 @@
|
|||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
@@ -724,7 +724,7 @@
|
|||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
|||||||
+264
-412
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -179,7 +179,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
This will install the products into your DJGPP installation tree given
|
This will install the products into your DJGPP installation tree given
|
||||||
by the default prefix "/dev/env/DJDIR". If you prefer to install them
|
by the default prefix "/dev/env/DJDIR". If you prefer to install them
|
||||||
into some other directory you will have to set prefix to the appropiate
|
into some other directory you will have to set prefix to the appropriate
|
||||||
value:
|
value:
|
||||||
make install prefix=z:/some/other/place
|
make install prefix=z:/some/other/place
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -471,7 +471,7 @@ redir -e /dev/null rm %XSRC%/po/stamp-cat-id
|
|||||||
|
|
||||||
Rem Update the arguments file for the configure script.
|
Rem Update the arguments file for the configure script.
|
||||||
Rem We prefer without-included-gettext because libintl.a from gettext package
|
Rem We prefer without-included-gettext because libintl.a from gettext package
|
||||||
Rem is the only one that is garanteed to have been ported to DJGPP.
|
Rem is the only one that is guaranteed to have been ported to DJGPP.
|
||||||
echo --enable-nls --without-included-gettext >> args
|
echo --enable-nls --without-included-gettext >> args
|
||||||
goto ConfigurePackage
|
goto ConfigurePackage
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
+880
-161
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.texinfo
|
|
||||||
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
|
|
||||||
+1137
-382
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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
A directory of tools provided to people using CVS Bison. None of
|
|
||||||
these is distributed.
|
|
||||||
|
|
||||||
* bench.pl
|
* bench.pl
|
||||||
A primitive Perl script to run benches. Currently its only bench is
|
A primitive Perl script to run benches. Currently its only bench is
|
||||||
the usual calculator: it has a lightweight processing part (but not
|
the usual calculator: it has a lightweight processing part (but not
|
||||||
|
|||||||
+793
-36
@@ -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;
|
||||||
@@ -71,8 +284,8 @@ for my $size (1 .. $max)
|
|||||||
{
|
{
|
||||||
use Text::Wrap;
|
use Text::Wrap;
|
||||||
print $out wrap ("| ", " ",
|
print $out wrap ("| ", " ",
|
||||||
(map { "\"$_\"" } (1 .. $size)),
|
(map { "\"$_\"" } (1 .. $size)),
|
||||||
" END \n"),
|
" END \n"),
|
||||||
" { \$\$ = $size; }\n";
|
" { \$\$ = $size; }\n";
|
||||||
};
|
};
|
||||||
print $out ";\n";
|
print $out ";\n";
|
||||||
@@ -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;
|
||||||
@@ -174,7 +411,7 @@ static int yylex (void);
|
|||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%left NEG /* negation--unary minus */
|
%left NEG /* negation--unary minus */
|
||||||
@@ -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',
|
|
||||||
);
|
|
||||||
|
|
||||||
|
=item C<bench ($grammar, @token)>
|
||||||
|
|
||||||
|
Generate benches for the C<$grammar> and the directive specification
|
||||||
|
given in the list of C<@token>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub bench ($@)
|
||||||
|
{
|
||||||
|
my ($grammar, @token) = @_;
|
||||||
|
use Benchmark qw (:all :hireswallclock);
|
||||||
|
|
||||||
|
my @directive = parse (@token);
|
||||||
|
|
||||||
|
# Set up the benches as expected by timethese.
|
||||||
my %bench;
|
my %bench;
|
||||||
while (my ($name, $directives) = each %test)
|
# A counter of directive sets.
|
||||||
|
my $count = 1;
|
||||||
|
for my $d (@directive)
|
||||||
{
|
{
|
||||||
print STDERR "$name\n";
|
$bench{$count} = $d;
|
||||||
my $generator = "$gram" . "_grammar";
|
printf " %2d. %s\n", $count, join (' ', split ("\n", $d));
|
||||||
&$generator ($name, 200, $directives);
|
$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.texinfo
|
|
||||||
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.texinfo -- 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
+142
-109
@@ -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
|
||||||
|
{
|
||||||
|
message("SKIP $f");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($file && /^\@(small)?example$/ .. /^\@end (small)?example$/)
|
||||||
|
{
|
||||||
|
if (/^\@(small)?example$/)
|
||||||
|
{
|
||||||
|
# Bison supports synclines, but not Flex.
|
||||||
|
$input .= sprintf ("#line %s \"$in\"\n", $. + 1)
|
||||||
|
if $file =~ /\.[chy]*$/;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
elsif (/^\@end (small)?example$/)
|
||||||
|
{
|
||||||
|
die "no contents: $file"
|
||||||
|
if $input eq "";
|
||||||
|
|
||||||
|
$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.
|
||||||
|
my $o = new IO::File(">$file")
|
||||||
|
or die "$file: cannot create: $?";
|
||||||
|
print $o $file{$file}{$_}
|
||||||
|
for sort keys %{$file{$file}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my @input;
|
||||||
|
my $seen_dash = 0;
|
||||||
|
for my $arg (@ARGV)
|
||||||
|
{
|
||||||
|
if ($arg eq '--')
|
||||||
|
{
|
||||||
|
$seen_dash = 1;
|
||||||
|
}
|
||||||
|
elsif ($seen_dash)
|
||||||
|
{
|
||||||
|
use File::Basename;
|
||||||
|
$file_wanted{basename($arg)} = $arg;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message("extracting " $3);
|
push @input, $arg;
|
||||||
file = $3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
process $_
|
||||||
/^@example$/, /^@end example$/ {
|
foreach @input;
|
||||||
if (!file)
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ($0 ~ /^@example$/)
|
|
||||||
{
|
|
||||||
input = files_output[file] ? "\n" : "";
|
|
||||||
|
|
||||||
# FNR is starting at 0 instead of 1, and
|
|
||||||
# #line report the line number of the *next* line.
|
|
||||||
# => + 2.
|
|
||||||
# Note that recent Bison support it, but not Flex.
|
|
||||||
if (file ~ /\.[chy]*$/)
|
|
||||||
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($0 ~ /^@end example$/)
|
|
||||||
{
|
|
||||||
if (input == "")
|
|
||||||
fatal("no contents: " file);
|
|
||||||
|
|
||||||
input = normalize(input);
|
|
||||||
# No spurious end of line: use printf.
|
|
||||||
if (files_output[file])
|
|
||||||
# The parens around the output file seem to be required
|
|
||||||
# by awk on Mac OS X Tiger (darwin 8.4.6).
|
|
||||||
printf ("%s", input) >> (output_dir "/" file);
|
|
||||||
else
|
|
||||||
printf ("%s", input) > (output_dir "/" file);
|
|
||||||
close (output_dir "/" file);
|
|
||||||
files_output[file] = 1;
|
|
||||||
|
|
||||||
file = input = "";
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
input = input $0 "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# We have to handle CONTENTS line per line, since anchors in AWK are
|
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||||
# referring to the whole string, not the lines.
|
## Local Variables:
|
||||||
function normalize(contents, i, lines, n, line, res) {
|
## perl-indent-level: 2
|
||||||
# Remove the Texinfo tags.
|
## perl-continued-statement-offset: 2
|
||||||
n = split (contents, lines, "\n");
|
## perl-continued-brace-offset: 0
|
||||||
# We don't want the last field which empty: it's behind the last \n.
|
## perl-brace-offset: 0
|
||||||
for (i = 1; i < n; ++i)
|
## perl-brace-imaginary-offset: 0
|
||||||
{
|
## perl-label-offset: -2
|
||||||
line = lines[i];
|
## cperl-indent-level: 2
|
||||||
|
## cperl-brace-offset: 0
|
||||||
# Whole line commands.
|
## cperl-continued-brace-offset: 0
|
||||||
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
|
## cperl-label-offset: -2
|
||||||
# Gperf accepts empty lines as valid input!!!
|
## cperl-extra-newline-before-brace: t
|
||||||
if (file ~ /\.gperf$/)
|
## cperl-merge-trailing-else: nil
|
||||||
continue;
|
## cperl-continued-statement-offset: 2
|
||||||
else
|
## End:
|
||||||
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";
|
|
||||||
message_printed[msg] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fatal(msg) {
|
|
||||||
message(msg);
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# 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 += $(rpcalc_sources)
|
||||||
|
CLEANFILES += examples/rpcalc/rpcalc.[ch] examples/rpcalc/rpcalc.output
|
||||||
|
|
||||||
|
rpcalc_extracted = \
|
||||||
|
examples/rpcalc/rpcalc.y
|
||||||
|
rpcalc_sources = \
|
||||||
|
$(rpcalc_extracted)
|
||||||
|
extracted += $(rpcalc_extracted)
|
||||||
|
|
||||||
|
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:
|
||||||
+1
-1
Submodule gnulib updated: 338dd5d436...2f67aa79c6
+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
|
|
||||||
+115
-115
@@ -47,7 +47,7 @@ abitset_resize (bitset src, bitset_bindex size)
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_small_list (bitset src, bitset_bindex *list,
|
abitset_small_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_bindex count;
|
bitset_bindex count;
|
||||||
@@ -73,27 +73,27 @@ abitset_small_list (bitset src, bitset_bindex *list,
|
|||||||
if (num >= BITSET_WORD_BITS)
|
if (num >= BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
for (count = 0; word; bitno++)
|
for (count = 0; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (count = 0; word; bitno++)
|
for (count = 0; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
bitno++;
|
bitno++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitno;
|
*next = bitno;
|
||||||
@@ -115,7 +115,7 @@ abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
|
|||||||
/* Reset bit BITNO in bitset DST. */
|
/* Reset bit BITNO in bitset DST. */
|
||||||
static void
|
static void
|
||||||
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
|
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
|
||||||
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
/* This should never occur for abitsets since we should always hit
|
/* This should never occur for abitsets since we should always hit
|
||||||
the cache. It is likely someone is trying to access outside the
|
the cache. It is likely someone is trying to access outside the
|
||||||
@@ -126,7 +126,7 @@ abitset_reset (bitset dst ATTRIBUTE_UNUSED,
|
|||||||
/* Test bit BITNO in bitset SRC. */
|
/* Test bit BITNO in bitset SRC. */
|
||||||
static bool
|
static bool
|
||||||
abitset_test (bitset src ATTRIBUTE_UNUSED,
|
abitset_test (bitset src ATTRIBUTE_UNUSED,
|
||||||
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
/* This should never occur for abitsets since we should always
|
/* This should never occur for abitsets since we should always
|
||||||
hit the cache. */
|
hit the cache. */
|
||||||
@@ -140,7 +140,7 @@ abitset_test (bitset src ATTRIBUTE_UNUSED,
|
|||||||
stopped. */
|
stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_list_reverse (bitset src, bitset_bindex *list,
|
abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_bindex rbitno;
|
bitset_bindex rbitno;
|
||||||
@@ -173,18 +173,18 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
|
|
||||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = bitoff + bitcnt;
|
list[count++] = bitoff + bitcnt;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (bitoff + bitcnt);
|
*next = n_bits - (bitoff + bitcnt);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
bitoff -= BITSET_WORD_BITS;
|
bitoff -= BITSET_WORD_BITS;
|
||||||
bitcnt = BITSET_WORD_BITS - 1;
|
bitcnt = BITSET_WORD_BITS - 1;
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_list (bitset src, bitset_bindex *list,
|
abitset_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_bindex count;
|
bitset_bindex count;
|
||||||
@@ -217,80 +217,80 @@ abitset_list (bitset src, bitset_bindex *list,
|
|||||||
{
|
{
|
||||||
/* Many bitsets are zero, so make this common case fast. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||||
continue;
|
continue;
|
||||||
if (windex >= size)
|
if (windex >= size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the current word. */
|
of the current word. */
|
||||||
|
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bitno >= BITSET_SIZE_ (src))
|
if (bitno >= BITSET_SIZE_ (src))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
bitno = bitno % BITSET_WORD_BITS;
|
bitno = bitno % BITSET_WORD_BITS;
|
||||||
|
|
||||||
if (bitno)
|
if (bitno)
|
||||||
{
|
{
|
||||||
/* Handle the case where we start within a word.
|
/* Handle the case where we start within a word.
|
||||||
Most often, this is executed with large bitsets
|
Most often, this is executed with large bitsets
|
||||||
with many set bits where we filled the array
|
with many set bits where we filled the array
|
||||||
on the previous call to this function. */
|
on the previous call to this function. */
|
||||||
|
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
word = srcp[windex] >> bitno;
|
word = srcp[windex] >> bitno;
|
||||||
for (bitno = bitoff + bitno; word; bitno++)
|
for (bitno = bitoff + bitno; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
}
|
}
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
if (!(word = srcp[windex]))
|
if (!(word = srcp[windex]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((count + BITSET_WORD_BITS) < num)
|
if ((count + BITSET_WORD_BITS) < num)
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitoff;
|
*next = bitoff;
|
||||||
@@ -387,7 +387,7 @@ abitset_equal_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ abitset_subset_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ abitset_disjoint_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -452,10 +452,10 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & *src2p++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -490,10 +490,10 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -528,10 +528,10 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ | *src2p++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -566,10 +566,10 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -606,10 +606,10 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -646,10 +646,10 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -686,10 +686,10 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -32,9 +32,9 @@
|
|||||||
Memory for bit array and bitset structure allocated
|
Memory for bit array and bitset structure allocated
|
||||||
contiguously.
|
contiguously.
|
||||||
BITSET_LIST: Linked list of arrays of bits (variable size, least storage
|
BITSET_LIST: Linked list of arrays of bits (variable size, least storage
|
||||||
for large very sparse sets).
|
for large very sparse sets).
|
||||||
BITSET_TABLE: Expandable table of pointers to arrays of bits
|
BITSET_TABLE: Expandable table of pointers to arrays of bits
|
||||||
(variable size, less storage for large sparse sets).
|
(variable size, less storage for large sparse sets).
|
||||||
Faster than BITSET_LIST for random access.
|
Faster than BITSET_LIST for random access.
|
||||||
BITSET_VARRAY: Variable array of bits (variable size, fast for
|
BITSET_VARRAY: Variable array of bits (variable size, fast for
|
||||||
dense bitsets).
|
dense bitsets).
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
statistics and/or better run-time checking.
|
statistics and/or better run-time checking.
|
||||||
*/
|
*/
|
||||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
|
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
|
||||||
BITSET_TYPE_NUM, BITSET_STATS};
|
BITSET_TYPE_NUM, BITSET_STATS};
|
||||||
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
|
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
|
||||||
|
|
||||||
extern const char * const bitset_type_names[];
|
extern const char * const bitset_type_names[];
|
||||||
@@ -78,19 +78,19 @@ typedef size_t bitset_windex;
|
|||||||
#define BITSET_LIST_SIZE 1024
|
#define BITSET_LIST_SIZE 1024
|
||||||
|
|
||||||
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||||
BITSET_OP_COPY, BITSET_OP_NOT,
|
BITSET_OP_COPY, BITSET_OP_NOT,
|
||||||
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
|
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
|
||||||
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
|
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
|
||||||
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
||||||
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
|
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
|
||||||
|
|
||||||
struct bbitset_struct
|
struct bbitset_struct
|
||||||
{
|
{
|
||||||
const struct bitset_vtable *vtable;
|
const struct bitset_vtable *vtable;
|
||||||
bitset_windex cindex; /* Cache word index. */
|
bitset_windex cindex; /* Cache word index. */
|
||||||
bitset_windex csize; /* Cache size in words. */
|
bitset_windex csize; /* Cache size in words. */
|
||||||
bitset_word *cdata; /* Cache data pointer. */
|
bitset_word *cdata; /* Cache data pointer. */
|
||||||
bitset_bindex n_bits; /* Number of bits. */
|
bitset_bindex n_bits; /* Number of bits. */
|
||||||
/* Perhaps we could sacrifice another word to indicate
|
/* Perhaps we could sacrifice another word to indicate
|
||||||
that the bitset is known to be zero, that a bit has been set
|
that the bitset is known to be zero, that a bit has been set
|
||||||
in the cache, and that a bit has been cleared in the cache.
|
in the cache, and that a bit has been cleared in the cache.
|
||||||
@@ -148,9 +148,9 @@ struct bitset_vtable
|
|||||||
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
|
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
|
||||||
|
|
||||||
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
|
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
|
||||||
bitset_bindex *);
|
bitset_bindex *);
|
||||||
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
|
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
|
||||||
bitset_bindex *);
|
bitset_bindex *);
|
||||||
void (*free) (bitset);
|
void (*free) (bitset);
|
||||||
enum bitset_type type;
|
enum bitset_type type;
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-5
@@ -151,7 +151,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
|||||||
/* Create a bitset of N_BITS of type TYPE. */
|
/* Create a bitset of N_BITS of type TYPE. */
|
||||||
bitset
|
bitset
|
||||||
bitset_obstack_alloc (struct obstack *bobstack,
|
bitset_obstack_alloc (struct obstack *bobstack,
|
||||||
bitset_bindex n_bits, enum bitset_type type)
|
bitset_bindex n_bits, enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
bitset bset;
|
bitset bset;
|
||||||
@@ -296,15 +296,15 @@ bitset_print (FILE *file, bitset bset, bool verbose)
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf (file, "n_bits = %lu, set = {",
|
fprintf (file, "n_bits = %lu, set = {",
|
||||||
(unsigned long int) bitset_size (bset));
|
(unsigned long int) bitset_size (bset));
|
||||||
|
|
||||||
pos = 30;
|
pos = 30;
|
||||||
BITSET_FOR_EACH (iter, bset, i, 0)
|
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||||
{
|
{
|
||||||
if (pos > 70)
|
if (pos > 70)
|
||||||
{
|
{
|
||||||
fprintf (file, "\n");
|
fprintf (file, "\n");
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (file, "%lu ", (unsigned long int) i);
|
fprintf (file, "%lu ", (unsigned long int) i);
|
||||||
@@ -407,7 +407,7 @@ bitset_copy_ (bitset dst, bitset src)
|
|||||||
four operand operations. */
|
four operand operations. */
|
||||||
static inline bool
|
static inline bool
|
||||||
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
||||||
enum bitset_ops op)
|
enum bitset_ops op)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool stats_enabled_save;
|
bool stats_enabled_save;
|
||||||
|
|||||||
+29
-29
@@ -33,11 +33,11 @@
|
|||||||
|
|
||||||
/* Attributes used to select a bitset implementation. */
|
/* Attributes used to select a bitset implementation. */
|
||||||
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
||||||
BITSET_VARIABLE = 2, /* Bitset size variable. */
|
BITSET_VARIABLE = 2, /* Bitset size variable. */
|
||||||
BITSET_DENSE = 4, /* Bitset dense. */
|
BITSET_DENSE = 4, /* Bitset dense. */
|
||||||
BITSET_SPARSE = 8, /* Bitset sparse. */
|
BITSET_SPARSE = 8, /* Bitset sparse. */
|
||||||
BITSET_FRUGAL = 16, /* Prefer most compact. */
|
BITSET_FRUGAL = 16, /* Prefer most compact. */
|
||||||
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
|
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
|
||||||
|
|
||||||
typedef unsigned int bitset_attrs;
|
typedef unsigned int bitset_attrs;
|
||||||
|
|
||||||
@@ -49,26 +49,26 @@ union bitset_union
|
|||||||
{
|
{
|
||||||
/* This must be the first member of every other structure that is a
|
/* This must be the first member of every other structure that is a
|
||||||
member of this union. */
|
member of this union. */
|
||||||
struct bbitset_struct b; /* Base bitset data. */
|
struct bbitset_struct b; /* Base bitset data. */
|
||||||
|
|
||||||
struct abitset_struct
|
struct abitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
bitset_word words[1]; /* The array of bits. */
|
bitset_word words[1]; /* The array of bits. */
|
||||||
} a;
|
} a;
|
||||||
|
|
||||||
struct ebitset_struct
|
struct ebitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
bitset_windex size; /* Number of elements. */
|
bitset_windex size; /* Number of elements. */
|
||||||
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
|
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
|
||||||
} e;
|
} e;
|
||||||
|
|
||||||
struct lbitset_struct
|
struct lbitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
struct lbitset_elt_struct *head; /* First element in linked list. */
|
struct lbitset_elt_struct *head; /* First element in linked list. */
|
||||||
struct lbitset_elt_struct *tail; /* Last element in linked list. */
|
struct lbitset_elt_struct *tail; /* Last element in linked list. */
|
||||||
} l;
|
} l;
|
||||||
|
|
||||||
struct bitset_stats_struct
|
struct bitset_stats_struct
|
||||||
@@ -80,7 +80,7 @@ union bitset_union
|
|||||||
struct vbitset_struct
|
struct vbitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
bitset_windex size; /* Allocated size of array. */
|
bitset_windex size; /* Allocated size of array. */
|
||||||
} v;
|
} v;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -116,7 +116,7 @@ extern void bitset_free (bitset);
|
|||||||
/* Create a bitset of desired type and size using an obstack. The
|
/* Create a bitset of desired type and size using an obstack. The
|
||||||
bitset is zeroed. */
|
bitset is zeroed. */
|
||||||
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
||||||
bitset_bindex, enum bitset_type);
|
bitset_bindex, enum bitset_type);
|
||||||
|
|
||||||
/* Free bitset allocated on obstack. */
|
/* Free bitset allocated on obstack. */
|
||||||
extern void bitset_obstack_free (bitset);
|
extern void bitset_obstack_free (bitset);
|
||||||
@@ -312,14 +312,14 @@ extern void bitset_dump (FILE *, bitset);
|
|||||||
printf ("%lu ", (unsigned long int) i);
|
printf ("%lu ", (unsigned long int) i);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
|
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
|
||||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||||
(ITER.num == BITSET_LIST_SIZE) \
|
(ITER.num == BITSET_LIST_SIZE) \
|
||||||
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
||||||
BITSET_LIST_SIZE, &ITER.next));) \
|
BITSET_LIST_SIZE, &ITER.next));) \
|
||||||
for (ITER.i = 0; \
|
for (ITER.i = 0; \
|
||||||
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
||||||
ITER.i++)
|
ITER.i++)
|
||||||
|
|
||||||
|
|
||||||
/* Loop over all elements of BSET, in reverse order starting with
|
/* Loop over all elements of BSET, in reverse order starting with
|
||||||
@@ -334,14 +334,14 @@ extern void bitset_dump (FILE *, bitset);
|
|||||||
printf ("%lu ", (unsigned long int) i);
|
printf ("%lu ", (unsigned long int) i);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
|
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
|
||||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||||
(ITER.num == BITSET_LIST_SIZE) \
|
(ITER.num == BITSET_LIST_SIZE) \
|
||||||
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
||||||
BITSET_LIST_SIZE, &ITER.next));) \
|
BITSET_LIST_SIZE, &ITER.next));) \
|
||||||
for (ITER.i = 0; \
|
for (ITER.i = 0; \
|
||||||
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
||||||
ITER.i++)
|
ITER.i++)
|
||||||
|
|
||||||
|
|
||||||
/* Define set operations in terms of logical operations. */
|
/* Define set operations in terms of logical operations. */
|
||||||
|
|||||||
+39
-39
@@ -48,29 +48,29 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Accessor macros. */
|
/* Accessor macros. */
|
||||||
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||||
bitset_stats_info->types[(TYPE)].allocs++
|
bitset_stats_info->types[(TYPE)].allocs++
|
||||||
#define BITSET_STATS_FREES_INC(BSET) \
|
#define BITSET_STATS_FREES_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
|
||||||
#define BITSET_STATS_SETS_INC(BSET) \
|
#define BITSET_STATS_SETS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
|
||||||
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
|
||||||
#define BITSET_STATS_RESETS_INC(BSET) \
|
#define BITSET_STATS_RESETS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
|
||||||
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
|
||||||
#define BITSET_STATS_TESTS_INC(BSET) \
|
#define BITSET_STATS_TESTS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
|
||||||
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
|
||||||
#define BITSET_STATS_LISTS_INC(BSET) \
|
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
|
||||||
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
|
||||||
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
|
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
|
||||||
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
||||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
||||||
|
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ bool bitset_stats_enabled = false;
|
|||||||
/* Print a percentage histogram with message MSG to FILE. */
|
/* Print a percentage histogram with message MSG to FILE. */
|
||||||
static void
|
static void
|
||||||
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
||||||
unsigned int n_bins, unsigned int *bins)
|
unsigned int n_bins, unsigned int *bins)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int total;
|
unsigned int total;
|
||||||
@@ -120,16 +120,16 @@ bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
|||||||
fprintf (file, "%s %s", name, msg);
|
fprintf (file, "%s %s", name, msg);
|
||||||
for (i = 0; i < n_bins; i++)
|
for (i = 0; i < n_bins; i++)
|
||||||
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
||||||
i * 100.0 / n_bins,
|
i * 100.0 / n_bins,
|
||||||
(i + 1) * 100.0 / n_bins, bins[i],
|
(i + 1) * 100.0 / n_bins, bins[i],
|
||||||
(100.0 * bins[i]) / total);
|
(100.0 * bins[i]) / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Print a log histogram with message MSG to FILE. */
|
/* Print a log histogram with message MSG to FILE. */
|
||||||
static void
|
static void
|
||||||
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
||||||
unsigned int n_bins, unsigned int *bins)
|
unsigned int n_bins, unsigned int *bins)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int total;
|
unsigned int total;
|
||||||
@@ -153,50 +153,50 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
|||||||
fprintf (file, "%s %s", name, msg);
|
fprintf (file, "%s %s", name, msg);
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
||||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||||
|
|
||||||
for (; i < n_bins; i++)
|
for (; i < n_bins; i++)
|
||||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||||
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||||
1UL << (i - 1),
|
1UL << (i - 1),
|
||||||
(1UL << i) - 1,
|
(1UL << i) - 1,
|
||||||
bins[i],
|
bins[i],
|
||||||
(100.0 * bins[i]) / total);
|
(100.0 * bins[i]) / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Print bitset statistics to FILE. */
|
/* Print bitset statistics to FILE. */
|
||||||
static void
|
static void
|
||||||
bitset_stats_print_1 (FILE *file, const char *name,
|
bitset_stats_print_1 (FILE *file, const char *name,
|
||||||
struct bitset_type_info_struct *stats)
|
struct bitset_type_info_struct *stats)
|
||||||
{
|
{
|
||||||
if (!stats)
|
if (!stats)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf (file, "%s:\n", name);
|
fprintf (file, "%s:\n", name);
|
||||||
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
|
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
|
||||||
stats->allocs, stats->frees,
|
stats->allocs, stats->frees,
|
||||||
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
||||||
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
|
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
|
||||||
stats->sets, stats->cache_sets,
|
stats->sets, stats->cache_sets,
|
||||||
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
||||||
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
|
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
|
||||||
stats->resets, stats->cache_resets,
|
stats->resets, stats->cache_resets,
|
||||||
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
||||||
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
|
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
|
||||||
stats->tests, stats->cache_tests,
|
stats->tests, stats->cache_tests,
|
||||||
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
||||||
|
|
||||||
fprintf (file, _("%u bitset_lists\n"), stats->lists);
|
fprintf (file, _("%u bitset_lists\n"), stats->lists);
|
||||||
|
|
||||||
bitset_log_histogram_print (file, name, _("count log histogram\n"),
|
bitset_log_histogram_print (file, name, _("count log histogram\n"),
|
||||||
BITSET_LOG_COUNT_BINS, stats->list_counts);
|
BITSET_LOG_COUNT_BINS, stats->list_counts);
|
||||||
|
|
||||||
bitset_log_histogram_print (file, name, _("size log histogram\n"),
|
bitset_log_histogram_print (file, name, _("size log histogram\n"),
|
||||||
BITSET_LOG_SIZE_BINS, stats->list_sizes);
|
BITSET_LOG_SIZE_BINS, stats->list_sizes);
|
||||||
|
|
||||||
bitset_percent_histogram_print (file, name, _("density histogram\n"),
|
bitset_percent_histogram_print (file, name, _("density histogram\n"),
|
||||||
BITSET_DENSITY_BINS, stats->list_density);
|
BITSET_DENSITY_BINS, stats->list_density);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
|||||||
|
|
||||||
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||||
bitset_stats_print_1 (file, bitset_type_names[i],
|
bitset_stats_print_1 (file, bitset_type_names[i],
|
||||||
&bitset_stats_info->types[i]);
|
&bitset_stats_info->types[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
|
|||||||
if (offset < bset->b.csize)
|
if (offset < bset->b.csize)
|
||||||
{
|
{
|
||||||
bset->b.cdata[offset] &=
|
bset->b.cdata[offset] &=
|
||||||
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||||
BITSET_STATS_CACHE_RESETS_INC (bset);
|
BITSET_STATS_CACHE_RESETS_INC (bset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -570,7 +570,7 @@ bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
|
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
bitset_stats_list (bitset bset, bitset_bindex *list,
|
bitset_stats_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex count;
|
bitset_bindex count;
|
||||||
bitset_bindex tmp;
|
bitset_bindex tmp;
|
||||||
@@ -607,7 +607,7 @@ bitset_stats_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
|
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
|
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
|||||||
{
|
{
|
||||||
fprintf (out, "%2lu|", (unsigned long int) i);
|
fprintf (out, "%2lu|", (unsigned long int) i);
|
||||||
for (j = 0; j < hsize; ++j)
|
for (j = 0; j < hsize; ++j)
|
||||||
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
|
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
|
||||||
fputs ("|\n", out);
|
fputs ("|\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -27,7 +27,7 @@
|
|||||||
type TYPE. */
|
type TYPE. */
|
||||||
bitset *
|
bitset *
|
||||||
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||||
enum bitset_type type)
|
enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t vector_bytes;
|
size_t vector_bytes;
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
@@ -116,7 +116,7 @@ bitsetv_transitive_closure (bitsetv bsetv)
|
|||||||
for (i = 0; bsetv[i]; i++)
|
for (i = 0; bsetv[i]; i++)
|
||||||
for (j = 0; bsetv[j]; j++)
|
for (j = 0; bsetv[j]; j++)
|
||||||
if (bitset_test (bsetv[j], i))
|
if (bitset_test (bsetv[j], i))
|
||||||
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
|||||||
FILE. */
|
FILE. */
|
||||||
void
|
void
|
||||||
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||||
bitsetv bsetv)
|
bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
bitset_windex i;
|
||||||
|
|
||||||
|
|||||||
+304
-304
@@ -58,7 +58,7 @@ typedef struct ebitset_elt_struct
|
|||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
|
bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
|
||||||
struct ebitset_elt_struct *next;
|
struct ebitset_elt_struct *next;
|
||||||
}
|
}
|
||||||
u;
|
u;
|
||||||
@@ -84,7 +84,7 @@ static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
|
|||||||
/* Obstack to allocate bitset elements from. */
|
/* Obstack to allocate bitset elements from. */
|
||||||
static struct obstack ebitset_obstack;
|
static struct obstack ebitset_obstack;
|
||||||
static bool ebitset_obstack_init = false;
|
static bool ebitset_obstack_init = false;
|
||||||
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
||||||
|
|
||||||
#define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
|
#define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
|
||||||
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
|
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
|
||||||
@@ -96,7 +96,7 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
|||||||
|
|
||||||
/* Disable bitset cache and mark BSET as being zero. */
|
/* Disable bitset cache and mark BSET as being zero. */
|
||||||
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \
|
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \
|
||||||
(BSET)->b.cdata = 0)
|
(BSET)->b.cdata = 0)
|
||||||
|
|
||||||
#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX)
|
#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX)
|
||||||
|
|
||||||
@@ -136,37 +136,37 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
|
|||||||
bitset_windex size;
|
bitset_windex size;
|
||||||
|
|
||||||
/* The bitset needs to grow. If we already have enough memory
|
/* The bitset needs to grow. If we already have enough memory
|
||||||
allocated, then just zero what we need. */
|
allocated, then just zero what we need. */
|
||||||
if (newsize > EBITSET_ASIZE (src))
|
if (newsize > EBITSET_ASIZE (src))
|
||||||
{
|
{
|
||||||
/* We need to allocate more memory. When oldsize is
|
/* We need to allocate more memory. When oldsize is
|
||||||
non-zero this means that we are changing the size, so
|
non-zero this means that we are changing the size, so
|
||||||
grow the bitset 25% larger than requested to reduce
|
grow the bitset 25% larger than requested to reduce
|
||||||
number of reallocations. */
|
number of reallocations. */
|
||||||
|
|
||||||
if (oldsize == 0)
|
if (oldsize == 0)
|
||||||
size = newsize;
|
size = newsize;
|
||||||
else
|
else
|
||||||
size = newsize + newsize / 4;
|
size = newsize + newsize / 4;
|
||||||
|
|
||||||
EBITSET_ELTS (src)
|
EBITSET_ELTS (src)
|
||||||
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
|
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
|
||||||
EBITSET_ASIZE (src) = size;
|
EBITSET_ASIZE (src) = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (EBITSET_ELTS (src) + oldsize, 0,
|
memset (EBITSET_ELTS (src) + oldsize, 0,
|
||||||
(newsize - oldsize) * sizeof (ebitset_elt *));
|
(newsize - oldsize) * sizeof (ebitset_elt *));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The bitset needs to shrink. There's no point deallocating
|
/* The bitset needs to shrink. There's no point deallocating
|
||||||
the memory unless it is shrinking by a reasonable amount. */
|
the memory unless it is shrinking by a reasonable amount. */
|
||||||
if ((oldsize - newsize) >= oldsize / 2)
|
if ((oldsize - newsize) >= oldsize / 2)
|
||||||
{
|
{
|
||||||
EBITSET_ELTS (src)
|
EBITSET_ELTS (src)
|
||||||
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
|
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
|
||||||
EBITSET_ASIZE (src) = newsize;
|
EBITSET_ASIZE (src) = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to prune any excess bits. FIXME. */
|
/* Need to prune any excess bits. FIXME. */
|
||||||
}
|
}
|
||||||
@@ -190,16 +190,16 @@ ebitset_elt_alloc (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!ebitset_obstack_init)
|
if (!ebitset_obstack_init)
|
||||||
{
|
{
|
||||||
ebitset_obstack_init = true;
|
ebitset_obstack_init = true;
|
||||||
|
|
||||||
/* Let particular systems override the size of a chunk. */
|
/* Let particular systems override the size of a chunk. */
|
||||||
|
|
||||||
#ifndef OBSTACK_CHUNK_SIZE
|
#ifndef OBSTACK_CHUNK_SIZE
|
||||||
#define OBSTACK_CHUNK_SIZE 0
|
#define OBSTACK_CHUNK_SIZE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Let them override the alloc and free routines too. */
|
/* Let them override the alloc and free routines too. */
|
||||||
|
|
||||||
#ifndef OBSTACK_CHUNK_ALLOC
|
#ifndef OBSTACK_CHUNK_ALLOC
|
||||||
#define OBSTACK_CHUNK_ALLOC xmalloc
|
#define OBSTACK_CHUNK_ALLOC xmalloc
|
||||||
@@ -213,16 +213,16 @@ ebitset_elt_alloc (void)
|
|||||||
#define __alignof__(type) 0
|
#define __alignof__(type) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
|
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||||
__alignof__ (ebitset_elt),
|
__alignof__ (ebitset_elt),
|
||||||
OBSTACK_CHUNK_ALLOC,
|
OBSTACK_CHUNK_ALLOC,
|
||||||
OBSTACK_CHUNK_FREE);
|
OBSTACK_CHUNK_FREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perhaps we should add a number of new elements to the free
|
/* Perhaps we should add a number of new elements to the free
|
||||||
list. */
|
list. */
|
||||||
elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
|
elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
|
||||||
sizeof (ebitset_elt));
|
sizeof (ebitset_elt));
|
||||||
}
|
}
|
||||||
|
|
||||||
return elt;
|
return elt;
|
||||||
@@ -293,7 +293,7 @@ ebitset_elt_zero_p (ebitset_elt *elt)
|
|||||||
|
|
||||||
static ebitset_elt *
|
static ebitset_elt *
|
||||||
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||||
enum ebitset_find_mode mode)
|
enum ebitset_find_mode mode)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt;
|
ebitset_elt *elt;
|
||||||
bitset_windex size;
|
bitset_windex size;
|
||||||
@@ -308,13 +308,13 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
|||||||
if (eindex < size)
|
if (eindex < size)
|
||||||
{
|
{
|
||||||
if ((elt = elts[eindex]))
|
if ((elt = elts[eindex]))
|
||||||
{
|
{
|
||||||
if (EBITSET_WORDS (elt) == bset->b.cdata)
|
if (EBITSET_WORDS (elt) == bset->b.cdata)
|
||||||
return elt;
|
return elt;
|
||||||
|
|
||||||
EBITSET_CACHE_SET (bset, eindex);
|
EBITSET_CACHE_SET (bset, eindex);
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The element could not be found. */
|
/* The element could not be found. */
|
||||||
@@ -329,7 +329,7 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
|||||||
|
|
||||||
case EBITSET_CREATE:
|
case EBITSET_CREATE:
|
||||||
if (eindex >= size)
|
if (eindex >= size)
|
||||||
ebitset_resize (bset, bindex);
|
ebitset_resize (bset, bindex);
|
||||||
|
|
||||||
/* Create a new element. */
|
/* Create a new element. */
|
||||||
elt = ebitset_elt_calloc ();
|
elt = ebitset_elt_calloc ();
|
||||||
@@ -361,22 +361,22 @@ ebitset_weed (bitset bset)
|
|||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
if (ebitset_elt_zero_p (elt))
|
if (ebitset_elt_zero_p (elt))
|
||||||
{
|
{
|
||||||
ebitset_elt_remove (bset, j);
|
ebitset_elt_remove (bset, j);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = j - count;
|
count = j - count;
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
/* All the bits are zero. We could shrink the elts.
|
/* All the bits are zero. We could shrink the elts.
|
||||||
For now just mark BSET as known to be zero. */
|
For now just mark BSET as known to be zero. */
|
||||||
EBITSET_ZERO_SET (bset);
|
EBITSET_ZERO_SET (bset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -402,7 +402,7 @@ ebitset_zero (bitset bset)
|
|||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
if (elt)
|
if (elt)
|
||||||
ebitset_elt_remove (bset, j);
|
ebitset_elt_remove (bset, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All the bits are zero. We could shrink the elts.
|
/* All the bits are zero. We could shrink the elts.
|
||||||
@@ -437,13 +437,13 @@ ebitset_equal_p (bitset dst, bitset src)
|
|||||||
ebitset_elt *delt = delts[j];
|
ebitset_elt *delt = delts[j];
|
||||||
|
|
||||||
if (!selt && !delt)
|
if (!selt && !delt)
|
||||||
continue;
|
continue;
|
||||||
if ((selt && !delt) || (!selt && delt))
|
if ((selt && !delt) || (!selt && delt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -472,14 +472,14 @@ ebitset_copy_ (bitset dst, bitset src)
|
|||||||
ebitset_elt *selt = selts[j];
|
ebitset_elt *selt = selts[j];
|
||||||
|
|
||||||
if (selt)
|
if (selt)
|
||||||
{
|
{
|
||||||
ebitset_elt *tmp;
|
ebitset_elt *tmp;
|
||||||
|
|
||||||
tmp = ebitset_elt_alloc ();
|
tmp = ebitset_elt_alloc ();
|
||||||
delts[j] = tmp;
|
delts[j] = tmp;
|
||||||
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
||||||
sizeof (EBITSET_WORDS (selt)));
|
sizeof (EBITSET_WORDS (selt)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
}
|
}
|
||||||
@@ -545,9 +545,9 @@ ebitset_test (bitset src, bitset_bindex bitno)
|
|||||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
|
||||||
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
|
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
|
||||||
&& ((src->b.cdata[windex - src->b.cindex]
|
&& ((src->b.cdata[windex - src->b.cindex]
|
||||||
>> (bitno % BITSET_WORD_BITS))
|
>> (bitno % BITSET_WORD_BITS))
|
||||||
& 1));
|
& 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -564,7 +564,7 @@ ebitset_free (bitset bset)
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex n_bits;
|
bitset_bindex n_bits;
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
@@ -610,33 +610,33 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
srcp = EBITSET_WORDS (elt);
|
srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||||
|
|
||||||
for (; word; bcount--)
|
for (; word; bcount--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = boffset + bcount;
|
list[count++] = boffset + bcount;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (boffset + bcount);
|
*next = n_bits - (boffset + bcount);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
boffset -= BITSET_WORD_BITS;
|
boffset -= BITSET_WORD_BITS;
|
||||||
bcount = BITSET_WORD_BITS - 1;
|
bcount = BITSET_WORD_BITS - 1;
|
||||||
}
|
}
|
||||||
while (woffset--);
|
while (woffset--);
|
||||||
}
|
}
|
||||||
|
|
||||||
woffset = EBITSET_ELT_WORDS - 1;
|
woffset = EBITSET_ELT_WORDS - 1;
|
||||||
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
|
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
|
||||||
@@ -653,7 +653,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
ebitset_list (bitset bset, bitset_bindex *list,
|
ebitset_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
@@ -680,33 +680,33 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
bitset_windex woffset;
|
bitset_windex woffset;
|
||||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
woffset = eindex * EBITSET_ELT_WORDS;
|
woffset = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
||||||
{
|
{
|
||||||
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
|
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
|
||||||
|
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
bitno = (windex + 1) * BITSET_WORD_BITS;
|
bitno = (windex + 1) * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip to next element. */
|
/* Skip to next element. */
|
||||||
eindex++;
|
eindex++;
|
||||||
@@ -722,108 +722,108 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (!elt)
|
if (!elt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
srcp = EBITSET_WORDS (elt);
|
srcp = EBITSET_WORDS (elt);
|
||||||
windex = eindex * EBITSET_ELT_WORDS;
|
windex = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
if ((count + EBITSET_ELT_BITS) < num)
|
if ((count + EBITSET_ELT_BITS) < num)
|
||||||
{
|
{
|
||||||
/* The coast is clear, plant boot! */
|
/* The coast is clear, plant boot! */
|
||||||
|
|
||||||
#if EBITSET_ELT_WORDS == 2
|
#if EBITSET_ELT_WORDS == 2
|
||||||
word = srcp[0];
|
word = srcp[0];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
word = srcp[1];
|
word = srcp[1];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||||
{
|
{
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
word = srcp[i];
|
word = srcp[i];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Tread more carefully since we need to check
|
/* Tread more carefully since we need to check
|
||||||
if array overflows. */
|
if array overflows. */
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||||
{
|
{
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
for (word = srcp[i]; word; bitno++)
|
for (word = srcp[i]; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitno;
|
*next = bitno;
|
||||||
@@ -853,19 +853,19 @@ ebitset_unused_clear (bitset dst)
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
bitset_windex woffset;
|
bitset_windex woffset;
|
||||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
windex = n_bits / BITSET_WORD_BITS;
|
windex = n_bits / BITSET_WORD_BITS;
|
||||||
woffset = eindex * EBITSET_ELT_WORDS;
|
woffset = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
||||||
windex++;
|
windex++;
|
||||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
||||||
srcp[windex - woffset] = 0;
|
srcp[windex - woffset] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,9 +879,9 @@ ebitset_ones (bitset dst)
|
|||||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
||||||
{
|
{
|
||||||
/* Create new elements if they cannot be found. Perhaps
|
/* Create new elements if they cannot be found. Perhaps
|
||||||
we should just add pointers to a ones element? */
|
we should just add pointers to a ones element? */
|
||||||
elt =
|
elt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||||
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
||||||
}
|
}
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
@@ -904,12 +904,12 @@ ebitset_empty_p (bitset dst)
|
|||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
if (!ebitset_elt_zero_p (elt))
|
if (!ebitset_elt_zero_p (elt))
|
||||||
return 0;
|
return 0;
|
||||||
/* Do some weeding as we go. */
|
/* Do some weeding as we go. */
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All the bits are zero. We could shrink the elts.
|
/* All the bits are zero. We could shrink the elts.
|
||||||
@@ -932,14 +932,14 @@ ebitset_not (bitset dst, bitset src)
|
|||||||
for (j = 0; j < EBITSET_SIZE (src); j++)
|
for (j = 0; j < EBITSET_SIZE (src); j++)
|
||||||
{
|
{
|
||||||
/* Create new elements for dst if they cannot be found
|
/* Create new elements for dst if they cannot be found
|
||||||
or substitute zero elements if src elements not found. */
|
or substitute zero elements if src elements not found. */
|
||||||
selt =
|
selt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
||||||
delt =
|
delt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
|
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
|
||||||
}
|
}
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
ebitset_unused_clear (dst);
|
ebitset_unused_clear (dst);
|
||||||
@@ -972,17 +972,17 @@ ebitset_subset_p (bitset dst, bitset src)
|
|||||||
delt = j < dsize ? delts[j] : 0;
|
delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
if (!selt && !delt)
|
if (!selt && !delt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!selt)
|
if (!selt)
|
||||||
selt = &ebitset_zero_elts[0];
|
selt = &ebitset_zero_elts[0];
|
||||||
if (!delt)
|
if (!delt)
|
||||||
delt = &ebitset_zero_elts[0];
|
delt = &ebitset_zero_elts[0];
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
if (EBITSET_WORDS (delt)[i]
|
if (EBITSET_WORDS (delt)[i]
|
||||||
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1014,11 +1014,11 @@ ebitset_disjoint_p (bitset dst, bitset src)
|
|||||||
delt = j < dsize ? delts[j] : 0;
|
delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
if (!selt || !delt)
|
if (!selt || !delt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1066,93 +1066,93 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
delt = j < dsize ? delts[j] : 0;
|
delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
if (!selt1 && !selt2)
|
if (!selt1 && !selt2)
|
||||||
{
|
{
|
||||||
if (delt)
|
if (delt)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selt1)
|
if (!selt1)
|
||||||
selt1 = &ebitset_zero_elts[0];
|
selt1 = &ebitset_zero_elts[0];
|
||||||
if (!selt2)
|
if (!selt2)
|
||||||
selt2 = &ebitset_zero_elts[0];
|
selt2 = &ebitset_zero_elts[0];
|
||||||
if (!delt)
|
if (!delt)
|
||||||
delt = ebitset_elt_calloc ();
|
delt = ebitset_elt_calloc ();
|
||||||
else
|
else
|
||||||
delts[j] = 0;
|
delts[j] = 0;
|
||||||
|
|
||||||
srcp1 = EBITSET_WORDS (selt1);
|
srcp1 = EBITSET_WORDS (selt1);
|
||||||
srcp2 = EBITSET_WORDS (selt2);
|
srcp2 = EBITSET_WORDS (selt2);
|
||||||
dstp = EBITSET_WORDS (delt);
|
dstp = EBITSET_WORDS (delt);
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case BITSET_OP_OR:
|
case BITSET_OP_OR:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ | *srcp2++;
|
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_AND:
|
case BITSET_OP_AND:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & *srcp2++;
|
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_XOR:
|
case BITSET_OP_XOR:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_ANDN:
|
case BITSET_OP_ANDN:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ebitset_elt_zero_p (delt))
|
if (!ebitset_elt_zero_p (delt))
|
||||||
{
|
{
|
||||||
ebitset_elt_add (dst, delt, j);
|
ebitset_elt_add (dst, delt, j);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ebitset_elt_free (delt);
|
ebitset_elt_free (delt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have elements of DST left over, free them all. */
|
/* If we have elements of DST left over, free them all. */
|
||||||
@@ -1165,7 +1165,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
delt = delts[j];
|
delt = delts[j];
|
||||||
|
|
||||||
if (delt)
|
if (delt)
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/lock.c
|
||||||
|
/lock.h
|
||||||
|
/threadlib.c
|
||||||
+361
-362
@@ -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 (m.hayes@elec.canterbury.ac.nz).
|
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||||
|
|
||||||
@@ -60,10 +59,10 @@ typedef bitset_word lbitset_word;
|
|||||||
These are linked together in a doubly-linked list. */
|
These are linked together in a doubly-linked list. */
|
||||||
typedef struct lbitset_elt_struct
|
typedef struct lbitset_elt_struct
|
||||||
{
|
{
|
||||||
struct lbitset_elt_struct *next; /* Next element. */
|
struct lbitset_elt_struct *next; /* Next element. */
|
||||||
struct lbitset_elt_struct *prev; /* Previous element. */
|
struct lbitset_elt_struct *prev; /* Previous element. */
|
||||||
bitset_windex index; /* bitno / BITSET_WORD_BITS. */
|
bitset_windex index; /* bitno / BITSET_WORD_BITS. */
|
||||||
bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
|
bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
|
||||||
}
|
}
|
||||||
lbitset_elt;
|
lbitset_elt;
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */
|
|||||||
/* Obstack to allocate bitset elements from. */
|
/* Obstack to allocate bitset elements from. */
|
||||||
static struct obstack lbitset_obstack;
|
static struct obstack lbitset_obstack;
|
||||||
static bool lbitset_obstack_init = false;
|
static bool lbitset_obstack_init = false;
|
||||||
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
|
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
|
||||||
|
|
||||||
extern void debug_lbitset (bitset);
|
extern void debug_lbitset (bitset);
|
||||||
|
|
||||||
@@ -102,16 +101,16 @@ lbitset_elt_alloc (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!lbitset_obstack_init)
|
if (!lbitset_obstack_init)
|
||||||
{
|
{
|
||||||
lbitset_obstack_init = true;
|
lbitset_obstack_init = true;
|
||||||
|
|
||||||
/* Let particular systems override the size of a chunk. */
|
/* Let particular systems override the size of a chunk. */
|
||||||
|
|
||||||
#ifndef OBSTACK_CHUNK_SIZE
|
#ifndef OBSTACK_CHUNK_SIZE
|
||||||
#define OBSTACK_CHUNK_SIZE 0
|
#define OBSTACK_CHUNK_SIZE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Let them override the alloc and free routines too. */
|
/* Let them override the alloc and free routines too. */
|
||||||
|
|
||||||
#ifndef OBSTACK_CHUNK_ALLOC
|
#ifndef OBSTACK_CHUNK_ALLOC
|
||||||
#define OBSTACK_CHUNK_ALLOC xmalloc
|
#define OBSTACK_CHUNK_ALLOC xmalloc
|
||||||
@@ -125,16 +124,16 @@ lbitset_elt_alloc (void)
|
|||||||
#define __alignof__(type) 0
|
#define __alignof__(type) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
|
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||||
__alignof__ (lbitset_elt),
|
__alignof__ (lbitset_elt),
|
||||||
OBSTACK_CHUNK_ALLOC,
|
OBSTACK_CHUNK_ALLOC,
|
||||||
OBSTACK_CHUNK_FREE);
|
OBSTACK_CHUNK_FREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perhaps we should add a number of new elements to the free
|
/* Perhaps we should add a number of new elements to the free
|
||||||
list. */
|
list. */
|
||||||
elt = (lbitset_elt *) obstack_alloc (&lbitset_obstack,
|
elt = (lbitset_elt *) obstack_alloc (&lbitset_obstack,
|
||||||
sizeof (lbitset_elt));
|
sizeof (lbitset_elt));
|
||||||
}
|
}
|
||||||
|
|
||||||
return elt;
|
return elt;
|
||||||
@@ -185,20 +184,20 @@ lbitset_elt_unlink (bitset bset, lbitset_elt *elt)
|
|||||||
if (LBITSET_CURRENT (bset) == elt)
|
if (LBITSET_CURRENT (bset) == elt)
|
||||||
{
|
{
|
||||||
if (next)
|
if (next)
|
||||||
{
|
{
|
||||||
bset->b.cdata = next->words;
|
bset->b.cdata = next->words;
|
||||||
bset->b.cindex = next->index;
|
bset->b.cindex = next->index;
|
||||||
}
|
}
|
||||||
else if (prev)
|
else if (prev)
|
||||||
{
|
{
|
||||||
bset->b.cdata = prev->words;
|
bset->b.cdata = prev->words;
|
||||||
bset->b.cindex = prev->index;
|
bset->b.cindex = prev->index;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bset->b.csize = 0;
|
bset->b.csize = 0;
|
||||||
bset->b.cdata = 0;
|
bset->b.cdata = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lbitset_elt_free (elt);
|
lbitset_elt_free (elt);
|
||||||
@@ -278,13 +277,13 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
else if (windex < bset->b.cindex)
|
else if (windex < bset->b.cindex)
|
||||||
{
|
{
|
||||||
for (ptr = current;
|
for (ptr = current;
|
||||||
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr->prev)
|
if (ptr->prev)
|
||||||
ptr->prev->next = elt;
|
ptr->prev->next = elt;
|
||||||
else
|
else
|
||||||
LBITSET_HEAD (bset) = elt;
|
LBITSET_HEAD (bset) = elt;
|
||||||
|
|
||||||
elt->prev = ptr->prev;
|
elt->prev = ptr->prev;
|
||||||
elt->next = ptr;
|
elt->next = ptr;
|
||||||
@@ -295,13 +294,13 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (ptr = current;
|
for (ptr = current;
|
||||||
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr->next)
|
if (ptr->next)
|
||||||
ptr->next->prev = elt;
|
ptr->next->prev = elt;
|
||||||
else
|
else
|
||||||
LBITSET_TAIL (bset) = elt;
|
LBITSET_TAIL (bset) = elt;
|
||||||
|
|
||||||
elt->next = ptr->next;
|
elt->next = ptr->next;
|
||||||
elt->prev = ptr;
|
elt->prev = ptr;
|
||||||
@@ -317,7 +316,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
|
|
||||||
static lbitset_elt *
|
static lbitset_elt *
|
||||||
lbitset_elt_find (bitset bset, bitset_windex windex,
|
lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||||
enum lbitset_find_mode mode)
|
enum lbitset_find_mode mode)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
lbitset_elt *elt;
|
||||||
lbitset_elt *current;
|
lbitset_elt *current;
|
||||||
@@ -327,7 +326,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
current = LBITSET_CURRENT (bset);
|
current = LBITSET_CURRENT (bset);
|
||||||
/* Check if element is the cached element. */
|
/* Check if element is the cached element. */
|
||||||
if ((windex - bset->b.cindex) < bset->b.csize)
|
if ((windex - bset->b.cindex) < bset->b.csize)
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -337,28 +336,28 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
if (current)
|
if (current)
|
||||||
{
|
{
|
||||||
if (windex < bset->b.cindex)
|
if (windex < bset->b.cindex)
|
||||||
{
|
{
|
||||||
for (elt = current;
|
for (elt = current;
|
||||||
elt->prev && elt->index > windex; elt = elt->prev)
|
elt->prev && elt->index > windex; elt = elt->prev)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (elt = current;
|
for (elt = current;
|
||||||
elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
||||||
elt = elt->next)
|
elt = elt->next)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ELT is the nearest to the one we want. If it's not the one
|
/* ELT is the nearest to the one we want. If it's not the one
|
||||||
we want, the one we want does not exist. */
|
we want, the one we want does not exist. */
|
||||||
if (windex - elt->index < LBITSET_ELT_WORDS)
|
if (windex - elt->index < LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
bset->b.cindex = elt->index;
|
bset->b.cindex = elt->index;
|
||||||
bset->b.csize = LBITSET_ELT_WORDS;
|
bset->b.csize = LBITSET_ELT_WORDS;
|
||||||
bset->b.cdata = elt->words;
|
bset->b.cdata = elt->words;
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
@@ -394,7 +393,7 @@ lbitset_weed (bitset bset)
|
|||||||
{
|
{
|
||||||
next = elt->next;
|
next = elt->next;
|
||||||
if (lbitset_elt_zero_p (elt))
|
if (lbitset_elt_zero_p (elt))
|
||||||
lbitset_elt_unlink (bset, elt);
|
lbitset_elt_unlink (bset, elt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,11 +430,11 @@ lbitset_equal_p (bitset dst, bitset src)
|
|||||||
selt && delt; selt = selt->next, delt = delt->next)
|
selt && delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (selt->index != delt->index)
|
if (selt->index != delt->index)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
if (delt->words[j] != selt->words[j])
|
if (delt->words[j] != selt->words[j])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !selt && !delt;
|
return !selt && !delt;
|
||||||
}
|
}
|
||||||
@@ -467,9 +466,9 @@ lbitset_copy (bitset dst, bitset src)
|
|||||||
tmp->prev = prev;
|
tmp->prev = prev;
|
||||||
tmp->next = 0;
|
tmp->next = 0;
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->next = tmp;
|
prev->next = tmp;
|
||||||
else
|
else
|
||||||
LBITSET_HEAD (dst) = tmp;
|
LBITSET_HEAD (dst) = tmp;
|
||||||
prev = tmp;
|
prev = tmp;
|
||||||
|
|
||||||
memcpy (tmp->words, elt->words, sizeof (elt->words));
|
memcpy (tmp->words, elt->words, sizeof (elt->words));
|
||||||
@@ -549,9 +548,9 @@ lbitset_test (bitset src, bitset_bindex bitno)
|
|||||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
|
||||||
return (lbitset_elt_find (src, windex, LBITSET_FIND)
|
return (lbitset_elt_find (src, windex, LBITSET_FIND)
|
||||||
&& ((src->b.cdata[windex - src->b.cindex]
|
&& ((src->b.cdata[windex - src->b.cindex]
|
||||||
>> (bitno % BITSET_WORD_BITS))
|
>> (bitno % BITSET_WORD_BITS))
|
||||||
& 1));
|
& 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -567,7 +566,7 @@ lbitset_free (bitset bset)
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex rbitno;
|
bitset_bindex rbitno;
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
@@ -603,7 +602,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
/* We are trying to start in no-mans land so start
|
/* We are trying to start in no-mans land so start
|
||||||
at end of current elt. */
|
at end of current elt. */
|
||||||
bcount = BITSET_WORD_BITS - 1;
|
bcount = BITSET_WORD_BITS - 1;
|
||||||
windex = elt->index + LBITSET_ELT_WORDS - 1;
|
windex = elt->index + LBITSET_ELT_WORDS - 1;
|
||||||
}
|
}
|
||||||
@@ -623,33 +622,33 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
bitset_word *srcp = elt->words;
|
bitset_word *srcp = elt->words;
|
||||||
|
|
||||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS;
|
for (; (windex - elt->index) < LBITSET_ELT_WORDS;
|
||||||
windex--, boffset -= BITSET_WORD_BITS,
|
windex--, boffset -= BITSET_WORD_BITS,
|
||||||
bcount = BITSET_WORD_BITS - 1)
|
bcount = BITSET_WORD_BITS - 1)
|
||||||
{
|
{
|
||||||
word =
|
word =
|
||||||
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
||||||
|
|
||||||
for (; word; bcount--)
|
for (; word; bcount--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = boffset + bcount;
|
list[count++] = boffset + bcount;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (boffset + bcount);
|
*next = n_bits - (boffset + bcount);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = elt->prev;
|
elt = elt->prev;
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
windex = elt->index + LBITSET_ELT_WORDS - 1;
|
windex = elt->index + LBITSET_ELT_WORDS - 1;
|
||||||
boffset = windex * BITSET_WORD_BITS;
|
boffset = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = n_bits - (boffset + 1);
|
*next = n_bits - (boffset + 1);
|
||||||
@@ -662,7 +661,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
lbitset_list (bitset bset, bitset_bindex *list,
|
lbitset_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
@@ -693,51 +692,51 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
/* Skip to starting element. */
|
/* Skip to starting element. */
|
||||||
for (elt = head;
|
for (elt = head;
|
||||||
elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
||||||
elt = elt->next)
|
elt = elt->next)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!elt)
|
if (!elt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (windex < elt->index)
|
if (windex < elt->index)
|
||||||
{
|
{
|
||||||
windex = elt->index;
|
windex = elt->index;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bitset_word *srcp = elt->words;
|
bitset_word *srcp = elt->words;
|
||||||
|
|
||||||
/* We are starting within an element. */
|
/* We are starting within an element. */
|
||||||
|
|
||||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
||||||
{
|
{
|
||||||
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
|
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
|
||||||
|
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
bitno = (windex + 1) * BITSET_WORD_BITS;
|
bitno = (windex + 1) * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = elt->next;
|
elt = elt->next;
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
windex = elt->index;
|
windex = elt->index;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -750,109 +749,109 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
bitset_word *srcp = elt->words;
|
bitset_word *srcp = elt->words;
|
||||||
|
|
||||||
if ((count + LBITSET_ELT_BITS) < num)
|
if ((count + LBITSET_ELT_BITS) < num)
|
||||||
{
|
{
|
||||||
/* The coast is clear, plant boot! */
|
/* The coast is clear, plant boot! */
|
||||||
|
|
||||||
#if LBITSET_ELT_WORDS == 2
|
#if LBITSET_ELT_WORDS == 2
|
||||||
word = srcp[0];
|
word = srcp[0];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
word = srcp[1];
|
word = srcp[1];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
word = srcp[i];
|
word = srcp[i];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Tread more carefully since we need to check
|
/* Tread more carefully since we need to check
|
||||||
if array overflows. */
|
if array overflows. */
|
||||||
|
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
for (word = srcp[i]; word; bitno++)
|
for (word = srcp[i]; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = elt->next;
|
elt = elt->next;
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
windex = elt->index;
|
windex = elt->index;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitno;
|
*next = bitno;
|
||||||
@@ -870,7 +869,7 @@ lbitset_empty_p (bitset dst)
|
|||||||
{
|
{
|
||||||
next = elt->next;
|
next = elt->next;
|
||||||
if (!lbitset_elt_zero_p (elt))
|
if (!lbitset_elt_zero_p (elt))
|
||||||
return 0;
|
return 0;
|
||||||
/* Weed as we go. */
|
/* Weed as we go. */
|
||||||
lbitset_elt_unlink (dst, elt);
|
lbitset_elt_unlink (dst, elt);
|
||||||
}
|
}
|
||||||
@@ -903,7 +902,7 @@ lbitset_unused_clear (bitset dst)
|
|||||||
windex++;
|
windex++;
|
||||||
|
|
||||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
||||||
srcp[windex - elt->index] = 0;
|
srcp[windex - elt->index] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,12 +946,12 @@ lbitset_not (bitset dst, bitset src)
|
|||||||
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
/* Create new elements for dst if they cannot be found
|
/* Create new elements for dst if they cannot be found
|
||||||
or substitute zero elements if src elements not found. */
|
or substitute zero elements if src elements not found. */
|
||||||
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
||||||
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
delt->words[j] = ~selt->words[j];
|
delt->words[j] = ~selt->words[j];
|
||||||
}
|
}
|
||||||
lbitset_unused_clear (dst);
|
lbitset_unused_clear (dst);
|
||||||
lbitset_weed (dst);
|
lbitset_weed (dst);
|
||||||
@@ -972,26 +971,26 @@ lbitset_subset_p (bitset dst, bitset src)
|
|||||||
selt || delt; selt = selt->next, delt = delt->next)
|
selt || delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (!selt)
|
if (!selt)
|
||||||
selt = &lbitset_zero_elts[0];
|
selt = &lbitset_zero_elts[0];
|
||||||
else if (!delt)
|
else if (!delt)
|
||||||
delt = &lbitset_zero_elts[0];
|
delt = &lbitset_zero_elts[0];
|
||||||
else if (selt->index != delt->index)
|
else if (selt->index != delt->index)
|
||||||
{
|
{
|
||||||
if (selt->index < delt->index)
|
if (selt->index < delt->index)
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[2].next = delt;
|
lbitset_zero_elts[2].next = delt;
|
||||||
delt = &lbitset_zero_elts[2];
|
delt = &lbitset_zero_elts[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[1].next = selt;
|
lbitset_zero_elts[1].next = selt;
|
||||||
selt = &lbitset_zero_elts[1];
|
selt = &lbitset_zero_elts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1009,25 +1008,25 @@ lbitset_disjoint_p (bitset dst, bitset src)
|
|||||||
selt && delt; selt = selt->next, delt = delt->next)
|
selt && delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (selt->index != delt->index)
|
if (selt->index != delt->index)
|
||||||
{
|
{
|
||||||
if (selt->index < delt->index)
|
if (selt->index < delt->index)
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[2].next = delt;
|
lbitset_zero_elts[2].next = delt;
|
||||||
delt = &lbitset_zero_elts[2];
|
delt = &lbitset_zero_elts[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[1].next = selt;
|
lbitset_zero_elts[1].next = selt;
|
||||||
selt = &lbitset_zero_elts[1];
|
selt = &lbitset_zero_elts[1];
|
||||||
}
|
}
|
||||||
/* Since the elements are different, there is no
|
/* Since the elements are different, there is no
|
||||||
intersection of these elements. */
|
intersection of these elements. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
if (selt->words[j] & delt->words[j])
|
if (selt->words[j] & delt->words[j])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1060,124 +1059,124 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
while (selt1 || selt2)
|
while (selt1 || selt2)
|
||||||
{
|
{
|
||||||
/* Figure out whether we need to substitute zero elements for
|
/* Figure out whether we need to substitute zero elements for
|
||||||
missing links. */
|
missing links. */
|
||||||
if (windex1 == windex2)
|
if (windex1 == windex2)
|
||||||
{
|
{
|
||||||
windex = windex1;
|
windex = windex1;
|
||||||
stmp1 = selt1;
|
stmp1 = selt1;
|
||||||
stmp2 = selt2;
|
stmp2 = selt2;
|
||||||
selt1 = selt1->next;
|
selt1 = selt1->next;
|
||||||
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||||
selt2 = selt2->next;
|
selt2 = selt2->next;
|
||||||
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||||
}
|
}
|
||||||
else if (windex1 < windex2)
|
else if (windex1 < windex2)
|
||||||
{
|
{
|
||||||
windex = windex1;
|
windex = windex1;
|
||||||
stmp1 = selt1;
|
stmp1 = selt1;
|
||||||
stmp2 = &lbitset_zero_elts[0];
|
stmp2 = &lbitset_zero_elts[0];
|
||||||
selt1 = selt1->next;
|
selt1 = selt1->next;
|
||||||
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
windex = windex2;
|
windex = windex2;
|
||||||
stmp1 = &lbitset_zero_elts[0];
|
stmp1 = &lbitset_zero_elts[0];
|
||||||
stmp2 = selt2;
|
stmp2 = selt2;
|
||||||
selt2 = selt2->next;
|
selt2 = selt2->next;
|
||||||
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the appropriate element from DST. Begin by discarding
|
/* Find the appropriate element from DST. Begin by discarding
|
||||||
elements that we've skipped. */
|
elements that we've skipped. */
|
||||||
while (delt && delt->index < windex)
|
while (delt && delt->index < windex)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
dtmp = delt;
|
dtmp = delt;
|
||||||
delt = delt->next;
|
delt = delt->next;
|
||||||
lbitset_elt_free (dtmp);
|
lbitset_elt_free (dtmp);
|
||||||
}
|
}
|
||||||
if (delt && delt->index == windex)
|
if (delt && delt->index == windex)
|
||||||
{
|
{
|
||||||
dtmp = delt;
|
dtmp = delt;
|
||||||
delt = delt->next;
|
delt = delt->next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dtmp = lbitset_elt_calloc ();
|
dtmp = lbitset_elt_calloc ();
|
||||||
|
|
||||||
/* Do the operation, and if any bits are set, link it into the
|
/* Do the operation, and if any bits are set, link it into the
|
||||||
linked list. */
|
linked list. */
|
||||||
srcp1 = stmp1->words;
|
srcp1 = stmp1->words;
|
||||||
srcp2 = stmp2->words;
|
srcp2 = stmp2->words;
|
||||||
dstp = dtmp->words;
|
dstp = dtmp->words;
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case BITSET_OP_OR:
|
case BITSET_OP_OR:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ | *srcp2++;
|
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_AND:
|
case BITSET_OP_AND:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & *srcp2++;
|
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_XOR:
|
case BITSET_OP_XOR:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_ANDN:
|
case BITSET_OP_ANDN:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lbitset_elt_zero_p (dtmp))
|
if (!lbitset_elt_zero_p (dtmp))
|
||||||
{
|
{
|
||||||
dtmp->index = windex;
|
dtmp->index = windex;
|
||||||
/* Perhaps this could be optimised... */
|
/* Perhaps this could be optimised... */
|
||||||
lbitset_elt_link (dst, dtmp);
|
lbitset_elt_link (dst, dtmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lbitset_elt_free (dtmp);
|
lbitset_elt_free (dtmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have elements of DST left over, free them all. */
|
/* If we have elements of DST left over, free them all. */
|
||||||
@@ -1385,17 +1384,17 @@ debug_lbitset (bitset bset)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
|
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
word = elt->words[i];
|
word = elt->words[i];
|
||||||
|
|
||||||
fprintf (stderr, " Word %u:", i);
|
fprintf (stderr, " Word %u:", i);
|
||||||
for (j = 0; j < LBITSET_WORD_BITS; j++)
|
for (j = 0; j < LBITSET_WORD_BITS; j++)
|
||||||
if ((word & ((bitset_word) 1 << j)))
|
if ((word & ((bitset_word) 1 << j)))
|
||||||
fprintf (stderr, " %u", j);
|
fprintf (stderr, " %u", j);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
+20
-20
@@ -189,8 +189,8 @@ static struct timevar_time_def start_time;
|
|||||||
|
|
||||||
static void get_time (struct timevar_time_def *);
|
static void get_time (struct timevar_time_def *);
|
||||||
static void timevar_accumulate (struct timevar_time_def *,
|
static void timevar_accumulate (struct timevar_time_def *,
|
||||||
struct timevar_time_def *,
|
struct timevar_time_def *,
|
||||||
struct timevar_time_def *);
|
struct timevar_time_def *);
|
||||||
|
|
||||||
/* Fill the current times into TIME. The definition of this function
|
/* Fill the current times into TIME. The definition of this function
|
||||||
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
|
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
|
||||||
@@ -479,20 +479,20 @@ timevar_print (fp)
|
|||||||
const float tiny = 5e-3;
|
const float tiny = 5e-3;
|
||||||
|
|
||||||
/* Don't print the total execution time here; that goes at the
|
/* Don't print the total execution time here; that goes at the
|
||||||
end. */
|
end. */
|
||||||
if ((timevar_id_t) id == TV_TOTAL)
|
if ((timevar_id_t) id == TV_TOTAL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Don't print timing variables that were never used. */
|
/* Don't print timing variables that were never used. */
|
||||||
if (!tv->used)
|
if (!tv->used)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Don't print timing variables if we're going to get a row of
|
/* Don't print timing variables if we're going to get a row of
|
||||||
zeroes. */
|
zeroes. */
|
||||||
if (tv->elapsed.user < tiny
|
if (tv->elapsed.user < tiny
|
||||||
&& tv->elapsed.sys < tiny
|
&& tv->elapsed.sys < tiny
|
||||||
&& tv->elapsed.wall < tiny)
|
&& tv->elapsed.wall < tiny)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* The timing variable name. */
|
/* The timing variable name. */
|
||||||
fprintf (fp, " %-22s:", tv->name);
|
fprintf (fp, " %-22s:", tv->name);
|
||||||
@@ -500,22 +500,22 @@ timevar_print (fp)
|
|||||||
#ifdef HAVE_USER_TIME
|
#ifdef HAVE_USER_TIME
|
||||||
/* Print user-mode time for this process. */
|
/* Print user-mode time for this process. */
|
||||||
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
||||||
tv->elapsed.user,
|
tv->elapsed.user,
|
||||||
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
||||||
#endif /* HAVE_USER_TIME */
|
#endif /* HAVE_USER_TIME */
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME
|
#ifdef HAVE_SYS_TIME
|
||||||
/* Print system-mode time for this process. */
|
/* Print system-mode time for this process. */
|
||||||
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
||||||
tv->elapsed.sys,
|
tv->elapsed.sys,
|
||||||
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
||||||
#endif /* HAVE_SYS_TIME */
|
#endif /* HAVE_SYS_TIME */
|
||||||
|
|
||||||
#ifdef HAVE_WALL_TIME
|
#ifdef HAVE_WALL_TIME
|
||||||
/* Print wall clock time elapsed. */
|
/* Print wall clock time elapsed. */
|
||||||
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
||||||
tv->elapsed.wall,
|
tv->elapsed.wall,
|
||||||
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
||||||
#endif /* HAVE_WALL_TIME */
|
#endif /* HAVE_WALL_TIME */
|
||||||
|
|
||||||
putc ('\n', fp);
|
putc ('\n', fp);
|
||||||
@@ -534,7 +534,7 @@ timevar_print (fp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
||||||
|| defined (HAVE_WALL_TIME) */
|
|| defined (HAVE_WALL_TIME) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns time (user + system) used so far by the compiler process,
|
/* Returns time (user + system) used so far by the compiler process,
|
||||||
@@ -558,8 +558,8 @@ print_time (str, total)
|
|||||||
{
|
{
|
||||||
long all_time = get_run_time ();
|
long all_time = get_run_time ();
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
||||||
str, total / 1000000, total % 1000000,
|
str, total / 1000000, total % 1000000,
|
||||||
all_time == 0 ? 0
|
all_time == 0 ? 0
|
||||||
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
||||||
}
|
}
|
||||||
|
|||||||
+153
-153
@@ -38,9 +38,9 @@ static void vbitset_set (bitset, bitset_bindex);
|
|||||||
static void vbitset_reset (bitset, bitset_bindex);
|
static void vbitset_reset (bitset, bitset_bindex);
|
||||||
static bool vbitset_test (bitset, bitset_bindex);
|
static bool vbitset_test (bitset, bitset_bindex);
|
||||||
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
|
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
|
||||||
bitset_bindex, bitset_bindex *);
|
bitset_bindex, bitset_bindex *);
|
||||||
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
|
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
|
||||||
bitset_bindex, bitset_bindex *);
|
bitset_bindex, bitset_bindex *);
|
||||||
|
|
||||||
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||||
#define VBITSET_WORDS(X) ((X)->b.cdata)
|
#define VBITSET_WORDS(X) ((X)->b.cdata)
|
||||||
@@ -69,38 +69,38 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
|
|||||||
bitset_windex size;
|
bitset_windex size;
|
||||||
|
|
||||||
/* The bitset needs to grow. If we already have enough memory
|
/* The bitset needs to grow. If we already have enough memory
|
||||||
allocated, then just zero what we need. */
|
allocated, then just zero what we need. */
|
||||||
if (newsize > VBITSET_ASIZE (src))
|
if (newsize > VBITSET_ASIZE (src))
|
||||||
{
|
{
|
||||||
/* We need to allocate more memory. When oldsize is
|
/* We need to allocate more memory. When oldsize is
|
||||||
non-zero this means that we are changing the size, so
|
non-zero this means that we are changing the size, so
|
||||||
grow the bitset 25% larger than requested to reduce
|
grow the bitset 25% larger than requested to reduce
|
||||||
number of reallocations. */
|
number of reallocations. */
|
||||||
|
|
||||||
if (oldsize == 0)
|
if (oldsize == 0)
|
||||||
size = newsize;
|
size = newsize;
|
||||||
else
|
else
|
||||||
size = newsize + newsize / 4;
|
size = newsize + newsize / 4;
|
||||||
|
|
||||||
VBITSET_WORDS (src)
|
VBITSET_WORDS (src)
|
||||||
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
|
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
|
||||||
VBITSET_ASIZE (src) = size;
|
VBITSET_ASIZE (src) = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (VBITSET_WORDS (src) + oldsize, 0,
|
memset (VBITSET_WORDS (src) + oldsize, 0,
|
||||||
(newsize - oldsize) * sizeof (bitset_word));
|
(newsize - oldsize) * sizeof (bitset_word));
|
||||||
VBITSET_SIZE (src) = newsize;
|
VBITSET_SIZE (src) = newsize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The bitset needs to shrink. There's no point deallocating
|
/* The bitset needs to shrink. There's no point deallocating
|
||||||
the memory unless it is shrinking by a reasonable amount. */
|
the memory unless it is shrinking by a reasonable amount. */
|
||||||
if ((oldsize - newsize) >= oldsize / 2)
|
if ((oldsize - newsize) >= oldsize / 2)
|
||||||
{
|
{
|
||||||
VBITSET_WORDS (src)
|
VBITSET_WORDS (src)
|
||||||
= realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
|
= realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
|
||||||
VBITSET_ASIZE (src) = newsize;
|
VBITSET_ASIZE (src) = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to prune any excess bits. FIXME. */
|
/* Need to prune any excess bits. FIXME. */
|
||||||
|
|
||||||
@@ -196,18 +196,18 @@ vbitset_list_reverse (src, list, num, next)
|
|||||||
|
|
||||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = bitoff + bitcnt;
|
list[count++] = bitoff + bitcnt;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (bitoff + bitcnt);
|
*next = n_bits - (bitoff + bitcnt);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
bitoff -= BITSET_WORD_BITS;
|
bitoff -= BITSET_WORD_BITS;
|
||||||
bitcnt = BITSET_WORD_BITS - 1;
|
bitcnt = BITSET_WORD_BITS - 1;
|
||||||
}
|
}
|
||||||
@@ -243,80 +243,80 @@ vbitset_list (src, list, num, next)
|
|||||||
{
|
{
|
||||||
/* Many bitsets are zero, so make this common case fast. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||||
continue;
|
continue;
|
||||||
if (windex >= size)
|
if (windex >= size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the current word. */
|
of the current word. */
|
||||||
|
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bitno >= BITSET_SIZE_ (src))
|
if (bitno >= BITSET_SIZE_ (src))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
bitno = bitno % BITSET_WORD_BITS;
|
bitno = bitno % BITSET_WORD_BITS;
|
||||||
|
|
||||||
if (bitno)
|
if (bitno)
|
||||||
{
|
{
|
||||||
/* Handle the case where we start within a word.
|
/* Handle the case where we start within a word.
|
||||||
Most often, this is executed with large bitsets
|
Most often, this is executed with large bitsets
|
||||||
with many set bits where we filled the array
|
with many set bits where we filled the array
|
||||||
on the previous call to this function. */
|
on the previous call to this function. */
|
||||||
|
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
word = srcp[windex] >> bitno;
|
word = srcp[windex] >> bitno;
|
||||||
for (bitno = bitoff + bitno; word; bitno++)
|
for (bitno = bitoff + bitno; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
}
|
}
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
if (!(word = srcp[windex]))
|
if (!(word = srcp[windex]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((count + BITSET_WORD_BITS) < num)
|
if ((count + BITSET_WORD_BITS) < num)
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitoff;
|
*next = bitoff;
|
||||||
@@ -398,7 +398,7 @@ vbitset_copy1 (bitset dst, bitset src)
|
|||||||
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
||||||
|
|
||||||
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
||||||
sizeof (bitset_word) * (dsize - ssize));
|
sizeof (bitset_word) * (dsize - ssize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ vbitset_not (bitset dst, bitset src)
|
|||||||
|
|
||||||
vbitset_unused_clear (dst);
|
vbitset_unused_clear (dst);
|
||||||
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
||||||
sizeof (bitset_word) * (dsize - ssize));
|
sizeof (bitset_word) * (dsize - ssize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -438,19 +438,19 @@ vbitset_equal_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < min (ssize, dsize); i++)
|
for (i = 0; i < min (ssize, dsize); i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ssize > dsize)
|
if (ssize > dsize)
|
||||||
{
|
{
|
||||||
for (; i < ssize; i++)
|
for (; i < ssize; i++)
|
||||||
if (*srcp++)
|
if (*srcp++)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; i < dsize; i++)
|
for (; i < dsize; i++)
|
||||||
if (*dstp++)
|
if (*dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -468,13 +468,13 @@ vbitset_subset_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ssize > dsize)
|
if (ssize > dsize)
|
||||||
{
|
{
|
||||||
for (; i < ssize; i++)
|
for (; i < ssize; i++)
|
||||||
if (*srcp++)
|
if (*srcp++)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -492,7 +492,7 @@ vbitset_disjoint_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < min (ssize, dsize); i++)
|
for (i = 0; i < min (ssize, dsize); i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -551,10 +551,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & *src2p++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
@@ -566,10 +566,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
for (; i < ssize1; i++, dstp++)
|
for (; i < ssize1; i++, dstp++)
|
||||||
{
|
{
|
||||||
if (*dstp != 0)
|
if (*dstp != 0)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = 0;
|
*dstp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
||||||
@@ -604,14 +604,14 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
|
|||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
for (; i < ssize2; i++)
|
for (; i < ssize2; i++)
|
||||||
*dstp++ = 0;
|
*dstp++ = 0;
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; i < ssize1; i++)
|
for (; i < ssize1; i++)
|
||||||
*dstp++ = *src1p++;
|
*dstp++ = *src1p++;
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
||||||
}
|
}
|
||||||
@@ -644,37 +644,37 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
for (; i < ssize2; i++, dstp++)
|
for (; i < ssize2; i++, dstp++)
|
||||||
{
|
{
|
||||||
if (*dstp != 0)
|
if (*dstp != 0)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = 0;
|
*dstp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; i < ssize1; i++, dstp++)
|
for (; i < ssize1; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++;
|
bitset_word tmp = *src1p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
||||||
}
|
}
|
||||||
@@ -745,10 +745,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ | *src2p++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
@@ -762,10 +762,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++;
|
bitset_word tmp = *src1p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
||||||
@@ -836,10 +836,10 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
@@ -853,10 +853,10 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++;
|
bitset_word tmp = *src1p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
||||||
@@ -926,10 +926,10 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -993,10 +993,10 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -1060,10 +1060,10 @@ vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -34,6 +34,7 @@
|
|||||||
/fprintf-posix.m4
|
/fprintf-posix.m4
|
||||||
/frexp.m4
|
/frexp.m4
|
||||||
/frexpl.m4
|
/frexpl.m4
|
||||||
|
/fseterr.m4
|
||||||
/fstat.m4
|
/fstat.m4
|
||||||
/getdtablesize.m4
|
/getdtablesize.m4
|
||||||
/getopt.m4
|
/getopt.m4
|
||||||
@@ -50,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
|
||||||
@@ -95,11 +97,13 @@
|
|||||||
/multiarch.m4
|
/multiarch.m4
|
||||||
/nls.m4
|
/nls.m4
|
||||||
/nocrash.m4
|
/nocrash.m4
|
||||||
|
/off_t.m4
|
||||||
/open.m4
|
/open.m4
|
||||||
/pathmax.m4
|
/pathmax.m4
|
||||||
/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
|
||||||
@@ -150,6 +154,7 @@
|
|||||||
/sys_ioctl_h.m4
|
/sys_ioctl_h.m4
|
||||||
/sys_socket_h.m4
|
/sys_socket_h.m4
|
||||||
/sys_stat_h.m4
|
/sys_stat_h.m4
|
||||||
|
/sys_types_h.m4
|
||||||
/sys_wait_h.m4
|
/sys_wait_h.m4
|
||||||
/sysexits.m4
|
/sysexits.m4
|
||||||
/threadlib.m4
|
/threadlib.m4
|
||||||
@@ -176,5 +181,3 @@
|
|||||||
/xalloc.m4
|
/xalloc.m4
|
||||||
/xsize.m4
|
/xsize.m4
|
||||||
/xstrndup.m4
|
/xstrndup.m4
|
||||||
/off_t.m4
|
|
||||||
/sys_types_h.m4
|
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [
|
|||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <limits.h>
|
[[#include <limits.h>
|
||||||
int test_array[CHAR_BIT];]])],
|
int test_array[CHAR_BIT];]])],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_FAILURE([cannot compile a simple C program])])
|
[AC_MSG_FAILURE([cannot compile a simple C program])])
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -26,25 +26,25 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
|
|||||||
bison_cv_cxx_works=no
|
bison_cv_cxx_works=no
|
||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[#include <cstdlib>
|
[#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;],
|
using namespace std;],
|
||||||
[std::cerr << "";
|
[std::cerr << "";
|
||||||
cout << "";
|
cout << "";
|
||||||
typedef std::pair<unsigned int, int> uipair;
|
typedef std::pair<unsigned int, int> uipair;
|
||||||
std::map<unsigned int, int> m;
|
std::map<unsigned int, int> m;
|
||||||
std::map<unsigned int, int>::iterator i;
|
std::map<unsigned int, int>::iterator i;
|
||||||
m.insert (uipair (4, -4));
|
m.insert (uipair (4, -4));
|
||||||
for (i = m.begin (); i != m.end (); ++i)
|
for (i = m.begin (); i != m.end (); ++i)
|
||||||
if (i->first != 4)
|
if (i->first != 4)
|
||||||
return 1;])],
|
return 1;])],
|
||||||
[AS_IF([AC_TRY_COMMAND([$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD])],
|
[AS_IF([AC_TRY_COMMAND([$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD])],
|
||||||
[AS_IF([test "$cross_compiling" = yes],
|
[AS_IF([test "$cross_compiling" = yes],
|
||||||
[bison_cv_cxx_works=cross],
|
[bison_cv_cxx_works=cross],
|
||||||
[AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
|
[AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
|
||||||
[bison_cv_cxx_works=yes])])])
|
[bison_cv_cxx_works=yes])])])
|
||||||
rm -f conftest$ac_exeext])
|
rm -f conftest$ac_exeext])
|
||||||
AC_LANG_POP([C++])])
|
AC_LANG_POP([C++])])
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -62,7 +61,7 @@ state_list_append (symbol_number sym, size_t core_size, item_number *core)
|
|||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
||||||
nstates, sym, symbols[sym]->tag);
|
nstates, sym, symbols[sym]->tag);
|
||||||
|
|
||||||
node->next = NULL;
|
node->next = NULL;
|
||||||
node->state = s;
|
node->state = s;
|
||||||
@@ -100,13 +99,13 @@ allocate_itemsets (void)
|
|||||||
symbols. */
|
symbols. */
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
||||||
sizeof *symbol_count);
|
sizeof *symbol_count);
|
||||||
|
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
symbol_count[*rhsp]++;
|
symbol_count[*rhsp]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See comments before new_itemsets. All the vectors of items
|
/* See comments before new_itemsets. All the vectors of items
|
||||||
@@ -187,15 +186,15 @@ new_itemsets (state *s)
|
|||||||
for (i = 0; i < nitemset; ++i)
|
for (i = 0; i < nitemset; ++i)
|
||||||
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
||||||
{
|
{
|
||||||
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
||||||
if (!kernel_size[sym])
|
if (!kernel_size[sym])
|
||||||
{
|
{
|
||||||
shift_symbol[nshifts] = sym;
|
shift_symbol[nshifts] = sym;
|
||||||
nshifts++;
|
nshifts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
|
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
|
||||||
kernel_size[sym]++;
|
kernel_size[sym]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +213,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
|
|||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
||||||
sym, symbols[sym]->tag);
|
sym, symbols[sym]->tag);
|
||||||
|
|
||||||
s = state_hash_lookup (core_size, core);
|
s = state_hash_lookup (core_size, core);
|
||||||
if (!s)
|
if (!s)
|
||||||
@@ -228,7 +227,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
|
|||||||
|
|
||||||
/*---------------------------------------------------------------.
|
/*---------------------------------------------------------------.
|
||||||
| Use the information computed by new_itemsets to find the state |
|
| Use the information computed by new_itemsets to find the state |
|
||||||
| numbers reached by each shift transition from S. |
|
| numbers reached by each shift transition from S. |
|
||||||
| |
|
| |
|
||||||
| SHIFTSET is set up as a vector of those states. |
|
| SHIFTSET is set up as a vector of those states. |
|
||||||
`---------------------------------------------------------------*/
|
`---------------------------------------------------------------*/
|
||||||
@@ -248,7 +247,7 @@ append_states (state *s)
|
|||||||
symbol_number sym = shift_symbol[i];
|
symbol_number sym = shift_symbol[i];
|
||||||
int j;
|
int j;
|
||||||
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
|
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
|
||||||
shift_symbol[j] = shift_symbol[j - 1];
|
shift_symbol[j] = shift_symbol[j - 1];
|
||||||
shift_symbol[j] = sym;
|
shift_symbol[j] = sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,16 +276,16 @@ save_reductions (state *s)
|
|||||||
{
|
{
|
||||||
item_number item = ritem[itemset[i]];
|
item_number item = ritem[itemset[i]];
|
||||||
if (item_number_is_rule_number (item))
|
if (item_number_is_rule_number (item))
|
||||||
{
|
{
|
||||||
rule_number r = item_number_as_rule_number (item);
|
rule_number r = item_number_as_rule_number (item);
|
||||||
redset[count++] = &rules[r];
|
redset[count++] = &rules[r];
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
{
|
{
|
||||||
/* This is "reduce 0", i.e., accept. */
|
/* This is "reduce 0", i.e., accept. */
|
||||||
aver (!final_state);
|
aver (!final_state);
|
||||||
final_state = s;
|
final_state = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a reductions structure and copy the data into it. */
|
/* Make a reductions structure and copy the data into it. */
|
||||||
@@ -308,14 +307,14 @@ set_states (void)
|
|||||||
state_list *this = first_state;
|
state_list *this = first_state;
|
||||||
|
|
||||||
/* Pessimization, but simplification of the code: make sure all
|
/* Pessimization, but simplification of the code: make sure all
|
||||||
the states have valid transitions and reductions members,
|
the states have valid transitions and reductions members,
|
||||||
even if reduced to 0. It is too soon for errs, which are
|
even if reduced to 0. It is too soon for errs, which are
|
||||||
computed later, but set_conflicts. */
|
computed later, but set_conflicts. */
|
||||||
state *s = this->state;
|
state *s = this->state;
|
||||||
if (!s->transitions)
|
if (!s->transitions)
|
||||||
state_transitions_set (s, 0, 0);
|
state_transitions_set (s, 0, 0);
|
||||||
if (!s->reductions)
|
if (!s->reductions)
|
||||||
state_reductions_set (s, 0, 0);
|
state_reductions_set (s, 0, 0);
|
||||||
|
|
||||||
states[s->number] = s;
|
states[s->number] = s;
|
||||||
|
|
||||||
@@ -349,9 +348,9 @@ generate_states (void)
|
|||||||
{
|
{
|
||||||
state *s = list->state;
|
state *s = list->state;
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
||||||
s->number,
|
s->number,
|
||||||
symbols[s->accessing_symbol]->tag);
|
symbols[s->accessing_symbol]->tag);
|
||||||
/* Set up itemset for the transitions out of this state. itemset gets a
|
/* Set up itemset for the transitions out of this state. itemset gets a
|
||||||
vector of all the items that could be accepted next. */
|
vector of all the items that could be accepted next. */
|
||||||
closure (s->items, s->nitems);
|
closure (s->items, s->nitems);
|
||||||
@@ -363,7 +362,7 @@ generate_states (void)
|
|||||||
append_states (s);
|
append_states (s);
|
||||||
|
|
||||||
/* Create the shifts structures for the shifts to those states,
|
/* Create the shifts structures for the shifts to those states,
|
||||||
now that the state numbers transitioning to are known. */
|
now that the state numbers transitioning to are known. */
|
||||||
state_transitions_set (s, nshifts, shiftset);
|
state_transitions_set (s, nshifts, shiftset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-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);
|
||||||
|
|||||||
+20
-19
@@ -61,7 +61,7 @@ print_closure (char const *title, item_number *array, size_t size)
|
|||||||
item_number *rp;
|
item_number *rp;
|
||||||
fprintf (stderr, " %2d: .", array[i]);
|
fprintf (stderr, " %2d: .", array[i]);
|
||||||
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
|
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
|
||||||
fprintf (stderr, " %s", symbols[*rp]->tag);
|
fprintf (stderr, " %s", symbols[*rp]->tag);
|
||||||
fprintf (stderr, " (rule %d)\n", -*rp - 1);
|
fprintf (stderr, " (rule %d)\n", -*rp - 1);
|
||||||
}
|
}
|
||||||
fputs ("\n\n", stderr);
|
fputs ("\n\n", stderr);
|
||||||
@@ -79,10 +79,10 @@ print_firsts (void)
|
|||||||
bitset_iterator iter;
|
bitset_iterator iter;
|
||||||
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
|
||||||
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\t\t%s\n",
|
fprintf (stderr, "\t\t%s\n",
|
||||||
symbols[j + ntokens]->tag);
|
symbols[j + ntokens]->tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n\n");
|
fprintf (stderr, "\n\n");
|
||||||
}
|
}
|
||||||
@@ -100,10 +100,11 @@ print_fderives (void)
|
|||||||
bitset_iterator iter;
|
bitset_iterator iter;
|
||||||
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||||
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
||||||
{
|
{
|
||||||
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");
|
||||||
}
|
}
|
||||||
@@ -129,9 +130,9 @@ set_firsts (void)
|
|||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
for (j = 0; derives[i - ntokens][j]; ++j)
|
for (j = 0; derives[i - ntokens][j]; ++j)
|
||||||
{
|
{
|
||||||
item_number sym = derives[i - ntokens][j]->rhs[0];
|
item_number sym = derives[i - ntokens][j]->rhs[0];
|
||||||
if (ISVAR (sym))
|
if (ISVAR (sym))
|
||||||
bitset_set (FIRSTS (i), sym - ntokens);
|
bitset_set (FIRSTS (i), sym - ntokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_flag & trace_sets)
|
if (trace_flag & trace_sets)
|
||||||
@@ -167,8 +168,8 @@ set_fderives (void)
|
|||||||
for (i = ntokens; i < nsyms; ++i)
|
for (i = ntokens; i < nsyms; ++i)
|
||||||
for (j = ntokens; j < nsyms; ++j)
|
for (j = ntokens; j < nsyms; ++j)
|
||||||
if (bitset_test (FIRSTS (i), j - ntokens))
|
if (bitset_test (FIRSTS (i), j - ntokens))
|
||||||
for (k = 0; derives[j - ntokens][k]; ++k)
|
for (k = 0; derives[j - ntokens][k]; ++k)
|
||||||
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
|
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
|
||||||
|
|
||||||
if (trace_flag & trace_sets)
|
if (trace_flag & trace_sets)
|
||||||
print_fderives ();
|
print_fderives ();
|
||||||
@@ -218,11 +219,11 @@ closure (item_number *core, size_t n)
|
|||||||
{
|
{
|
||||||
item_number itemno = rules[ruleno].rhs - ritem;
|
item_number itemno = rules[ruleno].rhs - ritem;
|
||||||
while (c < n && core[c] < itemno)
|
while (c < n && core[c] < itemno)
|
||||||
{
|
{
|
||||||
itemset[nitemset] = core[c];
|
itemset[nitemset] = core[c];
|
||||||
nitemset++;
|
nitemset++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
itemset[nitemset] = itemno;
|
itemset[nitemset] = itemno;
|
||||||
nitemset++;
|
nitemset++;
|
||||||
};
|
};
|
||||||
|
|||||||
+102
-121
@@ -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);
|
{
|
||||||
fflush (stderr);
|
putc ('\n', 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);
|
|
||||||
}
|
|
||||||
|
|||||||
+37
-49
@@ -21,72 +21,60 @@
|
|||||||
|
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
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;
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user