2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
8 #define YYPATCH 20140101
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
22 #define YYSTYPE_IS_DECLARED
23 #define yyerror yaccError
26 #if defined(YYBISON) || !defined(YYBYACC)
27 static void yyerror(const char *s);
34 #define OPT_LINTLIBRARY 1
44 /* #include "cproto.h" */
45 #define MAX_TEXT_SIZE 1024
47 /* Prototype styles */
49 #define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
50 #define PROTO_LINTLIBRARY -1 /* form lint-library source */
52 #define PROTO_NONE 0 /* do not output any prototypes */
53 #define PROTO_TRADITIONAL 1 /* comment out parameters */
54 #define PROTO_ABSTRACT 2 /* comment out parameter names */
55 #define PROTO_ANSI 3 /* ANSI C prototype */
57 typedef int PrototypeStyle;
61 extern boolean types_out;
62 extern PrototypeStyle proto_style;
64 #define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
65 #define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
66 #define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
69 #define FUNC_UNKNOWN -1 /* unspecified */
71 #define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
73 #define FUNC_NONE 0 /* not a function definition */
74 #define FUNC_TRADITIONAL 1 /* traditional style */
75 #define FUNC_ANSI 2 /* ANSI style */
76 #define FUNC_BOTH 3 /* both styles */
78 typedef int FuncDefStyle;
80 /* Source file text */
82 char text[MAX_TEXT_SIZE]; /* source text */
83 long begin; /* offset in temporary file */
86 /* Declaration specifier flags */
87 #define DS_NONE 0 /* default */
88 #define DS_EXTERN 1 /* contains "extern" specifier */
89 #define DS_STATIC 2 /* contains "static" specifier */
90 #define DS_CHAR 4 /* contains "char" type specifier */
91 #define DS_SHORT 8 /* contains "short" type specifier */
92 #define DS_FLOAT 16 /* contains "float" type specifier */
93 #define DS_INLINE 32 /* contains "inline" specifier */
94 #define DS_JUNK 64 /* we're not interested in this declaration */
96 /* This structure stores information about a declaration specifier. */
97 typedef struct decl_spec {
98 unsigned short flags; /* flags defined above */
99 char *text; /* source text */
100 long begin; /* offset in temporary file */
103 /* This is a list of function parameters. */
104 typedef struct _ParameterList {
105 struct parameter *first; /* pointer to first parameter in list */
106 struct parameter *last; /* pointer to last parameter in list */
107 long begin_comment; /* begin offset of comment */
108 long end_comment; /* end offset of comment */
109 char *comment; /* comment at start of parameter list */
112 /* This structure stores information about a declarator. */
113 typedef struct _Declarator {
114 char *name; /* name of variable or function */
115 char *text; /* source text */
116 long begin; /* offset in temporary file */
117 long begin_comment; /* begin offset of comment */
118 long end_comment; /* end offset of comment */
119 FuncDefStyle func_def; /* style of function definition */
120 ParameterList params; /* function parameters */
121 boolean pointer; /* TRUE if it declares a pointer */
122 struct _Declarator *head; /* head function declarator */
123 struct _Declarator *func_stack; /* stack of function declarators */
124 struct _Declarator *next; /* next declarator in list */
127 /* This structure stores information about a function parameter. */
128 typedef struct parameter {
129 struct parameter *next; /* next parameter in list */
131 Declarator *declarator;
132 char *comment; /* comment following the parameter */
135 /* This is a list of declarators. */
136 typedef struct declarator_list {
137 Declarator *first; /* pointer to first declarator in list */
138 Declarator *last; /* pointer to last declarator in list */
141 /* #include "symbol.h" */
142 typedef struct symbol {
143 struct symbol *next; /* next symbol in list */
144 char *name; /* name of symbol */
145 char *value; /* value of symbol (for defines) */
146 short flags; /* symbol attributes */
149 /* parser stack entry type */
153 Parameter *parameter;
154 ParameterList param_list;
155 Declarator *declarator;
156 DeclaratorList decl_list;
159 /* The hash table length should be a prime number. */
160 #define SYM_MAX_HASH 251
162 typedef struct symbol_table {
163 Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */
166 extern SymbolTable *new_symbol_table /* Create symbol table */
168 extern void free_symbol_table /* Destroy symbol table */
170 extern Symbol *find_symbol /* Lookup symbol name */
171 (SymbolTable *s, const char *n);
172 extern Symbol *new_symbol /* Define new symbol */
173 (SymbolTable *s, const char *n, const char *v, int f);
175 /* #include "semantic.h" */
176 extern void new_decl_spec (DeclSpec *, const char *, long, int);
177 extern void free_decl_spec (DeclSpec *);
178 extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *);
179 extern void check_untagged (DeclSpec *);
180 extern Declarator *new_declarator (const char *, const char *, long);
181 extern void free_declarator (Declarator *);
182 extern void new_decl_list (DeclaratorList *, Declarator *);
183 extern void free_decl_list (DeclaratorList *);
184 extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *);
185 extern Parameter *new_parameter (DeclSpec *, Declarator *);
186 extern void free_parameter (Parameter *);
187 extern void new_param_list (ParameterList *, Parameter *);
188 extern void free_param_list (ParameterList *);
189 extern void add_param_list (ParameterList *, ParameterList *, Parameter *);
190 extern void new_ident_list (ParameterList *);
191 extern void add_ident_list (ParameterList *, ParameterList *, const char *);
192 extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *);
193 extern void gen_declarations (DeclSpec *, DeclaratorList *);
194 extern void gen_prototype (DeclSpec *, Declarator *);
195 extern void gen_func_declarator (Declarator *);
196 extern void gen_func_definition (DeclSpec *, Declarator *);
198 extern void init_parser (void);
199 extern void process_file (FILE *infile, char *name);
200 extern char *cur_text (void);
201 extern char *cur_file_name (void);
202 extern char *implied_typedef (void);
203 extern void include_file (char *name, int convert);
204 extern char *supply_parm (int count);
205 extern char *xstrdup (const char *);
206 extern int already_declared (char *name);
207 extern int is_actual_func (Declarator *d);
208 extern int lint_ellipsis (Parameter *p);
209 extern int want_typedef (void);
210 extern void begin_tracking (void);
211 extern void begin_typedef (void);
212 extern void copy_typedef (char *s);
213 extern void ellipsis_varargs (Declarator *d);
214 extern void end_typedef (void);
215 extern void flush_varargs (void);
216 extern void fmt_library (int code);
217 extern void imply_typedef (const char *s);
218 extern void indent (FILE *outf);
219 extern void put_blankline (FILE *outf);
220 extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator);
221 extern void put_char (FILE *outf, int c);
222 extern void put_error (void);
223 extern void put_newline (FILE *outf);
224 extern void put_padded (FILE *outf, const char *s);
225 extern void put_string (FILE *outf, const char *s);
226 extern void track_in (void);
228 extern boolean file_comments;
229 extern FuncDefStyle func_style;
230 extern char base_file[];
232 extern int yylex (void);
234 /* declaration specifier attributes for the typedef statement currently being
237 static int cur_decl_spec_flags;
239 /* pointer to parameter list for the current function definition */
240 static ParameterList *func_params;
242 /* A parser semantic action sets this pointer to the current declarator in
243 * a function parameter declaration in order to catch any comments following
244 * the parameter declaration on the same line. If the lexer scans a comment
245 * and <cur_declarator> is not NULL, then the comment is attached to the
246 * declarator. To ignore subsequent comments, the lexer sets this to NULL
247 * after scanning a comment or end of line.
249 static Declarator *cur_declarator;
251 /* temporary string buffer */
252 static char buf[MAX_TEXT_SIZE];
254 /* table of typedef names */
255 static SymbolTable *typedef_names;
257 /* table of define names */
258 static SymbolTable *define_names;
260 /* table of type qualifiers */
261 static SymbolTable *type_qualifiers;
263 /* information about the current input file */
265 char *base_name; /* base input file name */
266 char *file_name; /* current file name */
267 FILE *file; /* input file */
268 unsigned line_num; /* current line number in input file */
269 FILE *tmp_file; /* temporary file */
270 long begin_comment; /* tmp file offset after last written ) or ; */
271 long end_comment; /* tmp file offset after last comment */
272 boolean convert; /* if TRUE, convert function definitions */
273 boolean changed; /* TRUE if conversion done in this file */
276 static IncludeStack *cur_file; /* current input file */
278 /* #include "yyerror.c" */
280 static int haveAnsiParam (void);
283 /* Flags to enable us to find if a procedure returns a value.
285 static int return_val; /* nonzero on BRACES iff return-expression found */
290 return (lintLibrary() && !return_val) ? "void" : "int";
297 if (func_params != 0) {
298 for (p = func_params->first; p != 0; p = p->next) {
299 if (p->declarator->func_def == FUNC_ANSI) {
306 #line 306 "/dev/stdout"
308 /* compatibility with bison */
310 /* compatibility with FreeBSD */
311 # ifdef YYPARSE_PARAM_TYPE
312 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
314 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
317 # define YYPARSE_DECL() yyparse(void)
320 /* Parameters sent to lex. */
322 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
323 # define YYLEX yylex(YYLEX_PARAM)
325 # define YYLEX_DECL() yylex(void)
326 # define YYLEX yylex()
329 /* Parameters sent to yyerror. */
331 #define YYERROR_DECL() yyerror(const char *s)
334 #define YYERROR_CALL(msg) yyerror(msg)
337 extern int YYPARSE_DECL();
339 #define T_IDENTIFIER 257
340 #define T_TYPEDEF_NAME 258
341 #define T_DEFINE_NAME 259
344 #define T_REGISTER 262
346 #define T_TYPEDEF 264
348 #define T_EXTENSION 266
357 #define T_UNSIGNED 275
362 #define T_Complex 280
363 #define T_Imaginary 281
364 #define T_TYPE_QUALIFIER 282
365 #define T_BRACKETS 283
367 #define T_MATCHRBRACE 285
368 #define T_ELLIPSIS 286
369 #define T_INITIALIZER 287
370 #define T_STRING_LITERAL 288
374 #define YYERRCODE 256
375 static const short yylhs[] = { -1,
376 0, 0, 26, 26, 27, 27, 27, 27, 27, 27,
377 27, 31, 30, 30, 28, 28, 34, 28, 32, 32,
378 33, 33, 35, 35, 37, 38, 29, 39, 29, 36,
379 36, 36, 40, 40, 1, 1, 2, 2, 2, 3,
380 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
381 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
382 5, 5, 6, 6, 6, 19, 19, 8, 8, 9,
383 41, 9, 7, 7, 7, 25, 23, 23, 10, 10,
384 11, 11, 11, 11, 11, 20, 20, 21, 21, 22,
385 22, 14, 14, 15, 15, 16, 16, 16, 17, 17,
386 18, 18, 24, 24, 12, 12, 12, 13, 13, 13,
389 static const short yylen[] = { 2,
390 0, 1, 1, 2, 1, 1, 1, 1, 3, 2,
391 2, 2, 3, 3, 2, 3, 0, 5, 2, 1,
392 0, 1, 1, 3, 0, 0, 7, 0, 5, 0,
393 1, 1, 1, 2, 1, 2, 1, 1, 1, 1,
394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 1, 3, 2, 2, 1, 1, 1, 3, 1,
397 0, 4, 3, 2, 2, 1, 1, 1, 2, 1,
398 1, 3, 2, 4, 4, 2, 3, 0, 1, 1,
399 2, 1, 3, 1, 3, 2, 2, 1, 0, 1,
400 1, 3, 1, 2, 1, 2, 1, 3, 2, 1,
403 static const short yydefred[] = { 0,
404 0, 0, 0, 0, 77, 0, 62, 40, 0, 42,
405 43, 20, 44, 0, 46, 47, 48, 49, 54, 50,
406 51, 52, 53, 76, 66, 67, 55, 56, 57, 61,
407 0, 7, 0, 0, 35, 37, 38, 39, 59, 60,
408 28, 0, 0, 0, 103, 81, 0, 0, 3, 5,
409 6, 8, 0, 10, 11, 78, 0, 90, 0, 0,
410 104, 0, 19, 0, 41, 45, 15, 36, 0, 68,
411 0, 0, 0, 83, 0, 0, 64, 0, 0, 74,
412 4, 58, 0, 82, 87, 91, 0, 14, 13, 9,
413 16, 0, 71, 0, 31, 33, 0, 0, 0, 0,
414 0, 94, 0, 0, 101, 12, 63, 73, 0, 0,
415 69, 0, 0, 0, 34, 0, 110, 96, 97, 0,
416 0, 84, 0, 85, 0, 23, 0, 0, 72, 26,
417 29, 114, 0, 0, 0, 109, 0, 93, 95, 102,
418 18, 0, 0, 108, 113, 112, 0, 24, 27, 111,
420 static const short yydgoto[] = { 33,
421 87, 35, 36, 37, 38, 39, 40, 69, 70, 41,
422 42, 119, 120, 100, 101, 102, 103, 104, 43, 44,
423 59, 60, 45, 46, 47, 48, 49, 50, 51, 52,
424 77, 53, 127, 109, 128, 97, 94, 143, 72, 98,
427 static const short yysindex[] = { -2,
428 -3, 27, -239, -177, 0, 0, 0, 0, -274, 0,
429 0, 0, 0, -246, 0, 0, 0, 0, 0, 0,
430 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
431 -266, 0, 0, 455, 0, 0, 0, 0, 0, 0,
432 0, -35, -245, 128, 0, 0, -245, -2, 0, 0,
433 0, 0, 642, 0, 0, 0, -15, 0, -12, -239,
434 0, 590, 0, -27, 0, 0, 0, 0, -10, 0,
435 -11, 534, -72, 0, -237, -232, 0, -35, -232, 0,
436 0, 0, 642, 0, 0, 0, 455, 0, 0, 0,
437 0, 27, 0, 534, 0, 0, -222, 617, 209, 34,
438 39, 0, 44, 42, 0, 0, 0, 0, 27, -11,
439 0, -200, -196, -195, 0, 174, 0, 0, 0, -33,
440 243, 0, 561, 0, -177, 0, 33, 49, 0, 0,
441 0, 0, 53, 55, 417, 0, -33, 0, 0, 0,
442 0, 27, -188, 0, 0, 0, 57, 0, 0, 0,
444 static const short yyrindex[] = { 99,
445 0, 0, 275, 0, 0, -38, 0, 0, 481, 0,
446 0, 0, 0, 509, 0, 0, 0, 0, 0, 0,
447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
449 0, 30, 0, 0, 0, 0, 0, 101, 0, 0,
450 0, 0, 0, 0, 0, 0, 0, 0, 343, 309,
451 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
452 98, -182, 62, 0, 0, 133, 0, 64, 379, 0,
453 0, 0, -5, 0, 0, 0, 0, 0, 0, 0,
454 0, 0, 0, -182, 0, 0, 0, -180, -19, 0,
455 65, 0, 0, 68, 0, 0, 0, 0, 51, 9,
456 0, 0, 0, 0, 0, 0, 0, 0, 0, -13,
457 19, 0, 0, 0, 0, 0, 0, 52, 0, 0,
458 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
459 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
461 static const short yygindex[] = { 0,
462 11, -17, 0, 0, 13, 0, 0, 0, 20, 8,
463 -43, -1, -8, -89, 0, -9, 0, 0, 0, -44,
464 0, 0, 4, 0, 0, 0, 70, -53, 0, 0,
465 -18, 0, 0, 0, 0, 22, 0, 0, 0, 0,
468 #define YYTABLESIZE 924
469 static const short yytable[] = { 58,
470 78, 58, 58, 58, 73, 58, 135, 61, 88, 57,
471 34, 5, 56, 62, 85, 58, 68, 63, 96, 7,
472 58, 98, 78, 64, 98, 84, 134, 107, 80, 3,
473 107, 90, 17, 92, 17, 4, 17, 2, 75, 3,
474 96, 71, 30, 89, 115, 147, 76, 106, 91, 93,
475 79, 75, 70, 17, 121, 55, 32, 107, 34, 105,
476 108, 114, 105, 83, 4, 68, 2, 70, 3, 68,
477 80, 121, 86, 80, 122, 106, 105, 78, 106, 5,
478 56, 68, 123, 99, 124, 125, 129, 130, 80, 131,
479 80, 141, 142, 144, 110, 145, 149, 150, 1, 110,
480 2, 30, 99, 32, 79, 92, 118, 79, 100, 21,
481 22, 111, 137, 139, 133, 113, 126, 81, 0, 0,
482 0, 0, 79, 57, 79, 0, 99, 0, 140, 0,
483 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
484 0, 70, 0, 0, 0, 99, 0, 0, 0, 148,
485 0, 0, 0, 0, 0, 0, 70, 0, 0, 0,
486 0, 0, 0, 0, 0, 4, 0, 2, 0, 0,
487 65, 0, 65, 65, 65, 0, 65, 0, 0, 0,
488 0, 0, 0, 0, 5, 6, 7, 8, 65, 10,
489 11, 65, 13, 66, 15, 16, 17, 18, 19, 20,
490 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
491 0, 4, 0, 116, 132, 3, 0, 0, 58, 58,
492 58, 58, 58, 58, 58, 78, 58, 58, 58, 58,
493 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
494 58, 58, 58, 58, 58, 78, 4, 74, 116, 136,
495 3, 17, 78, 1, 5, 6, 7, 8, 9, 10,
496 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
497 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
498 4, 54, 116, 5, 56, 0, 31, 80, 80, 80,
499 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
500 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
501 80, 80, 88, 80, 88, 88, 88, 0, 88, 0,
502 80, 79, 79, 79, 79, 79, 79, 79, 79, 79,
503 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
504 79, 79, 79, 79, 79, 79, 89, 79, 89, 89,
505 89, 0, 89, 0, 79, 25, 25, 25, 25, 25,
506 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
507 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
508 86, 25, 86, 86, 5, 56, 86, 0, 25, 65,
509 65, 65, 65, 65, 65, 65, 0, 65, 65, 65,
510 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
511 65, 65, 65, 65, 65, 65, 75, 0, 75, 75,
512 75, 0, 75, 0, 0, 0, 0, 0, 0, 0,
513 5, 6, 7, 8, 65, 10, 11, 75, 13, 66,
514 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
515 25, 26, 27, 28, 29, 30, 117, 146, 0, 0,
516 0, 0, 0, 0, 0, 5, 6, 7, 8, 65,
517 10, 11, 0, 13, 66, 15, 16, 17, 18, 19,
518 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
519 30, 117, 4, 0, 2, 0, 3, 0, 0, 5,
520 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
521 0, 0, 0, 67, 0, 0, 0, 0, 41, 0,
522 41, 0, 41, 0, 0, 117, 0, 0, 0, 0,
523 0, 88, 88, 0, 0, 0, 0, 0, 0, 41,
524 0, 0, 0, 0, 0, 0, 45, 0, 45, 0,
525 45, 0, 0, 0, 0, 0, 0, 88, 0, 0,
526 0, 0, 0, 0, 0, 89, 89, 45, 0, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
528 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
529 0, 89, 0, 0, 0, 0, 0, 0, 0, 86,
530 86, 0, 0, 0, 0, 0, 0, 0, 0, 0,
531 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
532 0, 0, 0, 0, 0, 86, 0, 0, 0, 0,
533 0, 0, 0, 0, 0, 75, 75, 75, 75, 75,
534 75, 75, 0, 75, 75, 75, 75, 75, 75, 75,
535 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
536 75, 75, 0, 0, 0, 0, 0, 0, 0, 0,
537 0, 0, 0, 0, 82, 7, 8, 65, 10, 11,
538 0, 13, 66, 15, 16, 17, 18, 19, 20, 21,
539 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
540 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
541 0, 5, 6, 7, 8, 65, 10, 11, 0, 13,
542 66, 15, 16, 17, 18, 19, 20, 21, 22, 23,
543 24, 25, 26, 27, 28, 29, 30, 41, 41, 41,
544 41, 41, 41, 41, 0, 41, 41, 41, 41, 41,
545 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
546 41, 41, 41, 0, 0, 45, 45, 45, 45, 45,
547 45, 45, 0, 45, 45, 45, 45, 45, 45, 45,
548 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
549 45, 82, 7, 8, 65, 10, 11, 12, 13, 14,
550 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
551 25, 26, 27, 28, 29, 30, 0, 0, 82, 7,
552 8, 65, 10, 11, 95, 13, 66, 15, 16, 17,
553 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
554 28, 29, 30, 0, 0, 0, 138, 82, 7, 8,
555 65, 10, 11, 12, 13, 14, 15, 16, 17, 18,
556 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
557 29, 30, 0, 75, 82, 7, 8, 65, 10, 11,
558 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
559 22, 23, 24, 25, 26, 27, 28, 29, 30, 82,
560 7, 8, 65, 10, 11, 0, 13, 66, 15, 16,
561 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
564 static const short yycheck[] = { 38,
565 44, 40, 41, 42, 40, 44, 40, 4, 62, 2,
566 0, 257, 258, 288, 59, 3, 34, 264, 72, 259,
567 59, 41, 61, 290, 44, 41, 116, 41, 47, 42,
568 44, 59, 38, 44, 40, 38, 42, 40, 284, 42,
569 94, 34, 282, 62, 98, 135, 43, 285, 59, 61,
570 47, 284, 44, 59, 99, 59, 59, 76, 48, 41,
571 79, 284, 44, 53, 38, 83, 40, 59, 42, 87,
572 41, 116, 60, 44, 41, 41, 73, 121, 44, 257,
573 258, 99, 44, 73, 41, 44, 287, 284, 59, 285,
574 61, 59, 44, 41, 87, 41, 285, 41, 0, 92,
575 0, 284, 41, 284, 41, 41, 99, 44, 41, 59,
576 59, 92, 121, 123, 116, 94, 109, 48, -1, -1,
577 -1, -1, 59, 116, 61, -1, 116, -1, 125, -1,
578 -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
579 -1, 44, -1, -1, -1, 135, -1, -1, -1, 142,
580 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
581 -1, -1, -1, -1, -1, 38, -1, 40, -1, -1,
582 38, -1, 40, 41, 42, -1, 44, -1, -1, -1,
583 -1, -1, -1, -1, 257, 258, 259, 260, 261, 262,
584 263, 59, 265, 266, 267, 268, 269, 270, 271, 272,
585 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
586 -1, 38, -1, 40, 41, 42, -1, -1, 257, 258,
587 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
588 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
589 279, 280, 281, 282, 283, 284, 38, 283, 40, 283,
590 42, 257, 291, 256, 257, 258, 259, 260, 261, 262,
591 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
592 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
593 38, 285, 40, 257, 258, -1, 289, 258, 259, 260,
594 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
595 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
596 281, 282, 38, 284, 40, 41, 42, -1, 44, -1,
597 291, 258, 259, 260, 261, 262, 263, 264, 265, 266,
598 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
599 277, 278, 279, 280, 281, 282, 38, 284, 40, 41,
600 42, -1, 44, -1, 291, 258, 259, 260, 261, 262,
601 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
602 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
603 38, 284, 40, 41, 257, 258, 44, -1, 291, 257,
604 258, 259, 260, 261, 262, 263, -1, 265, 266, 267,
605 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
606 278, 279, 280, 281, 282, 283, 38, -1, 40, 41,
607 42, -1, 44, -1, -1, -1, -1, -1, -1, -1,
608 257, 258, 259, 260, 261, 262, 263, 59, 265, 266,
609 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
610 277, 278, 279, 280, 281, 282, 283, 41, -1, -1,
611 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
612 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
613 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
614 282, 283, 38, -1, 40, -1, 42, -1, -1, 257,
615 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
616 -1, -1, -1, 59, -1, -1, -1, -1, 38, -1,
617 40, -1, 42, -1, -1, 283, -1, -1, -1, -1,
618 -1, 257, 258, -1, -1, -1, -1, -1, -1, 59,
619 -1, -1, -1, -1, -1, -1, 38, -1, 40, -1,
620 42, -1, -1, -1, -1, -1, -1, 283, -1, -1,
621 -1, -1, -1, -1, -1, 257, 258, 59, -1, -1,
622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
623 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
624 -1, 283, -1, -1, -1, -1, -1, -1, -1, 257,
625 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
627 -1, -1, -1, -1, -1, 283, -1, -1, -1, -1,
628 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
629 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
630 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
631 282, 283, -1, -1, -1, -1, -1, -1, -1, -1,
632 -1, -1, -1, -1, 258, 259, 260, 261, 262, 263,
633 -1, 265, 266, 267, 268, 269, 270, 271, 272, 273,
634 274, 275, 276, 277, 278, 279, 280, 281, 282, -1,
635 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
636 -1, 257, 258, 259, 260, 261, 262, 263, -1, 265,
637 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
638 276, 277, 278, 279, 280, 281, 282, 257, 258, 259,
639 260, 261, 262, 263, -1, 265, 266, 267, 268, 269,
640 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
641 280, 281, 282, -1, -1, 257, 258, 259, 260, 261,
642 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
643 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
644 282, 258, 259, 260, 261, 262, 263, 264, 265, 266,
645 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
646 277, 278, 279, 280, 281, 282, -1, -1, 258, 259,
647 260, 261, 262, 263, 291, 265, 266, 267, 268, 269,
648 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
649 280, 281, 282, -1, -1, -1, 286, 258, 259, 260,
650 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
651 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
652 281, 282, -1, 284, 258, 259, 260, 261, 262, 263,
653 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
654 274, 275, 276, 277, 278, 279, 280, 281, 282, 258,
655 259, 260, 261, 262, 263, -1, 265, 266, 267, 268,
656 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
663 #define YYMAXTOKEN 291
664 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? (YYMAXTOKEN + 1) : (a))
666 static const char *yyname[] = {
668 "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,
669 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
670 "'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
671 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
672 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
673 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
674 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
675 "T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
676 "T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR",
677 "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED",
678 "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary",
679 "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS",
680 "T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
683 static const char *yyrule[] = {
686 "program : translation_unit",
687 "translation_unit : external_declaration",
688 "translation_unit : translation_unit external_declaration",
689 "external_declaration : declaration",
690 "external_declaration : function_definition",
691 "external_declaration : ';'",
692 "external_declaration : linkage_specification",
693 "external_declaration : T_ASM T_ASMARG ';'",
694 "external_declaration : error T_MATCHRBRACE",
695 "external_declaration : error ';'",
696 "braces : T_LBRACE T_MATCHRBRACE",
697 "linkage_specification : T_EXTERN T_STRING_LITERAL braces",
698 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
699 "declaration : decl_specifiers ';'",
700 "declaration : decl_specifiers init_declarator_list ';'",
702 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
703 "any_typedef : T_EXTENSION T_TYPEDEF",
704 "any_typedef : T_TYPEDEF",
705 "opt_declarator_list :",
706 "opt_declarator_list : declarator_list",
707 "declarator_list : declarator",
708 "declarator_list : declarator_list ',' declarator",
711 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
713 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
714 "opt_declaration_list :",
715 "opt_declaration_list : T_VA_DCL",
716 "opt_declaration_list : declaration_list",
717 "declaration_list : declaration",
718 "declaration_list : declaration_list declaration",
719 "decl_specifiers : decl_specifier",
720 "decl_specifiers : decl_specifiers decl_specifier",
721 "decl_specifier : storage_class",
722 "decl_specifier : type_specifier",
723 "decl_specifier : type_qualifier",
724 "storage_class : T_AUTO",
725 "storage_class : T_EXTERN",
726 "storage_class : T_REGISTER",
727 "storage_class : T_STATIC",
728 "storage_class : T_INLINE",
729 "storage_class : T_EXTENSION",
730 "type_specifier : T_CHAR",
731 "type_specifier : T_DOUBLE",
732 "type_specifier : T_FLOAT",
733 "type_specifier : T_INT",
734 "type_specifier : T_LONG",
735 "type_specifier : T_SHORT",
736 "type_specifier : T_SIGNED",
737 "type_specifier : T_UNSIGNED",
738 "type_specifier : T_VOID",
739 "type_specifier : T_Bool",
740 "type_specifier : T_Complex",
741 "type_specifier : T_Imaginary",
742 "type_specifier : T_TYPEDEF_NAME",
743 "type_specifier : struct_or_union_specifier",
744 "type_specifier : enum_specifier",
745 "type_qualifier : T_TYPE_QUALIFIER",
746 "type_qualifier : T_DEFINE_NAME",
747 "struct_or_union_specifier : struct_or_union any_id braces",
748 "struct_or_union_specifier : struct_or_union braces",
749 "struct_or_union_specifier : struct_or_union any_id",
750 "struct_or_union : T_STRUCT",
751 "struct_or_union : T_UNION",
752 "init_declarator_list : init_declarator",
753 "init_declarator_list : init_declarator_list ',' init_declarator",
754 "init_declarator : declarator",
756 "init_declarator : declarator '=' $$5 T_INITIALIZER",
757 "enum_specifier : enumeration any_id braces",
758 "enum_specifier : enumeration braces",
759 "enum_specifier : enumeration any_id",
760 "enumeration : T_ENUM",
761 "any_id : T_IDENTIFIER",
762 "any_id : T_TYPEDEF_NAME",
763 "declarator : pointer direct_declarator",
764 "declarator : direct_declarator",
765 "direct_declarator : identifier_or_ref",
766 "direct_declarator : '(' declarator ')'",
767 "direct_declarator : direct_declarator T_BRACKETS",
768 "direct_declarator : direct_declarator '(' parameter_type_list ')'",
769 "direct_declarator : direct_declarator '(' opt_identifier_list ')'",
770 "pointer : '*' opt_type_qualifiers",
771 "pointer : '*' opt_type_qualifiers pointer",
772 "opt_type_qualifiers :",
773 "opt_type_qualifiers : type_qualifier_list",
774 "type_qualifier_list : type_qualifier",
775 "type_qualifier_list : type_qualifier_list type_qualifier",
776 "parameter_type_list : parameter_list",
777 "parameter_type_list : parameter_list ',' T_ELLIPSIS",
778 "parameter_list : parameter_declaration",
779 "parameter_list : parameter_list ',' parameter_declaration",
780 "parameter_declaration : decl_specifiers declarator",
781 "parameter_declaration : decl_specifiers abs_declarator",
782 "parameter_declaration : decl_specifiers",
783 "opt_identifier_list :",
784 "opt_identifier_list : identifier_list",
785 "identifier_list : any_id",
786 "identifier_list : identifier_list ',' any_id",
787 "identifier_or_ref : any_id",
788 "identifier_or_ref : '&' any_id",
789 "abs_declarator : pointer",
790 "abs_declarator : pointer direct_abs_declarator",
791 "abs_declarator : direct_abs_declarator",
792 "direct_abs_declarator : '(' abs_declarator ')'",
793 "direct_abs_declarator : direct_abs_declarator T_BRACKETS",
794 "direct_abs_declarator : T_BRACKETS",
795 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
796 "direct_abs_declarator : direct_abs_declarator '(' ')'",
797 "direct_abs_declarator : '(' parameter_type_list ')'",
798 "direct_abs_declarator : '(' ')'",
811 /* define the initial stack-sizes */
814 #define YYMAXDEPTH YYSTACKSIZE
817 #define YYSTACKSIZE YYMAXDEPTH
819 #define YYSTACKSIZE 10000
820 #define YYMAXDEPTH 10000
824 #define YYINITSTACKSIZE 200
834 /* variables for the parser stack */
835 static YYSTACKDATA yystack;
836 #line 1014 "grammar.y"
839 #define BEGIN yy_start = 1 + 2 *
850 extern FILE *yyin, *yyout;
852 static int curly; /* number of curly brace nesting levels */
853 static int ly_count; /* number of occurrences of %% */
854 static int inc_depth; /* include nesting level */
855 static SymbolTable *included_files; /* files already included */
856 static int yy_start = 0; /* start state number */
858 #define grammar_error(s) yaccError(s)
861 yaccError (const char *msg)
864 put_error(); /* tell what line we're on, and what file */
865 fprintf(stderr, "%s at token '%s'\n", msg, yytext);
868 /* Initialize the table of type qualifier keywords recognized by the lexical
874 static const char *keywords[] = {
883 #if defined(MSDOS) || defined(OS2)
941 /* Initialize type qualifier table. */
942 type_qualifiers = new_symbol_table();
943 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
944 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
948 /* Process the C source file. Write function prototypes to the standard
949 * output. Convert function definitions and write the converted source
950 * code to a temporary file.
953 process_file (FILE *infile, char *name)
957 if (strlen(name) > 2) {
958 s = name + strlen(name) - 2;
961 if (*s == 'l' || *s == 'y')
963 #if defined(MSDOS) || defined(OS2)
964 if (*s == 'L' || *s == 'Y')
970 included_files = new_symbol_table();
971 typedef_names = new_symbol_table();
972 define_names = new_symbol_table();
978 include_file(strcpy(base_file, name), func_style != FUNC_NONE);
982 put_blankline(stdout);
986 put_string(stdout, "/* ");
987 put_string(stdout, cur_file_name());
988 put_string(stdout, " */\n");
991 free_symbol_table(define_names);
992 free_symbol_table(typedef_names);
993 free_symbol_table(included_files);
1000 free_symbol_table (type_qualifiers);
1002 if (yy_current_buffer != 0)
1003 yy_delete_buffer(yy_current_buffer);
1007 #line 1006 "/dev/stdout"
1010 #include <stdio.h> /* needed for printf */
1013 #include <stdlib.h> /* needed for malloc, etc */
1014 #include <string.h> /* needed for memset */
1016 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1017 static int yygrowstack(YYSTACKDATA *data)
1024 if ((newsize = data->stacksize) == 0)
1025 newsize = YYINITSTACKSIZE;
1026 else if (newsize >= YYMAXDEPTH)
1028 else if ((newsize *= 2) > YYMAXDEPTH)
1029 newsize = YYMAXDEPTH;
1031 i = (int) (data->s_mark - data->s_base);
1032 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
1036 data->s_base = newss;
1037 data->s_mark = newss + i;
1039 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1043 data->l_base = newvs;
1044 data->l_mark = newvs + i;
1046 data->stacksize = newsize;
1047 data->s_last = data->s_base + newsize - 1;
1051 #if YYPURE || defined(YY_NO_LEAKS)
1052 static void yyfreestack(YYSTACKDATA *data)
1056 memset(data, 0, sizeof(*data));
1059 #define yyfreestack(data) /* nothing */
1062 #define YYABORT goto yyabort
1063 #define YYREJECT goto yyabort
1064 #define YYACCEPT goto yyaccept
1065 #define YYERROR goto yyerrlab
1070 int yym, yyn, yystate;
1074 if ((yys = getenv("YYDEBUG")) != 0)
1077 if (yyn >= '0' && yyn <= '9')
1078 yydebug = yyn - '0';
1088 memset(&yystack, 0, sizeof(yystack));
1091 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
1092 yystack.s_mark = yystack.s_base;
1093 yystack.l_mark = yystack.l_base;
1095 *yystack.s_mark = 0;
1098 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1101 if ((yychar = YYLEX) < 0) yychar = 0;
1105 yys = yyname[YYTRANSLATE(yychar)];
1106 printf("%sdebug: state %d, reading %d (%s)\n",
1107 YYPREFIX, yystate, yychar, yys);
1111 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1112 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1116 printf("%sdebug: state %d, shifting to state %d\n",
1117 YYPREFIX, yystate, yytable[yyn]);
1119 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1123 yystate = yytable[yyn];
1124 *++yystack.s_mark = yytable[yyn];
1125 *++yystack.l_mark = yylval;
1127 if (yyerrflag > 0) --yyerrflag;
1130 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1131 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1136 if (yyerrflag) goto yyinrecovery;
1138 yyerror("syntax error");
1151 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
1152 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1156 printf("%sdebug: state %d, error recovery shifting\
1157 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
1159 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1163 yystate = yytable[yyn];
1164 *++yystack.s_mark = yytable[yyn];
1165 *++yystack.l_mark = yylval;
1172 printf("%sdebug: error recovery discarding state %d\n",
1173 YYPREFIX, *yystack.s_mark);
1175 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1183 if (yychar == 0) goto yyabort;
1187 yys = yyname[YYTRANSLATE(yychar)];
1188 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1189 YYPREFIX, yystate, yychar, yys);
1199 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1200 YYPREFIX, yystate, yyn, yyrule[yyn]);
1204 yyval = yystack.l_mark[1-yym];
1206 memset(&yyval, 0, sizeof yyval);
1210 #line 377 "grammar.y"
1216 #line 381 "grammar.y"
1222 #line 392 "grammar.y"
1224 /* Provide an empty action here so bison will not complain about
1225 * incompatible types in the default action it normally would
1231 #line 399 "grammar.y"
1237 #line 406 "grammar.y"
1240 if (types_out && want_typedef()) {
1241 gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0);
1245 free_decl_spec(&yystack.l_mark[-1].decl_spec);
1250 #line 417 "grammar.y"
1252 if (func_params != NULL) {
1253 set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1255 gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1259 free_decl_list(&yystack.l_mark[-1].decl_list);
1261 free_decl_spec(&yystack.l_mark[-2].decl_spec);
1266 #line 431 "grammar.y"
1268 cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
1269 free_decl_spec(&yystack.l_mark[0].decl_spec);
1273 #line 436 "grammar.y"
1279 #line 443 "grammar.y"
1285 #line 447 "grammar.y"
1291 #line 459 "grammar.y"
1293 int flags = cur_decl_spec_flags;
1295 /* If the typedef is a pointer type, then reset the short type
1296 * flags so it does not get promoted.
1298 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1299 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1300 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1301 free_declarator(yystack.l_mark[0].declarator);
1305 #line 471 "grammar.y"
1307 int flags = cur_decl_spec_flags;
1309 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1310 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1311 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1312 free_declarator(yystack.l_mark[0].declarator);
1316 #line 483 "grammar.y"
1318 check_untagged(&yystack.l_mark[-1].decl_spec);
1319 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1320 yyerror("syntax error");
1323 func_params = &(yystack.l_mark[0].declarator->head->params);
1324 func_params->begin_comment = cur_file->begin_comment;
1325 func_params->end_comment = cur_file->end_comment;
1329 #line 494 "grammar.y"
1331 /* If we're converting to K&R and we've got a nominally K&R
1332 * function which has a parameter which is ANSI (i.e., a prototyped
1333 * function pointer), then we must override the deciphered value of
1334 * 'func_def' so that the parameter will be converted.
1336 if (func_style == FUNC_TRADITIONAL
1338 && yystack.l_mark[-3].declarator->head->func_def == func_style) {
1339 yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH;
1344 if (cur_file->convert)
1345 gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1346 gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1350 free_decl_spec(&yystack.l_mark[-4].decl_spec);
1351 free_declarator(yystack.l_mark[-3].declarator);
1355 #line 519 "grammar.y"
1357 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1358 yyerror("syntax error");
1361 func_params = &(yystack.l_mark[0].declarator->head->params);
1362 func_params->begin_comment = cur_file->begin_comment;
1363 func_params->end_comment = cur_file->end_comment;
1367 #line 529 "grammar.y"
1373 new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE);
1374 if (cur_file->convert)
1375 gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator);
1376 gen_prototype(&decl_spec, yystack.l_mark[-4].declarator);
1380 free_decl_spec(&decl_spec);
1381 free_declarator(yystack.l_mark[-4].declarator);
1385 #line 560 "grammar.y"
1387 join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
1388 free(yystack.l_mark[-1].decl_spec.text);
1389 free(yystack.l_mark[0].decl_spec.text);
1393 #line 575 "grammar.y"
1395 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1399 #line 579 "grammar.y"
1401 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
1405 #line 583 "grammar.y"
1407 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1411 #line 587 "grammar.y"
1413 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
1417 #line 591 "grammar.y"
1419 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
1423 #line 595 "grammar.y"
1425 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
1429 #line 602 "grammar.y"
1431 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1435 #line 606 "grammar.y"
1437 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1441 #line 610 "grammar.y"
1443 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
1447 #line 614 "grammar.y"
1449 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1453 #line 618 "grammar.y"
1455 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1459 #line 622 "grammar.y"
1461 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
1465 #line 626 "grammar.y"
1467 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1471 #line 630 "grammar.y"
1473 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1477 #line 634 "grammar.y"
1479 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1483 #line 638 "grammar.y"
1485 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1489 #line 642 "grammar.y"
1491 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1495 #line 646 "grammar.y"
1497 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1501 #line 650 "grammar.y"
1504 s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
1506 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1510 #line 662 "grammar.y"
1512 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1516 #line 666 "grammar.y"
1518 /* This rule allows the <pointer> nonterminal to scan #define
1519 * names as if they were type modifiers.
1522 s = find_symbol(define_names, yystack.l_mark[0].text.text);
1524 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1528 #line 679 "grammar.y"
1531 if ((s = implied_typedef()) == 0)
1532 (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
1533 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1537 #line 686 "grammar.y"
1540 if ((s = implied_typedef()) == 0)
1541 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1542 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1546 #line 693 "grammar.y"
1548 (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1549 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1553 #line 701 "grammar.y"
1555 imply_typedef(yyval.text.text);
1559 #line 705 "grammar.y"
1561 imply_typedef(yyval.text.text);
1565 #line 712 "grammar.y"
1567 new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
1571 #line 716 "grammar.y"
1573 add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
1577 #line 723 "grammar.y"
1579 if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
1580 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1581 gen_func_declarator(yystack.l_mark[0].declarator);
1582 fputs(cur_text(), cur_file->tmp_file);
1584 cur_declarator = yyval.declarator;
1588 #line 732 "grammar.y"
1590 if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
1591 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1592 gen_func_declarator(yystack.l_mark[-1].declarator);
1593 fputs(" =", cur_file->tmp_file);
1598 #line 744 "grammar.y"
1601 if ((s = implied_typedef()) == 0)
1602 (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
1603 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1607 #line 751 "grammar.y"
1610 if ((s = implied_typedef()) == 0)
1611 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1612 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1616 #line 758 "grammar.y"
1618 (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
1619 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1623 #line 766 "grammar.y"
1625 imply_typedef("enum");
1626 yyval.text = yystack.l_mark[0].text;
1630 #line 779 "grammar.y"
1632 yyval.declarator = yystack.l_mark[0].declarator;
1633 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1634 free(yyval.declarator->text);
1635 yyval.declarator->text = xstrdup(buf);
1636 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1637 yyval.declarator->pointer = TRUE;
1641 #line 792 "grammar.y"
1643 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
1647 #line 796 "grammar.y"
1649 yyval.declarator = yystack.l_mark[-1].declarator;
1650 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1651 free(yyval.declarator->text);
1652 yyval.declarator->text = xstrdup(buf);
1653 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1657 #line 804 "grammar.y"
1659 yyval.declarator = yystack.l_mark[-1].declarator;
1660 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1661 free(yyval.declarator->text);
1662 yyval.declarator->text = xstrdup(buf);
1666 #line 811 "grammar.y"
1668 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1669 yyval.declarator->params = yystack.l_mark[-1].param_list;
1670 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1671 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1672 yyval.declarator->func_def = FUNC_ANSI;
1676 #line 819 "grammar.y"
1678 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1679 yyval.declarator->params = yystack.l_mark[-1].param_list;
1680 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1681 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1682 yyval.declarator->func_def = FUNC_TRADITIONAL;
1686 #line 830 "grammar.y"
1688 (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
1689 yyval.text.begin = yystack.l_mark[-1].text.begin;
1693 #line 835 "grammar.y"
1695 (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1696 yyval.text.begin = yystack.l_mark[-2].text.begin;
1700 #line 843 "grammar.y"
1702 strcpy(yyval.text.text, "");
1703 yyval.text.begin = 0L;
1707 #line 852 "grammar.y"
1709 (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
1710 yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
1711 free(yystack.l_mark[0].decl_spec.text);
1715 #line 858 "grammar.y"
1717 (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
1718 yyval.text.begin = yystack.l_mark[-1].text.begin;
1719 free(yystack.l_mark[0].decl_spec.text);
1723 #line 868 "grammar.y"
1725 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
1729 #line 875 "grammar.y"
1731 new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
1735 #line 879 "grammar.y"
1737 add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
1741 #line 886 "grammar.y"
1743 check_untagged(&yystack.l_mark[-1].decl_spec);
1744 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1748 #line 891 "grammar.y"
1750 check_untagged(&yystack.l_mark[-1].decl_spec);
1751 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1755 #line 896 "grammar.y"
1757 check_untagged(&yystack.l_mark[0].decl_spec);
1758 yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
1762 #line 904 "grammar.y"
1764 new_ident_list(&yyval.param_list);
1768 #line 912 "grammar.y"
1770 new_ident_list(&yyval.param_list);
1771 add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
1775 #line 917 "grammar.y"
1777 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
1781 #line 924 "grammar.y"
1783 yyval.text = yystack.l_mark[0].text;
1787 #line 928 "grammar.y"
1790 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
1791 yyval.text = yystack.l_mark[0].text;
1794 (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
1795 yyval.text.begin = yystack.l_mark[-1].text.begin;
1799 #line 941 "grammar.y"
1801 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1805 #line 945 "grammar.y"
1807 yyval.declarator = yystack.l_mark[0].declarator;
1808 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1809 free(yyval.declarator->text);
1810 yyval.declarator->text = xstrdup(buf);
1811 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1815 #line 957 "grammar.y"
1817 yyval.declarator = yystack.l_mark[-1].declarator;
1818 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1819 free(yyval.declarator->text);
1820 yyval.declarator->text = xstrdup(buf);
1821 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1825 #line 965 "grammar.y"
1827 yyval.declarator = yystack.l_mark[-1].declarator;
1828 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1829 free(yyval.declarator->text);
1830 yyval.declarator->text = xstrdup(buf);
1834 #line 972 "grammar.y"
1836 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1840 #line 976 "grammar.y"
1842 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
1843 yyval.declarator->params = yystack.l_mark[-1].param_list;
1844 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1845 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1846 yyval.declarator->func_def = FUNC_ANSI;
1850 #line 984 "grammar.y"
1852 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
1853 yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
1854 yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head;
1855 yyval.declarator->func_def = FUNC_ANSI;
1859 #line 991 "grammar.y"
1863 d = new_declarator("", "", yystack.l_mark[-2].text.begin);
1864 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin);
1865 yyval.declarator->params = yystack.l_mark[-1].param_list;
1866 yyval.declarator->func_stack = d;
1867 yyval.declarator->head = yyval.declarator;
1868 yyval.declarator->func_def = FUNC_ANSI;
1872 #line 1002 "grammar.y"
1876 d = new_declarator("", "", yystack.l_mark[-1].text.begin);
1877 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin);
1878 yyval.declarator->func_stack = d;
1879 yyval.declarator->head = yyval.declarator;
1880 yyval.declarator->func_def = FUNC_ANSI;
1883 #line 1882 "/dev/stdout"
1885 yystack.s_mark -= yym;
1886 yystate = *yystack.s_mark;
1887 yystack.l_mark -= yym;
1889 if (yystate == 0 && yym == 0)
1893 printf("%sdebug: after reduction, shifting from state 0 to\
1894 state %d\n", YYPREFIX, YYFINAL);
1897 *++yystack.s_mark = YYFINAL;
1898 *++yystack.l_mark = yyval;
1901 if ((yychar = YYLEX) < 0) yychar = 0;
1905 yys = yyname[YYTRANSLATE(yychar)];
1906 printf("%sdebug: state %d, reading %d (%s)\n",
1907 YYPREFIX, YYFINAL, yychar, yys);
1911 if (yychar == 0) goto yyaccept;
1914 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1915 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1916 yystate = yytable[yyn];
1918 yystate = yydgoto[yym];
1921 printf("%sdebug: after reduction, shifting from state %d \
1922 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
1924 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1928 *++yystack.s_mark = (short) yystate;
1929 *++yystack.l_mark = yyval;
1933 yyerror("yacc stack overflow");
1936 yyfreestack(&yystack);
1940 yyfreestack(&yystack);