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