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