]>
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 | 20 | |
2b25d624 | 21 | |
30f8c395 AD |
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 | ||
82841af7 | 78 | AT_CHECK([./input '0<0']) |
30f8c395 AD |
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. | |
82841af7 | 82 | AT_CHECK([./input '0<0<0'], [1], [], |
30f8c395 AD |
83 | [parse error, unexpected '<', expecting '<' or '>' |
84 | ]) | |
85 | ||
82841af7 AD |
86 | AT_CHECK([./input '0>0']) |
87 | AT_CHECK([./input '0>0>0'], [1], [], | |
30f8c395 AD |
88 | [parse error, unexpected '>', expecting '<' or '>' |
89 | ]) | |
90 | ||
82841af7 | 91 | AT_CHECK([./input '0<0>0'], [1], [], |
30f8c395 AD |
92 | [parse error, unexpected '>', expecting '<' or '>' |
93 | ]) | |
94 | ||
95 | AT_CLEANUP | |
96 | ||
2b25d624 AD |
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 | ||
c95f2d78 AD |
119 | ## ------------------ ## |
120 | ## Duplicate string. ## | |
121 | ## ------------------ ## | |
122 | ||
123 | ||
124 | AT_SETUP([Duplicate string]) | |
125 | ||
f499b062 | 126 | AT_DATA([input.y], |
c95f2d78 AD |
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 | ||
f499b062 | 139 | AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore) |
c95f2d78 | 140 | |
d803322e | 141 | AT_CLEANUP |
c95f2d78 AD |
142 | |
143 | ||
ba9dda1a AD |
144 | ## ------------------------- ## |
145 | ## Unresolved SR Conflicts. ## | |
146 | ## ------------------------- ## | |
0df87bb6 | 147 | |
ba9dda1a | 148 | AT_SETUP([Unresolved SR Conflicts]) |
0df87bb6 AD |
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], [], | |
b365aa05 | 162 | [[State 5 contains 1 shift/reduce conflict. |
0df87bb6 | 163 | |
d2d1b42b | 164 | |
0df87bb6 AD |
165 | Grammar |
166 | ||
b29b2ed5 | 167 | Number, Line, Rule |
ff442794 | 168 | 0 3 $axiom -> exp $ |
b29b2ed5 AD |
169 | 1 3 exp -> exp OP exp |
170 | 2 3 exp -> NUM | |
0df87bb6 | 171 | |
d2d1b42b | 172 | |
0df87bb6 AD |
173 | Terminals, with rules where they appear |
174 | ||
b365aa05 | 175 | $ (0) 0 |
0df87bb6 AD |
176 | error (256) |
177 | NUM (257) 2 | |
178 | OP (258) 1 | |
179 | ||
d2d1b42b | 180 | |
0df87bb6 AD |
181 | Nonterminals, with rules where they appear |
182 | ||
b365aa05 AD |
183 | $axiom (5) |
184 | on left: 0 | |
185 | exp (6) | |
186 | on left: 1 2, on right: 0 1 | |
0df87bb6 AD |
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 | ||
b365aa05 | 207 | $axiom -> exp . $ (rule 0) |
0df87bb6 AD |
208 | exp -> exp . OP exp (rule 1) |
209 | ||
b365aa05 AD |
210 | $ shift, and go to state 3 |
211 | OP shift, and go to state 4 | |
0df87bb6 AD |
212 | |
213 | ||
214 | ||
215 | state 3 | |
216 | ||
b365aa05 | 217 | $axiom -> exp $ . (rule 0) |
0df87bb6 | 218 | |
b365aa05 | 219 | $default accept |
0df87bb6 AD |
220 | |
221 | ||
222 | state 4 | |
223 | ||
b365aa05 | 224 | exp -> exp OP . exp (rule 1) |
0df87bb6 | 225 | |
b365aa05 | 226 | NUM shift, and go to state 1 |
0df87bb6 | 227 | |
b365aa05 | 228 | exp go to state 5 |
c73a41af | 229 | |
0df87bb6 AD |
230 | |
231 | ||
232 | state 5 | |
233 | ||
b365aa05 AD |
234 | exp -> exp . OP exp (rule 1) |
235 | exp -> exp OP exp . (rule 1) | |
0df87bb6 | 236 | |
b365aa05 | 237 | OP shift, and go to state 4 |
0df87bb6 | 238 | |
b365aa05 AD |
239 | OP [reduce using rule 1 (exp)] |
240 | $default reduce using rule 1 (exp) | |
ba9dda1a | 241 | |
d2d1b42b AD |
242 | |
243 | ||
ba9dda1a AD |
244 | ]]) |
245 | ||
d803322e | 246 | AT_CLEANUP |
ba9dda1a AD |
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], [], | |
b365aa05 | 266 | [[Conflict in state 5 between rule 2 and token OP resolved as shift. |
ba9dda1a | 267 | |
d2d1b42b | 268 | |
ba9dda1a AD |
269 | Grammar |
270 | ||
b29b2ed5 | 271 | Number, Line, Rule |
ff442794 | 272 | 0 4 $axiom -> exp $ |
b29b2ed5 AD |
273 | 1 4 exp -> exp OP exp |
274 | 2 4 exp -> NUM | |
ba9dda1a | 275 | |
d2d1b42b | 276 | |
ba9dda1a AD |
277 | Terminals, with rules where they appear |
278 | ||
b365aa05 | 279 | $ (0) 0 |
ba9dda1a AD |
280 | error (256) |
281 | NUM (257) 2 | |
282 | OP (258) 1 | |
283 | ||
d2d1b42b | 284 | |
ba9dda1a AD |
285 | Nonterminals, with rules where they appear |
286 | ||
b365aa05 AD |
287 | $axiom (5) |
288 | on left: 0 | |
289 | exp (6) | |
290 | on left: 1 2, on right: 0 1 | |
ba9dda1a AD |
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 | ||
b365aa05 | 311 | $axiom -> exp . $ (rule 0) |
ba9dda1a AD |
312 | exp -> exp . OP exp (rule 1) |
313 | ||
b365aa05 AD |
314 | $ shift, and go to state 3 |
315 | OP shift, and go to state 4 | |
ba9dda1a AD |
316 | |
317 | ||
318 | ||
319 | state 3 | |
320 | ||
b365aa05 | 321 | $axiom -> exp $ . (rule 0) |
ba9dda1a | 322 | |
b365aa05 | 323 | $default accept |
ba9dda1a AD |
324 | |
325 | ||
326 | state 4 | |
327 | ||
b365aa05 | 328 | exp -> exp OP . exp (rule 1) |
ba9dda1a | 329 | |
b365aa05 | 330 | NUM shift, and go to state 1 |
ba9dda1a | 331 | |
b365aa05 | 332 | exp go to state 5 |
ba9dda1a AD |
333 | |
334 | ||
335 | ||
336 | state 5 | |
337 | ||
b365aa05 AD |
338 | exp -> exp . OP exp (rule 1) |
339 | exp -> exp OP exp . (rule 1) | |
ba9dda1a | 340 | |
b365aa05 | 341 | OP shift, and go to state 4 |
ba9dda1a | 342 | |
b365aa05 | 343 | $default reduce using rule 1 (exp) |
0df87bb6 | 344 | |
d2d1b42b AD |
345 | |
346 | ||
0df87bb6 AD |
347 | ]]) |
348 | ||
d803322e | 349 | AT_CLEANUP |
0df87bb6 | 350 | |
c95f2d78 | 351 | |
7da99ede | 352 | |
2ca209c1 AD |
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], [], | |
d2d1b42b | 394 | [[Grammar |
2ca209c1 AD |
395 | |
396 | Number, Line, Rule | |
ff442794 | 397 | 0 2 $axiom -> expr $ |
2ca209c1 AD |
398 | 1 2 @1 -> /* empty */ |
399 | 2 2 expr -> 'a' @1 'b' | |
400 | 3 15 @2 -> /* empty */ | |
401 | 4 15 expr -> @2 'c' | |
402 | ||
d2d1b42b | 403 | |
2ca209c1 AD |
404 | Terminals, with rules where they appear |
405 | ||
b365aa05 | 406 | $ (0) 0 |
2ca209c1 AD |
407 | 'a' (97) 2 |
408 | 'b' (98) 2 | |
409 | 'c' (99) 4 | |
410 | error (256) | |
411 | ||
d2d1b42b | 412 | |
2ca209c1 AD |
413 | Nonterminals, with rules where they appear |
414 | ||
b365aa05 AD |
415 | $axiom (6) |
416 | on left: 0 | |
417 | expr (7) | |
418 | on left: 2 4, on right: 0 | |
419 | @1 (8) | |
2ca209c1 | 420 | on left: 1, on right: 2 |
b365aa05 | 421 | @2 (9) |
2ca209c1 AD |
422 | on left: 3, on right: 4 |
423 | ||
424 | ||
425 | state 0 | |
426 | ||
427 | 'a' shift, and go to state 1 | |
428 | ||
610ab194 AD |
429 | $default reduce using rule 3 (@2) |
430 | ||
b365aa05 AD |
431 | expr go to state 2 |
432 | @2 go to state 3 | |
2ca209c1 AD |
433 | |
434 | ||
435 | ||
436 | state 1 | |
437 | ||
438 | expr -> 'a' . @1 'b' (rule 2) | |
439 | ||
440 | $default reduce using rule 1 (@1) | |
441 | ||
b365aa05 | 442 | @1 go to state 4 |
2ca209c1 AD |
443 | |
444 | ||
445 | ||
446 | state 2 | |
447 | ||
b365aa05 | 448 | $axiom -> expr . $ (rule 0) |
2ca209c1 | 449 | |
b365aa05 | 450 | $ shift, and go to state 5 |
2ca209c1 AD |
451 | |
452 | ||
453 | ||
454 | state 3 | |
455 | ||
b365aa05 | 456 | expr -> @2 . 'c' (rule 4) |
2ca209c1 | 457 | |
b365aa05 | 458 | 'c' shift, and go to state 6 |
2ca209c1 AD |
459 | |
460 | ||
461 | ||
462 | state 4 | |
463 | ||
b365aa05 | 464 | expr -> 'a' @1 . 'b' (rule 2) |
2ca209c1 | 465 | |
b365aa05 | 466 | 'b' shift, and go to state 7 |
2ca209c1 AD |
467 | |
468 | ||
469 | ||
470 | state 5 | |
471 | ||
b365aa05 | 472 | $axiom -> expr $ . (rule 0) |
2ca209c1 | 473 | |
b365aa05 | 474 | $default accept |
2ca209c1 AD |
475 | |
476 | ||
477 | state 6 | |
478 | ||
b365aa05 AD |
479 | expr -> @2 'c' . (rule 4) |
480 | ||
481 | $default reduce using rule 4 (expr) | |
2ca209c1 AD |
482 | |
483 | ||
484 | ||
485 | state 7 | |
486 | ||
b365aa05 AD |
487 | expr -> 'a' @1 'b' . (rule 2) |
488 | ||
489 | $default reduce using rule 2 (expr) | |
490 | ||
d2d1b42b AD |
491 | |
492 | ||
2ca209c1 AD |
493 | ]]) |
494 | ||
495 | AT_CLEANUP | |
496 | ||
497 | ||
498 | ||
7da99ede AD |
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 | ]) | |
d803322e | 516 | AT_CLEANUP |
7da99ede AD |
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 | ||
a034c8b8 | 532 | AT_CHECK([bison input.y -o input.c], 0) |
d803322e | 533 | AT_CLEANUP |
7da99ede AD |
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 | ]) | |
d803322e | 553 | AT_CLEANUP |
7da99ede AD |
554 | |
555 | ||
cd5aafcf AD |
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 | ||
d803322e | 575 | AT_CLEANUP |
cd5aafcf AD |
576 | |
577 | ||
578 | ||
29ae55f1 AD |
579 | ## ---------------- ## |
580 | ## Invalid inputs. ## | |
581 | ## ---------------- ## | |
561f9a30 AD |
582 | |
583 | ||
29ae55f1 | 584 | AT_SETUP([Invalid inputs]) |
561f9a30 AD |
585 | |
586 | AT_DATA([input.y], | |
587 | [[%% | |
588 | ? | |
561f9a30 | 589 | default: 'a' } |
29ae55f1 AD |
590 | %{ |
591 | %& | |
592 | %a | |
593 | %- | |
561f9a30 AD |
594 | ]]) |
595 | ||
596 | AT_CHECK([bison input.y], [1], [], | |
29ae55f1 AD |
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: `%-' | |
e0c40012 AD |
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 | ]]) | |
561f9a30 AD |
625 | |
626 | AT_CLEANUP | |
627 | ||
628 | ||
270a173c | 629 | |
b9752825 AD |
630 | ## -------------- ## |
631 | ## Web2c Report. ## | |
632 | ## -------------- ## | |
776209d6 AD |
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 | ||
b9752825 | 639 | AT_SETUP([Web2c Report]) |
776209d6 AD |
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 | |
78d5bae9 | 668 | 0 6 $axiom -> CONST_DEC_PART $ |
776209d6 AD |
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 | |
78d5bae9 | 675 | $ (0) 0 |
776209d6 AD |
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 | |
78d5bae9 AD |
682 | $axiom (7) |
683 | on left: 0 | |
684 | CONST_DEC_PART (8) | |
685 | on left: 1, on right: 0 | |
686 | CONST_DEC_LIST (9) | |
776209d6 | 687 | on left: 2 3, on right: 1 3 |
78d5bae9 | 688 | CONST_DEC (10) |
776209d6 | 689 | on left: 5, on right: 2 3 |
78d5bae9 | 690 | @1 (11) |
776209d6 AD |
691 | on left: 4, on right: 5 |
692 | state 0 | |
693 | $default reduce using rule 4 (@1) | |
78d5bae9 AD |
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 | |
776209d6 | 698 | state 1 |
78d5bae9 AD |
699 | $axiom -> CONST_DEC_PART . $ (rule 0) |
700 | $ shift, and go to state 5 | |
701 | state 2 | |
776209d6 AD |
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) | |
78d5bae9 AD |
706 | CONST_DEC go to state 6 |
707 | @1 go to state 4 | |
708 | state 3 | |
776209d6 AD |
709 | CONST_DEC_LIST -> CONST_DEC . (rule 2) |
710 | $default reduce using rule 2 (CONST_DEC_LIST) | |
776209d6 | 711 | state 4 |
78d5bae9 AD |
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 | |
776209d6 AD |
718 | CONST_DEC_LIST -> CONST_DEC_LIST CONST_DEC . (rule 3) |
719 | $default reduce using rule 3 (CONST_DEC_LIST) | |
78d5bae9 | 720 | state 7 |
776209d6 | 721 | CONST_DEC -> @1 undef_id_tok . '=' const_id_tok ';' (rule 5) |
78d5bae9 AD |
722 | '=' shift, and go to state 8 |
723 | state 8 | |
776209d6 | 724 | CONST_DEC -> @1 undef_id_tok '=' . const_id_tok ';' (rule 5) |
78d5bae9 AD |
725 | const_id_tok shift, and go to state 9 |
726 | state 9 | |
776209d6 | 727 | CONST_DEC -> @1 undef_id_tok '=' const_id_tok . ';' (rule 5) |
78d5bae9 AD |
728 | ';' shift, and go to state 10 |
729 | state 10 | |
776209d6 AD |
730 | CONST_DEC -> @1 undef_id_tok '=' const_id_tok ';' . (rule 5) |
731 | $default reduce using rule 5 (CONST_DEC) | |
776209d6 AD |
732 | ]]) |
733 | ||
734 | AT_CLEANUP | |
b9752825 AD |
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 | { | |
e7b8bef1 | 807 | 0, 0, 3, 5, 6, 9, 14 |
b9752825 AD |
808 | }; |
809 | static const short yyrhs[] = | |
810 | { | |
e7b8bef1 AD |
811 | 8, 0, -1, 9, -1, -1, 10, 11, -1, 3, |
812 | 4, 5, 8, -1, 6, 8, -1 | |
b9752825 AD |
813 | }; |
814 | static const short yyrline[] = | |
815 | { | |
e7b8bef1 | 816 | 0, 2, 2, 3, 3, 4, 5 |
b9752825 AD |
817 | }; |
818 | static const char *const yytname[] = | |
819 | { | |
820 | "$", "error", "$undefined.", "\"if\"", "\"const\"", "\"then\"", | |
e7b8bef1 | 821 | "\"else\"", "$axiom", "statement", "struct_stat", "if", "else", NULL |
b9752825 AD |
822 | }; |
823 | static const short yytoknum[] = | |
824 | { | |
825 | 0, 256, 2, 257, 258, 259, 260, -1 | |
826 | }; | |
827 | static const short yyr1[] = | |
828 | { | |
e7b8bef1 | 829 | 0, 7, 8, 9, 9, 10, 11 |
b9752825 AD |
830 | }; |
831 | static const short yyr2[] = | |
832 | { | |
e7b8bef1 | 833 | 0, 2, 1, 0, 2, 4, 2 |
b9752825 AD |
834 | }; |
835 | static const short yydefact[] = | |
836 | { | |
e7b8bef1 AD |
837 | 3, 0, 0, 2, 0, 0, 0, 3, 4, 3, |
838 | 6, 5 | |
b9752825 AD |
839 | }; |
840 | static const short yydefgoto[] = | |
841 | { | |
e7b8bef1 | 842 | -1, 2, 3, 4, 8 |
b9752825 AD |
843 | }; |
844 | static const short yypact[] = | |
845 | { | |
e7b8bef1 AD |
846 | -2, -1, 4,-32768, 0, 2,-32768, -2,-32768, -2, |
847 | -32768,-32768 | |
b9752825 AD |
848 | }; |
849 | static const short yypgoto[] = | |
850 | { | |
e7b8bef1 | 851 | -32768, -7,-32768,-32768,-32768 |
b9752825 AD |
852 | }; |
853 | static const short yytable[] = | |
854 | { | |
e7b8bef1 | 855 | 10, 1, 11, 5, 6, 0, 7, 9 |
b9752825 AD |
856 | }; |
857 | static const short yycheck[] = | |
858 | { | |
e7b8bef1 | 859 | 7, 3, 9, 4, 0, -1, 6, 5 |
b9752825 AD |
860 | }; |
861 | ]]) | |
862 | ||
863 | AT_CLEANUP |