]>
Commit | Line | Data |
---|---|---|
ed8e1f68 AD |
1 | # Exercising Bison Grammar Sets. -*- Autotest -*- |
2 | # Copyright 2001 Free Software Foundation, Inc. | |
3 | ||
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2, or (at your option) | |
7 | # any later version. | |
8 | ||
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | ||
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
17 | # 02111-1307, USA. | |
18 | ||
19 | AT_BANNER([[Grammar Sets (Firsts etc.).]]) | |
20 | ||
21 | ||
22 | ## ---------- ## | |
23 | ## Nullable. ## | |
24 | ## ---------- ## | |
25 | ||
26 | AT_SETUP([Nullable]) | |
27 | ||
28 | # At some point, nullable had been smoking grass, and managed to say: | |
29 | # | |
30 | # Entering set_nullable | |
31 | # NULLABLE | |
32 | # 'e': yes | |
33 | # (null): no | |
34 | # ... | |
35 | ||
36 | AT_DATA([[input.y]], | |
37 | [[%% | |
38 | e: 'e' | /* Nothing */; | |
39 | ]]) | |
40 | ||
30171f79 AD |
41 | AT_CHECK([[bison --trace input.y]], [], [], [stderr]) |
42 | ||
43 | AT_CHECK([[sed 's/[ ]*$//' stderr]], [], | |
ed8e1f68 | 44 | [[RITEM |
29d29c8f AD |
45 | e $ (rule 0) |
46 | 'e' (rule 1) | |
47 | (rule 2) | |
ed8e1f68 AD |
48 | |
49 | ||
50 | DERIVES | |
30171f79 | 51 | $axiom derives |
3d4daee3 | 52 | 1: e $ (rule 0) |
ed8e1f68 | 53 | e derives |
3d4daee3 AD |
54 | 2: 'e' (rule 1) |
55 | 3: (rule 2) | |
ed8e1f68 AD |
56 | |
57 | ||
58 | Entering set_nullable | |
59 | NULLABLE | |
3d4daee3 | 60 | $axiom: no |
ed8e1f68 AD |
61 | e: yes |
62 | ||
63 | ||
64 | TC: Input BEGIN | |
30171f79 AD |
65 | |
66 | 01 | |
67 | .--. | |
68 | 0| 1| | |
69 | 1| | | |
70 | `--' | |
ed8e1f68 AD |
71 | TC: Input END |
72 | ||
73 | TC: Output BEGIN | |
30171f79 AD |
74 | |
75 | 01 | |
76 | .--. | |
77 | 0| 1| | |
78 | 1| | | |
79 | `--' | |
ed8e1f68 AD |
80 | TC: Output END |
81 | ||
82 | FIRSTS | |
30171f79 AD |
83 | $axiom firsts |
84 | 4 ($axiom) | |
85 | 5 (e) | |
ed8e1f68 | 86 | e firsts |
30171f79 | 87 | 5 (e) |
ed8e1f68 AD |
88 | |
89 | ||
90 | FDERIVES | |
30171f79 | 91 | $axiom derives |
29d29c8f AD |
92 | 0: e $ |
93 | 1: 'e' | |
94 | 2: | |
ed8e1f68 | 95 | e derives |
29d29c8f AD |
96 | 1: 'e' |
97 | 2: | |
ed8e1f68 AD |
98 | |
99 | ||
100 | Processing state 0 (reached by $) | |
101 | Closure: input | |
102 | ||
103 | ||
104 | Closure: output | |
29d29c8f AD |
105 | 0: . e $ (rule 0) |
106 | 3: . 'e' (rule 1) | |
107 | 5: . (rule 2) | |
ed8e1f68 AD |
108 | |
109 | ||
110 | Entering new_itemsets, state = 0 | |
111 | Entering append_states, state = 0 | |
112 | Entering get_state, state = 0, symbol = 3 ('e') | |
113 | Entering new_state, state = 0, symbol = 3 ('e') | |
114 | Exiting get_state => 1 | |
30171f79 AD |
115 | Entering get_state, state = 0, symbol = 5 (e) |
116 | Entering new_state, state = 0, symbol = 5 (e) | |
117 | Exiting get_state => 2 | |
ed8e1f68 AD |
118 | Processing state 1 (reached by 'e') |
119 | Closure: input | |
29d29c8f | 120 | 4: . (rule 1) |
ed8e1f68 AD |
121 | |
122 | ||
123 | Closure: output | |
29d29c8f | 124 | 4: . (rule 1) |
ed8e1f68 AD |
125 | |
126 | ||
127 | Entering new_itemsets, state = 1 | |
128 | Entering append_states, state = 1 | |
30171f79 AD |
129 | Processing state 2 (reached by e) |
130 | Closure: input | |
29d29c8f | 131 | 1: . $ (rule 0) |
30171f79 AD |
132 | |
133 | ||
134 | Closure: output | |
29d29c8f | 135 | 1: . $ (rule 0) |
30171f79 AD |
136 | |
137 | ||
138 | Entering new_itemsets, state = 2 | |
139 | Entering append_states, state = 2 | |
140 | Entering get_state, state = 2, symbol = 0 ($) | |
141 | Entering new_state, state = 2, symbol = 0 ($) | |
142 | Exiting get_state => 3 | |
143 | Processing state 3 (reached by $) | |
144 | Closure: input | |
29d29c8f | 145 | 2: . (rule 0) |
30171f79 AD |
146 | |
147 | ||
148 | Closure: output | |
29d29c8f | 149 | 2: . (rule 0) |
30171f79 AD |
150 | |
151 | ||
152 | Entering new_itemsets, state = 3 | |
153 | Entering append_states, state = 3 | |
ed8e1f68 | 154 | transpose: input |
30171f79 | 155 | 0: |
ed8e1f68 AD |
156 | |
157 | transpose: output | |
30171f79 | 158 | 0: |
ed8e1f68 | 159 | |
7c6b64d0 | 160 | Lookaheads: BEGIN |
610ab194 AD |
161 | State 0: 1 lookaheads |
162 | on 0 ($) -> rule -4 | |
163 | on 1 (error) -> rule -4 | |
164 | on 2 ($undefined.) -> rule -4 | |
165 | on 3 ('e') -> rule -4 | |
7c6b64d0 AD |
166 | State 1: 0 lookaheads |
167 | State 2: 0 lookaheads | |
168 | State 3: 0 lookaheads | |
169 | Lookaheads: END | |
ed8e1f68 AD |
170 | ]]) |
171 | ||
172 | AT_CLEANUP | |
173 | ||
174 | ||
175 | ## ---------------- ## | |
176 | ## Broken Closure. ## | |
177 | ## ---------------- ## | |
178 | ||
179 | # TC was once broken during a massive `simplification' of the code. | |
180 | # It resulted in bison dumping core on the following grammar (the | |
181 | # computation of FIRSTS uses TC). It managed to produce a pretty | |
182 | # exotic closure: | |
183 | # | |
184 | # TC: Input | |
185 | # | |
186 | # 01234567 | |
187 | # +--------+ | |
188 | # 0| 1 | | |
189 | # 1| 1 | | |
190 | # 2| 1 | | |
191 | # 3| 1 | | |
192 | # 4| 1 | | |
193 | # 5| 1 | | |
194 | # 6| 1| | |
195 | # 7| | | |
196 | # +--------+ | |
197 | # | |
198 | # TC: Output | |
199 | # | |
200 | # 01234567 | |
201 | # +--------+ | |
202 | # 0| 1 | | |
203 | # 1| 111 | | |
204 | # 2| 111 | | |
205 | # 3| 1111 | | |
206 | # 4| 111 1 | | |
207 | # 5| 111 1 | | |
208 | # 6| 111 1| | |
209 | # 7| 111 | | |
210 | # +--------+ | |
211 | # | |
212 | # instead of that below. | |
213 | ||
214 | AT_SETUP([Broken Closure]) | |
215 | ||
216 | AT_DATA([input.y], | |
217 | [[%% | |
218 | a: b | |
219 | b: c | |
220 | c: d | |
221 | d: e | |
222 | e: f | |
223 | f: g | |
224 | g: h | |
225 | h: 'h' | |
226 | ]]) | |
227 | ||
30171f79 AD |
228 | AT_CHECK([[bison --trace input.y]], [], [], [stderr]) |
229 | ||
230 | AT_CHECK([[sed -n 's/[ ]*$//;/^TC: Output BEGIN/,/^TC: Output END/p' stderr]], [], | |
ed8e1f68 | 231 | [[TC: Output BEGIN |
30171f79 AD |
232 | |
233 | 012345678 | |
234 | .---------. | |
235 | 0| 11111111| | |
236 | 1| 1111111| | |
237 | 2| 111111| | |
238 | 3| 11111| | |
239 | 4| 1111| | |
240 | 5| 111| | |
241 | 6| 11| | |
242 | 7| 1| | |
243 | 8| | | |
244 | `---------' | |
ed8e1f68 AD |
245 | TC: Output END |
246 | ]]) | |
247 | ||
248 | AT_CLEANUP |