]> git.saurik.com Git - bison.git/blame_incremental - tests/input.at
Use ASCII for Sebastien Fricker's name.
[bison.git] / tests / input.at
... / ...
CommitLineData
1# Checking the Bison scanner. -*- Autotest -*-
2# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
3# Inc.
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18# 02110-1301, USA.
19
20AT_BANNER([[Input Processing.]])
21
22# Mostly test that we are robust to mistakes.
23
24
25## ------------ ##
26## Invalid $n. ##
27## ------------ ##
28
29AT_SETUP([Invalid $n and @n])
30
31AT_DATA([input.y],
32[[%%
33exp: { $$ = $1 ; };
34exp: { @$ = @1 ; };
35]])
36
37AT_CHECK([bison input.y], [1], [],
38[[input.y:2.13-14: integer out of range: `$1'
39input.y:3.13-14: integer out of range: `@1'
40]])
41
42AT_CLEANUP
43
44
45## -------------- ##
46## Type Clashes. ##
47## -------------- ##
48
49AT_SETUP([Type Clashes])
50
51AT_DATA([input.y],
52[[%union { int bar; }
53%token foo
54%type <bar> exp
55%%
56exp: foo { $$; } foo { $2; } foo
57 | foo
58 | /* Empty. */
59 ;
60]])
61
62AT_CHECK([bison input.y], [1], [],
63[[input.y:5.12-13: $$ for the midrule at $2 of `exp' has no declared type
64input.y:5.24-25: $2 of `exp' has no declared type
65input.y:5.6-32: warning: type clash on default action: <bar> != <>
66input.y:6.6-8: warning: type clash on default action: <bar> != <>
67input.y:7.5: warning: empty rule for typed nonterminal, and no action
68]])
69
70AT_CLEANUP
71
72
73# _AT_UNUSED_VALUES_DECLARATIONS()
74# --------------------------------------------
75# Generate the token, type, and destructor
76# declarations for the unused values tests.
77
78m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
79[[[%token <integer> INT;
80%type <integer> a b c d e f g h i j k l;
81%destructor { destroy ($$); } INT a b c d e f g h i j k l;]]])
82
83
84# AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
85# ------------------------------------------------------------------
86# Generate a grammar to test unused values,
87# compile it, run it. If DECLARATIONS_AFTER
88# is set, then the token, type, and destructor
89# declarations are generated after the rules
90# rather than before. If CHECK_MIDRULE_VALUES
91# is set, then --warnings=midrule-values is
92# set.
93
94m4_define([AT_CHECK_UNUSED_VALUES],
95[AT_DATA([input.y],
96m4_ifval($1, [
97
98
99], [_AT_UNUSED_VALUES_DECLARATIONS
100])[[%%
101start:
102 'a' a { $]2[ } | 'b' b { $]2[ } | 'c' c { $]2[ } | 'd' d { $]2[ } | 'e' e { $]2[ }
103| 'f' f { $]2[ } | 'g' g { $]2[ } | 'h' h { $]2[ } | 'i' i { $]2[ } | 'j' j { $]2[ }
104| 'k' k { $]2[ } | 'l' l { $]2[ }
105;
106
107a: INT | INT { } INT { } INT { };
108b: INT | /* empty */;
109c: INT | INT { $]1[ } INT { $<integer>2 } INT { $<integer>4 };
110d: INT | INT { } INT { $]1[ } INT { $<integer>2 };
111e: INT | INT { } INT { } INT { $]1[ };
112f: INT | INT { } INT { } INT { $]$[ = $]1[ + $]3[ + $]5[; };
113g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
114h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
115i: INT | INT INT { } { $]$[ = $]1[ + $]2[; };
116j: INT | INT INT { $<integer>$ = 1; } { $]$[ = $]1[ + $]2[; };
117k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
118l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<integer>3; } INT { $<integer>$ = $<integer>4 + $<integer>5; };]]m4_ifval($1, [
119_AT_UNUSED_VALUES_DECLARATIONS])
120)
121
122AT_CHECK([bison]m4_ifval($2, [ --warnings=midrule-values ])[ input.y], [0], [],
123[[input.y:11.10-32: warning: unset value: $]$[
124input.y:11.10-32: warning: unused value: $]1[
125input.y:11.10-32: warning: unused value: $]3[
126input.y:11.10-32: warning: unused value: $]5[
127input.y:12.9: warning: empty rule for typed nonterminal, and no action
128]]m4_ifval($2, [[[input.y:13.14-19: warning: unset value: $$
129input.y:13.25-39: warning: unset value: $$
130]]])[[input.y:13.10-59: warning: unset value: $]$[
131input.y:13.10-59: warning: unused value: $]3[
132input.y:13.10-59: warning: unused value: $]5[
133]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $$
134]]])[[input.y:14.10-47: warning: unset value: $]$[
135input.y:14.10-47: warning: unused value: $]3[
136input.y:14.10-47: warning: unused value: $]5[
137input.y:15.10-36: warning: unset value: $]$[
138input.y:15.10-36: warning: unused value: $]3[
139input.y:15.10-36: warning: unused value: $]5[
140input.y:17.10-58: warning: unset value: $]$[
141input.y:17.10-58: warning: unused value: $]1[
142]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]2[
143]]])[[input.y:17.10-58: warning: unused value: $]3[
144]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]4[
145]]])[[input.y:17.10-58: warning: unused value: $]5[
146input.y:18.10-72: warning: unset value: $]$[
147input.y:18.10-72: warning: unused value: $]1[
148input.y:18.10-72: warning: unused value: $]3[
149]]m4_ifval($2, [[[input.y:18.10-72: warning: unused value: $]4[
150]]])[[input.y:18.10-72: warning: unused value: $]5[
151]]m4_ifval($2, [[[input.y:20.10-55: warning: unused value: $]3[
152]]])[[input.y:21.10-68: warning: unset value: $]$[
153input.y:21.10-68: warning: unused value: $]1[
154input.y:21.10-68: warning: unused value: $]2[
155]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[
156]]]))])
157
158
159## --------------- ##
160## Unused values. ##
161## --------------- ##
162
163AT_SETUP([Unused values])
164AT_CHECK_UNUSED_VALUES
165AT_CHECK_UNUSED_VALUES(, [1])
166AT_CLEANUP
167
168
169## ------------------------------------------ ##
170## Unused values before symbol declarations. ##
171## ------------------------------------------ ##
172
173AT_SETUP([Unused values before symbol declarations])
174AT_CHECK_UNUSED_VALUES([1])
175AT_CHECK_UNUSED_VALUES([1], [1])
176AT_CLEANUP
177
178
179## --------------------------------------------- ##
180## Default %printer and %destructor redeclared. ##
181## --------------------------------------------- ##
182
183AT_SETUP([Default %printer and %destructor redeclared])
184
185AT_DATA([[input.y]],
186[[%destructor { destroy ($$); } <*> <*>
187%printer { destroy ($$); } <*> <*>
188
189%destructor { destroy ($$); } <*>
190%printer { destroy ($$); } <*>
191
192%destructor { destroy ($$); } <> <>
193%printer { destroy ($$); } <> <>
194
195%destructor { destroy ($$); } <>
196%printer { destroy ($$); } <>
197
198%%
199
200start: ;
201
202%destructor { destroy ($$); } <*>;
203%printer { destroy ($$); } <*>;
204
205%destructor { destroy ($$); } <>;
206%printer { destroy ($$); } <>;
207]])
208
209AT_CHECK([bison input.y], [1], [],
210[[input.y:1.13-29: redeclaration for default tagged %destructor
211input.y:1.13-29: previous declaration
212input.y:2.10-26: redeclaration for default tagged %printer
213input.y:2.10-26: previous declaration
214input.y:4.13-29: redeclaration for default tagged %destructor
215input.y:1.13-29: previous declaration
216input.y:5.10-26: redeclaration for default tagged %printer
217input.y:2.10-26: previous declaration
218input.y:7.13-29: redeclaration for default tagless %destructor
219input.y:7.13-29: previous declaration
220input.y:8.10-26: redeclaration for default tagless %printer
221input.y:8.10-26: previous declaration
222input.y:10.13-29: redeclaration for default tagless %destructor
223input.y:7.13-29: previous declaration
224input.y:11.10-26: redeclaration for default tagless %printer
225input.y:8.10-26: previous declaration
226input.y:17.13-29: redeclaration for default tagged %destructor
227input.y:4.13-29: previous declaration
228input.y:18.10-26: redeclaration for default tagged %printer
229input.y:5.10-26: previous declaration
230input.y:20.13-29: redeclaration for default tagless %destructor
231input.y:10.13-29: previous declaration
232input.y:21.10-26: redeclaration for default tagless %printer
233input.y:11.10-26: previous declaration
234]])
235
236AT_CLEANUP
237
238
239## ---------------------------------------------- ##
240## Per-type %printer and %destructor redeclared. ##
241## ---------------------------------------------- ##
242
243AT_SETUP([Per-type %printer and %destructor redeclared])
244
245AT_DATA([[input.y]],
246[[%destructor { destroy ($$); } <field1> <field2>
247%printer { destroy ($$); } <field1> <field2>
248
249%destructor { destroy ($$); } <field1> <field1>
250%printer { destroy ($$); } <field2> <field2>
251
252%%
253
254start: ;
255
256%destructor { destroy ($$); } <field2> <field1>;
257%printer { destroy ($$); } <field2> <field1>;
258]])
259
260AT_CHECK([bison input.y], [1], [],
261[[input.y:4.13-29: %destructor redeclaration for <field1>
262input.y:1.13-29: previous declaration
263input.y:4.13-29: %destructor redeclaration for <field1>
264input.y:4.13-29: previous declaration
265input.y:5.10-26: %printer redeclaration for <field2>
266input.y:2.10-26: previous declaration
267input.y:5.10-26: %printer redeclaration for <field2>
268input.y:5.10-26: previous declaration
269input.y:11.13-29: %destructor redeclaration for <field1>
270input.y:4.13-29: previous declaration
271input.y:11.13-29: %destructor redeclaration for <field2>
272input.y:1.13-29: previous declaration
273input.y:12.10-26: %printer redeclaration for <field1>
274input.y:2.10-26: previous declaration
275input.y:12.10-26: %printer redeclaration for <field2>
276input.y:5.10-26: previous declaration
277]])
278
279AT_CLEANUP
280
281
282## ---------------------------------------- ##
283## Unused values with default %destructor. ##
284## ---------------------------------------- ##
285
286AT_SETUP([Unused values with default %destructor])
287
288AT_DATA([[input.y]],
289[[%destructor { destroy ($$); } <>
290%type <tag> tagged
291
292%%
293
294start: end end tagged tagged { $<tag>1; $3; } ;
295end: { } ;
296tagged: { } ;
297]])
298
299AT_CHECK([bison input.y], [0], [],
300[[input.y:6.8-45: warning: unset value: $$
301input.y:6.8-45: warning: unused value: $2
302input.y:7.6-8: warning: unset value: $$
303]])
304
305AT_DATA([[input.y]],
306[[%destructor { destroy ($$); } <*>
307%type <tag> tagged
308
309%%
310
311start: end end tagged tagged { $<tag>1; $3; } ;
312end: { } ;
313tagged: { } ;
314]])
315
316AT_CHECK([bison input.y], [0], [],
317[[input.y:6.8-45: warning: unused value: $4
318input.y:8.9-11: warning: unset value: $$
319]])
320
321AT_CLEANUP
322
323
324## ----------------------------------------- ##
325## Unused values with per-type %destructor. ##
326## ----------------------------------------- ##
327
328AT_SETUP([Unused values with per-type %destructor])
329
330AT_DATA([[input.y]],
331[[%destructor { destroy ($$); } <field1>
332%type <field1> start end
333
334%%
335
336start: end end { $1; } ;
337end: { } ;
338]])
339
340AT_CHECK([bison input.y], [0], [],
341[[input.y:6.8-22: warning: unset value: $$
342input.y:6.8-22: warning: unused value: $2
343input.y:7.6-8: warning: unset value: $$
344]])
345
346AT_CLEANUP
347
348
349## ---------------------- ##
350## Incompatible Aliases. ##
351## ---------------------- ##
352
353AT_SETUP([Incompatible Aliases])
354
355AT_DATA([input.y],
356[[%token foo "foo"
357
358%type <bar> foo
359%printer {bar} foo
360%destructor {bar} foo
361%left foo
362
363%type <baz> "foo"
364%printer {baz} "foo"
365%destructor {baz} "foo"
366%left "foo"
367
368%%
369exp: foo;
370]])
371
372AT_CHECK([bison input.y], [1], [],
373[[input.y:8.7-11: %type redeclaration for foo
374input.y:3.7-11: previous declaration
375input.y:10.13-17: %destructor redeclaration for foo
376input.y:5.13-17: previous declaration
377input.y:9.10-14: %printer redeclaration for foo
378input.y:4.10-14: previous declaration
379input.y:11.1-5: %left redeclaration for foo
380input.y:6.1-5: previous declaration
381]])
382
383AT_CLEANUP
384
385
386
387## ----------------------- ##
388## Torturing the Scanner. ##
389## ----------------------- ##
390
391# Be sure to compile and run, so that the C compiler checks what
392# we do.
393
394AT_SETUP([Torturing the Scanner])
395
396
397AT_DATA([input.y], [])
398AT_CHECK([bison input.y], [1], [],
399[[input.y:1.1: syntax error, unexpected end of file
400]])
401
402
403AT_DATA([input.y],
404[{}
405])
406AT_CHECK([bison input.y], [1], [],
407[[input.y:1.1-2: syntax error, unexpected {...}
408]])
409
410
411AT_DATA_GRAMMAR([input.y],
412[[%{
413/* This is seen in GCC: a %{ and %} in middle of a comment. */
414const char *foo = "So %{ and %} can be here too.";
415
416#if 0
417/* These examples test Bison while not stressing C compilers too much.
418 Many C compilers mishandle backslash-newlines, so this part of the
419 test is inside "#if 0". The comment and string are written so that
420 the "#endif" will be seen regardless of the C compiler bugs that we
421 know about, namely:
422
423 HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
424 comment.
425
426 The Apple Darwin compiler (as of late 2002) mishandles
427 \\[newline]' within a character constant.
428
429 */
430
431/\
432* A comment with backslash-newlines in it. %} *\
433\
434/
435/* { Close the above comment, if the C compiler mishandled it. */
436
437char str[] = "\\
438" A string with backslash-newlines in it %{ %} \\
439\
440"";
441
442char apostrophe = '\'';
443#endif
444
445#include <stdio.h>
446#include <stdlib.h>
447%}
448/* %{ and %} can be here too. */
449
450%{
451/* Exercise pre-prologue dependency to %union. */
452typedef int value;
453%}
454
455/* Exercise M4 quoting: '@:>@@:>@', 0. */
456
457/* Also exercise %union. */
458%union
459{
460 value ival; /* A comment to exercise an old bug. */
461};
462
463
464/* Exercise post-prologue dependency to %union. */
465%{
466static YYSTYPE value_as_yystype (value val);
467
468/* Exercise quotes in declarations. */
469char quote[] = "@:>@@:>@,";
470%}
471
472%{
473static void yyerror (const char *s);
474static int yylex (void);
475%}
476
477%type <ival> '@<:@'
478
479/* Exercise quotes in strings. */
480%token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
481
482%%
483/* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
484exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
485 {
486 /* Exercise quotes in braces. */
487 char tmp[] = "@<:@%c@:>@,\n";
488 printf (tmp, $1);
489 }
490;
491
492two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
493oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
494output.or.oline.opt: ;|oline;;|output;;;
495output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
496%%
497/* Exercise M4 quoting: '@:>@@:>@', @<:@, 2. */
498
499static YYSTYPE
500value_as_yystype (value val)
501{
502 YYSTYPE res;
503 res.ival = val;
504 return res;
505}
506
507static int
508yylex (void)
509{
510 static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
511#output "; /* "
512 */
513 static size_t toknum;
514 if (! (toknum < sizeof input))
515 abort ();
516 yylval = value_as_yystype (input[toknum]);
517 return input[toknum++];
518}
519
520static void
521yyerror (const char *msg)
522{
523 fprintf (stderr, "%s\n", msg);
524}
525]])
526
527# Pacify Emacs'font-lock-mode: "
528
529AT_DATA([main.c],
530[[typedef int value;
531#include "input.h"
532
533int yyparse (void);
534
535int
536main (void)
537{
538 return yyparse ();
539}
540]])
541
542AT_CHECK([bison -d -v -o input.c input.y])
543AT_COMPILE([input.o], [-c input.c])
544AT_COMPILE([main.o], [-c main.c])
545AT_COMPILE([input], [input.o main.o])
546AT_PARSER_CHECK([./input], 0,
547[[[@<:@],
548]])
549
550AT_CLEANUP
551
552
553## ---------------------- ##
554## Typed symbol aliases. ##
555## ---------------------- ##
556
557AT_SETUP([Typed symbol aliases])
558
559# Bison 2.0 broke typed symbol aliases - ensure they work.
560
561AT_DATA_GRAMMAR([input.y],
562[[%union
563{
564 int val;
565};
566%token <val> MY_TOKEN "MY TOKEN"
567%type <val> exp
568%%
569exp: "MY TOKEN";
570%%
571]])
572
573AT_CHECK([bison -o input.c input.y])
574
575AT_CLEANUP
576
577
578## --------- ##
579## Require. ##
580## --------- ##
581
582m4_define([AT_CHECK_REQUIRE],
583[AT_SETUP([Require $1])
584AT_DATA_GRAMMAR([input.y],
585[[%require "$1";
586%%
587empty_file:;
588]])
589AT_CHECK([bison -o input.c input.y], $2, [], ignore)
590AT_CLEANUP
591])
592
593AT_CHECK_REQUIRE(1.0, 0)
594AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
595## FIXME: Some day augment this version number.
596AT_CHECK_REQUIRE(100.0, 63)
597
598
599## ------------------------------------- ##
600## String aliases for character tokens. ##
601## ------------------------------------- ##
602
603AT_SETUP([String aliases for character tokens])
604
605# Bison once thought a character token and its alias were different symbols
606# with the same user token number.
607
608AT_DATA_GRAMMAR([input.y],
609[[%token 'a' "a"
610%%
611start: 'a';
612%%
613]])
614
615AT_CHECK([bison -o input.c input.y])
616
617AT_CLEANUP
618
619
620## --------------------- ##
621## Unclosed constructs. ##
622## --------------------- ##
623
624AT_SETUP([Unclosed constructs])
625
626# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so
627# they were prepended to whatever it STRING_GROW'ed next. It also threw them
628# away rather than returning them to the parser. The effect was confusing
629# subsequent error messages.
630
631AT_DATA([input.y],
632[[%token A "a
633%token B "b"
634%token AB "ab" // Used to complain that "ab" was already used.
635%token C '1
636%token TWO "2"
637%token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
638
639%%
640
641start: ;
642
643// Used to report a syntax error because it didn't see any kind of symbol
644// identifier.
645%type <f> 'a
646;
647%type <f> "a
648;
649// Used to report a syntax error because it didn't see braced code.
650%destructor { free ($$)
651]])
652
653AT_CHECK([bison -o input.c input.y], 1, [],
654[[input.y:1.10-2.0: missing `"' at end of line
655input.y:4.10-5.0: missing `'' at end of line
656input.y:14.11-15.0: missing `'' at end of line
657input.y:16.11-17.0: missing `"' at end of line
658input.y:19.13-20.0: missing `}' at end of file
659input.y:20.1: syntax error, unexpected end of file
660]])
661
662AT_CLEANUP
663
664
665## ------------------------- ##
666## %start after first rule. ##
667## ------------------------- ##
668
669AT_SETUP([%start after first rule])
670
671# Bison once complained that a %start after the first rule was a redeclaration
672# of the start symbol.
673
674AT_DATA([input.y],
675[[%%
676false_start: ;
677start: false_start ;
678%start start;
679]])
680
681AT_CHECK([bison -o input.c input.y])
682
683AT_CLEANUP
684
685
686## --------------------- ##
687## %prec takes a token. ##
688## --------------------- ##
689
690AT_SETUP([%prec takes a token])
691
692# Bison once allowed %prec sym where sym was a nonterminal.
693
694AT_DATA([input.y],
695[[%%
696start: PREC %prec PREC ;
697PREC: ;
698]])
699
700AT_CHECK([bison input.y], [1], [],
701[[input.y:3.1-4: rule given for PREC, which is a token
702]])
703
704AT_CLEANUP
705
706
707## -------------------------------- ##
708## Reject unused %code qualifiers. ##
709## -------------------------------- ##
710
711AT_SETUP([Reject unused %code qualifiers])
712
713AT_DATA([input-c.y],
714[[%code q {}
715%code bad {}
716%code bad {}
717%code format {}
718%%
719start: ;
720]])
721AT_CHECK([[bison input-c.y]], [0], [],
722[[input-c.y:1.7: warning: %code qualifier `q' is not used
723input-c.y:2.7-9: warning: %code qualifier `bad' is not used
724input-c.y:3.7-9: warning: %code qualifier `bad' is not used
725input-c.y:4.7-12: warning: %code qualifier `format' is not used
726]])
727
728AT_DATA([input-c-glr.y],
729[[%code q {}
730%code bad {}
731 %code bad {}
732%%
733start: ;
734]])
735AT_CHECK([[bison input-c-glr.y]], [0], [],
736[[input-c-glr.y:1.7: warning: %code qualifier `q' is not used
737input-c-glr.y:2.7-9: warning: %code qualifier `bad' is not used
738input-c-glr.y:3.8-10: warning: %code qualifier `bad' is not used
739]])
740
741AT_DATA([input-c++.y],
742[[%code q {}
743%code bad {}
744 %code q {}
745%%
746start: ;
747]])
748AT_CHECK([[bison input-c++.y]], [0], [],
749[[input-c++.y:1.7: warning: %code qualifier `q' is not used
750input-c++.y:2.7-9: warning: %code qualifier `bad' is not used
751input-c++.y:3.8: warning: %code qualifier `q' is not used
752]])
753
754AT_DATA([input-c++-glr.y],
755[[%code bad {}
756%code q {}
757%code q {}
758%%
759start: ;
760]])
761AT_CHECK([[bison input-c++-glr.y]], [0], [],
762[[input-c++-glr.y:1.7-9: warning: %code qualifier `bad' is not used
763input-c++-glr.y:2.7: warning: %code qualifier `q' is not used
764input-c++-glr.y:3.7: warning: %code qualifier `q' is not used
765]])
766
767AT_DATA([special-char-@@.y],
768[[%code bad {}
769%code q {}
770%code q {}
771%%
772start: ;
773]])
774AT_CHECK([[bison special-char-@@.y]], [0], [],
775[[special-char-@@.y:1.7-9: warning: %code qualifier `bad' is not used
776special-char-@@.y:2.7: warning: %code qualifier `q' is not used
777special-char-@@.y:3.7: warning: %code qualifier `q' is not used
778]])
779
780AT_DATA([special-char-@:>@.y],
781[[%code bad {}
782%code q {}
783%code q {}
784%%
785start: ;
786]])
787AT_CHECK([[bison special-char-@:>@.y]], [0], [],
788[[special-char-@:>@.y:1.7-9: warning: %code qualifier `bad' is not used
789special-char-@:>@.y:2.7: warning: %code qualifier `q' is not used
790special-char-@:>@.y:3.7: warning: %code qualifier `q' is not used
791]])
792
793AT_CLEANUP
794
795
796## ---------------- ##
797## %define errors. ##
798## ---------------- ##
799
800AT_SETUP([%define errors])
801
802AT_DATA([input.y],
803[[%define var "value1"
804%define var "value1"
805 %define var "value2"
806%define special1 "@:>@"
807%define special2 "@<:@"
808%%
809start: ;
810]])
811
812AT_CHECK([[bison input.y]], [0], [],
813[[input.y:2.9-11: warning: %define variable `var' redefined
814input.y:1.9-11: warning: previous definition
815input.y:3.10-12: warning: %define variable `var' redefined
816input.y:2.9-11: warning: previous definition
817input.y:1.9-11: warning: %define variable `var' is not used
818input.y:2.9-11: warning: %define variable `var' is not used
819input.y:3.10-12: warning: %define variable `var' is not used
820input.y:4.9-16: warning: %define variable `special1' is not used
821input.y:5.9-16: warning: %define variable `special2' is not used
822]])
823
824AT_CLEANUP
825
826## --------------------------- ##
827## Boolean %define variables. ##
828## --------------------------- ##
829
830AT_SETUP([Boolean %define variables])
831
832AT_DATA([Input.y],
833[[%language "Java"
834%define public "maybe"
835%define parser_class_name "Input"
836%%
837start: ;
838]])
839
840AT_CHECK([[bison Input.y]], [1], [],
841[[Input.y:2.9-14: invalid value for %define boolean variable `public'
842]])
843
844AT_CLEANUP