]> git.saurik.com Git - bison.git/blob - tests/skeletons.at
281986d42dd01d3820329e924e306aef35e2dc92
[bison.git] / tests / skeletons.at
1 # Checking skeleton support. -*- Autotest -*-
2 # Copyright (C) 2007 Free Software Foundation, Inc.
3
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.
8
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.
13
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., 51 Franklin Street, Fifth Floor, Boston, MA
17 # 02110-1301, USA.
18
19 AT_BANNER([[Skeleton Support.]])
20
21 ## ------------------------------ ##
22 ## relative skeleton file names. ##
23 ## ------------------------------ ##
24
25 AT_SETUP([[relative skeleton file names]])
26
27 AT_CHECK([[mkdir tmp]])
28
29 AT_DATA([[tmp/skel.c]],
30 [[m4@&t@_divert_push(0)d@&t@nl
31 @output(b4_parser_file_name@)d@&t@nl
32 b4_percent_define_get([[test]])
33 m4@&t@_divert_pop(0)
34 ]])
35
36 AT_DATA([[skel.c]],
37 [[m4@&t@_divert_push(0)d@&t@nl
38 @output(b4_parser_file_name@)d@&t@nl
39 b4_percent_define_get([[test]]) -- Local
40 m4@&t@_divert_pop(0)
41 ]])
42
43 AT_DATA([[tmp/input-gram.y]],
44 [[%skeleton "./skel.c"
45 %define test "Hello World"
46 %%
47 start: ;
48 ]])
49
50 AT_DATA([[input-gram.y]],
51 [[%skeleton "./skel.c"
52 %define test "Hello World"
53 %%
54 start: ;
55 ]])
56
57 AT_DATA([[tmp/input-cmd-line.y]],
58 [[%define test "Hello World"
59 %%
60 start: ;
61 ]])
62
63 AT_CHECK([[bison tmp/input-gram.y]])
64 AT_CHECK([[cat input-gram.tab.c]], [[0]],
65 [[Hello World
66 ]])
67
68 AT_CHECK([[bison input-gram.y]])
69 AT_CHECK([[cat input-gram.tab.c]], [[0]],
70 [[Hello World -- Local
71 ]])
72
73 AT_CHECK([[bison --skeleton=tmp/skel.c tmp/input-cmd-line.y]])
74 AT_CHECK([[cat input-cmd-line.tab.c]], [[0]],
75 [[Hello World
76 ]])
77
78 AT_CLEANUP
79
80
81 ## ------------------------------- ##
82 ## installed skeleton file names. ##
83 ## ------------------------------- ##
84
85 AT_SETUP([[installed skeleton file names]])
86
87 m4_pushdef([AT_GRAM],
88 [[%{
89 #include <stdio.h>
90 void yyerror (char const *msg);
91 int yylex (void);
92 %}
93
94 %error-verbose
95 %token 'a'
96
97 %%
98
99 start: ;
100
101 %%
102
103 void
104 yyerror (char const *msg)
105 {
106 fprintf (stderr, "%s\n", msg);
107 }
108
109 int
110 yylex (void)
111 {
112 return 'a';
113 }
114
115 int
116 main (void)
117 {
118 return yyparse ();
119 }
120 ]])
121
122 AT_DATA([[input-cmd-line.y]],
123 [AT_GRAM])
124
125 AT_DATA([[input-gram.y]],
126 [[%skeleton "yacc.c"]
127 AT_GRAM])
128
129 AT_CHECK([[bison --skeleton=yacc.c -o input-cmd-line.c input-cmd-line.y]])
130 AT_COMPILE([[input-cmd-line]])
131 AT_PARSER_CHECK([[./input-cmd-line]], [[1]], [],
132 [[syntax error, unexpected 'a', expecting $end
133 ]])
134
135 AT_CHECK([[bison -o input-gram.c input-gram.y]])
136 AT_COMPILE([[input-gram]])
137 AT_PARSER_CHECK([[./input-gram]], [[1]], [],
138 [[syntax error, unexpected 'a', expecting $end
139 ]])
140
141 m4_popdef([AT_GRAM])
142
143 AT_CLEANUP