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