tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / byacc / dist / test / grammar.tab.c
blob67c788b1748b5d18532be39895c33b6603a8fbf5
1 /* $NetBSD: grammar.tab.c,v 1.1.1.5 2013/04/06 14:45:29 christos Exp $ */
3 #ifndef lint
4 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
5 #endif
7 #define YYBYACC 1
8 #define YYMAJOR 1
9 #define YYMINOR 9
11 #define YYEMPTY (-1)
12 #define yyclearin (yychar = YYEMPTY)
13 #define yyerrok (yyerrflag = 0)
14 #define YYRECOVERING() (yyerrflag != 0)
17 #ifndef yyparse
18 #define yyparse grammar_parse
19 #endif /* yyparse */
21 #ifndef yylex
22 #define yylex grammar_lex
23 #endif /* yylex */
25 #ifndef yyerror
26 #define yyerror grammar_error
27 #endif /* yyerror */
29 #ifndef yychar
30 #define yychar grammar_char
31 #endif /* yychar */
33 #ifndef yyval
34 #define yyval grammar_val
35 #endif /* yyval */
37 #ifndef yylval
38 #define yylval grammar_lval
39 #endif /* yylval */
41 #ifndef yydebug
42 #define yydebug grammar_debug
43 #endif /* yydebug */
45 #ifndef yynerrs
46 #define yynerrs grammar_nerrs
47 #endif /* yynerrs */
49 #ifndef yyerrflag
50 #define yyerrflag grammar_errflag
51 #endif /* yyerrflag */
53 #ifndef yylhs
54 #define yylhs grammar_lhs
55 #endif /* yylhs */
57 #ifndef yylen
58 #define yylen grammar_len
59 #endif /* yylen */
61 #ifndef yydefred
62 #define yydefred grammar_defred
63 #endif /* yydefred */
65 #ifndef yydgoto
66 #define yydgoto grammar_dgoto
67 #endif /* yydgoto */
69 #ifndef yysindex
70 #define yysindex grammar_sindex
71 #endif /* yysindex */
73 #ifndef yyrindex
74 #define yyrindex grammar_rindex
75 #endif /* yyrindex */
77 #ifndef yygindex
78 #define yygindex grammar_gindex
79 #endif /* yygindex */
81 #ifndef yytable
82 #define yytable grammar_table
83 #endif /* yytable */
85 #ifndef yycheck
86 #define yycheck grammar_check
87 #endif /* yycheck */
89 #ifndef yyname
90 #define yyname grammar_name
91 #endif /* yyname */
93 #ifndef yyrule
94 #define yyrule grammar_rule
95 #endif /* yyrule */
96 #define YYPREFIX "grammar_"
98 #define YYPURE 0
100 #line 9 "grammar.y"
101 #ifdef YYBISON
102 #include <stdlib.h>
103 #define YYSTYPE_IS_DECLARED
104 #define yyerror yaccError
105 #endif
107 #if defined(YYBISON) || !defined(YYBYACC)
108 static void yyerror(const char *s);
109 #endif
110 #line 81 "grammar.y"
111 #include <stdio.h>
112 #include <ctype.h>
113 #include <string.h>
115 #define OPT_LINTLIBRARY 1
117 #ifndef TRUE
118 #define TRUE (1)
119 #endif
121 #ifndef FALSE
122 #define FALSE (0)
123 #endif
125 /* #include "cproto.h" */
126 #define MAX_TEXT_SIZE 1024
128 /* Prototype styles */
129 #if OPT_LINTLIBRARY
130 #define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
131 #define PROTO_LINTLIBRARY -1 /* form lint-library source */
132 #endif
133 #define PROTO_NONE 0 /* do not output any prototypes */
134 #define PROTO_TRADITIONAL 1 /* comment out parameters */
135 #define PROTO_ABSTRACT 2 /* comment out parameter names */
136 #define PROTO_ANSI 3 /* ANSI C prototype */
138 typedef int PrototypeStyle;
140 typedef char boolean;
142 extern boolean types_out;
143 extern PrototypeStyle proto_style;
145 #define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
146 #define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
147 #define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
149 #if OPT_LINTLIBRARY
150 #define FUNC_UNKNOWN -1 /* unspecified */
151 #else
152 #define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
153 #endif
154 #define FUNC_NONE 0 /* not a function definition */
155 #define FUNC_TRADITIONAL 1 /* traditional style */
156 #define FUNC_ANSI 2 /* ANSI style */
157 #define FUNC_BOTH 3 /* both styles */
159 typedef int FuncDefStyle;
161 /* Source file text */
162 typedef struct text {
163 char text[MAX_TEXT_SIZE]; /* source text */
164 long begin; /* offset in temporary file */
165 } Text;
167 /* Declaration specifier flags */
168 #define DS_NONE 0 /* default */
169 #define DS_EXTERN 1 /* contains "extern" specifier */
170 #define DS_STATIC 2 /* contains "static" specifier */
171 #define DS_CHAR 4 /* contains "char" type specifier */
172 #define DS_SHORT 8 /* contains "short" type specifier */
173 #define DS_FLOAT 16 /* contains "float" type specifier */
174 #define DS_INLINE 32 /* contains "inline" specifier */
175 #define DS_JUNK 64 /* we're not interested in this declaration */
177 /* This structure stores information about a declaration specifier. */
178 typedef struct decl_spec {
179 unsigned short flags; /* flags defined above */
180 char *text; /* source text */
181 long begin; /* offset in temporary file */
182 } DeclSpec;
184 /* This is a list of function parameters. */
185 typedef struct _ParameterList {
186 struct parameter *first; /* pointer to first parameter in list */
187 struct parameter *last; /* pointer to last parameter in list */
188 long begin_comment; /* begin offset of comment */
189 long end_comment; /* end offset of comment */
190 char *comment; /* comment at start of parameter list */
191 } ParameterList;
193 /* This structure stores information about a declarator. */
194 typedef struct _Declarator {
195 char *name; /* name of variable or function */
196 char *text; /* source text */
197 long begin; /* offset in temporary file */
198 long begin_comment; /* begin offset of comment */
199 long end_comment; /* end offset of comment */
200 FuncDefStyle func_def; /* style of function definition */
201 ParameterList params; /* function parameters */
202 boolean pointer; /* TRUE if it declares a pointer */
203 struct _Declarator *head; /* head function declarator */
204 struct _Declarator *func_stack; /* stack of function declarators */
205 struct _Declarator *next; /* next declarator in list */
206 } Declarator;
208 /* This structure stores information about a function parameter. */
209 typedef struct parameter {
210 struct parameter *next; /* next parameter in list */
211 DeclSpec decl_spec;
212 Declarator *declarator;
213 char *comment; /* comment following the parameter */
214 } Parameter;
216 /* This is a list of declarators. */
217 typedef struct declarator_list {
218 Declarator *first; /* pointer to first declarator in list */
219 Declarator *last; /* pointer to last declarator in list */
220 } DeclaratorList;
222 /* #include "symbol.h" */
223 typedef struct symbol {
224 struct symbol *next; /* next symbol in list */
225 char *name; /* name of symbol */
226 char *value; /* value of symbol (for defines) */
227 short flags; /* symbol attributes */
228 } Symbol;
230 /* parser stack entry type */
231 typedef union {
232 Text text;
233 DeclSpec decl_spec;
234 Parameter *parameter;
235 ParameterList param_list;
236 Declarator *declarator;
237 DeclaratorList decl_list;
238 } YYSTYPE;
240 /* The hash table length should be a prime number. */
241 #define SYM_MAX_HASH 251
243 typedef struct symbol_table {
244 Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */
245 } SymbolTable;
247 extern SymbolTable *new_symbol_table /* Create symbol table */
248 (void);
249 extern void free_symbol_table /* Destroy symbol table */
250 (SymbolTable *s);
251 extern Symbol *find_symbol /* Lookup symbol name */
252 (SymbolTable *s, const char *n);
253 extern Symbol *new_symbol /* Define new symbol */
254 (SymbolTable *s, const char *n, const char *v, int f);
256 /* #include "semantic.h" */
257 extern void new_decl_spec (DeclSpec *, const char *, long, int);
258 extern void free_decl_spec (DeclSpec *);
259 extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *);
260 extern void check_untagged (DeclSpec *);
261 extern Declarator *new_declarator (const char *, const char *, long);
262 extern void free_declarator (Declarator *);
263 extern void new_decl_list (DeclaratorList *, Declarator *);
264 extern void free_decl_list (DeclaratorList *);
265 extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *);
266 extern Parameter *new_parameter (DeclSpec *, Declarator *);
267 extern void free_parameter (Parameter *);
268 extern void new_param_list (ParameterList *, Parameter *);
269 extern void free_param_list (ParameterList *);
270 extern void add_param_list (ParameterList *, ParameterList *, Parameter *);
271 extern void new_ident_list (ParameterList *);
272 extern void add_ident_list (ParameterList *, ParameterList *, const char *);
273 extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *);
274 extern void gen_declarations (DeclSpec *, DeclaratorList *);
275 extern void gen_prototype (DeclSpec *, Declarator *);
276 extern void gen_func_declarator (Declarator *);
277 extern void gen_func_definition (DeclSpec *, Declarator *);
279 extern void init_parser (void);
280 extern void process_file (FILE *infile, char *name);
281 extern char *cur_text (void);
282 extern char *cur_file_name (void);
283 extern char *implied_typedef (void);
284 extern void include_file (char *name, int convert);
285 extern char *supply_parm (int count);
286 extern char *xstrdup (const char *);
287 extern int already_declared (char *name);
288 extern int is_actual_func (Declarator *d);
289 extern int lint_ellipsis (Parameter *p);
290 extern int want_typedef (void);
291 extern void begin_tracking (void);
292 extern void begin_typedef (void);
293 extern void copy_typedef (char *s);
294 extern void ellipsis_varargs (Declarator *d);
295 extern void end_typedef (void);
296 extern void flush_varargs (void);
297 extern void fmt_library (int code);
298 extern void imply_typedef (const char *s);
299 extern void indent (FILE *outf);
300 extern void put_blankline (FILE *outf);
301 extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator);
302 extern void put_char (FILE *outf, int c);
303 extern void put_error (void);
304 extern void put_newline (FILE *outf);
305 extern void put_padded (FILE *outf, const char *s);
306 extern void put_string (FILE *outf, const char *s);
307 extern void track_in (void);
309 extern boolean file_comments;
310 extern FuncDefStyle func_style;
311 extern char base_file[];
313 extern int yylex (void);
315 /* declaration specifier attributes for the typedef statement currently being
316 * scanned
318 static int cur_decl_spec_flags;
320 /* pointer to parameter list for the current function definition */
321 static ParameterList *func_params;
323 /* A parser semantic action sets this pointer to the current declarator in
324 * a function parameter declaration in order to catch any comments following
325 * the parameter declaration on the same line. If the lexer scans a comment
326 * and <cur_declarator> is not NULL, then the comment is attached to the
327 * declarator. To ignore subsequent comments, the lexer sets this to NULL
328 * after scanning a comment or end of line.
330 static Declarator *cur_declarator;
332 /* temporary string buffer */
333 static char buf[MAX_TEXT_SIZE];
335 /* table of typedef names */
336 static SymbolTable *typedef_names;
338 /* table of define names */
339 static SymbolTable *define_names;
341 /* table of type qualifiers */
342 static SymbolTable *type_qualifiers;
344 /* information about the current input file */
345 typedef struct {
346 char *base_name; /* base input file name */
347 char *file_name; /* current file name */
348 FILE *file; /* input file */
349 unsigned line_num; /* current line number in input file */
350 FILE *tmp_file; /* temporary file */
351 long begin_comment; /* tmp file offset after last written ) or ; */
352 long end_comment; /* tmp file offset after last comment */
353 boolean convert; /* if TRUE, convert function definitions */
354 boolean changed; /* TRUE if conversion done in this file */
355 } IncludeStack;
357 static IncludeStack *cur_file; /* current input file */
359 /* #include "yyerror.c" */
361 static int haveAnsiParam (void);
364 /* Flags to enable us to find if a procedure returns a value.
366 static int return_val; /* nonzero on BRACES iff return-expression found */
368 static const char *
369 dft_decl_spec (void)
371 return (lintLibrary() && !return_val) ? "void" : "int";
374 static int
375 haveAnsiParam (void)
377 Parameter *p;
378 if (func_params != 0) {
379 for (p = func_params->first; p != 0; p = p->next) {
380 if (p->declarator->func_def == FUNC_ANSI) {
381 return TRUE;
385 return FALSE;
387 #line 386 "grammar.tab.c"
389 /* compatibility with bison */
390 #ifdef YYPARSE_PARAM
391 /* compatibility with FreeBSD */
392 # ifdef YYPARSE_PARAM_TYPE
393 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
394 # else
395 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
396 # endif
397 #else
398 # define YYPARSE_DECL() yyparse(void)
399 #endif
401 /* Parameters sent to lex. */
402 #ifdef YYLEX_PARAM
403 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
404 # define YYLEX yylex(YYLEX_PARAM)
405 #else
406 # define YYLEX_DECL() yylex(void)
407 # define YYLEX yylex()
408 #endif
410 /* Parameters sent to yyerror. */
411 #ifndef YYERROR_DECL
412 #define YYERROR_DECL() yyerror(const char *s)
413 #endif
414 #ifndef YYERROR_CALL
415 #define YYERROR_CALL(msg) yyerror(msg)
416 #endif
418 extern int YYPARSE_DECL();
420 #define T_IDENTIFIER 257
421 #define T_TYPEDEF_NAME 258
422 #define T_DEFINE_NAME 259
423 #define T_AUTO 260
424 #define T_EXTERN 261
425 #define T_REGISTER 262
426 #define T_STATIC 263
427 #define T_TYPEDEF 264
428 #define T_INLINE 265
429 #define T_EXTENSION 266
430 #define T_CHAR 267
431 #define T_DOUBLE 268
432 #define T_FLOAT 269
433 #define T_INT 270
434 #define T_VOID 271
435 #define T_LONG 272
436 #define T_SHORT 273
437 #define T_SIGNED 274
438 #define T_UNSIGNED 275
439 #define T_ENUM 276
440 #define T_STRUCT 277
441 #define T_UNION 278
442 #define T_Bool 279
443 #define T_Complex 280
444 #define T_Imaginary 281
445 #define T_TYPE_QUALIFIER 282
446 #define T_BRACKETS 283
447 #define T_LBRACE 284
448 #define T_MATCHRBRACE 285
449 #define T_ELLIPSIS 286
450 #define T_INITIALIZER 287
451 #define T_STRING_LITERAL 288
452 #define T_ASM 289
453 #define T_ASMARG 290
454 #define T_VA_DCL 291
455 #define YYERRCODE 256
456 static const short grammar_lhs[] = { -1,
457 0, 0, 26, 26, 27, 27, 27, 27, 27, 27,
458 27, 31, 30, 30, 28, 28, 34, 28, 32, 32,
459 33, 33, 35, 35, 37, 38, 29, 39, 29, 36,
460 36, 36, 40, 40, 1, 1, 2, 2, 2, 3,
461 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
462 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
463 5, 5, 6, 6, 6, 19, 19, 8, 8, 9,
464 41, 9, 7, 7, 7, 25, 23, 23, 10, 10,
465 11, 11, 11, 11, 11, 20, 20, 21, 21, 22,
466 22, 14, 14, 15, 15, 16, 16, 16, 17, 17,
467 18, 18, 24, 24, 12, 12, 12, 13, 13, 13,
468 13, 13, 13, 13,
470 static const short grammar_len[] = { 2,
471 0, 1, 1, 2, 1, 1, 1, 1, 3, 2,
472 2, 2, 3, 3, 2, 3, 0, 5, 2, 1,
473 0, 1, 1, 3, 0, 0, 7, 0, 5, 0,
474 1, 1, 1, 2, 1, 2, 1, 1, 1, 1,
475 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
476 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
477 1, 1, 3, 2, 2, 1, 1, 1, 3, 1,
478 0, 4, 3, 2, 2, 1, 1, 1, 2, 1,
479 1, 3, 2, 4, 4, 2, 3, 0, 1, 1,
480 2, 1, 3, 1, 3, 2, 2, 1, 0, 1,
481 1, 3, 1, 2, 1, 2, 1, 3, 2, 1,
482 4, 3, 3, 2,
484 static const short grammar_defred[] = { 0,
485 0, 0, 0, 0, 77, 0, 62, 40, 0, 42,
486 43, 20, 44, 0, 46, 47, 48, 49, 54, 50,
487 51, 52, 53, 76, 66, 67, 55, 56, 57, 61,
488 0, 7, 0, 0, 35, 37, 38, 39, 59, 60,
489 28, 0, 0, 0, 103, 81, 0, 0, 3, 5,
490 6, 8, 0, 10, 11, 78, 0, 90, 0, 0,
491 104, 0, 19, 0, 41, 45, 15, 36, 0, 68,
492 0, 0, 0, 83, 0, 0, 64, 0, 0, 74,
493 4, 58, 0, 82, 87, 91, 0, 14, 13, 9,
494 16, 0, 71, 0, 31, 33, 0, 0, 0, 0,
495 0, 94, 0, 0, 101, 12, 63, 73, 0, 0,
496 69, 0, 0, 0, 34, 0, 110, 96, 97, 0,
497 0, 84, 0, 85, 0, 23, 0, 0, 72, 26,
498 29, 114, 0, 0, 0, 109, 0, 93, 95, 102,
499 18, 0, 0, 108, 113, 112, 0, 24, 27, 111,
501 static const short grammar_dgoto[] = { 33,
502 87, 35, 36, 37, 38, 39, 40, 69, 70, 41,
503 42, 119, 120, 100, 101, 102, 103, 104, 43, 44,
504 59, 60, 45, 46, 47, 48, 49, 50, 51, 52,
505 77, 53, 127, 109, 128, 97, 94, 143, 72, 98,
506 112,
508 static const short grammar_sindex[] = { -2,
509 -3, 27, -239, -177, 0, 0, 0, 0, -274, 0,
510 0, 0, 0, -246, 0, 0, 0, 0, 0, 0,
511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
512 -266, 0, 0, 455, 0, 0, 0, 0, 0, 0,
513 0, -35, -245, 128, 0, 0, -245, -2, 0, 0,
514 0, 0, 642, 0, 0, 0, -15, 0, -12, -239,
515 0, 590, 0, -27, 0, 0, 0, 0, -10, 0,
516 -11, 534, -72, 0, -237, -232, 0, -35, -232, 0,
517 0, 0, 642, 0, 0, 0, 455, 0, 0, 0,
518 0, 27, 0, 534, 0, 0, -222, 617, 209, 34,
519 39, 0, 44, 42, 0, 0, 0, 0, 27, -11,
520 0, -200, -196, -195, 0, 174, 0, 0, 0, -33,
521 243, 0, 561, 0, -177, 0, 33, 49, 0, 0,
522 0, 0, 53, 55, 417, 0, -33, 0, 0, 0,
523 0, 27, -188, 0, 0, 0, 57, 0, 0, 0,
525 static const short grammar_rindex[] = { 99,
526 0, 0, 275, 0, 0, -38, 0, 0, 481, 0,
527 0, 0, 0, 509, 0, 0, 0, 0, 0, 0,
528 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
529 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
530 0, 30, 0, 0, 0, 0, 0, 101, 0, 0,
531 0, 0, 0, 0, 0, 0, 0, 0, 343, 309,
532 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
533 98, -182, 62, 0, 0, 133, 0, 64, 379, 0,
534 0, 0, -5, 0, 0, 0, 0, 0, 0, 0,
535 0, 0, 0, -182, 0, 0, 0, -180, -19, 0,
536 65, 0, 0, 68, 0, 0, 0, 0, 51, 9,
537 0, 0, 0, 0, 0, 0, 0, 0, 0, -13,
538 19, 0, 0, 0, 0, 0, 0, 52, 0, 0,
539 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
540 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
542 static const short grammar_gindex[] = { 0,
543 11, -17, 0, 0, 13, 0, 0, 0, 20, 8,
544 -43, -1, -8, -89, 0, -9, 0, 0, 0, -44,
545 0, 0, 4, 0, 0, 0, 70, -53, 0, 0,
546 -18, 0, 0, 0, 0, 22, 0, 0, 0, 0,
549 #define YYTABLESIZE 924
550 static const short grammar_table[] = { 58,
551 78, 58, 58, 58, 73, 58, 135, 61, 88, 57,
552 34, 5, 56, 62, 85, 58, 68, 63, 96, 7,
553 58, 98, 78, 64, 98, 84, 134, 107, 80, 3,
554 107, 90, 17, 92, 17, 4, 17, 2, 75, 3,
555 96, 71, 30, 89, 115, 147, 76, 106, 91, 93,
556 79, 75, 70, 17, 121, 55, 32, 107, 34, 105,
557 108, 114, 105, 83, 4, 68, 2, 70, 3, 68,
558 80, 121, 86, 80, 122, 106, 105, 78, 106, 5,
559 56, 68, 123, 99, 124, 125, 129, 130, 80, 131,
560 80, 141, 142, 144, 110, 145, 149, 150, 1, 110,
561 2, 30, 99, 32, 79, 92, 118, 79, 100, 21,
562 22, 111, 137, 139, 133, 113, 126, 81, 0, 0,
563 0, 0, 79, 57, 79, 0, 99, 0, 140, 0,
564 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
565 0, 70, 0, 0, 0, 99, 0, 0, 0, 148,
566 0, 0, 0, 0, 0, 0, 70, 0, 0, 0,
567 0, 0, 0, 0, 0, 4, 0, 2, 0, 0,
568 65, 0, 65, 65, 65, 0, 65, 0, 0, 0,
569 0, 0, 0, 0, 5, 6, 7, 8, 65, 10,
570 11, 65, 13, 66, 15, 16, 17, 18, 19, 20,
571 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
572 0, 4, 0, 116, 132, 3, 0, 0, 58, 58,
573 58, 58, 58, 58, 58, 78, 58, 58, 58, 58,
574 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
575 58, 58, 58, 58, 58, 78, 4, 74, 116, 136,
576 3, 17, 78, 1, 5, 6, 7, 8, 9, 10,
577 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
578 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
579 4, 54, 116, 5, 56, 0, 31, 80, 80, 80,
580 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
581 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
582 80, 80, 88, 80, 88, 88, 88, 0, 88, 0,
583 80, 79, 79, 79, 79, 79, 79, 79, 79, 79,
584 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
585 79, 79, 79, 79, 79, 79, 89, 79, 89, 89,
586 89, 0, 89, 0, 79, 25, 25, 25, 25, 25,
587 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
588 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
589 86, 25, 86, 86, 5, 56, 86, 0, 25, 65,
590 65, 65, 65, 65, 65, 65, 0, 65, 65, 65,
591 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
592 65, 65, 65, 65, 65, 65, 75, 0, 75, 75,
593 75, 0, 75, 0, 0, 0, 0, 0, 0, 0,
594 5, 6, 7, 8, 65, 10, 11, 75, 13, 66,
595 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
596 25, 26, 27, 28, 29, 30, 117, 146, 0, 0,
597 0, 0, 0, 0, 0, 5, 6, 7, 8, 65,
598 10, 11, 0, 13, 66, 15, 16, 17, 18, 19,
599 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
600 30, 117, 4, 0, 2, 0, 3, 0, 0, 5,
601 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
602 0, 0, 0, 67, 0, 0, 0, 0, 41, 0,
603 41, 0, 41, 0, 0, 117, 0, 0, 0, 0,
604 0, 88, 88, 0, 0, 0, 0, 0, 0, 41,
605 0, 0, 0, 0, 0, 0, 45, 0, 45, 0,
606 45, 0, 0, 0, 0, 0, 0, 88, 0, 0,
607 0, 0, 0, 0, 0, 89, 89, 45, 0, 0,
608 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
609 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
610 0, 89, 0, 0, 0, 0, 0, 0, 0, 86,
611 86, 0, 0, 0, 0, 0, 0, 0, 0, 0,
612 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
613 0, 0, 0, 0, 0, 86, 0, 0, 0, 0,
614 0, 0, 0, 0, 0, 75, 75, 75, 75, 75,
615 75, 75, 0, 75, 75, 75, 75, 75, 75, 75,
616 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
617 75, 75, 0, 0, 0, 0, 0, 0, 0, 0,
618 0, 0, 0, 0, 82, 7, 8, 65, 10, 11,
619 0, 13, 66, 15, 16, 17, 18, 19, 20, 21,
620 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
621 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
622 0, 5, 6, 7, 8, 65, 10, 11, 0, 13,
623 66, 15, 16, 17, 18, 19, 20, 21, 22, 23,
624 24, 25, 26, 27, 28, 29, 30, 41, 41, 41,
625 41, 41, 41, 41, 0, 41, 41, 41, 41, 41,
626 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
627 41, 41, 41, 0, 0, 45, 45, 45, 45, 45,
628 45, 45, 0, 45, 45, 45, 45, 45, 45, 45,
629 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
630 45, 82, 7, 8, 65, 10, 11, 12, 13, 14,
631 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
632 25, 26, 27, 28, 29, 30, 0, 0, 82, 7,
633 8, 65, 10, 11, 95, 13, 66, 15, 16, 17,
634 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
635 28, 29, 30, 0, 0, 0, 138, 82, 7, 8,
636 65, 10, 11, 12, 13, 14, 15, 16, 17, 18,
637 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
638 29, 30, 0, 75, 82, 7, 8, 65, 10, 11,
639 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
640 22, 23, 24, 25, 26, 27, 28, 29, 30, 82,
641 7, 8, 65, 10, 11, 0, 13, 66, 15, 16,
642 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
643 27, 28, 29, 30,
645 static const short grammar_check[] = { 38,
646 44, 40, 41, 42, 40, 44, 40, 4, 62, 2,
647 0, 257, 258, 288, 59, 3, 34, 264, 72, 259,
648 59, 41, 61, 290, 44, 41, 116, 41, 47, 42,
649 44, 59, 38, 44, 40, 38, 42, 40, 284, 42,
650 94, 34, 282, 62, 98, 135, 43, 285, 59, 61,
651 47, 284, 44, 59, 99, 59, 59, 76, 48, 41,
652 79, 284, 44, 53, 38, 83, 40, 59, 42, 87,
653 41, 116, 60, 44, 41, 41, 73, 121, 44, 257,
654 258, 99, 44, 73, 41, 44, 287, 284, 59, 285,
655 61, 59, 44, 41, 87, 41, 285, 41, 0, 92,
656 0, 284, 41, 284, 41, 41, 99, 44, 41, 59,
657 59, 92, 121, 123, 116, 94, 109, 48, -1, -1,
658 -1, -1, 59, 116, 61, -1, 116, -1, 125, -1,
659 -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
660 -1, 44, -1, -1, -1, 135, -1, -1, -1, 142,
661 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
662 -1, -1, -1, -1, -1, 38, -1, 40, -1, -1,
663 38, -1, 40, 41, 42, -1, 44, -1, -1, -1,
664 -1, -1, -1, -1, 257, 258, 259, 260, 261, 262,
665 263, 59, 265, 266, 267, 268, 269, 270, 271, 272,
666 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
667 -1, 38, -1, 40, 41, 42, -1, -1, 257, 258,
668 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
669 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
670 279, 280, 281, 282, 283, 284, 38, 283, 40, 283,
671 42, 257, 291, 256, 257, 258, 259, 260, 261, 262,
672 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
673 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
674 38, 285, 40, 257, 258, -1, 289, 258, 259, 260,
675 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
676 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
677 281, 282, 38, 284, 40, 41, 42, -1, 44, -1,
678 291, 258, 259, 260, 261, 262, 263, 264, 265, 266,
679 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
680 277, 278, 279, 280, 281, 282, 38, 284, 40, 41,
681 42, -1, 44, -1, 291, 258, 259, 260, 261, 262,
682 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
683 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
684 38, 284, 40, 41, 257, 258, 44, -1, 291, 257,
685 258, 259, 260, 261, 262, 263, -1, 265, 266, 267,
686 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
687 278, 279, 280, 281, 282, 283, 38, -1, 40, 41,
688 42, -1, 44, -1, -1, -1, -1, -1, -1, -1,
689 257, 258, 259, 260, 261, 262, 263, 59, 265, 266,
690 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
691 277, 278, 279, 280, 281, 282, 283, 41, -1, -1,
692 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
693 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
694 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
695 282, 283, 38, -1, 40, -1, 42, -1, -1, 257,
696 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
697 -1, -1, -1, 59, -1, -1, -1, -1, 38, -1,
698 40, -1, 42, -1, -1, 283, -1, -1, -1, -1,
699 -1, 257, 258, -1, -1, -1, -1, -1, -1, 59,
700 -1, -1, -1, -1, -1, -1, 38, -1, 40, -1,
701 42, -1, -1, -1, -1, -1, -1, 283, -1, -1,
702 -1, -1, -1, -1, -1, 257, 258, 59, -1, -1,
703 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
704 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
705 -1, 283, -1, -1, -1, -1, -1, -1, -1, 257,
706 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
707 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
708 -1, -1, -1, -1, -1, 283, -1, -1, -1, -1,
709 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
710 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
711 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
712 282, 283, -1, -1, -1, -1, -1, -1, -1, -1,
713 -1, -1, -1, -1, 258, 259, 260, 261, 262, 263,
714 -1, 265, 266, 267, 268, 269, 270, 271, 272, 273,
715 274, 275, 276, 277, 278, 279, 280, 281, 282, -1,
716 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
717 -1, 257, 258, 259, 260, 261, 262, 263, -1, 265,
718 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
719 276, 277, 278, 279, 280, 281, 282, 257, 258, 259,
720 260, 261, 262, 263, -1, 265, 266, 267, 268, 269,
721 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
722 280, 281, 282, -1, -1, 257, 258, 259, 260, 261,
723 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
724 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
725 282, 258, 259, 260, 261, 262, 263, 264, 265, 266,
726 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
727 277, 278, 279, 280, 281, 282, -1, -1, 258, 259,
728 260, 261, 262, 263, 291, 265, 266, 267, 268, 269,
729 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
730 280, 281, 282, -1, -1, -1, 286, 258, 259, 260,
731 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
732 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
733 281, 282, -1, 284, 258, 259, 260, 261, 262, 263,
734 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
735 274, 275, 276, 277, 278, 279, 280, 281, 282, 258,
736 259, 260, 261, 262, 263, -1, 265, 266, 267, 268,
737 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
738 279, 280, 281, 282,
740 #define YYFINAL 33
741 #ifndef YYDEBUG
742 #define YYDEBUG 0
743 #endif
744 #define YYMAXTOKEN 291
745 #if YYDEBUG
746 static const char *yyname[] = {
748 "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,
749 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
750 "'='",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,
751 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,
752 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,
753 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,
754 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,
755 "T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
756 "T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR",
757 "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED",
758 "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary",
759 "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS",
760 "T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
762 static const char *yyrule[] = {
763 "$accept : program",
764 "program :",
765 "program : translation_unit",
766 "translation_unit : external_declaration",
767 "translation_unit : translation_unit external_declaration",
768 "external_declaration : declaration",
769 "external_declaration : function_definition",
770 "external_declaration : ';'",
771 "external_declaration : linkage_specification",
772 "external_declaration : T_ASM T_ASMARG ';'",
773 "external_declaration : error T_MATCHRBRACE",
774 "external_declaration : error ';'",
775 "braces : T_LBRACE T_MATCHRBRACE",
776 "linkage_specification : T_EXTERN T_STRING_LITERAL braces",
777 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
778 "declaration : decl_specifiers ';'",
779 "declaration : decl_specifiers init_declarator_list ';'",
780 "$$1 :",
781 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
782 "any_typedef : T_EXTENSION T_TYPEDEF",
783 "any_typedef : T_TYPEDEF",
784 "opt_declarator_list :",
785 "opt_declarator_list : declarator_list",
786 "declarator_list : declarator",
787 "declarator_list : declarator_list ',' declarator",
788 "$$2 :",
789 "$$3 :",
790 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
791 "$$4 :",
792 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
793 "opt_declaration_list :",
794 "opt_declaration_list : T_VA_DCL",
795 "opt_declaration_list : declaration_list",
796 "declaration_list : declaration",
797 "declaration_list : declaration_list declaration",
798 "decl_specifiers : decl_specifier",
799 "decl_specifiers : decl_specifiers decl_specifier",
800 "decl_specifier : storage_class",
801 "decl_specifier : type_specifier",
802 "decl_specifier : type_qualifier",
803 "storage_class : T_AUTO",
804 "storage_class : T_EXTERN",
805 "storage_class : T_REGISTER",
806 "storage_class : T_STATIC",
807 "storage_class : T_INLINE",
808 "storage_class : T_EXTENSION",
809 "type_specifier : T_CHAR",
810 "type_specifier : T_DOUBLE",
811 "type_specifier : T_FLOAT",
812 "type_specifier : T_INT",
813 "type_specifier : T_LONG",
814 "type_specifier : T_SHORT",
815 "type_specifier : T_SIGNED",
816 "type_specifier : T_UNSIGNED",
817 "type_specifier : T_VOID",
818 "type_specifier : T_Bool",
819 "type_specifier : T_Complex",
820 "type_specifier : T_Imaginary",
821 "type_specifier : T_TYPEDEF_NAME",
822 "type_specifier : struct_or_union_specifier",
823 "type_specifier : enum_specifier",
824 "type_qualifier : T_TYPE_QUALIFIER",
825 "type_qualifier : T_DEFINE_NAME",
826 "struct_or_union_specifier : struct_or_union any_id braces",
827 "struct_or_union_specifier : struct_or_union braces",
828 "struct_or_union_specifier : struct_or_union any_id",
829 "struct_or_union : T_STRUCT",
830 "struct_or_union : T_UNION",
831 "init_declarator_list : init_declarator",
832 "init_declarator_list : init_declarator_list ',' init_declarator",
833 "init_declarator : declarator",
834 "$$5 :",
835 "init_declarator : declarator '=' $$5 T_INITIALIZER",
836 "enum_specifier : enumeration any_id braces",
837 "enum_specifier : enumeration braces",
838 "enum_specifier : enumeration any_id",
839 "enumeration : T_ENUM",
840 "any_id : T_IDENTIFIER",
841 "any_id : T_TYPEDEF_NAME",
842 "declarator : pointer direct_declarator",
843 "declarator : direct_declarator",
844 "direct_declarator : identifier_or_ref",
845 "direct_declarator : '(' declarator ')'",
846 "direct_declarator : direct_declarator T_BRACKETS",
847 "direct_declarator : direct_declarator '(' parameter_type_list ')'",
848 "direct_declarator : direct_declarator '(' opt_identifier_list ')'",
849 "pointer : '*' opt_type_qualifiers",
850 "pointer : '*' opt_type_qualifiers pointer",
851 "opt_type_qualifiers :",
852 "opt_type_qualifiers : type_qualifier_list",
853 "type_qualifier_list : type_qualifier",
854 "type_qualifier_list : type_qualifier_list type_qualifier",
855 "parameter_type_list : parameter_list",
856 "parameter_type_list : parameter_list ',' T_ELLIPSIS",
857 "parameter_list : parameter_declaration",
858 "parameter_list : parameter_list ',' parameter_declaration",
859 "parameter_declaration : decl_specifiers declarator",
860 "parameter_declaration : decl_specifiers abs_declarator",
861 "parameter_declaration : decl_specifiers",
862 "opt_identifier_list :",
863 "opt_identifier_list : identifier_list",
864 "identifier_list : any_id",
865 "identifier_list : identifier_list ',' any_id",
866 "identifier_or_ref : any_id",
867 "identifier_or_ref : '&' any_id",
868 "abs_declarator : pointer",
869 "abs_declarator : pointer direct_abs_declarator",
870 "abs_declarator : direct_abs_declarator",
871 "direct_abs_declarator : '(' abs_declarator ')'",
872 "direct_abs_declarator : direct_abs_declarator T_BRACKETS",
873 "direct_abs_declarator : T_BRACKETS",
874 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
875 "direct_abs_declarator : direct_abs_declarator '(' ')'",
876 "direct_abs_declarator : '(' parameter_type_list ')'",
877 "direct_abs_declarator : '(' ')'",
880 #endif
882 int yydebug;
883 int yynerrs;
885 int yyerrflag;
886 int yychar;
887 YYSTYPE yyval;
888 YYSTYPE yylval;
890 /* define the initial stack-sizes */
891 #ifdef YYSTACKSIZE
892 #undef YYMAXDEPTH
893 #define YYMAXDEPTH YYSTACKSIZE
894 #else
895 #ifdef YYMAXDEPTH
896 #define YYSTACKSIZE YYMAXDEPTH
897 #else
898 #define YYSTACKSIZE 500
899 #define YYMAXDEPTH 500
900 #endif
901 #endif
903 #define YYINITSTACKSIZE 500
905 typedef struct {
906 unsigned stacksize;
907 short *s_base;
908 short *s_mark;
909 short *s_last;
910 YYSTYPE *l_base;
911 YYSTYPE *l_mark;
912 } YYSTACKDATA;
913 /* variables for the parser stack */
914 static YYSTACKDATA yystack;
915 #line 1014 "grammar.y"
917 /* lex.yy.c */
918 #define BEGIN yy_start = 1 + 2 *
920 #define CPP1 1
921 #define INIT1 2
922 #define INIT2 3
923 #define CURLY 4
924 #define LEXYACC 5
925 #define ASM 6
926 #define CPP_INLINE 7
928 extern char *yytext;
929 extern FILE *yyin, *yyout;
931 static int curly; /* number of curly brace nesting levels */
932 static int ly_count; /* number of occurances of %% */
933 static int inc_depth; /* include nesting level */
934 static SymbolTable *included_files; /* files already included */
935 static int yy_start = 0; /* start state number */
937 #define grammar_error(s) yaccError(s)
939 static void
940 yaccError (const char *msg)
942 func_params = NULL;
943 put_error(); /* tell what line we're on, and what file */
944 fprintf(stderr, "%s at token '%s'\n", msg, yytext);
947 /* Initialize the table of type qualifier keywords recognized by the lexical
948 * analyzer.
950 void
951 init_parser (void)
953 static const char *keywords[] = {
954 "const",
955 "restrict",
956 "volatile",
957 "interrupt",
958 #ifdef vms
959 "noshare",
960 "readonly",
961 #endif
962 #if defined(MSDOS) || defined(OS2)
963 "__cdecl",
964 "__export",
965 "__far",
966 "__fastcall",
967 "__fortran",
968 "__huge",
969 "__inline",
970 "__interrupt",
971 "__loadds",
972 "__near",
973 "__pascal",
974 "__saveregs",
975 "__segment",
976 "__stdcall",
977 "__syscall",
978 "_cdecl",
979 "_cs",
980 "_ds",
981 "_es",
982 "_export",
983 "_far",
984 "_fastcall",
985 "_fortran",
986 "_huge",
987 "_interrupt",
988 "_loadds",
989 "_near",
990 "_pascal",
991 "_saveregs",
992 "_seg",
993 "_segment",
994 "_ss",
995 "cdecl",
996 "far",
997 "huge",
998 "near",
999 "pascal",
1000 #ifdef OS2
1001 "__far16",
1002 #endif
1003 #endif
1004 #ifdef __GNUC__
1005 /* gcc aliases */
1006 "__builtin_va_arg",
1007 "__builtin_va_list",
1008 "__const",
1009 "__const__",
1010 "__inline",
1011 "__inline__",
1012 "__restrict",
1013 "__restrict__",
1014 "__volatile",
1015 "__volatile__",
1016 #endif
1018 unsigned i;
1020 /* Initialize type qualifier table. */
1021 type_qualifiers = new_symbol_table();
1022 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
1023 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
1027 /* Process the C source file. Write function prototypes to the standard
1028 * output. Convert function definitions and write the converted source
1029 * code to a temporary file.
1031 void
1032 process_file (FILE *infile, char *name)
1034 char *s;
1036 if (strlen(name) > 2) {
1037 s = name + strlen(name) - 2;
1038 if (*s == '.') {
1039 ++s;
1040 if (*s == 'l' || *s == 'y')
1041 BEGIN LEXYACC;
1042 #if defined(MSDOS) || defined(OS2)
1043 if (*s == 'L' || *s == 'Y')
1044 BEGIN LEXYACC;
1045 #endif
1049 included_files = new_symbol_table();
1050 typedef_names = new_symbol_table();
1051 define_names = new_symbol_table();
1052 inc_depth = -1;
1053 curly = 0;
1054 ly_count = 0;
1055 func_params = NULL;
1056 yyin = infile;
1057 include_file(strcpy(base_file, name), func_style != FUNC_NONE);
1058 if (file_comments) {
1059 #if OPT_LINTLIBRARY
1060 if (lintLibrary()) {
1061 put_blankline(stdout);
1062 begin_tracking();
1064 #endif
1065 put_string(stdout, "/* ");
1066 put_string(stdout, cur_file_name());
1067 put_string(stdout, " */\n");
1069 yyparse();
1070 free_symbol_table(define_names);
1071 free_symbol_table(typedef_names);
1072 free_symbol_table(included_files);
1075 #ifdef NO_LEAKS
1076 void
1077 free_parser(void)
1079 free_symbol_table (type_qualifiers);
1080 #ifdef FLEX_SCANNER
1081 if (yy_current_buffer != 0)
1082 yy_delete_buffer(yy_current_buffer);
1083 #endif
1085 #endif
1086 #line 1085 "grammar.tab.c"
1088 #if YYDEBUG
1089 #include <stdio.h> /* needed for printf */
1090 #endif
1092 #include <stdlib.h> /* needed for malloc, etc */
1093 #include <string.h> /* needed for memset */
1095 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1096 static int yygrowstack(YYSTACKDATA *data)
1098 int i;
1099 unsigned newsize;
1100 short *newss;
1101 YYSTYPE *newvs;
1103 if ((newsize = data->stacksize) == 0)
1104 newsize = YYINITSTACKSIZE;
1105 else if (newsize >= YYMAXDEPTH)
1106 return -1;
1107 else if ((newsize *= 2) > YYMAXDEPTH)
1108 newsize = YYMAXDEPTH;
1110 i = (int) (data->s_mark - data->s_base);
1111 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
1112 if (newss == 0)
1113 return -1;
1115 data->s_base = newss;
1116 data->s_mark = newss + i;
1118 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1119 if (newvs == 0)
1120 return -1;
1122 data->l_base = newvs;
1123 data->l_mark = newvs + i;
1125 data->stacksize = newsize;
1126 data->s_last = data->s_base + newsize - 1;
1127 return 0;
1130 #if YYPURE || defined(YY_NO_LEAKS)
1131 static void yyfreestack(YYSTACKDATA *data)
1133 free(data->s_base);
1134 free(data->l_base);
1135 memset(data, 0, sizeof(*data));
1137 #else
1138 #define yyfreestack(data) /* nothing */
1139 #endif
1141 #define YYABORT goto yyabort
1142 #define YYREJECT goto yyabort
1143 #define YYACCEPT goto yyaccept
1144 #define YYERROR goto yyerrlab
1147 YYPARSE_DECL()
1149 int yym, yyn, yystate;
1150 #if YYDEBUG
1151 const char *yys;
1153 if ((yys = getenv("YYDEBUG")) != 0)
1155 yyn = *yys;
1156 if (yyn >= '0' && yyn <= '9')
1157 yydebug = yyn - '0';
1159 #endif
1161 yynerrs = 0;
1162 yyerrflag = 0;
1163 yychar = YYEMPTY;
1164 yystate = 0;
1166 #if YYPURE
1167 memset(&yystack, 0, sizeof(yystack));
1168 #endif
1170 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
1171 yystack.s_mark = yystack.s_base;
1172 yystack.l_mark = yystack.l_base;
1173 yystate = 0;
1174 *yystack.s_mark = 0;
1176 yyloop:
1177 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1178 if (yychar < 0)
1180 if ((yychar = YYLEX) < 0) yychar = 0;
1181 #if YYDEBUG
1182 if (yydebug)
1184 yys = 0;
1185 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1186 if (!yys) yys = "illegal-symbol";
1187 printf("%sdebug: state %d, reading %d (%s)\n",
1188 YYPREFIX, yystate, yychar, yys);
1190 #endif
1192 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1193 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1195 #if YYDEBUG
1196 if (yydebug)
1197 printf("%sdebug: state %d, shifting to state %d\n",
1198 YYPREFIX, yystate, yytable[yyn]);
1199 #endif
1200 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1202 goto yyoverflow;
1204 yystate = yytable[yyn];
1205 *++yystack.s_mark = yytable[yyn];
1206 *++yystack.l_mark = yylval;
1207 yychar = YYEMPTY;
1208 if (yyerrflag > 0) --yyerrflag;
1209 goto yyloop;
1211 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1212 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1214 yyn = yytable[yyn];
1215 goto yyreduce;
1217 if (yyerrflag) goto yyinrecovery;
1219 yyerror("syntax error");
1221 goto yyerrlab;
1223 yyerrlab:
1224 ++yynerrs;
1226 yyinrecovery:
1227 if (yyerrflag < 3)
1229 yyerrflag = 3;
1230 for (;;)
1232 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
1233 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1235 #if YYDEBUG
1236 if (yydebug)
1237 printf("%sdebug: state %d, error recovery shifting\
1238 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
1239 #endif
1240 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1242 goto yyoverflow;
1244 yystate = yytable[yyn];
1245 *++yystack.s_mark = yytable[yyn];
1246 *++yystack.l_mark = yylval;
1247 goto yyloop;
1249 else
1251 #if YYDEBUG
1252 if (yydebug)
1253 printf("%sdebug: error recovery discarding state %d\n",
1254 YYPREFIX, *yystack.s_mark);
1255 #endif
1256 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1257 --yystack.s_mark;
1258 --yystack.l_mark;
1262 else
1264 if (yychar == 0) goto yyabort;
1265 #if YYDEBUG
1266 if (yydebug)
1268 yys = 0;
1269 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1270 if (!yys) yys = "illegal-symbol";
1271 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1272 YYPREFIX, yystate, yychar, yys);
1274 #endif
1275 yychar = YYEMPTY;
1276 goto yyloop;
1279 yyreduce:
1280 #if YYDEBUG
1281 if (yydebug)
1282 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1283 YYPREFIX, yystate, yyn, yyrule[yyn]);
1284 #endif
1285 yym = yylen[yyn];
1286 if (yym)
1287 yyval = yystack.l_mark[1-yym];
1288 else
1289 memset(&yyval, 0, sizeof yyval);
1290 switch (yyn)
1292 case 10:
1293 #line 377 "grammar.y"
1295 yyerrok;
1297 break;
1298 case 11:
1299 #line 381 "grammar.y"
1301 yyerrok;
1303 break;
1304 case 13:
1305 #line 392 "grammar.y"
1307 /* Provide an empty action here so bison will not complain about
1308 * incompatible types in the default action it normally would
1309 * have generated.
1312 break;
1313 case 14:
1314 #line 399 "grammar.y"
1316 /* empty */
1318 break;
1319 case 15:
1320 #line 406 "grammar.y"
1322 #if OPT_LINTLIBRARY
1323 if (types_out && want_typedef()) {
1324 gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0);
1325 flush_varargs();
1327 #endif
1328 free_decl_spec(&yystack.l_mark[-1].decl_spec);
1329 end_typedef();
1331 break;
1332 case 16:
1333 #line 417 "grammar.y"
1335 if (func_params != NULL) {
1336 set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1337 } else {
1338 gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1339 #if OPT_LINTLIBRARY
1340 flush_varargs();
1341 #endif
1342 free_decl_list(&yystack.l_mark[-1].decl_list);
1344 free_decl_spec(&yystack.l_mark[-2].decl_spec);
1345 end_typedef();
1347 break;
1348 case 17:
1349 #line 431 "grammar.y"
1351 cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
1352 free_decl_spec(&yystack.l_mark[0].decl_spec);
1354 break;
1355 case 18:
1356 #line 436 "grammar.y"
1358 end_typedef();
1360 break;
1361 case 19:
1362 #line 443 "grammar.y"
1364 begin_typedef();
1366 break;
1367 case 20:
1368 #line 447 "grammar.y"
1370 begin_typedef();
1372 break;
1373 case 23:
1374 #line 459 "grammar.y"
1376 int flags = cur_decl_spec_flags;
1378 /* If the typedef is a pointer type, then reset the short type
1379 * flags so it does not get promoted.
1381 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1382 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1383 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1384 free_declarator(yystack.l_mark[0].declarator);
1386 break;
1387 case 24:
1388 #line 471 "grammar.y"
1390 int flags = cur_decl_spec_flags;
1392 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1393 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1394 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1395 free_declarator(yystack.l_mark[0].declarator);
1397 break;
1398 case 25:
1399 #line 483 "grammar.y"
1401 check_untagged(&yystack.l_mark[-1].decl_spec);
1402 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1403 yyerror("syntax error");
1404 YYERROR;
1406 func_params = &(yystack.l_mark[0].declarator->head->params);
1407 func_params->begin_comment = cur_file->begin_comment;
1408 func_params->end_comment = cur_file->end_comment;
1410 break;
1411 case 26:
1412 #line 494 "grammar.y"
1414 /* If we're converting to K&R and we've got a nominally K&R
1415 * function which has a parameter which is ANSI (i.e., a prototyped
1416 * function pointer), then we must override the deciphered value of
1417 * 'func_def' so that the parameter will be converted.
1419 if (func_style == FUNC_TRADITIONAL
1420 && haveAnsiParam()
1421 && yystack.l_mark[-3].declarator->head->func_def == func_style) {
1422 yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH;
1425 func_params = NULL;
1427 if (cur_file->convert)
1428 gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1429 gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1430 #if OPT_LINTLIBRARY
1431 flush_varargs();
1432 #endif
1433 free_decl_spec(&yystack.l_mark[-4].decl_spec);
1434 free_declarator(yystack.l_mark[-3].declarator);
1436 break;
1437 case 28:
1438 #line 519 "grammar.y"
1440 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1441 yyerror("syntax error");
1442 YYERROR;
1444 func_params = &(yystack.l_mark[0].declarator->head->params);
1445 func_params->begin_comment = cur_file->begin_comment;
1446 func_params->end_comment = cur_file->end_comment;
1448 break;
1449 case 29:
1450 #line 529 "grammar.y"
1452 DeclSpec decl_spec;
1454 func_params = NULL;
1456 new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE);
1457 if (cur_file->convert)
1458 gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator);
1459 gen_prototype(&decl_spec, yystack.l_mark[-4].declarator);
1460 #if OPT_LINTLIBRARY
1461 flush_varargs();
1462 #endif
1463 free_decl_spec(&decl_spec);
1464 free_declarator(yystack.l_mark[-4].declarator);
1466 break;
1467 case 36:
1468 #line 560 "grammar.y"
1470 join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
1471 free(yystack.l_mark[-1].decl_spec.text);
1472 free(yystack.l_mark[0].decl_spec.text);
1474 break;
1475 case 40:
1476 #line 575 "grammar.y"
1478 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1480 break;
1481 case 41:
1482 #line 579 "grammar.y"
1484 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
1486 break;
1487 case 42:
1488 #line 583 "grammar.y"
1490 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1492 break;
1493 case 43:
1494 #line 587 "grammar.y"
1496 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
1498 break;
1499 case 44:
1500 #line 591 "grammar.y"
1502 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
1504 break;
1505 case 45:
1506 #line 595 "grammar.y"
1508 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
1510 break;
1511 case 46:
1512 #line 602 "grammar.y"
1514 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1516 break;
1517 case 47:
1518 #line 606 "grammar.y"
1520 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1522 break;
1523 case 48:
1524 #line 610 "grammar.y"
1526 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
1528 break;
1529 case 49:
1530 #line 614 "grammar.y"
1532 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1534 break;
1535 case 50:
1536 #line 618 "grammar.y"
1538 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1540 break;
1541 case 51:
1542 #line 622 "grammar.y"
1544 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
1546 break;
1547 case 52:
1548 #line 626 "grammar.y"
1550 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1552 break;
1553 case 53:
1554 #line 630 "grammar.y"
1556 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1558 break;
1559 case 54:
1560 #line 634 "grammar.y"
1562 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1564 break;
1565 case 55:
1566 #line 638 "grammar.y"
1568 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1570 break;
1571 case 56:
1572 #line 642 "grammar.y"
1574 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1576 break;
1577 case 57:
1578 #line 646 "grammar.y"
1580 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1582 break;
1583 case 58:
1584 #line 650 "grammar.y"
1586 Symbol *s;
1587 s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
1588 if (s != NULL)
1589 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1591 break;
1592 case 61:
1593 #line 662 "grammar.y"
1595 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1597 break;
1598 case 62:
1599 #line 666 "grammar.y"
1601 /* This rule allows the <pointer> nonterminal to scan #define
1602 * names as if they were type modifiers.
1604 Symbol *s;
1605 s = find_symbol(define_names, yystack.l_mark[0].text.text);
1606 if (s != NULL)
1607 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1609 break;
1610 case 63:
1611 #line 679 "grammar.y"
1613 char *s;
1614 if ((s = implied_typedef()) == 0)
1615 (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
1616 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1618 break;
1619 case 64:
1620 #line 686 "grammar.y"
1622 char *s;
1623 if ((s = implied_typedef()) == 0)
1624 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1625 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1627 break;
1628 case 65:
1629 #line 693 "grammar.y"
1631 (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1632 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1634 break;
1635 case 66:
1636 #line 701 "grammar.y"
1638 imply_typedef(yyval.text.text);
1640 break;
1641 case 67:
1642 #line 705 "grammar.y"
1644 imply_typedef(yyval.text.text);
1646 break;
1647 case 68:
1648 #line 712 "grammar.y"
1650 new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
1652 break;
1653 case 69:
1654 #line 716 "grammar.y"
1656 add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
1658 break;
1659 case 70:
1660 #line 723 "grammar.y"
1662 if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
1663 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1664 gen_func_declarator(yystack.l_mark[0].declarator);
1665 fputs(cur_text(), cur_file->tmp_file);
1667 cur_declarator = yyval.declarator;
1669 break;
1670 case 71:
1671 #line 732 "grammar.y"
1673 if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
1674 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1675 gen_func_declarator(yystack.l_mark[-1].declarator);
1676 fputs(" =", cur_file->tmp_file);
1679 break;
1680 case 73:
1681 #line 744 "grammar.y"
1683 char *s;
1684 if ((s = implied_typedef()) == 0)
1685 (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
1686 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1688 break;
1689 case 74:
1690 #line 751 "grammar.y"
1692 char *s;
1693 if ((s = implied_typedef()) == 0)
1694 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1695 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1697 break;
1698 case 75:
1699 #line 758 "grammar.y"
1701 (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
1702 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1704 break;
1705 case 76:
1706 #line 766 "grammar.y"
1708 imply_typedef("enum");
1709 yyval.text = yystack.l_mark[0].text;
1711 break;
1712 case 79:
1713 #line 779 "grammar.y"
1715 yyval.declarator = yystack.l_mark[0].declarator;
1716 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1717 free(yyval.declarator->text);
1718 yyval.declarator->text = xstrdup(buf);
1719 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1720 yyval.declarator->pointer = TRUE;
1722 break;
1723 case 81:
1724 #line 792 "grammar.y"
1726 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
1728 break;
1729 case 82:
1730 #line 796 "grammar.y"
1732 yyval.declarator = yystack.l_mark[-1].declarator;
1733 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1734 free(yyval.declarator->text);
1735 yyval.declarator->text = xstrdup(buf);
1736 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1738 break;
1739 case 83:
1740 #line 804 "grammar.y"
1742 yyval.declarator = yystack.l_mark[-1].declarator;
1743 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1744 free(yyval.declarator->text);
1745 yyval.declarator->text = xstrdup(buf);
1747 break;
1748 case 84:
1749 #line 811 "grammar.y"
1751 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1752 yyval.declarator->params = yystack.l_mark[-1].param_list;
1753 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1754 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1755 yyval.declarator->func_def = FUNC_ANSI;
1757 break;
1758 case 85:
1759 #line 819 "grammar.y"
1761 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1762 yyval.declarator->params = yystack.l_mark[-1].param_list;
1763 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1764 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1765 yyval.declarator->func_def = FUNC_TRADITIONAL;
1767 break;
1768 case 86:
1769 #line 830 "grammar.y"
1771 (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
1772 yyval.text.begin = yystack.l_mark[-1].text.begin;
1774 break;
1775 case 87:
1776 #line 835 "grammar.y"
1778 (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1779 yyval.text.begin = yystack.l_mark[-2].text.begin;
1781 break;
1782 case 88:
1783 #line 843 "grammar.y"
1785 strcpy(yyval.text.text, "");
1786 yyval.text.begin = 0L;
1788 break;
1789 case 90:
1790 #line 852 "grammar.y"
1792 (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
1793 yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
1794 free(yystack.l_mark[0].decl_spec.text);
1796 break;
1797 case 91:
1798 #line 858 "grammar.y"
1800 (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
1801 yyval.text.begin = yystack.l_mark[-1].text.begin;
1802 free(yystack.l_mark[0].decl_spec.text);
1804 break;
1805 case 93:
1806 #line 868 "grammar.y"
1808 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
1810 break;
1811 case 94:
1812 #line 875 "grammar.y"
1814 new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
1816 break;
1817 case 95:
1818 #line 879 "grammar.y"
1820 add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
1822 break;
1823 case 96:
1824 #line 886 "grammar.y"
1826 check_untagged(&yystack.l_mark[-1].decl_spec);
1827 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1829 break;
1830 case 97:
1831 #line 891 "grammar.y"
1833 check_untagged(&yystack.l_mark[-1].decl_spec);
1834 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1836 break;
1837 case 98:
1838 #line 896 "grammar.y"
1840 check_untagged(&yystack.l_mark[0].decl_spec);
1841 yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
1843 break;
1844 case 99:
1845 #line 904 "grammar.y"
1847 new_ident_list(&yyval.param_list);
1849 break;
1850 case 101:
1851 #line 912 "grammar.y"
1853 new_ident_list(&yyval.param_list);
1854 add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
1856 break;
1857 case 102:
1858 #line 917 "grammar.y"
1860 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
1862 break;
1863 case 103:
1864 #line 924 "grammar.y"
1866 yyval.text = yystack.l_mark[0].text;
1868 break;
1869 case 104:
1870 #line 928 "grammar.y"
1872 #if OPT_LINTLIBRARY
1873 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
1874 yyval.text = yystack.l_mark[0].text;
1875 } else
1876 #endif
1877 (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
1878 yyval.text.begin = yystack.l_mark[-1].text.begin;
1880 break;
1881 case 105:
1882 #line 941 "grammar.y"
1884 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1886 break;
1887 case 106:
1888 #line 945 "grammar.y"
1890 yyval.declarator = yystack.l_mark[0].declarator;
1891 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1892 free(yyval.declarator->text);
1893 yyval.declarator->text = xstrdup(buf);
1894 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1896 break;
1897 case 108:
1898 #line 957 "grammar.y"
1900 yyval.declarator = yystack.l_mark[-1].declarator;
1901 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1902 free(yyval.declarator->text);
1903 yyval.declarator->text = xstrdup(buf);
1904 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1906 break;
1907 case 109:
1908 #line 965 "grammar.y"
1910 yyval.declarator = yystack.l_mark[-1].declarator;
1911 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1912 free(yyval.declarator->text);
1913 yyval.declarator->text = xstrdup(buf);
1915 break;
1916 case 110:
1917 #line 972 "grammar.y"
1919 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1921 break;
1922 case 111:
1923 #line 976 "grammar.y"
1925 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
1926 yyval.declarator->params = yystack.l_mark[-1].param_list;
1927 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1928 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1929 yyval.declarator->func_def = FUNC_ANSI;
1931 break;
1932 case 112:
1933 #line 984 "grammar.y"
1935 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
1936 yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
1937 yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head;
1938 yyval.declarator->func_def = FUNC_ANSI;
1940 break;
1941 case 113:
1942 #line 991 "grammar.y"
1944 Declarator *d;
1946 d = new_declarator("", "", yystack.l_mark[-2].text.begin);
1947 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin);
1948 yyval.declarator->params = yystack.l_mark[-1].param_list;
1949 yyval.declarator->func_stack = d;
1950 yyval.declarator->head = yyval.declarator;
1951 yyval.declarator->func_def = FUNC_ANSI;
1953 break;
1954 case 114:
1955 #line 1002 "grammar.y"
1957 Declarator *d;
1959 d = new_declarator("", "", yystack.l_mark[-1].text.begin);
1960 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin);
1961 yyval.declarator->func_stack = d;
1962 yyval.declarator->head = yyval.declarator;
1963 yyval.declarator->func_def = FUNC_ANSI;
1965 break;
1966 #line 1965 "grammar.tab.c"
1968 yystack.s_mark -= yym;
1969 yystate = *yystack.s_mark;
1970 yystack.l_mark -= yym;
1971 yym = yylhs[yyn];
1972 if (yystate == 0 && yym == 0)
1974 #if YYDEBUG
1975 if (yydebug)
1976 printf("%sdebug: after reduction, shifting from state 0 to\
1977 state %d\n", YYPREFIX, YYFINAL);
1978 #endif
1979 yystate = YYFINAL;
1980 *++yystack.s_mark = YYFINAL;
1981 *++yystack.l_mark = yyval;
1982 if (yychar < 0)
1984 if ((yychar = YYLEX) < 0) yychar = 0;
1985 #if YYDEBUG
1986 if (yydebug)
1988 yys = 0;
1989 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1990 if (!yys) yys = "illegal-symbol";
1991 printf("%sdebug: state %d, reading %d (%s)\n",
1992 YYPREFIX, YYFINAL, yychar, yys);
1994 #endif
1996 if (yychar == 0) goto yyaccept;
1997 goto yyloop;
1999 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
2000 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
2001 yystate = yytable[yyn];
2002 else
2003 yystate = yydgoto[yym];
2004 #if YYDEBUG
2005 if (yydebug)
2006 printf("%sdebug: after reduction, shifting from state %d \
2007 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
2008 #endif
2009 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
2011 goto yyoverflow;
2013 *++yystack.s_mark = (short) yystate;
2014 *++yystack.l_mark = yyval;
2015 goto yyloop;
2017 yyoverflow:
2018 yyerror("yacc stack overflow");
2020 yyabort:
2021 yyfreestack(&yystack);
2022 return (1);
2024 yyaccept:
2025 yyfreestack(&yystack);
2026 return (0);