]>
Commit | Line | Data |
---|---|---|
342b8b6e | 1 | # Bison Regressions. -*- Autotest -*- |
4f136612 | 2 | # Copyright (C) 2001, 2002, 2003, 2004, 2005 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 | |
0fb669f9 PE |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | # 02110-1301, USA. | |
c95f2d78 | 18 | |
342b8b6e | 19 | AT_BANNER([[Regression tests.]]) |
c95f2d78 | 20 | |
2b25d624 | 21 | |
69078d4b AD |
22 | ## ------------------------- ## |
23 | ## Early token definitions. ## | |
24 | ## ------------------------- ## | |
25 | ||
26 | ||
27 | AT_SETUP([Early token definitions]) | |
28 | ||
29 | # Found in GCJ: they expect the tokens to be defined before the user | |
30 | # prologue, so that they can use the token definitions in it. | |
31 | ||
9501dc6e | 32 | AT_DATA_GRAMMAR([input.y], |
69078d4b AD |
33 | [[%{ |
34 | void yyerror (const char *s); | |
35 | int yylex (void); | |
36 | %} | |
37 | ||
38 | %union | |
39 | { | |
40 | int val; | |
41 | }; | |
42 | %{ | |
43 | #ifndef MY_TOKEN | |
44 | # error "MY_TOKEN not defined." | |
45 | #endif | |
46 | %} | |
47 | %token MY_TOKEN | |
48 | %% | |
49 | exp: MY_TOKEN; | |
50 | %% | |
51 | ]]) | |
52 | ||
b56471a6 | 53 | AT_CHECK([bison -o input.c input.y]) |
002b9b7d | 54 | AT_COMPILE([input.o], [-c input.c]) |
69078d4b AD |
55 | |
56 | AT_CLEANUP | |
57 | ||
58 | ||
59 | ||
2b25d624 AD |
60 | ## ---------------- ## |
61 | ## Braces parsing. ## | |
62 | ## ---------------- ## | |
63 | ||
64 | ||
69078d4b | 65 | AT_SETUP([Braces parsing]) |
2b25d624 AD |
66 | |
67 | AT_DATA([input.y], | |
68 | [[/* Bison used to swallow the character after `}'. */ | |
69 | ||
70 | %% | |
bfcf1f3a | 71 | exp: { tests = {{{{{{{{{{}}}}}}}}}}; }; |
2b25d624 AD |
72 | %% |
73 | ]]) | |
74 | ||
b56471a6 | 75 | AT_CHECK([bison -v -o input.c input.y]) |
2b25d624 | 76 | |
a4bf0390 | 77 | AT_CHECK([grep 'tests = {{{{{{{{{{}}}}}}}}}};' input.c], 0, [ignore]) |
2b25d624 AD |
78 | |
79 | AT_CLEANUP | |
80 | ||
81 | ||
c95f2d78 AD |
82 | ## ------------------ ## |
83 | ## Duplicate string. ## | |
84 | ## ------------------ ## | |
85 | ||
86 | ||
87 | AT_SETUP([Duplicate string]) | |
88 | ||
f499b062 | 89 | AT_DATA([input.y], |
c95f2d78 AD |
90 | [[/* `Bison -v' used to dump core when two tokens are defined with the same |
91 | string, as LE and GE below. */ | |
92 | ||
93 | %token NUM | |
94 | %token LE "<=" | |
95 | %token GE "<=" | |
96 | ||
97 | %% | |
98 | exp: '(' exp ')' | NUM ; | |
99 | %% | |
100 | ]]) | |
101 | ||
b56471a6 | 102 | AT_CHECK([bison -v -o input.c input.y], 0, [], |
a5d50994 | 103 | [[input.y:6.8-14: warning: symbol `"<="' used more than once as a literal string |
69078d4b | 104 | ]]) |
c95f2d78 | 105 | |
d803322e | 106 | AT_CLEANUP |
c95f2d78 AD |
107 | |
108 | ||
2ca209c1 AD |
109 | ## ------------------- ## |
110 | ## Rule Line Numbers. ## | |
111 | ## ------------------- ## | |
112 | ||
113 | AT_SETUP([Rule Line Numbers]) | |
114 | ||
6b98e4b5 AD |
115 | AT_KEYWORDS([report]) |
116 | ||
2ca209c1 AD |
117 | AT_DATA([input.y], |
118 | [[%% | |
119 | expr: | |
120 | 'a' | |
121 | ||
122 | { | |
123 | ||
124 | } | |
125 | ||
126 | 'b' | |
127 | ||
128 | { | |
129 | ||
130 | } | |
131 | ||
132 | | | |
133 | ||
134 | ||
135 | { | |
136 | ||
137 | ||
138 | } | |
139 | ||
140 | 'c' | |
141 | ||
142 | { | |
143 | ||
bfcf1f3a | 144 | }; |
2ca209c1 AD |
145 | ]]) |
146 | ||
b56471a6 | 147 | AT_CHECK([bison -o input.c -v input.y]) |
2ca209c1 AD |
148 | |
149 | # Check the contents of the report. | |
150 | AT_CHECK([cat input.output], [], | |
d2d1b42b | 151 | [[Grammar |
2ca209c1 | 152 | |
88bce5a2 | 153 | 0 $accept: expr $end |
6b98e4b5 AD |
154 | |
155 | 1 @1: /* empty */ | |
156 | ||
157 | 2 expr: 'a' @1 'b' | |
158 | ||
159 | 3 @2: /* empty */ | |
160 | ||
161 | 4 expr: @2 'c' | |
2ca209c1 | 162 | |
d2d1b42b | 163 | |
2ca209c1 AD |
164 | Terminals, with rules where they appear |
165 | ||
88bce5a2 | 166 | $end (0) 0 |
2ca209c1 AD |
167 | 'a' (97) 2 |
168 | 'b' (98) 2 | |
169 | 'c' (99) 4 | |
170 | error (256) | |
171 | ||
d2d1b42b | 172 | |
2ca209c1 AD |
173 | Nonterminals, with rules where they appear |
174 | ||
88bce5a2 | 175 | $accept (6) |
b365aa05 AD |
176 | on left: 0 |
177 | expr (7) | |
178 | on left: 2 4, on right: 0 | |
179 | @1 (8) | |
2ca209c1 | 180 | on left: 1, on right: 2 |
b365aa05 | 181 | @2 (9) |
2ca209c1 AD |
182 | on left: 3, on right: 4 |
183 | ||
184 | ||
185 | state 0 | |
186 | ||
88bce5a2 | 187 | 0 $accept: . expr $end |
643a5994 | 188 | |
87675353 | 189 | 'a' shift, and go to state 1 |
2ca209c1 | 190 | |
87675353 | 191 | $default reduce using rule 3 (@2) |
2ca209c1 | 192 | |
87675353 AD |
193 | expr go to state 2 |
194 | @2 go to state 3 | |
2ca209c1 AD |
195 | |
196 | ||
197 | state 1 | |
198 | ||
ce4ccb4b | 199 | 2 expr: 'a' . @1 'b' |
2ca209c1 | 200 | |
87675353 | 201 | $default reduce using rule 1 (@1) |
2ca209c1 | 202 | |
87675353 | 203 | @1 go to state 4 |
2ca209c1 AD |
204 | |
205 | ||
206 | state 2 | |
207 | ||
88bce5a2 | 208 | 0 $accept: expr . $end |
2ca209c1 | 209 | |
88bce5a2 | 210 | $end shift, and go to state 5 |
2ca209c1 AD |
211 | |
212 | ||
213 | state 3 | |
214 | ||
ce4ccb4b | 215 | 4 expr: @2 . 'c' |
2ca209c1 | 216 | |
87675353 | 217 | 'c' shift, and go to state 6 |
2ca209c1 AD |
218 | |
219 | ||
220 | state 4 | |
221 | ||
ce4ccb4b | 222 | 2 expr: 'a' @1 . 'b' |
2ca209c1 | 223 | |
87675353 | 224 | 'b' shift, and go to state 7 |
2ca209c1 AD |
225 | |
226 | ||
227 | state 5 | |
228 | ||
88bce5a2 | 229 | 0 $accept: expr $end . |
2ca209c1 | 230 | |
e8832397 | 231 | $default accept |
2ca209c1 AD |
232 | |
233 | ||
234 | state 6 | |
235 | ||
ce4ccb4b | 236 | 4 expr: @2 'c' . |
b365aa05 | 237 | |
87675353 | 238 | $default reduce using rule 4 (expr) |
2ca209c1 AD |
239 | |
240 | ||
241 | state 7 | |
242 | ||
ce4ccb4b | 243 | 2 expr: 'a' @1 'b' . |
b365aa05 | 244 | |
87675353 | 245 | $default reduce using rule 2 (expr) |
2ca209c1 AD |
246 | ]]) |
247 | ||
248 | AT_CLEANUP | |
249 | ||
250 | ||
251 | ||
cd5aafcf AD |
252 | ## ---------------------- ## |
253 | ## Mixing %token styles. ## | |
254 | ## ---------------------- ## | |
255 | ||
256 | ||
257 | AT_SETUP([Mixing %token styles]) | |
258 | ||
259 | # Taken from the documentation. | |
260 | AT_DATA([input.y], | |
261 | [[%token <operator> OR "||" | |
262 | %token <operator> LE 134 "<=" | |
263 | %left OR "<=" | |
264 | %% | |
265 | exp: ; | |
266 | %% | |
267 | ]]) | |
268 | ||
b56471a6 | 269 | AT_CHECK([bison -v -o input.c input.y]) |
cd5aafcf | 270 | |
d803322e | 271 | AT_CLEANUP |
cd5aafcf AD |
272 | |
273 | ||
274 | ||
29ae55f1 AD |
275 | ## ---------------- ## |
276 | ## Invalid inputs. ## | |
277 | ## ---------------- ## | |
561f9a30 AD |
278 | |
279 | ||
29ae55f1 | 280 | AT_SETUP([Invalid inputs]) |
561f9a30 AD |
281 | |
282 | AT_DATA([input.y], | |
283 | [[%% | |
284 | ? | |
561f9a30 | 285 | default: 'a' } |
29ae55f1 | 286 | %& |
2dfbfc12 | 287 | %a-does-not-exist |
29ae55f1 | 288 | %- |
e9955c83 | 289 | %{ |
561f9a30 AD |
290 | ]]) |
291 | ||
292 | AT_CHECK([bison input.y], [1], [], | |
e9955c83 AD |
293 | [[input.y:2.1: invalid character: `?' |
294 | input.y:3.14: invalid character: `}' | |
295 | input.y:4.1: invalid character: `%' | |
296 | input.y:4.2: invalid character: `&' | |
2dfbfc12 | 297 | input.y:5.1-17: invalid directive: `%a-does-not-exist' |
e9955c83 AD |
298 | input.y:6.1: invalid character: `%' |
299 | input.y:6.2: invalid character: `-' | |
2115939b | 300 | input.y:7.1-8.0: missing `%}' at end of file |
e0c40012 | 301 | ]]) |
561f9a30 AD |
302 | |
303 | AT_CLEANUP | |
304 | ||
305 | ||
fc01665e PE |
306 | AT_SETUP([Invalid inputs with {}]) |
307 | ||
308 | AT_DATA([input.y], | |
309 | [[ | |
310 | %destructor | |
311 | %initial-action | |
312 | %lex-param | |
313 | %parse-param | |
314 | %printer | |
315 | %union | |
316 | ]]) | |
317 | ||
318 | AT_CHECK([bison input.y], [1], [], | |
319 | [[input.y:3.1: missing `{' in "%destructor {...}" | |
320 | input.y:4.1: missing `{' in "%initial-action {...}" | |
321 | input.y:4.1: syntax error, unexpected %initial-action {...}, expecting string or identifier | |
322 | ]]) | |
323 | ||
324 | AT_CLEANUP | |
325 | ||
326 | ||
270a173c | 327 | |
b87f8b21 AD |
328 | ## ------------------- ## |
329 | ## Token definitions. ## | |
330 | ## ------------------- ## | |
331 | ||
332 | ||
333 | AT_SETUP([Token definitions]) | |
334 | ||
335 | # Bison managed, when fed with `%token 'f' "f"' to #define 'f'! | |
9501dc6e | 336 | AT_DATA_GRAMMAR([input.y], |
db7c8e9a | 337 | [%{ |
ca407bdf | 338 | #include <stdio.h> |
db7c8e9a AD |
339 | void yyerror (const char *s); |
340 | int yylex (void); | |
341 | %} | |
ca407bdf PE |
342 | [%error-verbose |
343 | %token MYEOF 0 "end of file" | |
b87f8b21 | 344 | %token 'a' "a" |
4f136612 PE |
345 | %token B_TOKEN "b" |
346 | %token C_TOKEN 'c' | |
347 | %token 'd' D_TOKEN | |
3d54b576 | 348 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!" |
b87f8b21 | 349 | %% |
3d54b576 | 350 | exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"; |
ca407bdf PE |
351 | %% |
352 | void | |
353 | yyerror (char const *s) | |
354 | { | |
355 | fprintf (stderr, "%s\n", s); | |
356 | } | |
357 | ||
358 | int | |
359 | yylex (void) | |
360 | { | |
361 | return SPECIAL; | |
362 | } | |
363 | ||
364 | int | |
365 | main (void) | |
366 | { | |
367 | return yyparse (); | |
368 | } | |
b87f8b21 AD |
369 | ]]) |
370 | ||
b56471a6 | 371 | AT_CHECK([bison -o input.c input.y]) |
ca407bdf | 372 | AT_COMPILE([input]) |
3d54b576 PE |
373 | AT_DATA([experr], |
374 | [[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\201\001\201?\?!", expecting a | |
375 | ]]) | |
376 | AT_PARSER_CHECK([./input], 1, [], [experr]) | |
b87f8b21 AD |
377 | AT_CLEANUP |
378 | ||
379 | ||
380 | ||
eb714592 AD |
381 | ## -------------------- ## |
382 | ## Characters Escapes. ## | |
383 | ## -------------------- ## | |
384 | ||
385 | ||
386 | AT_SETUP([Characters Escapes]) | |
387 | ||
9501dc6e | 388 | AT_DATA_GRAMMAR([input.y], |
eb714592 AD |
389 | [%{ |
390 | void yyerror (const char *s); | |
391 | int yylex (void); | |
392 | %} | |
393 | [%% | |
394 | exp: | |
395 | '\'' "\'" | |
396 | | '\"' "\"" | |
397 | | '"' "'" | |
398 | ; | |
399 | ]]) | |
9501dc6e | 400 | # Pacify font-lock-mode: " |
eb714592 | 401 | |
b56471a6 | 402 | AT_CHECK([bison -o input.c input.y]) |
eb714592 AD |
403 | AT_COMPILE([input.o], [-c input.c]) |
404 | AT_CLEANUP | |
405 | ||
406 | ||
407 | ||
b9752825 AD |
408 | ## -------------- ## |
409 | ## Web2c Report. ## | |
410 | ## -------------- ## | |
776209d6 AD |
411 | |
412 | # The generation of the reduction was once wrong in Bison, and made it | |
413 | # miss some reductions. In the following test case, the reduction on | |
414 | # `undef_id_tok' in state 1 was missing. This is stripped down from | |
415 | # the actual web2c.y. | |
416 | ||
b9752825 | 417 | AT_SETUP([Web2c Report]) |
776209d6 | 418 | |
6b98e4b5 AD |
419 | AT_KEYWORDS([report]) |
420 | ||
776209d6 AD |
421 | AT_DATA([input.y], |
422 | [[%token undef_id_tok const_id_tok | |
423 | ||
424 | %start CONST_DEC_PART | |
425 | \f | |
426 | %% | |
427 | CONST_DEC_PART: | |
428 | CONST_DEC_LIST | |
429 | ; | |
430 | ||
431 | CONST_DEC_LIST: | |
432 | CONST_DEC | |
433 | | CONST_DEC_LIST CONST_DEC | |
434 | ; | |
435 | ||
436 | CONST_DEC: | |
437 | { } undef_id_tok '=' const_id_tok ';' | |
438 | ; | |
439 | %% | |
776209d6 AD |
440 | ]]) |
441 | ||
442 | AT_CHECK([bison -v input.y]) | |
87675353 | 443 | AT_CHECK([cat input.output], 0, |
776209d6 | 444 | [[Grammar |
87675353 | 445 | |
88bce5a2 | 446 | 0 $accept: CONST_DEC_PART $end |
87675353 | 447 | |
6b98e4b5 | 448 | 1 CONST_DEC_PART: CONST_DEC_LIST |
87675353 | 449 | |
6b98e4b5 AD |
450 | 2 CONST_DEC_LIST: CONST_DEC |
451 | 3 | CONST_DEC_LIST CONST_DEC | |
87675353 | 452 | |
6b98e4b5 | 453 | 4 @1: /* empty */ |
87675353 | 454 | |
6b98e4b5 | 455 | 5 CONST_DEC: @1 undef_id_tok '=' const_id_tok ';' |
87675353 AD |
456 | |
457 | ||
776209d6 | 458 | Terminals, with rules where they appear |
87675353 | 459 | |
88bce5a2 | 460 | $end (0) 0 |
776209d6 AD |
461 | ';' (59) 5 |
462 | '=' (61) 5 | |
463 | error (256) | |
007a50a4 AD |
464 | undef_id_tok (258) 5 |
465 | const_id_tok (259) 5 | |
87675353 AD |
466 | |
467 | ||
776209d6 | 468 | Nonterminals, with rules where they appear |
87675353 | 469 | |
88bce5a2 | 470 | $accept (7) |
78d5bae9 AD |
471 | on left: 0 |
472 | CONST_DEC_PART (8) | |
473 | on left: 1, on right: 0 | |
474 | CONST_DEC_LIST (9) | |
776209d6 | 475 | on left: 2 3, on right: 1 3 |
78d5bae9 | 476 | CONST_DEC (10) |
776209d6 | 477 | on left: 5, on right: 2 3 |
78d5bae9 | 478 | @1 (11) |
776209d6 | 479 | on left: 4, on right: 5 |
87675353 AD |
480 | |
481 | ||
776209d6 | 482 | state 0 |
87675353 | 483 | |
88bce5a2 | 484 | 0 $accept: . CONST_DEC_PART $end |
87675353 AD |
485 | |
486 | $default reduce using rule 4 (@1) | |
487 | ||
488 | CONST_DEC_PART go to state 1 | |
489 | CONST_DEC_LIST go to state 2 | |
490 | CONST_DEC go to state 3 | |
491 | @1 go to state 4 | |
492 | ||
493 | ||
776209d6 | 494 | state 1 |
87675353 | 495 | |
88bce5a2 | 496 | 0 $accept: CONST_DEC_PART . $end |
87675353 | 497 | |
88bce5a2 | 498 | $end shift, and go to state 5 |
87675353 AD |
499 | |
500 | ||
78d5bae9 | 501 | state 2 |
87675353 | 502 | |
ce4ccb4b AD |
503 | 1 CONST_DEC_PART: CONST_DEC_LIST . |
504 | 3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC | |
87675353 AD |
505 | |
506 | undef_id_tok reduce using rule 4 (@1) | |
507 | $default reduce using rule 1 (CONST_DEC_PART) | |
508 | ||
509 | CONST_DEC go to state 6 | |
510 | @1 go to state 4 | |
511 | ||
512 | ||
78d5bae9 | 513 | state 3 |
87675353 | 514 | |
ce4ccb4b | 515 | 2 CONST_DEC_LIST: CONST_DEC . |
87675353 AD |
516 | |
517 | $default reduce using rule 2 (CONST_DEC_LIST) | |
518 | ||
519 | ||
776209d6 | 520 | state 4 |
87675353 | 521 | |
ce4ccb4b | 522 | 5 CONST_DEC: @1 . undef_id_tok '=' const_id_tok ';' |
87675353 AD |
523 | |
524 | undef_id_tok shift, and go to state 7 | |
525 | ||
526 | ||
78d5bae9 | 527 | state 5 |
87675353 | 528 | |
88bce5a2 | 529 | 0 $accept: CONST_DEC_PART $end . |
87675353 | 530 | |
e8832397 | 531 | $default accept |
87675353 AD |
532 | |
533 | ||
78d5bae9 | 534 | state 6 |
87675353 | 535 | |
ce4ccb4b | 536 | 3 CONST_DEC_LIST: CONST_DEC_LIST CONST_DEC . |
87675353 AD |
537 | |
538 | $default reduce using rule 3 (CONST_DEC_LIST) | |
539 | ||
540 | ||
78d5bae9 | 541 | state 7 |
87675353 | 542 | |
ce4ccb4b | 543 | 5 CONST_DEC: @1 undef_id_tok . '=' const_id_tok ';' |
87675353 AD |
544 | |
545 | '=' shift, and go to state 8 | |
546 | ||
547 | ||
78d5bae9 | 548 | state 8 |
87675353 | 549 | |
ce4ccb4b | 550 | 5 CONST_DEC: @1 undef_id_tok '=' . const_id_tok ';' |
87675353 AD |
551 | |
552 | const_id_tok shift, and go to state 9 | |
553 | ||
554 | ||
78d5bae9 | 555 | state 9 |
87675353 | 556 | |
ce4ccb4b | 557 | 5 CONST_DEC: @1 undef_id_tok '=' const_id_tok . ';' |
87675353 AD |
558 | |
559 | ';' shift, and go to state 10 | |
560 | ||
561 | ||
78d5bae9 | 562 | state 10 |
87675353 | 563 | |
ce4ccb4b | 564 | 5 CONST_DEC: @1 undef_id_tok '=' const_id_tok ';' . |
87675353 AD |
565 | |
566 | $default reduce using rule 5 (CONST_DEC) | |
776209d6 AD |
567 | ]]) |
568 | ||
569 | AT_CLEANUP | |
b9752825 AD |
570 | |
571 | ||
572 | ## --------------- ## | |
573 | ## Web2c Actions. ## | |
574 | ## --------------- ## | |
575 | ||
576 | # The generation of the mapping `state -> action' was once wrong in | |
577 | # extremely specific situations. web2c.y exhibits this situation. | |
578 | # Below is a stripped version of the grammar. It looks like one can | |
579 | # simplify it further, but just don't: it is tuned to exhibit a bug, | |
580 | # which disapears when applying sane grammar transformations. | |
581 | # | |
582 | # It used to be wrong on yydefact only: | |
583 | # | |
779e7ceb | 584 | # static const short int yydefact[] = |
b9752825 AD |
585 | # { |
586 | # - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4, | |
587 | # + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4, | |
588 | # 0, 0 | |
589 | # }; | |
590 | # | |
591 | # but let's check all the tables. | |
592 | ||
593 | ||
594 | AT_SETUP([Web2c Actions]) | |
595 | ||
6b98e4b5 AD |
596 | AT_KEYWORDS([report]) |
597 | ||
b9752825 AD |
598 | AT_DATA([input.y], |
599 | [[%% | |
600 | statement: struct_stat; | |
601 | struct_stat: /* empty. */ | if else; | |
602 | if: "if" "const" "then" statement; | |
603 | else: "else" statement; | |
604 | %% | |
605 | ]]) | |
606 | ||
b56471a6 | 607 | AT_CHECK([bison -v -o input.c input.y]) |
b9752825 AD |
608 | |
609 | # Check only the tables. We don't use --no-parser, because it is | |
610 | # still to be implemented in the experimental branch of Bison. | |
ce4ccb4b AD |
611 | [sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c] |
612 | ||
613 | AT_CHECK([[cat tables.c]], 0, | |
c0c9ea05 | 614 | [[static const unsigned char yytranslate[] = |
b9752825 AD |
615 | { |
616 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
617 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
618 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
619 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
620 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
621 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
622 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
623 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
624 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
625 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
626 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
627 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
628 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
629 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
630 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
631 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
632 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
633 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
634 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
635 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
636 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
637 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
638 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
639 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
640 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
007a50a4 AD |
641 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
642 | 5, 6 | |
b9752825 | 643 | }; |
5df5f6d5 | 644 | static const unsigned char yyprhs[] = |
b9752825 | 645 | { |
e7b8bef1 | 646 | 0, 0, 3, 5, 6, 9, 14 |
b9752825 | 647 | }; |
7c78fa18 | 648 | static const yysigned_char yyrhs[] = |
b9752825 | 649 | { |
e7b8bef1 AD |
650 | 8, 0, -1, 9, -1, -1, 10, 11, -1, 3, |
651 | 4, 5, 8, -1, 6, 8, -1 | |
b9752825 | 652 | }; |
5df5f6d5 | 653 | static const unsigned char yyrline[] = |
b9752825 | 654 | { |
e7b8bef1 | 655 | 0, 2, 2, 3, 3, 4, 5 |
b9752825 AD |
656 | }; |
657 | static const char *const yytname[] = | |
658 | { | |
9e0876fb PE |
659 | "$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"", |
660 | "\"else\"", "$accept", "statement", "struct_stat", "if", "else", 0 | |
b9752825 | 661 | }; |
779e7ceb | 662 | static const unsigned short int yytoknum[] = |
b9752825 | 663 | { |
3650b4b8 | 664 | 0, 256, 257, 258, 259, 260, 261 |
b9752825 | 665 | }; |
c0c9ea05 | 666 | static const unsigned char yyr1[] = |
b9752825 | 667 | { |
e7b8bef1 | 668 | 0, 7, 8, 9, 9, 10, 11 |
b9752825 | 669 | }; |
5df5f6d5 | 670 | static const unsigned char yyr2[] = |
b9752825 | 671 | { |
e7b8bef1 | 672 | 0, 2, 1, 0, 2, 4, 2 |
b9752825 | 673 | }; |
a762e609 | 674 | static const unsigned char yydefact[] = |
b9752825 | 675 | { |
e8832397 | 676 | 3, 0, 0, 2, 0, 0, 1, 3, 4, 3, |
e7b8bef1 | 677 | 6, 5 |
b9752825 | 678 | }; |
7c78fa18 | 679 | static const yysigned_char yydefgoto[] = |
b9752825 | 680 | { |
e7b8bef1 | 681 | -1, 2, 3, 4, 8 |
b9752825 | 682 | }; |
7c78fa18 | 683 | static const yysigned_char yypact[] = |
b9752825 | 684 | { |
12b0043a AD |
685 | -2, -1, 4, -8, 0, 2, -8, -2, -8, -2, |
686 | -8, -8 | |
b9752825 | 687 | }; |
7c78fa18 | 688 | static const yysigned_char yypgoto[] = |
b9752825 | 689 | { |
12b0043a | 690 | -8, -7, -8, -8, -8 |
b9752825 | 691 | }; |
a762e609 | 692 | static const unsigned char yytable[] = |
b9752825 | 693 | { |
e7b8bef1 | 694 | 10, 1, 11, 5, 6, 0, 7, 9 |
b9752825 | 695 | }; |
7c78fa18 | 696 | static const yysigned_char yycheck[] = |
b9752825 | 697 | { |
e7b8bef1 | 698 | 7, 3, 9, 4, 0, -1, 6, 5 |
b9752825 | 699 | }; |
5504898e AD |
700 | static const unsigned char yystos[] = |
701 | { | |
702 | 0, 3, 8, 9, 10, 4, 0, 6, 11, 5, | |
703 | 8, 8 | |
704 | }; | |
b9752825 AD |
705 | ]]) |
706 | ||
707 | AT_CLEANUP | |
22e304a6 AD |
708 | |
709 | ||
710 | ## ------------------------- ## | |
711 | ## yycheck Bound Violation. ## | |
712 | ## ------------------------- ## | |
713 | ||
714 | ||
715 | # _AT_DATA_DANCER_Y(BISON-OPTIONS) | |
716 | # -------------------------------- | |
717 | # The following grammar, taken from Andrew Suffield's GPL'd implementation | |
718 | # of DGMTP, the Dancer Generic Message Transport Protocol, used to violate | |
719 | # yycheck's bounds where issuing a verbose error message. Keep this test | |
720 | # so that possible bound checking compilers could check all the skeletons. | |
721 | m4_define([_AT_DATA_DANCER_Y], | |
722 | [AT_DATA_GRAMMAR([dancer.y], | |
723 | [%{ | |
848dc439 PE |
724 | static int yylex (AT_LALR1_CC_IF([int *], [void])); |
725 | AT_LALR1_CC_IF([], | |
22e304a6 | 726 | [#include <stdio.h> |
848dc439 | 727 | static void yyerror (const char *);]) |
22e304a6 AD |
728 | %} |
729 | $1 | |
730 | %token ARROW INVALID NUMBER STRING DATA | |
731 | %defines | |
732 | %verbose | |
733 | %error-verbose | |
734 | /* Grammar follows */ | |
735 | %% | |
736 | line: header body | |
737 | ; | |
738 | ||
739 | header: '<' from ARROW to '>' type ':' | |
740 | | '<' ARROW to '>' type ':' | |
741 | | ARROW to type ':' | |
742 | | type ':' | |
743 | | '<' '>' | |
744 | ; | |
745 | ||
746 | from: DATA | |
747 | | STRING | |
748 | | INVALID | |
749 | ; | |
750 | ||
751 | to: DATA | |
752 | | STRING | |
753 | | INVALID | |
754 | ; | |
755 | ||
756 | type: DATA | |
757 | | STRING | |
758 | | INVALID | |
759 | ; | |
760 | ||
761 | body: /* empty */ | |
762 | | body member | |
763 | ; | |
764 | ||
765 | member: STRING | |
766 | | DATA | |
767 | | '+' NUMBER | |
768 | | '-' NUMBER | |
769 | | NUMBER | |
770 | | INVALID | |
771 | ; | |
772 | %% | |
773 | AT_LALR1_CC_IF( | |
68e11668 | 774 | [/* A C++ error reporting function. */ |
22e304a6 | 775 | void |
99880de5 | 776 | yy::parser::error (const location&, const std::string& m) |
22e304a6 | 777 | { |
efeed023 | 778 | std::cerr << m << std::endl; |
22e304a6 AD |
779 | } |
780 | ||
781 | int | |
99880de5 | 782 | yyparse () |
22e304a6 | 783 | { |
99880de5 | 784 | yy::parser parser; |
a3cb6248 | 785 | parser.set_debug_level (!!YYDEBUG); |
22e304a6 AD |
786 | return parser.parse (); |
787 | } | |
788 | ], | |
789 | [static void | |
790 | yyerror (const char *s) | |
791 | { | |
792 | fprintf (stderr, "%s\n", s); | |
793 | }]) | |
794 | ||
795 | static int | |
848dc439 | 796 | yylex (AT_LALR1_CC_IF([int *lval], [void])) |
22e304a6 AD |
797 | [{ |
798 | static int toknum = 0; | |
799 | int tokens[] = | |
800 | { | |
801 | ':', -1 | |
802 | }; | |
848dc439 | 803 | ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[ |
22e304a6 AD |
804 | return tokens[toknum++]; |
805 | }] | |
806 | ||
807 | int | |
808 | main (void) | |
809 | { | |
810 | return yyparse (); | |
811 | } | |
812 | ]) | |
813 | ])# _AT_DATA_DANCER_Y | |
814 | ||
815 | ||
816 | # AT_CHECK_DANCER(BISON-OPTIONS) | |
817 | # ------------------------------ | |
818 | # Generate the grammar, compile it, run it. | |
819 | m4_define([AT_CHECK_DANCER], | |
820 | [AT_SETUP([Dancer $1]) | |
821 | AT_BISON_OPTION_PUSHDEFS([$1]) | |
822 | _AT_DATA_DANCER_Y([$1]) | |
823 | AT_CHECK([bison -o dancer.c dancer.y]) | |
07971983 PE |
824 | AT_LALR1_CC_IF( |
825 | [AT_CHECK([bison -o dancer.cc dancer.y]) | |
826 | AT_COMPILE_CXX([dancer])], | |
827 | [AT_CHECK([bison -o dancer.c dancer.y]) | |
828 | AT_COMPILE([dancer])]) | |
22e304a6 | 829 | AT_PARSER_CHECK([./dancer], 1, [], |
d5286af1 | 830 | [syntax error, unexpected ':' |
22e304a6 AD |
831 | ]) |
832 | AT_BISON_OPTION_POPDEFS | |
833 | AT_CLEANUP | |
834 | ]) | |
835 | ||
836 | AT_CHECK_DANCER() | |
837 | AT_CHECK_DANCER([%glr-parser]) | |
838 | AT_CHECK_DANCER([%skeleton "lalr1.cc"]) |