]> git.saurik.com Git - bison.git/blame - tests/skeletons.at
In impure push mode, don't allow more than one yypstate to be allocated
[bison.git] / tests / skeletons.at
CommitLineData
a7867f53
JD
1# Checking skeleton support. -*- Autotest -*-
2# Copyright (C) 2007 Free Software Foundation, Inc.
3
f16b0819 4# This program is free software: you can redistribute it and/or modify
a7867f53 5# it under the terms of the GNU General Public License as published by
f16b0819
PE
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
a7867f53
JD
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.
f16b0819 13#
a7867f53 14# You should have received a copy of the GNU General Public License
f16b0819 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
a7867f53 16
3eb82471 17AT_BANNER([[Skeleton Support.]])
a7867f53
JD
18
19## ------------------------------ ##
9611cfa2 20## Relative skeleton file names. ##
a7867f53
JD
21## ------------------------------ ##
22
9611cfa2 23AT_SETUP([[Relative skeleton file names]])
a7867f53
JD
24
25AT_CHECK([[mkdir tmp]])
26
27AT_DATA([[tmp/skel.c]],
28[[m4@&t@_divert_push(0)d@&t@nl
29@output(b4_parser_file_name@)d@&t@nl
30b4_percent_define_get([[test]])
31m4@&t@_divert_pop(0)
32]])
33
34AT_DATA([[skel.c]],
35[[m4@&t@_divert_push(0)d@&t@nl
36@output(b4_parser_file_name@)d@&t@nl
37b4_percent_define_get([[test]]) -- Local
38m4@&t@_divert_pop(0)
39]])
40
41AT_DATA([[tmp/input-gram.y]],
42[[%skeleton "./skel.c"
43%define test "Hello World"
44%%
45start: ;
46]])
47
48AT_DATA([[input-gram.y]],
49[[%skeleton "./skel.c"
50%define test "Hello World"
51%%
52start: ;
53]])
54
55AT_DATA([[tmp/input-cmd-line.y]],
56[[%define test "Hello World"
57%%
58start: ;
59]])
60
61AT_CHECK([[bison tmp/input-gram.y]])
62AT_CHECK([[cat input-gram.tab.c]], [[0]],
63[[Hello World
64]])
65
66AT_CHECK([[bison input-gram.y]])
67AT_CHECK([[cat input-gram.tab.c]], [[0]],
68[[Hello World -- Local
69]])
70
71AT_CHECK([[bison --skeleton=tmp/skel.c tmp/input-cmd-line.y]])
72AT_CHECK([[cat input-cmd-line.tab.c]], [[0]],
73[[Hello World
74]])
75
76AT_CLEANUP
77
78
3eb82471 79## ------------------------------- ##
9611cfa2 80## Installed skeleton file names. ##
3eb82471 81## ------------------------------- ##
a7867f53 82
9611cfa2 83AT_SETUP([[Installed skeleton file names]])
a7867f53
JD
84
85m4_pushdef([AT_GRAM],
86[[%{
87 #include <stdio.h>
88 void yyerror (char const *msg);
89 int yylex (void);
90%}
91
92%error-verbose
93%token 'a'
94
95%%
96
97start: ;
98
99%%
100
101void
102yyerror (char const *msg)
103{
104 fprintf (stderr, "%s\n", msg);
105}
106
107int
108yylex (void)
109{
110 return 'a';
111}
112
113int
114main (void)
115{
116 return yyparse ();
117}
118]])
119
120AT_DATA([[input-cmd-line.y]],
121[AT_GRAM])
122
123AT_DATA([[input-gram.y]],
124[[%skeleton "yacc.c"]
125AT_GRAM])
126
127AT_CHECK([[bison --skeleton=yacc.c -o input-cmd-line.c input-cmd-line.y]])
128AT_COMPILE([[input-cmd-line]])
129AT_PARSER_CHECK([[./input-cmd-line]], [[1]], [],
130[[syntax error, unexpected 'a', expecting $end
131]])
132
133AT_CHECK([[bison -o input-gram.c input-gram.y]])
134AT_COMPILE([[input-gram]])
135AT_PARSER_CHECK([[./input-gram]], [[1]], [],
136[[syntax error, unexpected 'a', expecting $end
137]])
138
139m4_popdef([AT_GRAM])
140
141AT_CLEANUP
9611cfa2
JD
142
143
144## ------------------------------------------------------ ##
145## %define boolean variables: invalid skeleton defaults. ##
146## ------------------------------------------------------ ##
147
148AT_SETUP([[%define boolean variables: invalid skeleton defaults]])
149
150AT_CHECK([[mkdir tmp]])
151
152AT_DATA([[skel.c]],
153[[b4_percent_define_default([[foo]], [[bogus value]])
154b4_percent_define_flag_if([[foo]])
155]])
156
157AT_DATA([[input.y]],
158[[%skeleton "./skel.c"
159%%
160start: ;
161]])
162
163AT_CHECK([[bison input.y]], [[1]], [[]],
164[[[Bison:b4_percent_define_default]:0.0: invalid value for %define boolean variable `foo'
165]])
166
167AT_CLEANUP
168
169