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