Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / byacc / dist / test / grammar.tab.c
blob22eb0b88235fa4a3b47e60837f5de4a77d770b53
1 /* $NetBSD$ */
3 #ifndef lint
4 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
5 #endif
7 #include <stdlib.h>
8 #include <string.h>
10 #define YYBYACC 1
11 #define YYMAJOR 1
12 #define YYMINOR 9
14 #define YYEMPTY (-1)
15 #define yyclearin (yychar = YYEMPTY)
16 #define yyerrok (yyerrflag = 0)
17 #define YYRECOVERING() (yyerrflag != 0)
19 /* compatibility with bison */
20 #ifdef YYPARSE_PARAM
21 /* compatibility with FreeBSD */
22 #ifdef YYPARSE_PARAM_TYPE
23 #define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
24 #else
25 #define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
26 #endif
27 #else
28 #define YYPARSE_DECL() yyparse(void)
29 #endif /* YYPARSE_PARAM */
31 extern int YYPARSE_DECL();
33 static int yygrowstack(void);
34 #define yyparse grammar_parse
35 #define yylex grammar_lex
36 #define yyerror grammar_error
37 #define yychar grammar_char
38 #define yyval grammar_val
39 #define yylval grammar_lval
40 #define yydebug grammar_debug
41 #define yynerrs grammar_nerrs
42 #define yyerrflag grammar_errflag
43 #define yyss grammar_ss
44 #define yyssp grammar_ssp
45 #define yyvs grammar_vs
46 #define yyvsp grammar_vsp
47 #define yylhs grammar_lhs
48 #define yylen grammar_len
49 #define yydefred grammar_defred
50 #define yydgoto grammar_dgoto
51 #define yysindex grammar_sindex
52 #define yyrindex grammar_rindex
53 #define yygindex grammar_gindex
54 #define yytable grammar_table
55 #define yycheck grammar_check
56 #define yyname grammar_name
57 #define yyrule grammar_rule
58 #define YYPREFIX "grammar_"
59 #line 69 "grammar.y"
60 #include <stdio.h>
61 #include <ctype.h>
62 #include "cproto.h"
63 #include "symbol.h"
64 #include "semantic.h"
66 #define YYMAXDEPTH 150
68 extern int yylex (void);
70 /* declaration specifier attributes for the typedef statement currently being
71 * scanned
73 static int cur_decl_spec_flags;
75 /* pointer to parameter list for the current function definition */
76 static ParameterList *func_params;
78 /* A parser semantic action sets this pointer to the current declarator in
79 * a function parameter declaration in order to catch any comments following
80 * the parameter declaration on the same line. If the lexer scans a comment
81 * and <cur_declarator> is not NULL, then the comment is attached to the
82 * declarator. To ignore subsequent comments, the lexer sets this to NULL
83 * after scanning a comment or end of line.
85 static Declarator *cur_declarator;
87 /* temporary string buffer */
88 static char buf[MAX_TEXT_SIZE];
90 /* table of typedef names */
91 static SymbolTable *typedef_names;
93 /* table of define names */
94 static SymbolTable *define_names;
96 /* table of type qualifiers */
97 static SymbolTable *type_qualifiers;
99 /* information about the current input file */
100 typedef struct {
101 char *base_name; /* base input file name */
102 char *file_name; /* current file name */
103 FILE *file; /* input file */
104 unsigned line_num; /* current line number in input file */
105 FILE *tmp_file; /* temporary file */
106 long begin_comment; /* tmp file offset after last written ) or ; */
107 long end_comment; /* tmp file offset after last comment */
108 boolean convert; /* if TRUE, convert function definitions */
109 boolean changed; /* TRUE if conversion done in this file */
110 } IncludeStack;
112 static IncludeStack *cur_file; /* current input file */
114 #include "yyerror.c"
116 static int haveAnsiParam (void);
119 /* Flags to enable us to find if a procedure returns a value.
121 static int return_val, /* nonzero on BRACES iff return-expression found */
122 returned_at; /* marker for token-number to set 'return_val' */
124 #if OPT_LINTLIBRARY
125 static char *dft_decl_spec (void);
127 static char *
128 dft_decl_spec (void)
130 return (lintLibrary() && !return_val) ? "void" : "int";
133 #else
134 #define dft_decl_spec() "int"
135 #endif
137 static int
138 haveAnsiParam (void)
140 Parameter *p;
141 if (func_params != 0) {
142 for (p = func_params->first; p != 0; p = p->next) {
143 if (p->declarator->func_def == FUNC_ANSI) {
144 return TRUE;
148 return FALSE;
150 #line 149 "grammar.tab.c"
151 #define T_IDENTIFIER 257
152 #define T_TYPEDEF_NAME 258
153 #define T_DEFINE_NAME 259
154 #define T_AUTO 260
155 #define T_EXTERN 261
156 #define T_REGISTER 262
157 #define T_STATIC 263
158 #define T_TYPEDEF 264
159 #define T_INLINE 265
160 #define T_EXTENSION 266
161 #define T_CHAR 267
162 #define T_DOUBLE 268
163 #define T_FLOAT 269
164 #define T_INT 270
165 #define T_VOID 271
166 #define T_LONG 272
167 #define T_SHORT 273
168 #define T_SIGNED 274
169 #define T_UNSIGNED 275
170 #define T_ENUM 276
171 #define T_STRUCT 277
172 #define T_UNION 278
173 #define T_Bool 279
174 #define T_Complex 280
175 #define T_Imaginary 281
176 #define T_TYPE_QUALIFIER 282
177 #define T_BRACKETS 283
178 #define T_LBRACE 284
179 #define T_MATCHRBRACE 285
180 #define T_ELLIPSIS 286
181 #define T_INITIALIZER 287
182 #define T_STRING_LITERAL 288
183 #define T_ASM 289
184 #define T_ASMARG 290
185 #define T_VA_DCL 291
186 #define YYERRCODE 256
187 static const short grammar_lhs[] = { -1,
188 0, 0, 26, 26, 27, 27, 27, 27, 27, 27,
189 27, 31, 30, 30, 28, 28, 34, 28, 32, 32,
190 33, 33, 35, 35, 37, 38, 29, 39, 29, 36,
191 36, 36, 40, 40, 1, 1, 2, 2, 2, 3,
192 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
193 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
194 5, 5, 6, 6, 6, 19, 19, 8, 8, 9,
195 41, 9, 7, 7, 7, 25, 23, 23, 10, 10,
196 11, 11, 11, 11, 11, 20, 20, 21, 21, 22,
197 22, 14, 14, 15, 15, 16, 16, 16, 17, 17,
198 18, 18, 24, 24, 12, 12, 12, 13, 13, 13,
199 13, 13, 13, 13,
201 static const short grammar_len[] = { 2,
202 0, 1, 1, 2, 1, 1, 1, 1, 3, 2,
203 2, 2, 3, 3, 2, 3, 0, 5, 2, 1,
204 0, 1, 1, 3, 0, 0, 7, 0, 5, 0,
205 1, 1, 1, 2, 1, 2, 1, 1, 1, 1,
206 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
207 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
208 1, 1, 3, 2, 2, 1, 1, 1, 3, 1,
209 0, 4, 3, 2, 2, 1, 1, 1, 2, 1,
210 1, 3, 2, 4, 4, 2, 3, 0, 1, 1,
211 2, 1, 3, 1, 3, 2, 2, 1, 0, 1,
212 1, 3, 1, 2, 1, 2, 1, 3, 2, 1,
213 4, 3, 3, 2,
215 static const short grammar_defred[] = { 0,
216 0, 0, 0, 0, 77, 0, 62, 40, 0, 42,
217 43, 20, 44, 0, 46, 47, 48, 49, 54, 50,
218 51, 52, 53, 76, 66, 67, 55, 56, 57, 61,
219 0, 7, 0, 0, 35, 37, 38, 39, 59, 60,
220 28, 0, 0, 0, 103, 81, 0, 0, 3, 5,
221 6, 8, 0, 10, 11, 78, 0, 90, 0, 0,
222 104, 0, 19, 0, 41, 45, 15, 36, 0, 68,
223 0, 0, 0, 83, 0, 0, 64, 0, 0, 74,
224 4, 58, 0, 82, 87, 91, 0, 14, 13, 9,
225 16, 0, 71, 0, 31, 33, 0, 0, 0, 0,
226 0, 94, 0, 0, 101, 12, 63, 73, 0, 0,
227 69, 0, 0, 0, 34, 0, 110, 96, 97, 0,
228 0, 84, 0, 85, 0, 23, 0, 0, 72, 26,
229 29, 114, 0, 0, 0, 109, 0, 93, 95, 102,
230 18, 0, 0, 108, 113, 112, 0, 24, 27, 111,
232 static const short grammar_dgoto[] = { 33,
233 87, 35, 36, 37, 38, 39, 40, 69, 70, 41,
234 42, 119, 120, 100, 101, 102, 103, 104, 43, 44,
235 59, 60, 45, 46, 47, 48, 49, 50, 51, 52,
236 77, 53, 127, 109, 128, 97, 94, 143, 72, 98,
237 112,
239 static const short grammar_sindex[] = { -2,
240 -3, 27, -239, -177, 0, 0, 0, 0, -274, 0,
241 0, 0, 0, -246, 0, 0, 0, 0, 0, 0,
242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
243 -266, 0, 0, 455, 0, 0, 0, 0, 0, 0,
244 0, -35, -245, 128, 0, 0, -245, -2, 0, 0,
245 0, 0, 642, 0, 0, 0, -15, 0, -12, -239,
246 0, 590, 0, -27, 0, 0, 0, 0, -10, 0,
247 -11, 534, -72, 0, -237, -232, 0, -35, -232, 0,
248 0, 0, 642, 0, 0, 0, 455, 0, 0, 0,
249 0, 27, 0, 534, 0, 0, -222, 617, 209, 34,
250 39, 0, 44, 42, 0, 0, 0, 0, 27, -11,
251 0, -200, -196, -195, 0, 174, 0, 0, 0, -33,
252 243, 0, 561, 0, -177, 0, 33, 49, 0, 0,
253 0, 0, 53, 55, 417, 0, -33, 0, 0, 0,
254 0, 27, -188, 0, 0, 0, 57, 0, 0, 0,
256 static const short grammar_rindex[] = { 99,
257 0, 0, 275, 0, 0, -38, 0, 0, 481, 0,
258 0, 0, 0, 509, 0, 0, 0, 0, 0, 0,
259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
261 0, 30, 0, 0, 0, 0, 0, 101, 0, 0,
262 0, 0, 0, 0, 0, 0, 0, 0, 343, 309,
263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264 98, -182, 62, 0, 0, 133, 0, 64, 379, 0,
265 0, 0, -5, 0, 0, 0, 0, 0, 0, 0,
266 0, 0, 0, -182, 0, 0, 0, -180, -19, 0,
267 65, 0, 0, 68, 0, 0, 0, 0, 51, 9,
268 0, 0, 0, 0, 0, 0, 0, 0, 0, -13,
269 19, 0, 0, 0, 0, 0, 0, 52, 0, 0,
270 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
271 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
273 static const short grammar_gindex[] = { 0,
274 11, -17, 0, 0, 13, 0, 0, 0, 20, 8,
275 -43, -1, -8, -89, 0, -9, 0, 0, 0, -44,
276 0, 0, 4, 0, 0, 0, 70, -53, 0, 0,
277 -18, 0, 0, 0, 0, 22, 0, 0, 0, 0,
280 #define YYTABLESIZE 924
281 static const short grammar_table[] = { 58,
282 78, 58, 58, 58, 73, 58, 135, 61, 88, 57,
283 34, 5, 56, 62, 85, 58, 68, 63, 96, 7,
284 58, 98, 78, 64, 98, 84, 134, 107, 80, 3,
285 107, 90, 17, 92, 17, 4, 17, 2, 75, 3,
286 96, 71, 30, 89, 115, 147, 76, 106, 91, 93,
287 79, 75, 70, 17, 121, 55, 32, 107, 34, 105,
288 108, 114, 105, 83, 4, 68, 2, 70, 3, 68,
289 80, 121, 86, 80, 122, 106, 105, 78, 106, 5,
290 56, 68, 123, 99, 124, 125, 129, 130, 80, 131,
291 80, 141, 142, 144, 110, 145, 149, 150, 1, 110,
292 2, 30, 99, 32, 79, 92, 118, 79, 100, 21,
293 22, 111, 137, 139, 133, 113, 126, 81, 0, 0,
294 0, 0, 79, 57, 79, 0, 99, 0, 140, 0,
295 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
296 0, 70, 0, 0, 0, 99, 0, 0, 0, 148,
297 0, 0, 0, 0, 0, 0, 70, 0, 0, 0,
298 0, 0, 0, 0, 0, 4, 0, 2, 0, 0,
299 65, 0, 65, 65, 65, 0, 65, 0, 0, 0,
300 0, 0, 0, 0, 5, 6, 7, 8, 65, 10,
301 11, 65, 13, 66, 15, 16, 17, 18, 19, 20,
302 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
303 0, 4, 0, 116, 132, 3, 0, 0, 58, 58,
304 58, 58, 58, 58, 58, 78, 58, 58, 58, 58,
305 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
306 58, 58, 58, 58, 58, 78, 4, 74, 116, 136,
307 3, 17, 78, 1, 5, 6, 7, 8, 9, 10,
308 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
309 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
310 4, 54, 116, 5, 56, 0, 31, 80, 80, 80,
311 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
312 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
313 80, 80, 88, 80, 88, 88, 88, 0, 88, 0,
314 80, 79, 79, 79, 79, 79, 79, 79, 79, 79,
315 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
316 79, 79, 79, 79, 79, 79, 89, 79, 89, 89,
317 89, 0, 89, 0, 79, 25, 25, 25, 25, 25,
318 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
319 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
320 86, 25, 86, 86, 5, 56, 86, 0, 25, 65,
321 65, 65, 65, 65, 65, 65, 0, 65, 65, 65,
322 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
323 65, 65, 65, 65, 65, 65, 75, 0, 75, 75,
324 75, 0, 75, 0, 0, 0, 0, 0, 0, 0,
325 5, 6, 7, 8, 65, 10, 11, 75, 13, 66,
326 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
327 25, 26, 27, 28, 29, 30, 117, 146, 0, 0,
328 0, 0, 0, 0, 0, 5, 6, 7, 8, 65,
329 10, 11, 0, 13, 66, 15, 16, 17, 18, 19,
330 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
331 30, 117, 4, 0, 2, 0, 3, 0, 0, 5,
332 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
333 0, 0, 0, 67, 0, 0, 0, 0, 41, 0,
334 41, 0, 41, 0, 0, 117, 0, 0, 0, 0,
335 0, 88, 88, 0, 0, 0, 0, 0, 0, 41,
336 0, 0, 0, 0, 0, 0, 45, 0, 45, 0,
337 45, 0, 0, 0, 0, 0, 0, 88, 0, 0,
338 0, 0, 0, 0, 0, 89, 89, 45, 0, 0,
339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
341 0, 89, 0, 0, 0, 0, 0, 0, 0, 86,
342 86, 0, 0, 0, 0, 0, 0, 0, 0, 0,
343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
344 0, 0, 0, 0, 0, 86, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 75, 75, 75, 75, 75,
346 75, 75, 0, 75, 75, 75, 75, 75, 75, 75,
347 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
348 75, 75, 0, 0, 0, 0, 0, 0, 0, 0,
349 0, 0, 0, 0, 82, 7, 8, 65, 10, 11,
350 0, 13, 66, 15, 16, 17, 18, 19, 20, 21,
351 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
352 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
353 0, 5, 6, 7, 8, 65, 10, 11, 0, 13,
354 66, 15, 16, 17, 18, 19, 20, 21, 22, 23,
355 24, 25, 26, 27, 28, 29, 30, 41, 41, 41,
356 41, 41, 41, 41, 0, 41, 41, 41, 41, 41,
357 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
358 41, 41, 41, 0, 0, 45, 45, 45, 45, 45,
359 45, 45, 0, 45, 45, 45, 45, 45, 45, 45,
360 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
361 45, 82, 7, 8, 65, 10, 11, 12, 13, 14,
362 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
363 25, 26, 27, 28, 29, 30, 0, 0, 82, 7,
364 8, 65, 10, 11, 95, 13, 66, 15, 16, 17,
365 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
366 28, 29, 30, 0, 0, 0, 138, 82, 7, 8,
367 65, 10, 11, 12, 13, 14, 15, 16, 17, 18,
368 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
369 29, 30, 0, 75, 82, 7, 8, 65, 10, 11,
370 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
371 22, 23, 24, 25, 26, 27, 28, 29, 30, 82,
372 7, 8, 65, 10, 11, 0, 13, 66, 15, 16,
373 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
374 27, 28, 29, 30,
376 static const short grammar_check[] = { 38,
377 44, 40, 41, 42, 40, 44, 40, 4, 62, 2,
378 0, 257, 258, 288, 59, 3, 34, 264, 72, 259,
379 59, 41, 61, 290, 44, 41, 116, 41, 47, 42,
380 44, 59, 38, 44, 40, 38, 42, 40, 284, 42,
381 94, 34, 282, 62, 98, 135, 43, 285, 59, 61,
382 47, 284, 44, 59, 99, 59, 59, 76, 48, 41,
383 79, 284, 44, 53, 38, 83, 40, 59, 42, 87,
384 41, 116, 60, 44, 41, 41, 73, 121, 44, 257,
385 258, 99, 44, 73, 41, 44, 287, 284, 59, 285,
386 61, 59, 44, 41, 87, 41, 285, 41, 0, 92,
387 0, 284, 41, 284, 41, 41, 99, 44, 41, 59,
388 59, 92, 121, 123, 116, 94, 109, 48, -1, -1,
389 -1, -1, 59, 116, 61, -1, 116, -1, 125, -1,
390 -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
391 -1, 44, -1, -1, -1, 135, -1, -1, -1, 142,
392 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
393 -1, -1, -1, -1, -1, 38, -1, 40, -1, -1,
394 38, -1, 40, 41, 42, -1, 44, -1, -1, -1,
395 -1, -1, -1, -1, 257, 258, 259, 260, 261, 262,
396 263, 59, 265, 266, 267, 268, 269, 270, 271, 272,
397 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
398 -1, 38, -1, 40, 41, 42, -1, -1, 257, 258,
399 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
400 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
401 279, 280, 281, 282, 283, 284, 38, 283, 40, 283,
402 42, 257, 291, 256, 257, 258, 259, 260, 261, 262,
403 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
404 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
405 38, 285, 40, 257, 258, -1, 289, 258, 259, 260,
406 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
407 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
408 281, 282, 38, 284, 40, 41, 42, -1, 44, -1,
409 291, 258, 259, 260, 261, 262, 263, 264, 265, 266,
410 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
411 277, 278, 279, 280, 281, 282, 38, 284, 40, 41,
412 42, -1, 44, -1, 291, 258, 259, 260, 261, 262,
413 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
414 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
415 38, 284, 40, 41, 257, 258, 44, -1, 291, 257,
416 258, 259, 260, 261, 262, 263, -1, 265, 266, 267,
417 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
418 278, 279, 280, 281, 282, 283, 38, -1, 40, 41,
419 42, -1, 44, -1, -1, -1, -1, -1, -1, -1,
420 257, 258, 259, 260, 261, 262, 263, 59, 265, 266,
421 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
422 277, 278, 279, 280, 281, 282, 283, 41, -1, -1,
423 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
424 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
425 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
426 282, 283, 38, -1, 40, -1, 42, -1, -1, 257,
427 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
428 -1, -1, -1, 59, -1, -1, -1, -1, 38, -1,
429 40, -1, 42, -1, -1, 283, -1, -1, -1, -1,
430 -1, 257, 258, -1, -1, -1, -1, -1, -1, 59,
431 -1, -1, -1, -1, -1, -1, 38, -1, 40, -1,
432 42, -1, -1, -1, -1, -1, -1, 283, -1, -1,
433 -1, -1, -1, -1, -1, 257, 258, 59, -1, -1,
434 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
435 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
436 -1, 283, -1, -1, -1, -1, -1, -1, -1, 257,
437 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
438 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
439 -1, -1, -1, -1, -1, 283, -1, -1, -1, -1,
440 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
441 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
442 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
443 282, 283, -1, -1, -1, -1, -1, -1, -1, -1,
444 -1, -1, -1, -1, 258, 259, 260, 261, 262, 263,
445 -1, 265, 266, 267, 268, 269, 270, 271, 272, 273,
446 274, 275, 276, 277, 278, 279, 280, 281, 282, -1,
447 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
448 -1, 257, 258, 259, 260, 261, 262, 263, -1, 265,
449 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
450 276, 277, 278, 279, 280, 281, 282, 257, 258, 259,
451 260, 261, 262, 263, -1, 265, 266, 267, 268, 269,
452 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
453 280, 281, 282, -1, -1, 257, 258, 259, 260, 261,
454 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
455 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
456 282, 258, 259, 260, 261, 262, 263, 264, 265, 266,
457 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
458 277, 278, 279, 280, 281, 282, -1, -1, 258, 259,
459 260, 261, 262, 263, 291, 265, 266, 267, 268, 269,
460 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
461 280, 281, 282, -1, -1, -1, 286, 258, 259, 260,
462 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
463 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
464 281, 282, -1, 284, 258, 259, 260, 261, 262, 263,
465 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
466 274, 275, 276, 277, 278, 279, 280, 281, 282, 258,
467 259, 260, 261, 262, 263, -1, 265, 266, 267, 268,
468 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
469 279, 280, 281, 282,
471 #define YYFINAL 33
472 #ifndef YYDEBUG
473 #define YYDEBUG 0
474 #endif
475 #define YYMAXTOKEN 291
476 #if YYDEBUG
477 static const char *grammar_name[] = {
479 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
480 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
481 "'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
482 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
483 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
484 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
485 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
486 "T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
487 "T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR",
488 "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED",
489 "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary",
490 "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS",
491 "T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
493 static const char *grammar_rule[] = {
494 "$accept : program",
495 "program :",
496 "program : translation_unit",
497 "translation_unit : external_declaration",
498 "translation_unit : translation_unit external_declaration",
499 "external_declaration : declaration",
500 "external_declaration : function_definition",
501 "external_declaration : ';'",
502 "external_declaration : linkage_specification",
503 "external_declaration : T_ASM T_ASMARG ';'",
504 "external_declaration : error T_MATCHRBRACE",
505 "external_declaration : error ';'",
506 "braces : T_LBRACE T_MATCHRBRACE",
507 "linkage_specification : T_EXTERN T_STRING_LITERAL braces",
508 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
509 "declaration : decl_specifiers ';'",
510 "declaration : decl_specifiers init_declarator_list ';'",
511 "$$1 :",
512 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
513 "any_typedef : T_EXTENSION T_TYPEDEF",
514 "any_typedef : T_TYPEDEF",
515 "opt_declarator_list :",
516 "opt_declarator_list : declarator_list",
517 "declarator_list : declarator",
518 "declarator_list : declarator_list ',' declarator",
519 "$$2 :",
520 "$$3 :",
521 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
522 "$$4 :",
523 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
524 "opt_declaration_list :",
525 "opt_declaration_list : T_VA_DCL",
526 "opt_declaration_list : declaration_list",
527 "declaration_list : declaration",
528 "declaration_list : declaration_list declaration",
529 "decl_specifiers : decl_specifier",
530 "decl_specifiers : decl_specifiers decl_specifier",
531 "decl_specifier : storage_class",
532 "decl_specifier : type_specifier",
533 "decl_specifier : type_qualifier",
534 "storage_class : T_AUTO",
535 "storage_class : T_EXTERN",
536 "storage_class : T_REGISTER",
537 "storage_class : T_STATIC",
538 "storage_class : T_INLINE",
539 "storage_class : T_EXTENSION",
540 "type_specifier : T_CHAR",
541 "type_specifier : T_DOUBLE",
542 "type_specifier : T_FLOAT",
543 "type_specifier : T_INT",
544 "type_specifier : T_LONG",
545 "type_specifier : T_SHORT",
546 "type_specifier : T_SIGNED",
547 "type_specifier : T_UNSIGNED",
548 "type_specifier : T_VOID",
549 "type_specifier : T_Bool",
550 "type_specifier : T_Complex",
551 "type_specifier : T_Imaginary",
552 "type_specifier : T_TYPEDEF_NAME",
553 "type_specifier : struct_or_union_specifier",
554 "type_specifier : enum_specifier",
555 "type_qualifier : T_TYPE_QUALIFIER",
556 "type_qualifier : T_DEFINE_NAME",
557 "struct_or_union_specifier : struct_or_union any_id braces",
558 "struct_or_union_specifier : struct_or_union braces",
559 "struct_or_union_specifier : struct_or_union any_id",
560 "struct_or_union : T_STRUCT",
561 "struct_or_union : T_UNION",
562 "init_declarator_list : init_declarator",
563 "init_declarator_list : init_declarator_list ',' init_declarator",
564 "init_declarator : declarator",
565 "$$5 :",
566 "init_declarator : declarator '=' $$5 T_INITIALIZER",
567 "enum_specifier : enumeration any_id braces",
568 "enum_specifier : enumeration braces",
569 "enum_specifier : enumeration any_id",
570 "enumeration : T_ENUM",
571 "any_id : T_IDENTIFIER",
572 "any_id : T_TYPEDEF_NAME",
573 "declarator : pointer direct_declarator",
574 "declarator : direct_declarator",
575 "direct_declarator : identifier_or_ref",
576 "direct_declarator : '(' declarator ')'",
577 "direct_declarator : direct_declarator T_BRACKETS",
578 "direct_declarator : direct_declarator '(' parameter_type_list ')'",
579 "direct_declarator : direct_declarator '(' opt_identifier_list ')'",
580 "pointer : '*' opt_type_qualifiers",
581 "pointer : '*' opt_type_qualifiers pointer",
582 "opt_type_qualifiers :",
583 "opt_type_qualifiers : type_qualifier_list",
584 "type_qualifier_list : type_qualifier",
585 "type_qualifier_list : type_qualifier_list type_qualifier",
586 "parameter_type_list : parameter_list",
587 "parameter_type_list : parameter_list ',' T_ELLIPSIS",
588 "parameter_list : parameter_declaration",
589 "parameter_list : parameter_list ',' parameter_declaration",
590 "parameter_declaration : decl_specifiers declarator",
591 "parameter_declaration : decl_specifiers abs_declarator",
592 "parameter_declaration : decl_specifiers",
593 "opt_identifier_list :",
594 "opt_identifier_list : identifier_list",
595 "identifier_list : any_id",
596 "identifier_list : identifier_list ',' any_id",
597 "identifier_or_ref : any_id",
598 "identifier_or_ref : '&' any_id",
599 "abs_declarator : pointer",
600 "abs_declarator : pointer direct_abs_declarator",
601 "abs_declarator : direct_abs_declarator",
602 "direct_abs_declarator : '(' abs_declarator ')'",
603 "direct_abs_declarator : direct_abs_declarator T_BRACKETS",
604 "direct_abs_declarator : T_BRACKETS",
605 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
606 "direct_abs_declarator : direct_abs_declarator '(' ')'",
607 "direct_abs_declarator : '(' parameter_type_list ')'",
608 "direct_abs_declarator : '(' ')'",
611 #endif
612 #if YYDEBUG
613 #include <stdio.h>
614 #endif
616 /* define the initial stack-sizes */
617 #ifdef YYSTACKSIZE
618 #undef YYMAXDEPTH
619 #define YYMAXDEPTH YYSTACKSIZE
620 #else
621 #ifdef YYMAXDEPTH
622 #define YYSTACKSIZE YYMAXDEPTH
623 #else
624 #define YYSTACKSIZE 500
625 #define YYMAXDEPTH 500
626 #endif
627 #endif
629 #define YYINITSTACKSIZE 500
631 int yydebug;
632 int yynerrs;
633 int yyerrflag;
634 int yychar;
635 short *yyssp;
636 YYSTYPE *yyvsp;
637 YYSTYPE yyval;
638 YYSTYPE yylval;
640 /* variables for the parser stack */
641 static short *yyss;
642 static short *yysslim;
643 static YYSTYPE *yyvs;
644 static unsigned yystacksize;
645 #line 816 "grammar.y"
647 #if defined(__EMX__) || defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(vms)
648 # ifdef USE_flex
649 # include "lexyy.c"
650 # else
651 # include "lex_yy.c"
652 # endif
653 #else
654 # include "lex.yy.c"
655 #endif
657 static void
658 yaccError (char *msg)
660 func_params = NULL;
661 put_error(); /* tell what line we're on, and what file */
662 fprintf(stderr, "%s at token '%s'\n", msg, yytext);
665 /* Initialize the table of type qualifier keywords recognized by the lexical
666 * analyzer.
668 void
669 init_parser (void)
671 static char *keywords[] = {
672 "const",
673 "restrict",
674 "volatile",
675 "interrupt",
676 #ifdef vms
677 "noshare",
678 "readonly",
679 #endif
680 #if defined(MSDOS) || defined(OS2)
681 "__cdecl",
682 "__export",
683 "__far",
684 "__fastcall",
685 "__fortran",
686 "__huge",
687 "__inline",
688 "__interrupt",
689 "__loadds",
690 "__near",
691 "__pascal",
692 "__saveregs",
693 "__segment",
694 "__stdcall",
695 "__syscall",
696 "_cdecl",
697 "_cs",
698 "_ds",
699 "_es",
700 "_export",
701 "_far",
702 "_fastcall",
703 "_fortran",
704 "_huge",
705 "_interrupt",
706 "_loadds",
707 "_near",
708 "_pascal",
709 "_saveregs",
710 "_seg",
711 "_segment",
712 "_ss",
713 "cdecl",
714 "far",
715 "huge",
716 "near",
717 "pascal",
718 #ifdef OS2
719 "__far16",
720 #endif
721 #endif
722 #ifdef __GNUC__
723 /* gcc aliases */
724 "__builtin_va_arg",
725 "__builtin_va_list",
726 "__const",
727 "__const__",
728 "__inline",
729 "__inline__",
730 "__restrict",
731 "__restrict__",
732 "__volatile",
733 "__volatile__",
734 #endif
736 unsigned i;
738 /* Initialize type qualifier table. */
739 type_qualifiers = new_symbol_table();
740 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
741 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
745 /* Process the C source file. Write function prototypes to the standard
746 * output. Convert function definitions and write the converted source
747 * code to a temporary file.
749 void
750 process_file (FILE *infile, char *name)
752 char *s;
754 if (strlen(name) > 2) {
755 s = name + strlen(name) - 2;
756 if (*s == '.') {
757 ++s;
758 if (*s == 'l' || *s == 'y')
759 BEGIN LEXYACC;
760 #if defined(MSDOS) || defined(OS2)
761 if (*s == 'L' || *s == 'Y')
762 BEGIN LEXYACC;
763 #endif
767 included_files = new_symbol_table();
768 typedef_names = new_symbol_table();
769 define_names = new_symbol_table();
770 inc_depth = -1;
771 curly = 0;
772 ly_count = 0;
773 func_params = NULL;
774 yyin = infile;
775 include_file(strcpy(base_file, name), func_style != FUNC_NONE);
776 if (file_comments) {
777 #if OPT_LINTLIBRARY
778 if (lintLibrary()) {
779 put_blankline(stdout);
780 begin_tracking();
782 #endif
783 put_string(stdout, "/* ");
784 put_string(stdout, cur_file_name());
785 put_string(stdout, " */\n");
787 yyparse();
788 free_symbol_table(define_names);
789 free_symbol_table(typedef_names);
790 free_symbol_table(included_files);
793 #ifdef NO_LEAKS
794 void
795 free_parser(void)
797 free_symbol_table (type_qualifiers);
798 #ifdef FLEX_SCANNER
799 if (yy_current_buffer != 0)
800 yy_delete_buffer(yy_current_buffer);
801 #endif
803 #endif
804 #line 803 "grammar.tab.c"
805 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
806 static int yygrowstack(void)
808 int i;
809 unsigned newsize;
810 short *newss;
811 YYSTYPE *newvs;
813 if ((newsize = yystacksize) == 0)
814 newsize = YYINITSTACKSIZE;
815 else if (newsize >= YYMAXDEPTH)
816 return -1;
817 else if ((newsize *= 2) > YYMAXDEPTH)
818 newsize = YYMAXDEPTH;
820 i = yyssp - yyss;
821 newss = (yyss != 0)
822 ? (short *)realloc(yyss, newsize * sizeof(*newss))
823 : (short *)malloc(newsize * sizeof(*newss));
824 if (newss == 0)
825 return -1;
827 yyss = newss;
828 yyssp = newss + i;
829 newvs = (yyvs != 0)
830 ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs))
831 : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
832 if (newvs == 0)
833 return -1;
835 yyvs = newvs;
836 yyvsp = newvs + i;
837 yystacksize = newsize;
838 yysslim = yyss + newsize - 1;
839 return 0;
842 #define YYABORT goto yyabort
843 #define YYREJECT goto yyabort
844 #define YYACCEPT goto yyaccept
845 #define YYERROR goto yyerrlab
848 YYPARSE_DECL()
850 int yym, yyn, yystate;
851 #if YYDEBUG
852 const char *yys;
854 if ((yys = getenv("YYDEBUG")) != 0)
856 yyn = *yys;
857 if (yyn >= '0' && yyn <= '9')
858 yydebug = yyn - '0';
860 #endif
862 yynerrs = 0;
863 yyerrflag = 0;
864 yychar = YYEMPTY;
865 yystate = 0;
867 if (yyss == NULL && yygrowstack()) goto yyoverflow;
868 yyssp = yyss;
869 yyvsp = yyvs;
870 yystate = 0;
871 *yyssp = 0;
873 yyloop:
874 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
875 if (yychar < 0)
877 if ((yychar = yylex()) < 0) yychar = 0;
878 #if YYDEBUG
879 if (yydebug)
881 yys = 0;
882 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
883 if (!yys) yys = "illegal-symbol";
884 printf("%sdebug: state %d, reading %d (%s)\n",
885 YYPREFIX, yystate, yychar, yys);
887 #endif
889 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
890 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
892 #if YYDEBUG
893 if (yydebug)
894 printf("%sdebug: state %d, shifting to state %d\n",
895 YYPREFIX, yystate, yytable[yyn]);
896 #endif
897 if (yyssp >= yysslim && yygrowstack())
899 goto yyoverflow;
901 yystate = yytable[yyn];
902 *++yyssp = yytable[yyn];
903 *++yyvsp = yylval;
904 yychar = YYEMPTY;
905 if (yyerrflag > 0) --yyerrflag;
906 goto yyloop;
908 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
909 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
911 yyn = yytable[yyn];
912 goto yyreduce;
914 if (yyerrflag) goto yyinrecovery;
916 yyerror("syntax error");
918 goto yyerrlab;
920 yyerrlab:
921 ++yynerrs;
923 yyinrecovery:
924 if (yyerrflag < 3)
926 yyerrflag = 3;
927 for (;;)
929 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
930 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
932 #if YYDEBUG
933 if (yydebug)
934 printf("%sdebug: state %d, error recovery shifting\
935 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
936 #endif
937 if (yyssp >= yysslim && yygrowstack())
939 goto yyoverflow;
941 yystate = yytable[yyn];
942 *++yyssp = yytable[yyn];
943 *++yyvsp = yylval;
944 goto yyloop;
946 else
948 #if YYDEBUG
949 if (yydebug)
950 printf("%sdebug: error recovery discarding state %d\n",
951 YYPREFIX, *yyssp);
952 #endif
953 if (yyssp <= yyss) goto yyabort;
954 --yyssp;
955 --yyvsp;
959 else
961 if (yychar == 0) goto yyabort;
962 #if YYDEBUG
963 if (yydebug)
965 yys = 0;
966 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
967 if (!yys) yys = "illegal-symbol";
968 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
969 YYPREFIX, yystate, yychar, yys);
971 #endif
972 yychar = YYEMPTY;
973 goto yyloop;
976 yyreduce:
977 #if YYDEBUG
978 if (yydebug)
979 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
980 YYPREFIX, yystate, yyn, yyrule[yyn]);
981 #endif
982 yym = yylen[yyn];
983 if (yym)
984 yyval = yyvsp[1-yym];
985 else
986 memset(&yyval, 0, sizeof yyval);
987 switch (yyn)
989 case 10:
990 #line 179 "grammar.y"
992 yyerrok;
994 break;
995 case 11:
996 #line 183 "grammar.y"
998 yyerrok;
1000 break;
1001 case 13:
1002 #line 194 "grammar.y"
1004 /* Provide an empty action here so bison will not complain about
1005 * incompatible types in the default action it normally would
1006 * have generated.
1009 break;
1010 case 14:
1011 #line 201 "grammar.y"
1013 /* empty */
1015 break;
1016 case 15:
1017 #line 208 "grammar.y"
1019 #if OPT_LINTLIBRARY
1020 if (types_out && want_typedef()) {
1021 gen_declarations(&yyvsp[-1].decl_spec, (DeclaratorList *)0);
1022 flush_varargs();
1024 #endif
1025 free_decl_spec(&yyvsp[-1].decl_spec);
1026 end_typedef();
1028 break;
1029 case 16:
1030 #line 219 "grammar.y"
1032 if (func_params != NULL) {
1033 set_param_types(func_params, &yyvsp[-2].decl_spec, &yyvsp[-1].decl_list);
1034 } else {
1035 gen_declarations(&yyvsp[-2].decl_spec, &yyvsp[-1].decl_list);
1036 #if OPT_LINTLIBRARY
1037 flush_varargs();
1038 #endif
1039 free_decl_list(&yyvsp[-1].decl_list);
1041 free_decl_spec(&yyvsp[-2].decl_spec);
1042 end_typedef();
1044 break;
1045 case 17:
1046 #line 233 "grammar.y"
1048 cur_decl_spec_flags = yyvsp[0].decl_spec.flags;
1049 free_decl_spec(&yyvsp[0].decl_spec);
1051 break;
1052 case 18:
1053 #line 238 "grammar.y"
1055 end_typedef();
1057 break;
1058 case 19:
1059 #line 245 "grammar.y"
1061 begin_typedef();
1063 break;
1064 case 20:
1065 #line 249 "grammar.y"
1067 begin_typedef();
1069 break;
1070 case 23:
1071 #line 261 "grammar.y"
1073 int flags = cur_decl_spec_flags;
1075 /* If the typedef is a pointer type, then reset the short type
1076 * flags so it does not get promoted.
1078 if (strcmp(yyvsp[0].declarator->text, yyvsp[0].declarator->name) != 0)
1079 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1080 new_symbol(typedef_names, yyvsp[0].declarator->name, NULL, flags);
1081 free_declarator(yyvsp[0].declarator);
1083 break;
1084 case 24:
1085 #line 273 "grammar.y"
1087 int flags = cur_decl_spec_flags;
1089 if (strcmp(yyvsp[0].declarator->text, yyvsp[0].declarator->name) != 0)
1090 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1091 new_symbol(typedef_names, yyvsp[0].declarator->name, NULL, flags);
1092 free_declarator(yyvsp[0].declarator);
1094 break;
1095 case 25:
1096 #line 285 "grammar.y"
1098 check_untagged(&yyvsp[-1].decl_spec);
1099 if (yyvsp[0].declarator->func_def == FUNC_NONE) {
1100 yyerror("syntax error");
1101 YYERROR;
1103 func_params = &(yyvsp[0].declarator->head->params);
1104 func_params->begin_comment = cur_file->begin_comment;
1105 func_params->end_comment = cur_file->end_comment;
1107 break;
1108 case 26:
1109 #line 296 "grammar.y"
1111 /* If we're converting to K&R and we've got a nominally K&R
1112 * function which has a parameter which is ANSI (i.e., a prototyped
1113 * function pointer), then we must override the deciphered value of
1114 * 'func_def' so that the parameter will be converted.
1116 if (func_style == FUNC_TRADITIONAL
1117 && haveAnsiParam()
1118 && yyvsp[-3].declarator->head->func_def == func_style) {
1119 yyvsp[-3].declarator->head->func_def = FUNC_BOTH;
1122 func_params = NULL;
1124 if (cur_file->convert)
1125 gen_func_definition(&yyvsp[-4].decl_spec, yyvsp[-3].declarator);
1126 gen_prototype(&yyvsp[-4].decl_spec, yyvsp[-3].declarator);
1127 #if OPT_LINTLIBRARY
1128 flush_varargs();
1129 #endif
1130 free_decl_spec(&yyvsp[-4].decl_spec);
1131 free_declarator(yyvsp[-3].declarator);
1133 break;
1134 case 28:
1135 #line 321 "grammar.y"
1137 if (yyvsp[0].declarator->func_def == FUNC_NONE) {
1138 yyerror("syntax error");
1139 YYERROR;
1141 func_params = &(yyvsp[0].declarator->head->params);
1142 func_params->begin_comment = cur_file->begin_comment;
1143 func_params->end_comment = cur_file->end_comment;
1145 break;
1146 case 29:
1147 #line 331 "grammar.y"
1149 DeclSpec decl_spec;
1151 func_params = NULL;
1153 new_decl_spec(&decl_spec, dft_decl_spec(), yyvsp[-4].declarator->begin, DS_NONE);
1154 if (cur_file->convert)
1155 gen_func_definition(&decl_spec, yyvsp[-4].declarator);
1156 gen_prototype(&decl_spec, yyvsp[-4].declarator);
1157 #if OPT_LINTLIBRARY
1158 flush_varargs();
1159 #endif
1160 free_decl_spec(&decl_spec);
1161 free_declarator(yyvsp[-4].declarator);
1163 break;
1164 case 36:
1165 #line 362 "grammar.y"
1167 join_decl_specs(&yyval.decl_spec, &yyvsp[-1].decl_spec, &yyvsp[0].decl_spec);
1168 free(yyvsp[-1].decl_spec.text);
1169 free(yyvsp[0].decl_spec.text);
1171 break;
1172 case 40:
1173 #line 377 "grammar.y"
1175 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1177 break;
1178 case 41:
1179 #line 381 "grammar.y"
1181 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_EXTERN);
1183 break;
1184 case 42:
1185 #line 385 "grammar.y"
1187 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1189 break;
1190 case 43:
1191 #line 389 "grammar.y"
1193 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_STATIC);
1195 break;
1196 case 44:
1197 #line 393 "grammar.y"
1199 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_INLINE);
1201 break;
1202 case 45:
1203 #line 397 "grammar.y"
1205 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_JUNK);
1207 break;
1208 case 46:
1209 #line 404 "grammar.y"
1211 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_CHAR);
1213 break;
1214 case 47:
1215 #line 408 "grammar.y"
1217 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1219 break;
1220 case 48:
1221 #line 412 "grammar.y"
1223 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_FLOAT);
1225 break;
1226 case 49:
1227 #line 416 "grammar.y"
1229 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1231 break;
1232 case 50:
1233 #line 420 "grammar.y"
1235 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1237 break;
1238 case 51:
1239 #line 424 "grammar.y"
1241 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_SHORT);
1243 break;
1244 case 52:
1245 #line 428 "grammar.y"
1247 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1249 break;
1250 case 53:
1251 #line 432 "grammar.y"
1253 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1255 break;
1256 case 54:
1257 #line 436 "grammar.y"
1259 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1261 break;
1262 case 55:
1263 #line 440 "grammar.y"
1265 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_CHAR);
1267 break;
1268 case 56:
1269 #line 444 "grammar.y"
1271 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1273 break;
1274 case 57:
1275 #line 448 "grammar.y"
1277 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1279 break;
1280 case 58:
1281 #line 452 "grammar.y"
1283 Symbol *s;
1284 s = find_symbol(typedef_names, yyvsp[0].text.text);
1285 if (s != NULL)
1286 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, s->flags);
1288 break;
1289 case 61:
1290 #line 464 "grammar.y"
1292 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
1294 break;
1295 case 62:
1296 #line 468 "grammar.y"
1298 /* This rule allows the <pointer> nonterminal to scan #define
1299 * names as if they were type modifiers.
1301 Symbol *s;
1302 s = find_symbol(define_names, yyvsp[0].text.text);
1303 if (s != NULL)
1304 new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, s->flags);
1306 break;
1307 case 63:
1308 #line 481 "grammar.y"
1310 char *s;
1311 if ((s = implied_typedef()) == 0)
1312 (void)sprintf(s = buf, "%s %s", yyvsp[-2].text.text, yyvsp[-1].text.text);
1313 new_decl_spec(&yyval.decl_spec, s, yyvsp[-2].text.begin, DS_NONE);
1315 break;
1316 case 64:
1317 #line 488 "grammar.y"
1319 char *s;
1320 if ((s = implied_typedef()) == 0)
1321 (void)sprintf(s = buf, "%s {}", yyvsp[-1].text.text);
1322 new_decl_spec(&yyval.decl_spec, s, yyvsp[-1].text.begin, DS_NONE);
1324 break;
1325 case 65:
1326 #line 495 "grammar.y"
1328 (void)sprintf(buf, "%s %s", yyvsp[-1].text.text, yyvsp[0].text.text);
1329 new_decl_spec(&yyval.decl_spec, buf, yyvsp[-1].text.begin, DS_NONE);
1331 break;
1332 case 66:
1333 #line 503 "grammar.y"
1335 imply_typedef(yyval.text.text);
1337 break;
1338 case 67:
1339 #line 507 "grammar.y"
1341 imply_typedef(yyval.text.text);
1343 break;
1344 case 68:
1345 #line 514 "grammar.y"
1347 new_decl_list(&yyval.decl_list, yyvsp[0].declarator);
1349 break;
1350 case 69:
1351 #line 518 "grammar.y"
1353 add_decl_list(&yyval.decl_list, &yyvsp[-2].decl_list, yyvsp[0].declarator);
1355 break;
1356 case 70:
1357 #line 525 "grammar.y"
1359 if (yyvsp[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
1360 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1361 gen_func_declarator(yyvsp[0].declarator);
1362 fputs(cur_text(), cur_file->tmp_file);
1364 cur_declarator = yyval.declarator;
1366 break;
1367 case 71:
1368 #line 534 "grammar.y"
1370 if (yyvsp[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
1371 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1372 gen_func_declarator(yyvsp[-1].declarator);
1373 fputs(" =", cur_file->tmp_file);
1376 break;
1377 case 73:
1378 #line 546 "grammar.y"
1380 char *s;
1381 if ((s = implied_typedef()) == 0)
1382 (void)sprintf(s = buf, "enum %s", yyvsp[-1].text.text);
1383 new_decl_spec(&yyval.decl_spec, s, yyvsp[-2].text.begin, DS_NONE);
1385 break;
1386 case 74:
1387 #line 553 "grammar.y"
1389 char *s;
1390 if ((s = implied_typedef()) == 0)
1391 (void)sprintf(s = buf, "%s {}", yyvsp[-1].text.text);
1392 new_decl_spec(&yyval.decl_spec, s, yyvsp[-1].text.begin, DS_NONE);
1394 break;
1395 case 75:
1396 #line 560 "grammar.y"
1398 (void)sprintf(buf, "enum %s", yyvsp[0].text.text);
1399 new_decl_spec(&yyval.decl_spec, buf, yyvsp[-1].text.begin, DS_NONE);
1401 break;
1402 case 76:
1403 #line 568 "grammar.y"
1405 imply_typedef("enum");
1406 yyval.text = yyvsp[0].text;
1408 break;
1409 case 79:
1410 #line 581 "grammar.y"
1412 yyval.declarator = yyvsp[0].declarator;
1413 (void)sprintf(buf, "%s%s", yyvsp[-1].text.text, yyval.declarator->text);
1414 free(yyval.declarator->text);
1415 yyval.declarator->text = xstrdup(buf);
1416 yyval.declarator->begin = yyvsp[-1].text.begin;
1417 yyval.declarator->pointer = TRUE;
1419 break;
1420 case 81:
1421 #line 594 "grammar.y"
1423 yyval.declarator = new_declarator(yyvsp[0].text.text, yyvsp[0].text.text, yyvsp[0].text.begin);
1425 break;
1426 case 82:
1427 #line 598 "grammar.y"
1429 yyval.declarator = yyvsp[-1].declarator;
1430 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1431 free(yyval.declarator->text);
1432 yyval.declarator->text = xstrdup(buf);
1433 yyval.declarator->begin = yyvsp[-2].text.begin;
1435 break;
1436 case 83:
1437 #line 606 "grammar.y"
1439 yyval.declarator = yyvsp[-1].declarator;
1440 (void)sprintf(buf, "%s%s", yyval.declarator->text, yyvsp[0].text.text);
1441 free(yyval.declarator->text);
1442 yyval.declarator->text = xstrdup(buf);
1444 break;
1445 case 84:
1446 #line 613 "grammar.y"
1448 yyval.declarator = new_declarator("%s()", yyvsp[-3].declarator->name, yyvsp[-3].declarator->begin);
1449 yyval.declarator->params = yyvsp[-1].param_list;
1450 yyval.declarator->func_stack = yyvsp[-3].declarator;
1451 yyval.declarator->head = (yyvsp[-3].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-3].declarator->head;
1452 yyval.declarator->func_def = FUNC_ANSI;
1454 break;
1455 case 85:
1456 #line 621 "grammar.y"
1458 yyval.declarator = new_declarator("%s()", yyvsp[-3].declarator->name, yyvsp[-3].declarator->begin);
1459 yyval.declarator->params = yyvsp[-1].param_list;
1460 yyval.declarator->func_stack = yyvsp[-3].declarator;
1461 yyval.declarator->head = (yyvsp[-3].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-3].declarator->head;
1462 yyval.declarator->func_def = FUNC_TRADITIONAL;
1464 break;
1465 case 86:
1466 #line 632 "grammar.y"
1468 (void)sprintf(yyval.text.text, "*%s", yyvsp[0].text.text);
1469 yyval.text.begin = yyvsp[-1].text.begin;
1471 break;
1472 case 87:
1473 #line 637 "grammar.y"
1475 (void)sprintf(yyval.text.text, "*%s%s", yyvsp[-1].text.text, yyvsp[0].text.text);
1476 yyval.text.begin = yyvsp[-2].text.begin;
1478 break;
1479 case 88:
1480 #line 645 "grammar.y"
1482 strcpy(yyval.text.text, "");
1483 yyval.text.begin = 0L;
1485 break;
1486 case 90:
1487 #line 654 "grammar.y"
1489 (void)sprintf(yyval.text.text, "%s ", yyvsp[0].decl_spec.text);
1490 yyval.text.begin = yyvsp[0].decl_spec.begin;
1491 free(yyvsp[0].decl_spec.text);
1493 break;
1494 case 91:
1495 #line 660 "grammar.y"
1497 (void)sprintf(yyval.text.text, "%s%s ", yyvsp[-1].text.text, yyvsp[0].decl_spec.text);
1498 yyval.text.begin = yyvsp[-1].text.begin;
1499 free(yyvsp[0].decl_spec.text);
1501 break;
1502 case 93:
1503 #line 670 "grammar.y"
1505 add_ident_list(&yyval.param_list, &yyvsp[-2].param_list, "...");
1507 break;
1508 case 94:
1509 #line 677 "grammar.y"
1511 new_param_list(&yyval.param_list, yyvsp[0].parameter);
1513 break;
1514 case 95:
1515 #line 681 "grammar.y"
1517 add_param_list(&yyval.param_list, &yyvsp[-2].param_list, yyvsp[0].parameter);
1519 break;
1520 case 96:
1521 #line 688 "grammar.y"
1523 check_untagged(&yyvsp[-1].decl_spec);
1524 yyval.parameter = new_parameter(&yyvsp[-1].decl_spec, yyvsp[0].declarator);
1526 break;
1527 case 97:
1528 #line 693 "grammar.y"
1530 check_untagged(&yyvsp[-1].decl_spec);
1531 yyval.parameter = new_parameter(&yyvsp[-1].decl_spec, yyvsp[0].declarator);
1533 break;
1534 case 98:
1535 #line 698 "grammar.y"
1537 check_untagged(&yyvsp[0].decl_spec);
1538 yyval.parameter = new_parameter(&yyvsp[0].decl_spec, (Declarator *)0);
1540 break;
1541 case 99:
1542 #line 706 "grammar.y"
1544 new_ident_list(&yyval.param_list);
1546 break;
1547 case 101:
1548 #line 714 "grammar.y"
1550 new_ident_list(&yyval.param_list);
1551 add_ident_list(&yyval.param_list, &yyval.param_list, yyvsp[0].text.text);
1553 break;
1554 case 102:
1555 #line 719 "grammar.y"
1557 add_ident_list(&yyval.param_list, &yyvsp[-2].param_list, yyvsp[0].text.text);
1559 break;
1560 case 103:
1561 #line 726 "grammar.y"
1563 yyval.text = yyvsp[0].text;
1565 break;
1566 case 104:
1567 #line 730 "grammar.y"
1569 #if OPT_LINTLIBRARY
1570 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
1571 yyval.text = yyvsp[0].text;
1572 } else
1573 #endif
1574 (void)sprintf(yyval.text.text, "&%s", yyvsp[0].text.text);
1575 yyval.text.begin = yyvsp[-1].text.begin;
1577 break;
1578 case 105:
1579 #line 743 "grammar.y"
1581 yyval.declarator = new_declarator(yyvsp[0].text.text, "", yyvsp[0].text.begin);
1583 break;
1584 case 106:
1585 #line 747 "grammar.y"
1587 yyval.declarator = yyvsp[0].declarator;
1588 (void)sprintf(buf, "%s%s", yyvsp[-1].text.text, yyval.declarator->text);
1589 free(yyval.declarator->text);
1590 yyval.declarator->text = xstrdup(buf);
1591 yyval.declarator->begin = yyvsp[-1].text.begin;
1593 break;
1594 case 108:
1595 #line 759 "grammar.y"
1597 yyval.declarator = yyvsp[-1].declarator;
1598 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1599 free(yyval.declarator->text);
1600 yyval.declarator->text = xstrdup(buf);
1601 yyval.declarator->begin = yyvsp[-2].text.begin;
1603 break;
1604 case 109:
1605 #line 767 "grammar.y"
1607 yyval.declarator = yyvsp[-1].declarator;
1608 (void)sprintf(buf, "%s%s", yyval.declarator->text, yyvsp[0].text.text);
1609 free(yyval.declarator->text);
1610 yyval.declarator->text = xstrdup(buf);
1612 break;
1613 case 110:
1614 #line 774 "grammar.y"
1616 yyval.declarator = new_declarator(yyvsp[0].text.text, "", yyvsp[0].text.begin);
1618 break;
1619 case 111:
1620 #line 778 "grammar.y"
1622 yyval.declarator = new_declarator("%s()", "", yyvsp[-3].declarator->begin);
1623 yyval.declarator->params = yyvsp[-1].param_list;
1624 yyval.declarator->func_stack = yyvsp[-3].declarator;
1625 yyval.declarator->head = (yyvsp[-3].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-3].declarator->head;
1626 yyval.declarator->func_def = FUNC_ANSI;
1628 break;
1629 case 112:
1630 #line 786 "grammar.y"
1632 yyval.declarator = new_declarator("%s()", "", yyvsp[-2].declarator->begin);
1633 yyval.declarator->func_stack = yyvsp[-2].declarator;
1634 yyval.declarator->head = (yyvsp[-2].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-2].declarator->head;
1635 yyval.declarator->func_def = FUNC_ANSI;
1637 break;
1638 case 113:
1639 #line 793 "grammar.y"
1641 Declarator *d;
1643 d = new_declarator("", "", yyvsp[-2].text.begin);
1644 yyval.declarator = new_declarator("%s()", "", yyvsp[-2].text.begin);
1645 yyval.declarator->params = yyvsp[-1].param_list;
1646 yyval.declarator->func_stack = d;
1647 yyval.declarator->head = yyval.declarator;
1648 yyval.declarator->func_def = FUNC_ANSI;
1650 break;
1651 case 114:
1652 #line 804 "grammar.y"
1654 Declarator *d;
1656 d = new_declarator("", "", yyvsp[-1].text.begin);
1657 yyval.declarator = new_declarator("%s()", "", yyvsp[-1].text.begin);
1658 yyval.declarator->func_stack = d;
1659 yyval.declarator->head = yyval.declarator;
1660 yyval.declarator->func_def = FUNC_ANSI;
1662 break;
1663 #line 1662 "grammar.tab.c"
1665 yyssp -= yym;
1666 yystate = *yyssp;
1667 yyvsp -= yym;
1668 yym = yylhs[yyn];
1669 if (yystate == 0 && yym == 0)
1671 #if YYDEBUG
1672 if (yydebug)
1673 printf("%sdebug: after reduction, shifting from state 0 to\
1674 state %d\n", YYPREFIX, YYFINAL);
1675 #endif
1676 yystate = YYFINAL;
1677 *++yyssp = YYFINAL;
1678 *++yyvsp = yyval;
1679 if (yychar < 0)
1681 if ((yychar = yylex()) < 0) yychar = 0;
1682 #if YYDEBUG
1683 if (yydebug)
1685 yys = 0;
1686 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1687 if (!yys) yys = "illegal-symbol";
1688 printf("%sdebug: state %d, reading %d (%s)\n",
1689 YYPREFIX, YYFINAL, yychar, yys);
1691 #endif
1693 if (yychar == 0) goto yyaccept;
1694 goto yyloop;
1696 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1697 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1698 yystate = yytable[yyn];
1699 else
1700 yystate = yydgoto[yym];
1701 #if YYDEBUG
1702 if (yydebug)
1703 printf("%sdebug: after reduction, shifting from state %d \
1704 to state %d\n", YYPREFIX, *yyssp, yystate);
1705 #endif
1706 if (yyssp >= yysslim && yygrowstack())
1708 goto yyoverflow;
1710 *++yyssp = (short) yystate;
1711 *++yyvsp = yyval;
1712 goto yyloop;
1714 yyoverflow:
1715 yyerror("yacc stack overflow");
1717 yyabort:
1718 return (1);
1720 yyaccept:
1721 return (0);