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