174 |
|
|
175 |
state 0 |
state 0 |
176 |
|
|
177 |
$axiom -> . exp $ (rule 0) |
0 $axiom: . exp $ |
178 |
exp -> . exp OP exp (rule 1) |
1 exp: . exp OP exp |
179 |
exp -> . NUM (rule 2) |
2 | . NUM |
180 |
|
|
181 |
NUM shift, and go to state 1 |
NUM shift, and go to state 1 |
182 |
|
|
186 |
|
|
187 |
state 1 |
state 1 |
188 |
|
|
189 |
exp -> NUM . (rule 2) |
2 exp: NUM . |
190 |
|
|
191 |
$default reduce using rule 2 (exp) |
$default reduce using rule 2 (exp) |
192 |
|
|
194 |
|
|
195 |
state 2 |
state 2 |
196 |
|
|
197 |
$axiom -> exp . $ (rule 0) |
0 $axiom: exp . $ |
198 |
exp -> exp . OP exp (rule 1) |
1 exp: exp . OP exp |
199 |
|
|
200 |
$ shift, and go to state 3 |
$ shift, and go to state 3 |
201 |
OP shift, and go to state 4 |
OP shift, and go to state 4 |
204 |
|
|
205 |
state 3 |
state 3 |
206 |
|
|
207 |
$axiom -> exp $ . (rule 0) |
0 $axiom: exp $ . |
208 |
|
|
209 |
$default accept |
$default accept |
210 |
|
|
211 |
|
|
212 |
state 4 |
state 4 |
213 |
|
|
214 |
exp -> . exp OP exp (rule 1) |
1 exp: . exp OP exp |
215 |
exp -> exp OP . exp (rule 1) |
1 | exp OP . exp |
216 |
exp -> . NUM (rule 2) |
2 | . NUM |
217 |
|
|
218 |
NUM shift, and go to state 1 |
NUM shift, and go to state 1 |
219 |
|
|
223 |
|
|
224 |
state 5 |
state 5 |
225 |
|
|
226 |
exp -> exp . OP exp [$, OP] (rule 1) |
1 exp: exp . OP exp [$, OP] |
227 |
exp -> exp OP exp . [$, OP] (rule 1) |
1 | exp OP exp . [$, OP] |
228 |
|
|
229 |
OP shift, and go to state 4 |
OP shift, and go to state 4 |
230 |
|
|
238 |
AT_CLEANUP |
AT_CLEANUP |
239 |
|
|
240 |
|
|
|
## ------------------------- ## |
|
|
## Unresolved SR Conflicts. ## |
|
|
## ------------------------- ## |
|
241 |
|
|
242 |
AT_SETUP([Unresolved SR Conflicts]) |
## ----------------------- ## |
243 |
|
## Resolved SR Conflicts. ## |
244 |
|
## ----------------------- ## |
245 |
|
|
246 |
|
AT_SETUP([Resolved SR Conflicts]) |
247 |
|
|
248 |
AT_KEYWORDS([report]) |
AT_KEYWORDS([report]) |
249 |
|
|
250 |
AT_DATA([input.y], |
AT_DATA([input.y], |
251 |
[[%token NUM OP |
[[%token NUM OP |
252 |
|
%left OP |
253 |
%% |
%% |
254 |
exp: exp OP exp | NUM; |
exp: exp OP exp | NUM; |
255 |
]]) |
]]) |
256 |
|
|
257 |
AT_CHECK([bison input.y -o input.c --report=all], 0, [], |
AT_CHECK([bison input.y -o input.c --report=all]) |
|
[input.y contains 1 shift/reduce conflict. |
|
|
]) |
|
258 |
|
|
259 |
# Check the contents of the report. |
# Check the contents of the report. |
260 |
AT_CHECK([cat input.output], [], |
AT_CHECK([cat input.output], [], |
261 |
[[State 5 contains 1 shift/reduce conflict. |
[[Grammar |
|
|
|
|
|
|
|
Grammar |
|
262 |
|
|
263 |
0 $axiom: exp $ |
0 $axiom: exp $ |
264 |
|
|
284 |
|
|
285 |
state 0 |
state 0 |
286 |
|
|
287 |
$axiom -> . exp $ (rule 0) |
0 $axiom: . exp $ |
288 |
exp -> . exp OP exp (rule 1) |
1 exp: . exp OP exp |
289 |
exp -> . NUM (rule 2) |
2 | . NUM |
290 |
|
|
291 |
NUM shift, and go to state 1 |
NUM shift, and go to state 1 |
292 |
|
|
296 |
|
|
297 |
state 1 |
state 1 |
298 |
|
|
299 |
exp -> NUM . (rule 2) |
2 exp: NUM . |
300 |
|
|
301 |
$default reduce using rule 2 (exp) |
$default reduce using rule 2 (exp) |
302 |
|
|
304 |
|
|
305 |
state 2 |
state 2 |
306 |
|
|
307 |
$axiom -> exp . $ (rule 0) |
0 $axiom: exp . $ |
308 |
exp -> exp . OP exp (rule 1) |
1 exp: exp . OP exp |
309 |
|
|
310 |
$ shift, and go to state 3 |
$ shift, and go to state 3 |
311 |
OP shift, and go to state 4 |
OP shift, and go to state 4 |
314 |
|
|
315 |
state 3 |
state 3 |
316 |
|
|
317 |
$axiom -> exp $ . (rule 0) |
0 $axiom: exp $ . |
318 |
|
|
319 |
$default accept |
$default accept |
320 |
|
|
321 |
|
|
322 |
state 4 |
state 4 |
323 |
|
|
324 |
exp -> . exp OP exp (rule 1) |
1 exp: . exp OP exp |
325 |
exp -> exp OP . exp (rule 1) |
1 | exp OP . exp |
326 |
exp -> . NUM (rule 2) |
2 | . NUM |
327 |
|
|
328 |
NUM shift, and go to state 1 |
NUM shift, and go to state 1 |
329 |
|
|
333 |
|
|
334 |
state 5 |
state 5 |
335 |
|
|
336 |
exp -> exp . OP exp [$, OP] (rule 1) |
1 exp: exp . OP exp [$, OP] |
337 |
exp -> exp OP exp . [$, OP] (rule 1) |
1 | exp OP exp . [$, OP] |
338 |
|
|
|
OP shift, and go to state 4 |
|
339 |
|
|
|
OP [reduce using rule 1 (exp)] |
|
340 |
$default reduce using rule 1 (exp) |
$default reduce using rule 1 (exp) |
341 |
|
|
342 |
|
Conflict between rule 2 and token OP resolved as shift (%left OP). |
343 |
|
|
344 |
|
|
345 |
]]) |
]]) |
347 |
AT_CLEANUP |
AT_CLEANUP |
348 |
|
|
349 |
|
|
|
|
|
350 |
## -------------------------------- ## |
## -------------------------------- ## |
351 |
## Defaulted Conflicted Reduction. ## |
## Defaulted Conflicted Reduction. ## |
352 |
## -------------------------------- ## |
## -------------------------------- ## |
425 |
|
|
426 |
state 0 |
state 0 |
427 |
|
|
428 |
$axiom -> . exp $ (rule 0) |
0 $axiom: . exp $ |
429 |
exp -> . num (rule 1) |
1 exp: . num |
430 |
exp -> . id (rule 2) |
2 | . id |
431 |
num -> . '0' (rule 3) |
3 num: . '0' |
432 |
id -> . '0' (rule 4) |
4 id: . '0' |
433 |
|
|
434 |
'0' shift, and go to state 1 |
'0' shift, and go to state 1 |
435 |
|
|
441 |
|
|
442 |
state 1 |
state 1 |
443 |
|
|
444 |
num -> '0' . [$] (rule 3) |
3 num: '0' . [$] |
445 |
id -> '0' . [$] (rule 4) |
4 id: '0' . [$] |
446 |
|
|
447 |
$ reduce using rule 3 (num) |
$ reduce using rule 3 (num) |
448 |
$ [reduce using rule 4 (id)] |
$ [reduce using rule 4 (id)] |
452 |
|
|
453 |
state 2 |
state 2 |
454 |
|
|
455 |
$axiom -> exp . $ (rule 0) |
0 $axiom: exp . $ |
456 |
|
|
457 |
$ shift, and go to state 5 |
$ shift, and go to state 5 |
458 |
|
|
460 |
|
|
461 |
state 3 |
state 3 |
462 |
|
|
463 |
exp -> num . (rule 1) |
1 exp: num . |
464 |
|
|
465 |
$default reduce using rule 1 (exp) |
$default reduce using rule 1 (exp) |
466 |
|
|
468 |
|
|
469 |
state 4 |
state 4 |
470 |
|
|
471 |
exp -> id . (rule 2) |
2 exp: id . |
472 |
|
|
473 |
$default reduce using rule 2 (exp) |
$default reduce using rule 2 (exp) |
474 |
|
|
476 |
|
|
477 |
state 5 |
state 5 |
478 |
|
|
479 |
$axiom -> exp $ . (rule 0) |
0 $axiom: exp $ . |
480 |
|
|
481 |
$default accept |
$default accept |
482 |
|
|