]>
Commit | Line | Data |
---|---|---|
342b8b6e AD |
1 | # Bison Regressions. -*- Autotest -*- |
2 | # Copyright 2001 Free Software Foundation, Inc. | |
c95f2d78 | 3 | |
342b8b6e AD |
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. | |
c95f2d78 | 8 | |
342b8b6e AD |
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. | |
c95f2d78 | 13 | |
342b8b6e AD |
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. | |
c95f2d78 | 18 | |
342b8b6e | 19 | AT_BANNER([[Regression tests.]]) |
c95f2d78 AD |
20 | |
21 | ## ------------------ ## | |
22 | ## Duplicate string. ## | |
23 | ## ------------------ ## | |
24 | ||
25 | ||
26 | AT_SETUP([Duplicate string]) | |
27 | ||
f499b062 | 28 | AT_DATA([input.y], |
c95f2d78 AD |
29 | [[/* `Bison -v' used to dump core when two tokens are defined with the same |
30 | string, as LE and GE below. */ | |
31 | ||
32 | %token NUM | |
33 | %token LE "<=" | |
34 | %token GE "<=" | |
35 | ||
36 | %% | |
37 | exp: '(' exp ')' | NUM ; | |
38 | %% | |
39 | ]]) | |
40 | ||
f499b062 | 41 | AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore) |
c95f2d78 | 42 | |
d803322e | 43 | AT_CLEANUP |
c95f2d78 AD |
44 | |
45 | ||
ba9dda1a AD |
46 | ## ------------------------- ## |
47 | ## Unresolved SR Conflicts. ## | |
48 | ## ------------------------- ## | |
0df87bb6 | 49 | |
ba9dda1a | 50 | AT_SETUP([Unresolved SR Conflicts]) |
0df87bb6 AD |
51 | |
52 | AT_DATA([input.y], | |
53 | [[%token NUM OP | |
54 | %% | |
55 | exp: exp OP exp | NUM; | |
56 | ]]) | |
57 | ||
58 | AT_CHECK([bison input.y -o input.c -v], 0, [], | |
59 | [input.y contains 1 shift/reduce conflict. | |
60 | ]) | |
61 | ||
62 | # Check the contents of the report. | |
63 | AT_CHECK([cat input.output], [], | |
b365aa05 | 64 | [[State 5 contains 1 shift/reduce conflict. |
0df87bb6 | 65 | |
d2d1b42b | 66 | |
0df87bb6 AD |
67 | Grammar |
68 | ||
b29b2ed5 | 69 | Number, Line, Rule |
b365aa05 | 70 | 0 4 $axiom -> exp $ |
b29b2ed5 AD |
71 | 1 3 exp -> exp OP exp |
72 | 2 3 exp -> NUM | |
0df87bb6 | 73 | |
d2d1b42b | 74 | |
0df87bb6 AD |
75 | Terminals, with rules where they appear |
76 | ||
b365aa05 | 77 | $ (0) 0 |
0df87bb6 AD |
78 | error (256) |
79 | NUM (257) 2 | |
80 | OP (258) 1 | |
81 | ||
d2d1b42b | 82 | |
0df87bb6 AD |
83 | Nonterminals, with rules where they appear |
84 | ||
b365aa05 AD |
85 | $axiom (5) |
86 | on left: 0 | |
87 | exp (6) | |
88 | on left: 1 2, on right: 0 1 | |
0df87bb6 AD |
89 | |
90 | ||
91 | state 0 | |
92 | ||
93 | NUM shift, and go to state 1 | |
94 | ||
95 | exp go to state 2 | |
96 | ||
97 | ||
98 | ||
99 | state 1 | |
100 | ||
101 | exp -> NUM . (rule 2) | |
102 | ||
103 | $default reduce using rule 2 (exp) | |
104 | ||
105 | ||
106 | ||
107 | state 2 | |
108 | ||
b365aa05 | 109 | $axiom -> exp . $ (rule 0) |
0df87bb6 AD |
110 | exp -> exp . OP exp (rule 1) |
111 | ||
b365aa05 AD |
112 | $ shift, and go to state 3 |
113 | OP shift, and go to state 4 | |
0df87bb6 AD |
114 | |
115 | ||
116 | ||
117 | state 3 | |
118 | ||
b365aa05 | 119 | $axiom -> exp $ . (rule 0) |
0df87bb6 | 120 | |
b365aa05 | 121 | $default accept |
0df87bb6 AD |
122 | |
123 | ||
124 | state 4 | |
125 | ||
b365aa05 | 126 | exp -> exp OP . exp (rule 1) |
0df87bb6 | 127 | |
b365aa05 | 128 | NUM shift, and go to state 1 |
0df87bb6 | 129 | |
b365aa05 | 130 | exp go to state 5 |
c73a41af | 131 | |
0df87bb6 AD |
132 | |
133 | ||
134 | state 5 | |
135 | ||
b365aa05 AD |
136 | exp -> exp . OP exp (rule 1) |
137 | exp -> exp OP exp . (rule 1) | |
0df87bb6 | 138 | |
b365aa05 | 139 | OP shift, and go to state 4 |
0df87bb6 | 140 | |
b365aa05 AD |
141 | OP [reduce using rule 1 (exp)] |
142 | $default reduce using rule 1 (exp) | |
ba9dda1a | 143 | |
d2d1b42b AD |
144 | |
145 | ||
ba9dda1a AD |
146 | ]]) |
147 | ||
d803322e | 148 | AT_CLEANUP |
ba9dda1a AD |
149 | |
150 | ||
151 | ## --------------------- ## | |
152 | ## Solved SR Conflicts. ## | |
153 | ## --------------------- ## | |
154 | ||
155 | AT_SETUP([Solved SR Conflicts]) | |
156 | ||
157 | AT_DATA([input.y], | |
158 | [[%token NUM OP | |
159 | %right OP | |
160 | %% | |
161 | exp: exp OP exp | NUM; | |
162 | ]]) | |
163 | ||
164 | AT_CHECK([bison input.y -o input.c -v], 0, [], []) | |
165 | ||
166 | # Check the contents of the report. | |
167 | AT_CHECK([cat input.output], [], | |
b365aa05 | 168 | [[Conflict in state 5 between rule 2 and token OP resolved as shift. |
ba9dda1a | 169 | |
d2d1b42b | 170 | |
ba9dda1a AD |
171 | Grammar |
172 | ||
b29b2ed5 | 173 | Number, Line, Rule |
b365aa05 | 174 | 0 5 $axiom -> exp $ |
b29b2ed5 AD |
175 | 1 4 exp -> exp OP exp |
176 | 2 4 exp -> NUM | |
ba9dda1a | 177 | |
d2d1b42b | 178 | |
ba9dda1a AD |
179 | Terminals, with rules where they appear |
180 | ||
b365aa05 | 181 | $ (0) 0 |
ba9dda1a AD |
182 | error (256) |
183 | NUM (257) 2 | |
184 | OP (258) 1 | |
185 | ||
d2d1b42b | 186 | |
ba9dda1a AD |
187 | Nonterminals, with rules where they appear |
188 | ||
b365aa05 AD |
189 | $axiom (5) |
190 | on left: 0 | |
191 | exp (6) | |
192 | on left: 1 2, on right: 0 1 | |
ba9dda1a AD |
193 | |
194 | ||
195 | state 0 | |
196 | ||
197 | NUM shift, and go to state 1 | |
198 | ||
199 | exp go to state 2 | |
200 | ||
201 | ||
202 | ||
203 | state 1 | |
204 | ||
205 | exp -> NUM . (rule 2) | |
206 | ||
207 | $default reduce using rule 2 (exp) | |
208 | ||
209 | ||
210 | ||
211 | state 2 | |
212 | ||
b365aa05 | 213 | $axiom -> exp . $ (rule 0) |
ba9dda1a AD |
214 | exp -> exp . OP exp (rule 1) |
215 | ||
b365aa05 AD |
216 | $ shift, and go to state 3 |
217 | OP shift, and go to state 4 | |
ba9dda1a AD |
218 | |
219 | ||
220 | ||
221 | state 3 | |
222 | ||
b365aa05 | 223 | $axiom -> exp $ . (rule 0) |
ba9dda1a | 224 | |
b365aa05 | 225 | $default accept |
ba9dda1a AD |
226 | |
227 | ||
228 | state 4 | |
229 | ||
b365aa05 | 230 | exp -> exp OP . exp (rule 1) |
ba9dda1a | 231 | |
b365aa05 | 232 | NUM shift, and go to state 1 |
ba9dda1a | 233 | |
b365aa05 | 234 | exp go to state 5 |
ba9dda1a AD |
235 | |
236 | ||
237 | ||
238 | state 5 | |
239 | ||
b365aa05 AD |
240 | exp -> exp . OP exp (rule 1) |
241 | exp -> exp OP exp . (rule 1) | |
ba9dda1a | 242 | |
b365aa05 | 243 | OP shift, and go to state 4 |
ba9dda1a | 244 | |
b365aa05 | 245 | $default reduce using rule 1 (exp) |
0df87bb6 | 246 | |
d2d1b42b AD |
247 | |
248 | ||
0df87bb6 AD |
249 | ]]) |
250 | ||
d803322e | 251 | AT_CLEANUP |
0df87bb6 | 252 | |
c95f2d78 | 253 | |
7da99ede | 254 | |
2ca209c1 AD |
255 | |
256 | ## ------------------- ## | |
257 | ## Rule Line Numbers. ## | |
258 | ## ------------------- ## | |
259 | ||
260 | AT_SETUP([Rule Line Numbers]) | |
261 | ||
262 | AT_DATA([input.y], | |
263 | [[%% | |
264 | expr: | |
265 | 'a' | |
266 | ||
267 | { | |
268 | ||
269 | } | |
270 | ||
271 | 'b' | |
272 | ||
273 | { | |
274 | ||
275 | } | |
276 | ||
277 | | | |
278 | ||
279 | ||
280 | { | |
281 | ||
282 | ||
283 | } | |
284 | ||
285 | 'c' | |
286 | ||
287 | { | |
288 | ||
289 | } | |
290 | ]]) | |
291 | ||
292 | AT_CHECK([bison input.y -o input.c -v], 0, [], []) | |
293 | ||
294 | # Check the contents of the report. | |
295 | AT_CHECK([cat input.output], [], | |
d2d1b42b | 296 | [[Grammar |
2ca209c1 AD |
297 | |
298 | Number, Line, Rule | |
b365aa05 | 299 | 0 28 $axiom -> expr $ |
2ca209c1 AD |
300 | 1 2 @1 -> /* empty */ |
301 | 2 2 expr -> 'a' @1 'b' | |
302 | 3 15 @2 -> /* empty */ | |
303 | 4 15 expr -> @2 'c' | |
304 | ||
d2d1b42b | 305 | |
2ca209c1 AD |
306 | Terminals, with rules where they appear |
307 | ||
b365aa05 | 308 | $ (0) 0 |
2ca209c1 AD |
309 | 'a' (97) 2 |
310 | 'b' (98) 2 | |
311 | 'c' (99) 4 | |
312 | error (256) | |
313 | ||
d2d1b42b | 314 | |
2ca209c1 AD |
315 | Nonterminals, with rules where they appear |
316 | ||
b365aa05 AD |
317 | $axiom (6) |
318 | on left: 0 | |
319 | expr (7) | |
320 | on left: 2 4, on right: 0 | |
321 | @1 (8) | |
2ca209c1 | 322 | on left: 1, on right: 2 |
b365aa05 | 323 | @2 (9) |
2ca209c1 AD |
324 | on left: 3, on right: 4 |
325 | ||
326 | ||
327 | state 0 | |
328 | ||
329 | 'a' shift, and go to state 1 | |
330 | ||
b365aa05 AD |
331 | expr go to state 2 |
332 | @2 go to state 3 | |
2ca209c1 AD |
333 | |
334 | ||
335 | ||
336 | state 1 | |
337 | ||
338 | expr -> 'a' . @1 'b' (rule 2) | |
339 | ||
340 | $default reduce using rule 1 (@1) | |
341 | ||
b365aa05 | 342 | @1 go to state 4 |
2ca209c1 AD |
343 | |
344 | ||
345 | ||
346 | state 2 | |
347 | ||
b365aa05 | 348 | $axiom -> expr . $ (rule 0) |
2ca209c1 | 349 | |
b365aa05 | 350 | $ shift, and go to state 5 |
2ca209c1 AD |
351 | |
352 | ||
353 | ||
354 | state 3 | |
355 | ||
b365aa05 | 356 | expr -> @2 . 'c' (rule 4) |
2ca209c1 | 357 | |
b365aa05 | 358 | 'c' shift, and go to state 6 |
2ca209c1 AD |
359 | |
360 | ||
361 | ||
362 | state 4 | |
363 | ||
b365aa05 | 364 | expr -> 'a' @1 . 'b' (rule 2) |
2ca209c1 | 365 | |
b365aa05 | 366 | 'b' shift, and go to state 7 |
2ca209c1 AD |
367 | |
368 | ||
369 | ||
370 | state 5 | |
371 | ||
b365aa05 | 372 | $axiom -> expr $ . (rule 0) |
2ca209c1 | 373 | |
b365aa05 | 374 | $default accept |
2ca209c1 AD |
375 | |
376 | ||
377 | state 6 | |
378 | ||
b365aa05 AD |
379 | expr -> @2 'c' . (rule 4) |
380 | ||
381 | $default reduce using rule 4 (expr) | |
2ca209c1 AD |
382 | |
383 | ||
384 | ||
385 | state 7 | |
386 | ||
b365aa05 AD |
387 | expr -> 'a' @1 'b' . (rule 2) |
388 | ||
389 | $default reduce using rule 2 (expr) | |
390 | ||
d2d1b42b AD |
391 | |
392 | ||
2ca209c1 AD |
393 | ]]) |
394 | ||
395 | AT_CLEANUP | |
396 | ||
397 | ||
398 | ||
7da99ede AD |
399 | ## -------------------- ## |
400 | ## %expect not enough. ## | |
401 | ## -------------------- ## | |
402 | ||
403 | AT_SETUP([%expect not enough]) | |
404 | ||
405 | AT_DATA([input.y], | |
406 | [[%token NUM OP | |
407 | %expect 0 | |
408 | %% | |
409 | exp: exp OP exp | NUM; | |
410 | ]]) | |
411 | ||
412 | AT_CHECK([bison input.y -o input.c], 1, [], | |
413 | [input.y contains 1 shift/reduce conflict. | |
414 | expected 0 shift/reduce conflicts | |
415 | ]) | |
d803322e | 416 | AT_CLEANUP |
7da99ede AD |
417 | |
418 | ||
419 | ## --------------- ## | |
420 | ## %expect right. ## | |
421 | ## --------------- ## | |
422 | ||
423 | AT_SETUP([%expect right]) | |
424 | ||
425 | AT_DATA([input.y], | |
426 | [[%token NUM OP | |
427 | %expect 1 | |
428 | %% | |
429 | exp: exp OP exp | NUM; | |
430 | ]]) | |
431 | ||
a034c8b8 | 432 | AT_CHECK([bison input.y -o input.c], 0) |
d803322e | 433 | AT_CLEANUP |
7da99ede AD |
434 | |
435 | ||
436 | ## ------------------ ## | |
437 | ## %expect too much. ## | |
438 | ## ------------------ ## | |
439 | ||
440 | AT_SETUP([%expect too much]) | |
441 | ||
442 | AT_DATA([input.y], | |
443 | [[%token NUM OP | |
444 | %expect 2 | |
445 | %% | |
446 | exp: exp OP exp | NUM; | |
447 | ]]) | |
448 | ||
449 | AT_CHECK([bison input.y -o input.c], 1, [], | |
450 | [input.y contains 1 shift/reduce conflict. | |
451 | expected 2 shift/reduce conflicts | |
452 | ]) | |
d803322e | 453 | AT_CLEANUP |
7da99ede AD |
454 | |
455 | ||
cd5aafcf AD |
456 | ## ---------------------- ## |
457 | ## Mixing %token styles. ## | |
458 | ## ---------------------- ## | |
459 | ||
460 | ||
461 | AT_SETUP([Mixing %token styles]) | |
462 | ||
463 | # Taken from the documentation. | |
464 | AT_DATA([input.y], | |
465 | [[%token <operator> OR "||" | |
466 | %token <operator> LE 134 "<=" | |
467 | %left OR "<=" | |
468 | %% | |
469 | exp: ; | |
470 | %% | |
471 | ]]) | |
472 | ||
473 | AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore) | |
474 | ||
d803322e | 475 | AT_CLEANUP |
cd5aafcf AD |
476 | |
477 | ||
478 | ||
c95f2d78 AD |
479 | ## ---------------------- ## |
480 | ## %union and --defines. ## | |
481 | ## ---------------------- ## | |
482 | ||
483 | ||
484 | AT_SETUP([%union and --defines]) | |
485 | ||
f499b062 | 486 | AT_DATA([input.y], |
c95f2d78 AD |
487 | [%union |
488 | { | |
489 | int integer; | |
490 | char *string ; | |
491 | } | |
492 | %% | |
493 | exp: {}; | |
494 | ]) | |
495 | ||
f499b062 | 496 | AT_CHECK([bison --defines input.y]) |
c95f2d78 | 497 | |
d803322e | 498 | AT_CLEANUP |
342b8b6e AD |
499 | |
500 | ||
501 | ## --------------------------------------- ## | |
502 | ## Duplicate '/' in C comments in %union ## | |
503 | ## --------------------------------------- ## | |
504 | ||
505 | ||
506 | AT_SETUP([%union and C comments]) | |
507 | ||
f499b062 | 508 | AT_DATA([input.y], |
342b8b6e AD |
509 | [%union |
510 | { | |
511 | /* The int. */ int integer; | |
512 | /* The string. */ char *string ; | |
513 | } | |
514 | %% | |
515 | exp: {}; | |
516 | ]) | |
517 | ||
f499b062 AD |
518 | AT_CHECK([bison input.y -o input.c]) |
519 | AT_CHECK([fgrep '//*' input.c], [1], []) | |
342b8b6e | 520 | |
d803322e | 521 | AT_CLEANUP |
342b8b6e AD |
522 | |
523 | ||
561f9a30 AD |
524 | ## ----------------- ## |
525 | ## Invalid input 1. ## | |
526 | ## ----------------- ## | |
527 | ||
528 | ||
529 | AT_SETUP([Invalid input: 1]) | |
530 | ||
531 | AT_DATA([input.y], | |
532 | [[%% | |
533 | ? | |
534 | ]]) | |
535 | ||
536 | AT_CHECK([bison input.y], [1], [], | |
e0c40012 | 537 | [[input.y:2: invalid input: `?' |
561f9a30 | 538 | input.y:3: fatal error: no rules in the input grammar |
e0c40012 | 539 | ]]) |
561f9a30 AD |
540 | |
541 | AT_CLEANUP | |
542 | ||
543 | ||
544 | ## ----------------- ## | |
545 | ## Invalid input 2. ## | |
546 | ## ----------------- ## | |
547 | ||
548 | ||
549 | AT_SETUP([Invalid input: 2]) | |
550 | ||
551 | AT_DATA([input.y], | |
552 | [[%% | |
553 | default: 'a' } | |
554 | ]]) | |
555 | ||
556 | AT_CHECK([bison input.y], [1], [], | |
e0c40012 AD |
557 | [[input.y:2: invalid input: `}' |
558 | ]]) | |
559 | ||
560 | AT_CLEANUP | |
561 | ||
562 | ||
563 | ||
564 | ## -------------------- ## | |
565 | ## Invalid %directive. ## | |
566 | ## -------------------- ## | |
567 | ||
568 | ||
569 | AT_SETUP([Invalid %directive]) | |
570 | ||
571 | AT_DATA([input.y], | |
572 | [[%invalid | |
573 | ]]) | |
574 | ||
575 | AT_CHECK([bison input.y], [1], [], | |
576 | [[input.y:1: unrecognized: %invalid | |
577 | input.y:1: Skipping to next % | |
578 | input.y:2: fatal error: no input grammar | |
579 | ]]) | |
561f9a30 AD |
580 | |
581 | AT_CLEANUP | |
582 | ||
583 | ||
270a173c | 584 | |
342b8b6e AD |
585 | ## --------------------- ## |
586 | ## Invalid CPP headers. ## | |
587 | ## --------------------- ## | |
588 | ||
270a173c AD |
589 | # AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE) |
590 | # ------------------------------------- | |
591 | m4_define([AT_TEST_CPP_GUARD_H], | |
592 | [AT_SETUP([Invalid CPP guards: $1]) | |
342b8b6e | 593 | |
d803322e AD |
594 | # Possibly create inner directories. |
595 | dirname=`AS_DIRNAME([$1])` | |
270a173c | 596 | AS_MKDIR_P([$dirname]) |
342b8b6e | 597 | |
270a173c | 598 | AT_DATA([$1.y], |
342b8b6e AD |
599 | [%% |
600 | dummy: | |
601 | ]) | |
602 | ||
270a173c | 603 | AT_CHECK([bison --defines=$1.h $1.y]) |
342b8b6e | 604 | |
270a173c AD |
605 | # CPP should be happy with it. |
606 | AT_CHECK([$CC -E $1.h], 0, [ignore]) | |
607 | ||
d803322e | 608 | AT_CLEANUP |
270a173c | 609 | ]) |
342b8b6e | 610 | |
270a173c AD |
611 | AT_TEST_CPP_GUARD_H([input/input]) |
612 | AT_TEST_CPP_GUARD_H([9foo]) | |
776209d6 AD |
613 | |
614 | ||
615 | ||
b9752825 AD |
616 | ## -------------- ## |
617 | ## Web2c Report. ## | |
618 | ## -------------- ## | |
776209d6 AD |
619 | |
620 | # The generation of the reduction was once wrong in Bison, and made it | |
621 | # miss some reductions. In the following test case, the reduction on | |
622 | # `undef_id_tok' in state 1 was missing. This is stripped down from | |
623 | # the actual web2c.y. | |
624 | ||
b9752825 | 625 | AT_SETUP([Web2c Report]) |
776209d6 AD |
626 | |
627 | AT_DATA([input.y], | |
628 | [[%token undef_id_tok const_id_tok | |
629 | ||
630 | %start CONST_DEC_PART | |
631 | \f | |
632 | %% | |
633 | CONST_DEC_PART: | |
634 | CONST_DEC_LIST | |
635 | ; | |
636 | ||
637 | CONST_DEC_LIST: | |
638 | CONST_DEC | |
639 | | CONST_DEC_LIST CONST_DEC | |
640 | ; | |
641 | ||
642 | CONST_DEC: | |
643 | { } undef_id_tok '=' const_id_tok ';' | |
644 | ; | |
645 | %% | |
646 | ||
647 | ]]) | |
648 | ||
649 | AT_CHECK([bison -v input.y]) | |
650 | ||
651 | AT_CHECK([sed -n 's/ *$//;/^$/!p' input.output], 0, | |
652 | [[Grammar | |
653 | Number, Line, Rule | |
654 | 1 6 CONST_DEC_PART -> CONST_DEC_LIST | |
655 | 2 10 CONST_DEC_LIST -> CONST_DEC | |
656 | 3 12 CONST_DEC_LIST -> CONST_DEC_LIST CONST_DEC | |
657 | 4 15 @1 -> /* empty */ | |
658 | 5 15 CONST_DEC -> @1 undef_id_tok '=' const_id_tok ';' | |
659 | Terminals, with rules where they appear | |
b7c49edf | 660 | $ (0) |
776209d6 AD |
661 | ';' (59) 5 |
662 | '=' (61) 5 | |
663 | error (256) | |
664 | undef_id_tok (257) 5 | |
665 | const_id_tok (258) 5 | |
666 | Nonterminals, with rules where they appear | |
667 | CONST_DEC_PART (7) | |
668 | on left: 1 | |
669 | CONST_DEC_LIST (8) | |
670 | on left: 2 3, on right: 1 3 | |
671 | CONST_DEC (9) | |
672 | on left: 5, on right: 2 3 | |
673 | @1 (10) | |
674 | on left: 4, on right: 5 | |
675 | state 0 | |
676 | $default reduce using rule 4 (@1) | |
677 | CONST_DEC_PART go to state 9 | |
678 | CONST_DEC_LIST go to state 1 | |
679 | CONST_DEC go to state 2 | |
680 | @1 go to state 3 | |
681 | state 1 | |
682 | CONST_DEC_PART -> CONST_DEC_LIST . (rule 1) | |
683 | CONST_DEC_LIST -> CONST_DEC_LIST . CONST_DEC (rule 3) | |
684 | undef_id_tok reduce using rule 4 (@1) | |
685 | $default reduce using rule 1 (CONST_DEC_PART) | |
686 | CONST_DEC go to state 4 | |
687 | @1 go to state 3 | |
688 | state 2 | |
689 | CONST_DEC_LIST -> CONST_DEC . (rule 2) | |
690 | $default reduce using rule 2 (CONST_DEC_LIST) | |
691 | state 3 | |
692 | CONST_DEC -> @1 . undef_id_tok '=' const_id_tok ';' (rule 5) | |
693 | undef_id_tok shift, and go to state 5 | |
694 | state 4 | |
695 | CONST_DEC_LIST -> CONST_DEC_LIST CONST_DEC . (rule 3) | |
696 | $default reduce using rule 3 (CONST_DEC_LIST) | |
697 | state 5 | |
698 | CONST_DEC -> @1 undef_id_tok . '=' const_id_tok ';' (rule 5) | |
699 | '=' shift, and go to state 6 | |
700 | state 6 | |
701 | CONST_DEC -> @1 undef_id_tok '=' . const_id_tok ';' (rule 5) | |
702 | const_id_tok shift, and go to state 7 | |
703 | state 7 | |
704 | CONST_DEC -> @1 undef_id_tok '=' const_id_tok . ';' (rule 5) | |
705 | ';' shift, and go to state 8 | |
706 | state 8 | |
707 | CONST_DEC -> @1 undef_id_tok '=' const_id_tok ';' . (rule 5) | |
708 | $default reduce using rule 5 (CONST_DEC) | |
709 | state 9 | |
710 | $ shift, and go to state 10 | |
711 | state 10 | |
712 | $default accept | |
713 | ]]) | |
714 | ||
715 | AT_CLEANUP | |
b9752825 AD |
716 | |
717 | ||
718 | ## --------------- ## | |
719 | ## Web2c Actions. ## | |
720 | ## --------------- ## | |
721 | ||
722 | # The generation of the mapping `state -> action' was once wrong in | |
723 | # extremely specific situations. web2c.y exhibits this situation. | |
724 | # Below is a stripped version of the grammar. It looks like one can | |
725 | # simplify it further, but just don't: it is tuned to exhibit a bug, | |
726 | # which disapears when applying sane grammar transformations. | |
727 | # | |
728 | # It used to be wrong on yydefact only: | |
729 | # | |
730 | # static const short yydefact[] = | |
731 | # { | |
732 | # - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4, | |
733 | # + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4, | |
734 | # 0, 0 | |
735 | # }; | |
736 | # | |
737 | # but let's check all the tables. | |
738 | ||
739 | ||
740 | AT_SETUP([Web2c Actions]) | |
741 | ||
742 | AT_DATA([input.y], | |
743 | [[%% | |
744 | statement: struct_stat; | |
745 | struct_stat: /* empty. */ | if else; | |
746 | if: "if" "const" "then" statement; | |
747 | else: "else" statement; | |
748 | %% | |
749 | ]]) | |
750 | ||
751 | AT_CHECK([bison -v input.y -o input.c]) | |
752 | ||
753 | # Check only the tables. We don't use --no-parser, because it is | |
754 | # still to be implemented in the experimental branch of Bison. | |
755 | AT_CHECK([[sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c]], 0, | |
756 | [[static const char yytranslate[] = | |
757 | { | |
758 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
759 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
760 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
761 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
762 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
763 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
764 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
765 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
766 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
767 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
768 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
769 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
770 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
771 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
772 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
773 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
774 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
775 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
776 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
777 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
778 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
779 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
780 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
781 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
782 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
783 | 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, | |
784 | 6 | |
785 | }; | |
786 | static const short yyprhs[] = | |
787 | { | |
788 | 0, 0, 2, 3, 6, 11 | |
789 | }; | |
790 | static const short yyrhs[] = | |
791 | { | |
792 | 8, 0, 0, 9, 10, 0, 3, 4, 5, 7, | |
793 | 0, 6, 7, 0 | |
794 | }; | |
795 | static const short yyrline[] = | |
796 | { | |
797 | 0, 2, 3, 3, 4, 5 | |
798 | }; | |
799 | static const char *const yytname[] = | |
800 | { | |
801 | "$", "error", "$undefined.", "\"if\"", "\"const\"", "\"then\"", | |
802 | "\"else\"", "statement", "struct_stat", "if", "else", NULL | |
803 | }; | |
804 | static const short yytoknum[] = | |
805 | { | |
806 | 0, 256, 2, 257, 258, 259, 260, -1 | |
807 | }; | |
808 | static const short yyr1[] = | |
809 | { | |
810 | 0, 7, 8, 8, 9, 10 | |
811 | }; | |
812 | static const short yyr2[] = | |
813 | { | |
814 | 0, 1, 0, 2, 4, 2 | |
815 | }; | |
816 | static const short yydefact[] = | |
817 | { | |
818 | 2, 0, 1, 0, 0, 2, 3, 2, 5, 4, | |
819 | 0, 0 | |
820 | }; | |
821 | static const short yydefgoto[] = | |
822 | { | |
823 | 8, 2, 3, 6 | |
824 | }; | |
825 | static const short yypact[] = | |
826 | { | |
827 | -2, -1,-32768, -4, 1, -2,-32768, -2,-32768,-32768, | |
828 | 4,-32768 | |
829 | }; | |
830 | static const short yypgoto[] = | |
831 | { | |
832 | 0,-32768,-32768,-32768 | |
833 | }; | |
834 | static const short yytable[] = | |
835 | { | |
836 | 10, 1, 5, 4, 11, 0, 7, 9 | |
837 | }; | |
838 | static const short yycheck[] = | |
839 | { | |
840 | 0, 3, 6, 4, 0, -1, 5, 7 | |
841 | }; | |
842 | ]]) | |
843 | ||
844 | AT_CLEANUP |