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