mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-10 19:25:15 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0535d2a608 | ||
|
|
52ce2a008b | ||
|
|
12f4091de4 | ||
|
|
8ece778cb8 | ||
|
|
f80890c4bb | ||
|
|
1ebc2ac55c | ||
|
|
94952779b6 | ||
|
|
4d9fa28ba8 | ||
|
|
a100a3c4c1 | ||
|
|
b18ceb50f1 | ||
|
|
ff4d67ede8 | ||
|
|
465babb635 | ||
|
|
6a28e6d412 | ||
|
|
f4495da337 | ||
|
|
dbaed0bbf2 | ||
|
|
78c7fb6460 | ||
|
|
da29809969 | ||
|
|
87e4895189 | ||
|
|
01e3f45f83 | ||
|
|
091943f265 | ||
|
|
bf98d94f4f | ||
|
|
6bb37dbe27 | ||
|
|
c3585f41ef | ||
|
|
6525abdc83 | ||
|
|
2b63c54f5a | ||
|
|
2da399d15f | ||
|
|
0c77d69721 | ||
|
|
307fcdee00 | ||
|
|
d26d10ad6c | ||
|
|
1b4108da3e | ||
|
|
53bfc7df94 | ||
|
|
a5fb4a88ef | ||
|
|
54df196d49 | ||
|
|
52bb6f0525 | ||
|
|
76dab18af3 | ||
|
|
c982974f33 | ||
|
|
dc2a3578b7 | ||
|
|
9661b2fcbc | ||
|
|
d9a9b054ae | ||
|
|
cb9f4cb543 | ||
|
|
b86dcaf40b | ||
|
|
0fafbbdefb | ||
|
|
4b85b969d0 | ||
|
|
7727693711 | ||
|
|
ce27796b74 | ||
|
|
6135fdc152 | ||
|
|
f1497356e8 | ||
|
|
1429569362 | ||
|
|
506c368ab2 | ||
|
|
4f9dc3bdc1 | ||
|
|
0d81be2dc7 | ||
|
|
32f44f4bfb | ||
|
|
38a8287813 | ||
|
|
df752784c2 | ||
|
|
292409e91e | ||
|
|
eea56d70d9 | ||
|
|
6e2de439e6 | ||
|
|
e33cd4b824 | ||
|
|
0669780ff8 | ||
|
|
160df220b1 | ||
|
|
da5c072a62 | ||
|
|
73ac8ff409 | ||
|
|
0e0fb0efc9 | ||
|
|
bb1d776be0 | ||
|
|
d7e1abe656 | ||
|
|
13a1537dba | ||
|
|
ac2ba46053 | ||
|
|
2a7a2c1d3a | ||
|
|
c9b5b68c73 | ||
|
|
26aef31552 | ||
|
|
392f3caef6 | ||
|
|
ccaa8e29f9 | ||
|
|
76c3bccf40 | ||
|
|
6275137378 | ||
|
|
d0571c846f | ||
|
|
8c1002e4b7 | ||
|
|
dbd8fd71ba | ||
|
|
95bac741c3 | ||
|
|
f8ab4d81c0 | ||
|
|
d55c9b001a | ||
|
|
611495999f | ||
|
|
01d5f232a9 | ||
|
|
0407acbc59 | ||
|
|
0c0e778bd1 | ||
|
|
30357ae942 | ||
|
|
fb1d76d9a9 | ||
|
|
a61bc3f9f8 | ||
|
|
f0942df01a | ||
|
|
52ababbc89 | ||
|
|
8e11933e41 | ||
|
|
99efa35369 | ||
|
|
547545a795 | ||
|
|
1b5cf80e32 | ||
|
|
4c641c5189 | ||
|
|
3b05de2d05 | ||
|
|
902a235ad3 | ||
|
|
11027558c8 | ||
|
|
cd4e799da4 | ||
|
|
7346163840 | ||
|
|
89c4e1becf | ||
|
|
3262747c5b | ||
|
|
5f3cd49acc | ||
|
|
e6d928c4e8 | ||
|
|
b254b36db8 | ||
|
|
58e79539fc | ||
|
|
60366b152b | ||
|
|
c90110efd3 | ||
|
|
3b50adf7f4 | ||
|
|
3aaa971096 | ||
|
|
7eabe1c70b | ||
|
|
7fec669e42 | ||
|
|
cbbbe12e02 | ||
|
|
286d0755f8 | ||
|
|
1c3d79b871 | ||
|
|
9c72d3c5a8 | ||
|
|
bc083be055 | ||
|
|
22eeb1ab8a | ||
|
|
c4dbc1776c | ||
|
|
b74fc07d21 | ||
|
|
3ab12c1036 | ||
|
|
30ce43b2b5 | ||
|
|
150dc95395 | ||
|
|
bb7c4a5508 | ||
|
|
5c9f50b545 | ||
|
|
b42702d738 | ||
|
|
401e7c5c36 | ||
|
|
93fec67c46 | ||
|
|
4378e2dc3c | ||
|
|
81334eb5a0 | ||
|
|
df373f1ea1 | ||
|
|
9b7e7077dd | ||
|
|
5ab0086157 | ||
|
|
2831bd376f | ||
|
|
1d0e3ee896 | ||
|
|
0a64b76430 | ||
|
|
0b948b7696 | ||
|
|
8b5fb7c4c3 | ||
|
|
d6ae95fb50 | ||
|
|
e86b14069d | ||
|
|
5d983253f7 | ||
|
|
caadfc552b | ||
|
|
c4c25e091c | ||
|
|
fc18b4313a | ||
|
|
758172a8b9 | ||
|
|
e9454c3456 | ||
|
|
8f01cf0269 | ||
|
|
dab08da605 | ||
|
|
8cedb4b40e | ||
|
|
258c2c967f | ||
|
|
9a33570493 | ||
|
|
42ab6c1e44 | ||
|
|
dc1035bada | ||
|
|
71e3f6d4da | ||
|
|
3877b7210e | ||
|
|
64aec0a8d8 | ||
|
|
5e2e9af56d | ||
|
|
7a226860ef | ||
|
|
c973361138 | ||
|
|
5839f4d289 | ||
|
|
ffa46e6516 | ||
|
|
ff50f6f223 | ||
|
|
05be0fef95 | ||
|
|
72c9fa4510 | ||
|
|
a555b41990 | ||
|
|
ecf5cb7e0e | ||
|
|
e50de09886 | ||
|
|
95421df67b | ||
|
|
a4ed94bc13 | ||
|
|
07726f1178 | ||
|
|
e78596955d | ||
|
|
ecd5cae2d4 | ||
|
|
8dcc25a1e4 | ||
|
|
1a5f74d2f6 | ||
|
|
00a654c8ad | ||
|
|
6c5f690da4 | ||
|
|
007e1b5f0a | ||
|
|
bbb9750b3e | ||
|
|
52d0e77c2c | ||
|
|
088d5668a9 | ||
|
|
87579e03e0 | ||
|
|
11225a5d2f | ||
|
|
3dcfb4fd88 | ||
|
|
c0ccb8e5b4 | ||
|
|
79f967ac0d | ||
|
|
0f6ab8e692 | ||
|
|
e657f04b62 | ||
|
|
10e61eec6d | ||
|
|
149e280aab | ||
|
|
e9fddab715 | ||
|
|
cc68bbf799 | ||
|
|
f0bb82ae9e | ||
|
|
04d62346f3 | ||
|
|
9b70d69f39 | ||
|
|
2b7bde9d13 | ||
|
|
ff2fc62138 | ||
|
|
2c05fc750a | ||
|
|
57bc3c9013 | ||
|
|
7aee4586ca | ||
|
|
6c44f2dce3 | ||
|
|
5604903f7a | ||
|
|
225a67321b | ||
|
|
4e3c06b0f8 | ||
|
|
4e26809ab9 | ||
|
|
678853da7e | ||
|
|
76e11b5a3e | ||
|
|
f9c73eec5f | ||
|
|
f6dcecb287 | ||
|
|
ad31c3cdf4 | ||
|
|
7fa23136ca | ||
|
|
961ea2ac85 | ||
|
|
cc6e5cf854 | ||
|
|
1376a7c6e2 | ||
|
|
1c273826d4 | ||
|
|
4a55a5ea9a | ||
|
|
72f04ca80f | ||
|
|
fd98afaf10 | ||
|
|
cca8c73431 | ||
|
|
cb40f5c624 | ||
|
|
6c23b012b9 | ||
|
|
ef88dfba81 | ||
|
|
6e89bc0fd2 | ||
|
|
e3e21cc0d8 | ||
|
|
a0ee2a7543 | ||
|
|
7e28dbea11 | ||
|
|
65df8d6747 | ||
|
|
beea39b2ec | ||
|
|
086506bf23 | ||
|
|
39792f57fb | ||
|
|
65bbaf9598 | ||
|
|
9039c571f4 | ||
|
|
d3db22d788 | ||
|
|
9434571f95 | ||
|
|
0cdbcee0ce | ||
|
|
fd37eb057e | ||
|
|
ecc3a13c34 | ||
|
|
04904e4d28 | ||
|
|
75a605454d | ||
|
|
d7f39ac507 | ||
|
|
f3c18c8e80 | ||
|
|
00c80bc96c | ||
|
|
f62f1db298 | ||
|
|
3ba001baac | ||
|
|
4140320a0a | ||
|
|
af19fd7e0f | ||
|
|
2c74872991 | ||
|
|
50517d578c | ||
|
|
59d820d1ef | ||
|
|
90f0500ef8 | ||
|
|
17a9542c4f | ||
|
|
b7045aa706 | ||
|
|
ee56b6e0f2 | ||
|
|
1edc98f793 | ||
|
|
4192de1f41 | ||
|
|
00b0d02955 | ||
|
|
1045c8d0ef | ||
|
|
ef8965b5f5 | ||
|
|
84b1972c96 | ||
|
|
1079595b2a | ||
|
|
e364bcdbc5 | ||
|
|
5a8db8a739 | ||
|
|
5acc29041e | ||
|
|
5b0b0a1e08 | ||
|
|
1c694e08cc | ||
|
|
4cfb067d93 | ||
|
|
cf60d0a617 | ||
|
|
c0e8489605 | ||
|
|
788b1a6858 | ||
|
|
56414791e9 | ||
|
|
675dcf1962 | ||
|
|
466fb66578 | ||
|
|
cbb967dbad | ||
|
|
44ac18d136 | ||
|
|
0c3dd3a669 | ||
|
|
951da960e6 | ||
|
|
15ea35019f | ||
|
|
f49684a577 | ||
|
|
044ad1288c | ||
|
|
e3812bb8c3 | ||
|
|
cfcd823e16 | ||
|
|
2f02d9beae | ||
|
|
b638603477 | ||
|
|
e21ff47f5d | ||
|
|
b82b387da9 | ||
|
|
641e326303 | ||
|
|
192e9fdf77 | ||
|
|
a4a3f08c11 | ||
|
|
666df338a7 | ||
|
|
b437b16603 | ||
|
|
b493c173c9 | ||
|
|
aab3feb5a1 | ||
|
|
b7942f2661 | ||
|
|
cefb538ab0 | ||
|
|
ecd922024e | ||
|
|
2353ce7216 | ||
|
|
9cc76ee62c | ||
|
|
2f83ef57f3 | ||
|
|
744171ddbf | ||
|
|
4fd3282dd7 | ||
|
|
67793793e8 | ||
|
|
f334775dbf | ||
|
|
feb1011c8b | ||
|
|
99bedadf23 | ||
|
|
79c3f2b8fd | ||
|
|
4cca30d2e6 | ||
|
|
5789f9d91e | ||
|
|
b269a45fa4 | ||
|
|
1478fccd23 | ||
|
|
535281f0ff | ||
|
|
c4a7e7a1ab | ||
|
|
388e12ac0f | ||
|
|
b870d5fee4 | ||
|
|
30d01b21e7 | ||
|
|
c2cca46795 | ||
|
|
879530cb95 | ||
|
|
72acecb30c | ||
|
|
d4fcd5c3d0 | ||
|
|
368fcf0af5 | ||
|
|
6fe063da8f | ||
|
|
296660304c | ||
|
|
323731ff74 | ||
|
|
6f7f949708 | ||
|
|
15e57d9108 | ||
|
|
30ba94081c | ||
|
|
0e7bc7a6d8 | ||
|
|
eff4d16175 | ||
|
|
b0e11f4523 | ||
|
|
d9b2270bed | ||
|
|
7a28659495 | ||
|
|
e09a72eeb0 | ||
|
|
a09d0ae4d1 | ||
|
|
1e25cb44d1 | ||
|
|
3ed42d2487 | ||
|
|
26c5f48c1c | ||
|
|
7f921d18dd | ||
|
|
cc3760ef51 | ||
|
|
2f23ca6f65 | ||
|
|
468b68c5cd | ||
|
|
9ed802a026 | ||
|
|
fb554c2804 | ||
|
|
47850d4f58 | ||
|
|
57b035a242 | ||
|
|
e7a202d762 | ||
|
|
11e2b755f0 | ||
|
|
f3d33c3613 | ||
|
|
163a35d6dd | ||
|
|
cdb42f7730 | ||
|
|
126252333d | ||
|
|
8637f2c7d6 | ||
|
|
6946149701 | ||
|
|
1368b9dbc9 | ||
|
|
0e96eaf612 | ||
|
|
77bdcc6f0c | ||
|
|
57647bb656 | ||
|
|
63cd2918ff | ||
|
|
d810aa3d8f | ||
|
|
ed1eedbbcb | ||
|
|
bc74b4b15a | ||
|
|
8dd8137c38 | ||
|
|
1388e5b276 | ||
|
|
6f5465c917 | ||
|
|
bb02acc2ed | ||
|
|
80a4389377 | ||
|
|
ef097719ea | ||
|
|
0c90c59795 | ||
|
|
18a7cfc7cf | ||
|
|
088356cb2f | ||
|
|
52db24b2bc | ||
|
|
650b253843 | ||
|
|
7781254e01 | ||
|
|
fa226d773c | ||
|
|
1cc83505c5 | ||
|
|
2d97fe86fd | ||
|
|
3239866f4a | ||
|
|
ebab1ffca8 | ||
|
|
f705e9abdb | ||
|
|
d6f576102e | ||
|
|
0f587e9931 | ||
|
|
48be689a73 | ||
|
|
d727e0ff23 | ||
|
|
37aeda6fb3 | ||
|
|
bba2f0a3a0 | ||
|
|
fe14fb1c40 | ||
|
|
88d1ab421a | ||
|
|
edf495b38e | ||
|
|
ba69beafac | ||
|
|
c16fcaf2fb | ||
|
|
7e99f67592 | ||
|
|
d5f929d407 | ||
|
|
c5b215b5e6 | ||
|
|
0774b2c6e3 | ||
|
|
493359b758 | ||
|
|
23ba9e5dfa | ||
|
|
792fc34016 | ||
|
|
c4a08d1899 | ||
|
|
50fb1e6e0c | ||
|
|
6bd0527a50 | ||
|
|
1aa9d40b24 | ||
|
|
a1da9b9fe8 | ||
|
|
c80cdf2db2 | ||
|
|
3197d0fac9 | ||
|
|
78e43ce8ff | ||
|
|
fe23e19323 | ||
|
|
f374310119 | ||
|
|
7bfff37f01 | ||
|
|
26fba6fc94 | ||
|
|
c592202345 | ||
|
|
0917f4dc76 | ||
|
|
0f792833c2 | ||
|
|
b62e063df5 | ||
|
|
e6b0612f91 | ||
|
|
2eb3328afc | ||
|
|
81849520cd | ||
|
|
fc2191f137 | ||
|
|
6fb362c87a | ||
|
|
46ab1d0cbe | ||
|
|
f54a5b303b | ||
|
|
2cc361387c | ||
|
|
e6d1289f4a | ||
|
|
16c77b4ba2 | ||
|
|
1587a5ea9b | ||
|
|
4ab2cf7450 | ||
|
|
172f103c1e | ||
|
|
6ada985ff3 | ||
|
|
2e12257803 | ||
|
|
1db962716a | ||
|
|
9096955fba | ||
|
|
e9d404415a | ||
|
|
d9df62bfcd | ||
|
|
adac9a17f0 | ||
|
|
3b4b157369 | ||
|
|
5c332d70d7 | ||
|
|
91247f50d7 | ||
|
|
f443673450 | ||
|
|
8e6233353f | ||
|
|
e5a5da16ed | ||
|
|
ebe427bbf3 | ||
|
|
7e3a513d88 | ||
|
|
57f64ebbf8 | ||
|
|
c8d997cb5f | ||
|
|
61b8a8def5 | ||
|
|
6990c5bde9 | ||
|
|
27e822abfd | ||
|
|
21ba496083 | ||
|
|
c6e2dcabae | ||
|
|
e1197fcc3d | ||
|
|
1854429e40 | ||
|
|
cece227f95 | ||
|
|
e83077c617 | ||
|
|
fd33cc9c8b | ||
|
|
8637438cee | ||
|
|
ee97f37cb4 | ||
|
|
68ef3a0466 | ||
|
|
cda1934606 | ||
|
|
5b883180e6 | ||
|
|
135d0336d5 | ||
|
|
cc6c647f00 | ||
|
|
a1aef9825a | ||
|
|
ece99a890c | ||
|
|
169c2530e4 | ||
|
|
c894a6e2ce | ||
|
|
187c2ac344 | ||
|
|
f06c0d2c05 | ||
|
|
975be86ccc | ||
|
|
1c0adb410d | ||
|
|
32b529f038 | ||
|
|
46cce832fd | ||
|
|
98a1045bea | ||
|
|
8426663631 | ||
|
|
a0675d707f | ||
|
|
9cf0a97aa9 | ||
|
|
3dec8a4caf | ||
|
|
2cb52c5a91 | ||
|
|
04f3bfc596 | ||
|
|
c67daa9a97 | ||
|
|
2ca8e86f83 | ||
|
|
e419eda5e2 | ||
|
|
2116af766a | ||
|
|
8036635251 | ||
|
|
c442b5de9d | ||
|
|
da4587fcd7 | ||
|
|
86a3ec0f8d | ||
|
|
7122d747cf | ||
|
|
69fe4b9eb6 | ||
|
|
385fb345bf | ||
|
|
f983d00e77 | ||
|
|
78bb152a63 | ||
|
|
4d6ff4c5e5 | ||
|
|
9bb5087ad1 | ||
|
|
d29e40a047 | ||
|
|
b10366f296 | ||
|
|
139d065594 | ||
|
|
0d73c39bb7 | ||
|
|
7f01adced9 | ||
|
|
3bad20352c | ||
|
|
cb3bf6493d | ||
|
|
57503e2165 | ||
|
|
b3abe014f2 | ||
|
|
80f3220fea | ||
|
|
fc2040a750 | ||
|
|
d55f240991 | ||
|
|
4f961a706d | ||
|
|
ac203e6c3c | ||
|
|
9141f0b79f | ||
|
|
d57eab87e8 | ||
|
|
bb901beb68 | ||
|
|
fa00c56c17 | ||
|
|
5359c479bc | ||
|
|
20107b77c0 | ||
|
|
5e71eef267 | ||
|
|
472531dc72 | ||
|
|
046f238826 | ||
|
|
9bf06f6963 | ||
|
|
357336d254 | ||
|
|
d4a6c3c58a | ||
|
|
8976e0f567 | ||
|
|
6dca1eb950 | ||
|
|
f8d82ff039 | ||
|
|
9e9e49224f | ||
|
|
8b53f4e022 | ||
|
|
8c87a62308 | ||
|
|
478cb5cf12 | ||
|
|
94f70bd861 | ||
|
|
9b4f0970fe | ||
|
|
869028a66d | ||
|
|
6f92a7f664 | ||
|
|
6a61b6b17e | ||
|
|
a4bf7cdf9e | ||
|
|
9471a5ffe9 | ||
|
|
24c5214ae8 | ||
|
|
2f7097d1b1 | ||
|
|
28369ecb5d | ||
|
|
b92f064e9b | ||
|
|
98f19578aa | ||
|
|
7d9839c4a8 | ||
|
|
ad32ec64c8 | ||
|
|
44cdc0f001 | ||
|
|
ca796220ec | ||
|
|
8a910107b3 | ||
|
|
28d1ca8f48 | ||
|
|
1817b475a6 | ||
|
|
22ca07defa | ||
|
|
dbd6975b5c | ||
|
|
cd726fdc4d | ||
|
|
60ebd8e210 | ||
|
|
3765e3e790 | ||
|
|
c313360deb | ||
|
|
25698b58c0 | ||
|
|
17d34c231b | ||
|
|
af000bab11 | ||
|
|
b2347a3c3e | ||
|
|
008d927f71 | ||
|
|
1650c729d9 | ||
|
|
7bdf7246fb | ||
|
|
583c193ffa | ||
|
|
47b9ada6fa | ||
|
|
dcd5bb26e3 | ||
|
|
cce6c998b6 | ||
|
|
3398b0fa90 | ||
|
|
2bd1d9e20f | ||
|
|
1f2546396e | ||
|
|
809268c1a4 | ||
|
|
10acc148bb | ||
|
|
28f1e1546c | ||
|
|
c53b379784 | ||
|
|
fead28d9e3 | ||
|
|
7e0b50c524 | ||
|
|
8228d96d33 | ||
|
|
a5fc4e3b44 | ||
|
|
3be912e4af | ||
|
|
4b4e532748 | ||
|
|
6e7d8ba6a7 | ||
|
|
c680300a29 | ||
|
|
0cbefb71e8 | ||
|
|
402332c4b6 | ||
|
|
aa244fc5fe | ||
|
|
719395c9cd | ||
|
|
fa9871a2fb | ||
|
|
76597d01f3 | ||
|
|
bc5efb558d | ||
|
|
17e21f6158 | ||
|
|
6ef8513e7c | ||
|
|
3945beb1d2 | ||
|
|
c86b7815fc | ||
|
|
048730c691 | ||
|
|
ec64a0bc7e | ||
|
|
d6fe39cd18 | ||
|
|
d76ea5ce06 | ||
|
|
fdef997432 | ||
|
|
0073b5ea5f | ||
|
|
717be0a0f0 | ||
|
|
c6e4b260e0 | ||
|
|
8b87da8d12 | ||
|
|
41b1f828ae | ||
|
|
4e0de4df8c | ||
|
|
97d6da0c5b | ||
|
|
e31f92495c | ||
|
|
54c5d5d1b4 | ||
|
|
693e69f289 | ||
|
|
5c2c9fcb17 | ||
|
|
071f43d5b7 | ||
|
|
8a4ec5d4e4 | ||
|
|
052215a138 | ||
|
|
15c1b913cf | ||
|
|
83c9051a64 | ||
|
|
7a557ee7fe | ||
|
|
08dd5e9feb | ||
|
|
68cc2631a4 | ||
|
|
b47340982b | ||
|
|
ee35055b49 | ||
|
|
e5cbac98b6 | ||
|
|
d563a01709 | ||
|
|
a428a9fa6c | ||
|
|
2a0185b693 | ||
|
|
ab3621678a | ||
|
|
8631f35bf9 | ||
|
|
c483b6593f | ||
|
|
59cb1f421c | ||
|
|
d9d37a1196 | ||
|
|
c3db1394a1 | ||
|
|
2c20ae9b41 | ||
|
|
0c56c195e0 | ||
|
|
3dd2ae4415 | ||
|
|
d50df39f1a | ||
|
|
2c66acfec0 | ||
|
|
3f320159e3 | ||
|
|
f41e0cf73c | ||
|
|
d6ce0521cf | ||
|
|
cf298ebb7d | ||
|
|
734db67004 | ||
|
|
7d47d51962 | ||
|
|
602d562d6f | ||
|
|
825150b085 | ||
|
|
d4b6c86c7f | ||
|
|
5463291a91 | ||
|
|
6373b90fc8 | ||
|
|
beceb2fa93 | ||
|
|
58302c6079 | ||
|
|
d2a7a28438 | ||
|
|
9e6c5328d3 | ||
|
|
fec13ce2db | ||
|
|
be3cf406af | ||
|
|
126c4622de | ||
|
|
dd64eaf9db | ||
|
|
0b585c49ae | ||
|
|
37c4d0b175 | ||
|
|
56bcccbc51 | ||
|
|
17cc7da519 | ||
|
|
2713e7c4ff | ||
|
|
32e5a91a91 | ||
|
|
5973d763c0 | ||
|
|
4246cd81df | ||
|
|
e69b47cd18 | ||
|
|
8f5aaa0e04 | ||
|
|
b75b055288 | ||
|
|
41e84cddc7 | ||
|
|
5709f94a91 | ||
|
|
bc96b757ca | ||
|
|
1133220416 | ||
|
|
39eb80bdbc | ||
|
|
361004aabe | ||
|
|
032a52be6e | ||
|
|
843ef49bc3 | ||
|
|
5df33278b4 | ||
|
|
d96fff6115 | ||
|
|
be92ad1eb4 | ||
|
|
ff2f02815b | ||
|
|
67dcef357c | ||
|
|
133edcd248 | ||
|
|
4d9ff272cf | ||
|
|
2ca6b71967 | ||
|
|
871c02b327 | ||
|
|
a57e74a5bf | ||
|
|
4971409e39 | ||
|
|
b772baef24 | ||
|
|
406e8c7c02 | ||
|
|
97c4169f23 | ||
|
|
8add45dbd9 | ||
|
|
b3e9c20227 | ||
|
|
b2c381cd25 | ||
|
|
67bff62e31 | ||
|
|
5f45cb05f1 | ||
|
|
b61b0eb9ac | ||
|
|
69277e109a | ||
|
|
f716484627 | ||
|
|
945b917da2 | ||
|
|
1ef407d923 | ||
|
|
576b863e91 | ||
|
|
2274c34e91 | ||
|
|
fccab9bc40 | ||
|
|
488607534a | ||
|
|
4db572dd21 | ||
|
|
8faf075fd7 | ||
|
|
453639dfac | ||
|
|
4901ee115b | ||
|
|
6c7b2dfe51 | ||
|
|
a3e201de02 | ||
|
|
5e95bb6251 | ||
|
|
569125a6bf | ||
|
|
8ac28ba1f0 | ||
|
|
3ca713abd0 | ||
|
|
8c18e3f18c | ||
|
|
1e5e274972 | ||
|
|
b1679f8346 | ||
|
|
9861bcc540 | ||
|
|
d94d83e10b | ||
|
|
2f6e377953 | ||
|
|
32dff87c1d | ||
|
|
19da501e06 | ||
|
|
5e4133175d | ||
|
|
0b093ac4d9 | ||
|
|
69b22b49d4 | ||
|
|
ec11f08fb3 | ||
|
|
67444a6f0d | ||
|
|
4eed3a0f0c | ||
|
|
84a6621c78 | ||
|
|
06a273625b | ||
|
|
d120a07e6b | ||
|
|
741a58a504 | ||
|
|
d80815ac23 | ||
|
|
0b417c3479 | ||
|
|
f6fd9be688 | ||
|
|
77dbdd0d59 | ||
|
|
f8db8fe4d7 | ||
|
|
375eb71489 | ||
|
|
d3a86f7b20 | ||
|
|
29c75ef27f | ||
|
|
628012d830 | ||
|
|
f788ba2ab6 | ||
|
|
53526f31df | ||
|
|
e63811dd86 | ||
|
|
47262c36bb | ||
|
|
1e452b1553 | ||
|
|
ed796869bb | ||
|
|
12c412f6bb | ||
|
|
2663035ea5 | ||
|
|
de7c66ab41 | ||
|
|
feeacc2d57 | ||
|
|
cc10f9ab24 | ||
|
|
a9499e6ea2 | ||
|
|
09a4bfdab4 | ||
|
|
7d701f4378 | ||
|
|
378963b139 | ||
|
|
2dd882bce5 | ||
|
|
989503b1ba | ||
|
|
61c2c40092 | ||
|
|
3953c61362 | ||
|
|
39e584c018 | ||
|
|
611eaffd28 | ||
|
|
3f4ad2cd24 | ||
|
|
989a7aa865 | ||
|
|
95cbd56882 | ||
|
|
92124d27c1 | ||
|
|
6d81b91ae0 | ||
|
|
9145bd0b61 | ||
|
|
d7cf3f5b18 | ||
|
|
f49598a1e1 | ||
|
|
72d4ae5306 | ||
|
|
996abe62d7 | ||
|
|
0420362ee8 | ||
|
|
6f47eea7ab | ||
|
|
99bfdc09cb | ||
|
|
52f21717f7 | ||
|
|
cbdc22af10 | ||
|
|
220c593a79 | ||
|
|
e29ac453d0 | ||
|
|
44a56b20ac | ||
|
|
f99956b550 | ||
|
|
1f02348d6c | ||
|
|
421ff03018 | ||
|
|
5d3468e0d1 | ||
|
|
40a8dddde1 | ||
|
|
9bdefd7984 | ||
|
|
d233a2e314 | ||
|
|
d90023af5f | ||
|
|
964c6508b1 | ||
|
|
4e3c6f59cc | ||
|
|
801582b410 | ||
|
|
6d35340556 | ||
|
|
1161649446 | ||
|
|
13577a809e | ||
|
|
afc219a765 | ||
|
|
21aa4b2713 | ||
|
|
63f4dca78f | ||
|
|
0984f70e08 | ||
|
|
f26bd45da3 | ||
|
|
a3adc1701b | ||
|
|
7ab275214b | ||
|
|
0428c429a1 | ||
|
|
14fb2cc820 | ||
|
|
faf033957c | ||
|
|
0555e25a41 | ||
|
|
cde8c0a0e6 | ||
|
|
5b525e86a5 | ||
|
|
df77a98edf | ||
|
|
c23fa0fc97 | ||
|
|
08c0571613 | ||
|
|
f2b210a901 | ||
|
|
66ac4acc6c | ||
|
|
cd0f25df5f | ||
|
|
0f46038589 | ||
|
|
1105cf841b | ||
|
|
a298a6d82b | ||
|
|
5f33acefd1 | ||
|
|
849ba01b8b | ||
|
|
29c9cb3188 | ||
|
|
ec4d49e129 | ||
|
|
d84b245c63 | ||
|
|
73797b2552 | ||
|
|
dfef525920 | ||
|
|
7f017ae1c9 | ||
|
|
65126716d7 | ||
|
|
1dcd6068dd | ||
|
|
02f16dc799 | ||
|
|
aa21c457f2 | ||
|
|
9f26e6d6b3 | ||
|
|
8d3e782e05 | ||
|
|
1c671bad33 | ||
|
|
88cd9570b6 | ||
|
|
c423ad17e7 | ||
|
|
9114b267a8 | ||
|
|
70c3f3ade5 | ||
|
|
1934304acf | ||
|
|
c8e57e8159 | ||
|
|
1e49f5e1e6 | ||
|
|
49aae94bed | ||
|
|
e191bf7b9f | ||
|
|
f520e150eb | ||
|
|
75db37c564 | ||
|
|
886b503e4b | ||
|
|
a2f0444c6e | ||
|
|
66100b640f | ||
|
|
de5207244b | ||
|
|
cae8132690 | ||
|
|
a1a847bfb5 | ||
|
|
3ac95de01a | ||
|
|
da7af36a13 | ||
|
|
3f25104caf | ||
|
|
6b1933d992 | ||
|
|
5163803a63 | ||
|
|
fee7c78a83 | ||
|
|
8fc544b03c | ||
|
|
d62d5c4b33 | ||
|
|
ab3eaff7c4 | ||
|
|
85e83ea968 | ||
|
|
0269c6fb03 | ||
|
|
23e536af49 | ||
|
|
cd56929097 | ||
|
|
7aa38561f7 | ||
|
|
22a00cfbf2 | ||
|
|
8c06cb9130 | ||
|
|
b5233ba323 | ||
|
|
013720f0e7 | ||
|
|
365b4d95a4 | ||
|
|
5bb44cca81 | ||
|
|
15f9f8c853 | ||
|
|
04676a5085 | ||
|
|
cf44351dd7 | ||
|
|
614e0bbe23 | ||
|
|
3eb7b0ee78 | ||
|
|
02a1600994 | ||
|
|
f6868c5a77 | ||
|
|
f92f2f8afe | ||
|
|
0cc04eaa2a | ||
|
|
57290d63fd | ||
|
|
33b246a624 | ||
|
|
dc5ce5989f | ||
|
|
7ea108fa67 | ||
|
|
386cf25088 | ||
|
|
a514c51e55 | ||
|
|
91b8f3f171 | ||
|
|
8f5d475079 | ||
|
|
f5a4e279bc | ||
|
|
571447afe8 | ||
|
|
9260e5ca4f | ||
|
|
971e72514f | ||
|
|
0ee5ac5367 | ||
|
|
935d119c82 | ||
|
|
01fe32ee53 | ||
|
|
19ea6b1405 | ||
|
|
a4d33cdf48 | ||
|
|
a992a3cb9e | ||
|
|
95d688957f | ||
|
|
a9b350fb3a | ||
|
|
afe7dfd3b9 | ||
|
|
6b6c3de2ae | ||
|
|
1b70f687fa | ||
|
|
520d474ec6 | ||
|
|
deec7ca65c | ||
|
|
dff7454371 | ||
|
|
e50eedf3c5 | ||
|
|
341776b03b | ||
|
|
79f7afb125 | ||
|
|
2f3d9717ee | ||
|
|
9ad7524659 | ||
|
|
4ec413da32 | ||
|
|
61d53e606d | ||
|
|
d67b7daa1d | ||
|
|
2ab70cf0c6 | ||
|
|
99664706e2 | ||
|
|
a745041b7d | ||
|
|
0dd97f7c87 | ||
|
|
69a823c72d | ||
|
|
0f193d2d21 | ||
|
|
9832fdd6ef | ||
|
|
507c679b9b | ||
|
|
0b42cf8a36 | ||
|
|
10175e4a65 | ||
|
|
18831f985c | ||
|
|
6d4e6bf118 | ||
|
|
a8558bc5a6 | ||
|
|
bbf37f2534 | ||
|
|
d332ff3c77 | ||
|
|
eb92ec3dc6 | ||
|
|
dee8fbbc1e | ||
|
|
75303c61d8 | ||
|
|
af99826ef4 | ||
|
|
af1c6f973a | ||
|
|
b5cd777ad6 | ||
|
|
ae91c3cce3 | ||
|
|
5de4e79fc8 | ||
|
|
4d34b06fb3 | ||
|
|
22a413ce9f | ||
|
|
01855ca328 | ||
|
|
225bc5836a | ||
|
|
941cdf921d | ||
|
|
58ae95670b | ||
|
|
4e19ab9fcd | ||
|
|
6cb612e7e3 | ||
|
|
35add841ee | ||
|
|
f6e38d7ac9 | ||
|
|
855fbf1c11 | ||
|
|
e5ec21215e | ||
|
|
91bbf4219d | ||
|
|
f4c1586454 | ||
|
|
9a71d9d1c6 | ||
|
|
bb0310a353 | ||
|
|
f8408562f8 | ||
|
|
8eac78f8ef | ||
|
|
d57751d2fb | ||
|
|
e062b9f70d | ||
|
|
c837141832 | ||
|
|
a415a78d71 | ||
|
|
5255b919ae | ||
|
|
b12f9c76e2 | ||
|
|
575b814119 | ||
|
|
661bbacfc7 | ||
|
|
d04962f788 | ||
|
|
ec8142391a | ||
|
|
59bec5fade | ||
|
|
5230e610fc | ||
|
|
b81419a9fd | ||
|
|
2b9ee006d8 | ||
|
|
609b40f1a1 | ||
|
|
1e76448ced | ||
|
|
967a59d2c0 | ||
|
|
fbf94ac900 | ||
|
|
a11c144609 | ||
|
|
4848092bf8 | ||
|
|
948f3decb4 | ||
|
|
7d6747cec9 | ||
|
|
420e7b03ec | ||
|
|
b31015a927 | ||
|
|
bd55d43333 | ||
|
|
98020cedf7 | ||
|
|
cbf213915c | ||
|
|
93371999ee | ||
|
|
6289d673a0 | ||
|
|
0adda755a2 | ||
|
|
0782ed3274 | ||
|
|
d7ec136ffb | ||
|
|
dbdf2878ab | ||
|
|
8654fca058 | ||
|
|
05a8097779 | ||
|
|
c06ec1f132 | ||
|
|
fb83319d9c | ||
|
|
e42a7a1862 | ||
|
|
8cbf3ce22c | ||
|
|
1997093e21 | ||
|
|
f23b879ff5 | ||
|
|
8b2d233283 | ||
|
|
40fc688765 | ||
|
|
30f61b0549 | ||
|
|
ad7d8af6d1 | ||
|
|
f293345aa8 | ||
|
|
e18ad5a96b | ||
|
|
dd232b95b7 | ||
|
|
51861998c7 | ||
|
|
e346210c03 | ||
|
|
0d44f83fcc | ||
|
|
40b5f89ee0 | ||
|
|
eed9550993 | ||
|
|
cf96d1b0af | ||
|
|
3d25b52a10 | ||
|
|
437f6250c5 | ||
|
|
334cb8f222 | ||
|
|
03878edf77 | ||
|
|
cacdfc2f6e | ||
|
|
56c00ed1ea | ||
|
|
513d2f723f | ||
|
|
48429252c1 | ||
|
|
d459a5b8e6 | ||
|
|
9566232422 | ||
|
|
dc654a925c | ||
|
|
76366e8e5c | ||
|
|
31788ed4c7 | ||
|
|
781d2b02de | ||
|
|
8b5fc2143f | ||
|
|
5670677cb6 | ||
|
|
32b9dcecc7 | ||
|
|
ac12b725ea | ||
|
|
e1783bc686 | ||
|
|
c4f143eb96 | ||
|
|
94054924a9 | ||
|
|
c639611002 | ||
|
|
69061fed82 | ||
|
|
3075d96d44 | ||
|
|
7fec997ecf | ||
|
|
7355a35e4b | ||
|
|
e585377e68 | ||
|
|
9cd7bd4d5f | ||
|
|
a108d84f88 | ||
|
|
1e83dd2229 | ||
|
|
d02ca923e2 | ||
|
|
f82f7eb1d8 | ||
|
|
0d472b29ec | ||
|
|
7a21067bb9 | ||
|
|
ed02d34fbc | ||
|
|
8b0b295569 | ||
|
|
59a108c0a6 | ||
|
|
83ebc8bdb6 | ||
|
|
21a7fa8063 | ||
|
|
83463dfbee | ||
|
|
c3c50c0030 | ||
|
|
e85ab7ac9b | ||
|
|
a11463a02f | ||
|
|
8023b3153a |
@@ -1,8 +1,6 @@
|
|||||||
*.eps
|
|
||||||
*.log
|
*.log
|
||||||
*.o
|
*.o
|
||||||
*.pdf
|
*.pdf
|
||||||
*.png
|
|
||||||
*.stamp
|
*.stamp
|
||||||
*.trs
|
*.trs
|
||||||
*~
|
*~
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
3.2.91
|
3.6.2
|
||||||
|
|||||||
+335
-158
@@ -1,180 +1,346 @@
|
|||||||
# Travis defines and exports CC and CXX *after* we have defined our
|
version: ~> 1.0
|
||||||
# environment variables via 'env'. So, do not use 'env' to define
|
|
||||||
# them. Instead, put their definitions in MATRIX_EVAL, which we eval
|
|
||||||
# after the definitions from Travis.
|
|
||||||
|
|
||||||
language: cpp
|
# If the language is set to C or C++, Travis defines and exports CC
|
||||||
|
# and CXX *after* we have defined our environment variables via 'env'.
|
||||||
|
language: minimal
|
||||||
|
|
||||||
env:
|
# Run in two steps:
|
||||||
global:
|
# 1. Build the tarball
|
||||||
# ICC serial number.
|
# On a modern distro, with all the needed dependencies, including the whole git history.
|
||||||
secure: ED3w6rzxuE6tVu3oyxha2MoGMRzRQCtinvr9uor1gw9TGKB80esTLx4KyX0xHemUdyQVarFDDQfVS5rf7jSDY8XiWIR6O+2Af9/30gb+8eyngyvACu7E28n+1XHmYWIEHsbvB9mic6C60FBj5sPcDnFWZeyttGL0WooSjYHiw1Egafwqbeu1mD3Aet9OI9VaLQvy0KcWAdVrYWSI9UWLvLM+xPVUjPFko4oS+dTlETzVnmn6JFbZX1OKONtfcvdoDRFBzs3iHm5dQUt/Fz+y/DtKSuvF3zvePHSgF6c8URbEPPjBdh87gkovSLyy+83fVeh4WMkF8b+dGZmikQv6kRsjKJdbQrS8tiMhZlORC5Gfmn4HXNgmapL+paUweakH7UZQHm6d5SZoBgCHNazfqMrywbZsZkGvZTDQIVG1Be7Lhh2BDFbPhPZNDvI9XYiqZP0QSb0BVfeO+AUSRcUPM7TvarxB74jYdfpTBu7sqJP6dSwhcDTEUhHmuLGjzsNm3uTZe8SUw/TGGx5uPTXNsCjJq6ClIOAIYXZTXLbBmIL/NBWCy0MUpD+9zsiknU7vzzq1RfgCCExhvYgosTjBLcX1kKI+eRSU5M44e+xCg4xx0m9WfafbKbhA20FfnWxCFIkZeVpkOOsexJ9zfe0SflVLxkd7vmci5SCBixLVbN0=
|
# 2. Check it on various environments.
|
||||||
|
# Less dependencies, and little git content (we would like to have none, but it's not
|
||||||
|
# an option on Travis).
|
||||||
|
stages:
|
||||||
|
- dist
|
||||||
|
- check
|
||||||
|
|
||||||
matrix:
|
# The 'check' jobs do not need the repo at all, only the 'dist'
|
||||||
|
# does. Let's save time, bandwith, energy, and polar bears.
|
||||||
|
git:
|
||||||
|
clone: false
|
||||||
|
|
||||||
|
# matrix.include and jobs.include are aliases
|
||||||
|
# (https://docs.travis-ci.com/user/conditional-builds-stages-jobs/).
|
||||||
|
jobs:
|
||||||
include:
|
include:
|
||||||
|
- stage: dist
|
||||||
|
name: "Make dist"
|
||||||
|
git:
|
||||||
|
clone: true
|
||||||
|
dist: bionic
|
||||||
|
script:
|
||||||
|
- sudo apt-get install -qq autoconf automake autopoint flex gettext graphviz help2man m4 texinfo
|
||||||
|
- autoconf --version
|
||||||
|
- automake --version
|
||||||
|
- autopoint --version
|
||||||
|
- dot -V
|
||||||
|
- gettext --version
|
||||||
|
- help2man --version
|
||||||
|
- makeinfo --version
|
||||||
|
- m4 --version
|
||||||
|
|
||||||
|
# Travis makes a shallow clone, but we need it in full to build the ChangeLog and apply the fixes in git-log-fix.
|
||||||
|
- git fetch --unshallow || true
|
||||||
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
|
- ./bootstrap
|
||||||
|
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
||||||
|
- make -j2
|
||||||
|
- make -j2 dist-xz
|
||||||
|
# Can help understanding why we get "dirty" tarballs.
|
||||||
|
- git status
|
||||||
|
- dist=$(echo bison*.xz)
|
||||||
|
|
||||||
|
# Unfortunately we cannot deterministically know the name of the tarball without the full
|
||||||
|
# git history (because git describe --abbrev=4 may use more than 4 characters if there are
|
||||||
|
# conflicts).
|
||||||
|
#
|
||||||
|
# So for the sake of the 'check' jobs (that don't even have the repo at all), also expose this
|
||||||
|
# tarball on a name that only depends on the Travis build number.
|
||||||
|
#
|
||||||
|
# Without -b -, exit status is always 0.
|
||||||
|
#
|
||||||
|
# If we rerun a job that was already uploaded, 'ln -s' will fail: remove beforehand.
|
||||||
|
- sftp -b - [email protected] <<< "put $dist"$'\n'"-rm bison-$TRAVIS_BUILD_NUMBER.tar.xz"$'\n'"ln -s $dist bison-$TRAVIS_BUILD_NUMBER.tar.xz"
|
||||||
|
|
||||||
## ------- ##
|
## ------- ##
|
||||||
## First. ##
|
## First. ##
|
||||||
## ------- ##
|
## ------- ##
|
||||||
|
|
||||||
# Start with three completely different environments, to get
|
# Start with three completely different environments, to get errors asap.
|
||||||
# errors asap.
|
|
||||||
|
|
||||||
- name: "GCC 7 -O3"
|
- name: "GCC 10 -O3"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
addons:
|
addons: &gcc10
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||||
packages:
|
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||||
- g++-7
|
packages: g++-10
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
|
- CC=gcc-10
|
||||||
|
- CXX=g++-10
|
||||||
|
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||||
|
|
||||||
# ASAN is time consuming, and we timeout the 50min granted by
|
# ASAN is time consuming, and we timeout the 50min granted by
|
||||||
# Travis if we run all the tests in on go. Run in two parts.
|
# Travis if we run all the tests in one go. Run in two parts.
|
||||||
- name: "Clang 7 libc++ and ASAN part 1"
|
- name: "Clang 10 libc++ and ASAN part 1"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
addons:
|
addons: &clang10
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- llvm-toolchain-xenial-7
|
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||||
- ubuntu-toolchain-r-test
|
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||||
|
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||||
|
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||||
packages:
|
packages:
|
||||||
- clang-7
|
- clang-10
|
||||||
- libc++-7-dev
|
- libc++-10-dev
|
||||||
- libc++abi-7-dev
|
- libc++abi-10-dev
|
||||||
env:
|
env:
|
||||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||||
- MATRIX_EVAL="PART=1 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
|
- CC='clang-10 -fsanitize=address'
|
||||||
|
- CXX='clang++-10 -fsanitize=address -stdlib=libc++'
|
||||||
|
- PART=1
|
||||||
|
|
||||||
- name: "Clang 7 libc++ and ASAN part 2"
|
- name: "Clang 10 libc++ and ASAN part 2"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
addons:
|
addons: *clang10
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- llvm-toolchain-xenial-7
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- clang-7
|
|
||||||
- libc++-7-dev
|
|
||||||
- libc++abi-7-dev
|
|
||||||
env:
|
env:
|
||||||
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
|
||||||
- MATRIX_EVAL="PART=2 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
|
- CC='clang-10 -fsanitize=address'
|
||||||
|
- CXX='clang++-10 -fsanitize=address -stdlib=libc++'
|
||||||
|
- PART=2
|
||||||
|
|
||||||
- name: "ICC"
|
- name: "ICC"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
compiler: icc
|
||||||
env:
|
env:
|
||||||
# ICC's warnings are often very wrong (e.g., it thinks foo ?
|
- CC=icc
|
||||||
# "bar" : "baz" is char* instead of const char*), so don't try
|
- CXX=icpc
|
||||||
# to work around the, and obviously, don't die on them.
|
install:
|
||||||
- MATRIX_EVAL="CC=icc && CXX=icpc"
|
- source /opt/intel/inteloneapi/compiler/latest/env/vars.sh
|
||||||
- MAKE_ARGS='WERROR_CFLAGS= WERROR_CXXFLAGS='
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- sourceline: 'deb https://apt.repos.intel.com/oneapi all main'
|
||||||
|
key_url: 'https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB'
|
||||||
|
packages:
|
||||||
|
- intel-oneapi-icc
|
||||||
|
|
||||||
|
- name: "ARM64: GCC 10 -O3 part 1"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
dist: bionic
|
||||||
|
addons: *gcc10
|
||||||
|
env:
|
||||||
|
- CC=gcc-10
|
||||||
|
- CXX=g++-10
|
||||||
|
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||||
|
- PART=1
|
||||||
|
|
||||||
|
# GCC10 on PPC seems to be buggy.
|
||||||
|
# E.g., https://travis-ci.org/github/akimd/bison/jobs/687812428.
|
||||||
|
- name: "PPC64le: GCC 9 part 1"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
arch: ppc64le
|
||||||
|
dist: bionic
|
||||||
|
addons: *gcc10
|
||||||
|
env:
|
||||||
|
- CC=gcc-9
|
||||||
|
- CXX=g++-9
|
||||||
|
- CONFIGUREFLAGS='CFLAGS=-O3 CXXFLAGS=-O3'
|
||||||
|
- PART=1
|
||||||
|
|
||||||
|
- name: "s390x: GCC 10 part 1"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
arch: s390x
|
||||||
|
dist: bionic
|
||||||
|
addons: *gcc10
|
||||||
|
env:
|
||||||
|
- CC=gcc-10
|
||||||
|
- CXX=g++-10
|
||||||
|
- CONFIGUREFLAGS='CFLAGS=-O3 CXXFLAGS=-O3'
|
||||||
|
- PART=1
|
||||||
|
|
||||||
## ----- ##
|
## ----- ##
|
||||||
## GCC. ##
|
## GCC. ##
|
||||||
## ----- ##
|
## ----- ##
|
||||||
|
|
||||||
#- name: "GCC 8 with sanitizers"
|
- name: "GCC 9 with sanitizers part 1"
|
||||||
# os: linux
|
stage: check
|
||||||
# dist: xenial
|
os: linux
|
||||||
# addons:
|
dist: bionic
|
||||||
# apt:
|
addons:
|
||||||
# sources:
|
apt:
|
||||||
# - ubuntu-toolchain-r-test
|
sources:
|
||||||
# packages:
|
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||||
# - g++-8
|
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||||
# env:
|
packages: g++-9
|
||||||
# # Can't use UBSAN: I get:
|
env:
|
||||||
# # configure:4951: gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer conftest.c
|
- CC='gcc-9 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||||
# # /usr/bin/ld: unrecognized option '--push-state' (on trusty)
|
- CXX='g++-9 -fsanitize=undefined,address -fno-omit-frame-pointer'
|
||||||
# # /usr/bin/ld: unrecognized option '--push-state--no-as-needed' (on xenial)
|
- CONFIGUREFLAGS='CFLAGS=-O1 CXXFLAGS=-O1'
|
||||||
# #
|
- PART=1
|
||||||
# # https://stackoverflow.com/questions/50024731/ suggests using the gold linker.
|
|
||||||
# - MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
|
- name: "GCC 8"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages: g++-8
|
||||||
|
env:
|
||||||
|
- CC=gcc-8
|
||||||
|
- CXX=g++-8
|
||||||
|
|
||||||
|
- name: "GCC 7"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages: g++-7
|
||||||
|
env:
|
||||||
|
- CC=gcc-7
|
||||||
|
- CXX=g++-7
|
||||||
|
|
||||||
- name: "GCC 6"
|
- name: "GCC 6"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-6
|
||||||
packages:
|
|
||||||
- g++-6
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
- CC=gcc-6
|
||||||
|
- CXX=g++-6
|
||||||
|
|
||||||
- name: "GCC 5"
|
- name: "GCC 5"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-5
|
||||||
packages:
|
|
||||||
- g++-5
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
- CC=gcc-5
|
||||||
|
- CXX=g++-5
|
||||||
|
|
||||||
- name: "GCC 4.9"
|
- name: "GCC 4.9"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.9
|
||||||
packages:
|
|
||||||
- g++-4.9
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
|
- CC=gcc-4.9
|
||||||
|
- CXX=g++-4.9
|
||||||
|
|
||||||
- name: "GCC 4.8"
|
- name: "GCC 4.8"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.8
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
|
- CC=gcc-4.8
|
||||||
|
- CXX=g++-4.8
|
||||||
|
|
||||||
- name: "GCC 4.7"
|
- name: "GCC 4.7"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.7
|
||||||
packages:
|
|
||||||
- g++-4.7
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
|
- CC=gcc-4.7
|
||||||
|
- CXX=g++-4.7
|
||||||
|
|
||||||
- name: "GCC 4.6"
|
- name: "GCC 4.6"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: ubuntu-toolchain-r-test
|
||||||
- ubuntu-toolchain-r-test
|
packages: g++-4.6
|
||||||
packages:
|
|
||||||
- g++-4.6
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=gcc-4.6 && CXX=g++-4.6"
|
- CC=gcc-4.6
|
||||||
|
- CXX=g++-4.6
|
||||||
|
|
||||||
## ------- ##
|
## ------- ##
|
||||||
## Clang. ##
|
## Clang. ##
|
||||||
## ------- ##
|
## ------- ##
|
||||||
|
|
||||||
- name: "Clang 6 -O3 and libc++"
|
- name: "Clang 9 -O3"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
# See https://github.com/travis-ci/apt-source-safelist/issues/410.
|
||||||
|
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||||
|
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||||
|
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||||
|
packages:
|
||||||
|
- clang-9
|
||||||
|
- libc++-9-dev
|
||||||
|
- libc++abi-9-dev
|
||||||
|
env:
|
||||||
|
- CC='clang-9'
|
||||||
|
- CXX='clang++-9 -stdlib=libc++'
|
||||||
|
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
||||||
|
|
||||||
|
- name: "Clang 8"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- clang-8
|
||||||
|
- libc++-8-dev
|
||||||
|
- libc++abi-8-dev
|
||||||
|
env:
|
||||||
|
- CC=clang-8
|
||||||
|
- CXX='clang++-8 -stdlib=libc++'
|
||||||
|
|
||||||
|
- name: "Clang 7"
|
||||||
|
stage: check
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- clang-7
|
||||||
|
- libc++-7-dev
|
||||||
|
- libc++abi-7-dev
|
||||||
|
env:
|
||||||
|
- CC=clang-7
|
||||||
|
- CXX='clang++-7 -stdlib=libc++'
|
||||||
|
|
||||||
|
- name: "Clang 6 and libc++"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
@@ -186,47 +352,49 @@ matrix:
|
|||||||
- clang-6.0
|
- clang-6.0
|
||||||
- libc++-dev
|
- libc++-dev
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-6.0 && CXX='clang++-6.0 -stdlib=libc++'"
|
- CC=clang-6.0
|
||||||
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
|
- CXX='clang++-6.0 -stdlib=libc++'
|
||||||
|
|
||||||
- name: "Clang 5"
|
- name: "Clang 5"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: llvm-toolchain-xenial-5.0
|
||||||
- llvm-toolchain-xenial-5.0
|
|
||||||
packages:
|
packages:
|
||||||
- clang-5.0
|
- clang-5.0
|
||||||
- libc++-dev
|
- libc++-dev
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
|
- CC='clang-5.0'
|
||||||
|
- CXX='clang++-5.0'
|
||||||
|
|
||||||
- name: "Clang 4"
|
- name: "Clang 4"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: llvm-toolchain-xenial-4.0
|
||||||
- llvm-toolchain-xenial-4.0
|
packages: clang-4.0
|
||||||
packages:
|
|
||||||
- clang-4.0
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
|
- CC=clang-4.0
|
||||||
|
- CXX=clang++-4.0
|
||||||
|
|
||||||
- name: "Clang 3.9"
|
- name: "Clang 3.9"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources: llvm-toolchain-xenial-3.9
|
||||||
- llvm-toolchain-xenial-3.9
|
packages: clang-3.9
|
||||||
packages:
|
|
||||||
- clang-3.9
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
|
- CC=clang-3.9
|
||||||
|
- CXX=clang++-3.9
|
||||||
|
|
||||||
- name: "Clang 3.8"
|
- name: "Clang 3.8"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
@@ -234,12 +402,13 @@ matrix:
|
|||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.8
|
- llvm-toolchain-precise-3.8
|
||||||
packages:
|
packages: clang-3.8
|
||||||
- clang-3.8
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
- CC=clang-3.8
|
||||||
|
- CXX=clang++-3.8
|
||||||
|
|
||||||
- name: "CLang 3.7"
|
- name: "CLang 3.7"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
@@ -247,12 +416,13 @@ matrix:
|
|||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- llvm-toolchain-precise-3.7
|
||||||
packages:
|
packages: clang-3.7
|
||||||
- clang-3.7
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
|
- CC=clang-3.7
|
||||||
|
- CXX=clang++-3.7
|
||||||
|
|
||||||
- name: "Clang 3.6"
|
- name: "Clang 3.6"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
@@ -260,12 +430,13 @@ matrix:
|
|||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.6
|
- llvm-toolchain-precise-3.6
|
||||||
packages:
|
packages: clang-3.6
|
||||||
- clang-3.6
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
|
- CC=clang-3.6
|
||||||
|
- CXX=clang++-3.6
|
||||||
|
|
||||||
- name: "Clang 3.5"
|
- name: "Clang 3.5"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
@@ -273,79 +444,85 @@ matrix:
|
|||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.5
|
- llvm-toolchain-precise-3.5
|
||||||
packages:
|
packages: clang-3.5
|
||||||
- clang-3.5
|
|
||||||
env:
|
env:
|
||||||
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
|
- CC=clang-3.5
|
||||||
|
- CXX=clang++-3.5
|
||||||
|
|
||||||
- name: "Clang 3.4"
|
- name: "Clang 3.4"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
# Not available on Xenial.
|
# Not available on Xenial.
|
||||||
dist: trusty
|
dist: trusty
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages: clang-3.4
|
||||||
- clang-3.4
|
|
||||||
env:
|
env:
|
||||||
# No versioned name installed, but beware that Travis installs
|
# No versioned name installed, but beware that Travis installs
|
||||||
# a more modern clang earlier in the default PATH.
|
# a more modern clang earlier in the default PATH.
|
||||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
- CC=/usr/bin/clang
|
||||||
|
- CXX=/usr/bin/clang++
|
||||||
|
|
||||||
- name: "Clang 3.3"
|
- name: "Clang 3.3"
|
||||||
|
stage: check
|
||||||
os: linux
|
os: linux
|
||||||
# Not available on Xenial.
|
# Not available on Xenial.
|
||||||
dist: trusty
|
dist: trusty
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages: clang-3.3
|
||||||
- clang-3.3
|
|
||||||
env:
|
env:
|
||||||
# See comment for 3.4.
|
# See comment for 3.4.
|
||||||
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
|
- CC=/usr/bin/clang
|
||||||
|
- CXX=/usr/bin/clang++
|
||||||
|
|
||||||
|
## From https://docs.gitlab.com/ce/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor.
|
||||||
|
## Applies to Travis too. Applied to all the 'script's (of all the jobs).
|
||||||
|
before_script:
|
||||||
|
- 'which ssh-agent || ( sudo apt-get install openssh-client -y )'
|
||||||
|
- eval "$(ssh-agent -s)"
|
||||||
|
# $SSH_PRIVATE_KEY is multiline. Use $'...' to register its value: $'-----BEGIN OPENSSH PRIVATE KEY-----\nXXXXX...\n...==\n-----END OPENSSH PRIVATE KEY-----'.
|
||||||
|
- echo "$SSH_PRIVATE_KEY" >/tmp/key.id_rsa
|
||||||
|
- chmod 600 /tmp/key.id_rsa
|
||||||
|
- ssh-add /tmp/key.id_rsa </dev/null
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- chmod 700 ~/.ssh
|
||||||
|
- echo '|1|bpc51UGxoDZjCPiwRlCStW32trI=|rfh6mLoLZv/vAvOVrpZXI1hTLxg= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIR+ckMoJTNXHvAQLHWSfrRnrNJGW2ZR6kr5pBVDGCkz1v1RcQ5rleq0NAt9kS3v4hgnuLiEVnK7KDRzcEH3ikc=' >>~/.ssh/known_hosts
|
||||||
|
- chmod 600 ~/.ssh/known_hosts
|
||||||
|
|
||||||
before_install:
|
# Applies only to the jobs that don't have a 'script', i.e., applies to all the 'check' jobs, but not the 'dist' one.
|
||||||
- eval "$MATRIX_EVAL"
|
script:
|
||||||
- env
|
# Beware not too leak $SSH_PRIVATE_KEY.
|
||||||
- sudo apt-get update -qq
|
# - env
|
||||||
- sudo apt-get install -qq autoconf automake autopoint doxygen flex gettext graphviz help2man m4 texinfo
|
- sudo apt-get install -qq doxygen flex m4
|
||||||
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
|
# Install and activate dmd.
|
||||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
|
||||||
# Install and activate dmd
|
|
||||||
- mkdir -p ~/dlang && wget https://dlang.org/install.sh -O ~/dlang/install.sh
|
- mkdir -p ~/dlang && wget https://dlang.org/install.sh -O ~/dlang/install.sh
|
||||||
- source $(source ~/dlang/install.sh dmd -a)
|
- source $(source ~/dlang/install.sh dmd -a) || true
|
||||||
- autoconf --version
|
|
||||||
- automake --version
|
|
||||||
- autopoint --version
|
|
||||||
- $CC --version
|
- $CC --version
|
||||||
- $CXX --version
|
- $CXX --version
|
||||||
- dmd --version
|
- dmd --version || true
|
||||||
- doxygen --version
|
- doxygen --version
|
||||||
- flex --version
|
- flex --version
|
||||||
- gettext --version
|
|
||||||
- dot -V
|
|
||||||
- help2man --version
|
|
||||||
- ld --version
|
- ld --version
|
||||||
- m4 --version
|
- m4 --version
|
||||||
- makeinfo --version
|
|
||||||
|
|
||||||
script:
|
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
||||||
- git tag -l
|
|
||||||
# For some reasons, sometimes the checkout does not have any tags,
|
|
||||||
# so `git describe` fails, so bootstrap fails.
|
|
||||||
- git describe || git tag v3.0 -m "Fake version 3.0."
|
|
||||||
- git describe
|
|
||||||
# Unset this variable, otherwise, Java programs' stderr is cluttered
|
# Unset this variable, otherwise, Java programs' stderr is cluttered
|
||||||
# with `Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m`, which makes
|
# with `Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m`, which makes
|
||||||
# the test suite fail.
|
# the test suite fail.
|
||||||
- unset _JAVA_OPTIONS
|
- unset _JAVA_OPTIONS
|
||||||
- ./bootstrap
|
|
||||||
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
|
# Fail fast from now on.
|
||||||
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
|
- set -e
|
||||||
|
- sftp [email protected]:bison-$TRAVIS_BUILD_NUMBER.tar.xz
|
||||||
|
- tar xf bison-$TRAVIS_BUILD_NUMBER.tar.xz
|
||||||
|
- dir=$(tar tf bison-$TRAVIS_BUILD_NUMBER.tar.xz | sed 1q)
|
||||||
|
- cd $dir
|
||||||
|
- mkdir _build
|
||||||
|
- cd _build
|
||||||
|
- ../configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
|
||||||
- make -j2 $MAKE_ARGS
|
- make -j2 $MAKE_ARGS
|
||||||
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat test-suite.log && cat tests/testsuite.log && false; }; fi
|
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat test-suite.log && cat tests/testsuite.log && false; }; fi
|
||||||
- if test ${PART-1} = 1; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
- if test ${PART-2} = 2; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||||
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
|
||||||
|
|
||||||
after_script:
|
|
||||||
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ and nasty bugs.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1998-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 1998-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26733,7 +26733,7 @@
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1987-1988, 1991-2015, 2018-2019 Free Software
|
Copyright (C) 1987-1988, 1991-2015, 2018-2020 Free Software
|
||||||
Foundation, Inc.
|
Foundation, Inc.
|
||||||
|
|
||||||
Copying and distribution of this file, with or without
|
Copying and distribution of this file, with or without
|
||||||
|
|||||||
+24
-6
@@ -1,6 +1,6 @@
|
|||||||
## Process this file with automake to produce Makefile.in.
|
## Process this file with automake to produce Makefile.in.
|
||||||
|
|
||||||
# Copyright (C) 2001-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2001-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
AUTOMAKE_OPTIONS = subdir-objects
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
SUBDIRS = po runtime-po .
|
SUBDIRS = po runtime-po gnulib-po .
|
||||||
|
|
||||||
# Files installed for use by Automake.
|
# Files installed for use by Automake.
|
||||||
aclocaldir = @aclocaldir@
|
aclocaldir = @aclocaldir@
|
||||||
@@ -29,12 +29,12 @@ EXTRA_DIST = .prev-version .version cfg.mk PACKAGING \
|
|||||||
|
|
||||||
dist_doc_DATA = AUTHORS COPYING NEWS README THANKS TODO
|
dist_doc_DATA = AUTHORS COPYING NEWS README THANKS TODO
|
||||||
|
|
||||||
# Let generated files (e.g., from exampkles/) depend on this variable,
|
# Let generated files (e.g., from examples/) depend on this variable,
|
||||||
# to make sure they are regenerated when there are changes in Bison.
|
# to make sure they are regenerated when there are changes in Bison.
|
||||||
#
|
#
|
||||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||||
# in srcdir, including during distcheck, which is forbidden.
|
# in srcdir, including during distcheck, which is forbidden.
|
||||||
dependencies = $(BISON_IN) $(dist_skeletons_DATA)
|
dependencies = $(BISON_IN) $(src_bison_SOURCES) $(dist_skeletons_DATA)
|
||||||
|
|
||||||
## Running the bison from this tarball. To generate our own parser,
|
## Running the bison from this tarball. To generate our own parser,
|
||||||
## but also to run the tests. Of course, you ought to keep a sane
|
## but also to run the tests. Of course, you ought to keep a sane
|
||||||
@@ -42,7 +42,8 @@ dependencies = $(BISON_IN) $(dist_skeletons_DATA)
|
|||||||
BISON = $(top_builddir)/tests/bison
|
BISON = $(top_builddir)/tests/bison
|
||||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||||
YACC = $(BISON) -o y.tab.c
|
YACC = $(BISON) -o y.tab.c
|
||||||
AM_YFLAGS = -d -v -Werror -Wall -Wno-yacc --report=all
|
AM_YFLAGS_WITH_LINES = --defines -Werror -Wall,dangling-alias --report=all
|
||||||
|
AM_YFLAGS = $(AM_YFLAGS_WITH_LINES) --no-lines
|
||||||
|
|
||||||
# Initialization before completion by local.mk's.
|
# Initialization before completion by local.mk's.
|
||||||
AM_CFLAGS = $(WARN_CFLAGS)
|
AM_CFLAGS = $(WARN_CFLAGS)
|
||||||
@@ -87,9 +88,22 @@ clean-local:
|
|||||||
BUILT_SOURCES += $(top_srcdir)/.version
|
BUILT_SOURCES += $(top_srcdir)/.version
|
||||||
$(top_srcdir)/.version: configure
|
$(top_srcdir)/.version: configure
|
||||||
echo $(VERSION) > $@-t && mv $@-t $@
|
echo $(VERSION) > $@-t && mv $@-t $@
|
||||||
dist-hook: gen-ChangeLog
|
dist-hook: gen-ChangeLog gen-synclines
|
||||||
echo $(VERSION) > $(distdir)/.tarball-version
|
echo $(VERSION) > $(distdir)/.tarball-version
|
||||||
|
|
||||||
|
# When generating a release, include the #lines in Bison's parser. Do it
|
||||||
|
# only if needed. In particular, distcheck runs dist with read-only
|
||||||
|
# sources, so don't try to update src/parse-gram.c: we don't have the
|
||||||
|
# permissions.
|
||||||
|
.PHONY: gen-synclines
|
||||||
|
gen-synclines:
|
||||||
|
cd $(distdir) && \
|
||||||
|
if ! grep '#line' src/parse-gram.c >/dev/null 2>&1; then \
|
||||||
|
$(abs_top_builddir)/tests/bison \
|
||||||
|
$(AM_YFLAGS_WITH_LINES) src/parse-gram.y \
|
||||||
|
-o src/parse-gram.c; \
|
||||||
|
fi
|
||||||
|
|
||||||
.PHONY: update-b4-copyright update-package-copyright-year
|
.PHONY: update-b4-copyright update-package-copyright-year
|
||||||
update-b4-copyright:
|
update-b4-copyright:
|
||||||
$(AM_V_GEN)find $(srcdir)/data -type f \
|
$(AM_V_GEN)find $(srcdir)/data -type f \
|
||||||
@@ -113,3 +127,7 @@ gen-ChangeLog:
|
|||||||
--since=$(gen_start_date) > $$cl.tmp && \
|
--since=$(gen_start_date) > $$cl.tmp && \
|
||||||
mv -f $$cl.tmp $$cl; \
|
mv -f $$cl.tmp $$cl; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Useful to debug.
|
||||||
|
.c.i:
|
||||||
|
$(CC) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -o $@ -E $<
|
||||||
|
|||||||
@@ -1,12 +1,701 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.6.3 (2020-06-03) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Incorrect comments in the generated parsers.
|
||||||
|
|
||||||
|
Warnings in push parsers (yacc.c).
|
||||||
|
|
||||||
|
Incorrect display of gotos in LAC traces (lalr1.cc).
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.6.2 (2020-05-17) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Some tests were fixed.
|
||||||
|
|
||||||
|
When token aliases contain comment delimiters:
|
||||||
|
|
||||||
|
%token FOO "/* foo */"
|
||||||
|
|
||||||
|
bison used to emit "nested" comments, which is invalid C.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.6.1 (2020-05-10) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Restored ANSI-C compliance in yacc.c.
|
||||||
|
|
||||||
|
GNU readline portability issues.
|
||||||
|
|
||||||
|
In C++, yy::parser::symbol_name is now a public member, as was intended.
|
||||||
|
|
||||||
|
** New features
|
||||||
|
|
||||||
|
In C++, yy::parser::symbol_type now has a public name() member function.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.6 (2020-05-08) [stable]
|
||||||
|
|
||||||
|
** Backward incompatible changes
|
||||||
|
|
||||||
|
TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
|
||||||
|
|
||||||
|
The YYERROR_VERBOSE macro is no longer supported; the parsers that still
|
||||||
|
depend on it will now produce Yacc-like error messages (just "syntax
|
||||||
|
error"). It was superseded by the "%error-verbose" directive in Bison
|
||||||
|
1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that support
|
||||||
|
for YYERROR_VERBOSE would be removed. Note that since Bison 3.0
|
||||||
|
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
||||||
|
parse.error verbose".
|
||||||
|
|
||||||
|
** Deprecated features
|
||||||
|
|
||||||
|
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||||
|
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
|
||||||
|
It is deprecated and its support will be removed eventually.
|
||||||
|
|
||||||
|
** New features
|
||||||
|
|
||||||
|
*** Improved syntax error messages
|
||||||
|
|
||||||
|
Two new values for the %define parse.error variable offer more control to
|
||||||
|
the user. Available in all the skeletons (C, C++, Java).
|
||||||
|
|
||||||
|
**** %define parse.error detailed
|
||||||
|
|
||||||
|
The behavior of "%define parse.error detailed" is closely resembling that
|
||||||
|
of "%define parse.error verbose" with a few exceptions. First, it is safe
|
||||||
|
to use non-ASCII characters in token aliases (with 'verbose', the result
|
||||||
|
depends on the locale with which bison was run). Second, a yysymbol_name
|
||||||
|
function is exposed to the user, instead of the yytnamerr function and the
|
||||||
|
yytname table. Third, token internationalization is supported (see
|
||||||
|
below).
|
||||||
|
|
||||||
|
**** %define parse.error custom
|
||||||
|
|
||||||
|
With this directive, the user forges and emits the syntax error message
|
||||||
|
herself by defining the yyreport_syntax_error function. A new type,
|
||||||
|
yypcontext_t, captures the circumstances of the error, and provides the
|
||||||
|
user with functions to get details, such as yypcontext_expected_tokens to
|
||||||
|
get the list of expected token kinds.
|
||||||
|
|
||||||
|
A possible implementation of yyreport_syntax_error is:
|
||||||
|
|
||||||
|
int
|
||||||
|
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||||
|
fprintf (stderr, ": syntax error");
|
||||||
|
// Report the tokens expected at this point.
|
||||||
|
{
|
||||||
|
enum { TOKENMAX = 10 };
|
||||||
|
yysymbol_kind_t expected[TOKENMAX];
|
||||||
|
int n = yypcontext_expected_tokens (ctx, expected, TOKENMAX);
|
||||||
|
if (n < 0)
|
||||||
|
// Forward errors to yyparse.
|
||||||
|
res = n;
|
||||||
|
else
|
||||||
|
for (int i = 0; i < n; ++i)
|
||||||
|
fprintf (stderr, "%s %s",
|
||||||
|
i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
|
||||||
|
}
|
||||||
|
// Report the unexpected token.
|
||||||
|
{
|
||||||
|
yysymbol_kind_t lookahead = yypcontext_token (ctx);
|
||||||
|
if (lookahead != YYSYMBOL_YYEMPTY)
|
||||||
|
fprintf (stderr, " before %s", yysymbol_name (lookahead));
|
||||||
|
}
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
**** Token aliases internationalization
|
||||||
|
|
||||||
|
When the %define variable parse.error is set to `custom` or `detailed`,
|
||||||
|
one may specify which token aliases are to be translated using _(). For
|
||||||
|
instance
|
||||||
|
|
||||||
|
%token
|
||||||
|
PLUS "+"
|
||||||
|
MINUS "-"
|
||||||
|
<double>
|
||||||
|
NUM _("number")
|
||||||
|
<symrec*>
|
||||||
|
FUN _("function")
|
||||||
|
VAR _("variable")
|
||||||
|
|
||||||
|
In that case the user must define _() and N_(), and yysymbol_name returns
|
||||||
|
the translated symbol (i.e., it returns '_("variable")' rather that
|
||||||
|
'"variable"'). In Java, the user must provide an i18n() function.
|
||||||
|
|
||||||
|
*** List of expected tokens (yacc.c)
|
||||||
|
|
||||||
|
Push parsers may invoke yypstate_expected_tokens at any point during
|
||||||
|
parsing (including even before submitting the first token) to get the list
|
||||||
|
of possible tokens. This feature can be used to propose autocompletion
|
||||||
|
(see below the "bistromathic" example).
|
||||||
|
|
||||||
|
It makes little sense to use this feature without enabling LAC (lookahead
|
||||||
|
correction).
|
||||||
|
|
||||||
|
*** Returning the error token
|
||||||
|
|
||||||
|
When the scanner returns an invalid token or the undefined token
|
||||||
|
(YYUNDEF), the parser generates an error message and enters error
|
||||||
|
recovery. Because of that error message, most scanners that find lexical
|
||||||
|
errors generate an error message, and then ignore the invalid input
|
||||||
|
without entering the error-recovery.
|
||||||
|
|
||||||
|
The scanners may now return YYerror, the error token, to enter the
|
||||||
|
error-recovery mode without triggering an additional error message. See
|
||||||
|
the bistromathic for an example.
|
||||||
|
|
||||||
|
*** Deep overhaul of the symbol and token kinds
|
||||||
|
|
||||||
|
To avoid the confusion with types in programming languages, we now refer
|
||||||
|
to token and symbol "kinds" instead of token and symbol "types". The
|
||||||
|
documentation and error messages have been revised.
|
||||||
|
|
||||||
|
All the skeletons have been updated to use dedicated enum types rather
|
||||||
|
than integral types. Special symbols are now regular citizens, instead of
|
||||||
|
being declared in ad hoc ways.
|
||||||
|
|
||||||
|
**** Token kinds
|
||||||
|
|
||||||
|
The "token kind" is what is returned by the scanner, e.g., PLUS, NUMBER,
|
||||||
|
LPAREN, etc. While backward compatibility is of course ensured, users are
|
||||||
|
nonetheless invited to replace their uses of "enum yytokentype" by
|
||||||
|
"yytoken_kind_t".
|
||||||
|
|
||||||
|
This type now also includes tokens that were previously hidden: YYEOF (end
|
||||||
|
of input), YYUNDEF (undefined token), and YYerror (error token). They
|
||||||
|
now have string aliases, internationalized when internationalization is
|
||||||
|
enabled. Therefore, by default, error messages now refer to "end of file"
|
||||||
|
(internationalized) rather than the cryptic "$end", or to "invalid token"
|
||||||
|
rather than "$undefined".
|
||||||
|
|
||||||
|
Therefore in most cases it is now useless to define the end-of-line token
|
||||||
|
as follows:
|
||||||
|
|
||||||
|
%token T_EOF 0 "end of file"
|
||||||
|
|
||||||
|
Rather simply use "YYEOF" in your scanner.
|
||||||
|
|
||||||
|
**** Symbol kinds
|
||||||
|
|
||||||
|
The "symbol kinds" is what the parser actually uses. (Unless the
|
||||||
|
api.token.raw %define variable is used, the symbol kind of a terminal
|
||||||
|
differs from the corresponding token kind.)
|
||||||
|
|
||||||
|
They are now exposed as a enum, "yysymbol_kind_t".
|
||||||
|
|
||||||
|
This allows users to tailor the error messages the way they want, or to
|
||||||
|
process some symbols in a specific way in autocompletion (see the
|
||||||
|
bistromathic example below).
|
||||||
|
|
||||||
|
*** Modernize display of explanatory statements in diagnostics
|
||||||
|
|
||||||
|
Since Bison 2.7, output was indented four spaces for explanatory
|
||||||
|
statements. For example:
|
||||||
|
|
||||||
|
input.y:2.7-13: error: %type redeclaration for exp
|
||||||
|
input.y:1.7-11: previous declaration
|
||||||
|
|
||||||
|
Since the introduction of caret-diagnostics, it became less clear. This
|
||||||
|
indentation has been removed and submessages are displayed similarly as in
|
||||||
|
GCC:
|
||||||
|
|
||||||
|
input.y:2.7-13: error: %type redeclaration for exp
|
||||||
|
2 | %type <float> exp
|
||||||
|
| ^~~~~~~
|
||||||
|
input.y:1.7-11: note: previous declaration
|
||||||
|
1 | %type <int> exp
|
||||||
|
| ^~~~~
|
||||||
|
|
||||||
|
Contributed by Victor Morales Cayuela.
|
||||||
|
|
||||||
|
*** C++
|
||||||
|
|
||||||
|
The token and symbol kinds are yy::parser::token_kind_type and
|
||||||
|
yy::parser::symbol_kind_type.
|
||||||
|
|
||||||
|
The symbol_type::kind() member function allows to get the kind of a
|
||||||
|
symbol. This can be used to write unit tests for scanners, e.g.,
|
||||||
|
|
||||||
|
yy::parser::symbol_type t = make_NUMBER ("123");
|
||||||
|
assert (t.kind () == yy::parser::symbol_kind::S_NUMBER);
|
||||||
|
assert (t.value.as<int> () == 123);
|
||||||
|
|
||||||
|
** Documentation
|
||||||
|
|
||||||
|
*** User Manual
|
||||||
|
|
||||||
|
In order to avoid ambiguities with "type" as in "typing", we now refer to
|
||||||
|
the "token kind" (e.g., `PLUS`, `NUMBER`, etc.) rather than the "token
|
||||||
|
type". We now also refer to the "symbol type" (e.g., `PLUS`, `expr`,
|
||||||
|
etc.).
|
||||||
|
|
||||||
|
*** Examples
|
||||||
|
|
||||||
|
There are now examples/java: a very simple calculator, and a more complete
|
||||||
|
one (push-parser, location tracking, and debug traces).
|
||||||
|
|
||||||
|
The lexcalc example (a simple example in C based on Flex and Bison) now
|
||||||
|
also demonstrates location tracking.
|
||||||
|
|
||||||
|
|
||||||
|
A new C example, bistromathic, is a fully featured interactive calculator
|
||||||
|
using many Bison features: pure interface, push parser, autocompletion
|
||||||
|
based on the current parser state (using yypstate_expected_tokens),
|
||||||
|
location tracking, internationalized custom error messages, lookahead
|
||||||
|
correction, rich debug traces, etc.
|
||||||
|
|
||||||
|
It shows how to depend on the symbol kinds to tailor autocompletion. For
|
||||||
|
instance it recognizes the symbol kind "VARIABLE" to propose
|
||||||
|
autocompletion on the existing variables, rather than of the word
|
||||||
|
"variable".
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5.4 (2020-04-05) [stable]
|
||||||
|
|
||||||
|
** WARNING: Future backward-incompatibilities!
|
||||||
|
|
||||||
|
TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
|
||||||
|
|
||||||
|
Bison 3.6 will no longer support the YYERROR_VERBOSE macro; the parsers
|
||||||
|
that still depend on it will produce Yacc-like error messages (just
|
||||||
|
"syntax error"). It was superseded by the "%error-verbose" directive in
|
||||||
|
Bison 1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that
|
||||||
|
support for YYERROR_VERBOSE would be removed. Note that since Bison 3.0
|
||||||
|
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
||||||
|
parse.error verbose".
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Fix portability issues of the package itself on old compilers.
|
||||||
|
|
||||||
|
Fix api.token.raw support in Java.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5.3 (2020-03-08) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Error messages could quote lines containing zero-width characters (such as
|
||||||
|
\005) with incorrect styling. Fixes for similar issues with unexpectedly
|
||||||
|
short lines (e.g., the file was changed between parsing and diagnosing).
|
||||||
|
|
||||||
|
Several unlikely crashes found by fuzzing have been fixed.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Portability issues and minor cosmetic issues.
|
||||||
|
|
||||||
|
The lalr1.cc skeleton properly rejects unsupported values for parse.lac
|
||||||
|
(as yacc.c does).
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5.1 (2020-01-19) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Portability fixes.
|
||||||
|
|
||||||
|
Fix compiler warnings.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.5 (2019-12-11) [stable]
|
||||||
|
|
||||||
|
** Backward incompatible changes
|
||||||
|
|
||||||
|
Lone carriage-return characters (aka \r or ^M) in the grammar files are no
|
||||||
|
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||||
|
particular their locations.
|
||||||
|
|
||||||
|
In C++, line numbers and columns are now represented as 'int' not
|
||||||
|
'unsigned', so that integer overflow on positions is easily checkable via
|
||||||
|
'gcc -fsanitize=undefined' and the like. This affects the API for
|
||||||
|
positions. The default position and location classes now expose
|
||||||
|
'counter_type' (int), used to define line and column numbers.
|
||||||
|
|
||||||
|
** Deprecated features
|
||||||
|
|
||||||
|
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||||
|
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
|
||||||
|
It is deprecated and its support will be removed eventually.
|
||||||
|
|
||||||
|
** New features
|
||||||
|
|
||||||
|
*** Lookahead correction in C++
|
||||||
|
|
||||||
|
Contributed by Adrian Vogelsgesang.
|
||||||
|
|
||||||
|
The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
|
||||||
|
%define variable parse.lac.
|
||||||
|
|
||||||
|
*** Variable api.token.raw: Optimized token numbers (all skeletons)
|
||||||
|
|
||||||
|
In the generated parsers, tokens have two numbers: the "external" token
|
||||||
|
number as returned by yylex (which starts at 257), and the "internal"
|
||||||
|
symbol number (which starts at 3). Each time yylex is called, a table
|
||||||
|
lookup maps the external token number to the internal symbol number.
|
||||||
|
|
||||||
|
When the %define variable api.token.raw is set, tokens are assigned their
|
||||||
|
internal number, which saves one table lookup per token, and also saves
|
||||||
|
the generation of the mapping table.
|
||||||
|
|
||||||
|
The gain is typically moderate, but in extreme cases (very simple user
|
||||||
|
actions), a 10% improvement can be observed.
|
||||||
|
|
||||||
|
*** Generated parsers use better types for states
|
||||||
|
|
||||||
|
Stacks now use the best integral type for state numbers, instead of always
|
||||||
|
using 15 bits. As a result "small" parsers now have a smaller memory
|
||||||
|
footprint (they use 8 bits), and there is support for large automata (16
|
||||||
|
bits), and extra large (using int, i.e., typically 31 bits).
|
||||||
|
|
||||||
|
*** Generated parsers prefer signed integer types
|
||||||
|
|
||||||
|
Bison skeletons now prefer signed to unsigned integer types when either
|
||||||
|
will do, as the signed types are less error-prone and allow for better
|
||||||
|
checking with 'gcc -fsanitize=undefined'. Also, the types chosen are now
|
||||||
|
portable to unusual machines where char, short and int are all the same
|
||||||
|
width. On non-GNU platforms this may entail including <limits.h> and (if
|
||||||
|
available) <stdint.h> to define integer types and constants.
|
||||||
|
|
||||||
|
*** A skeleton for the D programming language
|
||||||
|
|
||||||
|
For the last few releases, Bison has shipped a stealth experimental
|
||||||
|
skeleton: lalr1.d. It was first contributed by Oliver Mangold, based on
|
||||||
|
Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
|
||||||
|
H. S. Teoh.
|
||||||
|
|
||||||
|
However, because nobody has committed to improving, testing, and
|
||||||
|
documenting this skeleton, it is not clear that it will be supported in
|
||||||
|
the future.
|
||||||
|
|
||||||
|
The lalr1.d skeleton *is functional*, and works well, as demonstrated in
|
||||||
|
examples/d/calc.d. Please try it, enjoy it, and... commit to support it.
|
||||||
|
|
||||||
|
*** Debug traces in Java
|
||||||
|
|
||||||
|
The Java backend no longer emits code and data for parser tracing if the
|
||||||
|
%define variable parse.trace is not defined.
|
||||||
|
|
||||||
|
** Diagnostics
|
||||||
|
|
||||||
|
*** New diagnostic: -Wdangling-alias
|
||||||
|
|
||||||
|
String literals, which allow for better error messages, are (too)
|
||||||
|
liberally accepted by Bison, which might result in silent errors. For
|
||||||
|
instance
|
||||||
|
|
||||||
|
%type <exVal> cond "condition"
|
||||||
|
|
||||||
|
does not define "condition" as a string alias to 'cond' (nonterminal
|
||||||
|
symbols do not have string aliases). It is rather equivalent to
|
||||||
|
|
||||||
|
%nterm <exVal> cond
|
||||||
|
%token <exVal> "condition"
|
||||||
|
|
||||||
|
i.e., it gives the type 'exVal' to the "condition" token, which was
|
||||||
|
clearly not the intention.
|
||||||
|
|
||||||
|
Also, because string aliases need not be defined, typos such as "baz"
|
||||||
|
instead of "bar" will be not reported.
|
||||||
|
|
||||||
|
The option -Wdangling-alias catches these situations. On
|
||||||
|
|
||||||
|
%token BAR "bar"
|
||||||
|
%type <ival> foo "foo"
|
||||||
|
%%
|
||||||
|
foo: "baz" {}
|
||||||
|
|
||||||
|
bison -Wdangling-alias reports
|
||||||
|
|
||||||
|
warning: string literal not attached to a symbol
|
||||||
|
| %type <ival> foo "foo"
|
||||||
|
| ^~~~~
|
||||||
|
warning: string literal not attached to a symbol
|
||||||
|
| foo: "baz" {}
|
||||||
|
| ^~~~~
|
||||||
|
|
||||||
|
The -Wall option does not (yet?) include -Wdangling-alias.
|
||||||
|
|
||||||
|
*** Better POSIX Yacc compatibility diagnostics
|
||||||
|
|
||||||
|
POSIX Yacc restricts %type to nonterminals. This is now diagnosed by
|
||||||
|
-Wyacc.
|
||||||
|
|
||||||
|
%token TOKEN1
|
||||||
|
%type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
%token TOKEN2
|
||||||
|
%%
|
||||||
|
expr:
|
||||||
|
|
||||||
|
gives with -Wyacc
|
||||||
|
|
||||||
|
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||||
|
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
| ^~~~~~
|
||||||
|
input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||||
|
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
| ^~~
|
||||||
|
input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||||
|
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||||
|
| ^~~~~~
|
||||||
|
|
||||||
|
*** Diagnostics with insertion
|
||||||
|
|
||||||
|
The diagnostics now display the suggestion below the underlined source.
|
||||||
|
Replacement for undeclared symbols are now also suggested.
|
||||||
|
|
||||||
|
$ cat /tmp/foo.y
|
||||||
|
%%
|
||||||
|
list: lis '.' |
|
||||||
|
|
||||||
|
$ bison -Wall foo.y
|
||||||
|
foo.y:2.7-9: error: symbol 'lis' is used, but is not defined as a token and has no rules; did you mean 'list'?
|
||||||
|
2 | list: lis '.' |
|
||||||
|
| ^~~
|
||||||
|
| list
|
||||||
|
foo.y:2.16: warning: empty rule without %empty [-Wempty-rule]
|
||||||
|
2 | list: lis '.' |
|
||||||
|
| ^
|
||||||
|
| %empty
|
||||||
|
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||||
|
|
||||||
|
*** Diagnostics about long lines
|
||||||
|
|
||||||
|
Quoted sources may now be truncated to fit the screen. For instance, on a
|
||||||
|
30-column wide terminal:
|
||||||
|
|
||||||
|
$ cat foo.y
|
||||||
|
%token FOO FOO FOO
|
||||||
|
%%
|
||||||
|
exp: FOO
|
||||||
|
$ bison foo.y
|
||||||
|
foo.y:1.34-36: warning: symbol FOO redeclared [-Wother]
|
||||||
|
1 | … FOO …
|
||||||
|
| ^~~
|
||||||
|
foo.y:1.8-10: previous declaration
|
||||||
|
1 | %token FOO …
|
||||||
|
| ^~~
|
||||||
|
foo.y:1.62-64: warning: symbol FOO redeclared [-Wother]
|
||||||
|
1 | … FOO
|
||||||
|
| ^~~
|
||||||
|
foo.y:1.8-10: previous declaration
|
||||||
|
1 | %token FOO …
|
||||||
|
| ^~~
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
|
*** Debugging glr.c and glr.cc
|
||||||
|
|
||||||
|
The glr.c skeleton always had asserts to check its own behavior (not the
|
||||||
|
user's). These assertions are now under the control of the parse.assert
|
||||||
|
%define variable (disabled by default).
|
||||||
|
|
||||||
|
*** Clean up
|
||||||
|
|
||||||
|
Several new compiler warnings in the generated output have been avoided.
|
||||||
|
Some unused features are no longer emitted. Cleaner generated code in
|
||||||
|
general.
|
||||||
|
|
||||||
|
** Bug Fixes
|
||||||
|
|
||||||
|
Portability issues in the test suite.
|
||||||
|
|
||||||
|
In theory, parsers using %nonassoc could crash when reporting verbose
|
||||||
|
error messages. This unlikely bug has been fixed.
|
||||||
|
|
||||||
|
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
In some cases, when warnings are disabled, bison could emit tons of white
|
||||||
|
spaces as diagnostics.
|
||||||
|
|
||||||
|
When running out of memory, bison could crash (found by fuzzing).
|
||||||
|
|
||||||
|
When defining twice the EOF token, bison would crash.
|
||||||
|
|
||||||
|
New warnings from recent compilers have been addressed in the generated
|
||||||
|
parsers (yacc.c, glr.c, glr.cc).
|
||||||
|
|
||||||
|
When lone carriage-return characters appeared in the input file,
|
||||||
|
diagnostics could hang forever.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Portability fixes.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.4 (2019-05-19) [stable]
|
||||||
|
|
||||||
|
** Deprecated features
|
||||||
|
|
||||||
|
The %pure-parser directive is deprecated in favor of '%define api.pure'
|
||||||
|
since Bison 2.3b (2008-05-27), but no warning was issued; there is one
|
||||||
|
now. Note that since Bison 2.7 you are strongly encouraged to use
|
||||||
|
'%define api.pure full' instead of '%define api.pure'.
|
||||||
|
|
||||||
|
** New features
|
||||||
|
|
||||||
|
*** Colored diagnostics
|
||||||
|
|
||||||
|
As an experimental feature, diagnostics are now colored, controlled by the
|
||||||
|
new options --color and --style.
|
||||||
|
|
||||||
|
To use them, install the libtextstyle library before configuring Bison.
|
||||||
|
It is available from
|
||||||
|
|
||||||
|
https://alpha.gnu.org/gnu/gettext/
|
||||||
|
|
||||||
|
for instance
|
||||||
|
|
||||||
|
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz
|
||||||
|
|
||||||
|
The option --color supports the following arguments:
|
||||||
|
- always, yes: Enable colors.
|
||||||
|
- never, no: Disable colors.
|
||||||
|
- auto, tty (default): Enable colors if the output device is a tty.
|
||||||
|
|
||||||
|
To customize the styles, create a CSS file similar to
|
||||||
|
|
||||||
|
/* bison-bw.css */
|
||||||
|
.warning { }
|
||||||
|
.error { font-weight: 800; text-decoration: underline; }
|
||||||
|
.note { }
|
||||||
|
|
||||||
|
then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
|
||||||
|
environment variable to "bison-bw.css".
|
||||||
|
|
||||||
|
*** Disabling output
|
||||||
|
|
||||||
|
When given -fsyntax-only, the diagnostics are reported, but no output is
|
||||||
|
generated.
|
||||||
|
|
||||||
|
The name of this option is somewhat misleading as bison does more than
|
||||||
|
just checking the syntax: every stage is run (including checking for
|
||||||
|
conflicts for instance), except the generation of the output files.
|
||||||
|
|
||||||
|
*** Include the generated header (yacc.c)
|
||||||
|
|
||||||
|
Before, when --defines is used, bison generated a header, and pasted an
|
||||||
|
exact copy of it into the generated parser implementation file. If the
|
||||||
|
header name is not "y.tab.h", it is now #included instead of being
|
||||||
|
duplicated.
|
||||||
|
|
||||||
|
To use an '#include' even if the header name is "y.tab.h" (which is what
|
||||||
|
happens with --yacc, or when using the Autotools' ylwrap), define
|
||||||
|
api.header.include to the exact argument to pass to #include. For
|
||||||
|
instance:
|
||||||
|
|
||||||
|
%define api.header.include {"parse.h"}
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
%define api.header.include {<parser/parse.h>}
|
||||||
|
|
||||||
|
*** api.location.type is now supported in C (yacc.c, glr.c)
|
||||||
|
|
||||||
|
The %define variable api.location.type defines the name of the type to use
|
||||||
|
for locations. When defined, Bison no longer defines YYLTYPE.
|
||||||
|
|
||||||
|
This can be used in programs with several parsers to factor their
|
||||||
|
definition of locations: let one of them generate them, and the others
|
||||||
|
just use them.
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
|
*** Graphviz output
|
||||||
|
|
||||||
|
In conformance with the recommendations of the Graphviz team, if %require
|
||||||
|
"3.4" (or better) is specified, the option --graph generates a *.gv file
|
||||||
|
by default, instead of *.dot.
|
||||||
|
|
||||||
|
*** Diagnostics overhaul
|
||||||
|
|
||||||
|
Column numbers were wrong with multibyte characters, which would also
|
||||||
|
result in skewed diagnostics with carets. Beside, because we were
|
||||||
|
indenting the quoted source with a single space, lines with tab characters
|
||||||
|
were incorrectly underlined.
|
||||||
|
|
||||||
|
To address these issues, and to be clearer, Bison now issues diagnostics
|
||||||
|
as GCC9 does. For instance it used to display (there's a tab before the
|
||||||
|
opening brace):
|
||||||
|
|
||||||
|
foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
|
||||||
|
expr: expr '+' "number" { $$ = $1 + $2; }
|
||||||
|
^~
|
||||||
|
It now reports
|
||||||
|
|
||||||
|
foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
|
||||||
|
3 | expr: expr '+' "number" { $$ = $1 + $2; }
|
||||||
|
| ^~
|
||||||
|
|
||||||
|
Other constructs now also have better locations, resulting in more precise
|
||||||
|
diagnostics.
|
||||||
|
|
||||||
|
*** Fix-it hints for %empty
|
||||||
|
|
||||||
|
Running Bison with -Wempty-rules and --update will remove incorrect %empty
|
||||||
|
annotations, and add the missing ones.
|
||||||
|
|
||||||
|
*** Generated reports
|
||||||
|
|
||||||
|
The format of the reports (parse.output) was improved for readability.
|
||||||
|
|
||||||
|
*** Better support for --no-line.
|
||||||
|
|
||||||
|
When --no-line is used, the generated files are now cleaner: no lines are
|
||||||
|
generated instead of empty lines. Together with using api.header.include,
|
||||||
|
that should help people saving the generated files into version control
|
||||||
|
systems get smaller diffs.
|
||||||
|
|
||||||
|
** Documentation
|
||||||
|
|
||||||
|
A new example in C shows an simple infix calculator with a hand-written
|
||||||
|
scanner (examples/c/calc).
|
||||||
|
|
||||||
|
A new example in C shows a reentrant parser (capable of recursive calls)
|
||||||
|
built with Flex and Bison (examples/c/reccalc).
|
||||||
|
|
||||||
|
There is a new section about the history of Yaccs and Bison.
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
A few obscure bugs were fixed, including the second oldest (known) bug in
|
||||||
|
Bison: it was there when Bison was entered in the RCS version control
|
||||||
|
system, in December 1987. See the NEWS of Bison 3.3 for the previous
|
||||||
|
oldest bug.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Bison 3.3 failed to generate parsers for grammars with unused nonterminal
|
||||||
|
symbols.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
|
The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
|
||||||
|
extensions into errors. It now makes them simple warnings (-Wyacc).
|
||||||
|
|
||||||
* Noteworthy changes in release 3.3 (2019-01-26) [stable]
|
* Noteworthy changes in release 3.3 (2019-01-26) [stable]
|
||||||
|
|
||||||
A new mailing list was created, Bison Announce. It is low traffic, and is
|
A new mailing list was created, Bison Announce. It is low traffic, and is
|
||||||
only about announcing new releases and important messages (e.g., polls about
|
only about announcing new releases and important messages (e.g., polls
|
||||||
major decisions to make).
|
about major decisions to make).
|
||||||
|
|
||||||
https://lists.gnu.org/mailman/listinfo/bison-announce
|
https://lists.gnu.org/mailman/listinfo/bison-announce
|
||||||
|
|
||||||
** Backward incompatible changes
|
** Backward incompatible changes
|
||||||
|
|
||||||
@@ -209,17 +898,18 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
symbol_type (int token, const int&);
|
symbol_type (int token, const int&);
|
||||||
symbol_type (int token);
|
symbol_type (int token);
|
||||||
|
|
||||||
which should be used in a Flex-scanner as follows.
|
|
||||||
|
|
||||||
%%
|
|
||||||
[a-z]+ return yy::parser::symbol_type (ID, yytext);
|
|
||||||
[0-9]+ return yy::parser::symbol_type (INT, text_to_int (yytext);
|
|
||||||
":" return yy::parser::symbol_type (’:’);
|
|
||||||
<<EOF>> return yy::parser::symbol_type (0);
|
|
||||||
|
|
||||||
Correct matching between token types and value types is checked via
|
Correct matching between token types and value types is checked via
|
||||||
'assert'. For instance, 'symbol_type (ID, 42)' would abort (while
|
'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named
|
||||||
'make_ID (42)' would not even compile).
|
constructors are preferable, as they offer better type safety (for
|
||||||
|
instance 'make_ID (42)' would not even compile), but symbol_type
|
||||||
|
constructors may help when token types are discovered at run-time, e.g.,
|
||||||
|
|
||||||
|
[a-z]+ {
|
||||||
|
if (auto i = lookup_keyword (yytext))
|
||||||
|
return yy::parser::symbol_type (i);
|
||||||
|
else
|
||||||
|
return yy::parser::make_ID (yytext);
|
||||||
|
}
|
||||||
|
|
||||||
*** C++: Variadic emplace
|
*** C++: Variadic emplace
|
||||||
|
|
||||||
@@ -722,10 +1412,10 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
bison used to report:
|
bison used to report:
|
||||||
|
|
||||||
/tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO
|
foo.yy:2.10-11: error: %printer redeclaration for FOO
|
||||||
%printer {} "foo"
|
%printer {} "foo"
|
||||||
^^
|
^^
|
||||||
/tmp/foo.yy:3.10-11: previous declaration
|
foo.yy:3.10-11: previous declaration
|
||||||
%printer {} FOO
|
%printer {} FOO
|
||||||
^^
|
^^
|
||||||
|
|
||||||
@@ -1882,7 +2572,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
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.
|
||||||
|
|
||||||
* Changes in version 2.5 (2011-05-14):
|
* Noteworthy changes in release 2.5 (2011-05-14)
|
||||||
|
|
||||||
** Grammar symbol names can now contain non-initial dashes:
|
** Grammar symbol names can now contain non-initial dashes:
|
||||||
|
|
||||||
@@ -2237,7 +2927,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
This bug has been fixed.
|
This bug has been fixed.
|
||||||
|
|
||||||
* Changes in version 2.4.3 (2010-08-05):
|
* Noteworthy changes in release 2.4.3 (2010-08-05)
|
||||||
|
|
||||||
** Bison now obeys -Werror and --warnings=error for warnings about
|
** Bison now obeys -Werror and --warnings=error for warnings about
|
||||||
grammar rules that are useless in the parser due to conflicts.
|
grammar rules that are useless in the parser due to conflicts.
|
||||||
@@ -2257,7 +2947,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** Minor documentation fixes.
|
** Minor documentation fixes.
|
||||||
|
|
||||||
* Changes in version 2.4.2 (2010-03-20):
|
* Noteworthy changes in release 2.4.2 (2010-03-20)
|
||||||
|
|
||||||
** Some portability problems that resulted in failures and livelocks
|
** Some portability problems that resulted in failures and livelocks
|
||||||
in the test suite on some versions of at least Solaris, AIX, HP-UX,
|
in the test suite on some versions of at least Solaris, AIX, HP-UX,
|
||||||
@@ -2351,7 +3041,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
message translations were not installed although supported by the
|
message translations were not installed although supported by the
|
||||||
host system.
|
host system.
|
||||||
|
|
||||||
* Changes in version 2.4.1 (2008-12-11):
|
* Noteworthy changes in release 2.4.1 (2008-12-11)
|
||||||
|
|
||||||
** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
|
** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
|
||||||
declarations have been fixed.
|
declarations have been fixed.
|
||||||
@@ -2376,7 +3066,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** A few minor improvements to the Bison manual.
|
** A few minor improvements to the Bison manual.
|
||||||
|
|
||||||
* Changes in version 2.4 (2008-11-02):
|
* Noteworthy changes in release 2.4 (2008-11-02)
|
||||||
|
|
||||||
** %language is an experimental feature.
|
** %language is an experimental feature.
|
||||||
|
|
||||||
@@ -2391,7 +3081,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** Several bugs in the C++ skeleton and the experimental Java skeleton have been
|
** Several bugs in the C++ skeleton and the experimental Java skeleton have been
|
||||||
fixed.
|
fixed.
|
||||||
|
|
||||||
* Changes in version 2.3b (2008-05-27):
|
* Noteworthy changes in release 2.3b (2008-05-27)
|
||||||
|
|
||||||
** The quotes around NAME that used to be required in the following directive
|
** The quotes around NAME that used to be required in the following directive
|
||||||
are now deprecated:
|
are now deprecated:
|
||||||
@@ -2577,7 +3267,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** The nonfunctional --no-parser, -n, and %no-parser options have been
|
** The nonfunctional --no-parser, -n, and %no-parser options have been
|
||||||
completely removed from Bison.
|
completely removed from Bison.
|
||||||
|
|
||||||
* Changes in version 2.3a, 2006-09-13:
|
* Noteworthy changes in release 2.3a (2006-09-13)
|
||||||
|
|
||||||
** Instead of %union, you can define and use your own union type
|
** Instead of %union, you can define and use your own union type
|
||||||
YYSTYPE if your grammar contains at least one <type> tag.
|
YYSTYPE if your grammar contains at least one <type> tag.
|
||||||
@@ -2691,7 +3381,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
The old spelling still works, but is not documented and may be removed
|
The old spelling still works, but is not documented and may be removed
|
||||||
in a future release.
|
in a future release.
|
||||||
|
|
||||||
* Changes in version 2.3, 2006-06-05:
|
* Noteworthy changes in release 2.3 (2006-06-05)
|
||||||
|
|
||||||
** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
|
** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
|
||||||
for compatibility with LALR(1) grammars.
|
for compatibility with LALR(1) grammars.
|
||||||
@@ -2699,7 +3389,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** It is now documented that any definition of YYSTYPE or YYLTYPE should
|
** It is now documented that any definition of YYSTYPE or YYLTYPE should
|
||||||
be to a type name that does not contain parentheses or brackets.
|
be to a type name that does not contain parentheses or brackets.
|
||||||
|
|
||||||
* Changes in version 2.2, 2006-05-19:
|
* Noteworthy changes in release 2.2 (2006-05-19)
|
||||||
|
|
||||||
** The distribution terms for all Bison-generated parsers now permit
|
** The distribution terms for all Bison-generated parsers now permit
|
||||||
using the parsers in nonfree programs. Previously, this permission
|
using the parsers in nonfree programs. Previously, this permission
|
||||||
@@ -2781,7 +3471,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** DJGPP support added.
|
** DJGPP support added.
|
||||||
|
|
||||||
* Changes in version 2.1, 2005-09-16:
|
* Noteworthy changes in release 2.1 (2005-09-16)
|
||||||
|
|
||||||
** The C++ lalr1.cc skeleton supports %lex-param.
|
** The C++ lalr1.cc skeleton supports %lex-param.
|
||||||
|
|
||||||
@@ -2807,7 +3497,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
print 'syntax error, unexpected number' instead of 'syntax error,
|
print 'syntax error, unexpected number' instead of 'syntax error,
|
||||||
unexpected "number"'.
|
unexpected "number"'.
|
||||||
|
|
||||||
* Changes in version 2.0, 2004-12-25:
|
* Noteworthy changes in release 2.0 (2004-12-25)
|
||||||
|
|
||||||
** Possibly-incompatible changes
|
** Possibly-incompatible changes
|
||||||
|
|
||||||
@@ -2870,7 +3560,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
- Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
|
- Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
|
||||||
|
|
||||||
* Changes in version 1.875, 2003-01-01:
|
* Noteworthy changes in release 1.875 (2003-01-01)
|
||||||
|
|
||||||
** The documentation license has been upgraded to version 1.2
|
** The documentation license has been upgraded to version 1.2
|
||||||
of the GNU Free Documentation License.
|
of the GNU Free Documentation License.
|
||||||
@@ -2990,7 +3680,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
ago, but nobody noticed until we recently asked someone to try
|
ago, but nobody noticed until we recently asked someone to try
|
||||||
building Bison with a K&R C compiler.
|
building Bison with a K&R C compiler.
|
||||||
|
|
||||||
* Changes in version 1.75, 2002-10-14:
|
* Noteworthy changes in release 1.75 (2002-10-14)
|
||||||
|
|
||||||
** Bison should now work on 64-bit hosts.
|
** Bison should now work on 64-bit hosts.
|
||||||
|
|
||||||
@@ -3021,7 +3711,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
was incorrectly rejected: $1 is defined in the second midrule
|
was incorrectly rejected: $1 is defined in the second midrule
|
||||||
action, and is equal to the $$ of the first midrule action.
|
action, and is equal to the $$ of the first midrule action.
|
||||||
|
|
||||||
* Changes in version 1.50, 2002-10-04:
|
* Noteworthy changes in release 1.50 (2002-10-04)
|
||||||
|
|
||||||
** GLR parsing
|
** GLR parsing
|
||||||
The declaration
|
The declaration
|
||||||
@@ -3165,7 +3855,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** GNU M4 is now required when using Bison.
|
** GNU M4 is now required when using Bison.
|
||||||
|
|
||||||
* Changes in version 1.35, 2002-03-25:
|
* Noteworthy changes in release 1.35 (2002-03-25)
|
||||||
|
|
||||||
** C Skeleton
|
** C Skeleton
|
||||||
Some projects use Bison's C parser with C++ compilers, and define
|
Some projects use Bison's C parser with C++ compilers, and define
|
||||||
@@ -3180,7 +3870,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
This kludge also addresses some C++ problems when the stack was
|
This kludge also addresses some C++ problems when the stack was
|
||||||
extended.
|
extended.
|
||||||
|
|
||||||
* Changes in version 1.34, 2002-03-12:
|
* Noteworthy changes in release 1.34 (2002-03-12)
|
||||||
|
|
||||||
** File name clashes are detected
|
** File name clashes are detected
|
||||||
$ bison foo.y -d -o foo.x
|
$ bison foo.y -d -o foo.x
|
||||||
@@ -3200,7 +3890,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** Fix test suite portability problems.
|
** Fix test suite portability problems.
|
||||||
|
|
||||||
* Changes in version 1.33, 2002-02-07:
|
* Noteworthy changes in release 1.33 (2002-02-07)
|
||||||
|
|
||||||
** Fix C++ issues
|
** Fix C++ issues
|
||||||
Groff could not be compiled for the definition of size_t was lacking
|
Groff could not be compiled for the definition of size_t was lacking
|
||||||
@@ -3209,7 +3899,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** Catch invalid @n
|
** Catch invalid @n
|
||||||
As is done with $n.
|
As is done with $n.
|
||||||
|
|
||||||
* Changes in version 1.32, 2002-01-23:
|
* Noteworthy changes in release 1.32 (2002-01-23)
|
||||||
|
|
||||||
** Fix Yacc output file names
|
** Fix Yacc output file names
|
||||||
|
|
||||||
@@ -3217,7 +3907,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** Italian, Dutch translations
|
** Italian, Dutch translations
|
||||||
|
|
||||||
* Changes in version 1.31, 2002-01-14:
|
* Noteworthy changes in release 1.31 (2002-01-14)
|
||||||
|
|
||||||
** Many Bug Fixes
|
** Many Bug Fixes
|
||||||
|
|
||||||
@@ -3304,7 +3994,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** --output
|
** --output
|
||||||
New, aliasing "--output-file".
|
New, aliasing "--output-file".
|
||||||
|
|
||||||
* Changes in version 1.30, 2001-10-26:
|
* Noteworthy changes in release 1.30 (2001-10-26)
|
||||||
|
|
||||||
** "--defines" and "--graph" have now an optional argument which is the
|
** "--defines" and "--graph" have now an optional argument which is the
|
||||||
output file name. "-d" and "-g" do not change; they do not take any
|
output file name. "-d" and "-g" do not change; they do not take any
|
||||||
@@ -3315,7 +4005,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** Portability fixes.
|
** Portability fixes.
|
||||||
|
|
||||||
* Changes in version 1.29, 2001-09-07:
|
* Noteworthy changes in release 1.29 (2001-09-07)
|
||||||
|
|
||||||
** The output file does not define const, as this caused problems when used
|
** The output file does not define const, as this caused problems when used
|
||||||
with common autoconfiguration schemes. If you still use ancient compilers
|
with common autoconfiguration schemes. If you still use ancient compilers
|
||||||
@@ -3350,7 +4040,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** @$
|
** @$
|
||||||
Automatic location tracking.
|
Automatic location tracking.
|
||||||
|
|
||||||
* Changes in version 1.28, 1999-07-06:
|
* Noteworthy changes in release 1.28 (1999-07-06)
|
||||||
|
|
||||||
** Should compile better now with K&R compilers.
|
** Should compile better now with K&R compilers.
|
||||||
|
|
||||||
@@ -3360,12 +4050,12 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
|
|
||||||
** There is now a FAQ.
|
** There is now a FAQ.
|
||||||
|
|
||||||
* Changes in version 1.27:
|
* Noteworthy changes in release 1.27
|
||||||
|
|
||||||
** The make rule which prevented bison.simple from being created on
|
** The make rule which prevented bison.simple from being created on
|
||||||
some systems has been fixed.
|
some systems has been fixed.
|
||||||
|
|
||||||
* Changes in version 1.26:
|
* Noteworthy changes in release 1.26
|
||||||
|
|
||||||
** Bison now uses Automake.
|
** Bison now uses Automake.
|
||||||
|
|
||||||
@@ -3382,7 +4072,7 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
|
|||||||
** Generated parsers should now work even on operating systems which do
|
** Generated parsers should now work even on operating systems which do
|
||||||
not provide alloca().
|
not provide alloca().
|
||||||
|
|
||||||
* Changes in version 1.25, 1995-10-16:
|
* Noteworthy changes in release 1.25 (1995-10-16)
|
||||||
|
|
||||||
** Errors in the input grammar are not fatal; Bison keeps reading
|
** Errors in the input grammar are not fatal; Bison keeps reading
|
||||||
the grammar file, and reports all the errors found in it.
|
the grammar file, and reports all the errors found in it.
|
||||||
@@ -3407,7 +4097,7 @@ the parser engine; a project can now use its own parser engine.
|
|||||||
The actions go into a separate file called NAME.act, in the form of
|
The actions go into a separate file called NAME.act, in the form of
|
||||||
a switch statement body.
|
a switch statement body.
|
||||||
|
|
||||||
* Changes in version 1.23:
|
* Noteworthy changes in release 1.23
|
||||||
|
|
||||||
The user can define YYPARSE_PARAM as the name of an argument to be
|
The user can define YYPARSE_PARAM as the name of an argument to be
|
||||||
passed into yyparse. The argument should have type void *. It should
|
passed into yyparse. The argument should have type void *. It should
|
||||||
@@ -3416,17 +4106,17 @@ by casting it to the proper pointer type.
|
|||||||
|
|
||||||
Line numbers in output file corrected.
|
Line numbers in output file corrected.
|
||||||
|
|
||||||
* Changes in version 1.22:
|
* Noteworthy changes in release 1.22
|
||||||
|
|
||||||
--help option added.
|
--help option added.
|
||||||
|
|
||||||
* Changes in version 1.20:
|
* Noteworthy changes in release 1.20
|
||||||
|
|
||||||
Output file does not redefine const for C++.
|
Output file does not redefine const for C++.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1995-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 1995-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Parser Generator.
|
This file is part of Bison, the GNU Parser Generator.
|
||||||
|
|
||||||
@@ -3467,12 +4157,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
|
||||||
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
|
||||||
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
|
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
|
||||||
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir
|
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir bw
|
||||||
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
|
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
|
||||||
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
|
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
|
||||||
LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
|
LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
|
||||||
LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
|
LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
|
||||||
LocalWords: noexcept constexpr ispell american
|
LocalWords: noexcept constexpr ispell american deprecations backend Teoh
|
||||||
|
LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
|
||||||
|
LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata yytname
|
||||||
|
LocalWords: yysymbol yytnamerr yyreport ctx ARGMAX yysyntax stderr LPAREN
|
||||||
|
LocalWords: symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF
|
||||||
|
LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
|
||||||
|
LocalWords: yytoken YYUNDEF YYerror
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ to the bison package.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2002, 2005, 2009-2015, 2018-2019 Free Software Foundation,
|
Copyright (C) 2002, 2005, 2009-2015, 2018-2020 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.
|
||||||
|
|||||||
@@ -1,15 +1,67 @@
|
|||||||
This package contains the GNU Bison parser generator.
|
GNU Bison is a general-purpose parser generator that converts an annotated
|
||||||
|
context-free grammar into a deterministic LR or generalized LR (GLR) parser
|
||||||
|
employing LALR(1) parser tables. Bison can also generate IELR(1) or
|
||||||
|
canonical LR(1) parser tables. Once you are proficient with Bison, you can
|
||||||
|
use it to develop a wide range of language parsers, from those used in
|
||||||
|
simple desk calculators to complex programming languages.
|
||||||
|
|
||||||
* Installation
|
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
||||||
** Build
|
work with Bison with no change. Anyone familiar with Yacc should be able to
|
||||||
|
use Bison with little trouble. You need to be fluent in C, C++ or Java
|
||||||
|
programming in order to use Bison.
|
||||||
|
|
||||||
|
Bison and the parsers it generates are portable, they do not require any
|
||||||
|
specific compilers.
|
||||||
|
|
||||||
|
GNU Bison's home page is https://gnu.org/software/bison/.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
## Build from git
|
||||||
|
Here are basic installation instructions for a repository checkout:
|
||||||
|
|
||||||
|
$ git submodule update --init
|
||||||
|
$ ./bootstrap
|
||||||
|
|
||||||
|
then proceed with the usual `configure && make` steps.
|
||||||
|
|
||||||
|
The file README-hacking.md is about building, modifying and checking Bison.
|
||||||
|
|
||||||
|
## Build from tarball
|
||||||
See the file INSTALL for generic compilation and installation instructions.
|
See the file INSTALL for generic compilation and installation instructions.
|
||||||
|
|
||||||
Bison requires GNU m4 1.4.6 or later. See:
|
Bison requires GNU m4 1.4.6 or later. See
|
||||||
|
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
|
||||||
|
|
||||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
|
## Running a non installed bison
|
||||||
|
Once you ran `make`, you might want to toy with this fresh bison before
|
||||||
|
installing it. In that case, do not use `src/bison`: it would use the
|
||||||
|
*installed* files (skeletons, etc.), not the local ones. Use `tests/bison`.
|
||||||
|
|
||||||
** Relocatability
|
## Colored diagnostics
|
||||||
If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
|
As an experimental feature, diagnostics are now colored, controlled by the
|
||||||
|
`--color` and `--style` options.
|
||||||
|
|
||||||
|
To use them, install the libtextstyle library before configuring Bison. It
|
||||||
|
is available from https://alpha.gnu.org/gnu/gettext/, for instance
|
||||||
|
https://alpha.gnu.org/pub/gnu/gettext/libtextstyle-0.20.5.tar.gz.
|
||||||
|
|
||||||
|
The option --color supports the following arguments:
|
||||||
|
- always, yes: Enable colors.
|
||||||
|
- never, no: Disable colors.
|
||||||
|
- auto, tty (default): Enable colors if the output device is a tty.
|
||||||
|
|
||||||
|
To customize the styles, create a CSS file, say `bison-bw.css`, similar to
|
||||||
|
|
||||||
|
/* bison-bw.css */
|
||||||
|
.warning { }
|
||||||
|
.error { font-weight: 800; text-decoration: underline; }
|
||||||
|
.note { }
|
||||||
|
|
||||||
|
then invoke bison with `--style=bison-bw.css`, or set the `BISON_STYLE`
|
||||||
|
environment variable to `bison-bw.css`.
|
||||||
|
|
||||||
|
## Relocatability
|
||||||
|
If you pass `--enable-relocatable` to `configure`, Bison is relocatable.
|
||||||
|
|
||||||
A relocatable program can be moved or copied to a different location on the
|
A relocatable program can be moved or copied to a different location on the
|
||||||
file system. It can also be used through mount points for network sharing.
|
file system. It can also be used through mount points for network sharing.
|
||||||
@@ -18,7 +70,7 @@ invoke them through the symlink.
|
|||||||
|
|
||||||
See "Enabling Relocatability" in the documentation.
|
See "Enabling Relocatability" in the documentation.
|
||||||
|
|
||||||
** Internationalization
|
## Internationalization
|
||||||
Bison supports two catalogs: one for Bison itself (i.e., for the
|
Bison supports two catalogs: one for Bison itself (i.e., for the
|
||||||
maintainer-side parser generation), and one for the generated parsers (i.e.,
|
maintainer-side parser generation), and one for the generated parsers (i.e.,
|
||||||
for the user-side parser execution). The requirements between both differ:
|
for the user-side parser execution). The requirements between both differ:
|
||||||
@@ -28,49 +80,46 @@ generated parsers could have been localized. See
|
|||||||
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for more
|
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for more
|
||||||
details.
|
details.
|
||||||
|
|
||||||
* Questions
|
# Questions
|
||||||
See the section FAQ in the documentation (doc/bison.info) for frequently
|
See the section FAQ in the documentation (doc/bison.info) for frequently
|
||||||
asked questions. The documentation is also available in PDF and HTML,
|
asked questions. The documentation is also available in PDF and HTML,
|
||||||
provided you have a recent version of Texinfo installed: run "make pdf" or
|
provided you have a recent version of Texinfo installed: run `make pdf` or
|
||||||
"make html".
|
`make html`.
|
||||||
|
|
||||||
If you have questions about using Bison and the documentation does not
|
If you have questions about using Bison and the documentation does not
|
||||||
answer them, please send mail to <[email protected]>.
|
answer them, please send mail to <[email protected]>.
|
||||||
|
|
||||||
* Bug reports
|
# Bug reports
|
||||||
Please send bug reports to <[email protected]>. Be sure to include the
|
Please send bug reports to <[email protected]>. Be sure to include the
|
||||||
version number from 'bison --version', and a complete, self-contained test
|
version number from `bison --version`, and a complete, self-contained test
|
||||||
case in each bug report.
|
case in each bug report.
|
||||||
|
|
||||||
* Copyright statements
|
# Copyright statements
|
||||||
For any copyright year range specified as YYYY-ZZZZ in this package, note
|
For any copyright year range specified as YYYY-ZZZZ in this package, note
|
||||||
that the range specifies every single year in that closed interval.
|
that the range specifies every single year in that closed interval.
|
||||||
|
|
||||||
-----
|
<!--
|
||||||
|
|
||||||
Local Variables:
|
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2020 Free
|
||||||
mode: outline
|
|
||||||
fill-column: 76
|
|
||||||
ispell-dictionary: "american"
|
|
||||||
End:
|
|
||||||
|
|
||||||
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2019 Free
|
|
||||||
Software Foundation, Inc.
|
Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU bison, the GNU Compiler Compiler.
|
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
it under the terms of the GNU General Public License as published by
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
any later version published by the Free Software Foundation; with no
|
||||||
(at your option) any later version.
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
Local Variables:
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
mode: markdown
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
fill-column: 76
|
||||||
GNU General Public License for more details.
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american md
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
LocalWords: MERCHANTABILITY GLR LALR IELR submodule init README src bw
|
||||||
|
LocalWords: Relocatability symlinks symlink
|
||||||
|
|
||||||
# LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
|
-->
|
||||||
# LocalWords: MERCHANTABILITY
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ the problems you encounter.
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
|
Copyright (C) 2002, 2004, 2009-2015, 2018-2020 Free Software Foundation,
|
||||||
Inc.
|
Inc.
|
||||||
|
|
||||||
This file is part of GNU Bison.
|
This file is part of GNU Bison.
|
||||||
|
|||||||
-482
@@ -1,482 +0,0 @@
|
|||||||
This file attempts to describe the rules to use when hacking Bison.
|
|
||||||
Don't put this file into the distribution.
|
|
||||||
|
|
||||||
Everything related to the development of Bison is on Savannah:
|
|
||||||
|
|
||||||
http://savannah.gnu.org/projects/bison/
|
|
||||||
|
|
||||||
|
|
||||||
* Administrivia
|
|
||||||
|
|
||||||
** If you incorporate a change from somebody on the net:
|
|
||||||
First, if it is a large change, you must make sure they have signed the
|
|
||||||
appropriate paperwork. Second, be sure to add their name and email address
|
|
||||||
to THANKS.
|
|
||||||
|
|
||||||
** If a change fixes a test, mention the test in the commit message.
|
|
||||||
|
|
||||||
** Bug reports
|
|
||||||
If somebody reports a new bug, mention his name in the commit message and in
|
|
||||||
the test case you write. Put him into THANKS.
|
|
||||||
|
|
||||||
The correct response to most actual bugs is to write a new test case which
|
|
||||||
demonstrates the bug. Then fix the bug, re-run the test suite, and check
|
|
||||||
everything in.
|
|
||||||
|
|
||||||
|
|
||||||
* Hacking
|
|
||||||
|
|
||||||
** Visible changes
|
|
||||||
Which include serious bug fixes, must be mentioned in NEWS.
|
|
||||||
|
|
||||||
** Translations
|
|
||||||
Only user visible strings are to be translated: error messages, bits of the
|
|
||||||
.output file etc. This excludes impossible error messages (comparable to
|
|
||||||
assert/abort), and all the --trace output which is meant for the maintainers
|
|
||||||
only.
|
|
||||||
|
|
||||||
** Horizontal tabs
|
|
||||||
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
|
|
||||||
|
|
||||||
These notes intend to help people working on the checked-out sources.
|
|
||||||
These requirements do not apply when building from a distribution tarball.
|
|
||||||
|
|
||||||
** Requirements
|
|
||||||
|
|
||||||
We've opted to keep only the highest-level sources in the repository. This
|
|
||||||
eases our maintenance burden, (fewer merges etc.), but imposes more
|
|
||||||
requirements on anyone wishing to build from the just-checked-out sources.
|
|
||||||
For example, you have to use the latest stable versions of the maintainer
|
|
||||||
tools we depend upon, including:
|
|
||||||
|
|
||||||
- Autoconf <http://www.gnu.org/software/autoconf/>
|
|
||||||
- Automake <http://www.gnu.org/software/automake/>
|
|
||||||
- Flex <http://www.gnu.org/software/flex/>
|
|
||||||
- Gettext <http://www.gnu.org/software/gettext/>
|
|
||||||
- Graphviz <http://www.graphviz.org>
|
|
||||||
- Gzip <http://www.gnu.org/software/gzip/>
|
|
||||||
- Help2man <http://www.gnu.org/software/help2man/>
|
|
||||||
- Perl <http://www.cpan.org/>
|
|
||||||
- Rsync <http://samba.anu.edu.au/rsync/>
|
|
||||||
- Tar <http://www.gnu.org/software/tar/>
|
|
||||||
- Texinfo <http://www.gnu.org/software/texinfo/>
|
|
||||||
|
|
||||||
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
|
|
||||||
your architecture.
|
|
||||||
|
|
||||||
If you're using a GNU/Linux distribution, the easiest way to install the
|
|
||||||
above packages depends on your system. The following shell command should
|
|
||||||
work for Debian-based systems such as Ubuntu:
|
|
||||||
|
|
||||||
sudo apt-get install \
|
|
||||||
autoconf automake autopoint flex graphviz help2man texinfo valgrind
|
|
||||||
|
|
||||||
Bison is written using Bison grammars, so there are bootstrapping issues.
|
|
||||||
The bootstrap script attempts to discover when the C code generated from the
|
|
||||||
grammars is out of date, and to bootstrap with an 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.
|
|
||||||
|
|
||||||
Only building the initial full source tree will be a bit painful. Later,
|
|
||||||
after synchronizing from the repository a plain 'make' should be sufficient.
|
|
||||||
Note, however, that when gnulib is updated, running './bootstrap' again
|
|
||||||
might be needed.
|
|
||||||
|
|
||||||
** First checkout
|
|
||||||
|
|
||||||
Obviously, if you are reading these notes, you did manage to check out this
|
|
||||||
package from the repository. For the record, you will find all the relevant
|
|
||||||
information on:
|
|
||||||
|
|
||||||
http://savannah.gnu.org/git/?group=bison
|
|
||||||
|
|
||||||
Bison uses Git submodules: subscriptions to other Git repositories. In
|
|
||||||
particular it uses gnulib, the GNU portability library. To ask Git to
|
|
||||||
perform the first checkout of the submodules, run
|
|
||||||
|
|
||||||
$ git submodule update --init
|
|
||||||
|
|
||||||
The next step is to get other files needed to build, which are extracted
|
|
||||||
from other source packages:
|
|
||||||
|
|
||||||
$ ./bootstrap
|
|
||||||
|
|
||||||
Bootstrapping updates the submodules to the versions registered in the
|
|
||||||
top-level directory. To change gnulib, first check out the version you want
|
|
||||||
in `gnulib`, then commit this change in Bison's repository, and finally run
|
|
||||||
bootstrap.
|
|
||||||
|
|
||||||
If it fails with missing symbols (e.g., "error: possibly undefined macro:
|
|
||||||
AC_PROG_GNU_M4"), you are likely to have forgotten the submodule
|
|
||||||
initialization part. To recover from it, run `git reset --hard HEAD`, and
|
|
||||||
restart with the submodule initialization. Otherwise, there you are! Just
|
|
||||||
|
|
||||||
$ ./configure
|
|
||||||
$ make
|
|
||||||
$ make check
|
|
||||||
|
|
||||||
At this point, there should be no difference between your local copy, and
|
|
||||||
the master copy:
|
|
||||||
|
|
||||||
$ git diff
|
|
||||||
|
|
||||||
should output no difference.
|
|
||||||
|
|
||||||
Enjoy!
|
|
||||||
|
|
||||||
** Updating
|
|
||||||
|
|
||||||
The use of submodules make things somewhat different because git does not
|
|
||||||
support recursive operations: submodules must be taken care of explicitly by
|
|
||||||
the user.
|
|
||||||
|
|
||||||
*** Updating Bison
|
|
||||||
|
|
||||||
If you pull a newer version of a branch, say via "git pull", you might
|
|
||||||
import requests for updated submodules. A simple "git diff" will reveal if
|
|
||||||
the current version of the submodule (i.e., the actual contents of the
|
|
||||||
gnulib directory) and the current request from the subscriber (i.e., the
|
|
||||||
reference of the version of gnulib that the Bison repository requests)
|
|
||||||
differ. To upgrade the submodules (i.e., to check out the version that is
|
|
||||||
actually requested by the subscriber, run "git submodule update".
|
|
||||||
|
|
||||||
$ git pull
|
|
||||||
$ git submodule update
|
|
||||||
|
|
||||||
*** Updating a submodule
|
|
||||||
To update a submodule, say gnulib, do as follows:
|
|
||||||
|
|
||||||
Get the most recent version of the master branch from git.
|
|
||||||
|
|
||||||
$ cd gnulib
|
|
||||||
$ git fetch
|
|
||||||
$ git checkout -b master --track origin/master
|
|
||||||
|
|
||||||
Make sure Bison can live with that version of gnulib.
|
|
||||||
|
|
||||||
$ cd ..
|
|
||||||
$ ./bootstrap
|
|
||||||
$ make distcheck
|
|
||||||
|
|
||||||
Register your changes.
|
|
||||||
|
|
||||||
$ git checkin ...
|
|
||||||
|
|
||||||
For a suggestion of what gnulib commit might be stable enough for a formal
|
|
||||||
release, see the ChangeLog in the latest gnulib snapshot at:
|
|
||||||
|
|
||||||
http://erislabs.net/ianb/projects/gnulib/
|
|
||||||
|
|
||||||
The Autoconf files we use are currently:
|
|
||||||
|
|
||||||
m4/m4.m4
|
|
||||||
lib/m4sugar/m4sugar.m4
|
|
||||||
lib/m4sugar/foreach.m4
|
|
||||||
|
|
||||||
These files don't change very often in Autoconf, so it should be relatively
|
|
||||||
straight-forward to examine the differences in order to decide whether to
|
|
||||||
update.
|
|
||||||
|
|
||||||
* Test suite
|
|
||||||
|
|
||||||
** make check
|
|
||||||
Use liberally.
|
|
||||||
|
|
||||||
** TESTSUITEFLAGS
|
|
||||||
|
|
||||||
To run just the testsuite (not the tests related to the examples), run `make
|
|
||||||
check-local`.
|
|
||||||
|
|
||||||
The default is for make check-local to run all tests sequentially. This can
|
|
||||||
be very time consuming when checking repeatedly or on slower setups. This
|
|
||||||
can be sped up in two ways:
|
|
||||||
|
|
||||||
Using -j, in a make-like fashion, for example:
|
|
||||||
$ make check-local TESTSUITEFLAGS='-j8'
|
|
||||||
|
|
||||||
Running only the tests of a certain category, as specified in the AT files
|
|
||||||
with AT_KEYWORDS([[category]]). Categories include:
|
|
||||||
- c++, for c++ parsers
|
|
||||||
- deprec, for tests concerning deprecated constructs.
|
|
||||||
- glr, for glr parsers
|
|
||||||
- java, for java parsers
|
|
||||||
- report, for automaton dumps
|
|
||||||
|
|
||||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
|
||||||
$ make check-local TESTSUITEFLAGS='-k c++'
|
|
||||||
|
|
||||||
Both can be combined.
|
|
||||||
|
|
||||||
** Typical errors
|
|
||||||
If the test suite shows failures such as the following one
|
|
||||||
|
|
||||||
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
|
|
||||||
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
|
|
||||||
|
|
||||||
it probably means that some file was compiled without
|
|
||||||
AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
|
|
||||||
pick up gnulib's replacement headers, such as getopt.h, and this will go
|
|
||||||
wrong if config.h was not included first.
|
|
||||||
|
|
||||||
See tests/local.at for details.
|
|
||||||
|
|
||||||
** 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
|
|
||||||
Try to run the test suite with more severe conditions before a
|
|
||||||
release:
|
|
||||||
|
|
||||||
- Configure the package with --enable-gcc-warnings, so that one checks that
|
|
||||||
1. Bison compiles cleanly, 2. the parsers it produces compile cleanly too.
|
|
||||||
|
|
||||||
- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules 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 gnulib.
|
|
||||||
|
|
||||||
- run "make maintainer-check" which:
|
|
||||||
- runs "valgrind -q bison" to run Bison under Valgrind.
|
|
||||||
- runs the parsers under Valgrind.
|
|
||||||
- runs the test suite with G++ as C compiler...
|
|
||||||
|
|
||||||
- run "make maintainer-check-push", which runs "make maintainer-check" while
|
|
||||||
activating the push implementation and its pull interface wrappers in many
|
|
||||||
test cases that were originally written to exercise only the pull
|
|
||||||
implementation. This makes certain the push implementation can perform
|
|
||||||
every task the pull implementation can.
|
|
||||||
|
|
||||||
- run "make maintainer-check-xml", which runs "make maintainer-check" while
|
|
||||||
checking Bison's XML automaton report for every working grammar passed to
|
|
||||||
Bison in the test suite. The check just diffs the output of Bison's
|
|
||||||
included XSLT style sheets with the output of --report=all and --graph.
|
|
||||||
|
|
||||||
- running "make maintainer-check-release" takes care of running
|
|
||||||
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
|
||||||
|
|
||||||
- Change tests/atlocal/CFLAGS to add your preferred options.
|
|
||||||
|
|
||||||
- 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
|
|
||||||
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 maintainer tools, such as Autoconf. See above.
|
|
||||||
|
|
||||||
** Try to get the *.pot files to the Translation Project at least one
|
|
||||||
week before a stable release, to give them time to translate them. Before
|
|
||||||
generating the *.pot files, make sure that po/POTFILES.in and
|
|
||||||
runtime-po/POTFILES.in list all files with translatable strings. This
|
|
||||||
helps: grep -l '\<_(' *.
|
|
||||||
|
|
||||||
** Tests
|
|
||||||
See above.
|
|
||||||
|
|
||||||
** Update the foreign files
|
|
||||||
Running "./bootstrap" in the top level should update them all for you. This
|
|
||||||
covers PO files too. Sometimes a PO file contains problems that causes it
|
|
||||||
to be rejected by recent Gettext releases; please report these to the
|
|
||||||
Translation Project.
|
|
||||||
|
|
||||||
** Update README
|
|
||||||
Make sure the information in README is current. Most notably, make sure it
|
|
||||||
recommends a version of GNU M4 that is compatible with the latest Bison
|
|
||||||
sources.
|
|
||||||
|
|
||||||
** Check copyright years.
|
|
||||||
We update years in copyright statements throughout Bison once at the 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
|
|
||||||
copyright statement for each Bison file, check the copyright statements that
|
|
||||||
the skeletons insert into generated parsers, and check all occurrences of
|
|
||||||
PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
|
||||||
|
|
||||||
** Update NEWS, commit and tag.
|
|
||||||
See do-release-commit-and-tag in README-release. For a while, we used beta
|
|
||||||
names such as "2.6_rc1". Now that we use gnulib in the release procedure,
|
|
||||||
we must use "2.5.90", which has the additional benefit of being properly
|
|
||||||
sorted in "git tag -l".
|
|
||||||
|
|
||||||
** make alpha, beta, or stable
|
|
||||||
See README-release.
|
|
||||||
|
|
||||||
** Upload
|
|
||||||
There are two ways to upload the tarballs to the GNU servers: using gnupload
|
|
||||||
(from gnulib), or by hand. Obviously prefer the former. But in either
|
|
||||||
case, be sure to read the following paragraph.
|
|
||||||
|
|
||||||
*** Setup
|
|
||||||
You need "gnupg".
|
|
||||||
|
|
||||||
Make sure your public key has been uploaded at least to keys.gnupg.net. You
|
|
||||||
can upload it with:
|
|
||||||
|
|
||||||
gpg --keyserver keys.gnupg.net --send-keys F125BDF3
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
*** make distcheck
|
|
||||||
*** gpg -b bison-2.3b.tar.gz
|
|
||||||
*** In a file named "bison-2.3b.tar.gz.directive", type:
|
|
||||||
|
|
||||||
version: 1.1
|
|
||||||
directory: bison
|
|
||||||
filename: bison-2.3b.tar.gz
|
|
||||||
|
|
||||||
*** gpg --clearsign bison-2.3b.tar.gz.directive
|
|
||||||
*** ftp ftp-upload.gnu.org # Log in as anonymous.
|
|
||||||
*** cd /incoming/alpha # cd /incoming/ftp for full release.
|
|
||||||
*** put bison-2.3b.tar.gz # This can take a while.
|
|
||||||
*** put bison-2.3b.tar.gz.sig
|
|
||||||
*** put bison-2.3b.tar.gz.directive.asc
|
|
||||||
*** Repeat all these steps for bison-2.3b.tar.xz.
|
|
||||||
|
|
||||||
** Update Bison manual on www.gnu.org.
|
|
||||||
|
|
||||||
The instructions below are obsolete, and left in case one would like to run
|
|
||||||
the commands by hand. Today, one just needs to run
|
|
||||||
|
|
||||||
$ make web-manual-update
|
|
||||||
|
|
||||||
See README-release.
|
|
||||||
|
|
||||||
*** You need a non-anonymous checkout of the web pages directory.
|
|
||||||
|
|
||||||
$ cvs -d [email protected]:/web/bison checkout bison
|
|
||||||
|
|
||||||
*** Get familiar with the instructions for web page maintainers.
|
|
||||||
http://www.gnu.org/server/standards/readme_index.html
|
|
||||||
http://www.gnu.org/server/standards/README.software.html
|
|
||||||
especially the note about symlinks.
|
|
||||||
|
|
||||||
*** Build the web pages.
|
|
||||||
Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
|
|
||||||
BISON_WWW_CHECKOUT refers to the web directory created above, do:
|
|
||||||
|
|
||||||
$ cd $BISON_CHECKOUT/doc
|
|
||||||
$ make stamp-vti
|
|
||||||
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
|
|
||||||
bison "Bison - GNU parser generator"
|
|
||||||
$ cd $BISON_WWW_CHECKOUT
|
|
||||||
|
|
||||||
Verify that the result looks sane.
|
|
||||||
|
|
||||||
*** Commit the modified and the new files.
|
|
||||||
|
|
||||||
*** Remove old files.
|
|
||||||
Find the files which have not been overwritten (because they belonged to
|
|
||||||
sections that have been removed or renamed):
|
|
||||||
|
|
||||||
$ cd manual/html_node
|
|
||||||
$ ls -lt
|
|
||||||
|
|
||||||
Remove these files and commit their removal to CVS. For each of these
|
|
||||||
files, add a line to the file .symlinks. This will ensure that hyperlinks
|
|
||||||
to the removed files will redirect to the entire manual; this is better than
|
|
||||||
a 404 error.
|
|
||||||
|
|
||||||
** Announce
|
|
||||||
The "make release" command just created a template,
|
|
||||||
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
|
|
||||||
|
|
||||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
|
||||||
|
|
||||||
where alpha can be replaced by beta or stable and F125BDF3 should be
|
|
||||||
replaced with your key ID.
|
|
||||||
|
|
||||||
Complete/fix the announcement file. The generated list of recipients
|
|
||||||
([email protected], [email protected], [email protected],
|
|
||||||
[email protected], and [email protected]) is
|
|
||||||
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 out
|
|
||||||
the rest of the template, search the mailing list archives for the most
|
|
||||||
recent release announcement.
|
|
||||||
|
|
||||||
For a stable release, send the same announcement on the comp.compilers
|
|
||||||
newsgroup by sending email to [email protected]. Do not make any Cc as the
|
|
||||||
moderator will throw away anything cross-posted or Cc'ed. It really needs
|
|
||||||
to be a separate message.
|
|
||||||
|
|
||||||
** Prepare NEWS
|
|
||||||
So that developers don't accidentally add new items to the old NEWS entry,
|
|
||||||
create a new empty entry in line 3 (without the two leading spaces):
|
|
||||||
|
|
||||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
|
||||||
|
|
||||||
Push these changes.
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
Copyright (C) 2002-2005, 2007-2015, 2018-2019 Free Software Foundation,
|
|
||||||
Inc.
|
|
||||||
|
|
||||||
This file is part of GNU Bison.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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:
|
|
||||||
@@ -0,0 +1,531 @@
|
|||||||
|
This file attempts to describe the rules to use when hacking Bison.
|
||||||
|
Don't put this file into the distribution.
|
||||||
|
|
||||||
|
Everything related to the development of Bison is on Savannah:
|
||||||
|
http://savannah.gnu.org/projects/bison/.
|
||||||
|
|
||||||
|
|
||||||
|
Administrivia
|
||||||
|
=============
|
||||||
|
|
||||||
|
## If you incorporate a change from somebody on the net:
|
||||||
|
First, if it is a large change, you must make sure they have signed the
|
||||||
|
appropriate paperwork. Second, be sure to add their name and email address
|
||||||
|
to THANKS.
|
||||||
|
|
||||||
|
## If a change fixes a test, mention the test in the commit message.
|
||||||
|
|
||||||
|
## Bug reports
|
||||||
|
If somebody reports a new bug, mention his name in the commit message and in
|
||||||
|
the test case you write. Put him into THANKS.
|
||||||
|
|
||||||
|
The correct response to most actual bugs is to write a new test case which
|
||||||
|
demonstrates the bug. Then fix the bug, re-run the test suite, and check
|
||||||
|
everything in.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Hacking
|
||||||
|
=======
|
||||||
|
|
||||||
|
## Visible Changes
|
||||||
|
Which include serious bug fixes, must be mentioned in NEWS.
|
||||||
|
|
||||||
|
## Translations
|
||||||
|
Only user visible strings are to be translated: error messages, bits of the
|
||||||
|
.output file etc. This excludes impossible error messages (comparable to
|
||||||
|
assert/abort), and all the --trace output which is meant for the maintainers
|
||||||
|
only.
|
||||||
|
|
||||||
|
## Syntax highlighting
|
||||||
|
It's quite nice to be in C++ mode when editing lalr1.cc for instance.
|
||||||
|
However tools such as Emacs will be fooled by the fact that braces and
|
||||||
|
parens do not nest, as in `[[}]]`. As a consequence you might be misguided
|
||||||
|
by its visual pairing to parens. The m4-mode is safer. Unfortunately the
|
||||||
|
m4-mode is also fooled by `#` which is sees as a comment, stops pairing with
|
||||||
|
parens/brackets that are inside...
|
||||||
|
|
||||||
|
## Coding Style
|
||||||
|
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.
|
||||||
|
|
||||||
|
Prefer "res" as the name of the local variable that will be "return"ed by
|
||||||
|
the function.
|
||||||
|
|
||||||
|
### Bison
|
||||||
|
Follow the GNU Coding Standards.
|
||||||
|
|
||||||
|
Don't reinvent the wheel: we use gnulib, which features many components.
|
||||||
|
Actually, Bison has legacy code that we should replace with gnulib modules
|
||||||
|
(e.g., many ad hoc implementations of lists).
|
||||||
|
|
||||||
|
### Skeletons
|
||||||
|
We try to use the "typical" coding style for each language.
|
||||||
|
|
||||||
|
#### CPP
|
||||||
|
We indent the CPP directives this way:
|
||||||
|
|
||||||
|
```
|
||||||
|
#if FOO
|
||||||
|
# if BAR
|
||||||
|
# define BAZ
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
Don't indent with leading spaces in the skeletons (it's ok in the grammar
|
||||||
|
files though, e.g., in `%code {...}` blocks).
|
||||||
|
|
||||||
|
On occasions, use `cppi -c` to see where we stand. We don't aim at full
|
||||||
|
correctness: depending `-d`, some bits can be in the *.c file, or the *.h
|
||||||
|
file within the double-inclusion cpp-guards. In that case, favor the case
|
||||||
|
of the *.h file, but don't waste time on this.
|
||||||
|
|
||||||
|
Don't hesitate to leave a comment on the `#endif` (e.g., `#endif /* FOO
|
||||||
|
*/`), especially for long blocks.
|
||||||
|
|
||||||
|
There is no conistency on `! defined` vs. `!defined`. The day gnulib
|
||||||
|
decides, we'll follow them.
|
||||||
|
|
||||||
|
#### C/C++
|
||||||
|
Follow the GNU Coding Standards.
|
||||||
|
|
||||||
|
The `glr.c` skeleton was implemented with `camlCase`. We are migrating it
|
||||||
|
to `snake_case`. Because we are standardizing the code, it is currently
|
||||||
|
inconsistent.
|
||||||
|
|
||||||
|
Use `YYFOO` and `yyfoo` for entities that are exposed to the user. They are
|
||||||
|
part of our contract with the users wrt backward compatibility.
|
||||||
|
|
||||||
|
Use `YY_FOO` and `yy_foo` for private matters. Users should not use them,
|
||||||
|
we are free to change them without fear of backward compatibility issues.
|
||||||
|
|
||||||
|
Use `*_t` for types, especially for `yy*_t` in which case we shouldn't worry
|
||||||
|
about the C standard introducing such a name.
|
||||||
|
|
||||||
|
#### C++
|
||||||
|
Follow the C++ Core Guidelines
|
||||||
|
(http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). The Google
|
||||||
|
ones may be interesting too
|
||||||
|
(https://google.github.io/styleguide/cppguide.html).
|
||||||
|
|
||||||
|
Our enumerators, such as the kinds (symbol and token kinds), should be lower
|
||||||
|
case, but it was too late to follow that track for token kinds, and symbol
|
||||||
|
kind enumerators are made to be consistent with them.
|
||||||
|
|
||||||
|
Use `*_type` for type aliases. Use `foo_get()` and `foo_set(v)` for
|
||||||
|
accessors, or simply `foo()` and `foo(v)`.
|
||||||
|
|
||||||
|
Use the `yy` prefix for private stuff, but there's no need for it in the
|
||||||
|
public API. The `yy` prefix is already taken care of via the namespace.
|
||||||
|
|
||||||
|
#### Java
|
||||||
|
We follow https://www.oracle.com/technetwork/java/codeconventions-150003.pdf
|
||||||
|
and https://google.github.io/styleguide/javaguide.html. Unfortunately at
|
||||||
|
some point some GNU Coding Style was installed in Java, but it's an error.
|
||||||
|
So we should for instance stop putting spaces in function calls. Because we
|
||||||
|
are standardizing the code, it is currently inconsistent.
|
||||||
|
|
||||||
|
Use a 2-space indentation (Google) rather than 4 (Oracle).
|
||||||
|
|
||||||
|
Don't use the "yy" prefix for public members: "getExpectedTokens", not
|
||||||
|
"yyexpectedTokens" or "yygetExpectedTokens".
|
||||||
|
|
||||||
|
## Commit Messages
|
||||||
|
Imitate the style we use. Use `git log` to get sources of inspiration.
|
||||||
|
|
||||||
|
If the changes have a small impact on Bison's generated parser, embed these
|
||||||
|
changes in the commit itself. If the impact is large, first push all the
|
||||||
|
changes except those about src/parse-gram.[ch], and then another commit
|
||||||
|
named "regen" which is only about them.
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
Bison supports tracing of its various steps, via the `--trace` option.
|
||||||
|
Since it is not meant for the end user, it is not displayed by `bison
|
||||||
|
--help`, nor is it documented in the manual. Instead, run `bison
|
||||||
|
--trace=help`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Working from the Repository
|
||||||
|
===========================
|
||||||
|
|
||||||
|
These notes intend to help people working on the checked-out sources. These
|
||||||
|
requirements do not apply when building from a distribution tarball.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
We've opted to keep only the highest-level sources in the repository. This
|
||||||
|
eases our maintenance burden, (fewer merges etc.), but imposes more
|
||||||
|
requirements on anyone wishing to build from the just-checked-out sources.
|
||||||
|
For example, you have to use the latest stable versions of the maintainer
|
||||||
|
tools we depend upon, including:
|
||||||
|
|
||||||
|
- Autoconf <http://www.gnu.org/software/autoconf/>
|
||||||
|
- Automake <http://www.gnu.org/software/automake/>
|
||||||
|
- Flex <http://www.gnu.org/software/flex/>
|
||||||
|
- Gettext <http://www.gnu.org/software/gettext/>
|
||||||
|
- Graphviz <http://www.graphviz.org>
|
||||||
|
- Gzip <http://www.gnu.org/software/gzip/>
|
||||||
|
- Help2man <http://www.gnu.org/software/help2man/>
|
||||||
|
- Perl <http://www.cpan.org/>
|
||||||
|
- Rsync <http://samba.anu.edu.au/rsync/>
|
||||||
|
- Tar <http://www.gnu.org/software/tar/>
|
||||||
|
- Texinfo <http://www.gnu.org/software/texinfo/>
|
||||||
|
|
||||||
|
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
|
||||||
|
your architecture.
|
||||||
|
|
||||||
|
If you're using a GNU/Linux distribution, the easiest way to install the
|
||||||
|
above packages depends on your system. The following shell command should
|
||||||
|
work for Debian-based systems such as Ubuntu:
|
||||||
|
|
||||||
|
sudo apt-get install \
|
||||||
|
autoconf automake autopoint flex graphviz help2man texinfo valgrind
|
||||||
|
|
||||||
|
Bison is written using Bison grammars, so there are bootstrapping issues.
|
||||||
|
The bootstrap script attempts to discover when the C code generated from the
|
||||||
|
grammars is out of date, and to bootstrap with an 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.
|
||||||
|
|
||||||
|
Only building the initial full source tree will be a bit painful. Later,
|
||||||
|
after synchronizing from the repository a plain 'make' should be sufficient.
|
||||||
|
Note, however, that when gnulib is updated, running './bootstrap' again
|
||||||
|
might be needed.
|
||||||
|
|
||||||
|
## First checkout
|
||||||
|
|
||||||
|
Obviously, if you are reading these notes, you did manage to check out this
|
||||||
|
package from the repository. For the record, you will find all the relevant
|
||||||
|
information on http://savannah.gnu.org/git/?group=bison.
|
||||||
|
|
||||||
|
Bison uses Git submodules: subscriptions to other Git repositories. In
|
||||||
|
particular it uses gnulib, the GNU portability library. To ask Git to
|
||||||
|
perform the first checkout of the submodules, run
|
||||||
|
|
||||||
|
$ git submodule update --init
|
||||||
|
|
||||||
|
The next step is to get other files needed to build, which are extracted
|
||||||
|
from other source packages:
|
||||||
|
|
||||||
|
$ ./bootstrap
|
||||||
|
|
||||||
|
Bootstrapping updates the submodules to the versions registered in the
|
||||||
|
top-level directory. To change gnulib, first check out the version you want
|
||||||
|
in `gnulib`, then commit this change in Bison's repository, and finally run
|
||||||
|
bootstrap.
|
||||||
|
|
||||||
|
If it fails with missing symbols (e.g., `error: possibly undefined macro:
|
||||||
|
AC_PROG_GNU_M4`), you are likely to have forgotten the submodule
|
||||||
|
initialization part. To recover from it, run `git reset --hard HEAD`, and
|
||||||
|
restart with the submodule initialization. Otherwise, there you are! Just
|
||||||
|
|
||||||
|
$ ./configure
|
||||||
|
$ make
|
||||||
|
$ make check
|
||||||
|
|
||||||
|
At this point, there should be no difference between your local copy, and
|
||||||
|
the master copy:
|
||||||
|
|
||||||
|
$ git diff
|
||||||
|
|
||||||
|
should output no difference.
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
## Updating
|
||||||
|
|
||||||
|
If you have git at version 1.8.2 or later, the command
|
||||||
|
|
||||||
|
$ git submodule update --recursive --remote
|
||||||
|
|
||||||
|
will be useful for updating to the latest version of all submodules.
|
||||||
|
|
||||||
|
Under earlier versions, use of submodules make things somewhat different
|
||||||
|
because git does not yet support recursive operations: submodules must be
|
||||||
|
taken care of explicitly.
|
||||||
|
|
||||||
|
### Updating Bison
|
||||||
|
|
||||||
|
If you pull a newer version of a branch, say via `git pull`, you might
|
||||||
|
import requests for updated submodules. A simple `git diff` will reveal if
|
||||||
|
the current version of the submodule (i.e., the actual contents of the
|
||||||
|
gnulib directory) and the current request from the subscriber (i.e., the
|
||||||
|
reference of the version of gnulib that the Bison repository requests)
|
||||||
|
differ. To upgrade the submodules (i.e., to check out the version that is
|
||||||
|
actually requested by the subscriber, run `git submodule update`.
|
||||||
|
|
||||||
|
$ git pull
|
||||||
|
$ git submodule update
|
||||||
|
|
||||||
|
### Updating a submodule
|
||||||
|
To update a submodule, say gnulib, do as follows:
|
||||||
|
|
||||||
|
Get the most recent version of the master branch from git.
|
||||||
|
|
||||||
|
$ cd gnulib
|
||||||
|
$ git fetch
|
||||||
|
$ git checkout -b master --track origin/master
|
||||||
|
|
||||||
|
Make sure Bison can live with that version of gnulib.
|
||||||
|
|
||||||
|
$ cd ..
|
||||||
|
$ ./bootstrap
|
||||||
|
$ make distcheck
|
||||||
|
|
||||||
|
Register your changes.
|
||||||
|
|
||||||
|
$ git commit ...
|
||||||
|
|
||||||
|
For a suggestion of what gnulib commit might be stable enough for a formal
|
||||||
|
release, see the ChangeLog in the latest gnulib snapshot at
|
||||||
|
http://erislabs.net/ianb/projects/gnulib/.
|
||||||
|
|
||||||
|
The Autoconf files we use are currently:
|
||||||
|
- m4/m4.m4
|
||||||
|
- lib/m4sugar/m4sugar.m4
|
||||||
|
- lib/m4sugar/foreach.m4
|
||||||
|
|
||||||
|
These files don't change very often in Autoconf, so it should be relatively
|
||||||
|
straight-forward to examine the differences in order to decide whether to
|
||||||
|
update.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
Bison is self-hosted: its parser is generated by Bison. We don't force
|
||||||
|
ourselves to use the previous release of Bison, we use the current git
|
||||||
|
master for several reasons:
|
||||||
|
- dogfooding: let Bison be its first user
|
||||||
|
- monitoring: seeing the diff on the generated parsers with git is very
|
||||||
|
helpful, as it allows to see easily the impact of the changes on a real
|
||||||
|
case parser.
|
||||||
|
|
||||||
|
If you are unlucky the generated files, src/parse-gram.[ch], may be older
|
||||||
|
than their source, src/parse-gram.y. And your current version of Bison
|
||||||
|
might not be able to grok it. In that case, first refresh the generated
|
||||||
|
files:
|
||||||
|
|
||||||
|
$ touch src/parse-gram.[ch]
|
||||||
|
|
||||||
|
Then proceed.
|
||||||
|
|
||||||
|
In case you wrecked your current copy of the parser, get back the previous
|
||||||
|
version, compile bison, then force it to recreate the files:
|
||||||
|
|
||||||
|
$ git checkout HEAD^ src/parse-gram.[ch]
|
||||||
|
$ make -C _build
|
||||||
|
$ touch src/parse-gram.y
|
||||||
|
$ make -C _build
|
||||||
|
|
||||||
|
|
||||||
|
Test Suite
|
||||||
|
==========
|
||||||
|
|
||||||
|
## make check
|
||||||
|
Consume without moderation. It is composed of two kinds of tests: the
|
||||||
|
examples, and the main test suite.
|
||||||
|
|
||||||
|
### The Examples
|
||||||
|
In examples/, there is a number of ready-to-use examples (see
|
||||||
|
examples/README.md). These examples have small test suites run by `make
|
||||||
|
check`. The test results are in local `*.log` files (e.g.,
|
||||||
|
`$build/examples/c/calc/calc.log`).
|
||||||
|
|
||||||
|
### The Main Test Suite
|
||||||
|
The main test suite, in tests/, is written on top of GNU Autotest, which is
|
||||||
|
part of Autoconf. Run `info autoconf 'Using Autotest'` to read the
|
||||||
|
documentation, not only about how to write tests, but also where are the
|
||||||
|
logs, how to read them etc.
|
||||||
|
|
||||||
|
The main test suite generates a log for each test (e.g.,
|
||||||
|
`$build/tests/testsuite.dir/004/testsuite.log` for test #4), and a main log
|
||||||
|
file in `$build/tests/testsuite.log`. The latter is meant for end users: it
|
||||||
|
contains lots of details that should help diagnosing issues, including build
|
||||||
|
issues. The per-test logs are more convenient when working locally.
|
||||||
|
|
||||||
|
#### TESTSUITEFLAGS
|
||||||
|
To run just the main test suite, run `make check-local`.
|
||||||
|
|
||||||
|
The default is for make check-local to run all tests sequentially. This can
|
||||||
|
be very time consuming when checking repeatedly or on slower setups. This
|
||||||
|
can be sped up in two ways:
|
||||||
|
|
||||||
|
Using -j, in a make-like fashion, for example:
|
||||||
|
|
||||||
|
$ make check-local TESTSUITEFLAGS='-j8'
|
||||||
|
|
||||||
|
Actually, when using GNU Make, TESTSUITEFLAGS defaults to the -jN passed to
|
||||||
|
it, so you may simply run
|
||||||
|
|
||||||
|
$ make check-local -j8
|
||||||
|
|
||||||
|
Running only the tests of a certain category, as specified in the AT files
|
||||||
|
with AT_KEYWORDS([[category]]). Categories include:
|
||||||
|
- c++, for c++ parsers
|
||||||
|
- deprec, for tests concerning deprecated constructs.
|
||||||
|
- glr, for glr parsers
|
||||||
|
- java, for java parsers
|
||||||
|
- report, for automaton dumps
|
||||||
|
|
||||||
|
To get a list of all the tests (and their keywords for -k), run
|
||||||
|
|
||||||
|
$ ./tests/testsuite -l
|
||||||
|
|
||||||
|
To run a specific set of tests, use -k (for "keyword"). For example:
|
||||||
|
|
||||||
|
$ make check-local TESTSUITEFLAGS='-k c++'
|
||||||
|
|
||||||
|
Both can be combined.
|
||||||
|
|
||||||
|
$ make check-local TESTSUITEFLAGS='-j8 -k c++'
|
||||||
|
|
||||||
|
To rerun the tests that failed:
|
||||||
|
|
||||||
|
$ make recheck -j5
|
||||||
|
|
||||||
|
#### Updating the Expectations
|
||||||
|
Sometimes some changes have a large impact on the test suite (e.g., when we
|
||||||
|
added the `[-Wother]` part to all the warnings). Part of the update can be
|
||||||
|
done with a crude tool: `build-aux/update-test`.
|
||||||
|
|
||||||
|
Once you ran the test suite, and therefore have many `testsuite.log` files,
|
||||||
|
run, from the source tree:
|
||||||
|
|
||||||
|
$ ./build-aux/update-test $build/tests/testsuite.dir/*/testsuite.log
|
||||||
|
|
||||||
|
where `$build` would be your build tree. This will hopefully update most
|
||||||
|
tests. Re-run the test suite. It might be interesting to run `update-test`
|
||||||
|
again, since some early failures may stop latter tests from being run. Yet
|
||||||
|
at some point, you'll have to fix remaining issues by hand...
|
||||||
|
|
||||||
|
|
||||||
|
## Running Java parsers
|
||||||
|
Use the `javaexec.sh` script. For instance to run the parser of test case
|
||||||
|
504:
|
||||||
|
|
||||||
|
$ sh ./_build/javaexec.sh -cp ./_build/tests/testsuite.dir/504 Calc
|
||||||
|
|
||||||
|
## 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
|
||||||
|
Try to run the test suite with more severe conditions before a
|
||||||
|
release:
|
||||||
|
|
||||||
|
- Configure the package with --enable-gcc-warnings, so that one checks that
|
||||||
|
1. Bison compiles cleanly, 2. the parsers it produces compile cleanly too.
|
||||||
|
|
||||||
|
- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules 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 gnulib.
|
||||||
|
|
||||||
|
- run `make maintainer-check` which:
|
||||||
|
- runs `valgrind -q bison` to run Bison under Valgrind.
|
||||||
|
- runs the parsers under Valgrind.
|
||||||
|
- runs the test suite with G++ as C compiler...
|
||||||
|
|
||||||
|
- run `make maintainer-check-push`, which runs `make maintainer-check` while
|
||||||
|
activating the push implementation and its pull interface wrappers in many
|
||||||
|
test cases that were originally written to exercise only the pull
|
||||||
|
implementation. This makes certain the push implementation can perform
|
||||||
|
every task the pull implementation can.
|
||||||
|
|
||||||
|
- run `make maintainer-check-xml`, which runs `make maintainer-check` while
|
||||||
|
checking Bison's XML automaton report for every working grammar passed to
|
||||||
|
Bison in the test suite. The check just diffs the output of Bison's
|
||||||
|
included XSLT style sheets with the output of --report=all and --graph.
|
||||||
|
|
||||||
|
- running `make maintainer-check-release` takes care of running
|
||||||
|
maintainer-check, maintainer-check-push and maintainer-check-xml.
|
||||||
|
|
||||||
|
- Change tests/atlocal/CFLAGS to add your preferred options.
|
||||||
|
|
||||||
|
- Test with a very recent version of GCC for both C and C++. Testing with
|
||||||
|
older versions that are still in use is nice too.
|
||||||
|
|
||||||
|
## gnulib
|
||||||
|
To run tests on gnulib components (e.g., on bitset):
|
||||||
|
|
||||||
|
cd gnulib
|
||||||
|
./gnulib-tool --test bitset-tests
|
||||||
|
|
||||||
|
possibly within a specified environment:
|
||||||
|
|
||||||
|
CC='gcc-mp-8 -fsanitize=undefined' ./gnulib-tool --test bitset-tests
|
||||||
|
|
||||||
|
To be able to run the tests several times, and to use symlinks instead of
|
||||||
|
copies so that one can update the origin gnulib directory and immediately
|
||||||
|
re-run the tests, run:
|
||||||
|
|
||||||
|
./gnulib-tool --symlink --create-test --dir=/tmp/gnutest bitset-tests
|
||||||
|
cd /tmp/gnutest
|
||||||
|
./configure -C CC='gcc-mp-8 -fsanitize=undefined' CFLAGS='-ggdb'
|
||||||
|
make check
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Release Procedure
|
||||||
|
=================
|
||||||
|
|
||||||
|
See README-release.
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Copyright (C) 2002-2005, 2007-2015, 2018-2020 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
mode: markdown
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
||||||
|
LocalWords: submodule init cd distcheck ChangeLog valgrind sigreturn sudo
|
||||||
|
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||||
|
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||||
|
LocalWords: symlinks vti html lt POSIX Cc'ed Graphviz Texinfo autoconf jN
|
||||||
|
LocalWords: automake autopoint graphviz texinfo PROG Wother parsers YYFOO
|
||||||
|
LocalWords: TESTSUITEFLAGS deprec struct gnulib's getopt config ggdb yyfoo
|
||||||
|
LocalWords: bitset fsanitize symlink CFLAGS MERCHANTABILITY ispell wrt YY
|
||||||
|
LocalWords: american Administrivia camlCase yy accessors namespace src
|
||||||
|
LocalWords: getExpectedTokens yyexpectedTokens yygetExpectedTokens
|
||||||
|
LocalWords: regen dogfooding Autotest testsuite
|
||||||
|
|
||||||
|
-->
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
From phr Tue Jul 8 10:36:19 1986
|
|
||||||
Date: Tue, 8 Jul 86 00:52:24 EDT
|
|
||||||
From: phr (Paul Rubin)
|
|
||||||
To: riferguson%[email protected], tower
|
|
||||||
Subject: Re: Bison documentation?
|
|
||||||
|
|
||||||
The main difference between Bison and Yacc that I know of is that
|
|
||||||
Bison supports the @N construction, which gives you access to
|
|
||||||
the starting and ending line number and character number associated
|
|
||||||
with any of the symbols in the current rule.
|
|
||||||
|
|
||||||
Also, Bison supports the command '%expect N' which says not to mention
|
|
||||||
the conflicts if there are N shift/reduce conflicts and no reduce/reduce
|
|
||||||
conflicts.
|
|
||||||
|
|
||||||
The differences in the algorithms stem mainly from the horrible
|
|
||||||
kludges that Johnson had to perpetrate to make Yacc fit in a PDP-11.
|
|
||||||
|
|
||||||
Also, Bison uses a faster but less space-efficient encoding for the
|
|
||||||
parse tables (see Corbett's PhD thesis from Berkeley, "Static
|
|
||||||
Semantics in Compiler Error Recovery", June 1985, Report No. UCB/CSD
|
|
||||||
85/251), and more modern technique for generating the lookahead sets.
|
|
||||||
(See Frank DeRemer and Thomas Pennello, "Efficient Computation of
|
|
||||||
LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
|
|
||||||
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
|
||||||
technique is the standard one now.)
|
|
||||||
|
|
||||||
paul rubin
|
|
||||||
free software foundation
|
|
||||||
|
|
||||||
|
|
||||||
[DeRemer-Pennello reference corrected by Paul Eggert <[email protected]>,
|
|
||||||
2004-06-21.]
|
|
||||||
@@ -4,12 +4,15 @@ it is today without the invaluable help of these people:
|
|||||||
Aaro Koskinen [email protected]
|
Aaro Koskinen [email protected]
|
||||||
Аскар Сафин [email protected]
|
Аскар Сафин [email protected]
|
||||||
Adam Sampson [email protected]
|
Adam Sampson [email protected]
|
||||||
|
Adrian Vogelsgesang [email protected]
|
||||||
|
Ahcheong Lee [email protected]
|
||||||
Airy Andre [email protected]
|
Airy Andre [email protected]
|
||||||
Akim Demaille akim@lrde.epita.fr
|
Akim Demaille akim@gnu.org
|
||||||
Albert Chin-A-Young [email protected]
|
Albert Chin-A-Young [email protected]
|
||||||
Alexander Belopolsky [email protected]
|
Alexander Belopolsky [email protected]
|
||||||
Alexandre Duret-Lutz [email protected]
|
Alexandre Duret-Lutz [email protected]
|
||||||
Andre da Costa Barros [email protected]
|
Andre da Costa Barros [email protected]
|
||||||
|
Andreas Damm [email protected]
|
||||||
Andreas Schwab [email protected]
|
Andreas Schwab [email protected]
|
||||||
Andrew Suffield [email protected]
|
Andrew Suffield [email protected]
|
||||||
Angelo Borsotti [email protected]
|
Angelo Borsotti [email protected]
|
||||||
@@ -17,7 +20,9 @@ Anthony Heading [email protected]
|
|||||||
Antonio Silva Correia [email protected]
|
Antonio Silva Correia [email protected]
|
||||||
Arnold Robbins [email protected]
|
Arnold Robbins [email protected]
|
||||||
Art Haas [email protected]
|
Art Haas [email protected]
|
||||||
|
Arthur Schwarz [email protected]
|
||||||
Askar Safin [email protected]
|
Askar Safin [email protected]
|
||||||
|
Balázs Scheidler [email protected]
|
||||||
Baron Schwartz [email protected]
|
Baron Schwartz [email protected]
|
||||||
Ben Pfaff [email protected]
|
Ben Pfaff [email protected]
|
||||||
Benoit Perrot [email protected]
|
Benoit Perrot [email protected]
|
||||||
@@ -32,6 +37,7 @@ Bruce Lilly [email protected]
|
|||||||
Bruno Haible [email protected]
|
Bruno Haible [email protected]
|
||||||
Charles-Henri de Boysson [email protected]
|
Charles-Henri de Boysson [email protected]
|
||||||
Christian Burger [email protected]
|
Christian Burger [email protected]
|
||||||
|
Clément Démoulins [email protected]
|
||||||
Colin Daley [email protected]
|
Colin Daley [email protected]
|
||||||
Cris Bailiff [email protected]
|
Cris Bailiff [email protected]
|
||||||
Cris van Pelt [email protected]
|
Cris van Pelt [email protected]
|
||||||
@@ -52,10 +58,14 @@ Derek M. Jones [email protected]
|
|||||||
Di-an Jan [email protected]
|
Di-an Jan [email protected]
|
||||||
Dick Streefland [email protected]
|
Dick Streefland [email protected]
|
||||||
Didier Godefroy [email protected]
|
Didier Godefroy [email protected]
|
||||||
|
Don Macpherson [email protected]
|
||||||
Efi Fogel [email protected]
|
Efi Fogel [email protected]
|
||||||
Enrico Scholz [email protected]
|
Enrico Scholz [email protected]
|
||||||
Eric Blake [email protected]
|
Eric Blake [email protected]
|
||||||
|
Eric S. Raymond [email protected]
|
||||||
Étienne Renault [email protected]
|
Étienne Renault [email protected]
|
||||||
|
Evan Lavelle [email protected]
|
||||||
|
Evan Nemerson [email protected]
|
||||||
Evgeny Stambulchik [email protected]
|
Evgeny Stambulchik [email protected]
|
||||||
Fabrice Bauzac [email protected]
|
Fabrice Bauzac [email protected]
|
||||||
Ferdinand Thiessen [email protected]
|
Ferdinand Thiessen [email protected]
|
||||||
@@ -64,6 +74,7 @@ Frank Heckenbach [email protected]
|
|||||||
Frans Englich [email protected]
|
Frans Englich [email protected]
|
||||||
Gabriel Rassoul [email protected]
|
Gabriel Rassoul [email protected]
|
||||||
Gary L Peskin [email protected]
|
Gary L Peskin [email protected]
|
||||||
|
Gavin Smith [email protected]
|
||||||
Georg Sauthoff [email protected]
|
Georg Sauthoff [email protected]
|
||||||
George Neuner [email protected]
|
George Neuner [email protected]
|
||||||
Gilles Espinasse [email protected]
|
Gilles Espinasse [email protected]
|
||||||
@@ -74,6 +85,7 @@ Hans Åberg [email protected]
|
|||||||
Horst Von Brand [email protected]
|
Horst Von Brand [email protected]
|
||||||
Jan Nieuwenhuizen [email protected]
|
Jan Nieuwenhuizen [email protected]
|
||||||
Jannick [email protected]
|
Jannick [email protected]
|
||||||
|
Jeff Hammond [email protected]
|
||||||
Jerry Quinn [email protected]
|
Jerry Quinn [email protected]
|
||||||
Jesse Thilo [email protected]
|
Jesse Thilo [email protected]
|
||||||
Jim Kent [email protected]
|
Jim Kent [email protected]
|
||||||
@@ -85,15 +97,19 @@ Jonathan Fabrizio [email protected]
|
|||||||
Jonathan Nieder [email protected]
|
Jonathan Nieder [email protected]
|
||||||
Josh Soref [email protected]
|
Josh Soref [email protected]
|
||||||
Juan Manuel Guerrero [email protected]
|
Juan Manuel Guerrero [email protected]
|
||||||
|
Karl Berry [email protected]
|
||||||
Kees Zeelenberg [email protected]
|
Kees Zeelenberg [email protected]
|
||||||
Keith Browne [email protected]
|
Keith Browne [email protected]
|
||||||
Ken Moffat [email protected]
|
Ken Moffat [email protected]
|
||||||
Kiyoshi Kanazawa [email protected]
|
Kiyoshi Kanazawa [email protected]
|
||||||
|
Lars Maier [email protected]
|
||||||
|
László Várady [email protected]
|
||||||
Laurent Mascherpa [email protected]
|
Laurent Mascherpa [email protected]
|
||||||
Lie Yan [email protected]
|
Lie Yan [email protected]
|
||||||
Magnus Fromreide [email protected]
|
Magnus Fromreide [email protected]
|
||||||
Marc Autret [email protected]
|
Marc Autret [email protected]
|
||||||
Marc Mendiola [email protected]
|
Marc Mendiola [email protected]
|
||||||
|
Marc Schönefeld [email protected]
|
||||||
Mark Boyall [email protected]
|
Mark Boyall [email protected]
|
||||||
Martin Jacobs [email protected]
|
Martin Jacobs [email protected]
|
||||||
Martin Mokrejs [email protected]
|
Martin Mokrejs [email protected]
|
||||||
@@ -114,10 +130,12 @@ Mike Sullivan [email protected]
|
|||||||
Nate Guerin [email protected]
|
Nate Guerin [email protected]
|
||||||
Neil Booth [email protected]
|
Neil Booth [email protected]
|
||||||
Nelson H. F. Beebe [email protected]
|
Nelson H. F. Beebe [email protected]
|
||||||
|
neok m4700 [email protected]
|
||||||
Nick Bowler [email protected]
|
Nick Bowler [email protected]
|
||||||
Nicolas Bedon [email protected]
|
Nicolas Bedon [email protected]
|
||||||
Nicolas Burrus [email protected]
|
Nicolas Burrus [email protected]
|
||||||
Nicolas Tisserand [email protected]
|
Nicolas Tisserand [email protected]
|
||||||
|
Nikki Valen [email protected]
|
||||||
Noah Friedman [email protected]
|
Noah Friedman [email protected]
|
||||||
Odd Arild Olsen [email protected]
|
Odd Arild Olsen [email protected]
|
||||||
Oleg Smolsky [email protected]
|
Oleg Smolsky [email protected]
|
||||||
@@ -126,6 +144,7 @@ Oliver Mangold [email protected]
|
|||||||
Paolo Bonzini [email protected]
|
Paolo Bonzini [email protected]
|
||||||
Paolo Simone Gasparello [email protected]
|
Paolo Simone Gasparello [email protected]
|
||||||
Pascal Bart [email protected]
|
Pascal Bart [email protected]
|
||||||
|
Patrice Dumas [email protected]
|
||||||
Paul Eggert [email protected]
|
Paul Eggert [email protected]
|
||||||
Paul Hilfinger [email protected]
|
Paul Hilfinger [email protected]
|
||||||
Per Allansson [email protected]
|
Per Allansson [email protected]
|
||||||
@@ -137,11 +156,13 @@ Petr Machata [email protected]
|
|||||||
Pho [email protected]
|
Pho [email protected]
|
||||||
Piotr Gackiewicz [email protected]
|
Piotr Gackiewicz [email protected]
|
||||||
Piotr Marcińczyk [email protected]
|
Piotr Marcińczyk [email protected]
|
||||||
|
Pramod Kumbhar [email protected]
|
||||||
Quentin Hocquet [email protected]
|
Quentin Hocquet [email protected]
|
||||||
Quoc Peyrot [email protected]
|
Quoc Peyrot [email protected]
|
||||||
R Blake [email protected]
|
R Blake [email protected]
|
||||||
Raja R Harinath [email protected]
|
Raja R Harinath [email protected]
|
||||||
Ralf Wildenhues [email protected]
|
Ralf Wildenhues [email protected]
|
||||||
|
Ryan [email protected]
|
||||||
Rich Wilson [email protected]
|
Rich Wilson [email protected]
|
||||||
Richard Stallman [email protected]
|
Richard Stallman [email protected]
|
||||||
Rici Lake [email protected]
|
Rici Lake [email protected]
|
||||||
@@ -164,16 +185,22 @@ Sum Wu [email protected]
|
|||||||
Théophile Ranquet [email protected]
|
Théophile Ranquet [email protected]
|
||||||
Thiru Ramakrishnan [email protected]
|
Thiru Ramakrishnan [email protected]
|
||||||
Thomas Jahns [email protected]
|
Thomas Jahns [email protected]
|
||||||
|
Thomas Petazzoni [email protected]
|
||||||
Tim Josling [email protected]
|
Tim Josling [email protected]
|
||||||
Tim Landscheidt [email protected]
|
Tim Landscheidt [email protected]
|
||||||
Tim Van Holder [email protected]
|
Tim Van Holder [email protected]
|
||||||
Tobias Frost [email protected]
|
Tobias Frost [email protected]
|
||||||
|
Todd Freed [email protected]
|
||||||
|
Tom Kramer [email protected]
|
||||||
Tom Lane [email protected]
|
Tom Lane [email protected]
|
||||||
Tom Tromey [email protected]
|
Tom Tromey [email protected]
|
||||||
|
Tomasz Kłoczko [email protected]
|
||||||
Tommy Nordgren [email protected]
|
Tommy Nordgren [email protected]
|
||||||
Troy A. Johnson [email protected]
|
Troy A. Johnson [email protected]
|
||||||
Tys Lefering [email protected]
|
Tys Lefering [email protected]
|
||||||
|
Uxio Prego [email protected]
|
||||||
Valentin Tolmer [email protected]
|
Valentin Tolmer [email protected]
|
||||||
|
wcventure [email protected]
|
||||||
Victor Khomenko [email protected]
|
Victor Khomenko [email protected]
|
||||||
Victor Zverovich [email protected]
|
Victor Zverovich [email protected]
|
||||||
Vin Shelton [email protected]
|
Vin Shelton [email protected]
|
||||||
@@ -186,8 +213,11 @@ Wolfgang Thaller [email protected]
|
|||||||
Wolfram Wagner [email protected]
|
Wolfram Wagner [email protected]
|
||||||
Wwp [email protected]
|
Wwp [email protected]
|
||||||
xolodho [email protected]
|
xolodho [email protected]
|
||||||
|
Yuichiro Kaneko [email protected]
|
||||||
Zack Weinberg [email protected]
|
Zack Weinberg [email protected]
|
||||||
|
江 祖铭 [email protected]
|
||||||
長田偉伸 [email protected]
|
長田偉伸 [email protected]
|
||||||
|
马俊 [email protected]
|
||||||
|
|
||||||
Many people are not named here because we lost track of them. We
|
Many people are not named here because we lost track of them. We
|
||||||
thank them! Please, help us keeping this list up to date.
|
thank them! Please, help us keeping this list up to date.
|
||||||
@@ -199,7 +229,7 @@ End:
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2000-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2000-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Parser Generator.
|
This file is part of Bison, the GNU Parser Generator.
|
||||||
|
|
||||||
|
|||||||
@@ -1,68 +1,230 @@
|
|||||||
* Bison 3.4
|
* Bison 3.7
|
||||||
** injection rules
|
** Bistromathic
|
||||||
** glr.cc
|
- Hitting tab on a line with a syntax error is ugly
|
||||||
move glr.c into the yy namespace
|
|
||||||
** improve syntax errors (UTF-8, internationalization)
|
|
||||||
Bison depends on the current locale. For instance:
|
|
||||||
|
|
||||||
%define parse.error verbose
|
- Be robust to existing ~/.inputrc
|
||||||
%code top {
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
void yyerror(const char* msg) { fprintf(stderr, "%s\n", msg); }
|
|
||||||
int yylex() { return 0; }
|
|
||||||
}
|
|
||||||
%%
|
|
||||||
exp: "↦" | "🎅🐃" | '\n'
|
|
||||||
%%
|
|
||||||
int main() { return yyparse(); }
|
|
||||||
|
|
||||||
gives different results with/without LC_ALL=C.
|
- How about not evaluating incomplete lines when the text is not finished
|
||||||
|
(as shells do).
|
||||||
|
|
||||||
$ LC_ALL=C /opt/local/bin/bison /tmp/mangle.y -o ascii.c
|
** Doc
|
||||||
$ /opt/local/bin/bison /tmp/mangle.y -o utf8.c
|
*** api.header.include
|
||||||
$ diff -u ascii.c utf8.c -I#line
|
|
||||||
--- ascii.c 2019-01-12 08:15:35.878010093 +0100
|
|
||||||
+++ utf8.c 2019-01-12 08:15:38.856495929 +0100
|
|
||||||
@@ -415,9 +415,8 @@
|
|
||||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
|
||||||
static const char *const yytname[] =
|
|
||||||
{
|
|
||||||
- "$end", "error", "$undefined", "\"\\342\\206\\246\"",
|
|
||||||
- "\"\\360\\237\\216\\205\\360\\237\\220\\203\"", "'\\n'", "$accept",
|
|
||||||
- "exp", YY_NULLPTR
|
|
||||||
+ "$end", "error", "$undefined", "\"↦\"", "\"🎅🐃\"", "'\\n'",
|
|
||||||
+ "$accept", "exp", YY_NULLPTR
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
$ gcc ascii.c -o ascii && ./ascii
|
** Questions
|
||||||
syntax error, unexpected $end, expecting "\342\206\246" or "\360\237\216\205\360\237\220\203" or '\n'
|
*** Java
|
||||||
$ gcc utf8.c -o utf8 && ./utf8
|
- Should i18n be part of the Lexer? Currently it's a static method of
|
||||||
syntax error, unexpected $end, expecting ↦ or 🎅🐃 or '\n'
|
Lexer.
|
||||||
|
|
||||||
|
- is there a migration path that would allow to use TokenKinds in
|
||||||
|
yylex?
|
||||||
|
|
||||||
While at it, we should stop using "$end" by default, in favor of "end of
|
- define the tokens as an enum too.
|
||||||
file", or "end of input", whatever.
|
|
||||||
|
|
||||||
** use gettext-h in gnulib instead of gettext
|
- promote YYEOF rather than EOF.
|
||||||
** use gnulib-po
|
|
||||||
For some reason, according to syntax-check, we have to keep getopt.c in
|
|
||||||
POTIFILES.in, but not bitset/stats.c, although both come from gnulib. But
|
|
||||||
bitset/stats.c is a symlink, not getopt.c. This is fishy and should be
|
|
||||||
fixed.
|
|
||||||
|
|
||||||
Meanwhile, bitset/stats.c is removed from the set of translations, which is
|
*** D
|
||||||
not too much of a problem as users are not expected to see this.
|
- is there a way to attach yysymbol_name to the enum itself? As we did
|
||||||
|
in Java.
|
||||||
|
|
||||||
|
- It would be better to have TokenKind as return value. Can we use
|
||||||
|
reflection to support both output types?
|
||||||
|
|
||||||
|
** YYerror
|
||||||
|
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y;h=a712255af4f2f739c93336d4ff6556d932a426a5;hb=HEAD
|
||||||
|
|
||||||
|
should be updated to not use YYERRCODE. Returning an undef token is good
|
||||||
|
enough.
|
||||||
|
|
||||||
|
** Java
|
||||||
|
*** calc.at
|
||||||
|
Stop hard-coding "Calc". Adjust local.at (look for FIXME).
|
||||||
|
|
||||||
|
** Counter example generation
|
||||||
|
See https://github.com/akimd/bison/pull/15.
|
||||||
|
|
||||||
|
** Clean up
|
||||||
|
Rename user_token_number for tokens as "code". It's not a "user number",
|
||||||
|
it's the token code, and the user can control it, but this code always
|
||||||
|
exists.
|
||||||
|
|
||||||
|
See also USER_NUMBER_UNDEFINED and NUMBER_UNDEFINED.
|
||||||
|
|
||||||
|
Rename endtoken as eoftoken.
|
||||||
|
|
||||||
|
Also do it in data/skeletons.
|
||||||
|
|
||||||
|
Don't rename in Bison 3.6 (it would be logical to do so) because that
|
||||||
|
would probably create many conflicts in Vincent's work (see previous point).
|
||||||
|
|
||||||
|
** A dev warning for b4_
|
||||||
|
Maybe we should check for m4_ and b4_ leaking out of the m4 processing, as
|
||||||
|
Autoconf does. It would have caught overquotation issues.
|
||||||
|
|
||||||
|
** doc
|
||||||
|
I feel it's ugly to use the GNU style to declare functions in the doc. It
|
||||||
|
generates tons of white space in the page, and may contribute to bad page
|
||||||
|
breaks.
|
||||||
|
|
||||||
|
** consistency
|
||||||
|
token vs terminal, variable vs non terminal.
|
||||||
|
|
||||||
|
** api.token.raw
|
||||||
|
The YYUNDEFTOK could be assigned a semantic value so that yyerror could be
|
||||||
|
used to report invalid lexemes.
|
||||||
|
|
||||||
|
** push parsers
|
||||||
|
Consider deprecating impure push parsers. They add a lot of complexity, for
|
||||||
|
a bad feature. On the other hand, that would make it much harder to sit
|
||||||
|
push parsers on top of pull parser. Which is currently not relevant, since
|
||||||
|
push parsers are measurably slower.
|
||||||
|
|
||||||
|
** %define parse.error formatted
|
||||||
|
How about pushing bistromathics' yyreport_syntax_error as another standard
|
||||||
|
way to generate the error message, and leave to the user the task of
|
||||||
|
providing the message formats? Currently in bistro, it reads:
|
||||||
|
|
||||||
|
const char *
|
||||||
|
error_format_string (int argc)
|
||||||
|
{
|
||||||
|
switch (argc)
|
||||||
|
{
|
||||||
|
default: /* Avoid compiler warnings. */
|
||||||
|
case 0: return _("%@: syntax error");
|
||||||
|
case 1: return _("%@: syntax error: unexpected %u");
|
||||||
|
// TRANSLATORS: '%@' is a location in a file, '%u' is an
|
||||||
|
// "unexpected token", and '%0e', '%1e'... are expected tokens
|
||||||
|
// at this point.
|
||||||
|
//
|
||||||
|
// For instance on the expression "1 + * 2", you'd get
|
||||||
|
//
|
||||||
|
// 1.5: syntax error: expected - or ( or number or function or variable before *
|
||||||
|
case 2: return _("%@: syntax error: expected %0e before %u");
|
||||||
|
case 3: return _("%@: syntax error: expected %0e or %1e before %u");
|
||||||
|
case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
|
||||||
|
case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
|
||||||
|
case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
|
||||||
|
case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
|
||||||
|
case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e or %6e before %u");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
The message would have to be generated in a string, and pushed to yyerror.
|
||||||
|
Which will be a pain in the neck in yacc.c.
|
||||||
|
|
||||||
|
If we want to do that, we should think very carefully about the syntax of
|
||||||
|
the format string.
|
||||||
|
|
||||||
|
** yyclearin does not invoke the lookahead token's %destructor
|
||||||
|
https://lists.gnu.org/r/bug-bison/2018-02/msg00000.html
|
||||||
|
Rici:
|
||||||
|
|
||||||
|
> Modifying yyclearin so that it calls yydestruct seems like the simplest
|
||||||
|
> solution to this issue, but it is conceivable that such a change would
|
||||||
|
> break programs which already perform some kind of workaround in order to
|
||||||
|
> destruct the lookahead symbol. So it might be necessary to use some kind of
|
||||||
|
> compatibility %define, or to create a new replacement macro with a
|
||||||
|
> different name such as yydiscardin.
|
||||||
|
>
|
||||||
|
> At a minimum, the fact that yyclearin does not invoke the %destructor
|
||||||
|
> should be highlighted in the documentation, since it is not at all obvious.
|
||||||
|
|
||||||
|
** Issues in i18n
|
||||||
|
|
||||||
|
Les catégories d'avertissements incluent :
|
||||||
|
conflicts-sr conflits S/R (activé par défaut)
|
||||||
|
conflicts-rr conflits R/R (activé par défaut)
|
||||||
|
dangling-alias l'alias chaîne n'est pas attaché à un symbole
|
||||||
|
deprecated construction obsolète
|
||||||
|
empty-rule règle vide sans %empty
|
||||||
|
midrule-values valeurs de règle intermédiaire non définies ou inutilisées
|
||||||
|
precedence priorité et associativité inutiles
|
||||||
|
yacc incompatibilités avec POSIX Yacc
|
||||||
|
other tous les autres avertissements (activé par défaut)
|
||||||
|
all tous les avertissements sauf « dangling-alias » et « yacc »
|
||||||
|
no-CATEGORY désactiver les avertissements dans CATEGORIE
|
||||||
|
none désactiver tous les avertissements
|
||||||
|
error[=CATEGORY] traiter les avertissements comme des erreurs
|
||||||
|
|
||||||
|
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
||||||
|
|
||||||
|
* Bison 3.8
|
||||||
|
** Unit rules / Injection rules (Akim Demaille)
|
||||||
|
Maybe we could expand unit rules (or "injections", see
|
||||||
|
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
|
||||||
|
transform
|
||||||
|
|
||||||
|
exp: arith | bool;
|
||||||
|
arith: exp '+' exp;
|
||||||
|
bool: exp '&' exp;
|
||||||
|
|
||||||
|
into
|
||||||
|
|
||||||
|
exp: exp '+' exp | exp '&' exp;
|
||||||
|
|
||||||
|
when there are no actions. This can significantly speed up some grammars.
|
||||||
|
I can't find the papers. In particular the book 'LR parsing: Theory and
|
||||||
|
Practice' is impossible to find, but according to 'Parsing Techniques: a
|
||||||
|
Practical Guide', it includes information about this issue. Does anybody
|
||||||
|
have it?
|
||||||
|
|
||||||
|
** clean up (Akim Demaille)
|
||||||
|
Do not work on these items now, as I (Akim) have branches with a lot of
|
||||||
|
changes in this area (hitting several files), and no desire to have to fix
|
||||||
|
conflicts. Addressing these items will happen after my branches have been
|
||||||
|
merged.
|
||||||
|
|
||||||
|
*** lalr.c
|
||||||
|
Introduce a goto struct, and use it in place of from_state/to_state.
|
||||||
|
Rename states1 as path, length as pathlen.
|
||||||
|
Introduce inline functions for things such as nullable[*rp - ntokens]
|
||||||
|
where we need to map from symbol number to nterm number.
|
||||||
|
|
||||||
|
There are probably a significant part of the relations management that
|
||||||
|
should be migrated on top of a bitsetv.
|
||||||
|
|
||||||
|
*** closure
|
||||||
|
It should probably take a "state*" instead of two arguments.
|
||||||
|
|
||||||
|
*** traces
|
||||||
|
The "automaton" and "set" categories are not so useful. We should probably
|
||||||
|
introduce lr(0) and lalr, just the way we have ielr categories. The
|
||||||
|
"closure" function is too verbose, it should probably have its own category.
|
||||||
|
|
||||||
|
"set" can still be used for summariring the important sets. That would make
|
||||||
|
tests easy to maintain.
|
||||||
|
|
||||||
|
*** complain.*
|
||||||
|
Rename these guys as "diagnostics.*" (or "diagnose.*"), since that's the
|
||||||
|
name they have in gcc, clang, etc. Likewise for the complain_* series of
|
||||||
|
functions.
|
||||||
|
|
||||||
|
*** ritem
|
||||||
|
states/nstates, rules/nrules, ..., ritem/nritems
|
||||||
|
Fix the latter.
|
||||||
|
|
||||||
|
* Better error messages
|
||||||
|
The users are not provided with enough tools to forge their error messages.
|
||||||
|
See for instance "Is there an option to change the message produced by
|
||||||
|
YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
|
||||||
|
|
||||||
|
See also
|
||||||
|
https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
|
||||||
|
https://research.swtch.com/yyerror
|
||||||
|
http://gallium.inria.fr/~fpottier/publis/fpottier-reachability-cc2016.pdf
|
||||||
|
|
||||||
|
* Modernization
|
||||||
|
Fix data/skeletons/yacc.c so that it defines YYPTRDIFF_T properly for modern
|
||||||
|
and older C++ compilers. Currently the code defaults to defining it to
|
||||||
|
'long' for non-GCC compilers, but it should use the proper C++ magic to
|
||||||
|
define it to the same type as the C ptrdiff_t type.
|
||||||
|
|
||||||
* Completion
|
* Completion
|
||||||
Several features are not available in all the backends.
|
Several features are not available in all the backends.
|
||||||
|
|
||||||
- push parsers: glr.cc, lalr1.cc
|
- lac: D, Java (easy)
|
||||||
- ielr: C++ and Java
|
- push parsers: glr.c, glr.cc, lalr1.cc (not very difficult)
|
||||||
- glr: Java
|
- token constructors: Java, C, D (a bit difficult)
|
||||||
- token constructors: Java and C
|
- glr: D, Java (super difficult)
|
||||||
|
|
||||||
* Bugs
|
* Bugs
|
||||||
** Autotest has quotation issues
|
** Autotest has quotation issues
|
||||||
@@ -74,24 +236,42 @@ $ ./tests/testsuite -l | grep errors | sed q
|
|||||||
38: input.at:1730 errors
|
38: input.at:1730 errors
|
||||||
|
|
||||||
* Short term
|
* Short term
|
||||||
** consistency
|
** Get rid of YYPRINT and b4_toknum
|
||||||
token vs terminal
|
Besides yytoknum is wrong when api.token.raw is defined.
|
||||||
|
|
||||||
** yacc.c
|
** Better design for diagnostics
|
||||||
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
|
The current implementation of diagnostics is ad hoc, it grew organically.
|
||||||
than duplicating it.
|
It works as a series of calls to several functions, with dependency of the
|
||||||
|
latter calls on the former. For instance:
|
||||||
|
|
||||||
** C++
|
complain (&sym->location,
|
||||||
Move to int everywhere instead of unsigned? stack_size, etc. The parser
|
sym->content->status == needed ? complaint : Wother,
|
||||||
itself uses int (for yylen for instance), yet stack is based on size_t.
|
_("symbol %s is used, but is not defined as a token"
|
||||||
|
" and has no rules; did you mean %s?"),
|
||||||
|
quote_n (0, sym->tag),
|
||||||
|
quote_n (1, best->tag));
|
||||||
|
if (feature_flag & feature_caret)
|
||||||
|
location_caret_suggestion (sym->location, best->tag, stderr);
|
||||||
|
|
||||||
Maybe locations should also move to ints.
|
We should rewrite this in a more FP way:
|
||||||
|
|
||||||
** C
|
1. build a rich structure that denotes the (complete) diagnostic.
|
||||||
Introduce state_type rather than spreading yytype_int16 everywhere?
|
"Complete" in the sense that it also contains the suggestions, the list
|
||||||
|
of possible matches, etc.
|
||||||
|
|
||||||
** glr.c
|
2. send this to the pretty-printing routine. The diagnostic structure
|
||||||
yyspaceLeft should probably be a pointer diff.
|
should be sufficient so that we can generate all the 'format' of
|
||||||
|
diagnostics, including the fixits.
|
||||||
|
|
||||||
|
If properly done, this diagnostic module can be detached from Bison and be
|
||||||
|
put in gnulib. It could be used, for instance, for errors caught by
|
||||||
|
xgettext.
|
||||||
|
|
||||||
|
There's certainly already something alike in GCC. At least that's the
|
||||||
|
impression I get from reading the "-fdiagnostics-format=FORMAT" part of this
|
||||||
|
page:
|
||||||
|
|
||||||
|
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
|
||||||
|
|
||||||
** Graphviz display code thoughts
|
** Graphviz display code thoughts
|
||||||
The code for the --graph option is over two files: print_graph, and
|
The code for the --graph option is over two files: print_graph, and
|
||||||
@@ -112,9 +292,6 @@ Little effort seems to have been given to factoring these files and their
|
|||||||
rint{,-xml} counterpart. We would very much like to re-use the pretty format
|
rint{,-xml} counterpart. We would very much like to re-use the pretty format
|
||||||
of states from .output for the graphs, etc.
|
of states from .output for the graphs, etc.
|
||||||
|
|
||||||
Also, the underscore in print_graph.[ch] isn't very fitting considering the
|
|
||||||
dashes in the other filenames.
|
|
||||||
|
|
||||||
Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
|
Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
|
||||||
|
|
||||||
** push-parser
|
** push-parser
|
||||||
@@ -171,61 +348,15 @@ class in the printers/destructors, which is not good for an operator<<
|
|||||||
since it is no longer bound to a particular parser, it's just a
|
since it is no longer bound to a particular parser, it's just a
|
||||||
(standalone symbol).
|
(standalone symbol).
|
||||||
|
|
||||||
** Rename LR0.cc
|
|
||||||
as lr0.cc, why upper case?
|
|
||||||
|
|
||||||
* Various
|
* Various
|
||||||
** Rewrite glr.cc in C++
|
** Rewrite glr.cc in C++ (Valentin Tolmer)
|
||||||
As a matter of fact, it would be very interesting to see how much we can
|
As a matter of fact, it would be very interesting to see how much we can
|
||||||
share between lalr1.cc and glr.cc. Most of the skeletons should be common.
|
share between lalr1.cc and glr.cc. Most of the skeletons should be common.
|
||||||
It would be a very nice source of inspiration for the other languages.
|
It would be a very nice source of inspiration for the other languages.
|
||||||
|
|
||||||
** YYERRCODE
|
Valentin Tolmer is working on this.
|
||||||
Defined to 256, but not used, not documented. Probably the token
|
|
||||||
number for the error token, which POSIX wants to be 256, but which
|
|
||||||
Bison might renumber if the user used number 256. Keep fix and doc?
|
|
||||||
Throw away?
|
|
||||||
|
|
||||||
Also, why don't we output the token name of the error token in the
|
** yychar == YYEMPTY
|
||||||
output? It is explicitly skipped:
|
|
||||||
|
|
||||||
/* Skip error token and tokens without identifier. */
|
|
||||||
if (sym != errtoken && id)
|
|
||||||
|
|
||||||
Of course there are issues with name spaces, but if we disable we have
|
|
||||||
something which seems to be more simpler and more consistent instead
|
|
||||||
of the special case YYERRCODE.
|
|
||||||
|
|
||||||
enum yytokentype {
|
|
||||||
error = 256,
|
|
||||||
// ...
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
We could (should?) also treat the case of the undef_token, which is
|
|
||||||
numbered 257 for yylex, and 2 internal. Both appear for instance in
|
|
||||||
toknum:
|
|
||||||
|
|
||||||
const unsigned short
|
|
||||||
parser::yytoken_number_[] =
|
|
||||||
{
|
|
||||||
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
|
||||||
|
|
||||||
while here
|
|
||||||
|
|
||||||
enum yytokentype {
|
|
||||||
TOK_EOF = 0,
|
|
||||||
TOK_EQ = 258,
|
|
||||||
|
|
||||||
so both 256 and 257 are "mysterious".
|
|
||||||
|
|
||||||
const char*
|
|
||||||
const parser::yytname_[] =
|
|
||||||
{
|
|
||||||
"\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
|
|
||||||
|
|
||||||
|
|
||||||
** yychar == yyempty_
|
|
||||||
The code in yyerrlab reads:
|
The code in yyerrlab reads:
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF)
|
||||||
@@ -249,10 +380,13 @@ other improvements and also made it faster (probably because memory
|
|||||||
management is performed once instead of three times). I suggest that
|
management is performed once instead of three times). I suggest that
|
||||||
we do the same in yacc.c.
|
we do the same in yacc.c.
|
||||||
|
|
||||||
** yysyntax_error
|
(Some time later): it's also very nice to have three stacks: it's more dense
|
||||||
The code bw glr.c and yacc.c is really alike, we can certainly factor
|
as we don't lose bits to padding. For instance the typical stack for states
|
||||||
some parts.
|
will use 8 bits, while it is likely to consume 32 bits in a struct.
|
||||||
|
|
||||||
|
We need trustworthy benchmarks for Bison, for all our backends. Akim has a
|
||||||
|
few things scattered around; we need to put them in the repo, and make them
|
||||||
|
more useful.
|
||||||
|
|
||||||
* Report
|
* Report
|
||||||
|
|
||||||
@@ -263,7 +397,7 @@ grammars she is working on. We should probably also include some
|
|||||||
information about the variables (I'm not sure for instance we even
|
information about the variables (I'm not sure for instance we even
|
||||||
specify what LR variant was used).
|
specify what LR variant was used).
|
||||||
|
|
||||||
** GLR
|
** GLR
|
||||||
How would Paul like to display the conflicted actions? In particular,
|
How would Paul like to display the conflicted actions? In particular,
|
||||||
what when two reductions are possible on a given lookahead token, but one is
|
what when two reductions are possible on a given lookahead token, but one is
|
||||||
part of $default. Should we make the two reductions explicit, or just
|
part of $default. Should we make the two reductions explicit, or just
|
||||||
@@ -291,17 +425,36 @@ An Experimental Ambiguity Detection Tool ∗ Sylvain Schmitz
|
|||||||
LORIA, INRIA Nancy - Grand Est, Nancy, France
|
LORIA, INRIA Nancy - Grand Est, Nancy, France
|
||||||
|
|
||||||
* Extensions
|
* Extensions
|
||||||
|
** More languages?
|
||||||
|
Well, only if there is really some demand for it.
|
||||||
|
|
||||||
|
*** PHP
|
||||||
|
https://github.com/scfc/bison-php/blob/master/data/lalr1.php
|
||||||
|
|
||||||
|
*** Python
|
||||||
|
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
||||||
|
|
||||||
** Multiple start symbols
|
** Multiple start symbols
|
||||||
Would be very useful when parsing closely related languages.
|
Would be very useful when parsing closely related languages. The idea is to
|
||||||
|
declare several start symbols, for instance
|
||||||
|
|
||||||
** Better error messages
|
%start stmt expr
|
||||||
The users are not provided with enough tools to forge their error messages.
|
%%
|
||||||
See for instance "Is there an option to change the message produced by
|
stmt: ...
|
||||||
YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
|
expr: ...
|
||||||
|
|
||||||
See also
|
and to generate parse(), parse_stmt() and parse_expr(). Technically, the
|
||||||
https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
|
above grammar would be transformed into
|
||||||
and https://research.swtch.com/yyerror.
|
|
||||||
|
%start yy_start
|
||||||
|
%token YY_START_STMT YY_START_EXPR
|
||||||
|
%%
|
||||||
|
yy_start: YY_START_STMT stmt | YY_START_EXPR expr
|
||||||
|
|
||||||
|
so that there are no new conflicts in the grammar (as would undoubtedly
|
||||||
|
happen with yy_start: stmt | expr). Then adjust the skeletons so that this
|
||||||
|
initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the
|
||||||
|
corresponding parse function.
|
||||||
|
|
||||||
** %include
|
** %include
|
||||||
This is a popular demand. We already made many changes in the parser that
|
This is a popular demand. We already made many changes in the parser that
|
||||||
@@ -310,6 +463,12 @@ should make this reasonably easy to implement.
|
|||||||
Bruce Mardle <[email protected]>
|
Bruce Mardle <[email protected]>
|
||||||
https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
|
https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
|
||||||
|
|
||||||
|
However, there are many other things to do before having such a feature,
|
||||||
|
because I don't want a % equivalent to #include (which we all learned to
|
||||||
|
hate). I want something that builds "modules" of grammars, and assembles
|
||||||
|
them together, paying attention to keep separate bits separated, in pseudo
|
||||||
|
name spaces.
|
||||||
|
|
||||||
** Push parsers
|
** Push parsers
|
||||||
There is demand for push parsers in Java and C++. And GLR I guess.
|
There is demand for push parsers in Java and C++. And GLR I guess.
|
||||||
|
|
||||||
@@ -336,6 +495,10 @@ must be in the scanner: we must not parse what is in a switched off
|
|||||||
part of %if. Akim Demaille thinks it should be in the parser, so as
|
part of %if. Akim Demaille thinks it should be in the parser, so as
|
||||||
to avoid falling into another CPP mistake.
|
to avoid falling into another CPP mistake.
|
||||||
|
|
||||||
|
(Later): I'm sure there's actually good case for this. People who need that
|
||||||
|
feature can use m4/cpp on top of Bison. I don't think it is worth the
|
||||||
|
trouble in Bison itself.
|
||||||
|
|
||||||
** XML Output
|
** XML Output
|
||||||
There are couple of available extensions of Bison targeting some XML
|
There are couple of available extensions of Bison targeting some XML
|
||||||
output. Some day we should consider including them. One issue is
|
output. Some day we should consider including them. One issue is
|
||||||
@@ -355,32 +518,8 @@ XML output for GNU Bison
|
|||||||
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
|
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
|
||||||
http://www.cs.cornell.edu/andru/papers/cupex/
|
http://www.cs.cornell.edu/andru/papers/cupex/
|
||||||
|
|
||||||
* Unit rules
|
Andrew Myers and Vincent Imbimbo are working on this item, see
|
||||||
Maybe we could expand unit rules (or "injections", see
|
https://github.com/akimd/bison/issues/12
|
||||||
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
|
|
||||||
transform
|
|
||||||
|
|
||||||
exp: arith | bool;
|
|
||||||
arith: exp '+' exp;
|
|
||||||
bool: exp '&' exp;
|
|
||||||
|
|
||||||
into
|
|
||||||
|
|
||||||
exp: exp '+' exp | exp '&' exp;
|
|
||||||
|
|
||||||
when there are no actions. This can significantly speed up some grammars.
|
|
||||||
I can't find the papers. In particular the book 'LR parsing: Theory and
|
|
||||||
Practice' is impossible to find, but according to 'Parsing Techniques: a
|
|
||||||
Practical Guide', it includes information about this issue. Does anybody
|
|
||||||
have it?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Documentation
|
|
||||||
|
|
||||||
** History/Bibliography
|
|
||||||
Some history of Bison and some bibliography would be most welcome.
|
|
||||||
Are there any Texinfo standards for bibliography?
|
|
||||||
|
|
||||||
* Coding system independence
|
* Coding system independence
|
||||||
Paul notes:
|
Paul notes:
|
||||||
@@ -399,7 +538,7 @@ Paul notes:
|
|||||||
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
||||||
the source code. This should get fixed.
|
the source code. This should get fixed.
|
||||||
|
|
||||||
* Broken options ?
|
* Broken options?
|
||||||
** %token-table
|
** %token-table
|
||||||
** Skeleton strategy
|
** Skeleton strategy
|
||||||
Must we keep %token-table?
|
Must we keep %token-table?
|
||||||
@@ -411,15 +550,7 @@ It is unfortunate that there is a total order for precedence. It
|
|||||||
makes it impossible to have modular precedence information. We should
|
makes it impossible to have modular precedence information. We should
|
||||||
move to partial orders (sounds like series/parallel orders to me).
|
move to partial orders (sounds like series/parallel orders to me).
|
||||||
|
|
||||||
|
This is a prerequisite for modules.
|
||||||
* $undefined
|
|
||||||
From Hans:
|
|
||||||
- If the Bison generated parser experiences an undefined number in the
|
|
||||||
character range, that character is written out in diagnostic messages, an
|
|
||||||
addition to the $undefined value.
|
|
||||||
|
|
||||||
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
|
||||||
|
|
||||||
|
|
||||||
* Pre and post actions.
|
* Pre and post actions.
|
||||||
From: Florian Krohm <[email protected]>
|
From: Florian Krohm <[email protected]>
|
||||||
@@ -452,23 +583,6 @@ to bison. If you're interested, I'll work on a patch.
|
|||||||
* Better graphics
|
* Better graphics
|
||||||
Equip the parser with a means to create the (visual) parse tree.
|
Equip the parser with a means to create the (visual) parse tree.
|
||||||
|
|
||||||
* Complaint submessage indentation.
|
|
||||||
We already have an implementation that works fairly well for named
|
|
||||||
reference messages, but it would be nice to use it consistently for all
|
|
||||||
submessages from Bison. For example, the "previous definition"
|
|
||||||
submessage or the list of correct values for a %define variable might
|
|
||||||
look better with indentation.
|
|
||||||
|
|
||||||
However, the current implementation makes the assumption that the
|
|
||||||
location printed on the first line is not usually much shorter than the
|
|
||||||
locations printed on the submessage lines that follow. That assumption
|
|
||||||
may not hold true as often for some kinds of submessages especially if
|
|
||||||
we ever support multiple grammar files.
|
|
||||||
|
|
||||||
Here's a proposal for how a new implementation might look:
|
|
||||||
|
|
||||||
http://lists.gnu.org/archive/html/bison-patches/2009-09/msg00086.html
|
|
||||||
|
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
@@ -478,7 +592,7 @@ End:
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2019 Free Software
|
Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2020 Free Software
|
||||||
Foundation, Inc.
|
Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2019-01-04.17; # UTC
|
scriptversion=2020-04-13.15; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
# Copyright (C) 2003-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -166,7 +166,7 @@ bootstrap_epilogue() { :; }
|
|||||||
# specified directory. Fill in the first %s with the destination
|
# specified directory. Fill in the first %s with the destination
|
||||||
# directory and the second with the domain name.
|
# directory and the second with the domain name.
|
||||||
po_download_command_format=\
|
po_download_command_format=\
|
||||||
"wget --mirror --level=1 -nd -q -A.po -P '%s' \
|
"wget --mirror --level=1 -nd -nv -A.po -P '%s' \
|
||||||
https://translationproject.org/latest/%s/"
|
https://translationproject.org/latest/%s/"
|
||||||
|
|
||||||
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
|
||||||
@@ -970,7 +970,7 @@ bootstrap_post_import_hook \
|
|||||||
# Uninitialized submodules are listed with an initial dash.
|
# Uninitialized submodules are listed with an initial dash.
|
||||||
if $use_git && git submodule | grep '^-' >/dev/null; then
|
if $use_git && git submodule | grep '^-' >/dev/null; then
|
||||||
die "some git submodules are not initialized. " \
|
die "some git submodules are not initialized. " \
|
||||||
"Run 'git submodule init' and bootstrap again."
|
"Run 'git submodule update --init' and bootstrap again."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
||||||
|
|||||||
+22
-24
@@ -1,6 +1,6 @@
|
|||||||
# Bootstrap configuration.
|
# Bootstrap configuration.
|
||||||
|
|
||||||
# Copyright (C) 2006-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2006-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,24 +17,27 @@
|
|||||||
|
|
||||||
# gnulib modules used by this package.
|
# gnulib modules used by this package.
|
||||||
gnulib_modules='
|
gnulib_modules='
|
||||||
argmatch array-list assert
|
argmatch array-list assert assure
|
||||||
bitsetv
|
bitsetv
|
||||||
calloc-posix close closeout config-h c-strcase
|
calloc-posix close closeout config-h c-strcase
|
||||||
configmake
|
configmake
|
||||||
dirname
|
dirname
|
||||||
error extensions fdl fopen-safer
|
error extensions
|
||||||
|
fdl fopen-safer fstrcmp
|
||||||
getopt-gnu
|
getopt-gnu
|
||||||
gettext git-version-gen gitlog-to-changelog
|
gettext-h git-version-gen gitlog-to-changelog
|
||||||
gpl-3.0 hash inttypes isnan javacomp-script
|
gpl-3.0 intprops inttypes isnan javacomp-script
|
||||||
javaexec-script
|
javaexec-script
|
||||||
ldexpl
|
ldexpl
|
||||||
|
libtextstyle-optional
|
||||||
malloc-gnu
|
malloc-gnu
|
||||||
mbswidth
|
mbfile mbswidth
|
||||||
non-recursive-gnulib-prefix-hack
|
non-recursive-gnulib-prefix-hack
|
||||||
obstack
|
obstack
|
||||||
obstack-printf
|
obstack-printf
|
||||||
perror progname
|
perror progname
|
||||||
quote quotearg
|
quote quotearg
|
||||||
|
readline
|
||||||
readme-release
|
readme-release
|
||||||
realloc-posix
|
realloc-posix
|
||||||
relocatable-prog relocatable-script
|
relocatable-prog relocatable-script
|
||||||
@@ -44,9 +47,12 @@ gnulib_modules='
|
|||||||
unistd unistd-safer unlink unlocked-io
|
unistd unistd-safer unlink unlocked-io
|
||||||
update-copyright unsetenv verify
|
update-copyright unsetenv verify
|
||||||
warnings
|
warnings
|
||||||
|
winsz-ioctl
|
||||||
|
winsz-termios
|
||||||
xalloc
|
xalloc
|
||||||
xalloc-die
|
xalloc-die
|
||||||
xconcat-filename
|
xconcat-filename
|
||||||
|
xhash
|
||||||
xlist
|
xlist
|
||||||
xmemdup0
|
xmemdup0
|
||||||
xstrndup
|
xstrndup
|
||||||
@@ -55,6 +61,8 @@ gnulib_modules='
|
|||||||
vsnprintf-posix vsprintf-posix
|
vsnprintf-posix vsprintf-posix
|
||||||
'
|
'
|
||||||
|
|
||||||
|
checkout_only_file=README-hacking.md
|
||||||
|
|
||||||
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
||||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||||
--from-code=UTF-8\\\
|
--from-code=UTF-8\\\
|
||||||
@@ -67,24 +75,7 @@ XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
|||||||
--keyword=YY_ \\\
|
--keyword=YY_ \\\
|
||||||
'
|
'
|
||||||
|
|
||||||
# Gettext supplies these files, but we don't need them since
|
gnulib_tool_option_extras='--symlink --conditional-dependencies --makefile-name=gnulib.mk --po-base=gnulib-po --po-domain=bison'
|
||||||
# we don't have an intl subdirectory.
|
|
||||||
excluded_files='
|
|
||||||
m4/glibc2.m4
|
|
||||||
m4/intdiv0.m4
|
|
||||||
m4/intl.m4
|
|
||||||
m4/intldir.m4
|
|
||||||
m4/intmax.m4
|
|
||||||
m4/lcmessage.m4
|
|
||||||
m4/lock.m4
|
|
||||||
m4/longdouble.m4
|
|
||||||
m4/signed.m4
|
|
||||||
m4/uintmax_t.m4
|
|
||||||
m4/ulonglong.m4
|
|
||||||
m4/visibility.m4
|
|
||||||
'
|
|
||||||
|
|
||||||
gnulib_tool_option_extras='--symlink --conditional-dependencies --makefile-name=gnulib.mk'
|
|
||||||
|
|
||||||
bootstrap_post_import_hook()
|
bootstrap_post_import_hook()
|
||||||
{
|
{
|
||||||
@@ -102,6 +93,13 @@ bootstrap_epilogue()
|
|||||||
touch src/parse-gram.[ch]
|
touch src/parse-gram.[ch]
|
||||||
|
|
||||||
perl -pi -e "s/\@PACKAGE\@/$package/g" README-release
|
perl -pi -e "s/\@PACKAGE\@/$package/g" README-release
|
||||||
|
|
||||||
|
# Bison currently uses Gettext 0.19, but the gnulib-po module
|
||||||
|
# imports files from more recent versions of Gettext that are not
|
||||||
|
# yet available widely enough (e.g., not in bionic, used by the CI).
|
||||||
|
# Work around this. Don't use autopoint, which sends some other
|
||||||
|
# files in the past.
|
||||||
|
cp po/Makefile.in.in gnulib-po
|
||||||
}
|
}
|
||||||
|
|
||||||
# Keep our bootstrap script in sync with gnulib's. If we ever need to
|
# Keep our bootstrap script in sync with gnulib's. If we ever need to
|
||||||
|
|||||||
@@ -27,3 +27,4 @@
|
|||||||
/install-reloc
|
/install-reloc
|
||||||
/reloc-ldflags
|
/reloc-ldflags
|
||||||
/relocatable.sh.in
|
/relocatable.sh.in
|
||||||
|
/libtool-reloc
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+31
-10
@@ -1,5 +1,24 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
|
|
||||||
|
# Generate a release announcement message.
|
||||||
|
|
||||||
|
# Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Written by Akim Demaille.
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use 5.005;
|
use 5.005;
|
||||||
use strict;
|
use strict;
|
||||||
@@ -12,7 +31,7 @@ while (<STDIN>)
|
|||||||
{
|
{
|
||||||
if (/^\s* # Initial spaces.
|
if (/^\s* # Initial spaces.
|
||||||
(?:(-\w),\s+)? # $1: $short: Possible short option.
|
(?:(-\w),\s+)? # $1: $short: Possible short option.
|
||||||
(--[-\w]+) # $2: $long: Long option.
|
(--[-\w]+) # $2: $long: Mandatory long option.
|
||||||
(\[?) # $3: $opt: '[' iff the argument is optional.
|
(\[?) # $3: $opt: '[' iff the argument is optional.
|
||||||
(?:=(\S+))? # $4: $arg: Possible argument name.
|
(?:=(\S+))? # $4: $arg: Possible argument name.
|
||||||
\s # Spaces.
|
\s # Spaces.
|
||||||
@@ -32,7 +51,6 @@ while (<STDIN>)
|
|||||||
# if $opt, $arg contains the closing ].
|
# if $opt, $arg contains the closing ].
|
||||||
substr ($arg, -1) = ''
|
substr ($arg, -1) = ''
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
$arg =~ s/^=//;
|
|
||||||
$arg = lc ($arg);
|
$arg = lc ($arg);
|
||||||
my $dir_arg = $arg;
|
my $dir_arg = $arg;
|
||||||
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
|
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
|
||||||
@@ -72,12 +90,15 @@ while (<STDIN>)
|
|||||||
my $sep = '';
|
my $sep = '';
|
||||||
foreach my $long (sort keys %option)
|
foreach my $long (sort keys %option)
|
||||||
{
|
{
|
||||||
# Avoid trailing spaces.
|
# Couldn't find a means to escape @ in the format (for @item, @tab), so
|
||||||
print $sep;
|
# pass it as a literal to print.
|
||||||
$sep = "\n";
|
format STDOUT =
|
||||||
print '@item @option{', $long, "}\n\@tab";
|
@item @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @tab @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @tab @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||||
print ' @option{', $option{$long}, '}' if $option{$long};
|
{
|
||||||
print "\n\@tab";
|
'@', '@option{' . $long . '}',
|
||||||
print ' @code{', $directive{$long}, '}' if $directive{$long};
|
'@', $option{$long} ? ('@option{' . $option{$long} . '}') : '',
|
||||||
print "\n";
|
'@', $directive{$long} ? ('@code{' . $directive{$long} . '}') : ''
|
||||||
|
}
|
||||||
|
.
|
||||||
|
write;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2000-2015, 2018-2019 Free Software Foundation, Inc.
|
## Copyright (C) 2000-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# Update b4_copyright invocations or b4_copyright_years definitions to
|
# Update b4_copyright invocations or b4_copyright_years definitions to
|
||||||
# include the current year.
|
# include the current year.
|
||||||
|
|
||||||
# Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2009-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
|
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
|
||||||
|
|
||||||
# Copyright (C) 2010-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2010-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
Executable
+122
@@ -0,0 +1,122 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
|
||||||
|
# Update expectations in an Autotest test suite.
|
||||||
|
|
||||||
|
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Written by Akim Demaille.
|
||||||
|
|
||||||
|
# usage:
|
||||||
|
#
|
||||||
|
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
|
||||||
|
#
|
||||||
|
# from your source tree.
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def getargs():
|
||||||
|
p = argparse.ArgumentParser(description='Update test cases.')
|
||||||
|
opt = p.add_argument
|
||||||
|
opt('logs', metavar='log', nargs='+', type=str, default=None,
|
||||||
|
help='log files to process')
|
||||||
|
opt('-v', '--verbose', action='store_true',
|
||||||
|
help='Be verbose')
|
||||||
|
return p.parse_args()
|
||||||
|
|
||||||
|
args = getargs()
|
||||||
|
subst = dict()
|
||||||
|
|
||||||
|
|
||||||
|
def trace(*args_):
|
||||||
|
if args.verbose:
|
||||||
|
print(*args_)
|
||||||
|
|
||||||
|
|
||||||
|
def contents(file):
|
||||||
|
'''The contents of a file.'''
|
||||||
|
trace(file)
|
||||||
|
f = open(file)
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
def diff_to_re(match):
|
||||||
|
'''Convert a portion of patch into a regex substitution to perform.
|
||||||
|
No longer used, we now use the expected/effective parts.
|
||||||
|
'''
|
||||||
|
frm = []
|
||||||
|
to = []
|
||||||
|
is_diff = False
|
||||||
|
for l in match.group(1).splitlines():
|
||||||
|
print(l)
|
||||||
|
# t in [-+ ]
|
||||||
|
t = l[0]
|
||||||
|
l = l[1:]
|
||||||
|
if t in ['-', ' ']:
|
||||||
|
is_diff = True
|
||||||
|
frm.append(l)
|
||||||
|
if t in ['+', ' ']:
|
||||||
|
is_diff = True
|
||||||
|
to.append(l)
|
||||||
|
if is_diff:
|
||||||
|
# Do not run s//SOMETHING/g (with an emty pattern), that won't
|
||||||
|
# work well...
|
||||||
|
if frm == []:
|
||||||
|
trace("no from for", match.group(1))
|
||||||
|
return
|
||||||
|
frm = "\n".join(frm)
|
||||||
|
to = "\n".join(to)
|
||||||
|
subst[frm] = to
|
||||||
|
|
||||||
|
|
||||||
|
def update(at_file, logfile):
|
||||||
|
test = contents(at_file)
|
||||||
|
if os.path.isfile(logfile):
|
||||||
|
trace("LOG: ", logfile)
|
||||||
|
l = contents(logfile)
|
||||||
|
trace("LOG: ", l)
|
||||||
|
global subst
|
||||||
|
subst = {}
|
||||||
|
re.sub(r'(?:^@@.*\n)((?:^[-+ ].*\n)+)',
|
||||||
|
diff_to_re, l, flags = re.MULTILINE)
|
||||||
|
print(subst)
|
||||||
|
if subst:
|
||||||
|
# Turn "subst{frm} -> to" into a large RE.
|
||||||
|
frm = '|'.join([re.escape(x) for x in subst])
|
||||||
|
trace("FROM:", frm)
|
||||||
|
test = re.sub("(" + frm + ")",
|
||||||
|
lambda m: subst[m.group(1)],
|
||||||
|
test, flags=re.MULTILINE)
|
||||||
|
open(at_file, 'w').write(test)
|
||||||
|
|
||||||
|
|
||||||
|
def process(logfile):
|
||||||
|
log = contents(logfile)
|
||||||
|
# Look for the file to update.
|
||||||
|
m = re.search(r'^\d+\. ([\-\+\w]+\.at):\d+: ', log, re.MULTILINE)
|
||||||
|
if not m:
|
||||||
|
trace("no diff found:", logfile)
|
||||||
|
return
|
||||||
|
at_file = 'tests/' + m.group(1)
|
||||||
|
print(at_file)
|
||||||
|
update(at_file, logfile)
|
||||||
|
|
||||||
|
for logfile in args.logs:
|
||||||
|
trace("FILE:", logfile)
|
||||||
|
if os.path.isdir(logfile):
|
||||||
|
logfile = os.path.join(logfile, 'testsuite.log')
|
||||||
|
process(logfile)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
## Customize maint.mk -*- makefile -*-
|
## Customize maint.mk -*- makefile -*-
|
||||||
## Copyright (C) 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
## Copyright (C) 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,6 +26,9 @@ regen: _version
|
|||||||
manual_title = The Yacc-compatible Parser Generator
|
manual_title = The Yacc-compatible Parser Generator
|
||||||
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
|
||||||
|
|
||||||
|
# By default, propagate -j from make to Bison's test suite.
|
||||||
|
TESTSUITEFLAGS = $(filter -j%,$(MAKEFLAGS))
|
||||||
|
|
||||||
# It's useful to run maintainer-check* targets during development, but we
|
# It's useful to run maintainer-check* targets during development, but we
|
||||||
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
||||||
# override the _is-dist-target from GNUmakefile so that maintainer-check*
|
# override the _is-dist-target from GNUmakefile so that maintainer-check*
|
||||||
@@ -48,7 +51,7 @@ gnulib_dir = $(srcdir)/gnulib
|
|||||||
bootstrap-tools = autoconf,automake,flex,gettext,gnulib
|
bootstrap-tools = autoconf,automake,flex,gettext,gnulib
|
||||||
|
|
||||||
announcement_Cc_ = \
|
announcement_Cc_ = \
|
||||||
[email protected], [email protected], bison-patches@gnu.org, \
|
[email protected], bison-announce@gnu.org, \
|
||||||
[email protected]
|
[email protected]
|
||||||
|
|
||||||
update-copyright: update-b4-copyright update-package-copyright-year
|
update-copyright: update-b4-copyright update-package-copyright-year
|
||||||
@@ -60,18 +63,6 @@ update-copyright-env = \
|
|||||||
## More syntax-checks. ##
|
## More syntax-checks. ##
|
||||||
## -------------------- ##
|
## -------------------- ##
|
||||||
|
|
||||||
# At least for Mac OS X's grep, the order between . and [ in "[^.[]"
|
|
||||||
# matters:
|
|
||||||
# $ LC_ALL=fr_FR grep -nE '[^[.]' /dev/null
|
|
||||||
# $ LC_ALL=C grep -nE '[^[.]' /dev/null
|
|
||||||
# grep: invalid collating element or class
|
|
||||||
# $ LC_ALL=fr_FR grep -nE '[^.[]' /dev/null
|
|
||||||
# $ LC_ALL=C grep -nE '[^.[]' /dev/null
|
|
||||||
sc_at_parser_check:
|
|
||||||
@prohibit='AT_PARSER_CHECK\(\[+[^.[]|AT_CHECK\(\[+\./' \
|
|
||||||
halt='use AT_PARSER_CHECK for and only for generated parsers' \
|
|
||||||
$(_sc_search_regexp)
|
|
||||||
|
|
||||||
# Indent only with spaces.
|
# Indent only with spaces.
|
||||||
# Taken from Coreutils.
|
# Taken from Coreutils.
|
||||||
sc_prohibit_tab_based_indentation:
|
sc_prohibit_tab_based_indentation:
|
||||||
@@ -156,11 +147,16 @@ sc_space_before_open_paren:
|
|||||||
## syntax-checks exceptions. ##
|
## syntax-checks exceptions. ##
|
||||||
## -------------------------- ##
|
## -------------------------- ##
|
||||||
|
|
||||||
|
# po-check: we use gnulib-po, so we don't need/want them in our POTFILE.
|
||||||
|
generated_files =
|
||||||
|
|
||||||
exclude = \
|
exclude = \
|
||||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
|
|
||||||
$(call exclude, \
|
$(call exclude, \
|
||||||
bindtextdomain=^lib/main.c$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
||||||
|
po_check=^tests|(^po/POTFILES.in|.md)$$ \
|
||||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||||
program_name=^lib/main.c$$ \
|
program_name=^lib/main.c$$ \
|
||||||
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||||
@@ -169,8 +165,8 @@ $(call exclude,
|
|||||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||||
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
|
prohibit_strcmp=^doc/bison\.texi|examples|tests \
|
||||||
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^\.git|Makefile$$ \
|
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^\.git|tests/input.at|Makefile$$ \
|
||||||
require_config_h=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
require_config_h=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||||
require_config_h_first=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
require_config_h_first=^(lib/yyerror|data/skeletons/(glr|yacc))\.c$$ \
|
||||||
space_before_open_paren=^data/skeletons/ \
|
space_before_open_paren=^data/skeletons/ \
|
||||||
|
|||||||
+83
-20
@@ -1,6 +1,6 @@
|
|||||||
# Configure template for GNU Bison. -*-Autoconf-*-
|
# Configure template for GNU Bison. -*-Autoconf-*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2001-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,15 +26,18 @@ m4_pattern_allow([^BISON_USE_NLS$])
|
|||||||
|
|
||||||
AC_INIT([GNU Bison],
|
AC_INIT([GNU Bison],
|
||||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||||
[[email protected]])
|
[[email protected]],
|
||||||
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2019])
|
[],
|
||||||
|
[https://www.gnu.org/software/bison/])
|
||||||
|
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2020])
|
||||||
AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
|
AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
|
||||||
[The copyright year for this package])
|
[The copyright year for this package])
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
# We use Automake 1.14's %D% and %C%.
|
# When we move to Automake 1.16, simplify examples/c/reccalc/local.mk.
|
||||||
|
# Our CI build the packages on Bionic, which has only Automake 1.15.
|
||||||
#
|
#
|
||||||
# We want gnits strictness only when rolling a stable release. For
|
# We want gnits strictness only when rolling a stable release. For
|
||||||
# release candidates, we use version strings like 2.4.3_rc1, but gnits
|
# release candidates, we use version strings like 2.4.3_rc1, but gnits
|
||||||
@@ -42,7 +45,7 @@ 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.14 dist-xz nostdinc
|
AM_INIT_AUTOMAKE([1.15 dist-lzip dist-xz nostdinc
|
||||||
color-tests parallel-tests
|
color-tests parallel-tests
|
||||||
silent-rules]
|
silent-rules]
|
||||||
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
||||||
@@ -94,13 +97,49 @@ AC_ARG_ENABLE([gcc-warnings],
|
|||||||
[enable_gcc_warnings=no])
|
[enable_gcc_warnings=no])
|
||||||
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
||||||
if test "$enable_gcc_warnings" = yes; then
|
if test "$enable_gcc_warnings" = yes; then
|
||||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
|
# -Wno-tautological-constant-out-of-range-compare for Clang 3.3 and
|
||||||
|
# 3.4 on GNU/Linux that choke on intprops.h's INT_MULTIPLY_WRAPV,
|
||||||
|
# etc.
|
||||||
|
#
|
||||||
|
# ICC: -wr188
|
||||||
|
#
|
||||||
|
# 1669 warnings warnings_default =
|
||||||
|
# ../src/complain.c(318): error #188: enumerated type mixed with another type
|
||||||
|
# 1670 Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||||
|
# 1671 ^
|
||||||
|
# 1672
|
||||||
|
# 1673../src/complain.c(393): error #188: enumerated type mixed with another type
|
||||||
|
# 1674 warnings w = 1 << wbit;
|
||||||
|
# 1675 ^
|
||||||
|
#
|
||||||
|
# ICC: -wr3179
|
||||||
|
#
|
||||||
|
# char const *usefulness
|
||||||
|
# = rule_useless_in_grammar_p (&rules[r]) ? "useless-in-grammar"
|
||||||
|
# : rule_useless_in_parser_p (&rules[r]) ? "useless-in-parser"
|
||||||
|
# : "useful";
|
||||||
|
#
|
||||||
|
# gives
|
||||||
|
#
|
||||||
|
# error #3179: deprecated conversion of string literal to char* (should be const char*)
|
||||||
|
#
|
||||||
|
# ICC: -wr2259 (that's in C, in spite of what the error messages which seems to be about C++).
|
||||||
|
# error #2259: non-pointer conversion from "int" to "yybool={signed char}" may lose significant bits
|
||||||
|
# yybool yynormal YY_ATTRIBUTE_UNUSED = yystackp->yysplitPoint == YY_NULLPTR;
|
||||||
|
# ^
|
||||||
|
warn_common='-Wall -Wextra
|
||||||
|
-Wcast-align -Wchar-subscripts
|
||||||
-fparse-all-comments -Wdocumentation
|
-fparse-all-comments -Wdocumentation
|
||||||
-Wformat -Wimplicit-fallthrough -Wnull-dereference
|
-Wformat -Wimplicit-fallthrough -Wnull-dereference
|
||||||
|
-Wno-sign-compare -Wno-tautological-constant-out-of-range-compare
|
||||||
-Wpointer-arith -Wshadow
|
-Wpointer-arith -Wshadow
|
||||||
-Wwrite-strings'
|
-Wwrite-strings
|
||||||
warn_c='-Wbad-function-cast -Wstrict-prototypes'
|
-wr188 -wr2259 -wr3179'
|
||||||
warn_cxx='-Wextra-semi -Wnoexcept -Wundefined-func-template -Wweak-vtables'
|
warn_c='-Wbad-function-cast
|
||||||
|
-Wmissing-prototypes
|
||||||
|
-Wstrict-prototypes'
|
||||||
|
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
|
||||||
|
-Wweak-vtables'
|
||||||
# Warnings for the test suite only.
|
# Warnings for the test suite only.
|
||||||
#
|
#
|
||||||
# -fno-color-diagnostics: Clang's use of colors in the error
|
# -fno-color-diagnostics: Clang's use of colors in the error
|
||||||
@@ -112,6 +151,7 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
# details for lalr1.cc.
|
# details for lalr1.cc.
|
||||||
warn_tests='-Wundef -pedantic -Wconversion
|
warn_tests='-Wundef -pedantic -Wconversion
|
||||||
-Wdeprecated -Wsign-compare -Wsign-conversion
|
-Wdeprecated -Wsign-compare -Wsign-conversion
|
||||||
|
-Wtautological-constant-out-of-range-compare
|
||||||
-fno-color-diagnostics
|
-fno-color-diagnostics
|
||||||
-Wno-keyword-macro'
|
-Wno-keyword-macro'
|
||||||
|
|
||||||
@@ -142,8 +182,6 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
|
|
||||||
# Warnings for the test suite, and maybe for bison if GCC is modern
|
# Warnings for the test suite, and maybe for bison if GCC is modern
|
||||||
# enough.
|
# enough.
|
||||||
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
|
|
||||||
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
|
|
||||||
test $lv_cv_gcc_pragma_push_works = yes &&
|
test $lv_cv_gcc_pragma_push_works = yes &&
|
||||||
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
|
||||||
|
|
||||||
@@ -170,6 +208,14 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
[[if (sizeof (long) < sizeof (int)) return 1;]])])
|
[[if (sizeof (long) < sizeof (int)) return 1;]])])
|
||||||
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
|
||||||
[AC_LANG_PROGRAM([], [nullptr])])
|
[AC_LANG_PROGRAM([], [nullptr])])
|
||||||
|
# Before GCC6, the pragmas don't work well enough to neutralize
|
||||||
|
# this warning.
|
||||||
|
gl_WARN_ADD([-Wuseless-cast], [WARN_CXXFLAGS],
|
||||||
|
[AC_LANG_PROGRAM([], [
|
||||||
|
#if defined __GNUC__ && ! defined __ICC && ! defined __clang__ && __GNUC__ < 6
|
||||||
|
syntax error
|
||||||
|
#endif
|
||||||
|
])])
|
||||||
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
|
||||||
# Warnings for the test suite only.
|
# Warnings for the test suite only.
|
||||||
for i in $warn_tests;
|
for i in $warn_tests;
|
||||||
@@ -192,6 +238,7 @@ BISON_CXX_COMPILER_POSIXLY_CORRECT
|
|||||||
|
|
||||||
# D.
|
# D.
|
||||||
AC_CHECK_PROGS([DC], [dmd])
|
AC_CHECK_PROGS([DC], [dmd])
|
||||||
|
AC_CHECK_PROGS([DCFLAGS], [-g])
|
||||||
AM_CONDITIONAL([ENABLE_D], [test x"$DC" != x])
|
AM_CONDITIONAL([ENABLE_D], [test x"$DC" != x])
|
||||||
|
|
||||||
# Java.
|
# Java.
|
||||||
@@ -210,12 +257,13 @@ AC_CONFIG_FILES([src/yacc], [chmod +x src/yacc])
|
|||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AM_MISSING_PROG([DOT], [dot])
|
AM_MISSING_PROG([DOT], [dot])
|
||||||
AC_PROG_LEX
|
AC_PROG_LEX
|
||||||
$LEX_IS_FLEX || test "X$LEX" = X: || {
|
if ! "$LEX_IS_FLEX" || test "X$LEX" = X:; then
|
||||||
AC_MSG_WARN([bypassing lex because flex is required])
|
AC_MSG_WARN([bypassing lex because flex is required])
|
||||||
LEX=:
|
LEX=:
|
||||||
}
|
fi
|
||||||
|
AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX && $FLEX_SUPPORTS_HEADER_OPT])
|
||||||
AM_CONDITIONAL([FLEX_CXX_WORKS],
|
AM_CONDITIONAL([FLEX_CXX_WORKS],
|
||||||
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
|
[$LEX_IS_FLEX && $FLEX_SUPPORTS_HEADER_OPT && test $bison_cv_cxx_works = yes])
|
||||||
AC_PROG_YACC
|
AC_PROG_YACC
|
||||||
AC_PROG_RANLIB
|
AC_PROG_RANLIB
|
||||||
AC_PROG_GNU_M4
|
AC_PROG_GNU_M4
|
||||||
@@ -223,9 +271,6 @@ AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
|||||||
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
|
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
|
||||||
supports -g, otherwise to "".])
|
supports -g, otherwise to "".])
|
||||||
AC_PATH_PROG([PERL], [perl])
|
AC_PATH_PROG([PERL], [perl])
|
||||||
if test -z "$PERL"; then
|
|
||||||
AC_MSG_ERROR([perl not found])
|
|
||||||
fi
|
|
||||||
AM_MISSING_PROG([HELP2MAN], [help2man])
|
AM_MISSING_PROG([HELP2MAN], [help2man])
|
||||||
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
||||||
AC_SUBST([XSLTPROC])
|
AC_SUBST([XSLTPROC])
|
||||||
@@ -242,14 +287,14 @@ gl_INIT
|
|||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||||
AM_WITH_DMALLOC
|
|
||||||
|
|
||||||
# Gettext.
|
# Gettext.
|
||||||
# We use gnulib, which is only guaranteed to work properly with the
|
# We use gnulib, which is only guaranteed to work properly with the
|
||||||
# latest Gettext.
|
# latest Gettext.
|
||||||
AM_GNU_GETTEXT([external], [need-ngettext])
|
AM_GNU_GETTEXT([external], [need-ngettext])
|
||||||
AM_GNU_GETTEXT_VERSION([0.18])
|
AM_GNU_GETTEXT_VERSION([0.19])
|
||||||
BISON_I18N
|
BISON_I18N
|
||||||
|
AC_CONFIG_FILES([gnulib-po/Makefile.in])
|
||||||
|
|
||||||
# Internationalized parsers.
|
# Internationalized parsers.
|
||||||
AC_CONFIG_FILES([runtime-po/Makefile.in])
|
AC_CONFIG_FILES([runtime-po/Makefile.in])
|
||||||
@@ -271,7 +316,7 @@ uname=`uname`
|
|||||||
case $VALGRIND:$uname in
|
case $VALGRIND:$uname in
|
||||||
'':*) ;;
|
'':*) ;;
|
||||||
*:Darwin)
|
*:Darwin)
|
||||||
# See README-hacking.
|
# See README-hacking.md.
|
||||||
VALGRIND=;;
|
VALGRIND=;;
|
||||||
*:*)
|
*:*)
|
||||||
suppfile=build-aux/$uname.valgrind
|
suppfile=build-aux/$uname.valgrind
|
||||||
@@ -287,6 +332,13 @@ AC_MSG_RESULT([$suppfile])
|
|||||||
# Whether we cannot run the compiled bison.
|
# Whether we cannot run the compiled bison.
|
||||||
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
||||||
|
|
||||||
|
# Build bistromathic if we have the lib and both readline/readline.h
|
||||||
|
# and readline/history.h.
|
||||||
|
AM_CONDITIONAL([ENABLE_BISTROMATHIC],
|
||||||
|
[test "$gl_cv_lib_readline" != no &&
|
||||||
|
test "$ac_cv_header_readline_readline_h" = yes &&
|
||||||
|
test "$ac_cv_header_readline_history_h" = yes])
|
||||||
|
|
||||||
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])
|
||||||
@@ -294,4 +346,15 @@ AC_SUBST([GCC])
|
|||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
doc/yacc.1])
|
doc/yacc.1])
|
||||||
|
|
||||||
|
# Fix LIBOBJS to give the Makefile the right file names. Otherwise
|
||||||
|
# compilation works, but with unexpected file names, so clean rules don't
|
||||||
|
# remove the actual files and distcheck fails.
|
||||||
|
AC_CONFIG_COMMANDS_PRE([
|
||||||
|
case $am__api_version in
|
||||||
|
1.14*|1.15*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/lib_libbison_a-,g'`;;
|
||||||
|
*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/libbison_a-,g'`;;
|
||||||
|
esac
|
||||||
|
])
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -75,48 +75,83 @@ skeletons.
|
|||||||
|
|
||||||
## Symbols
|
## Symbols
|
||||||
|
|
||||||
|
### `b4_symbol(NUM, FIELD)`
|
||||||
In order to unify the handling of the various aspects of symbols (tag, type
|
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,
|
name, whether terminal, etc.), bison.exe defines one macro per (token,
|
||||||
field), where field can `has_id`, `id`, etc.: see
|
field), where field can `has_id`, `id`, etc.: see
|
||||||
src/output.c:prepare_symbols_definitions().
|
`prepare_symbols_definitions()` in `src/output.c`.
|
||||||
|
|
||||||
The various FIELDS are:
|
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
|
||||||
|
|
||||||
- has_id: 0 or 1.
|
- `has_id`: 0 or 1
|
||||||
Whether the symbol has an id.
|
Whether the symbol has an id.
|
||||||
- id: string
|
|
||||||
If has_id, the id. Guaranteed to be usable as a C identifier.
|
- `id`: string
|
||||||
Prefixed by api.token.prefix if defined.
|
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
|
||||||
- tag: string.
|
defined as empty. Guaranteed to be usable as a C identifier. This is
|
||||||
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
used to define the token kind (i.e., the enum used by the return value of
|
||||||
- user_number: integer
|
yylex).
|
||||||
|
|
||||||
|
- `tag`: string
|
||||||
|
A human representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||||
|
|
||||||
|
- `user_number`: integer
|
||||||
|
The code associated to the `id`.
|
||||||
The external number as used by yylex. Can be ASCII code when a character,
|
The external number as used by yylex. Can be ASCII code when a character,
|
||||||
some number chosen by bison, or some user number in the case of
|
some number chosen by bison, or some user number in the case of
|
||||||
%token FOO <NUM>. Corresponds to yychar in yacc.c.
|
%token FOO <NUM>. Corresponds to yychar in yacc.c.
|
||||||
- is_token: 0 or 1
|
|
||||||
|
- `is_token`: 0 or 1
|
||||||
Whether this is a terminal symbol.
|
Whether this is a terminal symbol.
|
||||||
- number: integer
|
|
||||||
|
- `kind`: string
|
||||||
|
The symbol kind, i.e., the enumerator of this symbol (token or nonterminal)
|
||||||
|
which is mapping to its `number`.
|
||||||
|
|
||||||
|
- `number`: integer
|
||||||
|
The code associated to the `kind`.
|
||||||
The internal number (computed from the external number by yytranslate).
|
The internal number (computed from the external number by yytranslate).
|
||||||
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
||||||
key in b4_symbol(NUM, FIELD).
|
key in b4_symbol(NUM, FIELD).
|
||||||
- has_type: 0, 1
|
|
||||||
|
In bison, symbols are first assigned increasing numbers in order of
|
||||||
|
appearance (but tokens first, then nterms). After grammar reduction,
|
||||||
|
unused nterms are then renumbered to appear last (i.e., first tokens, then
|
||||||
|
used nterms and finally unused nterms). This final number NUM is the one
|
||||||
|
contained in this field, and it is the one used as key in `b4_symbol(NUM,
|
||||||
|
FIELD)`.
|
||||||
|
|
||||||
|
The code of the rule actions, however, is emitted before we know what
|
||||||
|
symbols are unused, so they use the original numbers. To avoid confusion,
|
||||||
|
they actually use "orig NUM" instead of just "NUM". bison also emits
|
||||||
|
definitions for `b4_symbol(orig NUM, number)` that map from original
|
||||||
|
numbers to the new ones. `b4_symbol` actually resolves `orig NUM` in the
|
||||||
|
other case, i.e., `b4_symbol(orig 42, tag)` would return the tag of the
|
||||||
|
symbols whose original number was 42.
|
||||||
|
|
||||||
|
- `has_type`: 0, 1
|
||||||
Whether has a semantic value.
|
Whether has a semantic value.
|
||||||
- type_tag: string
|
|
||||||
|
- `type_tag`: string
|
||||||
When api.value.type=union, the generated name for the union member.
|
When api.value.type=union, the generated name for the union member.
|
||||||
yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
|
yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
|
||||||
- type
|
|
||||||
|
- `type`
|
||||||
If it has a semantic value, its type tag, or, if variant are used,
|
If it has a semantic value, its type tag, or, if variant are used,
|
||||||
its type.
|
its type.
|
||||||
In the case of api.value.type=union, type is the real type (e.g. int).
|
In the case of api.value.type=union, type is the real type (e.g. int).
|
||||||
- has_printer: 0, 1
|
|
||||||
- printer: string
|
- `has_printer`: 0, 1
|
||||||
- printer_file: string
|
- `printer`: string
|
||||||
- printer_line: integer
|
- `printer_file`: string
|
||||||
|
- `printer_line`: integer
|
||||||
|
- `printer_loc`: location
|
||||||
If the symbol has a printer, everything about it.
|
If the symbol has a printer, everything about it.
|
||||||
- has_destructor, destructor, destructor_file, destructor_line
|
|
||||||
|
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`, `destructor_loc`
|
||||||
Likewise.
|
Likewise.
|
||||||
|
|
||||||
### b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])`
|
||||||
Expansion of $$, $1, $<TYPE-TAG>3, etc.
|
Expansion of $$, $1, $<TYPE-TAG>3, etc.
|
||||||
|
|
||||||
The semantic value from a given VAL.
|
The semantic value from a given VAL.
|
||||||
@@ -127,14 +162,14 @@ The semantic value from a given VAL.
|
|||||||
The result can be used safely, it is put in parens to avoid nasty precedence
|
The result can be used safely, it is put in parens to avoid nasty precedence
|
||||||
issues.
|
issues.
|
||||||
|
|
||||||
### b4_lhs_value(SYMBOL-NUM, [TYPE])
|
### `b4_lhs_value(SYMBOL-NUM, [TYPE])`
|
||||||
Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`.
|
Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`.
|
||||||
|
|
||||||
### b4_rhs_data(RULE-LENGTH, POS)
|
### `b4_rhs_data(RULE-LENGTH, POS)`
|
||||||
The data corresponding to the symbol `#POS`, where the current rule has
|
The data corresponding to the symbol `#POS`, where the current rule has
|
||||||
`RULE-LENGTH` symbols on RHS.
|
`RULE-LENGTH` symbols on RHS.
|
||||||
|
|
||||||
### b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
### `b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])`
|
||||||
Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols
|
Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols
|
||||||
on RHS.
|
on RHS.
|
||||||
|
|
||||||
@@ -146,7 +181,7 @@ fill-column: 76
|
|||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2002, 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Bison.
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/* Default styling rules for Bison when doing terminal output.
|
||||||
|
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* This is an experimental feature. The class names may change in the
|
||||||
|
future. */
|
||||||
|
|
||||||
|
/* Diagnostics. */
|
||||||
|
.warning { color: purple; }
|
||||||
|
.error { color: red; }
|
||||||
|
.note { color: cyan; }
|
||||||
|
|
||||||
|
.fixit-insert { color: green; }
|
||||||
|
|
||||||
|
/* Semantic values in Bison's own parser traces. */
|
||||||
|
.value { color: green; }
|
||||||
|
|
||||||
|
/* "Sections" in traces (--trace). */
|
||||||
|
.trace0 { color: green; }
|
||||||
|
|
||||||
|
.expected { color: green; }
|
||||||
|
.unexpected { color: red; }
|
||||||
+4
-2
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2002, 2005-2015, 2018-2019 Free Software Foundation,
|
## Copyright (C) 2002, 2005-2015, 2018-2020 Free Software Foundation,
|
||||||
## Inc.
|
## 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,7 +15,8 @@
|
|||||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
dist_pkgdata_DATA = \
|
||||||
data/README
|
data/README.md \
|
||||||
|
data/bison-default.css
|
||||||
|
|
||||||
skeletonsdir = $(pkgdatadir)/skeletons
|
skeletonsdir = $(pkgdatadir)/skeletons
|
||||||
dist_skeletons_DATA = \
|
dist_skeletons_DATA = \
|
||||||
@@ -33,6 +34,7 @@ dist_skeletons_DATA = \
|
|||||||
data/skeletons/lalr1.java \
|
data/skeletons/lalr1.java \
|
||||||
data/skeletons/location.cc \
|
data/skeletons/location.cc \
|
||||||
data/skeletons/stack.hh \
|
data/skeletons/stack.hh \
|
||||||
|
data/skeletons/traceon.m4 \
|
||||||
data/skeletons/variant.hh \
|
data/skeletons/variant.hh \
|
||||||
data/skeletons/yacc.c
|
data/skeletons/yacc.c
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public interface Lexer
|
|||||||
* to the next token and prepares to return the semantic value
|
* to the next token and prepares to return the semantic value
|
||||||
* and beginning/ending positions of the token.
|
* and beginning/ending positions of the token.
|
||||||
* @return the token identifier corresponding to the next token. */
|
* @return the token identifier corresponding to the next token. */
|
||||||
YYTokenType yylex ();
|
TokenKind yylex ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for error reporting. Emits an error
|
* Entry point for error reporting. Emits an error
|
||||||
@@ -39,7 +39,7 @@ public interface Lexer
|
|||||||
void yyerror (YYLocation loc, string s);
|
void yyerror (YYLocation loc, string s);
|
||||||
}
|
}
|
||||||
|
|
||||||
- semantic types are handled by D usions (same as for C/C++ parsers)
|
- semantic types are handled by D unions (same as for C/C++ parsers)
|
||||||
|
|
||||||
- the following (non-standard) %defines are supported:
|
- the following (non-standard) %defines are supported:
|
||||||
|
|
||||||
|
|||||||
+156
-63
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Language-independent M4 Macros for Bison.
|
# Language-independent M4 Macros for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
|
# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
|
||||||
# Inc.
|
# 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
|
||||||
@@ -19,6 +19,27 @@
|
|||||||
# 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_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...)
|
||||||
|
# ----------------------------------------------
|
||||||
|
# m4 equivalent of
|
||||||
|
#
|
||||||
|
# $_ = STRING;
|
||||||
|
# s/RE1/SUBST1/g;
|
||||||
|
# s/RE2/SUBST2/g;
|
||||||
|
# ...
|
||||||
|
#
|
||||||
|
# Really similar to m4_bpatsubsts, but behaves properly with quotes.
|
||||||
|
# See m4.at's "Generating Comments". Super inelegant, but so far, I
|
||||||
|
# did not find any better solution.
|
||||||
|
m4_define([b4_gsub],
|
||||||
|
[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]],
|
||||||
|
[$2], [$3]),
|
||||||
|
[$4], [$5]),
|
||||||
|
[$6], [$7])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
@@ -72,8 +93,9 @@ version 2.2 of Bison.])
|
|||||||
# -------------
|
# -------------
|
||||||
# Issue a warning about private implementation details.
|
# Issue a warning about private implementation details.
|
||||||
m4_define([b4_disclaimer],
|
m4_define([b4_disclaimer],
|
||||||
[b4_comment([Undocumented macros, especially those whose name start with YY_,
|
[b4_comment([DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
||||||
are private implementation details. Do not rely on them.])
|
especially those whose name start with YY_ or yy_. They are
|
||||||
|
private implementation details that can be changed or removed.])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -192,7 +214,7 @@ m4_define([b4_error],
|
|||||||
# @warn(1@)
|
# @warn(1@)
|
||||||
# @warn(1@,2@)
|
# @warn(1@,2@)
|
||||||
m4_define([b4_warn],
|
m4_define([b4_warn],
|
||||||
[b4_error([[warn]], [], [], $@)])
|
[b4_warn_at([], [], $@)])
|
||||||
|
|
||||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
@@ -210,7 +232,7 @@ m4_define([b4_warn_at],
|
|||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_complain],
|
m4_define([b4_complain],
|
||||||
[b4_error([[complain]], [], [], $@)])
|
[b4_complain_at([], [], $@)])
|
||||||
|
|
||||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
@@ -226,8 +248,7 @@ m4_define([b4_complain_at],
|
|||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_fatal],
|
m4_define([b4_fatal],
|
||||||
[b4_error([[fatal]], [], [], $@)dnl
|
[b4_fatal_at([], [], $@)])
|
||||||
m4_exit(1)])
|
|
||||||
|
|
||||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
@@ -370,6 +391,7 @@ m4_define([b4_$3_if],
|
|||||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||||
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||||
|
b4_define_flag_if([has_translations]) # Whether some tokens are internationalized.
|
||||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||||
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||||
@@ -385,26 +407,64 @@ m4_define([b4_glr_cc_if],
|
|||||||
## Symbols. ##
|
## Symbols. ##
|
||||||
## --------- ##
|
## --------- ##
|
||||||
|
|
||||||
# For a description of the Symbol handling, see README.
|
# For a description of the Symbol handling, see README.md.
|
||||||
#
|
#
|
||||||
# The following macros provide access to symbol related values.
|
# The following macros provide access to symbol related values.
|
||||||
|
|
||||||
|
# __b4_symbol(NUM, FIELD)
|
||||||
|
# -----------------------
|
||||||
|
# Fetch FIELD of symbol #NUM. Fail if undefined.
|
||||||
|
m4_define([__b4_symbol],
|
||||||
|
[m4_indir([b4_symbol($1, $2)])])
|
||||||
|
|
||||||
|
|
||||||
# _b4_symbol(NUM, FIELD)
|
# _b4_symbol(NUM, FIELD)
|
||||||
# ----------------------
|
# ----------------------
|
||||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md).
|
||||||
# undefined.
|
# Fail if undefined.
|
||||||
m4_define([_b4_symbol],
|
m4_define([_b4_symbol],
|
||||||
[m4_indir([b4_symbol($1, $2)])])
|
[m4_ifdef([b4_symbol($1, number)],
|
||||||
|
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
|
||||||
|
[__b4_symbol([$1], [$2])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_token_kind(NUM)
|
||||||
|
# -------------------------
|
||||||
|
# The token kind of this symbol.
|
||||||
|
m4_define([b4_symbol_token_kind],
|
||||||
|
[b4_percent_define_get([api.token.prefix])dnl
|
||||||
|
_b4_symbol([$1], [id])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_kind(NUM)
|
||||||
|
# -------------------
|
||||||
|
# Build the name of the kind of this symbol. It must always exist,
|
||||||
|
# otherwise some symbols might not be represented in the enum, which
|
||||||
|
# might be compiled into too small a type to contain all the symbol
|
||||||
|
# numbers.
|
||||||
|
m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])])
|
||||||
|
m4_define([b4_symbol_kind],
|
||||||
|
[b4_percent_define_get([api.symbol.prefix])dnl
|
||||||
|
m4_case([$1],
|
||||||
|
[-2], [[YYEMPTY]],
|
||||||
|
[0], [[YYEOF]],
|
||||||
|
[1], [[YYerror]],
|
||||||
|
[2], [[YYUNDEF]],
|
||||||
|
[m4_case(b4_symbol([$1], [tag]),
|
||||||
|
[$accept], [[YYACCEPT]],
|
||||||
|
[b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]),
|
||||||
|
[m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol(NUM, FIELD)
|
# b4_symbol(NUM, FIELD)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined.
|
||||||
# undefined. If FIELD = id, prepend the token prefix.
|
#
|
||||||
|
# If FIELD = id, prepend the token prefix.
|
||||||
m4_define([b4_symbol],
|
m4_define([b4_symbol],
|
||||||
[m4_case([$2],
|
[m4_case([$2],
|
||||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
[id], [b4_symbol_token_kind([$1])],
|
||||||
[_b4_symbol([$1], [id])])],
|
[kind], [b4_symbol_kind([$1])],
|
||||||
[_b4_symbol($@)])])
|
[_b4_symbol($@)])])
|
||||||
|
|
||||||
|
|
||||||
@@ -427,16 +487,9 @@ m4_define([b4_symbol_tag_comment],
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_action_location(SYMBOL-NUM, KIND)
|
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
||||||
# -------------------------------------------
|
# ------------------------------------
|
||||||
# Report the location of the KIND action as FILE:LINE.
|
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
||||||
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.
|
|
||||||
m4_define([b4_symbol_action],
|
m4_define([b4_symbol_action],
|
||||||
[b4_symbol_if([$1], [has_$2],
|
[b4_symbol_if([$1], [has_$2],
|
||||||
[b4_dollar_pushdef([(*yyvaluep)],
|
[b4_dollar_pushdef([(*yyvaluep)],
|
||||||
@@ -444,9 +497,9 @@ m4_define([b4_symbol_action],
|
|||||||
[],
|
[],
|
||||||
[(*yylocationp)])dnl
|
[(*yylocationp)])dnl
|
||||||
_b4_symbol_case([$1])[]dnl
|
_b4_symbol_case([$1])[]dnl
|
||||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
||||||
b4_symbol([$1], [$2])
|
b4_symbol([$1], [$2])
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])dnl
|
||||||
break;
|
break;
|
||||||
|
|
||||||
b4_dollar_popdef[]dnl
|
b4_dollar_popdef[]dnl
|
||||||
@@ -460,21 +513,21 @@ m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
|
|||||||
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_actions(KIND, [TYPE = yytype])
|
# b4_symbol_actions(ACTION, [KIND = yykind])
|
||||||
# ----------------------------------------
|
# ------------------------------------------
|
||||||
# Emit the symbol actions for KIND ("printer" or "destructor").
|
# Emit the symbol actions for ACTION ("destructor" or "printer").
|
||||||
# Dispatch on TYPE.
|
# Dispatch on KIND.
|
||||||
m4_define([b4_symbol_actions],
|
m4_define([b4_symbol_actions],
|
||||||
[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl
|
[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl
|
||||||
m4_ifval(m4_defn([b4_actions_]),
|
m4_ifval(m4_defn([b4_actions_]),
|
||||||
[switch (m4_default([$2], [yytype]))
|
[switch (m4_default([$2], [yykind]))
|
||||||
{
|
{
|
||||||
m4_defn([b4_actions_])[]dnl
|
m4_defn([b4_actions_])[]dnl
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}dnl
|
}dnl
|
||||||
],
|
],
|
||||||
[YYUSE (m4_default([$2], [yytype]));])dnl
|
[YYUSE (m4_default([$2], [yykind]));])dnl
|
||||||
m4_popdef([b4_actions_])dnl
|
m4_popdef([b4_actions_])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -504,13 +557,14 @@ m4_define([b4_symbol_map],
|
|||||||
|
|
||||||
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Whether NUM denotes a token that has an exported definition (i.e.,
|
# Whether NUM denotes a token kind that has an exported definition
|
||||||
# shows in enum yytokentype).
|
# (i.e., shows in enum yytokentype).
|
||||||
m4_define([b4_token_visible_if],
|
m4_define([b4_token_visible_if],
|
||||||
[b4_symbol_if([$1], [is_token],
|
[b4_symbol_if([$1], [is_token],
|
||||||
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_has_definition(NUM)
|
# b4_token_has_definition(NUM)
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# 1 if NUM is visible, nothing otherwise.
|
# 1 if NUM is visible, nothing otherwise.
|
||||||
@@ -527,13 +581,27 @@ m4_define([b4_any_token_visible_if],
|
|||||||
|
|
||||||
# b4_token_format(FORMAT, NUM)
|
# b4_token_format(FORMAT, NUM)
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
|
# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER.
|
||||||
m4_define([b4_token_format],
|
m4_define([b4_token_format],
|
||||||
[b4_token_visible_if([$2],
|
[b4_token_visible_if([$2],
|
||||||
[m4_quote(m4_format([$1],
|
[m4_format([[$1]],
|
||||||
[b4_symbol([$2], [id])],
|
m4_expand(b4_symbol([$2], [id])),
|
||||||
[b4_symbol([$2], [user_number])]))])])
|
m4_expand(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_last_enum_token
|
||||||
|
# ------------------
|
||||||
|
# The code of the last token visible token.
|
||||||
|
m4_define([_b4_last_enum_token],
|
||||||
|
[b4_token_visible_if([$1],
|
||||||
|
[m4_define([b4_last_enum_token], [$1])])])
|
||||||
|
b4_symbol_foreach([_b4_last_enum_token])
|
||||||
|
|
||||||
|
# b4_last_symbol
|
||||||
|
# --------------
|
||||||
|
# The code of the last symbol.
|
||||||
|
m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1))
|
||||||
|
|
||||||
## ------- ##
|
## ------- ##
|
||||||
## Types. ##
|
## Types. ##
|
||||||
## ------- ##
|
## ------- ##
|
||||||
@@ -575,12 +643,15 @@ m4_define([b4_basename],
|
|||||||
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
||||||
|
|
||||||
|
|
||||||
# b4_syncline(LINE, FILE)
|
# b4_syncline(LINE, FILE)dnl
|
||||||
# -----------------------
|
# --------------------------
|
||||||
|
# Should always be following by a dnl.
|
||||||
|
#
|
||||||
|
# Emit "#line LINE FILE /* __LINE__ __FILE__ */".
|
||||||
m4_define([b4_syncline],
|
m4_define([b4_syncline],
|
||||||
[b4_flag_if([synclines],
|
[b4_flag_if([synclines],
|
||||||
[b4_sync_start([$1], [$2]) b4_sync_end([__line__],
|
[b4_sync_start([$1], [$2])[]dnl
|
||||||
[b4_basename(m4_quote(__file__))])[]dnl
|
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||||
])])
|
])])
|
||||||
|
|
||||||
# b4_sync_start(LINE, FILE)
|
# b4_sync_start(LINE, FILE)
|
||||||
@@ -592,7 +663,17 @@ m4_define([b4_sync_start], [b4_comment([$2:$1])])
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
# Syncline for the current place, which ends. Typically a comment
|
# Syncline for the current place, which ends. Typically a comment
|
||||||
# left for the reader.
|
# left for the reader.
|
||||||
m4_define([b4_sync_end], [b4_comment([$2:$1])])
|
m4_define([b4_sync_end], [ b4_comment([$2:$1])]
|
||||||
|
)
|
||||||
|
# This generates dependencies on the Bison skeletons hence lots of
|
||||||
|
# useless 'git diff'. This location is useless for the regular
|
||||||
|
# user (who does not care about the skeletons) and is actually not
|
||||||
|
# useful for Bison developers too (I, Akim, never used this to locate
|
||||||
|
# the code in skeletons that generated output). So disable it
|
||||||
|
# completely. If someone thinks this was actually useful, a %define
|
||||||
|
# variable should be provided to control the level of verbosity of
|
||||||
|
# '#line', in replacement of --no-lines.
|
||||||
|
m4_define([b4_sync_end])
|
||||||
|
|
||||||
|
|
||||||
# b4_user_code(USER-CODE)
|
# b4_user_code(USER-CODE)
|
||||||
@@ -742,8 +823,10 @@ m4_define([b4_percent_define_get_kind],
|
|||||||
[m4_indir([b4_percent_define_kind(]$1[)])],
|
[m4_indir([b4_percent_define_kind(]$1[)])],
|
||||||
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
||||||
|
|
||||||
# b4_percent_define_get_syncline(VARIABLE)
|
# b4_percent_define_get_syncline(VARIABLE)dnl
|
||||||
# ----------------------------------------
|
# -------------------------------------------
|
||||||
|
# Should always be following by a dnl.
|
||||||
|
#
|
||||||
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.
|
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.
|
||||||
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
||||||
# since that's a Bison or skeleton error. Otherwise, return its definition
|
# since that's a Bison or skeleton error. Otherwise, return its definition
|
||||||
@@ -957,10 +1040,9 @@ m4_define([b4_percent_code_get],
|
|||||||
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
||||||
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
||||||
m4_ifdef(b4_macro_name,
|
m4_ifdef(b4_macro_name,
|
||||||
[b4_comment([m4_if([$#], [0], [[Unqualified %code]],
|
[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]],
|
||||||
[["%code ]$1["]])[ blocks.]])
|
[[["%code ]$1[" blocks.]]]))
|
||||||
b4_user_code([m4_indir(b4_macro_name)])
|
b4_user_code([m4_indir(b4_macro_name)])])dnl
|
||||||
])dnl
|
|
||||||
m4_popdef([b4_macro_name])])
|
m4_popdef([b4_macro_name])])
|
||||||
|
|
||||||
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
||||||
@@ -984,6 +1066,7 @@ m4_define([b4_percent_code_ifdef],
|
|||||||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||||
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
|
b4_percent_define_if_define([api.token.raw])
|
||||||
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
||||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||||
b4_percent_define_if_define([parse.assert])
|
b4_percent_define_if_define([parse.assert])
|
||||||
@@ -998,21 +1081,23 @@ m4_define([b4_bison_locations_if],
|
|||||||
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
|
|
||||||
|
# %define parse.error "(custom|detailed|simple|verbose)"
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
# 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_default([[parse.error]], [[simple]])
|
||||||
b4_percent_define_check_values([[[[parse.error]],
|
b4_percent_define_check_values([[[[parse.error]],
|
||||||
[[simple]], [[verbose]]]])
|
[[custom]], [[detailed]], [[simple]], [[verbose]]]])
|
||||||
m4_define([b4_error_verbose_flag],
|
|
||||||
[m4_case(b4_percent_define_get([[parse.error]]),
|
# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE)
|
||||||
[simple], [[0]],
|
# ----------------------------------------------------------
|
||||||
[verbose], [[1]])])
|
m4_define([b4_parse_error_case],
|
||||||
b4_define_flag_if([error_verbose])
|
[m4_case(b4_percent_define_get([[parse.error]]), $@)])
|
||||||
|
|
||||||
|
# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE)
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
m4_define([b4_parse_error_bmatch],
|
||||||
|
[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)])
|
||||||
|
|
||||||
# yytoken_table is needed to support verbose errors.
|
|
||||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
||||||
@@ -1060,10 +1145,10 @@ m4_define_default([b4_location_initial_line], [1])
|
|||||||
## Sanity checks. ##
|
## Sanity checks. ##
|
||||||
## --------------- ##
|
## --------------- ##
|
||||||
|
|
||||||
# api.location.prefix={...} (Java and C++).
|
# api.location.type={...} (C, C++ and Java).
|
||||||
b4_percent_define_check_kind([api.location.type], [code], [deprecated])
|
b4_percent_define_check_kind([api.location.type], [code], [deprecated])
|
||||||
|
|
||||||
# api.position.prefix={...} (Java).
|
# api.position.type={...} (Java).
|
||||||
b4_percent_define_check_kind([api.position.type], [code], [deprecated])
|
b4_percent_define_check_kind([api.position.type], [code], [deprecated])
|
||||||
|
|
||||||
# api.prefix >< %name-prefix.
|
# api.prefix >< %name-prefix.
|
||||||
@@ -1098,3 +1183,11 @@ b4_percent_define_ifdef([api.value.type],
|
|||||||
|
|
||||||
# api.value.union.name.
|
# api.value.union.name.
|
||||||
b4_percent_define_check_kind([api.value.union.name], [keyword])
|
b4_percent_define_check_kind([api.value.union.name], [keyword])
|
||||||
|
|
||||||
|
# parse.error (custom|detailed) >< token-table.
|
||||||
|
b4_token_table_if(
|
||||||
|
[b4_parse_error_bmatch([custom\|detailed],
|
||||||
|
[b4_complain_at(b4_percent_define_get_loc([parse.error]),
|
||||||
|
[['%s' and '%s' cannot be used together]],
|
||||||
|
[%token-table],
|
||||||
|
[%define parse.error (custom|detailed)])])])
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# C++ skeleton dispatching for Bison.
|
# C++ skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software
|
# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
|
||||||
# Foundation, Inc.
|
# Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
+155
-102
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -22,6 +22,8 @@ b4_percent_define_ifdef([[api.value.union.name]],
|
|||||||
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
||||||
[named %union is invalid in C++])])
|
[named %union is invalid in C++])])
|
||||||
|
|
||||||
|
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||||
|
|
||||||
m4_include(b4_skeletonsdir/[c.m4])
|
m4_include(b4_skeletonsdir/[c.m4])
|
||||||
|
|
||||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||||
@@ -147,33 +149,55 @@ m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
|||||||
[[namespace reference has a trailing "::"]])])
|
[[namespace reference has a trailing "::"]])])
|
||||||
|
|
||||||
m4_define([b4_namespace_open],
|
m4_define([b4_namespace_open],
|
||||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||||
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
||||||
[^\(.\)[ ]*::], [\1])),
|
[^\(.\)[ ]*::], [\1])),
|
||||||
[::], [ { namespace ])[ {]])])
|
[::], [ { namespace ])[ {]])])
|
||||||
|
|
||||||
m4_define([b4_namespace_close],
|
m4_define([b4_namespace_close],
|
||||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||||
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||||
[\1])),
|
[\1])),
|
||||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||||
|
|
||||||
|
|
||||||
|
## ------------- ##
|
||||||
|
## Token kinds. ##
|
||||||
|
## ------------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums
|
# b4_token_enums
|
||||||
# --------------
|
# --------------
|
||||||
# Output the definition of the tokens as enums.
|
# Output the definition of the token kinds.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[[enum yytokentype
|
[[enum token_kind_type
|
||||||
{
|
{
|
||||||
]m4_join([,
|
]b4_symbol([-2], [id])[ = -2,
|
||||||
],
|
]b4_symbol_foreach([b4_token_enum])dnl
|
||||||
b4_symbol_map([b4_token_enum]))[
|
[ };]dnl
|
||||||
};]dnl
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Symbol kinds. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
# b4_declare_symbol_enum
|
||||||
|
# ----------------------
|
||||||
|
# The definition of the symbol internal numbers as an enum.
|
||||||
|
# Defining YYEMPTY here is important: it forces the compiler
|
||||||
|
# to use a signed type, which matters for yytoken.
|
||||||
|
m4_define([b4_declare_symbol_enum],
|
||||||
|
[[enum symbol_kind_type
|
||||||
|
{
|
||||||
|
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
|
||||||
|
]b4_symbol_kind([-2])[ = -2,
|
||||||
|
]b4_symbol_foreach([ b4_symbol_enum])dnl
|
||||||
|
[ };]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
## Semantic Values. ##
|
## Semantic Values. ##
|
||||||
@@ -194,7 +218,7 @@ m4_define([b4_value_type_declare],
|
|||||||
[union\|union-directive],
|
[union\|union-directive],
|
||||||
[[ union semantic_type
|
[[ union semantic_type
|
||||||
{
|
{
|
||||||
]b4_user_union_members[
|
]b4_user_union_members[
|
||||||
};]])])dnl
|
};]])])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -231,23 +255,31 @@ m4_define([b4_public_types_declare],
|
|||||||
location_type location;])[
|
location_type location;])[
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Tokens.
|
/// Token kinds.
|
||||||
struct token
|
struct token
|
||||||
{
|
{
|
||||||
]b4_token_enums[
|
]b4_token_enums[
|
||||||
|
/// Backward compatibility alias (Bison 3.6).
|
||||||
|
typedef token_kind_type yytokentype;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// (External) token type, as returned by yylex.
|
/// Token kind, as returned by yylex.
|
||||||
typedef token::yytokentype token_type;
|
typedef token::yytokentype token_kind_type;
|
||||||
|
|
||||||
/// Symbol type: an internal symbol number.
|
/// Backward compatibility alias (Bison 3.6).
|
||||||
typedef int symbol_number_type;
|
typedef token_kind_type token_type;
|
||||||
|
|
||||||
/// The symbol type number to denote an empty symbol.
|
/// Symbol kinds.
|
||||||
enum { empty_symbol = -2 };
|
struct symbol_kind
|
||||||
|
{
|
||||||
|
]b4_declare_symbol_enum[
|
||||||
|
};
|
||||||
|
|
||||||
/// Internal symbol number for tokens (subsumed by symbol_number_type).
|
/// (Internal) symbol kind.
|
||||||
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
|
typedef symbol_kind::symbol_kind_type symbol_kind_type;
|
||||||
|
|
||||||
|
/// The number of tokens.
|
||||||
|
static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS;
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
@@ -258,8 +290,8 @@ m4_define([b4_public_types_declare],
|
|||||||
m4_define([b4_symbol_type_define],
|
m4_define([b4_symbol_type_define],
|
||||||
[[ /// A complete symbol.
|
[[ /// A complete symbol.
|
||||||
///
|
///
|
||||||
/// Expects its Base type to provide access to the symbol type
|
/// Expects its Base type to provide access to the symbol kind
|
||||||
/// via type_get ().
|
/// via kind ().
|
||||||
///
|
///
|
||||||
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
@@ -276,7 +308,14 @@ m4_define([b4_symbol_type_define],
|
|||||||
|
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
/// Move constructor.
|
/// Move constructor.
|
||||||
basic_symbol (basic_symbol&& that);
|
basic_symbol (basic_symbol&& that)
|
||||||
|
: Base (std::move (that))
|
||||||
|
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||||
|
, location (std::move (that.location))])[
|
||||||
|
{]b4_variant_if([
|
||||||
|
b4_symbol_variant([this->kind ()], [value], [move],
|
||||||
|
[std::move (that.value)])
|
||||||
|
])[}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
@@ -303,21 +342,47 @@ m4_define([b4_symbol_type_define],
|
|||||||
void clear ()
|
void clear ()
|
||||||
{]b4_variant_if([[
|
{]b4_variant_if([[
|
||||||
// User destructor.
|
// User destructor.
|
||||||
symbol_number_type yytype = this->type_get ();
|
symbol_kind_type yykind = this->kind ();
|
||||||
basic_symbol<Base>& yysym = *this;
|
basic_symbol<Base>& yysym = *this;
|
||||||
(void) yysym;
|
(void) yysym;
|
||||||
switch (yytype)
|
switch (yykind)
|
||||||
{
|
{
|
||||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type destructor.
|
// Value type destructor.
|
||||||
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
|
]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
|
||||||
Base::clear ();
|
Base::clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]b4_parse_error_bmatch(
|
||||||
|
[custom\|detailed],
|
||||||
|
[[ /// The user-facing name of this symbol.
|
||||||
|
const char *name () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||||
|
}]],
|
||||||
|
[simple],
|
||||||
|
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||||
|
/// The user-facing name of this symbol.
|
||||||
|
const char *name () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||||
|
}
|
||||||
|
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||||
|
]],
|
||||||
|
[verbose],
|
||||||
|
[[ /// The user-facing name of this symbol.
|
||||||
|
std::string name () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||||
|
}]])[
|
||||||
|
|
||||||
|
/// Backward compatibility (Bison 3.6).
|
||||||
|
symbol_kind_type type_get () const YY_NOEXCEPT;
|
||||||
|
|
||||||
/// Whether empty.
|
/// Whether empty.
|
||||||
bool empty () const YY_NOEXCEPT;
|
bool empty () const YY_NOEXCEPT;
|
||||||
|
|
||||||
@@ -338,49 +403,51 @@ m4_define([b4_symbol_type_define],
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Type access provider for token (enum) based symbols.
|
/// Type access provider for token (enum) based symbols.
|
||||||
struct by_type
|
struct by_kind
|
||||||
{
|
{
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
by_type ();
|
by_kind ();
|
||||||
|
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
/// Move constructor.
|
/// Move constructor.
|
||||||
by_type (by_type&& that);
|
by_kind (by_kind&& that);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
by_type (const by_type& that);
|
by_kind (const by_kind& that);
|
||||||
|
|
||||||
/// The symbol type as needed by the constructor.
|
/// The symbol kind as needed by the constructor.
|
||||||
typedef token_type kind_type;
|
typedef token_kind_type kind_type;
|
||||||
|
|
||||||
/// Constructor from (external) token numbers.
|
/// Constructor from (external) token numbers.
|
||||||
by_type (kind_type t);
|
by_kind (kind_type t);
|
||||||
|
|
||||||
/// Record that this symbol is empty.
|
/// Record that this symbol is empty.
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
||||||
/// Steal the symbol type from \a that.
|
/// Steal the symbol kind from \a that.
|
||||||
void move (by_type& that);
|
void move (by_kind& that);
|
||||||
|
|
||||||
/// The (internal) type number (corresponding to \a type).
|
/// The (internal) type number (corresponding to \a type).
|
||||||
/// \a empty when empty.
|
/// \a empty when empty.
|
||||||
symbol_number_type type_get () const YY_NOEXCEPT;
|
symbol_kind_type kind () const YY_NOEXCEPT;
|
||||||
|
|
||||||
/// The token.
|
/// Backward compatibility (Bison 3.6).
|
||||||
token_type token () const YY_NOEXCEPT;
|
symbol_kind_type type_get () const YY_NOEXCEPT;
|
||||||
|
|
||||||
/// The symbol type.
|
/// The symbol kind.
|
||||||
/// \a empty_symbol when empty.
|
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||||
/// An int, not token_number_type, to be able to store empty_symbol.
|
symbol_kind_type kind_;
|
||||||
int type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
||||||
|
typedef by_kind by_type;
|
||||||
|
|
||||||
/// "External" symbols: returned by the scanner.
|
/// "External" symbols: returned by the scanner.
|
||||||
struct symbol_type : basic_symbol<by_type>
|
struct symbol_type : basic_symbol<by_kind>
|
||||||
{]b4_variant_if([[
|
{]b4_variant_if([[
|
||||||
/// Superclass.
|
/// Superclass.
|
||||||
typedef basic_symbol<by_type> super_type;
|
typedef basic_symbol<by_kind> super_type;
|
||||||
|
|
||||||
/// Empty symbol.
|
/// Empty symbol.
|
||||||
symbol_type () {}
|
symbol_type () {}
|
||||||
@@ -396,25 +463,13 @@ m4_define([b4_symbol_type_define],
|
|||||||
# Provide the implementation needed by the public types.
|
# Provide the implementation needed by the public types.
|
||||||
m4_define([b4_public_types_define],
|
m4_define([b4_public_types_define],
|
||||||
[[ // basic_symbol.
|
[[ // basic_symbol.
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
|
|
||||||
: Base (std::move (that))
|
|
||||||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
|
||||||
, location (std::move (that.location))])[
|
|
||||||
{]b4_variant_if([
|
|
||||||
b4_symbol_variant([this->type_get ()], [value], [move],
|
|
||||||
[std::move (that.value)])
|
|
||||||
])[}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||||
: Base (that)
|
: Base (that)
|
||||||
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||||
, location (that.location)])[
|
, location (that.location)])[
|
||||||
{]b4_variant_if([
|
{]b4_variant_if([
|
||||||
b4_symbol_variant([this->type_get ()], [value], [copy],
|
b4_symbol_variant([this->kind ()], [value], [copy],
|
||||||
[YY_MOVE (that.value)])
|
[YY_MOVE (that.value)])
|
||||||
])[}
|
])[}
|
||||||
|
|
||||||
@@ -439,13 +494,20 @@ m4_define([b4_public_types_define],
|
|||||||
, location (YY_MOVE (l))])[
|
, location (YY_MOVE (l))])[
|
||||||
{]b4_variant_if([[
|
{]b4_variant_if([[
|
||||||
(void) v;
|
(void) v;
|
||||||
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||||
|
|
||||||
|
template <typename Base>
|
||||||
|
]b4_parser_class[::symbol_kind_type
|
||||||
|
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
||||||
|
{
|
||||||
|
return this->kind ();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
bool
|
bool
|
||||||
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return Base::type_get () == empty_symbol;
|
return this->kind () == symbol_kind::]b4_symbol_prefix[YYEMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
@@ -453,67 +515,58 @@ m4_define([b4_public_types_define],
|
|||||||
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
||||||
{
|
{
|
||||||
super_type::move (s);
|
super_type::move (s);
|
||||||
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move],
|
||||||
[YY_MOVE (s.value)])],
|
[YY_MOVE (s.value)])],
|
||||||
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
||||||
location = YY_MOVE (s.location);])[
|
location = YY_MOVE (s.location);])[
|
||||||
}
|
}
|
||||||
|
|
||||||
// by_type.
|
// by_kind.
|
||||||
]b4_inline([$1])b4_parser_class[::by_type::by_type ()
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
|
||||||
: type (empty_symbol)
|
: kind_ (symbol_kind::]b4_symbol_prefix[YYEMPTY)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (by_type&& that)
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that)
|
||||||
: type (that.type)
|
: kind_ (that.kind_)
|
||||||
{
|
{
|
||||||
that.clear ();
|
that.clear ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (const by_type& that)
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that)
|
||||||
: type (that.type)
|
: kind_ (that.kind_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t)
|
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t)
|
||||||
: type (yytranslate_ (t))
|
: kind_ (yytranslate_ (t))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])[void
|
]b4_inline([$1])[void
|
||||||
]b4_parser_class[::by_type::clear ()
|
]b4_parser_class[::by_kind::clear ()
|
||||||
{
|
{
|
||||||
type = empty_symbol;
|
kind_ = symbol_kind::]b4_symbol_prefix[YYEMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_inline([$1])[void
|
]b4_inline([$1])[void
|
||||||
]b4_parser_class[::by_type::move (by_type& that)
|
]b4_parser_class[::by_kind::move (by_kind& that)
|
||||||
{
|
{
|
||||||
type = that.type;
|
kind_ = that.kind_;
|
||||||
that.clear ();
|
that.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_inline([$1])[int
|
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::by_type::type_get () const YY_NOEXCEPT
|
]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return type;
|
return kind_;
|
||||||
}
|
}
|
||||||
]b4_token_ctor_if([[
|
|
||||||
]b4_inline([$1])b4_parser_class[::token_type
|
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::by_type::token () const YY_NOEXCEPT
|
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
// YYTOKNUM[NUM] -- (External) token number corresponding to the
|
return this->kind ();
|
||||||
// (internal) symbol number NUM (which must be that of a token). */
|
|
||||||
static
|
|
||||||
const ]b4_int_type_for([b4_toknum])[
|
|
||||||
yytoken_number_[] =
|
|
||||||
{
|
|
||||||
]b4_toknum[
|
|
||||||
};
|
|
||||||
return token_type (yytoken_number_[type]);
|
|
||||||
}
|
}
|
||||||
]])[]dnl
|
]])
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_token_constructor_define
|
# b4_token_constructor_define
|
||||||
@@ -528,27 +581,27 @@ m4_define([b4_token_constructor_define], [])
|
|||||||
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
||||||
# sometimes in the cc file.
|
# sometimes in the cc file.
|
||||||
m4_define([b4_yytranslate_define],
|
m4_define([b4_yytranslate_define],
|
||||||
[ b4_inline([$1])b4_parser_class[::token_number_type
|
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type],
|
]b4_parser_class[::yytranslate_ (int t)
|
||||||
[int])[ t)
|
|
||||||
{
|
{
|
||||||
// YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
]b4_api_token_raw_if(
|
||||||
|
[[ return static_cast<symbol_kind_type> (t);]],
|
||||||
|
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||||
// TOKEN-NUM as returned by yylex.
|
// TOKEN-NUM as returned by yylex.
|
||||||
static
|
static
|
||||||
const token_number_type
|
const ]b4_int_type_for([b4_translate])[
|
||||||
translate_table[] =
|
translate_table[] =
|
||||||
{
|
{
|
||||||
]b4_translate[
|
]b4_translate[
|
||||||
};
|
};
|
||||||
const unsigned user_token_number_max_ = ]b4_user_token_number_max[;
|
const int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
const token_number_type undef_token_ = ]b4_undef_token_number[;
|
|
||||||
|
|
||||||
if (static_cast<int> (t) <= yyeof_)
|
if (t <= 0)
|
||||||
return yyeof_;
|
return symbol_kind::]b4_symbol_prefix[YYEOF;
|
||||||
else if (static_cast<unsigned> (t) <= user_token_number_max_)
|
else if (t <= user_token_number_max_)
|
||||||
return translate_table[t];
|
return YY_CAST (symbol_kind_type, translate_table[t]);
|
||||||
else
|
else
|
||||||
return undef_token_;
|
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Common code for C-like languages (C, C++, Java, etc.)
|
# Common code for C-like languages (C, C++, Java, etc.)
|
||||||
|
|
||||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2012-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,15 +17,21 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||||
# Avoid adding indentation to the first line, as the indentation comes
|
# Avoid adding indentation to the first line, as the indentation comes
|
||||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||||
|
# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close
|
||||||
|
# the comments before its end.
|
||||||
#
|
#
|
||||||
# Prefix all the output lines with PREFIX.
|
# Prefix all the output lines with PREFIX.
|
||||||
m4_define([_b4_comment],
|
m4_define([_b4_comment],
|
||||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
[$2[]b4_gsub(m4_expand([$1]),
|
||||||
|
[[*]/], [*\\/],
|
||||||
|
[/[*]], [/\\*],
|
||||||
|
[
|
||||||
\(.\)], [
|
\(.\)], [
|
||||||
$3\1])$4])
|
$3\1])$4])
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# C skeleton dispatching for Bison.
|
# C skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software
|
# Copyright (C) 2006-2007, 2009-2015, 2018-2020 Free Software
|
||||||
# Foundation, Inc.
|
# Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
+318
-129
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# C M4 Macros for Bison.
|
# C M4 Macros for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
|
# Copyright (C) 2002, 2004-2015, 2018-2020 Free Software Foundation,
|
||||||
# Inc.
|
# 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
|
||||||
@@ -101,6 +101,7 @@ m4_define_default([b4_prefix], [b4_api_prefix])
|
|||||||
b4_percent_define_default([[api.value.union.name]],
|
b4_percent_define_default([[api.value.union.name]],
|
||||||
[b4_api_PREFIX[][STYPE]])
|
[b4_api_PREFIX[][STYPE]])
|
||||||
|
|
||||||
|
b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
|
||||||
|
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
## Pure/impure interfaces. ##
|
## Pure/impure interfaces. ##
|
||||||
@@ -129,6 +130,13 @@ m4_define([b4_user_args],
|
|||||||
[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
|
[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_user_formals
|
||||||
|
# ---------------
|
||||||
|
# The possible parse-params formal arguments preceded by a comma.
|
||||||
|
m4_define([b4_user_formals],
|
||||||
|
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
|
||||||
|
|
||||||
|
|
||||||
# b4_parse_param
|
# b4_parse_param
|
||||||
# --------------
|
# --------------
|
||||||
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
||||||
@@ -167,38 +175,158 @@ b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
|||||||
|
|
||||||
# b4_int_type(MIN, MAX)
|
# b4_int_type(MIN, MAX)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Return the smallest int type able to handle numbers ranging from
|
# Return a narrow int type able to handle integers ranging from MIN
|
||||||
# MIN to MAX (included).
|
# to MAX (included) in portable C code. Assume MIN and MAX fall in
|
||||||
|
# 'int' range.
|
||||||
m4_define([b4_int_type],
|
m4_define([b4_int_type],
|
||||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
[m4_if(b4_ints_in($@, [-127], [127]), [1], [signed char],
|
||||||
b4_ints_in($@, [-128], [127]), [1], [signed char],
|
b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||||
|
|
||||||
|
b4_ints_in($@, [-32767], [32767]), [1], [short],
|
||||||
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
||||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
|
||||||
|
|
||||||
m4_eval([0 <= $1]), [1], [unsigned],
|
|
||||||
|
|
||||||
[int])])
|
[int])])
|
||||||
|
|
||||||
|
# b4_c99_int_type(MIN, MAX)
|
||||||
|
# -------------------------
|
||||||
|
# Like b4_int_type, but for C99.
|
||||||
|
# b4_c99_int_type_define replaces b4_int_type with this.
|
||||||
|
m4_define([b4_c99_int_type],
|
||||||
|
[m4_if(b4_ints_in($@, [-127], [127]), [1], [yytype_int8],
|
||||||
|
b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
||||||
|
|
||||||
|
b4_ints_in($@, [-32767], [32767]), [1], [yytype_int16],
|
||||||
|
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
|
||||||
|
|
||||||
|
[int])])
|
||||||
|
|
||||||
|
# b4_c99_int_type_define
|
||||||
|
# ----------------------
|
||||||
|
# Define private types suitable for holding small integers in C99 or later.
|
||||||
|
m4_define([b4_c99_int_type_define],
|
||||||
|
[m4_copy_force([b4_c99_int_type], [b4_int_type])dnl
|
||||||
|
[#ifdef short
|
||||||
|
# undef short
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
|
||||||
|
<limits.h> and (if available) <stdint.h> are included
|
||||||
|
so that the code can choose integer types of a good width. */
|
||||||
|
|
||||||
|
#ifndef __PTRDIFF_MAX__
|
||||||
|
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||||
|
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YY_STDINT_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Narrow types that promote to a signed type and that can represent a
|
||||||
|
signed or unsigned integer of at least N bits. In tables they can
|
||||||
|
save space and decrease cache pressure. Promoting to a signed type
|
||||||
|
helps avoid bugs in integer arithmetic. */
|
||||||
|
|
||||||
|
#ifdef __INT_LEAST8_MAX__
|
||||||
|
typedef __INT_LEAST8_TYPE__ yytype_int8;
|
||||||
|
#elif defined YY_STDINT_H
|
||||||
|
typedef int_least8_t yytype_int8;
|
||||||
|
#else
|
||||||
|
typedef signed char yytype_int8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __INT_LEAST16_MAX__
|
||||||
|
typedef __INT_LEAST16_TYPE__ yytype_int16;
|
||||||
|
#elif defined YY_STDINT_H
|
||||||
|
typedef int_least16_t yytype_int16;
|
||||||
|
#else
|
||||||
|
typedef short yytype_int16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
|
||||||
|
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
|
||||||
|
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
|
||||||
|
&& UINT_LEAST8_MAX <= INT_MAX)
|
||||||
|
typedef uint_least8_t yytype_uint8;
|
||||||
|
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
|
||||||
|
typedef unsigned char yytype_uint8;
|
||||||
|
#else
|
||||||
|
typedef short yytype_uint8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
|
||||||
|
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
|
||||||
|
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
|
||||||
|
&& UINT_LEAST16_MAX <= INT_MAX)
|
||||||
|
typedef uint_least16_t yytype_uint16;
|
||||||
|
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
|
||||||
|
typedef unsigned short yytype_uint16;
|
||||||
|
#else
|
||||||
|
typedef int yytype_uint16;
|
||||||
|
#endif]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_sizes_types_define
|
||||||
|
# ---------------------
|
||||||
|
# Define YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM,
|
||||||
|
# and YYSIZEOF.
|
||||||
|
m4_define([b4_sizes_types_define],
|
||||||
|
[[#ifndef YYPTRDIFF_T
|
||||||
|
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
|
||||||
|
# define YYPTRDIFF_T __PTRDIFF_TYPE__
|
||||||
|
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
|
||||||
|
# elif defined PTRDIFF_MAX
|
||||||
|
# ifndef ptrdiff_t
|
||||||
|
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# endif
|
||||||
|
# define YYPTRDIFF_T ptrdiff_t
|
||||||
|
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
|
||||||
|
# else
|
||||||
|
# define YYPTRDIFF_T long
|
||||||
|
# define YYPTRDIFF_MAXIMUM LONG_MAX
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YYSIZE_T
|
||||||
|
# ifdef __SIZE_TYPE__
|
||||||
|
# define YYSIZE_T __SIZE_TYPE__
|
||||||
|
# elif defined size_t
|
||||||
|
# define YYSIZE_T size_t
|
||||||
|
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||||
|
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYSIZE_T size_t
|
||||||
|
# else
|
||||||
|
# define YYSIZE_T unsigned
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define YYSIZE_MAXIMUM \
|
||||||
|
YY_CAST (YYPTRDIFF_T, \
|
||||||
|
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
|
||||||
|
? YYPTRDIFF_MAXIMUM \
|
||||||
|
: YY_CAST (YYSIZE_T, -1)))
|
||||||
|
|
||||||
|
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
# b4_int_type_for(NAME)
|
# b4_int_type_for(NAME)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Return the smallest int type able to handle numbers ranging from
|
# Return a narrow int type able to handle numbers ranging from
|
||||||
# 'NAME_min' to 'NAME_max' (included).
|
# 'NAME_min' to 'NAME_max' (included).
|
||||||
m4_define([b4_int_type_for],
|
m4_define([b4_int_type_for],
|
||||||
[b4_int_type($1_min, $1_max)])
|
[b4_int_type($1_min, $1_max)])
|
||||||
|
|
||||||
|
|
||||||
# b4_table_value_equals(TABLE, VALUE, LITERAL)
|
# b4_table_value_equals(TABLE, VALUE, LITERAL, SYMBOL)
|
||||||
# --------------------------------------------
|
# ----------------------------------------------------
|
||||||
# Without inducing a comparison warning from the compiler, check if the
|
# Without inducing a comparison warning from the compiler, check if the
|
||||||
# literal value LITERAL equals VALUE from table TABLE, which must have
|
# literal value LITERAL equals VALUE from table TABLE, which must have
|
||||||
# TABLE_min and TABLE_max defined.
|
# TABLE_min and TABLE_max defined. SYMBOL denotes
|
||||||
m4_define([b4_table_value_equals],
|
m4_define([b4_table_value_equals],
|
||||||
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
||||||
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
||||||
[[0]],
|
[[0]],
|
||||||
[(!!(($2) == ($3)))])])
|
[(($2) == $4)])])
|
||||||
|
|
||||||
|
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
@@ -210,37 +338,39 @@ m4_define([b4_table_value_equals],
|
|||||||
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
||||||
# _Noreturn.
|
# _Noreturn.
|
||||||
m4_define([b4_attribute_define],
|
m4_define([b4_attribute_define],
|
||||||
[[#ifndef YY_ATTRIBUTE
|
[[#ifndef YY_ATTRIBUTE_PURE
|
||||||
# if (defined __GNUC__ \
|
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
||||||
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||||
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
|
|
||||||
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
|
|
||||||
# else
|
# else
|
||||||
# define YY_ATTRIBUTE(Spec) /* empty */
|
# define YY_ATTRIBUTE_PURE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef YY_ATTRIBUTE_PURE
|
|
||||||
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef YY_ATTRIBUTE_UNUSED
|
#ifndef YY_ATTRIBUTE_UNUSED
|
||||||
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
|
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
|
||||||
|
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||||
|
# else
|
||||||
|
# define YY_ATTRIBUTE_UNUSED
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
||||||
#if ! defined _Noreturn
|
]dnl This is an exact copy of lib/_Noreturn.h.
|
||||||
# if defined __cplusplus && 201103L <= __cplusplus
|
[#ifndef _Noreturn
|
||||||
|
# if (defined __cplusplus \
|
||||||
|
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||||
|
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
|
||||||
# define _Noreturn [[noreturn]]
|
# define _Noreturn [[noreturn]]
|
||||||
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
|
# elif ((!defined __cplusplus || defined __clang__) \
|
||||||
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||||
|| 0x5110 <= __SUNPRO_C)
|
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
|
||||||
# define _Noreturn __attribute__ ((__noreturn__))
|
/* _Noreturn works as-is. */
|
||||||
# elif defined _MSC_VER && 1200 <= _MSC_VER
|
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
|
||||||
# define _Noreturn __declspec (noreturn)
|
# define _Noreturn __attribute__ ((__noreturn__))
|
||||||
# else
|
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
||||||
# define _Noreturn
|
# define _Noreturn __declspec (noreturn)
|
||||||
# endif
|
# else
|
||||||
|
# define _Noreturn
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -253,11 +383,11 @@ m4_define([b4_attribute_define],
|
|||||||
|
|
||||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||||
_Pragma ("GCC diagnostic push") \
|
_Pragma ("GCC diagnostic push") \
|
||||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
|
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
|
||||||
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
||||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||||
_Pragma ("GCC diagnostic pop")
|
_Pragma ("GCC diagnostic pop")
|
||||||
#else
|
#else
|
||||||
# define YY_INITIAL_VALUE(Value) Value
|
# define YY_INITIAL_VALUE(Value) Value
|
||||||
@@ -269,9 +399,36 @@ m4_define([b4_attribute_define],
|
|||||||
#ifndef YY_INITIAL_VALUE
|
#ifndef YY_INITIAL_VALUE
|
||||||
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
|
||||||
|
# define YY_IGNORE_USELESS_CAST_BEGIN \
|
||||||
|
_Pragma ("GCC diagnostic push") \
|
||||||
|
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
|
||||||
|
# define YY_IGNORE_USELESS_CAST_END \
|
||||||
|
_Pragma ("GCC diagnostic pop")
|
||||||
|
#endif
|
||||||
|
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
|
||||||
|
# define YY_IGNORE_USELESS_CAST_BEGIN
|
||||||
|
# define YY_IGNORE_USELESS_CAST_END
|
||||||
|
#endif
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_cast_define
|
||||||
|
# --------------
|
||||||
|
m4_define([b4_cast_define],
|
||||||
|
[# ifndef YY_CAST
|
||||||
|
# ifdef __cplusplus
|
||||||
|
# define YY_CAST(Type, Val) static_cast<Type> (Val)
|
||||||
|
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
|
||||||
|
# else
|
||||||
|
# define YY_CAST(Type, Val) ((Type) (Val))
|
||||||
|
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
|
||||||
|
# endif
|
||||||
|
# endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_null_define
|
# b4_null_define
|
||||||
# --------------
|
# --------------
|
||||||
# Portability issues: define a YY_NULLPTR appropriate for the current
|
# Portability issues: define a YY_NULLPTR appropriate for the current
|
||||||
@@ -317,9 +474,22 @@ static const b4_int_type_for([$2]) yy$1[[]] =
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------- ##
|
||||||
## Assigning token numbers. ##
|
## Token kinds. ##
|
||||||
## ------------------------- ##
|
## ------------- ##
|
||||||
|
|
||||||
|
# Because C enums are not scoped, because tokens are exposed in the
|
||||||
|
# header, and because these tokens are common to all the parsers, we
|
||||||
|
# need to make sure their names don't collide: use the api.prefix.
|
||||||
|
# YYEOF is special, since the user may give it a different name.
|
||||||
|
m4_define([b4_symbol(-2, id)], [b4_api_PREFIX[][EMPTY]])
|
||||||
|
m4_define([b4_symbol(-2, tag)], [[No symbol.]])
|
||||||
|
|
||||||
|
m4_if(b4_symbol(0, id), [YYEOF],
|
||||||
|
[m4_define([b4_symbol(0, id)], [b4_api_PREFIX[][EOF]])])
|
||||||
|
m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][error]])
|
||||||
|
m4_define([b4_symbol(2, id)], [b4_api_PREFIX[][UNDEF]])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_define(TOKEN-NUM)
|
# b4_token_define(TOKEN-NUM)
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@@ -331,7 +501,7 @@ m4_define([b4_token_define],
|
|||||||
# ----------------
|
# ----------------
|
||||||
# Output the definition of the tokens.
|
# Output the definition of the tokens.
|
||||||
m4_define([b4_token_defines],
|
m4_define([b4_token_defines],
|
||||||
[b4_any_token_visible_if([/* Tokens. */
|
[b4_any_token_visible_if([/* Token kinds. */
|
||||||
m4_join([
|
m4_join([
|
||||||
], b4_symbol_map([b4_token_define]))
|
], b4_symbol_map([b4_token_define]))
|
||||||
])])
|
])])
|
||||||
@@ -341,34 +511,81 @@ m4_join([
|
|||||||
# ------------------------
|
# ------------------------
|
||||||
# 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],
|
||||||
[b4_token_format([%s = %s], [$1])])
|
[b4_token_visible_if([$1],
|
||||||
|
[m4_format([ %-30s %s],
|
||||||
|
m4_format([[%s = %s%s%s]],
|
||||||
|
b4_symbol([$1], [id]),
|
||||||
|
b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])),
|
||||||
|
m4_if([$1], b4_last_enum_token, [], [[,]])),
|
||||||
|
[b4_symbol_tag_comment([$1])])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums
|
# b4_token_enums
|
||||||
# --------------
|
# --------------
|
||||||
# Output the definition of the tokens (if there are) as enums.
|
# The definition of the token kinds.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[b4_any_token_visible_if([[/* Token type. */
|
[b4_any_token_visible_if([[/* Token kinds. */
|
||||||
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||||
# define ]b4_api_PREFIX[TOKENTYPE
|
# define ]b4_api_PREFIX[TOKENTYPE
|
||||||
enum ]b4_api_prefix[tokentype
|
enum ]b4_api_prefix[tokentype
|
||||||
{
|
{
|
||||||
]m4_join([,
|
]b4_symbol([-2], [id])[ = -2,
|
||||||
],
|
]b4_symbol_foreach([b4_token_enum])dnl
|
||||||
b4_symbol_map([b4_token_enum]))[
|
[ };
|
||||||
};
|
typedef enum ]b4_api_prefix[tokentype ]b4_api_prefix[token_kind_t;
|
||||||
#endif
|
#endif
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums_defines
|
# b4_token_enums_defines
|
||||||
# ----------------------
|
# ----------------------
|
||||||
# Output the definition of the tokens (if there are any) as enums and,
|
# The definition of the tokens (if there are any) as enums and,
|
||||||
# if POSIX 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])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_translate(STRING)
|
||||||
|
# ---------------------------
|
||||||
|
# Used by "bison" in the array of symbol names to mark those that
|
||||||
|
# require translation.
|
||||||
|
m4_define([b4_symbol_translate],
|
||||||
|
[[N_($1)]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Symbol kinds. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
# b4_symbol_enum(SYMBOL-NUM)
|
||||||
|
# --------------------------
|
||||||
|
# Output the definition of this symbol as an enum.
|
||||||
|
m4_define([b4_symbol_enum],
|
||||||
|
[m4_format([ %-40s %s],
|
||||||
|
m4_format([[%s = %s%s%s]],
|
||||||
|
b4_symbol([$1], [kind]),
|
||||||
|
[$1],
|
||||||
|
m4_if([$1], b4_last_symbol, [], [[,]])),
|
||||||
|
[b4_symbol_tag_comment([$1])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_declare_symbol_enum
|
||||||
|
# ----------------------
|
||||||
|
# The definition of the symbol internal numbers as an enum.
|
||||||
|
# Defining YYEMPTY here is important: it forces the compiler
|
||||||
|
# to use a signed type, which matters for yytoken.
|
||||||
|
m4_define([b4_declare_symbol_enum],
|
||||||
|
[[/* Symbol kind. */
|
||||||
|
enum yysymbol_kind_t
|
||||||
|
{
|
||||||
|
]b4_symbol_kind([-2])[ = -2,
|
||||||
|
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||||
|
[};
|
||||||
|
typedef enum yysymbol_kind_t yysymbol_kind_t;
|
||||||
|
]])])
|
||||||
|
|
||||||
|
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
## Semantic Values. ##
|
## Semantic Values. ##
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
@@ -392,15 +609,6 @@ m4_define([b4_symbol_value],
|
|||||||
## ---------------------- ##
|
## ---------------------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_function_define(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
|
||||||
# -----------------------------------------------------------
|
|
||||||
# Declare the function NAME in C.
|
|
||||||
m4_define([b4_function_define],
|
|
||||||
[$2
|
|
||||||
$1 (b4_formals(m4_shift2($@)))[]dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_formals([DECL1, NAME1], ...)
|
# b4_formals([DECL1, NAME1], ...)
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
# The formal arguments of a C function definition.
|
# The formal arguments of a C function definition.
|
||||||
@@ -414,21 +622,6 @@ m4_define([b4_formal],
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ----------------------- ##
|
|
||||||
## Declaring C functions. ##
|
|
||||||
## ----------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
# Declare the function NAME.
|
|
||||||
m4_define([b4_function_declare],
|
|
||||||
[$2 $1 (b4_formals(m4_shift2($@)));[]dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## Calling C functions. ##
|
## Calling C functions. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
@@ -470,7 +663,7 @@ m4_define([b4_sync_start], [[#]line $1 $2])
|
|||||||
m4_define([b4_case],
|
m4_define([b4_case],
|
||||||
[ case $1:
|
[ case $1:
|
||||||
$2
|
$2
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])dnl
|
||||||
break;])
|
break;])
|
||||||
|
|
||||||
|
|
||||||
@@ -480,7 +673,7 @@ m4_define([b4_predicate_case],
|
|||||||
[ case $1:
|
[ case $1:
|
||||||
if (! (
|
if (! (
|
||||||
$2)) YYERROR;
|
$2)) YYERROR;
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])dnl
|
||||||
break;])
|
break;])
|
||||||
|
|
||||||
|
|
||||||
@@ -492,18 +685,15 @@ m4_define_default([b4_yydestruct_define],
|
|||||||
| Release the memory associated to this symbol. |
|
| Release the memory associated to this symbol. |
|
||||||
`-----------------------------------------------*/
|
`-----------------------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yydestruct],
|
static void
|
||||||
[static void],
|
yydestruct (const char *yymsg,
|
||||||
[[const char *yymsg], [yymsg]],
|
yysymbol_kind_t yykind, YYSTYPE *yyvaluep]b4_locations_if(dnl
|
||||||
[[int yytype], [yytype]],
|
[[, YYLTYPE *yylocationp]])[]b4_user_formals[)
|
||||||
[[YYSTYPE *yyvaluep], [yyvaluep]][]dnl
|
|
||||||
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
|
||||||
{
|
{
|
||||||
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
||||||
[ if (!yymsg)
|
[ if (!yymsg)
|
||||||
yymsg = "Deleting";
|
yymsg = "Deleting";
|
||||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
|
||||||
|
|
||||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||||
]b4_symbol_actions([destructor])[
|
]b4_symbol_actions([destructor])[
|
||||||
@@ -521,13 +711,10 @@ m4_define_default([b4_yy_symbol_print_define],
|
|||||||
| Print this symbol's value on YYO. |
|
| Print this symbol's value on YYO. |
|
||||||
`-----------------------------------*/
|
`-----------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_symbol_value_print],
|
static void
|
||||||
[static void],
|
yy_symbol_value_print (FILE *yyo,
|
||||||
[[FILE *yyo], [yyo]],
|
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||||
[[int yytype], [yytype]],
|
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
|
||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
|
||||||
{
|
{
|
||||||
FILE *yyoutput = yyo;
|
FILE *yyoutput = yyo;
|
||||||
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
||||||
@@ -536,33 +723,34 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
|||||||
dnl glr.c does not feature yytoknum.
|
dnl glr.c does not feature yytoknum.
|
||||||
m4_if(b4_skeleton, ["yacc.c"],
|
m4_if(b4_skeleton, ["yacc.c"],
|
||||||
[[# ifdef YYPRINT
|
[[# ifdef YYPRINT
|
||||||
if (yytype < YYNTOKENS)
|
if (yykind < YYNTOKENS)
|
||||||
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
|
||||||
# endif
|
# endif
|
||||||
]])dnl
|
]])dnl
|
||||||
b4_symbol_actions([printer])[
|
b4_percent_code_get([[pre-printer]])dnl
|
||||||
}
|
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||||
|
b4_symbol_actions([printer])
|
||||||
|
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||||
|
b4_percent_code_get([[post-printer]])dnl
|
||||||
|
[}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------.
|
/*---------------------------.
|
||||||
| Print this symbol on YYO. |
|
| Print this symbol on YYO. |
|
||||||
`---------------------------*/
|
`---------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_symbol_print],
|
static void
|
||||||
[static void],
|
yy_symbol_print (FILE *yyo,
|
||||||
[[FILE *yyo], [yyo]],
|
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||||
[[int yytype], [yytype]],
|
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
|
||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
|
||||||
{
|
{
|
||||||
YYFPRINTF (yyo, "%s %s (",
|
YYFPRINTF (yyo, "%s %s (",
|
||||||
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
|
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
|
||||||
|
|
||||||
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
|
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
|
||||||
YYFPRINTF (yyo, ": ");
|
YYFPRINTF (yyo, ": ");
|
||||||
])dnl
|
])dnl
|
||||||
[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
|
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
|
||||||
b4_locations_if([, yylocationp])[]b4_user_args[);
|
b4_locations_if([, yylocationp])[]b4_user_args[);
|
||||||
YYFPRINTF (yyo, ")");
|
YYFPRINTF (yyo, ")");
|
||||||
}]dnl
|
}]dnl
|
||||||
@@ -588,11 +776,11 @@ m4_define([b4_symbol_type_register],
|
|||||||
[m4_define([b4_symbol($1, type_tag)],
|
[m4_define([b4_symbol($1, type_tag)],
|
||||||
[b4_symbol_if([$1], [has_id],
|
[b4_symbol_if([$1], [has_id],
|
||||||
[b4_symbol([$1], [id])],
|
[b4_symbol([$1], [id])],
|
||||||
[yytype_[]b4_symbol([$1], [number])])])dnl
|
[yykind_[]b4_symbol([$1], [number])])])dnl
|
||||||
m4_append([b4_union_members],
|
m4_append([b4_union_members],
|
||||||
m4_expand([
|
m4_expand([m4_format([ %-40s %s],
|
||||||
b4_symbol_tag_comment([$1])dnl
|
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
||||||
b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]))
|
[b4_symbol_tag_comment([$1])])]))
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -709,13 +897,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
|
|||||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||||
[union\|union-directive],
|
[union\|union-directive],
|
||||||
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||||
union ]b4_percent_define_get([[api.value.union.name]])[
|
[union ]b4_percent_define_get([[api.value.union.name]])[
|
||||||
{
|
{
|
||||||
]b4_user_union_members[
|
]b4_user_union_members[
|
||||||
};
|
};
|
||||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||||
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
[typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
||||||
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
||||||
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
@@ -726,7 +914,10 @@ typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[S
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([b4_location_type_define],
|
m4_define([b4_location_type_define],
|
||||||
[[/* Location type. */
|
[[/* Location type. */
|
||||||
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
]b4_percent_define_ifdef([[api.location.type]],
|
||||||
|
[[typedef ]b4_percent_define_get([[api.location.type]])[ ]b4_api_PREFIX[LTYPE;
|
||||||
|
]],
|
||||||
|
[[#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||||
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
||||||
struct ]b4_api_PREFIX[LTYPE
|
struct ]b4_api_PREFIX[LTYPE
|
||||||
{
|
{
|
||||||
@@ -738,7 +929,7 @@ struct ]b4_api_PREFIX[LTYPE
|
|||||||
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
||||||
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
]])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_declare_yylstype
|
# b4_declare_yylstype
|
||||||
@@ -822,16 +1013,14 @@ m4_define([b4_yy_location_print_define],
|
|||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
we won't break user code: when these are the locations we know. */
|
we won't break user code: when these are the locations we know. */
|
||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
# ifndef YY_LOCATION_PRINT
|
||||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
|
|
||||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||||
|
|
||||||
YY_ATTRIBUTE_UNUSED
|
YY_ATTRIBUTE_UNUSED
|
||||||
]b4_function_define([yy_location_print_],
|
static int
|
||||||
[static int],
|
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
||||||
[[FILE *yyo], [yyo]],
|
|
||||||
[[YYLTYPE const * const yylocp], [yylocp]])[
|
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||||
@@ -855,17 +1044,17 @@ YY_ATTRIBUTE_UNUSED
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
yy_location_print_ (File, &(Loc))
|
yy_location_print_ (File, &(Loc))
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
# endif
|
# endif
|
||||||
#endif]],
|
# endif /* !defined YY_LOCATION_PRINT */]],
|
||||||
[[/* This macro is provided for backward compatibility. */
|
[[/* This macro is provided for backward compatibility. */
|
||||||
#ifndef YY_LOCATION_PRINT
|
# ifndef YY_LOCATION_PRINT
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
#endif]])
|
# endif]])
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_yyloc_default
|
# b4_yyloc_default
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# D skeleton dispatching for Bison.
|
# D skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+70
-24
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# D language support for Bison
|
# D language support for Bison
|
||||||
|
|
||||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,11 +18,29 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
# b4_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(m4_expand([[$1]]), [
|
||||||
|
\(.\)], [
|
||||||
|
$3\1])$4])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_comment(TEXT, [PREFIX])
|
||||||
|
# --------------------------
|
||||||
|
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||||
|
m4_define([b4_comment],
|
||||||
|
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_sync_start(LINE, FILE)
|
||||||
|
# -------------------------
|
||||||
|
m4_define([b4_sync_start], [[#]line $1 $2])
|
||||||
|
|
||||||
|
|
||||||
# b4_list2(LIST1, LIST2)
|
# b4_list2(LIST1, LIST2)
|
||||||
@@ -82,12 +100,6 @@ m4_define([b4_location_type_if],
|
|||||||
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_locations_if(TRUE, FALSE)
|
|
||||||
# ----------------------------
|
|
||||||
m4_define([b4_locations_if],
|
|
||||||
[m4_if(b4_locations_flag, 1, [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_identification
|
# b4_identification
|
||||||
# -----------------
|
# -----------------
|
||||||
m4_define([b4_identification],
|
m4_define([b4_identification],
|
||||||
@@ -136,9 +148,9 @@ private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------- ##
|
||||||
## Assigning token numbers. ##
|
## Token kinds. ##
|
||||||
## ------------------------- ##
|
## ------------- ##
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
@@ -147,19 +159,53 @@ m4_define([b4_token_enum],
|
|||||||
[b4_token_format([ %s = %s,
|
[b4_token_format([ %s = %s,
|
||||||
], [$1])])
|
], [$1])])
|
||||||
|
|
||||||
# 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. */
|
[/* Token kinds. */
|
||||||
public enum YYTokenType {
|
public enum TokenKind {
|
||||||
|
]b4_symbol_kind([-2])[ = -2,
|
||||||
/** Token returned by the scanner to signal the end of its input. */
|
b4_symbol_foreach([b4_token_enum])dnl
|
||||||
EOF = 0,
|
|
||||||
b4_symbol_foreach([b4_token_enum])
|
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Symbol kinds. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_enum(SYMBOL-NUM)
|
||||||
|
# --------------------------
|
||||||
|
# Output the definition of this symbol as an enum.
|
||||||
|
m4_define([b4_symbol_enum],
|
||||||
|
[m4_format([ %-30s %s],
|
||||||
|
m4_format([[%s = %s,]],
|
||||||
|
b4_symbol([$1], [kind]),
|
||||||
|
[$1]),
|
||||||
|
[b4_symbol_tag_comment([$1])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_declare_symbol_enum
|
||||||
|
# ----------------------
|
||||||
|
# The definition of the symbol internal numbers as an enum.
|
||||||
|
# Defining YYEMPTY here is important: it forces the compiler
|
||||||
|
# to use a signed type, which matters for yytoken.
|
||||||
|
m4_define([b4_declare_symbol_enum],
|
||||||
|
[[ /* Symbol kinds. */
|
||||||
|
public enum SymbolKind
|
||||||
|
{
|
||||||
|
]b4_symbol_kind([-2])[ = -2, /* No symbol. */
|
||||||
|
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||||
|
[ };
|
||||||
|
]])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# b4-case(ID, CODE)
|
# b4-case(ID, CODE)
|
||||||
# -----------------
|
# -----------------
|
||||||
m4_define([b4_case], [ case $1:
|
m4_define([b4_case], [ case $1:
|
||||||
@@ -177,7 +223,7 @@ b4_percent_define_default([[stype]], [[YYSemanticType]])])
|
|||||||
# %name-prefix
|
# %name-prefix
|
||||||
m4_define_default([b4_prefix], [[YY]])
|
m4_define_default([b4_prefix], [[YY]])
|
||||||
|
|
||||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]YYParser])])
|
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])])
|
||||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||||
|
|
||||||
#b4_percent_define_default([[location_type]], [Location])])
|
#b4_percent_define_default([[location_type]], [Location])])
|
||||||
|
|||||||
+658
-525
File diff suppressed because it is too large
Load Diff
+83
-68
@@ -1,6 +1,6 @@
|
|||||||
# C++ GLR skeleton for Bison
|
# C++ GLR skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -66,30 +66,29 @@ m4_defn([b4_parse_param]))],
|
|||||||
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# b4_declare_symbol_enum
|
||||||
|
# ----------------------
|
||||||
|
m4_append([b4_declare_symbol_enum],
|
||||||
|
[[typedef symbol_kind_type yysymbol_kind_t;
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
# b4_yy_symbol_print_define
|
# b4_yy_symbol_print_define
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Bypass the default implementation to generate the "yy_symbol_print"
|
# Bypass the default implementation to generate the "yy_symbol_print"
|
||||||
# and "yy_symbol_value_print" functions.
|
# and "yy_symbol_value_print" functions.
|
||||||
m4_define([b4_yy_symbol_print_define],
|
m4_define([b4_yy_symbol_print_define],
|
||||||
[[
|
[[/*--------------------.
|
||||||
/*--------------------.
|
|
||||||
| Print this symbol. |
|
| Print this symbol. |
|
||||||
`--------------------*/
|
`--------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_symbol_print],
|
static void
|
||||||
[static void],
|
yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken,
|
||||||
[[FILE *], []],
|
const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep]b4_locations_if([[,
|
||||||
[[int yytype], [yytype]],
|
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
||||||
[[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep],
|
|
||||||
[yyvaluep]][]dnl
|
|
||||||
b4_locations_if([,
|
|
||||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
|
||||||
[yylocationp]]]),
|
|
||||||
b4_parse_param)[
|
|
||||||
{
|
{
|
||||||
]b4_parse_param_use[]dnl
|
]b4_parse_param_use[]dnl
|
||||||
[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[);
|
[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([, yylocationp])[);
|
||||||
}
|
}
|
||||||
]])[
|
]])[
|
||||||
|
|
||||||
@@ -100,46 +99,31 @@ m4_defn([b4_initial_action])]))])[
|
|||||||
|
|
||||||
# Hijack the post prologue to declare yyerror.
|
# Hijack the post prologue to declare yyerror.
|
||||||
]m4_append([b4_post_prologue],
|
]m4_append([b4_post_prologue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])dnl
|
||||||
]b4_function_declare([yyerror],
|
[static void
|
||||||
[static void],b4_locations_if([
|
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||||
[yylocationp]],])
|
])[const char* msg);]])[
|
||||||
b4_parse_param,
|
|
||||||
[[const char* msg], [msg]])])[
|
|
||||||
|
|
||||||
|
]b4_percent_define_flag_if([[global_tokens_and_yystype]], [],
|
||||||
#undef yynerrs
|
[m4_define([b4_pre_epilogue],
|
||||||
#undef yychar
|
[[/* The user is using the C++ token kind, not the C one. */
|
||||||
#undef yylval]b4_locations_if([
|
#undef ]b4_symbol(0, [id])
|
||||||
#undef yylloc])
|
])])[
|
||||||
|
|
||||||
m4_if(b4_prefix, [yy], [],
|
|
||||||
[[/* Substitute the variable and function names. */
|
|
||||||
#define yyparse ]b4_prefix[parse
|
|
||||||
#define yylex ]b4_prefix[lex
|
|
||||||
#define yyerror ]b4_prefix[error
|
|
||||||
#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
|
|
||||||
#define yylval ]b4_prefix[lval
|
|
||||||
#define yychar ]b4_prefix[char
|
|
||||||
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
|
||||||
#define yylloc ]b4_prefix[lloc]])]))
|
|
||||||
|
|
||||||
# Hijack the epilogue to define implementations (yyerror, parser member
|
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||||
# functions etc.).
|
# functions etc.).
|
||||||
m4_append([b4_epilogue],
|
]m4_append([b4_epilogue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])dnl
|
||||||
|
[
|
||||||
/*------------------.
|
/*------------------.
|
||||||
| Report an error. |
|
| Report an error. |
|
||||||
`------------------*/
|
`------------------*/
|
||||||
|
|
||||||
]b4_function_define([yyerror],
|
static void
|
||||||
[static void],b4_locations_if([
|
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||||
[yylocationp]],])
|
])[const char* msg)
|
||||||
b4_parse_param,
|
|
||||||
[[const char* msg], [msg]])[
|
|
||||||
{
|
{
|
||||||
]b4_parse_param_use[]dnl
|
]b4_parse_param_use[]dnl
|
||||||
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
||||||
@@ -181,9 +165,9 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
`--------------------*/
|
`--------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class[::yy_symbol_value_print_ (int yytype,
|
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||||
const location_type* yylocationp]])[)
|
const location_type* yylocationp]])[) const
|
||||||
{]b4_locations_if([[
|
{]b4_locations_if([[
|
||||||
YYUSE (yylocationp);]])[
|
YYUSE (yylocationp);]])[
|
||||||
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
||||||
@@ -195,14 +179,14 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class[::yy_symbol_print_ (int yytype,
|
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||||
const location_type* yylocationp]])[)
|
const location_type* yylocationp]])[) const
|
||||||
{
|
{
|
||||||
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||||
<< ' ' << yytname[yytype] << " ("]b4_locations_if([[
|
<< ' ' << yytname[yykind] << " ("]b4_locations_if([[
|
||||||
<< *yylocationp << ": "]])[;
|
<< *yylocationp << ": "]])[;
|
||||||
yy_symbol_value_print_ (yytype, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
||||||
*yycdebug_ << ')';
|
*yycdebug_ << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +218,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
]m4_popdef([b4_parse_param])dnl
|
]m4_popdef([b4_parse_param])dnl
|
||||||
b4_namespace_close
|
b4_namespace_close[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -257,6 +241,21 @@ b4_percent_code_get([[requires]])[
|
|||||||
]b4_attribute_define[
|
]b4_attribute_define[
|
||||||
]b4_null_define[
|
]b4_null_define[
|
||||||
|
|
||||||
|
// This skeleton is based on C, yet compiles it as C++.
|
||||||
|
// So expect warnings about C style casts.
|
||||||
|
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
|
||||||
|
# pragma clang diagnostic ignored "-Wold-style-cast"
|
||||||
|
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||||
|
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
||||||
|
// -pedantic reports as being a C++11 extension.
|
||||||
|
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
|
||||||
|
&& defined __clang__ && 4 <= __clang_major__
|
||||||
|
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Whether we are compiled with exception support.
|
// Whether we are compiled with exception support.
|
||||||
#ifndef YY_EXCEPTIONS
|
#ifndef YY_EXCEPTIONS
|
||||||
# if defined __GNUC__ && !defined __EXCEPTIONS
|
# if defined __GNUC__ && !defined __EXCEPTIONS
|
||||||
@@ -313,21 +312,21 @@ b4_percent_code_get([[requires]])[
|
|||||||
# if ]b4_api_PREFIX[DEBUG
|
# 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 yykind The symbol kind.
|
||||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||||
/// \param yylocationp Its location.]])[
|
/// \param yylocationp Its location.]])[
|
||||||
virtual void yy_symbol_value_print_ (int yytype,
|
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||||
const location_type* yylocationp]])[);
|
const location_type* yylocationp]])[) const;
|
||||||
/// \brief Report a symbol on the debug stream.
|
/// \brief Report a symbol on the debug stream.
|
||||||
/// \param yytype The token type.
|
/// \param yykind The symbol kind.
|
||||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||||
/// \param yylocationp Its location.]])[
|
/// \param yylocationp Its location.]])[
|
||||||
virtual void yy_symbol_print_ (int yytype,
|
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||||
const location_type* yylocationp]])[);
|
const location_type* yylocationp]])[) const;
|
||||||
private:
|
private:
|
||||||
// Debugging.
|
/// Debug stream.
|
||||||
std::ostream* yycdebug_;
|
std::ostream* yycdebug_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -336,8 +335,18 @@ b4_percent_code_get([[requires]])[
|
|||||||
|
|
||||||
]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_token_defines
|
||||||
[
|
])[
|
||||||
|
]b4_namespace_close[
|
||||||
|
|
||||||
|
]dnl Map the name used in c.m4 to the one used in c++.m4.
|
||||||
|
[#undef ]b4_symbol(-2, [id])[
|
||||||
|
#define ]b4_symbol(-2, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[
|
||||||
|
#undef ]b4_symbol(0, [id])[
|
||||||
|
#define ]b4_symbol(0, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[
|
||||||
|
#undef ]b4_symbol(1, [id])[
|
||||||
|
#define ]b4_symbol(1, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(1, [id])[
|
||||||
|
|
||||||
#ifndef ]b4_api_PREFIX[STYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
||||||
#endif
|
#endif
|
||||||
@@ -345,21 +354,27 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
|||||||
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_namespace_close[
|
]m4_define([b4_declare_symbol_enum],
|
||||||
|
[[typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
|
||||||
|
#define ]b4_symbol_prefix[YYEMPTY ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
|
||||||
|
#define ]b4_symbol_prefix[YYerror ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYerror
|
||||||
|
#define ]b4_symbol_prefix[YYEOF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
|
||||||
|
#define ]b4_symbol_prefix[YYUNDEF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
|
||||||
|
]])[
|
||||||
]b4_percent_code_get([[provides]])[
|
]b4_percent_code_get([[provides]])[
|
||||||
]m4_popdef([b4_parse_param])dnl
|
]m4_popdef([b4_parse_param])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[b4_output_begin([b4_spec_defines_file])
|
[b4_output_begin([b4_spec_header_file])
|
||||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||||
[2002-2015, 2018-2019])[
|
[2002-2015, 2018-2020])[
|
||||||
// C++ GLR parser skeleton written by Akim Demaille.
|
// C++ GLR parser skeleton written by Akim Demaille.
|
||||||
|
|
||||||
]b4_disclaimer[
|
]b4_disclaimer[
|
||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_header_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]b4_cpp_guard_close([b4_spec_header_file])[
|
||||||
]b4_output_end])
|
]b4_output_end])
|
||||||
|
|
||||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Java skeleton dispatching for Bison.
|
# Java skeleton dispatching for Bison.
|
||||||
|
|
||||||
# Copyright (C) 2007, 2009-2015, 2018-2019 Free Software Foundation,
|
# Copyright (C) 2007, 2009-2015, 2018-2020 Free Software Foundation,
|
||||||
# Inc.
|
# 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
|
||||||
|
|||||||
+159
-17
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Java language support for Bison
|
# Java language support for Bison
|
||||||
|
|
||||||
# Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -106,10 +106,13 @@ m4_define([b4_null], [null])
|
|||||||
|
|
||||||
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
|
# We use intermediate functions (e.g., yypact_init) to work around the
|
||||||
|
# 64KB limit for JVM methods. See
|
||||||
|
# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.
|
||||||
m4_define([b4_typed_parser_table_define],
|
m4_define([b4_typed_parser_table_define],
|
||||||
[m4_ifval([$4], [b4_comment([$4])
|
[m4_ifval([$4], [b4_comment([$4])
|
||||||
])dnl
|
])dnl
|
||||||
[private static final ]$1[ yy$2_[] = yy$2_init();
|
[private static final ]$1[[] yy$2_ = yy$2_init();
|
||||||
private static final ]$1[[] yy$2_init()
|
private static final ]$1[[] yy$2_init()
|
||||||
{
|
{
|
||||||
return new ]$1[[]
|
return new ]$1[[]
|
||||||
@@ -125,40 +128,151 @@ m4_define([b4_integral_parser_table_define],
|
|||||||
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------- ##
|
||||||
## Assigning token numbers. ##
|
## Token kinds. ##
|
||||||
## ------------------------- ##
|
## ------------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NUM)
|
# 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],
|
||||||
[b4_token_format([ /** Token number, to be returned by the scanner. */
|
[b4_token_visible_if([$1],
|
||||||
static final int %s = %s;
|
[m4_format([[ /** Token %s, to be returned by the scanner. */
|
||||||
], [$1])])
|
static final int %s = %s%s;
|
||||||
|
]],
|
||||||
|
b4_symbol([$1], [tag]),
|
||||||
|
b4_symbol([$1], [id]),
|
||||||
|
b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])))])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums
|
# 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],
|
||||||
[b4_any_token_visible_if([/* Tokens. */
|
[b4_any_token_visible_if([ /* Token kinds. */
|
||||||
b4_symbol_foreach([b4_token_enum])])])
|
b4_symbol_foreach([b4_token_enum])])])
|
||||||
|
|
||||||
# b4-case(ID, CODE)
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Symbol kinds. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
# b4_symbol_enum(SYMBOL-NUM)
|
||||||
|
# --------------------------
|
||||||
|
# Output the definition of this symbol as an enum.
|
||||||
|
m4_define([b4_symbol_enum],
|
||||||
|
[m4_format([ %-30s %s],
|
||||||
|
m4_format([[%s(%s)%s]],
|
||||||
|
b4_symbol([$1], [kind]),
|
||||||
|
[$1],
|
||||||
|
m4_if([$1], b4_last_symbol, [[;]], [[,]])),
|
||||||
|
[b4_symbol_tag_comment([$1])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_declare_symbol_enum
|
||||||
|
# ----------------------
|
||||||
|
# The definition of the symbol internal numbers as an enum.
|
||||||
|
m4_define([b4_declare_symbol_enum],
|
||||||
|
[[ public enum SymbolKind
|
||||||
|
{
|
||||||
|
]b4_symbol_foreach([b4_symbol_enum])[
|
||||||
|
|
||||||
|
private final int yycode_;
|
||||||
|
|
||||||
|
SymbolKind (int n) {
|
||||||
|
this.yycode_ = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final SymbolKind[] values_ = {
|
||||||
|
]m4_map_args_sep([b4_symbol_kind(], [)], [,
|
||||||
|
], b4_symbol_numbers)[
|
||||||
|
};
|
||||||
|
|
||||||
|
static final SymbolKind get(int code) {
|
||||||
|
return values_[code];
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getCode() {
|
||||||
|
return this.yycode_;
|
||||||
|
}
|
||||||
|
|
||||||
|
]b4_parse_error_bmatch(
|
||||||
|
[simple\|verbose],
|
||||||
|
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
||||||
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||||
|
that double-quoting is unnecessary unless the string contains an
|
||||||
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||||
|
YYSTR is taken from yytname. */
|
||||||
|
private static String yytnamerr_(String yystr)
|
||||||
|
{
|
||||||
|
if (yystr.charAt (0) == '"')
|
||||||
|
{
|
||||||
|
StringBuffer yyr = new StringBuffer();
|
||||||
|
strip_quotes: for (int i = 1; i < yystr.length(); i++)
|
||||||
|
switch (yystr.charAt(i))
|
||||||
|
{
|
||||||
|
case '\'':
|
||||||
|
case ',':
|
||||||
|
break strip_quotes;
|
||||||
|
|
||||||
|
case '\\':
|
||||||
|
if (yystr.charAt(++i) != '\\')
|
||||||
|
break strip_quotes;
|
||||||
|
/* Fall through. */
|
||||||
|
default:
|
||||||
|
yyr.append(yystr.charAt(i));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '"':
|
||||||
|
return yyr.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return yystr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
|
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||||
|
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||||
|
|
||||||
|
/* The user-facing name of this symbol. */
|
||||||
|
public final String getName() {
|
||||||
|
return yytnamerr_(yytname_[yycode_]);
|
||||||
|
}
|
||||||
|
]],
|
||||||
|
[custom\|detailed],
|
||||||
|
[[ /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
|
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||||
|
]b4_typed_parser_table_define([String], [names], [b4_symbol_names])[
|
||||||
|
|
||||||
|
/* The user-facing name of this symbol. */
|
||||||
|
public final String getName() {
|
||||||
|
return yynames_[yycode_];
|
||||||
|
}]])[
|
||||||
|
};
|
||||||
|
]])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_case(ID, CODE)
|
||||||
# -----------------
|
# -----------------
|
||||||
# We need to fool Java's stupid unreachable code detection.
|
# We need to fool Java's stupid unreachable code detection.
|
||||||
m4_define([b4_case], [ case $1:
|
m4_define([b4_case],
|
||||||
|
[ case $1:
|
||||||
if (yyn == $1)
|
if (yyn == $1)
|
||||||
$2;
|
$2;
|
||||||
break;
|
break;
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_predicate_case(LABEL, CONDITIONS)
|
# b4_predicate_case(LABEL, CONDITIONS)
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
m4_define([b4_predicate_case], [ case $1:
|
m4_define([b4_predicate_case],
|
||||||
|
[ case $1:
|
||||||
if (! ($2)) YYERROR;
|
if (! ($2)) YYERROR;
|
||||||
break;
|
break;
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## -------- ##
|
## -------- ##
|
||||||
@@ -183,9 +297,21 @@ b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
|||||||
|
|
||||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
||||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
b4_percent_define_default([[api.value.type]], [[Object]])
|
||||||
|
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||||
|
|
||||||
# %name-prefix
|
# b4_api_prefix, b4_api_PREFIX
|
||||||
m4_define_default([b4_prefix], [[YY]])
|
# ----------------------------
|
||||||
|
# Corresponds to %define api.prefix
|
||||||
|
b4_percent_define_default([[api.prefix]], [[YY]])
|
||||||
|
m4_define([b4_api_prefix],
|
||||||
|
[b4_percent_define_get([[api.prefix]])])
|
||||||
|
m4_define([b4_api_PREFIX],
|
||||||
|
[m4_toupper(b4_api_prefix)])
|
||||||
|
|
||||||
|
# b4_prefix
|
||||||
|
# ---------
|
||||||
|
# If the %name-prefix is not given, it is api.prefix.
|
||||||
|
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||||
|
|
||||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])
|
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])
|
||||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||||
@@ -211,6 +337,22 @@ m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
|
|||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_translate(STRING)
|
||||||
|
# ---------------------------
|
||||||
|
# Used by "bison" in the array of symbol names to mark those that
|
||||||
|
# require translation.
|
||||||
|
m4_define([b4_symbol_translate],
|
||||||
|
[[i18n($1)]])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_trans(STRING)
|
||||||
|
# ----------------
|
||||||
|
# Translate a string if i18n is enabled. Avoid collision with b4_translate.
|
||||||
|
m4_define([b4_trans],
|
||||||
|
[b4_has_translations_if([i18n($1)], [$1])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
# See README.
|
# See README.
|
||||||
@@ -350,4 +492,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])])
|
||||||
|
|||||||
+600
-225
File diff suppressed because it is too large
Load Diff
+330
-306
@@ -1,6 +1,6 @@
|
|||||||
# Java skeleton for Bison -*- autoconf -*-
|
# D skeleton for Bison -*- autoconf -*-
|
||||||
|
|
||||||
# Copyright (C) 2007-2011, 2019 Free Software Foundation, Inc.
|
# Copyright (C) 2007-2012, 2019-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,12 +18,11 @@
|
|||||||
m4_include(b4_skeletonsdir/[d.m4])
|
m4_include(b4_skeletonsdir/[d.m4])
|
||||||
|
|
||||||
|
|
||||||
m4_divert_push(0)dnl
|
b4_output_begin([b4_parser_file_name])
|
||||||
@output(b4_parser_file_name@)@
|
|
||||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
|
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
|
||||||
[2007-2012, 2019])
|
[2007-2012, 2019-2020])[
|
||||||
|
]b4_disclaimer[
|
||||||
b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
]b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
||||||
])[
|
])[
|
||||||
version(D_Version2) {
|
version(D_Version2) {
|
||||||
} else {
|
} else {
|
||||||
@@ -47,8 +46,8 @@ import std.format;
|
|||||||
* parser <tt>]b4_parser_class[</tt>.
|
* parser <tt>]b4_parser_class[</tt>.
|
||||||
*/
|
*/
|
||||||
public interface Lexer
|
public interface Lexer
|
||||||
{
|
{]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. */
|
||||||
@@property ]b4_position_type[ startPos ();
|
@@property ]b4_position_type[ startPos ();
|
||||||
@@ -56,8 +55,9 @@ public interface Lexer
|
|||||||
/**
|
/**
|
||||||
* Method to retrieve the ending position of the last scanned token.
|
* Method to retrieve the ending position of the last scanned token.
|
||||||
* @@return the first position beyond the last scanned token. */
|
* @@return the first position beyond the last scanned token. */
|
||||||
@@property ]b4_position_type[ endPos ();]])[
|
@@property ]b4_position_type[ endPos ();
|
||||||
|
|
||||||
|
]])[
|
||||||
/**
|
/**
|
||||||
* Method to retrieve the semantic value of the last scanned token.
|
* Method to retrieve the semantic value of the last scanned token.
|
||||||
* @@return the semantic value of the last scanned token. */
|
* @@return the semantic value of the last scanned token. */
|
||||||
@@ -68,80 +68,26 @@ public interface Lexer
|
|||||||
* to the next token and prepares to return the semantic value
|
* to the next token and prepares to return the semantic value
|
||||||
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
||||||
* @@return the token identifier corresponding to the next token. */
|
* @@return the token identifier corresponding to the next token. */
|
||||||
YYTokenType yylex ();
|
int yylex ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for error reporting. Emits an error
|
* Entry point for error reporting. Emits an error
|
||||||
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
|
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
|
||||||
*
|
*]b4_locations_if([[
|
||||||
* ]b4_locations_if([[@@param loc The location of the element to which the
|
* @@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 s 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 s);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final struct YYStackElement{
|
]b4_locations_if([b4_position_type_if([[
|
||||||
int state;
|
|
||||||
]b4_yystype[ value;
|
|
||||||
]b4_locations_if(b4_location_type[[] location;])[
|
|
||||||
}
|
|
||||||
|
|
||||||
private final struct YYStack {
|
|
||||||
private YYStackElement[] stack = [];
|
|
||||||
|
|
||||||
public final @@property ulong height()
|
|
||||||
{
|
|
||||||
return stack.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void push (int state, ]b4_yystype[ value]dnl
|
|
||||||
b4_locations_if([, ref ]b4_location_type[ loc])[)
|
|
||||||
{
|
|
||||||
stack ~= YYStackElement(state, value]b4_locations_if([, loc])[);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void pop ()
|
|
||||||
{
|
|
||||||
pop (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void pop (int num)
|
|
||||||
{
|
|
||||||
stack.length -= num;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int stateAt (int i)
|
|
||||||
{
|
|
||||||
return stack[$-i-1].state;
|
|
||||||
}
|
|
||||||
|
|
||||||
]b4_locations_if([[public final ref ]b4_location_type[ locationAt (int i)
|
|
||||||
{
|
|
||||||
return stack[$-i-1].location;
|
|
||||||
}
|
|
||||||
|
|
||||||
]])[public final ref ]b4_yystype[ valueAt (int i)
|
|
||||||
{
|
|
||||||
return stack[$-i-1].value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print the state stack on the debug stream.
|
|
||||||
public final void print (File stream)
|
|
||||||
{
|
|
||||||
stream.write ("Stack now");
|
|
||||||
for (int i = 0; i < stack.length; i++)
|
|
||||||
stream.write (" %d", stack[i].state);
|
|
||||||
stream.writeln ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]b4_locations_if(b4_position_type_if([[[
|
|
||||||
static assert(__traits(compiles,
|
static assert(__traits(compiles,
|
||||||
(new ]b4_position_type[[1])[0]=(new ]b4_position_type[[1])[0]),
|
(new ]b4_position_type[[1])[0]=(new ]b4_position_type[[1])[0]),
|
||||||
"struct/class ]b4_position_type[ must be default-constructible "
|
"struct/class ]b4_position_type[ must be default-constructible "
|
||||||
"and assignable");
|
"and assignable");
|
||||||
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_position_type[).toString()),
|
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_position_type[).toString()),
|
||||||
"error: struct/class ]b4_position_type[ must have toString method");
|
"error: struct/class ]b4_position_type[ must have toString method");
|
||||||
]]], [[
|
]], [[
|
||||||
/**
|
/**
|
||||||
* A struct denoting a point in the input.*/
|
* A struct denoting a point in the input.*/
|
||||||
public struct ]b4_position_type[ {
|
public struct ]b4_position_type[ {
|
||||||
@@ -151,15 +97,18 @@ public struct ]b4_position_type[ {
|
|||||||
/** The line number within an input file. */
|
/** The line number within an input file. */
|
||||||
public int line = 1;
|
public int line = 1;
|
||||||
/** The name of the input file. */
|
/** The name of the input file. */
|
||||||
public string filename = "(unspecified file)";
|
public string filename = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a string representation of the position. */
|
* A string representation of the position. */
|
||||||
public string toString() const {
|
public string toString() const {
|
||||||
return format("%s:%d.%d", filename, line, column);
|
if (filename)
|
||||||
|
return format("%s:%d.%d", filename, line, column);
|
||||||
|
else
|
||||||
|
return format("%d.%d", line, column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])b4_location_type_if([[[
|
]])b4_location_type_if([[
|
||||||
static assert(__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0]))) &&
|
static assert(__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0]))) &&
|
||||||
__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0], (new ]b4_position_type[[1])[0]))),
|
__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0], (new ]b4_position_type[[1])[0]))),
|
||||||
"error: struct/class ]b4_location_type[ must have "
|
"error: struct/class ]b4_location_type[ must have "
|
||||||
@@ -173,7 +122,7 @@ static assert(__traits(compiles, (new ]b4_location_type[[1])[0].begin=(new ]b4_l
|
|||||||
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_location_type[[1])[0].toString()),
|
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_location_type[[1])[0].toString()),
|
||||||
"error: struct/class ]b4_location_type[ must have toString method.");
|
"error: struct/class ]b4_location_type[ must have toString method.");
|
||||||
|
|
||||||
private immutable bool yy_location_is_class = !__traits(compiles, *(new ]b4_location_type[((new ]b4_position_type[[1])[0])));]]], [[
|
private immutable bool yy_location_is_class = !__traits(compiles, *(new ]b4_location_type[((new ]b4_position_type[[1])[0])));]], [[
|
||||||
/**
|
/**
|
||||||
* A class defining a pair of positions. Positions, defined by the
|
* A class defining a pair of positions. Positions, defined by the
|
||||||
* <code>]b4_position_type[</code> class, denote a point in the input.
|
* <code>]b4_position_type[</code> class, denote a point in the input.
|
||||||
@@ -195,6 +144,9 @@ public class ]b4_location_type[
|
|||||||
this.begin = this.end = loc;
|
this.begin = this.end = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public this () {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a <code>]b4_location_type[</code> from the endpoints of the range.
|
* Create a <code>]b4_location_type[</code> from the endpoints of the range.
|
||||||
* @@param begin The first position included in the range.
|
* @@param begin The first position included in the range.
|
||||||
@@ -206,34 +158,38 @@ public class ]b4_location_type[
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a representation of the location. For this to be correct,
|
* A representation of the location. For this to be correct,
|
||||||
* <code>]b4_position_type[</code> should override the <code>toString</code>
|
* <code>]b4_position_type[</code> should override the <code>toString</code>
|
||||||
* method. */
|
* method. */
|
||||||
public const string toString () const {
|
public override string toString () const {
|
||||||
if (begin==end)
|
auto end_col = 0 < end.column ? end.column - 1 : 0;
|
||||||
return begin.toString ();
|
auto res = begin.toString ();
|
||||||
else
|
if (end.filename && begin.filename != end.filename)
|
||||||
return begin.toString () ~ "-" ~ end.toString ();
|
res ~= "-" ~ format("%s:%d.%d", end.filename, end.line, end_col);
|
||||||
|
else if (begin.line < end.line)
|
||||||
|
res ~= "-" ~ format("%d.%d", end.line, end_col);
|
||||||
|
else if (begin.column < end_col)
|
||||||
|
res ~= "-" ~ format("%d", end_col);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private immutable bool yy_location_is_class = true;
|
private immutable bool yy_location_is_class = true;
|
||||||
|
|
||||||
]]))m4_ifdef([b4_user_union_members], [private union YYSemanticType
|
]])])m4_ifdef([b4_user_union_members], [private union YYSemanticType
|
||||||
{
|
{
|
||||||
b4_user_union_members
|
b4_user_union_members
|
||||||
};],
|
};],
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
[[private alias int YYSemanticType;]])])[
|
[[private alias int YYSemanticType;]])])[
|
||||||
]b4_token_enums(b4_tokens)[
|
]b4_token_enums[
|
||||||
]b4_parser_class_declaration[
|
]b4_parser_class_declaration[
|
||||||
{
|
{
|
||||||
]b4_identification[
|
]b4_identification[
|
||||||
|
|
||||||
/** True if verbose error messages are enabled. */
|
]b4_declare_symbol_enum[
|
||||||
public bool errorVerbose = ]b4_flag_value([error_verbose]);
|
|
||||||
|
|
||||||
b4_locations_if([[
|
]b4_locations_if([[
|
||||||
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
|
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
|
||||||
{
|
{
|
||||||
static if (yy_location_is_class) {
|
static if (yy_location_is_class) {
|
||||||
@@ -249,40 +205,38 @@ b4_user_union_members
|
|||||||
}
|
}
|
||||||
}]])[
|
}]])[
|
||||||
|
|
||||||
]b4_lexer_if([[private class YYLexer implements Lexer {
|
]b4_lexer_if([[ private class YYLexer implements Lexer {
|
||||||
]b4_percent_code_get([[lexer]])[
|
]b4_percent_code_get([[lexer]])[
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
]])[/** The object doing lexical analysis for us. */
|
/** The object doing lexical analysis for us. */
|
||||||
private Lexer yylexer;
|
private Lexer yylexer;
|
||||||
]
|
|
||||||
b4_parse_param_vars
|
|
||||||
|
|
||||||
b4_lexer_if([[
|
]b4_parse_param_vars[
|
||||||
|
|
||||||
|
]b4_lexer_if([[
|
||||||
/**
|
/**
|
||||||
* Instantiates the Bison-generated parser.
|
* Instantiate the Bison-generated parser.
|
||||||
*/
|
*/
|
||||||
public this] (b4_parse_param_decl([b4_lex_param_decl])[) {
|
public this] (b4_parse_param_decl([b4_lex_param_decl])[) {
|
||||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
this (new YYLexer(]b4_lex_param_call[));
|
||||||
this.yyDebugStream = stderr;
|
|
||||||
]b4_parse_param_cons[
|
|
||||||
}
|
}
|
||||||
]])
|
]])[
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates the Bison-generated parser.
|
* Instantiate 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]]) [this (]b4_parse_param_decl([[Lexer yylexer]])[) {
|
]b4_lexer_if([[protected]], [[public]]) [this (]b4_parse_param_decl([[Lexer yylexer]])[) {
|
||||||
this.yylexer = yylexer;
|
this.yylexer = yylexer;]b4_parse_trace_if([[
|
||||||
this.yyDebugStream = stderr;
|
this.yyDebugStream = stderr;]])[
|
||||||
]b4_parse_param_cons[
|
]b4_parse_param_cons[
|
||||||
}
|
}
|
||||||
|
]b4_parse_trace_if([[
|
||||||
private File yyDebugStream;
|
private File yyDebugStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the <tt>File</tt> on which the debugging output is
|
* The <tt>File</tt> on which the debugging output is
|
||||||
* printed.
|
* printed.
|
||||||
*/
|
*/
|
||||||
public File getDebugStream () { return yyDebugStream; }
|
public File getDebugStream () { return yyDebugStream; }
|
||||||
@@ -308,16 +262,22 @@ b4_lexer_if([[
|
|||||||
*/
|
*/
|
||||||
public final void setDebugLevel(int level) { yydebug = level; }
|
public final void setDebugLevel(int level) { yydebug = level; }
|
||||||
|
|
||||||
|
protected final void yycdebug (string s) {
|
||||||
|
if (0 < yydebug)
|
||||||
|
yyDebugStream.write (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void yycdebugln (string s) {
|
||||||
|
if (0 < yydebug)
|
||||||
|
yyDebugStream.writeln (s);
|
||||||
|
}
|
||||||
|
]])[
|
||||||
private final int yylex () {
|
private final int yylex () {
|
||||||
return yylexer.yylex ();
|
return yylexer.yylex ();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void yyerror (]b4_locations_if(ref [b4_location_type[ loc, ]])[string s) {
|
protected final void yyerror (]b4_locations_if(ref [b4_location_type[ loc, ]])[string s) {
|
||||||
yylexer.yyerror (]b4_locations_if([loc, ])[s);
|
yylexer.yyerror (]b4_locations_if([loc, ])[s);
|
||||||
}]
|
|
||||||
|
|
||||||
[protected final void yycdebug (string s) {
|
|
||||||
if (yydebug > 0)
|
|
||||||
yyDebugStream.writeln (s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -344,11 +304,11 @@ b4_lexer_if([[
|
|||||||
private static immutable int YYERRLAB1 = 7;
|
private static immutable int YYERRLAB1 = 7;
|
||||||
private static immutable int YYRETURN = 8;
|
private static immutable int YYRETURN = 8;
|
||||||
]b4_locations_if([
|
]b4_locations_if([
|
||||||
private static immutable YYSemanticType yy_semantic_null = cast(YYSemanticType)null;])[
|
private static immutable YYSemanticType yy_semantic_null;])[
|
||||||
private int yyerrstatus_ = 0;
|
private int yyerrstatus_ = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether error recovery is being done. In this state, the parser
|
* Whether error recovery is being done. In this state, the parser
|
||||||
* reads token until it reaches a known state, and then restarts normal
|
* reads token until it reaches a known state, and then restarts normal
|
||||||
* operation. */
|
* operation. */
|
||||||
public final bool recovering ()
|
public final bool recovering ()
|
||||||
@@ -358,8 +318,8 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
private int yyaction (int yyn, ref YYStack yystack, int yylen)
|
private int yyaction (int yyn, ref YYStack yystack, int yylen)
|
||||||
{
|
{
|
||||||
]b4_yystype[ yyval;
|
]b4_yystype[ yyval;]b4_locations_if([[
|
||||||
]b4_locations_if([b4_location_type[ yyloc = yylloc_from_stack (yystack, yylen);]])[
|
]b4_location_type[ yyloc = yylloc_from_stack (yystack, yylen);]])[
|
||||||
|
|
||||||
/* If YYLEN is nonzero, implement the default value of the action:
|
/* If YYLEN is nonzero, implement the default value of the action:
|
||||||
`$$ = $1'. Otherwise, use the top of the stack.
|
`$$ = $1'. Otherwise, use the top of the stack.
|
||||||
@@ -372,7 +332,8 @@ b4_lexer_if([[
|
|||||||
else
|
else
|
||||||
yyval = yystack.valueAt (0);
|
yyval = yystack.valueAt (0);
|
||||||
|
|
||||||
yy_reduce_print (yyn, yystack);
|
]b4_parse_trace_if([[
|
||||||
|
yy_reduce_print (yyn, yystack);]])[
|
||||||
|
|
||||||
switch (yyn)
|
switch (yyn)
|
||||||
{
|
{
|
||||||
@@ -380,7 +341,9 @@ b4_lexer_if([[
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
|
]b4_parse_trace_if([[
|
||||||
|
import std.conv : to;
|
||||||
|
yy_symbol_print ("-> $$ =", to!SymbolKind (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||||
|
|
||||||
yystack.pop (yylen);
|
yystack.pop (yylen);
|
||||||
yylen = 0;
|
yylen = 0;
|
||||||
@@ -408,7 +371,8 @@ b4_lexer_if([[
|
|||||||
if (yystr[0] == '"')
|
if (yystr[0] == '"')
|
||||||
{
|
{
|
||||||
string yyr;
|
string yyr;
|
||||||
strip_quotes: for (int i = 1; i < yystr.length; i++)
|
strip_quotes:
|
||||||
|
for (int i = 1; i < yystr.length; i++)
|
||||||
switch (yystr[i])
|
switch (yystr[i])
|
||||||
{
|
{
|
||||||
case '\'':
|
case '\'':
|
||||||
@@ -427,33 +391,34 @@ b4_lexer_if([[
|
|||||||
return yyr;
|
return yyr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (yystr=="$end")
|
else if (yystr == "$end")
|
||||||
return "end of input";
|
return "end of input";
|
||||||
|
|
||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
|
]b4_parse_trace_if([[
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
private final void yy_symbol_print (string s, int yytype,
|
private final void yy_symbol_print (string s, SymbolKind yykind,
|
||||||
ref ]b4_yystype[ yyvaluep]dnl
|
ref ]b4_yystype[ yyvaluep]dnl
|
||||||
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||||
{
|
{
|
||||||
if (yydebug > 0) {
|
if (0 < yydebug)
|
||||||
string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
|
{
|
||||||
~ yytname_[yytype] ~ " ("]b4_locations_if([
|
string message = s ~ (yykind < yyntokens_ ? " token " : " nterm ")
|
||||||
|
~ yytname_[yykind] ~ " ("]b4_locations_if([
|
||||||
~ yylocationp.toString() ~ ": "])[;
|
~ yylocationp.toString() ~ ": "])[;
|
||||||
static if (__traits(compiles, message~=yyvaluep.toString ()))
|
static if (__traits(compiles, message ~= yyvaluep.toString ()))
|
||||||
message ~= yyvaluep.toString ();
|
message ~= yyvaluep.toString ();
|
||||||
else
|
else
|
||||||
message ~= format ("%s", &yyvaluep);
|
message ~= format ("%s", &yyvaluep);
|
||||||
message ~= ")";
|
message ~= ")";
|
||||||
yycdebug (message);
|
yycdebugln (message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
/**
|
/**
|
||||||
* Parse input from the scanner that was specified at object construction
|
* Parse input from the scanner that was specified at object construction
|
||||||
* time. Return whether the end of the input was reached successfully.
|
* time. Return whether the end of the input was reached successfully.
|
||||||
@@ -464,8 +429,8 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
|||||||
public bool parse ()
|
public bool parse ()
|
||||||
{
|
{
|
||||||
/// Lookahead and lookahead in internal form.
|
/// Lookahead and lookahead in internal form.
|
||||||
int yychar = yyempty_;
|
int yychar = TokenKind.YYEMPTY;
|
||||||
int yytoken = 0;
|
SymbolKind yytoken = SymbolKind.]b4_symbol(-2, kind)[;
|
||||||
|
|
||||||
/* State. */
|
/* State. */
|
||||||
int yyn = 0;
|
int yyn = 0;
|
||||||
@@ -475,22 +440,22 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
|||||||
YYStack yystack;
|
YYStack yystack;
|
||||||
|
|
||||||
/* Error handling. */
|
/* Error handling. */
|
||||||
int yynerrs_ = 0;
|
int yynerrs_ = 0;]b4_locations_if([[
|
||||||
]b4_locations_if([/// The location where the error started.
|
/// The location where the error started.
|
||||||
]b4_location_type[ yyerrloc = null;
|
]b4_location_type[ yyerrloc = null;
|
||||||
|
|
||||||
/// ]b4_location_type[ of the lookahead.
|
/// ]b4_location_type[ of the lookahead.
|
||||||
]b4_location_type[ yylloc;
|
]b4_location_type[ yylloc;
|
||||||
|
|
||||||
/// @@$.
|
/// @@$.
|
||||||
]b4_location_type[ yyloc;])[
|
]b4_location_type[ yyloc;]])[
|
||||||
|
|
||||||
/// Semantic value of the lookahead.
|
/// Semantic value of the lookahead.
|
||||||
]b4_yystype[ yylval;
|
]b4_yystype[ yylval;
|
||||||
|
|
||||||
int yyresult;
|
bool yyresult;]b4_parse_trace_if([[
|
||||||
|
|
||||||
yycdebug ("Starting parse\n");
|
yycdebugln ("Starting parse");]])[
|
||||||
yyerrstatus_ = 0;
|
yyerrstatus_ = 0;
|
||||||
|
|
||||||
]m4_ifdef([b4_initial_action], [
|
]m4_ifdef([b4_initial_action], [
|
||||||
@@ -510,10 +475,10 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
{
|
{
|
||||||
/* New state. Unlike in the C/C++ skeletons, the state is already
|
/* New state. Unlike in the C/C++ skeletons, the state is already
|
||||||
pushed when we come here. */
|
pushed when we come here. */
|
||||||
case YYNEWSTATE:
|
case YYNEWSTATE:]b4_parse_trace_if([[
|
||||||
yycdebug (format("Entering state %d\n", yystate));
|
yycdebugln (format("Entering state %d", yystate));
|
||||||
if (yydebug > 0)
|
if (0 < yydebug)
|
||||||
yystack.print (yyDebugStream);
|
yystack.print (yyDebugStream);]])[
|
||||||
|
|
||||||
/* Accept? */
|
/* Accept? */
|
||||||
if (yystate == yyfinal_)
|
if (yystate == yyfinal_)
|
||||||
@@ -528,11 +493,10 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read a lookahead token. */
|
/* Read a lookahead token. */
|
||||||
if (yychar == yyempty_)
|
if (yychar == TokenKind.YYEMPTY)
|
||||||
{
|
{]b4_parse_trace_if([[
|
||||||
yycdebug ("Reading a token: ");
|
yycdebugln ("Reading a token");]])[
|
||||||
yychar = yylex ();]
|
yychar = yylex ();]b4_locations_if([[
|
||||||
b4_locations_if([[
|
|
||||||
static if (yy_location_is_class) {
|
static if (yy_location_is_class) {
|
||||||
yylloc = new ]b4_location_type[(yylexer.startPos, yylexer.endPos);
|
yylloc = new ]b4_location_type[(yylexer.startPos, yylexer.endPos);
|
||||||
} else {
|
} else {
|
||||||
@@ -542,53 +506,57 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert token to internal form. */
|
/* Convert token to internal form. */
|
||||||
if (yychar <= YYTokenType.EOF)
|
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
||||||
|
yy_symbol_print ("Next token is", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||||
|
|
||||||
|
if (yytoken == SymbolKind.]b4_symbol(1, kind)[)
|
||||||
{
|
{
|
||||||
yychar = yytoken = YYTokenType.EOF;
|
// The scanner already issued an error message, process directly
|
||||||
yycdebug ("Now at end of input.\n");
|
// to error recovery. But do not keep the error token as
|
||||||
|
// lookahead, it is too special and may lead us to an endless
|
||||||
|
// loop in error recovery. */
|
||||||
|
yychar = TokenKind.YYUNDEF;
|
||||||
|
yytoken = SymbolKind.]b4_symbol_prefix[YYUNDEF;]b4_locations_if([[
|
||||||
|
yyerrloc = yylloc;]])[
|
||||||
|
label = YYERRLAB1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yytoken = yytranslate_ (yychar);
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||||
yy_symbol_print ("Next token is",
|
detect an error, take that action. */
|
||||||
yytoken, yylval]b4_locations_if([, yylloc])[);
|
yyn += yytoken;
|
||||||
}
|
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
||||||
|
label = YYDEFAULT;
|
||||||
|
|
||||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
/* <= 0 means reduce or error. */
|
||||||
detect an error, take that action. */
|
else if ((yyn = yytable_[yyn]) <= 0)
|
||||||
yyn += yytoken;
|
{
|
||||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
if (yy_table_value_is_error_ (yyn))
|
||||||
label = YYDEFAULT;
|
label = YYERRLAB;
|
||||||
|
else
|
||||||
/* <= 0 means reduce or error. */
|
{
|
||||||
else if ((yyn = yytable_[yyn]) <= 0)
|
yyn = -yyn;
|
||||||
{
|
label = YYREDUCE;
|
||||||
if (yy_table_value_is_error_ (yyn))
|
}
|
||||||
label = YYERRLAB;
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yyn = -yyn;
|
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
||||||
label = YYREDUCE;
|
yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
||||||
|
|
||||||
|
/* Discard the token being shifted. */
|
||||||
|
yychar = TokenKind.YYEMPTY;
|
||||||
|
|
||||||
|
/* Count tokens shifted since error; after three, turn off error
|
||||||
|
* status. */
|
||||||
|
if (yyerrstatus_ > 0)
|
||||||
|
--yyerrstatus_;
|
||||||
|
|
||||||
|
yystate = yyn;
|
||||||
|
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||||
|
label = YYNEWSTATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Shift the lookahead token. */
|
|
||||||
yy_symbol_print ("Shifting", yytoken,
|
|
||||||
yylval]b4_locations_if([, yylloc])[);
|
|
||||||
|
|
||||||
/* Discard the token being shifted. */
|
|
||||||
yychar = yyempty_;
|
|
||||||
|
|
||||||
/* Count tokens shifted since error; after three, turn off error
|
|
||||||
* status. */
|
|
||||||
if (yyerrstatus_ > 0)
|
|
||||||
--yyerrstatus_;
|
|
||||||
|
|
||||||
yystate = yyn;
|
|
||||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
|
||||||
label = YYNEWSTATE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*-----------------------------------------------------------.
|
/*-----------------------------------------------------------.
|
||||||
@@ -611,33 +579,33 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
yystate = yystack.stateAt (0);
|
yystate = yystack.stateAt (0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*------------------------------------.
|
/*--------------------------------------.
|
||||||
| yyerrlab -- here on detecting error |
|
| yyerrlab -- here on detecting error. |
|
||||||
`------------------------------------*/
|
`--------------------------------------*/
|
||||||
case YYERRLAB:
|
case YYERRLAB:
|
||||||
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
||||||
if (yyerrstatus_ == 0)
|
if (yyerrstatus_ == 0)
|
||||||
{
|
{
|
||||||
++yynerrs_;
|
++yynerrs_;
|
||||||
if (yychar == yyempty_)
|
if (yychar == TokenKind.YYEMPTY)
|
||||||
yytoken = yyempty_;
|
yytoken = SymbolKind.]b4_symbol(-2, kind)[;
|
||||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||||
}
|
}
|
||||||
|
]b4_locations_if([
|
||||||
]b4_locations_if([yyerrloc = yylloc;])[
|
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 <= YYTokenType.EOF)
|
if (yychar <= TokenKind.]b4_symbol(0, [id])[)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == YYTokenType.EOF)
|
if (yychar == TokenKind.]b4_symbol(0, [id])[)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yychar = yyempty_;
|
yychar = TokenKind.YYEMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* Else will try to reuse lookahead token after shifting the error
|
||||||
@@ -648,9 +616,8 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
/*-------------------------------------------------.
|
/*-------------------------------------------------.
|
||||||
| errorlab -- error raised explicitly by YYERROR. |
|
| errorlab -- error raised explicitly by YYERROR. |
|
||||||
`-------------------------------------------------*/
|
`-------------------------------------------------*/
|
||||||
case YYERROR:
|
case YYERROR:]b4_locations_if([
|
||||||
|
yyerrloc = yystack.locationAt (yylen - 1);])[
|
||||||
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
|
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
yystack.pop (yylen);
|
yystack.pop (yylen);
|
||||||
@@ -663,15 +630,16 @@ 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.xb */
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
|
// Pop stack until we find a state that shifts the error token.
|
||||||
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 += SymbolKind.]b4_symbol(1, kind)[;
|
||||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == SymbolKind.]b4_symbol(1, kind)[)
|
||||||
{
|
{
|
||||||
yyn = yytable_[yyn];
|
yyn = yytable_[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
@@ -683,24 +651,23 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
if (yystack.height == 1)
|
if (yystack.height == 1)
|
||||||
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);]b4_parse_trace_if([[
|
||||||
if (yydebug > 0)
|
if (0 < yydebug)
|
||||||
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, yy_semantic_null, yylloc);
|
yystack.push (0, yy_semantic_null, yylloc);
|
||||||
yystack.push (0, yy_semantic_null, yyerrloc);
|
yystack.push (0, yy_semantic_null, yyerrloc);
|
||||||
yyloc = yylloc_from_stack (yystack, 2);
|
yyloc = yylloc_from_stack (yystack, 2);
|
||||||
yystack.pop (2);])[
|
yystack.pop (2);])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */]b4_parse_trace_if([[
|
||||||
yy_symbol_print ("Shifting", yystos_[yyn],
|
import std.conv : to;
|
||||||
yylval]b4_locations_if([, yyloc])[);
|
yy_symbol_print ("Shifting", to!SymbolKind (yystos_[yyn]), 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;
|
||||||
@@ -708,88 +675,93 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
|
|
||||||
/* Accept. */
|
/* Accept. */
|
||||||
case YYACCEPT:
|
case YYACCEPT:
|
||||||
return true;
|
yyresult = true;
|
||||||
|
label = YYRETURN;
|
||||||
|
break;
|
||||||
|
|
||||||
/* Abort. */
|
/* Abort. */
|
||||||
case YYABORT:
|
case YYABORT:
|
||||||
return false;
|
yyresult = false;
|
||||||
|
label = YYRETURN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case YYRETURN:]b4_parse_trace_if([[
|
||||||
|
if (0 < yydebug)
|
||||||
|
yystack.print (yyDebugStream);]])[
|
||||||
|
return yyresult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate an error message.
|
// Generate an error message.
|
||||||
private final string yysyntax_error (int yystate, int tok)
|
private final string yysyntax_error (int yystate, SymbolKind tok)
|
||||||
{
|
{]b4_parse_error_case([verbose], [[
|
||||||
if (errorVerbose)
|
/* There are many possibilities here to consider:
|
||||||
|
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||||
|
See
|
||||||
|
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||||
|
for details. YYERROR is fine as it does not invoke this
|
||||||
|
function.
|
||||||
|
- If this state is a consistent state with a default action,
|
||||||
|
then the only way this function was invoked is if the
|
||||||
|
default action is an error action. In that case, don't
|
||||||
|
check for expected tokens because there are none.
|
||||||
|
- The only way there can be no lookahead present (in tok) is
|
||||||
|
if this state is a consistent state with a default action.
|
||||||
|
Thus, detecting the absence of a lookahead is sufficient to
|
||||||
|
determine that there is no unexpected or expected token to
|
||||||
|
report. In that case, just report a simple "syntax error".
|
||||||
|
- Don't assume there isn't a lookahead just because this
|
||||||
|
state is a consistent state with a default action. There
|
||||||
|
might have been a previous inconsistent state, consistent
|
||||||
|
state with a non-default action, or user semantic action
|
||||||
|
that manipulated yychar. (However, yychar is currently out
|
||||||
|
of scope during semantic actions.)
|
||||||
|
- Of course, the expected token list depends on states to
|
||||||
|
have correct lookahead information, and it depends on the
|
||||||
|
parser not to perform extra reductions after fetching a
|
||||||
|
lookahead from the scanner and before detecting a syntax
|
||||||
|
error. Thus, state merging (from LALR or IELR) and default
|
||||||
|
reductions corrupt the expected token list. However, the
|
||||||
|
list is correct for canonical LR with one exception: it
|
||||||
|
will still contain any token that will not be accepted due
|
||||||
|
to an error action in a later state.
|
||||||
|
*/
|
||||||
|
if (tok != SymbolKind.]b4_symbol(-2, kind)[)
|
||||||
{
|
{
|
||||||
/* There are many possibilities here to consider:
|
// FIXME: This method of building the message is not compatible
|
||||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
// with internationalization.
|
||||||
See
|
string res = "syntax error, unexpected ";
|
||||||
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
res ~= yytnamerr_ (yytname_[tok]);
|
||||||
for details. YYERROR is fine as it does not invoke this
|
int yyn = yypact_[yystate];
|
||||||
function.
|
if (!yy_pact_value_is_default_ (yyn))
|
||||||
- If this state is a consistent state with a default action,
|
|
||||||
then the only way this function was invoked is if the
|
|
||||||
default action is an error action. In that case, don't
|
|
||||||
check for expected tokens because there are none.
|
|
||||||
- The only way there can be no lookahead present (in tok) is
|
|
||||||
if this state is a consistent state with a default action.
|
|
||||||
Thus, detecting the absence of a lookahead is sufficient to
|
|
||||||
determine that there is no unexpected or expected token to
|
|
||||||
report. In that case, just report a simple "syntax error".
|
|
||||||
- Don't assume there isn't a lookahead just because this
|
|
||||||
state is a consistent state with a default action. There
|
|
||||||
might have been a previous inconsistent state, consistent
|
|
||||||
state with a non-default action, or user semantic action
|
|
||||||
that manipulated yychar. (However, yychar is currently out
|
|
||||||
of scope during semantic actions.)
|
|
||||||
- Of course, the expected token list depends on states to
|
|
||||||
have correct lookahead information, and it depends on the
|
|
||||||
parser not to perform extra reductions after fetching a
|
|
||||||
lookahead from the scanner and before detecting a syntax
|
|
||||||
error. Thus, state merging (from LALR or IELR) and default
|
|
||||||
reductions corrupt the expected token list. However, the
|
|
||||||
list is correct for canonical LR with one exception: it
|
|
||||||
will still contain any token that will not be accepted due
|
|
||||||
to an error action in a later state.
|
|
||||||
*/
|
|
||||||
if (tok != yyempty_)
|
|
||||||
{
|
{
|
||||||
// FIXME: This method of building the message is not compatible
|
/* Start YYX at -YYN if negative to avoid negative
|
||||||
// with internationalization.
|
indexes in YYCHECK. In other words, skip the first
|
||||||
string res = "syntax error, unexpected ";
|
-YYN actions for this state because they are default
|
||||||
res ~= yytnamerr_ (yytname_[tok]);
|
actions. */
|
||||||
int yyn = yypact_[yystate];
|
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||||
if (!yy_pact_value_is_default_ (yyn))
|
/* Stay within bounds of both yycheck and yytname. */
|
||||||
{
|
int yychecklim = yylast_ - yyn + 1;
|
||||||
/* Start YYX at -YYN if negative to avoid negative
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||||
indexes in YYCHECK. In other words, skip the first
|
int count = 0;
|
||||||
-YYN actions for this state because they are default
|
for (int x = yyxbegin; x < yyxend; ++x)
|
||||||
actions. */
|
if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol(1, kind)[
|
||||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||||
/* Stay within bounds of both yycheck and yytname. */
|
++count;
|
||||||
int yychecklim = yylast_ - yyn + 1;
|
if (count < 5)
|
||||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
{
|
||||||
int count = 0;
|
count = 0;
|
||||||
for (int x = yyxbegin; x < yyxend; ++x)
|
for (int x = yyxbegin; x < yyxend; ++x)
|
||||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol(1, kind)[
|
||||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||||
++count;
|
{
|
||||||
if (count < 5)
|
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||||
{
|
res ~= yytnamerr_ (yytname_[x]);
|
||||||
count = 0;
|
}
|
||||||
for (int x = yyxbegin; x < yyxend; ++x)
|
}
|
||||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
|
||||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
|
||||||
{
|
|
||||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
|
||||||
res ~= yytnamerr_ (yytname_[x]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
}
|
return res;
|
||||||
|
}]])[
|
||||||
return "syntax error";
|
return "syntax error";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,14 +794,6 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
|
|
||||||
]b4_parser_tables_define[
|
]b4_parser_tables_define[
|
||||||
|
|
||||||
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
|
||||||
to YYLEX-NUM. */
|
|
||||||
private static immutable ]b4_int_type_for([b4_toknum])[[]
|
|
||||||
yytoken_number_ =
|
|
||||||
@{
|
|
||||||
]b4_toknum[
|
|
||||||
@};
|
|
||||||
|
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* 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 immutable string[] yytname_ =
|
private static immutable string[] yytname_ =
|
||||||
@@ -837,6 +801,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
]b4_tname[
|
]b4_tname[
|
||||||
@};
|
@};
|
||||||
|
|
||||||
|
]b4_parse_trace_if([[
|
||||||
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
||||||
private static immutable ]b4_int_type_for([b4_rline])[[] yyrline_ =
|
private static immutable ]b4_int_type_for([b4_rline])[[] yyrline_ =
|
||||||
@{
|
@{
|
||||||
@@ -852,46 +817,105 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
int yylno = yyrline_[yyrule];
|
int yylno = yyrline_[yyrule];
|
||||||
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 (format("Reducing stack by rule %d (line %d), ",
|
yycdebugln (format("Reducing stack by rule %d (line %d):",
|
||||||
yyrule - 1, yylno));
|
yyrule - 1, yylno));
|
||||||
|
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
|
import std.conv : to;
|
||||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||||
yy_symbol_print (format(" $%d =", yyi + 1),
|
yy_symbol_print (format(" $%d =", yyi + 1),
|
||||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
to!SymbolKind (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. */
|
private static SymbolKind yytranslate_ (int t)
|
||||||
private static immutable ]b4_int_type_for([b4_translate])[[] yytranslate_table_ =
|
|
||||||
@{
|
|
||||||
]b4_translate[
|
|
||||||
@};
|
|
||||||
|
|
||||||
private static ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
|
||||||
{
|
{
|
||||||
if (t >= 0 && t <= yyuser_token_number_max_)
|
]b4_api_token_raw_if(
|
||||||
return yytranslate_table_[t];
|
[[ import std.conv : to;
|
||||||
|
return to!SymbolKind (t);]],
|
||||||
|
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
|
immutable ]b4_int_type_for([b4_translate])[[] translate_table =
|
||||||
|
@{
|
||||||
|
]b4_translate[
|
||||||
|
@};
|
||||||
|
|
||||||
|
immutable int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
|
|
||||||
|
if (t <= 0)
|
||||||
|
return SymbolKind.]b4_symbol_prefix[YYEOF;
|
||||||
|
else if (t <= user_token_number_max_)
|
||||||
|
{
|
||||||
|
import std.conv : to;
|
||||||
|
return to!SymbolKind (translate_table[t]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return yyundef_token_;
|
return SymbolKind.]b4_symbol_prefix[YYUNDEF;]])[
|
||||||
}
|
}
|
||||||
|
|
||||||
private static immutable int yylast_ = ]b4_last[;
|
private static immutable int yylast_ = ]b4_last[;
|
||||||
private static immutable int yynnts_ = ]b4_nterms_number[;
|
private static immutable int yynnts_ = ]b4_nterms_number[;
|
||||||
private static immutable int yyempty_ = -2;
|
|
||||||
private static immutable int yyfinal_ = ]b4_final_state_number[;
|
private static immutable int yyfinal_ = ]b4_final_state_number[;
|
||||||
private static immutable int yyterror_ = 1;
|
|
||||||
private static immutable int yyerrcode_ = 256;
|
|
||||||
private static immutable int yyntokens_ = ]b4_tokens_number[;
|
private static immutable int yyntokens_ = ]b4_tokens_number[;
|
||||||
|
|
||||||
private static immutable int yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
private final struct YYStackElement {
|
||||||
private static immutable int yyundef_token_ = ]b4_undef_token_number[;
|
int state;
|
||||||
|
]b4_yystype[ value;]b4_locations_if(
|
||||||
|
b4_location_type[[] location;])[
|
||||||
|
}
|
||||||
|
|
||||||
]/* User implementation code. */
|
private final struct YYStack {
|
||||||
b4_percent_code_get[]dnl
|
private YYStackElement[] stack = [];
|
||||||
|
|
||||||
|
public final @@property ulong height()
|
||||||
|
{
|
||||||
|
return stack.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void push (int state, ]b4_yystype[ value]dnl
|
||||||
|
b4_locations_if([, ref ]b4_location_type[ loc])[)
|
||||||
|
{
|
||||||
|
stack ~= YYStackElement(state, value]b4_locations_if([, loc])[);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void pop ()
|
||||||
|
{
|
||||||
|
pop (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void pop (int num)
|
||||||
|
{
|
||||||
|
stack.length -= num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int stateAt (int i)
|
||||||
|
{
|
||||||
|
return stack[$-i-1].state;
|
||||||
|
}
|
||||||
|
|
||||||
|
]b4_locations_if([[
|
||||||
|
public final ref ]b4_location_type[ locationAt (int i)
|
||||||
|
{
|
||||||
|
return stack[$-i-1].location;
|
||||||
|
}]])[
|
||||||
|
|
||||||
|
public final ref ]b4_yystype[ valueAt (int i)
|
||||||
|
{
|
||||||
|
return stack[$-i-1].value;
|
||||||
|
}
|
||||||
|
]b4_parse_trace_if([[
|
||||||
|
// Print the state stack on the debug stream.
|
||||||
|
public final void print (File stream)
|
||||||
|
{
|
||||||
|
stream.write ("Stack now");
|
||||||
|
for (int i = 0; i < stack.length; i++)
|
||||||
|
stream.write (" ", stack[i].state);
|
||||||
|
stream.writeln ();
|
||||||
|
}]])[
|
||||||
|
}
|
||||||
|
]b4_percent_code_get[
|
||||||
}
|
}
|
||||||
|
]b4_percent_code_get([[epilogue]])[]dnl
|
||||||
b4_epilogue
|
b4_epilogue[]dnl
|
||||||
m4_divert_pop(0)dnl
|
b4_output_end
|
||||||
|
|||||||
+445
-398
File diff suppressed because it is too large
Load Diff
+44
-34
@@ -1,6 +1,6 @@
|
|||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
m4_pushdef([b4_copyright_years],
|
m4_pushdef([b4_copyright_years],
|
||||||
[2002-2015, 2018-2019])
|
[2002-2015, 2018-2020])
|
||||||
|
|
||||||
|
|
||||||
# b4_position_file
|
# b4_position_file
|
||||||
@@ -62,11 +62,14 @@ m4_define([b4_location_define],
|
|||||||
[[ /// A point in a source file.
|
[[ /// A point in a source file.
|
||||||
class position
|
class position
|
||||||
{
|
{
|
||||||
public:]m4_ifdef([b4_location_constructors], [[
|
public:
|
||||||
|
/// Type for line and column numbers.
|
||||||
|
typedef int counter_type;
|
||||||
|
]m4_ifdef([b4_location_constructors], [[
|
||||||
/// Construct a position.
|
/// Construct a position.
|
||||||
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
: filename (f)
|
: filename (f)
|
||||||
, line (l)
|
, line (l)
|
||||||
, column (c)
|
, column (c)
|
||||||
@@ -75,8 +78,8 @@ m4_define([b4_location_define],
|
|||||||
]])[
|
]])[
|
||||||
/// Initialization.
|
/// Initialization.
|
||||||
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
|
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
{
|
{
|
||||||
filename = fn;
|
filename = fn;
|
||||||
line = l;
|
line = l;
|
||||||
@@ -86,17 +89,17 @@ m4_define([b4_location_define],
|
|||||||
/** \name Line and Column related manipulators
|
/** \name Line and Column related manipulators
|
||||||
** \{ */
|
** \{ */
|
||||||
/// (line related) Advance to the COUNT next lines.
|
/// (line related) Advance to the COUNT next lines.
|
||||||
void lines (int count = 1)
|
void lines (counter_type count = 1)
|
||||||
{
|
{
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
column = ]b4_location_initial_column[u;
|
column = ]b4_location_initial_column[;
|
||||||
line = add_ (line, count, ]b4_location_initial_line[);
|
line = add_ (line, count, ]b4_location_initial_line[);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// (column related) Advance to the COUNT next columns.
|
/// (column related) Advance to the COUNT next columns.
|
||||||
void columns (int count = 1)
|
void columns (counter_type count = 1)
|
||||||
{
|
{
|
||||||
column = add_ (column, count, ]b4_location_initial_column[);
|
column = add_ (column, count, ]b4_location_initial_column[);
|
||||||
}
|
}
|
||||||
@@ -105,22 +108,21 @@ m4_define([b4_location_define],
|
|||||||
/// File name to which this position refers.
|
/// File name to which this position refers.
|
||||||
]b4_percent_define_get([[filename_type]])[* filename;
|
]b4_percent_define_get([[filename_type]])[* filename;
|
||||||
/// Current line number.
|
/// Current line number.
|
||||||
unsigned line;
|
counter_type line;
|
||||||
/// Current column number.
|
/// Current column number.
|
||||||
unsigned column;
|
counter_type column;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Compute max (min, lhs+rhs).
|
/// Compute max (min, lhs+rhs).
|
||||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
||||||
{
|
{
|
||||||
return static_cast<unsigned> (std::max (min,
|
return lhs + rhs < min ? min : lhs + rhs;
|
||||||
static_cast<int> (lhs) + rhs));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Add \a width columns, in place.
|
/// Add \a width columns, in place.
|
||||||
inline position&
|
inline position&
|
||||||
operator+= (position& res, int width)
|
operator+= (position& res, position::counter_type width)
|
||||||
{
|
{
|
||||||
res.columns (width);
|
res.columns (width);
|
||||||
return res;
|
return res;
|
||||||
@@ -128,21 +130,21 @@ m4_define([b4_location_define],
|
|||||||
|
|
||||||
/// Add \a width columns.
|
/// Add \a width columns.
|
||||||
inline position
|
inline position
|
||||||
operator+ (position res, int width)
|
operator+ (position res, position::counter_type width)
|
||||||
{
|
{
|
||||||
return res += width;
|
return res += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns, in place.
|
/// Subtract \a width columns, in place.
|
||||||
inline position&
|
inline position&
|
||||||
operator-= (position& res, int width)
|
operator-= (position& res, position::counter_type width)
|
||||||
{
|
{
|
||||||
return res += -width;
|
return res += -width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns.
|
/// Subtract \a width columns.
|
||||||
inline position
|
inline position
|
||||||
operator- (position res, int width)
|
operator- (position res, position::counter_type width)
|
||||||
{
|
{
|
||||||
return res -= width;
|
return res -= width;
|
||||||
}
|
}
|
||||||
@@ -182,6 +184,8 @@ m4_define([b4_location_define],
|
|||||||
class location
|
class location
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// Type for line and column numbers.
|
||||||
|
typedef position::counter_type counter_type;
|
||||||
]m4_ifdef([b4_location_constructors], [
|
]m4_ifdef([b4_location_constructors], [
|
||||||
/// Construct a location from \a b to \a e.
|
/// Construct a location from \a b to \a e.
|
||||||
location (const position& b, const position& e)
|
location (const position& b, const position& e)
|
||||||
@@ -197,8 +201,8 @@ m4_define([b4_location_define],
|
|||||||
|
|
||||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||||
explicit location (]b4_percent_define_get([[filename_type]])[* f,
|
explicit location (]b4_percent_define_get([[filename_type]])[* f,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
: begin (f, l, c)
|
: begin (f, l, c)
|
||||||
, end (f, l, c)
|
, end (f, l, c)
|
||||||
{}
|
{}
|
||||||
@@ -206,8 +210,8 @@ m4_define([b4_location_define],
|
|||||||
])[
|
])[
|
||||||
/// Initialization.
|
/// Initialization.
|
||||||
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||||
unsigned l = ]b4_location_initial_line[u,
|
counter_type l = ]b4_location_initial_line[,
|
||||||
unsigned c = ]b4_location_initial_column[u)
|
counter_type c = ]b4_location_initial_column[)
|
||||||
{
|
{
|
||||||
begin.initialize (f, l, c);
|
begin.initialize (f, l, c);
|
||||||
end = begin;
|
end = begin;
|
||||||
@@ -223,13 +227,13 @@ m4_define([b4_location_define],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next columns.
|
/// Extend the current location to the COUNT next columns.
|
||||||
void columns (int count = 1)
|
void columns (counter_type count = 1)
|
||||||
{
|
{
|
||||||
end += count;
|
end += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next lines.
|
/// Extend the current location to the COUNT next lines.
|
||||||
void lines (int count = 1)
|
void lines (counter_type count = 1)
|
||||||
{
|
{
|
||||||
end.lines (count);
|
end.lines (count);
|
||||||
}
|
}
|
||||||
@@ -244,39 +248,45 @@ m4_define([b4_location_define],
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Join two locations, in place.
|
/// Join two locations, in place.
|
||||||
inline location& operator+= (location& res, const location& end)
|
inline location&
|
||||||
|
operator+= (location& res, const location& end)
|
||||||
{
|
{
|
||||||
res.end = end.end;
|
res.end = end.end;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Join two locations.
|
/// Join two locations.
|
||||||
inline location operator+ (location res, const location& end)
|
inline location
|
||||||
|
operator+ (location res, const location& end)
|
||||||
{
|
{
|
||||||
return res += end;
|
return res += end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add \a width columns to the end position, in place.
|
/// Add \a width columns to the end position, in place.
|
||||||
inline location& operator+= (location& res, int width)
|
inline location&
|
||||||
|
operator+= (location& res, location::counter_type width)
|
||||||
{
|
{
|
||||||
res.columns (width);
|
res.columns (width);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add \a width columns to the end position.
|
/// Add \a width columns to the end position.
|
||||||
inline location operator+ (location res, int width)
|
inline location
|
||||||
|
operator+ (location res, location::counter_type width)
|
||||||
{
|
{
|
||||||
return res += width;
|
return res += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns to the end position, in place.
|
/// Subtract \a width columns to the end position, in place.
|
||||||
inline location& operator-= (location& res, int width)
|
inline location&
|
||||||
|
operator-= (location& res, location::counter_type width)
|
||||||
{
|
{
|
||||||
return res += -width;
|
return res += -width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract \a width columns to the end position.
|
/// Subtract \a width columns to the end position.
|
||||||
inline location operator- (location res, int width)
|
inline location
|
||||||
|
operator- (location res, location::counter_type width)
|
||||||
{
|
{
|
||||||
return res -= width;
|
return res -= width;
|
||||||
}
|
}
|
||||||
@@ -305,7 +315,8 @@ m4_define([b4_location_define],
|
|||||||
std::basic_ostream<YYChar>&
|
std::basic_ostream<YYChar>&
|
||||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||||
{
|
{
|
||||||
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
location::counter_type end_col
|
||||||
|
= 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||||
ostr << loc.begin;
|
ostr << loc.begin;
|
||||||
if (loc.end.filename
|
if (loc.end.filename
|
||||||
&& (!loc.begin.filename
|
&& (!loc.begin.filename
|
||||||
@@ -327,7 +338,7 @@ m4_ifdef([b4_position_file], [[
|
|||||||
// used to define is now defined in "]b4_location_file[".
|
// used to define is now defined in "]b4_location_file[".
|
||||||
//
|
//
|
||||||
// To get rid of this file:
|
// To get rid of this file:
|
||||||
// 1. add 'require "3.2"' (or newer) to your grammar file
|
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||||
// 2. remove references to this file from your build system
|
// 2. remove references to this file from your build system
|
||||||
// 3. if you used to include it, include "]b4_location_file[" instead.
|
// 3. if you used to include it, include "]b4_location_file[" instead.
|
||||||
|
|
||||||
@@ -346,7 +357,6 @@ m4_ifdef([b4_location_file], [[
|
|||||||
|
|
||||||
]b4_cpp_guard_open([b4_location_path])[
|
]b4_cpp_guard_open([b4_location_path])[
|
||||||
|
|
||||||
# include <algorithm> // std::max
|
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <string>
|
# include <string>
|
||||||
|
|
||||||
|
|||||||
+29
-35
@@ -1,6 +1,6 @@
|
|||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -32,48 +32,38 @@ m4_define([b4_stack_define],
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Hide our reversed order.
|
// Hide our reversed order.
|
||||||
typedef typename S::reverse_iterator iterator;
|
typedef typename S::iterator iterator;
|
||||||
typedef typename S::const_reverse_iterator const_iterator;
|
typedef typename S::const_iterator const_iterator;
|
||||||
typedef typename S::size_type size_type;
|
typedef typename S::size_type size_type;
|
||||||
|
typedef typename std::ptrdiff_t index_type;
|
||||||
|
|
||||||
stack (size_type n = 200)
|
stack (size_type n = 200)
|
||||||
: seq_ (n)
|
: seq_ (n)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Non copyable.
|
||||||
|
stack (const stack&) = delete;
|
||||||
|
/// Non copyable.
|
||||||
|
stack& operator= (const stack&) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Random access.
|
/// Random access.
|
||||||
///
|
///
|
||||||
/// Index 0 returns the topmost element.
|
/// Index 0 returns the topmost element.
|
||||||
T&
|
const T&
|
||||||
operator[] (size_type i)
|
operator[] (index_type i) const
|
||||||
{
|
{
|
||||||
return seq_[size () - 1 - i];
|
return seq_[size_type (size () - 1 - i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Random access.
|
/// Random access.
|
||||||
///
|
///
|
||||||
/// Index 0 returns the topmost element.
|
/// Index 0 returns the topmost element.
|
||||||
T&
|
T&
|
||||||
operator[] (int i)
|
operator[] (index_type i)
|
||||||
{
|
{
|
||||||
return operator[] (size_type (i));
|
return seq_[size_type (size () - 1 - i)];
|
||||||
}
|
|
||||||
|
|
||||||
/// Random access.
|
|
||||||
///
|
|
||||||
/// Index 0 returns the topmost element.
|
|
||||||
const T&
|
|
||||||
operator[] (size_type i) const
|
|
||||||
{
|
|
||||||
return seq_[size () - 1 - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Random access.
|
|
||||||
///
|
|
||||||
/// Index 0 returns the topmost element.
|
|
||||||
const T&
|
|
||||||
operator[] (int i) const
|
|
||||||
{
|
|
||||||
return operator[] (size_type (i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Steal the contents of \a t.
|
/// Steal the contents of \a t.
|
||||||
@@ -88,7 +78,7 @@ m4_define([b4_stack_define],
|
|||||||
|
|
||||||
/// Pop elements from the stack.
|
/// Pop elements from the stack.
|
||||||
void
|
void
|
||||||
pop (int n = 1) YY_NOEXCEPT
|
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
for (; 0 < n; --n)
|
for (; 0 < n; --n)
|
||||||
seq_.pop_back ();
|
seq_.pop_back ();
|
||||||
@@ -102,49 +92,53 @@ m4_define([b4_stack_define],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Number of elements on the stack.
|
/// Number of elements on the stack.
|
||||||
size_type
|
index_type
|
||||||
size () const YY_NOEXCEPT
|
size () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return seq_.size ();
|
return index_type (seq_.size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator on top of the stack (going downwards).
|
/// Iterator on top of the stack (going downwards).
|
||||||
const_iterator
|
const_iterator
|
||||||
begin () const YY_NOEXCEPT
|
begin () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return seq_.rbegin ();
|
return seq_.begin ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bottom of the stack.
|
/// Bottom of the stack.
|
||||||
const_iterator
|
const_iterator
|
||||||
end () const YY_NOEXCEPT
|
end () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return seq_.rend ();
|
return seq_.end ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Present a slice of the top of a stack.
|
/// Present a slice of the top of a stack.
|
||||||
class slice
|
class slice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
slice (const stack& stack, int range)
|
slice (const stack& stack, index_type range)
|
||||||
: stack_ (stack)
|
: stack_ (stack)
|
||||||
, range_ (range)
|
, range_ (range)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const T&
|
const T&
|
||||||
operator[] (int i) const
|
operator[] (index_type i) const
|
||||||
{
|
{
|
||||||
return stack_[range_ - i];
|
return stack_[range_ - i];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const stack& stack_;
|
const stack& stack_;
|
||||||
int range_;
|
index_type range_;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if YY_CPLUSPLUS < 201103L
|
||||||
|
/// Non copyable.
|
||||||
stack (const stack&);
|
stack (const stack&);
|
||||||
|
/// Non copyable.
|
||||||
stack& operator= (const stack&);
|
stack& operator= (const stack&);
|
||||||
|
#endif
|
||||||
/// The wrapped container.
|
/// The wrapped container.
|
||||||
S seq_;
|
S seq_;
|
||||||
};
|
};
|
||||||
@@ -157,7 +151,7 @@ m4_ifdef([b4_stack_file],
|
|||||||
// used to define is now defined with the parser itself.
|
// used to define is now defined with the parser itself.
|
||||||
//
|
//
|
||||||
// To get rid of this file:
|
// To get rid of this file:
|
||||||
// 1. add 'require "3.2"' (or newer) to your grammar file
|
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||||
// 2. remove references to this file from your build system.
|
// 2. remove references to this file from your build system.
|
||||||
]b4_output_end[
|
]b4_output_end[
|
||||||
]])
|
]])
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
dnl GNU M4 treats -dV in a position-independent manner.
|
||||||
|
m4_debugmode(V)m4_traceon()dnl
|
||||||
+33
-23
@@ -1,6 +1,6 @@
|
|||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -72,9 +72,9 @@ m4_map([ b4_symbol_tag_comment], [$@])dnl
|
|||||||
# The needed includes for variants support.
|
# The needed includes for variants support.
|
||||||
m4_define([b4_variant_includes],
|
m4_define([b4_variant_includes],
|
||||||
[b4_parse_assert_if([[#include <typeinfo>]])[
|
[b4_parse_assert_if([[#include <typeinfo>]])[
|
||||||
#ifndef YYASSERT
|
#ifndef YY_ASSERT
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
# define YYASSERT assert
|
# define YY_ASSERT assert
|
||||||
#endif
|
#endif
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -111,14 +111,21 @@ m4_define([b4_value_type_declare],
|
|||||||
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||||
: yytypeid_ (&typeid (T))])[
|
: yytypeid_ (&typeid (T))])[
|
||||||
{
|
{
|
||||||
YYASSERT (sizeof (T) <= size);
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Non copyable.
|
||||||
|
semantic_type (const self_type&) = delete;
|
||||||
|
/// Non copyable.
|
||||||
|
self_type& operator= (const self_type&) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Destruction, allowed only if empty.
|
/// Destruction, allowed only if empty.
|
||||||
~semantic_type () YY_NOEXCEPT
|
~semantic_type () YY_NOEXCEPT
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (!yytypeid_);
|
YY_ASSERT (!yytypeid_);
|
||||||
])[}
|
])[}
|
||||||
|
|
||||||
# if 201103L <= YY_CPLUSPLUS
|
# if 201103L <= YY_CPLUSPLUS
|
||||||
@@ -127,8 +134,8 @@ m4_define([b4_value_type_declare],
|
|||||||
T&
|
T&
|
||||||
emplace (U&&... u)
|
emplace (U&&... u)
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (!yytypeid_);
|
YY_ASSERT (!yytypeid_);
|
||||||
YYASSERT (sizeof (T) <= size);
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
yytypeid_ = & typeid (T);])[
|
yytypeid_ = & typeid (T);])[
|
||||||
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
||||||
}
|
}
|
||||||
@@ -138,8 +145,8 @@ m4_define([b4_value_type_declare],
|
|||||||
T&
|
T&
|
||||||
emplace ()
|
emplace ()
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (!yytypeid_);
|
YY_ASSERT (!yytypeid_);
|
||||||
YYASSERT (sizeof (T) <= size);
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
yytypeid_ = & typeid (T);])[
|
yytypeid_ = & typeid (T);])[
|
||||||
return *new (yyas_<T> ()) T ();
|
return *new (yyas_<T> ()) T ();
|
||||||
}
|
}
|
||||||
@@ -149,8 +156,8 @@ m4_define([b4_value_type_declare],
|
|||||||
T&
|
T&
|
||||||
emplace (const T& t)
|
emplace (const T& t)
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (!yytypeid_);
|
YY_ASSERT (!yytypeid_);
|
||||||
YYASSERT (sizeof (T) <= size);
|
YY_ASSERT (sizeof (T) <= size);
|
||||||
yytypeid_ = & typeid (T);])[
|
yytypeid_ = & typeid (T);])[
|
||||||
return *new (yyas_<T> ()) T (t);
|
return *new (yyas_<T> ()) T (t);
|
||||||
}
|
}
|
||||||
@@ -179,9 +186,9 @@ m4_define([b4_value_type_declare],
|
|||||||
T&
|
T&
|
||||||
as () YY_NOEXCEPT
|
as () YY_NOEXCEPT
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (yytypeid_);
|
YY_ASSERT (yytypeid_);
|
||||||
YYASSERT (*yytypeid_ == typeid (T));
|
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||||
YYASSERT (sizeof (T) <= size);])[
|
YY_ASSERT (sizeof (T) <= size);])[
|
||||||
return *yyas_<T> ();
|
return *yyas_<T> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,9 +197,9 @@ m4_define([b4_value_type_declare],
|
|||||||
const T&
|
const T&
|
||||||
as () const YY_NOEXCEPT
|
as () const YY_NOEXCEPT
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (yytypeid_);
|
YY_ASSERT (yytypeid_);
|
||||||
YYASSERT (*yytypeid_ == typeid (T));
|
YY_ASSERT (*yytypeid_ == typeid (T));
|
||||||
YYASSERT (sizeof (T) <= size);])[
|
YY_ASSERT (sizeof (T) <= size);])[
|
||||||
return *yyas_<T> ();
|
return *yyas_<T> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,8 +215,8 @@ m4_define([b4_value_type_declare],
|
|||||||
void
|
void
|
||||||
swap (self_type& that) YY_NOEXCEPT
|
swap (self_type& that) YY_NOEXCEPT
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
YYASSERT (yytypeid_);
|
YY_ASSERT (yytypeid_);
|
||||||
YYASSERT (*yytypeid_ == *that.yytypeid_);])[
|
YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
|
||||||
std::swap (as<T> (), that.as<T> ());
|
std::swap (as<T> (), that.as<T> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,9 +265,12 @@ m4_define([b4_value_type_declare],
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prohibit blind copies.
|
#if YY_CPLUSPLUS < 201103L
|
||||||
self_type& operator= (const self_type&);
|
/// Non copyable.
|
||||||
semantic_type (const self_type&);
|
semantic_type (const self_type&);
|
||||||
|
/// Non copyable.
|
||||||
|
self_type& operator= (const self_type&);
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Accessor to raw memory as \a T.
|
/// Accessor to raw memory as \a T.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -401,7 +411,7 @@ m4_define([_b4_token_constructor_define],
|
|||||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||||
b4_locations_if([std::move (l)]))[)
|
b4_locations_if([std::move (l)]))[)
|
||||||
{
|
{
|
||||||
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
symbol_type (]b4_join(
|
symbol_type (]b4_join(
|
||||||
@@ -413,7 +423,7 @@ m4_define([_b4_token_constructor_define],
|
|||||||
b4_symbol_if([$1], [has_type], [v]),
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
b4_locations_if([l]))[)
|
b4_locations_if([l]))[)
|
||||||
{
|
{
|
||||||
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
]])])
|
]])])
|
||||||
|
|||||||
+714
-542
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
bison.xsl - common templates for Bison XSLT.
|
bison.xsl - common templates for Bison XSLT.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
xml2dot.xsl - transform Bison XML Report into DOT.
|
xml2dot.xsl - transform Bison XML Report into DOT.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
xml2text.xsl - transform Bison XML Report into plain text.
|
xml2text.xsl - transform Bison XML Report into plain text.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!--
|
<!--
|
||||||
xml2html.xsl - transform Bison XML Report into XHTML.
|
xml2html.xsl - transform Bison XML Report into XHTML.
|
||||||
|
|
||||||
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2007-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
/bison.help
|
/bison.help
|
||||||
/bison.html
|
/bison.html
|
||||||
/bison.info
|
/bison.info
|
||||||
|
/bison.info.bak
|
||||||
/bison.log
|
/bison.log
|
||||||
/bison.pdf
|
/bison.pdf
|
||||||
/bison.ps
|
/bison.ps
|
||||||
@@ -31,3 +32,5 @@
|
|||||||
/version.texi
|
/version.texi
|
||||||
/yacc.1
|
/yacc.1
|
||||||
/relocatable.texi
|
/relocatable.texi
|
||||||
|
/figs/*.eps
|
||||||
|
/figs/*.svg
|
||||||
|
|||||||
+368
-186
File diff suppressed because it is too large
Load Diff
+2610
-1612
File diff suppressed because it is too large
Load Diff
+97
-58
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2001-2003, 2005-2015, 2018-2019 Free Software
|
## Copyright (C) 2001-2003, 2005-2015, 2018-2020 Free Software
|
||||||
## Foundation, Inc.
|
## Foundation, Inc.
|
||||||
|
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
@@ -14,55 +14,77 @@
|
|||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
AM_MAKEINFOFLAGS = --no-split
|
AM_MAKEINFOFLAGS = \
|
||||||
info_TEXINFOS = doc/bison.texi
|
--no-split \
|
||||||
doc_bison_TEXINFOS = \
|
--set-customization-variable=SECTION_NAME_IN_TITLE=true \
|
||||||
|
--set-customization-variable=AVOID_MENU_REDUNDANCY=true \
|
||||||
|
--set-customization-variable=ICONS=true
|
||||||
|
|
||||||
|
info_TEXINFOS = %D%/bison.texi
|
||||||
|
%C%_bison_TEXINFOS = \
|
||||||
$(CROSS_OPTIONS_TEXI) \
|
$(CROSS_OPTIONS_TEXI) \
|
||||||
doc/fdl.texi \
|
%D%/fdl.texi \
|
||||||
doc/gpl-3.0.texi \
|
%D%/gpl-3.0.texi \
|
||||||
doc/relocatable.texi
|
%D%/relocatable.texi
|
||||||
|
|
||||||
# Cannot express dependencies directly on file names because of Automake.
|
# Cannot express dependencies directly on file names because of Automake.
|
||||||
# Obfuscate with a variable.
|
# Obfuscate with a variable.
|
||||||
doc_bison = doc/bison
|
%C%_bison = %D%/bison
|
||||||
$(doc_bison).dvi: $(FIGS_GV:.gv=.eps)
|
$(%C%_bison).dvi: $(FIGS_GV:.gv=.eps)
|
||||||
$(doc_bison).info: $(FIGS_GV:.gv=.txt)
|
$(%C%_bison).info: $(FIGS_GV:.gv=.txt)
|
||||||
$(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
$(%C%_bison).pdf: $(FIGS_GV:.gv=.pdf)
|
||||||
$(doc_bison).html: $(FIGS_GV:.gv=.png)
|
$(%C%_bison).html: $(FIGS_GV:.gv=.svg)
|
||||||
|
|
||||||
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
TEXI2DVI = texi2dvi --build-dir=%D%/bison.t2d -I %D%
|
||||||
CLEANDIRS += doc/bison.t2d
|
CLEANDIRS += %D%/bison.t2d
|
||||||
|
|
||||||
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.tmp
|
MOSTLYCLEANFILES += $(top_srcdir)/%D%/*.tmp
|
||||||
|
|
||||||
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
||||||
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
|
CROSS_OPTIONS_TEXI = $(top_srcdir)/%D%/cross-options.texi
|
||||||
$(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
$(CROSS_OPTIONS_TEXI): %D%/bison.help $(CROSS_OPTIONS_PL)
|
||||||
# Create $@~ which is the previous contents. Don't use 'mv' here so
|
# Create $@~ which is the previous contents. Don't use 'mv' here so
|
||||||
# that even if we are interrupted, the file is still available for
|
# that even if we are interrupted, the file is still available for
|
||||||
# diff in the next run. Note that $@ might not exist yet.
|
# diff in the next run. Note that $@ might not exist yet.
|
||||||
$(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~
|
$(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~
|
||||||
$(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp
|
$(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp
|
||||||
$(AM_V_at)$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l \
|
$(AM_V_at)$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l \
|
||||||
<$(top_srcdir)/doc/bison.help >$@.tmp
|
<$(top_srcdir)/%D%/bison.help >$@.tmp
|
||||||
$(AM_V_at)diff -u $@~ $@.tmp || true
|
$(AM_V_at)diff -u $@~ $@.tmp || true
|
||||||
$(AM_V_at)mv $@.tmp $@
|
$(AM_V_at)mv $@.tmp $@
|
||||||
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
||||||
|
|
||||||
|
|
||||||
|
# Fix Info's @code in @deftype
|
||||||
|
# https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html
|
||||||
|
all: $(srcdir)/$(%C%_bison).info.bak
|
||||||
|
$(srcdir)/$(%C%_bison).info.bak: $(srcdir)/$(%C%_bison).info
|
||||||
|
$(AM_V_GEN) $(PERL) -pi.bak -0777 \
|
||||||
|
-e 's{(^ --.*\n(?: {10}.*\n)*)}' \
|
||||||
|
-e '{' \
|
||||||
|
-e ' $$def = $$1;' \
|
||||||
|
-e ' $$def =~ s/‘|’//g;' \
|
||||||
|
-e ' $$def;' \
|
||||||
|
-e '}gem;' $(srcdir)/$(%C%_bison).info
|
||||||
|
@ touch $@
|
||||||
|
EXTRA_DIST += $(srcdir)/$(%C%_bison).info.bak
|
||||||
|
MAINTAINERCLEANFILES += $(srcdir)/$(%C%_bison).info.bak
|
||||||
|
|
||||||
|
|
||||||
## ---------- ##
|
## ---------- ##
|
||||||
## Ref card. ##
|
## Ref card. ##
|
||||||
## ---------- ##
|
## ---------- ##
|
||||||
|
|
||||||
EXTRA_DIST += doc/refcard.tex
|
EXTRA_DIST += %D%/refcard.tex
|
||||||
CLEANFILES += doc/refcard.pdf
|
CLEANFILES += %D%/refcard.pdf
|
||||||
|
|
||||||
doc/refcard.pdf: doc/refcard.tex
|
%D%/refcard.pdf: %D%/refcard.tex
|
||||||
$(AM_V_GEN) cd doc && pdftex $(abs_top_srcdir)/doc/refcard.tex
|
$(AM_V_GEN) cd %D% && pdftex $(abs_top_srcdir)/%D%/refcard.tex
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## doc/bison.help. ##
|
## %D%/bison.help. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# Some of our targets (cross-options.texi, bison.1) use "bison --help".
|
# Some of our targets (cross-options.texi, bison.1) use "bison --help".
|
||||||
@@ -84,16 +106,19 @@ doc/refcard.pdf: doc/refcard.tex
|
|||||||
# compilations of cross-options.texi and bison.1. At the cost of
|
# compilations of cross-options.texi and bison.1. At the cost of
|
||||||
# repeated builds of bison.help.
|
# repeated builds of bison.help.
|
||||||
|
|
||||||
EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
EXTRA_DIST += $(top_srcdir)/%D%/bison.help
|
||||||
if ! CROSS_COMPILING
|
if ! CROSS_COMPILING
|
||||||
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
MAINTAINERCLEANFILES += $(top_srcdir)/%D%/bison.help
|
||||||
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
$(top_srcdir)/%D%/bison.help: src/bison$(EXEEXT)
|
||||||
$(AM_V_GEN)LC_ALL=C src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
$(AM_V_GEN)$(MKDIR_P) %D%
|
||||||
$(AM_V_at) LC_ALL=C src/bison$(EXEEXT) --help | \
|
$(AM_V_at) LC_ALL=C tests/bison --version >%D%/bison.help.tmp
|
||||||
|
$(AM_V_at) LC_ALL=C tests/bison --help | \
|
||||||
|
## Avoid depending on the path to Bison.
|
||||||
|
sed -e 's,^Usage: .*/bison \[OPTION\],Usage: bison [OPTION],g' \
|
||||||
## Avoid variations in the output depending on whether we are
|
## Avoid variations in the output depending on whether we are
|
||||||
## on a glibc system.
|
## on a glibc system.
|
||||||
sed '/translation bugs/d' >>doc/bison.help.tmp
|
-e '/translation bugs/d' >>%D%/bison.help.tmp
|
||||||
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change %D%/bison.help.tmp $@
|
||||||
endif ! CROSS_COMPILING
|
endif ! CROSS_COMPILING
|
||||||
|
|
||||||
|
|
||||||
@@ -101,48 +126,62 @@ endif ! CROSS_COMPILING
|
|||||||
## Man Pages. ##
|
## Man Pages. ##
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
|
|
||||||
dist_man_MANS = $(top_srcdir)/doc/bison.1
|
dist_man_MANS = $(top_srcdir)/%D%/bison.1
|
||||||
|
|
||||||
EXTRA_DIST += $(dist_man_MANS:.1=.x)
|
EXTRA_DIST += $(dist_man_MANS:.1=.x)
|
||||||
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
||||||
|
|
||||||
# Differences to ignore when comparing the man page (the date).
|
# Differences to ignore when comparing man pages (the date).
|
||||||
remove_time_stamp = \
|
remove_time_stamp = \
|
||||||
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
||||||
|
|
||||||
# Depend on configure to get version number changes.
|
# Depend on configure to get version number changes.
|
||||||
if ! CROSS_COMPILING
|
if ! CROSS_COMPILING
|
||||||
MAN_DEPS = doc/bison.help doc/bison.x $(top_srcdir)/configure
|
MAN_DEPS = %D%/bison.help %D%/bison.x $(top_srcdir)/configure
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
|
# If we don't have help2man, just touch the target. Maintainers must
|
||||||
$(AM_V_GEN)$(HELP2MAN) \
|
# have the real thing, so if there's a .git directory, fail hard.
|
||||||
--include=$(top_srcdir)/doc/bison.x \
|
#
|
||||||
--output=$@.tmp src/bison$(EXEEXT)
|
# We shouldn't need this, but on some OS the timestamps in the tarball
|
||||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.tmp 2>/dev/null && \
|
# leave us no choice. See
|
||||||
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
|
# https://lists.gnu.org/r/bug-bison/2020-05/msg00055.html.
|
||||||
touch $@; \
|
$(top_srcdir)/%D%/bison.1: $(MAN_DEPS)
|
||||||
else \
|
$(AM_V_GEN)if $(HELP2MAN) --version >/dev/null 2>&1; then \
|
||||||
mv $@.tmp $@; \
|
$(HELP2MAN) \
|
||||||
|
--include=$(top_srcdir)/%D%/bison.x \
|
||||||
|
--output=$@.tmp tests/bison && \
|
||||||
|
{ $(remove_time_stamp) $@ >$@a.tmp || true; } && \
|
||||||
|
$(remove_time_stamp) $@.tmp >$@b.tmp && \
|
||||||
|
if diff $@a.tmp $@b.tmp >/dev/null 2>&1; then \
|
||||||
|
touch $@; \
|
||||||
|
else \
|
||||||
|
mv $@.tmp $@; \
|
||||||
|
fi && \
|
||||||
|
rm -f $@*.tmp; \
|
||||||
|
elif test -d $(srcdir)/.git; then \
|
||||||
|
echo >&2 "ERROR: $@: help2man is needed"; \
|
||||||
|
exit 1; \
|
||||||
|
else \
|
||||||
|
touch $@; \
|
||||||
fi
|
fi
|
||||||
$(AM_V_at)rm -f $@*.tmp
|
|
||||||
|
|
||||||
if ENABLE_YACC
|
if ENABLE_YACC
|
||||||
nodist_man_MANS = doc/yacc.1
|
nodist_man_MANS = %D%/yacc.1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## ----------------------------- ##
|
## ----------------------------- ##
|
||||||
## Graphviz examples generation. ##
|
## Graphviz examples generation. ##
|
||||||
## ----------------------------- ##
|
## ----------------------------- ##
|
||||||
|
|
||||||
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
|
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||||
FIGS_GV = \
|
FIGS_GV = \
|
||||||
doc/figs/example.gv \
|
%D%/figs/example.gv \
|
||||||
doc/figs/example-reduce.gv doc/figs/example-shift.gv
|
%D%/figs/example-reduce.gv %D%/figs/example-shift.gv
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
|
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
|
||||||
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
|
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
|
||||||
SUFFIXES += .gv .eps .pdf .png
|
SUFFIXES += .gv .eps .pdf .svg
|
||||||
|
|
||||||
.gv.eps:
|
.gv.eps:
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||||
@@ -154,9 +193,9 @@ SUFFIXES += .gv .eps .pdf .png
|
|||||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
||||||
$(AM_V_at) mv $@.tmp $@
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
.gv.png:
|
.gv.svg:
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp
|
$(AM_V_at) $(DOT) -Gmargin=0 -Tsvg $< >$@.tmp
|
||||||
$(AM_V_at) mv $@.tmp $@
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
@@ -169,8 +208,8 @@ DOXYGEN = doxygen
|
|||||||
|
|
||||||
doc: html
|
doc: html
|
||||||
|
|
||||||
html-local: doc/Doxyfile
|
html-local: %D%/Doxyfile
|
||||||
$(AM_V_GEN) $(DOXYGEN) doc/Doxyfile
|
$(AM_V_GEN) $(DOXYGEN) %D%/Doxyfile
|
||||||
|
|
||||||
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
||||||
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
||||||
@@ -178,11 +217,11 @@ edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
|||||||
-e 's,@top_builddir\@,$(top_builddir),g' \
|
-e 's,@top_builddir\@,$(top_builddir),g' \
|
||||||
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
||||||
|
|
||||||
EXTRA_DIST += doc/Doxyfile.in
|
EXTRA_DIST += %D%/Doxyfile.in
|
||||||
CLEANFILES += doc/Doxyfile
|
CLEANFILES += %D%/Doxyfile
|
||||||
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
||||||
# configure, because the former is way faster than the latter.
|
# configure, because the former is way faster than the latter.
|
||||||
doc/Doxyfile: $(top_srcdir)/doc/Doxyfile.in
|
%D%/Doxyfile: $(top_srcdir)/%D%/Doxyfile.in
|
||||||
$(AM_V_GEN) $(edit) $(top_srcdir)/doc/Doxyfile.in >doc/Doxyfile
|
$(AM_V_GEN) $(edit) $(top_srcdir)/%D%/Doxyfile.in >%D%/Doxyfile
|
||||||
|
|
||||||
CLEANDIRS += doc/html
|
CLEANDIRS += %D%/html
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
\def\finalout{\overfullrule=0pt}
|
\def\finalout{\overfullrule=0pt}
|
||||||
%\finalout
|
%\finalout
|
||||||
|
|
||||||
% Copyright (c) 1998, 2001, 2009-2015, 2018-2019 Free Software
|
% Copyright (c) 1998, 2001, 2009--2015, 2018--2020 Free Software
|
||||||
% Foundation, Inc.
|
% Foundation, Inc.
|
||||||
%
|
%
|
||||||
% This file is part of Bison.
|
% This file is part of Bison.
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ straightforward use of _build/src/bison would.)
|
|||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
Copyright (C) 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2006, 2009-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
|||||||
+268
-183
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2006, 2008-2015, 2018-2019 Free Software Foundation,
|
## Copyright (C) 2006, 2008-2015, 2018-2020 Free Software Foundation,
|
||||||
## Inc.
|
## 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
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ fill-column: 76
|
|||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
/simple.yy
|
||||||
@@ -8,13 +8,13 @@ afterwards.
|
|||||||
## simple.yy - Simple example in C++14
|
## simple.yy - Simple example in C++14
|
||||||
A very simple example in C++, based on variants and symbol constructors.
|
A very simple example in C++, based on variants and symbol constructors.
|
||||||
Variants allow to use any C++ type as semantic value type, and symbol
|
Variants allow to use any C++ type as semantic value type, and symbol
|
||||||
constructors ensure consistency between declared token type and effective
|
constructors ensure consistency between declared token kind and effective
|
||||||
semantic value.
|
semantic value.
|
||||||
|
|
||||||
Run as `./simple`.
|
Run as `./simple`.
|
||||||
|
|
||||||
Extracted from the documentation: "A Simple C++ Example".
|
Extracted from the documentation: [A Simple C++
|
||||||
https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html
|
Example](https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html).
|
||||||
|
|
||||||
## variant.yy - Self-contained example in C++98
|
## variant.yy - Self-contained example in C++98
|
||||||
A variation of simple.yy, in C++98.
|
A variation of simple.yy, in C++98.
|
||||||
@@ -36,8 +36,8 @@ starting point for a clean parser in C++. The previous examples are better
|
|||||||
introductory examples, and the C examples are also useful introductory
|
introductory examples, and the C examples are also useful introductory
|
||||||
examples.
|
examples.
|
||||||
|
|
||||||
Extracted from the documentation: "A Complete C++ Example".
|
Extracted from the documentation: [A Complete C++
|
||||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html).
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ fill-column: 76
|
|||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
@@ -55,5 +55,5 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
|||||||
Texts. A copy of the license is included in the "GNU Free
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
Documentation License" file as part of this distribution.
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
# LocalWords: mfcalc calc parsers yy ispell american
|
LocalWords: mfcalc calc parsers yy ispell american
|
||||||
--->
|
--->
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ saw the traditional implementation in C, please first read
|
|||||||
examples/c/lexcalc, which can be seen as a C precursor of this example.
|
examples/c/lexcalc, which can be seen as a C precursor of this example.
|
||||||
|
|
||||||
Read the corresponding chapter in the documentation: "A Complete C++
|
Read the corresponding chapter in the documentation: "A Complete C++
|
||||||
Example". It is also available on line (maybe with a different version of
|
Example". It is also available [on
|
||||||
Bison):
|
line](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html)
|
||||||
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
|
(maybe with a different version of Bison).
|
||||||
|
|
||||||
To use it, copy this directory into some work directory, and run `make` to
|
To use it, copy this directory into some work directory, and run `make` to
|
||||||
compile the executable, and try it. It is a simple calculator which accepts
|
compile the executable, and try it. It is a simple calculator which accepts
|
||||||
@@ -36,22 +36,14 @@ fill-column: 76
|
|||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||||
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/>.
|
|
||||||
|
|
||||||
# LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
|
||||||
--->
|
--->
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2005-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2005-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -44,11 +44,18 @@ EOF
|
|||||||
run 0 9
|
run 0 9
|
||||||
|
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 +
|
||||||
|
EOF
|
||||||
|
run 1 'err: -:2.1: syntax error, unexpected end of file, expecting ( or identifier or number'
|
||||||
|
|
||||||
|
|
||||||
|
# LAC finds many more tokens.
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
a := 1
|
a := 1
|
||||||
d := a + b * c
|
d := a + b * c
|
||||||
EOF
|
EOF
|
||||||
run 1 'err: -:3.1: syntax error, unexpected end of file, expecting ( or identifier or number'
|
run 1 'err: -:3.1: syntax error, unexpected end of file'
|
||||||
|
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2019 Free Software
|
## Copyright (C) 2005-2006, 2008-2015, 2018-2020 Free Software
|
||||||
## Foundation, Inc.
|
## Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
@@ -18,8 +18,6 @@
|
|||||||
## Parser generation. ##
|
## Parser generation. ##
|
||||||
## ------------------- ##
|
## ------------------- ##
|
||||||
|
|
||||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
|
||||||
# in srcdir, including during distcheck, which is forbidden.
|
|
||||||
%D%/parser.stamp: $(dependencies)
|
%D%/parser.stamp: $(dependencies)
|
||||||
SUFFIXES += .yy .stamp
|
SUFFIXES += .yy .stamp
|
||||||
.yy.stamp:
|
.yy.stamp:
|
||||||
@@ -33,6 +31,7 @@ $(calcxx_sources_generated): %D%/parser.stamp
|
|||||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/parser.stamp
|
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/parser.stamp
|
||||||
CLEANFILES += \
|
CLEANFILES += \
|
||||||
$(calcxx_sources_generated) \
|
$(calcxx_sources_generated) \
|
||||||
|
%D%/parser.dot \
|
||||||
%D%/parser.output \
|
%D%/parser.output \
|
||||||
%D%/parser.stamp \
|
%D%/parser.stamp \
|
||||||
%D%/scanner.cc
|
%D%/scanner.cc
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
## Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -68,4 +68,6 @@ endif
|
|||||||
EXTRA_DIST += %D%/variant-11.test
|
EXTRA_DIST += %D%/variant-11.test
|
||||||
|
|
||||||
dist_cxx_DATA = %D%/README.md %D%/Makefile %D%/variant.yy %D%/variant-11.yy
|
dist_cxx_DATA = %D%/README.md %D%/Makefile %D%/variant.yy %D%/variant-11.yy
|
||||||
CLEANFILES += %D%/simple.output %D%/variant.output %D%/variant-11.output
|
CLEANFILES += \
|
||||||
|
%D%/simple.output %D%/variant.output %D%/variant-11.output \
|
||||||
|
%D%/simple.hh %D%/variant.hh %D%/variant-11.hh
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -117,7 +117,7 @@ namespace yy
|
|||||||
static int count = 0;
|
static int count = 0;
|
||||||
const int stage = count;
|
const int stage = count;
|
||||||
++count;
|
++count;
|
||||||
auto loc = parser::location_type{nullptr, unsigned (stage + 1), unsigned (stage + 1)};
|
auto loc = parser::location_type{nullptr, stage + 1, stage + 1};
|
||||||
if (stage == 0)
|
if (stage == 0)
|
||||||
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
||||||
else if (stage < max)
|
else if (stage < max)
|
||||||
@@ -139,7 +139,7 @@ namespace yy
|
|||||||
int
|
int
|
||||||
main (int argc, const char *argv[])
|
main (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
if (2 <= argc && isdigit (*argv[1]))
|
if (2 <= argc && isdigit (static_cast<unsigned char> (*argv[1])))
|
||||||
{
|
{
|
||||||
auto maxl = strtol (argv[1], nullptr, 10);
|
auto maxl = strtol (argv[1], nullptr, 10);
|
||||||
max = INT_MIN <= maxl && maxl <= INT_MAX ? int(maxl) : 4;
|
max = INT_MIN <= maxl && maxl <= INT_MAX ? int(maxl) : 4;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2008-2015, 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2008-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -117,7 +117,7 @@ namespace yy
|
|||||||
static int count = 0;
|
static int count = 0;
|
||||||
const int stage = count;
|
const int stage = count;
|
||||||
++count;
|
++count;
|
||||||
parser::location_type loc (NULLPTR, unsigned (stage + 1), unsigned (stage + 1));
|
parser::location_type loc (NULLPTR, stage + 1, stage + 1);
|
||||||
switch (stage)
|
switch (stage)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
+64
-12
@@ -1,22 +1,69 @@
|
|||||||
This directory contains examples of Bison grammar files.
|
# Examples in C
|
||||||
|
|
||||||
Most of them come from the documentation, which should be installed together
|
This directory contains simple examples of Bison grammar files in C.
|
||||||
|
|
||||||
|
Some of them come from the documentation, which should be installed together
|
||||||
with Bison. The URLs are provided for convenience.
|
with Bison. The URLs are provided for convenience.
|
||||||
|
|
||||||
# rpcalc - Reverse Polish Notation Calculator
|
## rpcalc - Reverse Polish Notation Calculator
|
||||||
The first example is that of a simple double-precision Reverse Polish
|
The first example is that of a simple double-precision Reverse Polish
|
||||||
Notation calculator (a calculator using postfix operators). This example
|
Notation calculator (a calculator using postfix operators). This example
|
||||||
provides a good starting point, since operator precedence is not an issue.
|
provides a good starting point, since operator precedence is not an issue.
|
||||||
|
|
||||||
Extracted from the documentation: "Reverse Polish Notation Calculator"
|
Extracted from the documentation: [Reverse Polish Notation
|
||||||
https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
|
Calculator](https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html).
|
||||||
|
|
||||||
# mfcalc - Multi-Function Calculator
|
## calc - Simple Calculator
|
||||||
A more complete C example: a multi-function calculator.
|
This example is slightly more complex than rpcalc: it features infix
|
||||||
|
operators (`1 + 2`, instead of `1 2 +` in rpcalc), but it does so using a
|
||||||
|
unambiguous grammar of the arithmetic instead of using precedence
|
||||||
|
directives (%left, etc.).
|
||||||
|
|
||||||
Extracted from the documentation: "Multi-Function Calculator: mfcalc".
|
## mfcalc - Multi-Function Calculator
|
||||||
https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
|
A more complete C example: a multi-function calculator. More complex than
|
||||||
|
the previous example. Using precedence directives to support infix
|
||||||
|
operators.
|
||||||
|
|
||||||
|
Extracted from the documentation: [Multi-Function Calculator:
|
||||||
|
mfcalc](https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html).
|
||||||
|
|
||||||
|
## lexcalc - calculator with Flex and Bison
|
||||||
|
The calculator with precedence directives and location tracking. It uses
|
||||||
|
Flex to generate the scanner.
|
||||||
|
|
||||||
|
## reccalc - recursive calculator with Flex and Bison
|
||||||
|
This example builds on top of the previous one to provide a reentrant
|
||||||
|
parser. Such parsers can be called concurrently in different threads, or
|
||||||
|
even recursively. To demonstrate this feature, expressions in parentheses
|
||||||
|
are tokenized as strings, and then recursively parsed from the parser. So
|
||||||
|
`(((1)+(2))*((3)+(4)))` uses eight parsers, with a depth of four.
|
||||||
|
|
||||||
|
## pushcalc - calculator implemented with a push parser
|
||||||
|
All the previous examples are so called "pull parsers": the user invokes the
|
||||||
|
parser once, which repeatedly calls the scanner until the input is drained.
|
||||||
|
|
||||||
|
This example demonstrates the "push parsers": the user calls the scanner to
|
||||||
|
fetch the next token, passes it to the parser, and repeats the operation
|
||||||
|
until the input is drained.
|
||||||
|
|
||||||
|
This example is a straightforward conversion of the 'calc' example to the
|
||||||
|
push-parser model.
|
||||||
|
|
||||||
|
## bistromathic - all the bells and whistles
|
||||||
|
This example demonstrates best practices when using Bison.
|
||||||
|
- Its hand-written scanner tracks locations.
|
||||||
|
- Its interface is pure.
|
||||||
|
- It uses the `error` token to get error recovery.
|
||||||
|
- Its interface is "incremental", well suited for interaction: it uses the
|
||||||
|
push-parser API to feed the parser with the incoming tokens.
|
||||||
|
- It features an interactive command line with completion based on the
|
||||||
|
parser state, based on `yyexpected_tokens`.
|
||||||
|
- It uses Bison's standard catalogue for internationalization of generated
|
||||||
|
messages.
|
||||||
|
- It uses a custom syntax error with location, lookahead correction and
|
||||||
|
token internationalization.
|
||||||
|
- It supports debug traces with semantic values.
|
||||||
|
- It uses named references instead of the traditional $1, $2, etc.
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
|
|
||||||
@@ -25,7 +72,9 @@ fill-column: 76
|
|||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
@@ -34,5 +83,8 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
|||||||
Texts. A copy of the license is included in the "GNU Free
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
Documentation License" file as part of this distribution.
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
# LocalWords: mfcalc calc parsers yy
|
LocalWords: mfcalc calc parsers yy rpcalc lexcalc redux reccalc ispell
|
||||||
--->
|
LocalWords: reentrant tokenized american postfix pushcalc bistromathic
|
||||||
|
LocalWords: lookahead
|
||||||
|
|
||||||
|
-->
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# This Makefile is designed to be simple and readable. It does not
|
||||||
|
# aim at portability. It requires GNU Make.
|
||||||
|
|
||||||
|
BASE = bistromathic
|
||||||
|
BISON = bison
|
||||||
|
XSLTPROC = xsltproc
|
||||||
|
|
||||||
|
# We need to find the headers and libs for readline (and possibly intl).
|
||||||
|
# You probably need to customize this for your own environment.
|
||||||
|
CPPFLAGS = -I/opt/local/include
|
||||||
|
LDFLAGS = -L/opt/local/lib
|
||||||
|
|
||||||
|
# Find the translation catalogue for Bison's generated messagess.
|
||||||
|
BISON_LOCALEDIR = $(shell $(BISON) $(BISON_FLAGS) --print-localedir)
|
||||||
|
CPPFLAGS += -DENABLE_NLS -DBISON_LOCALEDIR='"$(BISON_LOCALEDIR)"'
|
||||||
|
|
||||||
|
LIBS = -lreadline -lm # In some environments, -lintl is needed.
|
||||||
|
|
||||||
|
all: $(BASE)
|
||||||
|
|
||||||
|
%.c %.h %.xml %.gv: %.y
|
||||||
|
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||||
|
|
||||||
|
$(BASE): parse.o
|
||||||
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
run: $(BASE)
|
||||||
|
@echo "Type bistromathic expressions. Quit with ctrl-d."
|
||||||
|
./$<
|
||||||
|
|
||||||
|
html: $(BASE).html
|
||||||
|
%.html: %.xml
|
||||||
|
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(BASE) *.o \
|
||||||
|
parse.[ch] parse.output parse.xml parse.html parse.gv
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(CLEANFILES)
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# bistromathic - all the bells and whistles
|
||||||
|
This example demonstrates best practices when using Bison.
|
||||||
|
- Its hand-written scanner tracks locations.
|
||||||
|
- Its interface is pure.
|
||||||
|
- It uses the `error` token to get error recovery.
|
||||||
|
- Its interface is "incremental", well suited for interaction: it uses the
|
||||||
|
push-parser API to feed the parser with the incoming tokens.
|
||||||
|
- It features an interactive command line with completion based on the
|
||||||
|
parser state, based on `yyexpected_tokens`.
|
||||||
|
- It uses Bison's standard catalogue for internationalization of generated
|
||||||
|
messages.
|
||||||
|
- It uses a custom syntax error with location, lookahead correction and
|
||||||
|
token internationalization.
|
||||||
|
- It supports debug traces with semantic values.
|
||||||
|
- It uses named references instead of the traditional $1, $2, etc.
|
||||||
|
|
||||||
|
To customize the interaction with bistromathic, see the GNU Readline user
|
||||||
|
manual (see `info rluserman`).
|
||||||
|
|
||||||
|
<!---
|
||||||
|
Local Variables:
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
|
LocalWords: bistromathic yyexpected lookahead ispell american
|
||||||
|
LocalWords: MERCHANTABILITY
|
||||||
|
|
||||||
|
--->
|
||||||
Executable
+308
@@ -0,0 +1,308 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Users may customize the behavior of readline, which might break our
|
||||||
|
# expected results.
|
||||||
|
INPUTRC=/dev/null
|
||||||
|
export INPUTRC
|
||||||
|
|
||||||
|
# Beware of portability issues of readline when not feeding it from a
|
||||||
|
# terminal.
|
||||||
|
#
|
||||||
|
# With recent versions of GNU Readline, input "1+2*3\n" gives
|
||||||
|
# "> 1+2*3\n7\n> \n"
|
||||||
|
#
|
||||||
|
# macOS' version does not display the prompt and does not repeat stdin
|
||||||
|
# on stdout, so input "1+2*3\n" gives "7\n" as output. Let's try to
|
||||||
|
# cope with this.
|
||||||
|
#
|
||||||
|
# On OpenBSD 6.5 the prompt is displayed, but the input is not
|
||||||
|
# repeated (!). So input "1+2*3\n" gives "> 7\n> \n" as output.
|
||||||
|
#
|
||||||
|
# On AIX, you get some escaping sequence before the prompt:
|
||||||
|
# "<ESC>[?1034h> 1+2*3". It appears to pass the terminfo capability
|
||||||
|
# "smm", to put the terminal in "meta mode": as if the user had hit
|
||||||
|
# META.
|
||||||
|
|
||||||
|
echo >perfect '> 0
|
||||||
|
0
|
||||||
|
> '
|
||||||
|
|
||||||
|
echo >ok '0'
|
||||||
|
echo '0' | prog >effective
|
||||||
|
|
||||||
|
echo "checking for readline output..."
|
||||||
|
if diff perfect effective; then
|
||||||
|
# Alles ist gut.
|
||||||
|
strip_prompt=false
|
||||||
|
elif diff ok effective; then
|
||||||
|
strip_prompt=true
|
||||||
|
else
|
||||||
|
skip "this is not the GNU Readline we expect"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1+2*3
|
||||||
|
EOF
|
||||||
|
run 0 '> 1+2*3
|
||||||
|
7
|
||||||
|
> '
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
(1+2) * 3
|
||||||
|
EOF
|
||||||
|
run 0 '> (1+2) * 3
|
||||||
|
9
|
||||||
|
> '
|
||||||
|
run -noerr 0 '> (1+2) * 3
|
||||||
|
9
|
||||||
|
> ' -p
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
a = 256
|
||||||
|
sqrt (a)
|
||||||
|
EOF
|
||||||
|
run 0 '> a = 256
|
||||||
|
256
|
||||||
|
> sqrt (a)
|
||||||
|
16
|
||||||
|
> '
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
a = .16
|
||||||
|
b = 10 ^ 2
|
||||||
|
sqrt (a * b)
|
||||||
|
EOF
|
||||||
|
run 0 '> a = .16
|
||||||
|
0.16
|
||||||
|
> b = 10 ^ 2
|
||||||
|
100
|
||||||
|
> sqrt (a * b)
|
||||||
|
4
|
||||||
|
> '
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
*
|
||||||
|
EOF
|
||||||
|
run 0 '> *
|
||||||
|
> ''
|
||||||
|
err: 1.1: syntax error: expected end of file or - or ( or exit or number or function etc., before *'
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 + 2 * * 3
|
||||||
|
EOF
|
||||||
|
run 0 '> 1 + 2 * * 3
|
||||||
|
> ''
|
||||||
|
err: 1.9: syntax error: expected - or ( or number or function or variable before *'
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 / 0
|
||||||
|
EOF
|
||||||
|
run 0 '> 1 / 0
|
||||||
|
> ''
|
||||||
|
err: 1.1-5: error: division by zero'
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Error recovery. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
((1 ++ 2) ** 3)
|
||||||
|
(1 ++ 2) + (3 ** 4)
|
||||||
|
EOF
|
||||||
|
run 0 '> ((1 ++ 2) ** 3)
|
||||||
|
666
|
||||||
|
> (1 ++ 2) + (3 ** 4)
|
||||||
|
1332
|
||||||
|
> ''
|
||||||
|
err: 1.6: syntax error: expected - or ( or number or function or variable before +
|
||||||
|
err: 2.5: syntax error: expected - or ( or number or function or variable before +
|
||||||
|
err: 2.16: syntax error: expected - or ( or number or function or variable before *'
|
||||||
|
|
||||||
|
# The rule "( error )" should work even if there are no tokens between "(" and ")".
|
||||||
|
cat >input <<EOF
|
||||||
|
()
|
||||||
|
EOF
|
||||||
|
run 0 '> ()
|
||||||
|
666
|
||||||
|
> ''
|
||||||
|
err: 1.2: syntax error: expected - or ( or number or function or variable before )'
|
||||||
|
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
100% + 10
|
||||||
|
EOF
|
||||||
|
run 0 '> 100% + 10
|
||||||
|
> ''
|
||||||
|
err: 1.4: syntax error: invalid character: %'
|
||||||
|
|
||||||
|
# Traces. This allows to check the location of the error. If we
|
||||||
|
# forget to map YYerror to YYUNDEF, error recovery enters an endless
|
||||||
|
# loop with this input.
|
||||||
|
cat >input <<EOF
|
||||||
|
(+_)
|
||||||
|
EOF
|
||||||
|
run 0 '> (+_)
|
||||||
|
666
|
||||||
|
> ''
|
||||||
|
err: Starting parse
|
||||||
|
err: Entering state 0
|
||||||
|
err: Stack now 0
|
||||||
|
err: Reading a token
|
||||||
|
err: Next token is token ( (1.1: )
|
||||||
|
err: Shifting token ( (1.1: )
|
||||||
|
err: Entering state 2
|
||||||
|
err: Stack now 0 2
|
||||||
|
err: Return for a new token:
|
||||||
|
err: Reading a token
|
||||||
|
err: Next token is token + (1.2: )
|
||||||
|
err: LAC: initial context established for +
|
||||||
|
err: LAC: checking lookahead +: Err
|
||||||
|
err: LAC: checking lookahead end of file: Err
|
||||||
|
err: LAC: checking lookahead +: Err
|
||||||
|
err: LAC: checking lookahead -: S1
|
||||||
|
err: LAC: checking lookahead *: Err
|
||||||
|
err: LAC: checking lookahead /: Err
|
||||||
|
err: LAC: checking lookahead ^: Err
|
||||||
|
err: LAC: checking lookahead (: S2
|
||||||
|
err: LAC: checking lookahead ): Err
|
||||||
|
err: LAC: checking lookahead =: Err
|
||||||
|
err: LAC: checking lookahead exit: Err
|
||||||
|
err: LAC: checking lookahead number: S4
|
||||||
|
err: LAC: checking lookahead function: S5
|
||||||
|
err: LAC: checking lookahead variable: S6
|
||||||
|
err: LAC: checking lookahead NEG: Err
|
||||||
|
err: 1.2: syntax error: expected - or ( or number or function or variable before +
|
||||||
|
err: LAC: initial context discarded due to error recovery
|
||||||
|
err: Shifting token error (1.2: )
|
||||||
|
err: Entering state 10
|
||||||
|
err: Stack now 0 2 10
|
||||||
|
err: Next token is token + (1.2: )
|
||||||
|
err: LAC: initial context established for +
|
||||||
|
err: LAC: checking lookahead +: Err
|
||||||
|
err: Error: discarding token + (1.2: )
|
||||||
|
err: Error: popping token error (1.2: )
|
||||||
|
err: Stack now 0 2
|
||||||
|
err: LAC: initial context discarded due to error recovery
|
||||||
|
err: Shifting token error (1.2: )
|
||||||
|
err: Entering state 10
|
||||||
|
err: Stack now 0 2 10
|
||||||
|
err: Return for a new token:
|
||||||
|
err: 1.3: syntax error: invalid character: _
|
||||||
|
err: Reading a token
|
||||||
|
err: Error: popping token error (1.2: )
|
||||||
|
err: Stack now 0 2
|
||||||
|
err: Shifting token error (1.2-3: )
|
||||||
|
err: Entering state 10
|
||||||
|
err: Stack now 0 2 10
|
||||||
|
err: Next token is token invalid token (1.3: )
|
||||||
|
err: LAC: initial context established for invalid token
|
||||||
|
err: LAC: checking lookahead invalid token: Always Err
|
||||||
|
err: Error: discarding token invalid token (1.3: )
|
||||||
|
err: Error: popping token error (1.2-3: )
|
||||||
|
err: Stack now 0 2
|
||||||
|
err: LAC: initial context discarded due to error recovery
|
||||||
|
err: Shifting token error (1.2-3: )
|
||||||
|
err: Entering state 10
|
||||||
|
err: Stack now 0 2 10
|
||||||
|
err: Return for a new token:
|
||||||
|
err: Reading a token
|
||||||
|
err: Next token is token ) (1.4: )
|
||||||
|
err: Shifting token ) (1.4: )
|
||||||
|
err: Entering state 20
|
||||||
|
err: Stack now 0 2 10 20
|
||||||
|
err: Reducing stack by rule 15 (line 151):
|
||||||
|
err: $1 = token ( (1.1: )
|
||||||
|
err: $2 = token error (1.2-3: )
|
||||||
|
err: $3 = token ) (1.4: )
|
||||||
|
err: -> $$ = nterm exp (1.1-4: 666)
|
||||||
|
err: Entering state 7
|
||||||
|
err: Stack now 0 7
|
||||||
|
err: Return for a new token:
|
||||||
|
err: Reading a token
|
||||||
|
err: Now at end of input.
|
||||||
|
err: LAC: initial context established for end of file
|
||||||
|
err: LAC: checking lookahead end of file: R2 G8 S19
|
||||||
|
err: Reducing stack by rule 2 (line 126):
|
||||||
|
err: $1 = nterm exp (1.1-4: 666)
|
||||||
|
err: -> $$ = nterm input (1.1-4: )
|
||||||
|
err: Entering state 8
|
||||||
|
err: Stack now 0 8
|
||||||
|
err: Now at end of input.
|
||||||
|
err: Shifting token end of file (1.5: )
|
||||||
|
err: LAC: initial context discarded due to shift
|
||||||
|
err: Entering state 19
|
||||||
|
err: Stack now 0 8 19
|
||||||
|
err: Stack now 0 8 19
|
||||||
|
err: Cleanup: popping token end of file (1.5: )
|
||||||
|
err: Cleanup: popping nterm input (1.1-4: )' -p
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------ ##
|
||||||
|
## Completion. ##
|
||||||
|
## ------------ ##
|
||||||
|
|
||||||
|
# From now on, the differences between versions of GNU Readline are
|
||||||
|
# too painful to try to cope with.
|
||||||
|
if $strip_prompt; then
|
||||||
|
echo "SKIP: this is not the GNU Readline we expect"
|
||||||
|
exit $status
|
||||||
|
fi
|
||||||
|
|
||||||
|
# On Windows10/MSYS2 the ^G coming from <tab> completion is not
|
||||||
|
# emitted the same way
|
||||||
|
# (https://lists.gnu.org/r/bug-bison/2020-05/msg00076.html).
|
||||||
|
echo "checking for kernel name... $(uname -s)"
|
||||||
|
case $(uname -s) in
|
||||||
|
(MSYS*)
|
||||||
|
echo "SKIP: this is Windows/MSYS"
|
||||||
|
exit $status
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
# Check completion after an operator.
|
||||||
|
sed -e 's/\\t/ /g' >input <<EOF
|
||||||
|
(1+\t\t
|
||||||
|
EOF
|
||||||
|
run 0 '> (1+
|
||||||
|
( - atan cos exp ln number sin sqrt
|
||||||
|
> (1+
|
||||||
|
> ''
|
||||||
|
err: 1.4: syntax error: expected - or ( or number or function or variable before end of file'
|
||||||
|
|
||||||
|
# Check the completion of a word.
|
||||||
|
sed -e 's/\\t/ /g' >input <<EOF
|
||||||
|
(at\t\t
|
||||||
|
EOF
|
||||||
|
run 0 '> (atan ( ''
|
||||||
|
> ''
|
||||||
|
err: 1.9: syntax error: expected - or ( or number or function or variable before end of file'
|
||||||
|
|
||||||
|
# Check the completion at the very beginning.
|
||||||
|
sed -e 's/\\t/ /g' >input <<EOF
|
||||||
|
e\t\t
|
||||||
|
EOF
|
||||||
|
run -n 0 '> e
|
||||||
|
end of file exit exp ''
|
||||||
|
> e
|
||||||
|
0
|
||||||
|
> ''
|
||||||
|
err: '
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
## Copyright (C) 2020 Free Software Foundation, Inc.
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
bistromathicdir = $(docdir)/%D%
|
||||||
|
|
||||||
|
## --------------- ##
|
||||||
|
## Bistromathics. ##
|
||||||
|
## --------------- ##
|
||||||
|
|
||||||
|
%D%/parse.c: $(dependencies)
|
||||||
|
|
||||||
|
if ENABLE_BISTROMATHIC
|
||||||
|
check_PROGRAMS += %D%/bistromathic
|
||||||
|
TESTS += %D%/bistromathic.test
|
||||||
|
nodist_%C%_bistromathic_SOURCES = %D%/parse.y
|
||||||
|
|
||||||
|
# Don't use gnulib's system headers.
|
||||||
|
%C%_bistromathic_CPPFLAGS = \
|
||||||
|
-DBISON_LOCALEDIR='"$(localdir)"' \
|
||||||
|
-DLOCALEDIR='"$(localdir)"' \
|
||||||
|
-I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||||
|
%C%_bistromathic_CFLAGS = $(TEST_CFLAGS)
|
||||||
|
%C%_bistromathic_LDADD = -lm $(LIBREADLINE) $(LIBINTL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST += %D%/bistromathic.test
|
||||||
|
dist_bistromathic_DATA = %D%/parse.y %D%/Makefile %D%/README.md
|
||||||
|
CLEANFILES += %D%/parse.[ch] %D%/parse.output
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
@@ -0,0 +1,601 @@
|
|||||||
|
%require "3.6"
|
||||||
|
|
||||||
|
%code top {
|
||||||
|
#include <ctype.h> // isdigit
|
||||||
|
#include <locale.h> // LC_ALL
|
||||||
|
#include <math.h> // cos, sin, etc.
|
||||||
|
#include <stdarg.h> // va_start
|
||||||
|
#include <stdio.h> // printf
|
||||||
|
#include <stdlib.h> // calloc
|
||||||
|
#include <string.h> // strcmp
|
||||||
|
|
||||||
|
#include <readline/readline.h>
|
||||||
|
#include <readline/history.h>
|
||||||
|
|
||||||
|
#if defined ENABLE_NLS && ENABLE_NLS
|
||||||
|
// Unable the translation of Bison's generated messages.
|
||||||
|
# define YYENABLE_NLS 1
|
||||||
|
# include <libintl.h>
|
||||||
|
// Unless specified otherwise, we expect bistromathic's own
|
||||||
|
// catalogue to be installed in the same tree as Bison's catalogue.
|
||||||
|
# ifndef LOCALEDIR
|
||||||
|
# define LOCALEDIR BISON_LOCALEDIR
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
%code requires {
|
||||||
|
// Function type.
|
||||||
|
typedef double (func_t) (double);
|
||||||
|
|
||||||
|
// Data type for links in the chain of symbols.
|
||||||
|
typedef struct symrec symrec;
|
||||||
|
struct symrec
|
||||||
|
{
|
||||||
|
char *name; // name of symbol
|
||||||
|
int type; // type of symbol: either VAR or FUN
|
||||||
|
union
|
||||||
|
{
|
||||||
|
double var; // value of a VAR
|
||||||
|
func_t *fun; // value of a FUN
|
||||||
|
} value;
|
||||||
|
symrec *next; // link field
|
||||||
|
};
|
||||||
|
|
||||||
|
symrec *putsym (char const *name, int sym_type);
|
||||||
|
symrec *getsym (char const *name);
|
||||||
|
}
|
||||||
|
|
||||||
|
%code provides {
|
||||||
|
# ifndef __attribute__
|
||||||
|
# ifndef __GNUC__
|
||||||
|
# define __attribute__(Spec) /* empty */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
int yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc);
|
||||||
|
void yyerror (YYLTYPE *loc, char const *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
}
|
||||||
|
|
||||||
|
%code {
|
||||||
|
#if defined ENABLE_NLS && ENABLE_NLS
|
||||||
|
# define _(Msgid) gettext (Msgid)
|
||||||
|
#else
|
||||||
|
# define _(Msgid) (Msgid)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Whether to quit.
|
||||||
|
int done = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't share global variables between the scanner and the parser.
|
||||||
|
%define api.pure full
|
||||||
|
|
||||||
|
// Generate a push parser.
|
||||||
|
%define api.push-pull push
|
||||||
|
|
||||||
|
// To avoid name clashes (e.g., with C's EOF) prefix token definitions
|
||||||
|
// with TOK_ (e.g., TOK_EOF).
|
||||||
|
%define api.token.prefix {TOK_}
|
||||||
|
|
||||||
|
// Customized syntax error messages (see yyreport_syntax_error).
|
||||||
|
%define parse.error custom
|
||||||
|
|
||||||
|
// with locations.
|
||||||
|
%locations
|
||||||
|
|
||||||
|
// and accurate list of expected tokens.
|
||||||
|
%define parse.lac full
|
||||||
|
|
||||||
|
// Generate the parser description file (calc.output).
|
||||||
|
%verbose
|
||||||
|
|
||||||
|
// Generate YYSTYPE from the types assigned to symbols.
|
||||||
|
%define api.value.type union
|
||||||
|
%token
|
||||||
|
PLUS "+"
|
||||||
|
MINUS "-"
|
||||||
|
STAR "*"
|
||||||
|
SLASH "/"
|
||||||
|
CARET "^"
|
||||||
|
LPAREN "("
|
||||||
|
RPAREN ")"
|
||||||
|
EQUAL "="
|
||||||
|
EXIT "exit"
|
||||||
|
<double>
|
||||||
|
NUM _("number")
|
||||||
|
<symrec*>
|
||||||
|
FUN _("function")
|
||||||
|
VAR _("variable")
|
||||||
|
|
||||||
|
%nterm <double> exp
|
||||||
|
|
||||||
|
// Enable run-time traces (yydebug).
|
||||||
|
%define parse.trace
|
||||||
|
|
||||||
|
// Formatting semantic values in debug traces.
|
||||||
|
%printer { fprintf (yyo, "%s", $$->name); } VAR;
|
||||||
|
%printer { fprintf (yyo, "%s()", $$->name); } FUN;
|
||||||
|
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||||
|
|
||||||
|
|
||||||
|
// Precedence (from lowest to highest) and associativity.
|
||||||
|
%precedence "="
|
||||||
|
%left "+" "-"
|
||||||
|
%left "*" "/"
|
||||||
|
%precedence NEG // negation--unary minus
|
||||||
|
%right "^" // exponentiation
|
||||||
|
|
||||||
|
%% // The grammar follows.
|
||||||
|
input:
|
||||||
|
%empty
|
||||||
|
| exp { printf ("%.10g\n", $exp); }
|
||||||
|
| "exit" { done = 1; }
|
||||||
|
;
|
||||||
|
|
||||||
|
exp:
|
||||||
|
NUM
|
||||||
|
| VAR { $$ = $VAR->value.var; }
|
||||||
|
| VAR "=" exp { $$ = $3; $VAR->value.var = $3; }
|
||||||
|
| FUN "(" exp ")" { $$ = $FUN->value.fun ($3); }
|
||||||
|
| exp[l] "+" exp[r] { $$ = $l + $r; }
|
||||||
|
| exp[l] "-" exp[r] { $$ = $l - $r; }
|
||||||
|
| exp[l] "*" exp[r] { $$ = $l * $r; }
|
||||||
|
| exp[l] "/" exp[r]
|
||||||
|
{
|
||||||
|
if ($r == 0)
|
||||||
|
{
|
||||||
|
yyerror (&@$, "error: division by zero");
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$$ = $l / $r;
|
||||||
|
}
|
||||||
|
| "-" exp %prec NEG { $$ = -$2; }
|
||||||
|
| exp[l] "^" exp[r] { $$ = pow ($l, $r); }
|
||||||
|
| "(" exp ")" { $$ = $2; }
|
||||||
|
| "(" error ")" { $$ = 666; }
|
||||||
|
;
|
||||||
|
|
||||||
|
// End of grammar.
|
||||||
|
%%
|
||||||
|
|
||||||
|
/*------------.
|
||||||
|
| Functions. |
|
||||||
|
`------------*/
|
||||||
|
|
||||||
|
struct init
|
||||||
|
{
|
||||||
|
char const *name;
|
||||||
|
func_t *fun;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct init const funs[] =
|
||||||
|
{
|
||||||
|
{ "atan", atan },
|
||||||
|
{ "cos", cos },
|
||||||
|
{ "exp", exp },
|
||||||
|
{ "ln", log },
|
||||||
|
{ "sin", sin },
|
||||||
|
{ "sqrt", sqrt },
|
||||||
|
{ 0, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
// The symbol table: a chain of 'struct symrec'.
|
||||||
|
static symrec *sym_table;
|
||||||
|
|
||||||
|
// Put functions in table.
|
||||||
|
static void
|
||||||
|
init_table (void)
|
||||||
|
{
|
||||||
|
for (int i = 0; funs[i].name; i++)
|
||||||
|
{
|
||||||
|
symrec *ptr = putsym (funs[i].name, TOK_FUN);
|
||||||
|
ptr->value.fun = funs[i].fun;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
symrec *
|
||||||
|
putsym (char const *name, int sym_type)
|
||||||
|
{
|
||||||
|
symrec *res = (symrec *) malloc (sizeof (symrec));
|
||||||
|
res->name = strdup (name);
|
||||||
|
res->type = sym_type;
|
||||||
|
res->value.var = 0; // Set value to 0 even if fun.
|
||||||
|
res->next = sym_table;
|
||||||
|
sym_table = res;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
symrec *
|
||||||
|
getsym (char const *name)
|
||||||
|
{
|
||||||
|
for (symrec *p = sym_table; p; p = p->next)
|
||||||
|
if (strcmp (p->name, name) == 0)
|
||||||
|
return p;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// How many symbols are registered.
|
||||||
|
static int
|
||||||
|
symbol_count (void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
for (symrec *p = sym_table; p; p = p->next)
|
||||||
|
++res;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------.
|
||||||
|
| Scanner. |
|
||||||
|
`----------*/
|
||||||
|
|
||||||
|
int
|
||||||
|
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
// Ignore white space, get first nonwhite character.
|
||||||
|
do {
|
||||||
|
// Move the first position onto the last.
|
||||||
|
yylloc->first_line = yylloc->last_line;
|
||||||
|
yylloc->first_column = yylloc->last_column;
|
||||||
|
|
||||||
|
yylloc->last_column += 1;
|
||||||
|
c = *((*line)++);
|
||||||
|
} while (c == ' ' || c == '\t');
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '+': return TOK_PLUS;
|
||||||
|
case '-': return TOK_MINUS;
|
||||||
|
case '*': return TOK_STAR;
|
||||||
|
case '/': return TOK_SLASH;
|
||||||
|
case '^': return TOK_CARET;
|
||||||
|
case '=': return TOK_EQUAL;
|
||||||
|
case '(': return TOK_LPAREN;
|
||||||
|
case ')': return TOK_RPAREN;
|
||||||
|
|
||||||
|
case '!': return TOK_YYUNDEF;
|
||||||
|
|
||||||
|
case '\0': return TOK_YYEOF;
|
||||||
|
|
||||||
|
// Numbers.
|
||||||
|
case '.':
|
||||||
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
|
{
|
||||||
|
int nchars = 0;
|
||||||
|
sscanf (*line - 1, "%lf%n", &yylval->TOK_NUM, &nchars);
|
||||||
|
*line += nchars - 1;
|
||||||
|
yylloc->last_column += nchars - 1;
|
||||||
|
return TOK_NUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identifiers.
|
||||||
|
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||||
|
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||||
|
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||||
|
case 'p': case 'q': case 'r': case 's': case 't':
|
||||||
|
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||||
|
case 'z':
|
||||||
|
{
|
||||||
|
int nchars = 0;
|
||||||
|
char buf[100];
|
||||||
|
sscanf (*line - 1, "%99[a-z]%n", buf, &nchars);
|
||||||
|
*line += nchars - 1;
|
||||||
|
yylloc->last_column += nchars - 1;
|
||||||
|
if (strcmp (buf, "exit") == 0)
|
||||||
|
return TOK_EXIT;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
symrec *s = getsym (buf);
|
||||||
|
if (!s)
|
||||||
|
s = putsym (buf, TOK_VAR);
|
||||||
|
yylval->TOK_VAR = s;
|
||||||
|
return s->type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stray characters.
|
||||||
|
default:
|
||||||
|
yyerror (yylloc, "syntax error: invalid character: %c", c);
|
||||||
|
return TOK_YYerror;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------.
|
||||||
|
| Parser. |
|
||||||
|
`---------*/
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
error_format_string (int argc)
|
||||||
|
{
|
||||||
|
switch (argc)
|
||||||
|
{
|
||||||
|
default: // Avoid compiler warnings.
|
||||||
|
case 0: return _("%@: syntax error");
|
||||||
|
case 1: return _("%@: syntax error: unexpected %u");
|
||||||
|
// TRANSLATORS: '%@' is a location in a file, '%u' is an
|
||||||
|
// "unexpected token", and '%0e', '%1e'... are expected tokens
|
||||||
|
// at this point.
|
||||||
|
//
|
||||||
|
// For instance on the expression "1 + * 2", you'd get
|
||||||
|
//
|
||||||
|
// 1.5: syntax error: expected - or ( or number or function or variable before *
|
||||||
|
case 2: return _("%@: syntax error: expected %0e before %u");
|
||||||
|
case 3: return _("%@: syntax error: expected %0e or %1e before %u");
|
||||||
|
case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
|
||||||
|
case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
|
||||||
|
case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
|
||||||
|
case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
|
||||||
|
case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e etc., before %u");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||||
|
{
|
||||||
|
enum { ARGS_MAX = 6 };
|
||||||
|
yysymbol_kind_t arg[ARGS_MAX];
|
||||||
|
int argsize = yypcontext_expected_tokens (ctx, arg, ARGS_MAX);
|
||||||
|
if (argsize < 0)
|
||||||
|
return argsize;
|
||||||
|
const int too_many_expected_tokens = argsize == 0 && arg[0] != YYSYMBOL_YYEMPTY;
|
||||||
|
if (too_many_expected_tokens)
|
||||||
|
argsize = ARGS_MAX;
|
||||||
|
const char *format = error_format_string (1 + argsize + too_many_expected_tokens);
|
||||||
|
|
||||||
|
while (*format)
|
||||||
|
// %@: location.
|
||||||
|
if (format[0] == '%' && format[1] == '@')
|
||||||
|
{
|
||||||
|
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||||
|
format += 2;
|
||||||
|
}
|
||||||
|
// %u: unexpected token.
|
||||||
|
else if (format[0] == '%' && format[1] == 'u')
|
||||||
|
{
|
||||||
|
fputs (yysymbol_name (yypcontext_token (ctx)), stderr);
|
||||||
|
format += 2;
|
||||||
|
}
|
||||||
|
// %0e, %1e...: expected token.
|
||||||
|
else if (format[0] == '%'
|
||||||
|
&& isdigit ((unsigned char) format[1])
|
||||||
|
&& format[2] == 'e'
|
||||||
|
&& (format[1] - '0') < argsize)
|
||||||
|
{
|
||||||
|
int i = format[1] - '0';
|
||||||
|
fputs (yysymbol_name (arg[i]), stderr);
|
||||||
|
format += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fputc (*format, stderr);
|
||||||
|
++format;
|
||||||
|
}
|
||||||
|
fputc ('\n', stderr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Called by yyparse on error.
|
||||||
|
void yyerror (YYLTYPE *loc, char const *format, ...)
|
||||||
|
{
|
||||||
|
YY_LOCATION_PRINT (stderr, *loc);
|
||||||
|
fputs (": ", stderr);
|
||||||
|
va_list args;
|
||||||
|
va_start (args, format);
|
||||||
|
vfprintf (stderr, format, args);
|
||||||
|
va_end (args);
|
||||||
|
putc ('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Return a newly allocated copy of at most N bytes of STRING. In
|
||||||
|
// other words, return a copy of the initial segment of length N of
|
||||||
|
// STRING.
|
||||||
|
static char *
|
||||||
|
xstrndup (const char *string, size_t n)
|
||||||
|
{
|
||||||
|
// len = strnlen (string, n), portably.
|
||||||
|
const char *end = memchr (string, '\0', n);
|
||||||
|
size_t len = end ? (size_t) (end - string) : n;
|
||||||
|
char *new = malloc (len + 1);
|
||||||
|
if (!new)
|
||||||
|
abort ();
|
||||||
|
new[len] = '\0';
|
||||||
|
return memcpy (new, string, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------.
|
||||||
|
| Readline. |
|
||||||
|
`-----------*/
|
||||||
|
|
||||||
|
// Parse (and execute) this line.
|
||||||
|
static int
|
||||||
|
process_line (YYLTYPE *lloc, const char *line)
|
||||||
|
{
|
||||||
|
yypstate *ps = yypstate_new ();
|
||||||
|
int status = 0;
|
||||||
|
do {
|
||||||
|
YYSTYPE lval;
|
||||||
|
status = yypush_parse (ps, yylex (&line, &lval, lloc), &lval, lloc);
|
||||||
|
} while (status == YYPUSH_MORE);
|
||||||
|
yypstate_delete (ps);
|
||||||
|
lloc->last_line++;
|
||||||
|
lloc->last_column = 1;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the list of possible tokens after INPUT was read.
|
||||||
|
// Returns a nonnegative.
|
||||||
|
static int
|
||||||
|
expected_tokens (const char *input,
|
||||||
|
int *tokens, int ntokens)
|
||||||
|
{
|
||||||
|
YYDPRINTF ((stderr, "expected_tokens (\"%s\")", input));
|
||||||
|
|
||||||
|
// Parse the current state of the line.
|
||||||
|
yypstate *ps = yypstate_new ();
|
||||||
|
int status = 0;
|
||||||
|
do {
|
||||||
|
YYLTYPE lloc;
|
||||||
|
YYSTYPE lval;
|
||||||
|
int token = yylex (&input, &lval, &lloc);
|
||||||
|
// Don't let the parse know when we reach the end of input.
|
||||||
|
if (!token)
|
||||||
|
break;
|
||||||
|
status = yypush_parse (ps, token, &lval, &lloc);
|
||||||
|
} while (status == YYPUSH_MORE);
|
||||||
|
|
||||||
|
// Then query for the accepted tokens at this point.
|
||||||
|
int res = yypstate_expected_tokens (ps, tokens, ntokens);
|
||||||
|
if (res < 0)
|
||||||
|
abort ();
|
||||||
|
yypstate_delete (ps);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to complete on the contents of TEXT. START and END bound
|
||||||
|
// the region of rl_line_buffer that contains the word to complete.
|
||||||
|
// TEXT is the word to complete. We can use the entire contents of
|
||||||
|
// rl_line_buffer in case we want to do some simple parsing. Return
|
||||||
|
// the array of matches, or NULL if there aren't any.
|
||||||
|
static char **
|
||||||
|
completion (const char *text, int start, int end)
|
||||||
|
{
|
||||||
|
YYDPRINTF ((stderr, "completion (\"%.*s[%.*s]%s\")\n",
|
||||||
|
start, rl_line_buffer,
|
||||||
|
end - start, rl_line_buffer + start,
|
||||||
|
rl_line_buffer + end));
|
||||||
|
|
||||||
|
// Get list of token numbers.
|
||||||
|
int tokens[YYNTOKENS];
|
||||||
|
char *line = xstrndup (rl_line_buffer, (size_t) start);
|
||||||
|
int ntokens = expected_tokens (line, tokens, YYNTOKENS);
|
||||||
|
free (line);
|
||||||
|
|
||||||
|
// Build MATCHES, the list of possible completions.
|
||||||
|
const size_t len = strlen (text);
|
||||||
|
// Need initial prefix and final NULL.
|
||||||
|
char **matches
|
||||||
|
= calloc ((size_t) ntokens + (size_t) symbol_count () + 2, sizeof *matches);
|
||||||
|
if (!matches)
|
||||||
|
abort ();
|
||||||
|
int match = 1;
|
||||||
|
for (int i = 0; i < ntokens; ++i)
|
||||||
|
switch (tokens[i])
|
||||||
|
{
|
||||||
|
case YYSYMBOL_FUN:
|
||||||
|
for (symrec *s = sym_table; s; s = s->next)
|
||||||
|
if (s->type == TOK_FUN && strncmp (text, s->name, len) == 0)
|
||||||
|
matches[match++] = strdup (s->name);
|
||||||
|
break;
|
||||||
|
case YYSYMBOL_VAR:
|
||||||
|
for (symrec *s = sym_table; s; s = s->next)
|
||||||
|
if (s->type == TOK_VAR && strncmp (text, s->name, len) == 0)
|
||||||
|
matches[match++] = strdup (s->name);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const char* token = yysymbol_name (tokens[i]);
|
||||||
|
if (strncmp (text, token, len) == 0)
|
||||||
|
matches[match++] = strdup (token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the longest common prefix, and install it in matches[0], as
|
||||||
|
// required by readline.
|
||||||
|
if (match == 1)
|
||||||
|
matches[0] = strdup (text);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t lcplen = strlen (matches[1]);
|
||||||
|
for (int i = 2; i < match && lcplen; ++i)
|
||||||
|
for (size_t j = 0; j < lcplen; ++j)
|
||||||
|
if (matches[1][j] != matches[i][j])
|
||||||
|
lcplen = j;
|
||||||
|
matches[0] = xstrndup (matches[1], lcplen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yydebug)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "completion (\"%.*s[%.*s]%s\") = ",
|
||||||
|
start, rl_line_buffer,
|
||||||
|
end - start, rl_line_buffer + start,
|
||||||
|
rl_line_buffer + end);
|
||||||
|
for (int i = 1; matches[i]; ++i)
|
||||||
|
fprintf (stderr, "%s%s",
|
||||||
|
i == 1 ? "{" : ", ",
|
||||||
|
matches[i]);
|
||||||
|
fprintf (stderr, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't fall back to proposing file names.
|
||||||
|
rl_attempted_completion_over = 1;
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_readline (void)
|
||||||
|
{
|
||||||
|
// Allow conditional parsing of the ~/.inputrc file.
|
||||||
|
rl_readline_name = "bistromathic";
|
||||||
|
|
||||||
|
// Tell the completer that we want a crack first.
|
||||||
|
rl_attempted_completion_function = completion;
|
||||||
|
|
||||||
|
// The basic list of characters that signal a break between words
|
||||||
|
// for the completer routine.
|
||||||
|
rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(+-*/^)";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-------.
|
||||||
|
| Main. |
|
||||||
|
`-------*/
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char const* argv[])
|
||||||
|
{
|
||||||
|
#if defined ENABLE_NLS && ENABLE_NLS
|
||||||
|
// Set up internationalization.
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
// Use Bison's standard translation catalogue for error messages
|
||||||
|
// (the generated messages).
|
||||||
|
bindtextdomain ("bison-runtime", BISON_LOCALEDIR);
|
||||||
|
// The translation catalogue of bistromathic is actually included in
|
||||||
|
// Bison's. In your own project, use the name of your project.
|
||||||
|
bindtextdomain ("bison", LOCALEDIR);
|
||||||
|
textdomain ("bison");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Enable parse traces on option -p.
|
||||||
|
if (1 < argc && strcmp (argv[1], "-p") == 0)
|
||||||
|
yydebug = 1;
|
||||||
|
init_table ();
|
||||||
|
init_readline ();
|
||||||
|
YYLTYPE lloc = {1, 1, 1, 1};
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
char *line = readline ("> ");
|
||||||
|
if (!line)
|
||||||
|
{
|
||||||
|
// Finish the line started by the prompt.
|
||||||
|
putchar ('\n');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*line)
|
||||||
|
add_history (line);
|
||||||
|
process_line (&lloc, line);
|
||||||
|
free (line);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# This Makefile is designed to be simple and readable. It does not
|
||||||
|
# aim at portability. It requires GNU Make.
|
||||||
|
|
||||||
|
BASE = calc
|
||||||
|
BISON = bison
|
||||||
|
XSLTPROC = xsltproc
|
||||||
|
|
||||||
|
all: $(BASE)
|
||||||
|
|
||||||
|
%.c %.h %.xml %.gv: %.y
|
||||||
|
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||||
|
|
||||||
|
$(BASE): $(BASE).o
|
||||||
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
run: $(BASE)
|
||||||
|
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||||
|
./$<
|
||||||
|
|
||||||
|
html: $(BASE).html
|
||||||
|
%.html: %.xml
|
||||||
|
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(BASE) *.o $(BASE).[ch] $(BASE).output $(BASE).xml $(BASE).html $(BASE).gv
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(CLEANFILES)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# calc - calculator with Bison
|
||||||
|
|
||||||
|
This directory contains calc, the traditional example of using Bison to
|
||||||
|
build a simple calculator.
|
||||||
|
|
||||||
|
<!---
|
||||||
|
Local Variables:
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
|
--->
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1+2*3
|
||||||
|
EOF
|
||||||
|
run 0 7
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 - 2 - 3
|
||||||
|
EOF
|
||||||
|
run 0 -4
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
8 / 2 / 2
|
||||||
|
EOF
|
||||||
|
run 0 2
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
(1+2) * 3
|
||||||
|
EOF
|
||||||
|
run 0 9
|
||||||
|
# Check the traces.
|
||||||
|
run -noerr 0 9 -p
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1++2
|
||||||
|
EOF
|
||||||
|
run 0 "err: syntax error, unexpected '+', expecting number or '('"
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
%code top {
|
||||||
|
#include <ctype.h> /* isdigit. */
|
||||||
|
#include <stdio.h> /* printf. */
|
||||||
|
#include <stdlib.h> /* abort. */
|
||||||
|
#include <string.h> /* strcmp. */
|
||||||
|
|
||||||
|
int yylex (void);
|
||||||
|
void yyerror (char const *);
|
||||||
|
}
|
||||||
|
|
||||||
|
%define api.header.include {"calc.h"}
|
||||||
|
|
||||||
|
/* Generate YYSTYPE from the types used in %token and %type. */
|
||||||
|
%define api.value.type union
|
||||||
|
%token <double> NUM "number"
|
||||||
|
%type <double> expr term fact
|
||||||
|
|
||||||
|
/* Generate the parser description file (calc.output). */
|
||||||
|
%verbose
|
||||||
|
|
||||||
|
/* Nice error messages with details. */
|
||||||
|
%define parse.error detailed
|
||||||
|
|
||||||
|
/* Enable run-time traces (yydebug). */
|
||||||
|
%define parse.trace
|
||||||
|
|
||||||
|
/* Formatting semantic values in debug traces. */
|
||||||
|
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||||
|
|
||||||
|
%% /* The grammar follows. */
|
||||||
|
input:
|
||||||
|
%empty
|
||||||
|
| input line
|
||||||
|
;
|
||||||
|
|
||||||
|
line:
|
||||||
|
'\n'
|
||||||
|
| expr '\n' { printf ("%.10g\n", $1); }
|
||||||
|
| error '\n' { yyerrok; }
|
||||||
|
;
|
||||||
|
|
||||||
|
expr:
|
||||||
|
expr '+' term { $$ = $1 + $3; }
|
||||||
|
| expr '-' term { $$ = $1 - $3; }
|
||||||
|
| term
|
||||||
|
;
|
||||||
|
|
||||||
|
term:
|
||||||
|
term '*' fact { $$ = $1 * $3; }
|
||||||
|
| term '/' fact { $$ = $1 / $3; }
|
||||||
|
| fact
|
||||||
|
;
|
||||||
|
|
||||||
|
fact:
|
||||||
|
"number"
|
||||||
|
| '(' expr ')' { $$ = $2; }
|
||||||
|
;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int
|
||||||
|
yylex (void)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
/* Ignore white space, get first nonwhite character. */
|
||||||
|
while ((c = getchar ()) == ' ' || c == '\t')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (c == EOF)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Char starts a number => parse the number. */
|
||||||
|
if (c == '.' || isdigit (c))
|
||||||
|
{
|
||||||
|
ungetc (c, stdin);
|
||||||
|
if (scanf ("%lf", &yylval.NUM) != 1)
|
||||||
|
abort ();
|
||||||
|
return NUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Any other character is a token by itself. */
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called by yyparse on error. */
|
||||||
|
void
|
||||||
|
yyerror (char const *s)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char const* argv[])
|
||||||
|
{
|
||||||
|
/* Enable parse traces on option -p. */
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
if (!strcmp (argv[i], "-p"))
|
||||||
|
yydebug = 1;
|
||||||
|
return yyparse ();
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
## Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
calcdir = $(docdir)/%D%
|
||||||
|
|
||||||
|
## ------ ##
|
||||||
|
## Calc. ##
|
||||||
|
## ------ ##
|
||||||
|
|
||||||
|
check_PROGRAMS += %D%/calc
|
||||||
|
TESTS += %D%/calc.test
|
||||||
|
EXTRA_DIST += %D%/calc.test
|
||||||
|
nodist_%C%_calc_SOURCES = %D%/calc.y
|
||||||
|
%D%/calc.c: $(dependencies)
|
||||||
|
|
||||||
|
# Don't use gnulib's system headers.
|
||||||
|
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||||
|
%C%_calc_CFLAGS = $(TEST_CFLAGS)
|
||||||
|
|
||||||
|
dist_calc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
|
||||||
|
CLEANFILES += %D%/calc.[ch] %D%/calc.output %D%/scan.c
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
@@ -15,7 +15,7 @@ all: $(BASE)
|
|||||||
$(FLEX) $(FLEXFLAGS) -o$@ $<
|
$(FLEX) $(FLEXFLAGS) -o$@ $<
|
||||||
|
|
||||||
scan.o: parse.h
|
scan.o: parse.h
|
||||||
lexcalc: parse.o scan.o
|
$(BASE): parse.o scan.o
|
||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
run: $(BASE)
|
run: $(BASE)
|
||||||
|
|||||||
@@ -3,26 +3,22 @@
|
|||||||
This directory contains lexcalc, the traditional example of using Flex and
|
This directory contains lexcalc, the traditional example of using Flex and
|
||||||
Bison to build a simple calculator.
|
Bison to build a simple calculator.
|
||||||
|
|
||||||
|
It features detailed syntax errors with locations.
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
Local Variables:
|
Local Variables:
|
||||||
fill-column: 76
|
fill-column: 76
|
||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
End:
|
End:
|
||||||
|
|
||||||
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
it under the terms of the GNU General Public License as published by
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
any later version published by the Free Software Foundation; with no
|
||||||
(at your option) any later version.
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
This program is distributed in the hope that it will be useful,
|
Documentation License" file as part of this distribution.
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
--->
|
--->
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,3 +25,13 @@ cat >input <<EOF
|
|||||||
EOF
|
EOF
|
||||||
run 0 9
|
run 0 9
|
||||||
run -noerr 0 9 -p
|
run -noerr 0 9 -p
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
(1+2) *
|
||||||
|
EOF
|
||||||
|
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number'
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 / (2 - 2)
|
||||||
|
EOF
|
||||||
|
run 1 'err: 1.1-11: error: division by zero'
|
||||||
|
|||||||
+17
-12
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
## Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -15,18 +15,23 @@
|
|||||||
|
|
||||||
lexcalcdir = $(docdir)/%D%
|
lexcalcdir = $(docdir)/%D%
|
||||||
|
|
||||||
## ------ ##
|
## --------- ##
|
||||||
## Calc. ##
|
## LexCalc. ##
|
||||||
## ------ ##
|
## --------- ##
|
||||||
|
|
||||||
|
if FLEX_WORKS
|
||||||
|
check_PROGRAMS += %D%/lexcalc
|
||||||
|
TESTS += %D%/lexcalc.test
|
||||||
|
nodist_%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
|
||||||
|
# Don't use gnulib's system headers.
|
||||||
|
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||||
|
# Fighting warnings triggered by Flex is just too painful.
|
||||||
|
# %C%_lexcalc_CFLAGS = $(TEST_CFLAGS)
|
||||||
|
endif FLEX_WORKS
|
||||||
|
|
||||||
|
%D%/parse.c: $(dependencies)
|
||||||
|
|
||||||
check_PROGRAMS += %D%/lexcalc
|
|
||||||
TESTS += %D%/lexcalc.test
|
|
||||||
EXTRA_DIST += %D%/lexcalc.test
|
EXTRA_DIST += %D%/lexcalc.test
|
||||||
%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
|
|
||||||
|
|
||||||
# Don't use gnulib's system headers.
|
|
||||||
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
|
||||||
|
|
||||||
dist_lexcalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
|
dist_lexcalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
|
||||||
CLEANFILES += %D%/lexcalc %D%/*.o %D%/parse.c %D%/scan.c
|
CLEANFILES += %D%/parse.[ch] %D%/scan.c %D%/parse.output
|
||||||
CLEANDIRS += %D%/*.dSYM
|
CLEANDIRS += %D%/*.dSYM
|
||||||
|
|||||||
+35
-19
@@ -6,25 +6,40 @@
|
|||||||
{
|
{
|
||||||
// Tell Flex the expected prototype of yylex.
|
// Tell Flex the expected prototype of yylex.
|
||||||
#define YY_DECL \
|
#define YY_DECL \
|
||||||
enum yytokentype yylex (YYSTYPE* yylval, int *nerrs)
|
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc, int *nerrs)
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
void yyerror (int *nerrs, const char *msg);
|
void yyerror (YYLTYPE *loc, int *nerrs, const char *msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emitted on top of the implementation file.
|
// Emitted on top of the implementation file.
|
||||||
%code top
|
%code top
|
||||||
{
|
{
|
||||||
#include <stdio.h> /* printf. */
|
#include <stdio.h> // printf.
|
||||||
#include <stdlib.h> /* getenv. */
|
#include <stdlib.h> // getenv.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't share global variables between the scanner and the parser.
|
||||||
%define api.pure full
|
%define api.pure full
|
||||||
|
|
||||||
|
// To avoid name clashes (e.g., with C's EOF) prefix token definitions
|
||||||
|
// with TOK_ (e.g., TOK_EOF).
|
||||||
%define api.token.prefix {TOK_}
|
%define api.token.prefix {TOK_}
|
||||||
|
|
||||||
|
// %token and %type use genuine types (e.g., "%token <int>"). Let
|
||||||
|
// %bison define YYSTYPE as a union of all these types.
|
||||||
%define api.value.type union
|
%define api.value.type union
|
||||||
%define parse.error verbose
|
|
||||||
|
// Generate detailed error messages.
|
||||||
|
%define parse.error detailed
|
||||||
|
|
||||||
|
// with locations.
|
||||||
|
%locations
|
||||||
|
|
||||||
|
// Enable debug traces (see yydebug in main).
|
||||||
%define parse.trace
|
%define parse.trace
|
||||||
// Error count, exchanged between main, yyparse and yylex.
|
|
||||||
|
// Error count, exchanged between main, yyparse and yylex.
|
||||||
%param {int *nerrs}
|
%param {int *nerrs}
|
||||||
|
|
||||||
%token
|
%token
|
||||||
@@ -34,12 +49,11 @@
|
|||||||
SLASH "/"
|
SLASH "/"
|
||||||
LPAREN "("
|
LPAREN "("
|
||||||
RPAREN ")"
|
RPAREN ")"
|
||||||
EOL "end-of-line"
|
EOL "end of line"
|
||||||
EOF 0 "end-of-file"
|
|
||||||
;
|
;
|
||||||
|
|
||||||
%token <int> NUM "number"
|
%token <int> NUM "number"
|
||||||
%type <int> exp line
|
%type <int> exp
|
||||||
%printer { fprintf (yyo, "%d", $$); } <int>
|
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||||
|
|
||||||
// Precedence (from lowest to highest) and associativity.
|
// Precedence (from lowest to highest) and associativity.
|
||||||
@@ -50,37 +64,39 @@
|
|||||||
// Rules.
|
// Rules.
|
||||||
input:
|
input:
|
||||||
%empty
|
%empty
|
||||||
| input line { printf ("%d\n", $line); }
|
| input line
|
||||||
;
|
;
|
||||||
|
|
||||||
line:
|
line:
|
||||||
exp EOL { $$ = $1; }
|
exp EOL { printf ("%d\n", $exp); }
|
||||||
| error EOL { yyerrok; }
|
| error EOL { yyerrok; }
|
||||||
;
|
;
|
||||||
|
|
||||||
exp:
|
exp:
|
||||||
exp "+" exp { $$ = $1 + $3; }
|
exp "+" exp { $$ = $1 + $3; }
|
||||||
| exp "-" exp { $$ = $1 - $3; }
|
| exp "-" exp { $$ = $1 - $3; }
|
||||||
| exp "*" exp { $$ = $1 * $3; }
|
| exp "*" exp { $$ = $1 * $3; }
|
||||||
| exp "/" exp
|
| exp "/" exp
|
||||||
{
|
{
|
||||||
if ($3 == 0)
|
if ($3 == 0)
|
||||||
{
|
{
|
||||||
yyerror (nerrs, "invalid division by zero");
|
yyerror (&@$, nerrs, "error: division by zero");
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$$ = $1 / $3;
|
$$ = $1 / $3;
|
||||||
}
|
}
|
||||||
| "(" exp ")" { $$ = $2; }
|
| "(" exp ")" { $$ = $2; }
|
||||||
| NUM { $$ = $1; }
|
| NUM { $$ = $1; }
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
// Epilogue (C code).
|
// Epilogue (C code).
|
||||||
void yyerror(int *nerrs, const char *msg)
|
|
||||||
|
void yyerror (YYLTYPE *loc, int *nerrs, const char *msg)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s\n", msg);
|
YY_LOCATION_PRINT (stderr, *loc);
|
||||||
++nerrs;
|
fprintf (stderr, ": %s\n", msg);
|
||||||
|
++*nerrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
|
|||||||
@@ -1,16 +1,32 @@
|
|||||||
/* Prologue (directives). -*- C++ -*- */
|
/* Prologue (directives). -*- C -*- */
|
||||||
|
|
||||||
/* Disable Flex features we don't need, to avoid warnings. */
|
/* Disable Flex features we don't need, to avoid warnings. */
|
||||||
%option nodefault noinput nounput noyywrap
|
%option nodefault noinput nounput noyywrap
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <errno.h> /* errno, ERANGE */
|
||||||
#include <limits.h> /* INT_MIN */
|
#include <limits.h> /* INT_MIN */
|
||||||
#include <stdlib.h> /* strtol */
|
#include <stdlib.h> /* strtol */
|
||||||
|
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
|
||||||
|
// Each time a rule is matched, advance the end cursor/position.
|
||||||
|
#define YY_USER_ACTION \
|
||||||
|
yylloc->last_column += (int) yyleng;
|
||||||
|
|
||||||
|
// Move the first position onto the last.
|
||||||
|
#define LOCATION_STEP() \
|
||||||
|
do { \
|
||||||
|
yylloc->first_line = yylloc->last_line; \
|
||||||
|
yylloc->first_column = yylloc->last_column; \
|
||||||
|
} while (0)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
%{
|
||||||
|
// Each time yylex is called, move the head position to the end one.
|
||||||
|
LOCATION_STEP ();
|
||||||
|
%}
|
||||||
/* Rules. */
|
/* Rules. */
|
||||||
|
|
||||||
"+" return TOK_PLUS;
|
"+" return TOK_PLUS;
|
||||||
@@ -26,18 +42,18 @@
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
long n = strtol (yytext, NULL, 10);
|
long n = strtol (yytext, NULL, 10);
|
||||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||||
yyerror (nerrs, "integer is out of range");
|
yyerror (yylloc, nerrs, "integer is out of range");
|
||||||
yylval->TOK_NUM = (int) n;
|
yylval->TOK_NUM = (int) n;
|
||||||
return TOK_NUM;
|
return TOK_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"\n" yylloc->last_line++; yylloc->last_column = 1; return TOK_EOL;
|
||||||
|
|
||||||
/* Ignore white spaces. */
|
/* Ignore white spaces. */
|
||||||
[ \t]+ continue;
|
[ \t]+ LOCATION_STEP (); continue;
|
||||||
|
|
||||||
"\n" return TOK_EOL;
|
. yyerror (yylloc, nerrs, "syntax error, invalid character"); continue;
|
||||||
|
|
||||||
. yyerror (nerrs, "syntax error, invalid character");
|
<<EOF>> return TOK_YYEOF;
|
||||||
|
|
||||||
<<EOF>> return TOK_EOF;
|
|
||||||
%%
|
%%
|
||||||
/* Epilogue (C code). */
|
/* Epilogue (C code). */
|
||||||
|
|||||||
+5
-1
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
## Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
cdir = $(docdir)/%D%
|
cdir = $(docdir)/%D%
|
||||||
dist_c_DATA = %D%/README.md
|
dist_c_DATA = %D%/README.md
|
||||||
|
|
||||||
|
include %D%/bistromathic/local.mk
|
||||||
|
include %D%/calc/local.mk
|
||||||
include %D%/lexcalc/local.mk
|
include %D%/lexcalc/local.mk
|
||||||
include %D%/mfcalc/local.mk
|
include %D%/mfcalc/local.mk
|
||||||
|
include %D%/pushcalc/local.mk
|
||||||
|
include %D%/reccalc/local.mk
|
||||||
include %D%/rpcalc/local.mk
|
include %D%/rpcalc/local.mk
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2005-2006, 2008-2015, 2018-2019 Free Software
|
## Copyright (C) 2005-2006, 2008-2015, 2018-2020 Free Software
|
||||||
## Foundation, Inc.
|
## Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software: you can redistribute it and/or modify
|
## This program is free software: you can redistribute it and/or modify
|
||||||
@@ -28,8 +28,10 @@ extracted += $(mfcalc_extracted)
|
|||||||
|
|
||||||
check_PROGRAMS += %D%/mfcalc
|
check_PROGRAMS += %D%/mfcalc
|
||||||
nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
|
nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
|
||||||
|
%D%/mfcalc.c: $(dependencies)
|
||||||
# Don't use gnulib's system headers.
|
# Don't use gnulib's system headers.
|
||||||
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||||
|
%C%_mfcalc_CFLAGS = $(TEST_CFLAGS)
|
||||||
%C%_mfcalc_LDADD = -lm
|
%C%_mfcalc_LDADD = -lm
|
||||||
|
|
||||||
dist_TESTS += %D%/mfcalc.test
|
dist_TESTS += %D%/mfcalc.test
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2005-2015, 2018-2019 Free Software Foundation, Inc.
|
# Copyright (C) 2005-2015, 2018-2020 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,3 +25,15 @@ cat >input <<EOF
|
|||||||
EOF
|
EOF
|
||||||
run 0 9
|
run 0 9
|
||||||
run -noerr 0 9 -p
|
run -noerr 0 9 -p
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
a = 256
|
||||||
|
sqrt (a)
|
||||||
|
EOF
|
||||||
|
run 0 '256
|
||||||
|
16'
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
16 == 12
|
||||||
|
EOF
|
||||||
|
run 0 'err: syntax error'
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# This Makefile is designed to be simple and readable. It does not
|
||||||
|
# aim at portability. It requires GNU Make.
|
||||||
|
|
||||||
|
BASE = calc
|
||||||
|
BISON = bison
|
||||||
|
XSLTPROC = xsltproc
|
||||||
|
|
||||||
|
all: $(BASE)
|
||||||
|
|
||||||
|
%.c %.h %.xml %.gv: %.y
|
||||||
|
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||||
|
|
||||||
|
$(BASE): $(BASE).o
|
||||||
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
run: $(BASE)
|
||||||
|
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||||
|
./$<
|
||||||
|
|
||||||
|
html: $(BASE).html
|
||||||
|
%.html: %.xml
|
||||||
|
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(BASE) *.o $(BASE).[ch] $(BASE).output $(BASE).xml $(BASE).html $(BASE).gv
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(CLEANFILES)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# pushcalc - push parser with Bison
|
||||||
|
|
||||||
|
This directory contains pushcalc, the traditional calculator, implemented as
|
||||||
|
a push parser.
|
||||||
|
|
||||||
|
Traditionally Bison is used to create so called "pull parsers": the user
|
||||||
|
invokes the parser once, which repeatedly calls (pulls) the scanner until
|
||||||
|
the input is drained.
|
||||||
|
|
||||||
|
This example demonstrates the "push parsers": the user calls scanner to
|
||||||
|
fetch the next token, passes (pushes) it to the parser, and repeats the
|
||||||
|
operation until the input is drained.
|
||||||
|
|
||||||
|
This example is a straightforward conversion of the 'calc' example to the
|
||||||
|
push-parser model.
|
||||||
|
|
||||||
|
<!---
|
||||||
|
Local Variables:
|
||||||
|
fill-column: 76
|
||||||
|
ispell-dictionary: "american"
|
||||||
|
End:
|
||||||
|
|
||||||
|
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the "GNU Free
|
||||||
|
Documentation License" file as part of this distribution.
|
||||||
|
|
||||||
|
--->
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2020 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1+2*3
|
||||||
|
EOF
|
||||||
|
run 0 7
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1 - 2 - 3
|
||||||
|
EOF
|
||||||
|
run 0 -4
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
8 / 2 / 2
|
||||||
|
EOF
|
||||||
|
run 0 2
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
(1+2) * 3
|
||||||
|
EOF
|
||||||
|
run 0 9
|
||||||
|
run -noerr 0 9 -p
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
1++2
|
||||||
|
EOF
|
||||||
|
run 0 "err: syntax error, unexpected '+', expecting number or '('"
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
%code top {
|
||||||
|
#include <ctype.h> /* isdigit. */
|
||||||
|
#include <stdio.h> /* printf. */
|
||||||
|
#include <stdlib.h> /* abort. */
|
||||||
|
#include <string.h> /* strcmp. */
|
||||||
|
}
|
||||||
|
|
||||||
|
%code {
|
||||||
|
int yylex (YYSTYPE *yylval);
|
||||||
|
void yyerror (char const *);
|
||||||
|
}
|
||||||
|
|
||||||
|
%define api.header.include {"calc.h"}
|
||||||
|
|
||||||
|
/* Generate YYSTYPE from the types used in %token and %type. */
|
||||||
|
%define api.value.type union
|
||||||
|
%token <double> NUM "number"
|
||||||
|
%type <double> expr term fact
|
||||||
|
|
||||||
|
/* Don't share global variables between the scanner and the parser. */
|
||||||
|
%define api.pure full
|
||||||
|
/* Generate a push parser. */
|
||||||
|
%define api.push-pull push
|
||||||
|
|
||||||
|
/* Nice error messages with details. */
|
||||||
|
%define parse.error detailed
|
||||||
|
|
||||||
|
/* Generate the parser description file (calc.output). */
|
||||||
|
%verbose
|
||||||
|
|
||||||
|
/* Enable run-time traces (yydebug). */
|
||||||
|
%define parse.trace
|
||||||
|
|
||||||
|
/* Formatting semantic values in debug traces. */
|
||||||
|
%printer { fprintf (yyo, "%g", $$); } <double>;
|
||||||
|
|
||||||
|
%% /* The grammar follows. */
|
||||||
|
input:
|
||||||
|
%empty
|
||||||
|
| input line
|
||||||
|
;
|
||||||
|
|
||||||
|
line:
|
||||||
|
'\n'
|
||||||
|
| expr '\n' { printf ("%.10g\n", $1); }
|
||||||
|
| error '\n' { yyerrok; }
|
||||||
|
;
|
||||||
|
|
||||||
|
expr:
|
||||||
|
expr '+' term { $$ = $1 + $3; }
|
||||||
|
| expr '-' term { $$ = $1 - $3; }
|
||||||
|
| term
|
||||||
|
;
|
||||||
|
|
||||||
|
term:
|
||||||
|
term '*' fact { $$ = $1 * $3; }
|
||||||
|
| term '/' fact { $$ = $1 / $3; }
|
||||||
|
| fact
|
||||||
|
;
|
||||||
|
|
||||||
|
fact:
|
||||||
|
"number"
|
||||||
|
| '(' expr ')' { $$ = $expr; }
|
||||||
|
;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int
|
||||||
|
yylex (YYSTYPE *yylval)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
/* Ignore white space, get first nonwhite character. */
|
||||||
|
while ((c = getchar ()) == ' ' || c == '\t')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (c == EOF)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Char starts a number => parse the number. */
|
||||||
|
if (c == '.' || isdigit (c))
|
||||||
|
{
|
||||||
|
ungetc (c, stdin);
|
||||||
|
if (scanf ("%lf", &yylval->NUM) != 1)
|
||||||
|
abort ();
|
||||||
|
return NUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Any other character is a token by itself. */
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called by yyparse on error. */
|
||||||
|
void
|
||||||
|
yyerror (char const *s)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char const* argv[])
|
||||||
|
{
|
||||||
|
/* Enable parse traces on option -p. */
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
if (!strcmp (argv[i], "-p"))
|
||||||
|
yydebug = 1;
|
||||||
|
int status;
|
||||||
|
yypstate *ps = yypstate_new ();
|
||||||
|
do {
|
||||||
|
YYSTYPE lval;
|
||||||
|
status = yypush_parse (ps, yylex (&lval), &lval);
|
||||||
|
} while (status == YYPUSH_MORE);
|
||||||
|
yypstate_delete (ps);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
## Copyright (C) 2020 Free Software Foundation, Inc.
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
pushcalcdir = $(docdir)/%D%
|
||||||
|
|
||||||
|
## ------ ##
|
||||||
|
## Calc. ##
|
||||||
|
## ------ ##
|
||||||
|
|
||||||
|
check_PROGRAMS += %D%/calc
|
||||||
|
TESTS += %D%/calc.test
|
||||||
|
EXTRA_DIST += %D%/calc.test
|
||||||
|
nodist_%C%_calc_SOURCES = %D%/calc.y
|
||||||
|
%D%/calc.c: $(dependencies)
|
||||||
|
|
||||||
|
# Don't use gnulib's system headers.
|
||||||
|
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
|
||||||
|
%C%_calc_CFLAGS = $(TEST_CFLAGS)
|
||||||
|
|
||||||
|
dist_pushcalc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
|
||||||
|
CLEANFILES += %D%/calc.[ch] %D%/calc.output
|
||||||
|
CLEANDIRS += %D%/*.dSYM
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user