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