2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
10 #define yyclearin (yychar = YYEMPTY)
11 #define yyerrok (yyerrflag = 0)
12 #define YYRECOVERING() (yyerrflag != 0)
21 #define YYSTYPE_IS_DECLARED
22 #define yyerror yaccError
25 #if defined(YYBISON) || !defined(YYBYACC)
26 static void yyerror(const char *s);
33 #define OPT_LINTLIBRARY 1
43 /* #include "cproto.h" */
44 #define MAX_TEXT_SIZE 1024
46 /* Prototype styles */
48 #define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
49 #define PROTO_LINTLIBRARY -1 /* form lint-library source */
51 #define PROTO_NONE 0 /* do not output any prototypes */
52 #define PROTO_TRADITIONAL 1 /* comment out parameters */
53 #define PROTO_ABSTRACT 2 /* comment out parameter names */
54 #define PROTO_ANSI 3 /* ANSI C prototype */
56 typedef int PrototypeStyle;
60 extern boolean types_out;
61 extern PrototypeStyle proto_style;
63 #define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
64 #define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
65 #define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
68 #define FUNC_UNKNOWN -1 /* unspecified */
70 #define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
72 #define FUNC_NONE 0 /* not a function definition */
73 #define FUNC_TRADITIONAL 1 /* traditional style */
74 #define FUNC_ANSI 2 /* ANSI style */
75 #define FUNC_BOTH 3 /* both styles */
77 typedef int FuncDefStyle;
79 /* Source file text */
81 char text[MAX_TEXT_SIZE]; /* source text */
82 long begin; /* offset in temporary file */
85 /* Declaration specifier flags */
86 #define DS_NONE 0 /* default */
87 #define DS_EXTERN 1 /* contains "extern" specifier */
88 #define DS_STATIC 2 /* contains "static" specifier */
89 #define DS_CHAR 4 /* contains "char" type specifier */
90 #define DS_SHORT 8 /* contains "short" type specifier */
91 #define DS_FLOAT 16 /* contains "float" type specifier */
92 #define DS_INLINE 32 /* contains "inline" specifier */
93 #define DS_JUNK 64 /* we're not interested in this declaration */
95 /* This structure stores information about a declaration specifier. */
96 typedef struct decl_spec {
97 unsigned short flags; /* flags defined above */
98 char *text; /* source text */
99 long begin; /* offset in temporary file */
102 /* This is a list of function parameters. */
103 typedef struct _ParameterList {
104 struct parameter *first; /* pointer to first parameter in list */
105 struct parameter *last; /* pointer to last parameter in list */
106 long begin_comment; /* begin offset of comment */
107 long end_comment; /* end offset of comment */
108 char *comment; /* comment at start of parameter list */
111 /* This structure stores information about a declarator. */
112 typedef struct _Declarator {
113 char *name; /* name of variable or function */
114 char *text; /* source text */
115 long begin; /* offset in temporary file */
116 long begin_comment; /* begin offset of comment */
117 long end_comment; /* end offset of comment */
118 FuncDefStyle func_def; /* style of function definition */
119 ParameterList params; /* function parameters */
120 boolean pointer; /* TRUE if it declares a pointer */
121 struct _Declarator *head; /* head function declarator */
122 struct _Declarator *func_stack; /* stack of function declarators */
123 struct _Declarator *next; /* next declarator in list */
126 /* This structure stores information about a function parameter. */
127 typedef struct parameter {
128 struct parameter *next; /* next parameter in list */
130 Declarator *declarator;
131 char *comment; /* comment following the parameter */
134 /* This is a list of declarators. */
135 typedef struct declarator_list {
136 Declarator *first; /* pointer to first declarator in list */
137 Declarator *last; /* pointer to last declarator in list */
140 /* #include "symbol.h" */
141 typedef struct symbol {
142 struct symbol *next; /* next symbol in list */
143 char *name; /* name of symbol */
144 char *value; /* value of symbol (for defines) */
145 short flags; /* symbol attributes */
148 /* parser stack entry type */
152 Parameter *parameter;
153 ParameterList param_list;
154 Declarator *declarator;
155 DeclaratorList decl_list;
158 /* The hash table length should be a prime number. */
159 #define SYM_MAX_HASH 251
161 typedef struct symbol_table {
162 Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */
165 extern SymbolTable *new_symbol_table /* Create symbol table */
167 extern void free_symbol_table /* Destroy symbol table */
169 extern Symbol *find_symbol /* Lookup symbol name */
170 (SymbolTable *s, const char *n);
171 extern Symbol *new_symbol /* Define new symbol */
172 (SymbolTable *s, const char *n, const char *v, int f);
174 /* #include "semantic.h" */
175 extern void new_decl_spec (DeclSpec *, const char *, long, int);
176 extern void free_decl_spec (DeclSpec *);
177 extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *);
178 extern void check_untagged (DeclSpec *);
179 extern Declarator *new_declarator (const char *, const char *, long);
180 extern void free_declarator (Declarator *);
181 extern void new_decl_list (DeclaratorList *, Declarator *);
182 extern void free_decl_list (DeclaratorList *);
183 extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *);
184 extern Parameter *new_parameter (DeclSpec *, Declarator *);
185 extern void free_parameter (Parameter *);
186 extern void new_param_list (ParameterList *, Parameter *);
187 extern void free_param_list (ParameterList *);
188 extern void add_param_list (ParameterList *, ParameterList *, Parameter *);
189 extern void new_ident_list (ParameterList *);
190 extern void add_ident_list (ParameterList *, ParameterList *, const char *);
191 extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *);
192 extern void gen_declarations (DeclSpec *, DeclaratorList *);
193 extern void gen_prototype (DeclSpec *, Declarator *);
194 extern void gen_func_declarator (Declarator *);
195 extern void gen_func_definition (DeclSpec *, Declarator *);
197 extern void init_parser (void);
198 extern void process_file (FILE *infile, char *name);
199 extern char *cur_text (void);
200 extern char *cur_file_name (void);
201 extern char *implied_typedef (void);
202 extern void include_file (char *name, int convert);
203 extern char *supply_parm (int count);
204 extern char *xstrdup (const char *);
205 extern int already_declared (char *name);
206 extern int is_actual_func (Declarator *d);
207 extern int lint_ellipsis (Parameter *p);
208 extern int want_typedef (void);
209 extern void begin_tracking (void);
210 extern void begin_typedef (void);
211 extern void copy_typedef (char *s);
212 extern void ellipsis_varargs (Declarator *d);
213 extern void end_typedef (void);
214 extern void flush_varargs (void);
215 extern void fmt_library (int code);
216 extern void imply_typedef (const char *s);
217 extern void indent (FILE *outf);
218 extern void put_blankline (FILE *outf);
219 extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator);
220 extern void put_char (FILE *outf, int c);
221 extern void put_error (void);
222 extern void put_newline (FILE *outf);
223 extern void put_padded (FILE *outf, const char *s);
224 extern void put_string (FILE *outf, const char *s);
225 extern void track_in (void);
227 extern boolean file_comments;
228 extern FuncDefStyle func_style;
229 extern char base_file[];
231 extern int yylex (void);
233 /* declaration specifier attributes for the typedef statement currently being
236 static int cur_decl_spec_flags;
238 /* pointer to parameter list for the current function definition */
239 static ParameterList *func_params;
241 /* A parser semantic action sets this pointer to the current declarator in
242 * a function parameter declaration in order to catch any comments following
243 * the parameter declaration on the same line. If the lexer scans a comment
244 * and <cur_declarator> is not NULL, then the comment is attached to the
245 * declarator. To ignore subsequent comments, the lexer sets this to NULL
246 * after scanning a comment or end of line.
248 static Declarator *cur_declarator;
250 /* temporary string buffer */
251 static char buf[MAX_TEXT_SIZE];
253 /* table of typedef names */
254 static SymbolTable *typedef_names;
256 /* table of define names */
257 static SymbolTable *define_names;
259 /* table of type qualifiers */
260 static SymbolTable *type_qualifiers;
262 /* information about the current input file */
264 char *base_name; /* base input file name */
265 char *file_name; /* current file name */
266 FILE *file; /* input file */
267 unsigned line_num; /* current line number in input file */
268 FILE *tmp_file; /* temporary file */
269 long begin_comment; /* tmp file offset after last written ) or ; */
270 long end_comment; /* tmp file offset after last comment */
271 boolean convert; /* if TRUE, convert function definitions */
272 boolean changed; /* TRUE if conversion done in this file */
275 static IncludeStack *cur_file; /* current input file */
277 /* #include "yyerror.c" */
279 static int haveAnsiParam (void);
282 /* Flags to enable us to find if a procedure returns a value.
284 static int return_val; /* nonzero on BRACES iff return-expression found */
289 return (lintLibrary() && !return_val) ? "void" : "int";
296 if (func_params != 0) {
297 for (p = func_params->first; p != 0; p = p->next) {
298 if (p->declarator->func_def == FUNC_ANSI) {
305 #line 305 "/dev/stdout"
307 /* compatibility with bison */
309 /* compatibility with FreeBSD */
310 # ifdef YYPARSE_PARAM_TYPE
311 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
313 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
316 # define YYPARSE_DECL() yyparse(void)
319 /* Parameters sent to lex. */
321 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
322 # define YYLEX yylex(YYLEX_PARAM)
324 # define YYLEX_DECL() yylex(void)
325 # define YYLEX yylex()
328 /* Parameters sent to yyerror. */
330 #define YYERROR_DECL() yyerror(const char *s)
333 #define YYERROR_CALL(msg) yyerror(msg)
336 extern int YYPARSE_DECL();
338 #define T_IDENTIFIER 257
339 #define T_TYPEDEF_NAME 258
340 #define T_DEFINE_NAME 259
343 #define T_REGISTER 262
345 #define T_TYPEDEF 264
347 #define T_EXTENSION 266
356 #define T_UNSIGNED 275
361 #define T_Complex 280
362 #define T_Imaginary 281
363 #define T_TYPE_QUALIFIER 282
364 #define T_BRACKETS 283
366 #define T_MATCHRBRACE 285
367 #define T_ELLIPSIS 286
368 #define T_INITIALIZER 287
369 #define T_STRING_LITERAL 288
373 #define YYERRCODE 256
374 static const short yylhs[] = { -1,
375 0, 0, 26, 26, 27, 27, 27, 27, 27, 27,
376 27, 31, 30, 30, 28, 28, 34, 28, 32, 32,
377 33, 33, 35, 35, 37, 38, 29, 39, 29, 36,
378 36, 36, 40, 40, 1, 1, 2, 2, 2, 3,
379 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
380 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
381 5, 5, 6, 6, 6, 19, 19, 8, 8, 9,
382 41, 9, 7, 7, 7, 25, 23, 23, 10, 10,
383 11, 11, 11, 11, 11, 20, 20, 21, 21, 22,
384 22, 14, 14, 15, 15, 16, 16, 16, 17, 17,
385 18, 18, 24, 24, 12, 12, 12, 13, 13, 13,
388 static const short yylen[] = { 2,
389 0, 1, 1, 2, 1, 1, 1, 1, 3, 2,
390 2, 2, 3, 3, 2, 3, 0, 5, 2, 1,
391 0, 1, 1, 3, 0, 0, 7, 0, 5, 0,
392 1, 1, 1, 2, 1, 2, 1, 1, 1, 1,
393 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395 1, 1, 3, 2, 2, 1, 1, 1, 3, 1,
396 0, 4, 3, 2, 2, 1, 1, 1, 2, 1,
397 1, 3, 2, 4, 4, 2, 3, 0, 1, 1,
398 2, 1, 3, 1, 3, 2, 2, 1, 0, 1,
399 1, 3, 1, 2, 1, 2, 1, 3, 2, 1,
402 static const short yydefred[] = { 0,
403 0, 0, 0, 0, 77, 0, 62, 40, 0, 42,
404 43, 20, 44, 0, 46, 47, 48, 49, 54, 50,
405 51, 52, 53, 76, 66, 67, 55, 56, 57, 61,
406 0, 7, 0, 0, 35, 37, 38, 39, 59, 60,
407 28, 0, 0, 0, 103, 81, 0, 0, 3, 5,
408 6, 8, 0, 10, 11, 78, 0, 90, 0, 0,
409 104, 0, 19, 0, 41, 45, 15, 36, 0, 68,
410 0, 0, 0, 83, 0, 0, 64, 0, 0, 74,
411 4, 58, 0, 82, 87, 91, 0, 14, 13, 9,
412 16, 0, 71, 0, 31, 33, 0, 0, 0, 0,
413 0, 94, 0, 0, 101, 12, 63, 73, 0, 0,
414 69, 0, 0, 0, 34, 0, 110, 96, 97, 0,
415 0, 84, 0, 85, 0, 23, 0, 0, 72, 26,
416 29, 114, 0, 0, 0, 109, 0, 93, 95, 102,
417 18, 0, 0, 108, 113, 112, 0, 24, 27, 111,
419 static const short yydgoto[] = { 33,
420 87, 35, 36, 37, 38, 39, 40, 69, 70, 41,
421 42, 119, 120, 100, 101, 102, 103, 104, 43, 44,
422 59, 60, 45, 46, 47, 48, 49, 50, 51, 52,
423 77, 53, 127, 109, 128, 97, 94, 143, 72, 98,
426 static const short yysindex[] = { -2,
427 -3, 27, -239, -177, 0, 0, 0, 0, -274, 0,
428 0, 0, 0, -246, 0, 0, 0, 0, 0, 0,
429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
430 -266, 0, 0, 455, 0, 0, 0, 0, 0, 0,
431 0, -35, -245, 128, 0, 0, -245, -2, 0, 0,
432 0, 0, 642, 0, 0, 0, -15, 0, -12, -239,
433 0, 590, 0, -27, 0, 0, 0, 0, -10, 0,
434 -11, 534, -72, 0, -237, -232, 0, -35, -232, 0,
435 0, 0, 642, 0, 0, 0, 455, 0, 0, 0,
436 0, 27, 0, 534, 0, 0, -222, 617, 209, 34,
437 39, 0, 44, 42, 0, 0, 0, 0, 27, -11,
438 0, -200, -196, -195, 0, 174, 0, 0, 0, -33,
439 243, 0, 561, 0, -177, 0, 33, 49, 0, 0,
440 0, 0, 53, 55, 417, 0, -33, 0, 0, 0,
441 0, 27, -188, 0, 0, 0, 57, 0, 0, 0,
443 static const short yyrindex[] = { 99,
444 0, 0, 275, 0, 0, -38, 0, 0, 481, 0,
445 0, 0, 0, 509, 0, 0, 0, 0, 0, 0,
446 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
448 0, 30, 0, 0, 0, 0, 0, 101, 0, 0,
449 0, 0, 0, 0, 0, 0, 0, 0, 343, 309,
450 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
451 98, -182, 62, 0, 0, 133, 0, 64, 379, 0,
452 0, 0, -5, 0, 0, 0, 0, 0, 0, 0,
453 0, 0, 0, -182, 0, 0, 0, -180, -19, 0,
454 65, 0, 0, 68, 0, 0, 0, 0, 51, 9,
455 0, 0, 0, 0, 0, 0, 0, 0, 0, -13,
456 19, 0, 0, 0, 0, 0, 0, 52, 0, 0,
457 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
458 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
460 static const short yygindex[] = { 0,
461 11, -17, 0, 0, 13, 0, 0, 0, 20, 8,
462 -43, -1, -8, -89, 0, -9, 0, 0, 0, -44,
463 0, 0, 4, 0, 0, 0, 70, -53, 0, 0,
464 -18, 0, 0, 0, 0, 22, 0, 0, 0, 0,
467 #define YYTABLESIZE 924
468 static const short yytable[] = { 58,
469 78, 58, 58, 58, 73, 58, 135, 61, 88, 57,
470 34, 5, 56, 62, 85, 58, 68, 63, 96, 7,
471 58, 98, 78, 64, 98, 84, 134, 107, 80, 3,
472 107, 90, 17, 92, 17, 4, 17, 2, 75, 3,
473 96, 71, 30, 89, 115, 147, 76, 106, 91, 93,
474 79, 75, 70, 17, 121, 55, 32, 107, 34, 105,
475 108, 114, 105, 83, 4, 68, 2, 70, 3, 68,
476 80, 121, 86, 80, 122, 106, 105, 78, 106, 5,
477 56, 68, 123, 99, 124, 125, 129, 130, 80, 131,
478 80, 141, 142, 144, 110, 145, 149, 150, 1, 110,
479 2, 30, 99, 32, 79, 92, 118, 79, 100, 21,
480 22, 111, 137, 139, 133, 113, 126, 81, 0, 0,
481 0, 0, 79, 57, 79, 0, 99, 0, 140, 0,
482 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
483 0, 70, 0, 0, 0, 99, 0, 0, 0, 148,
484 0, 0, 0, 0, 0, 0, 70, 0, 0, 0,
485 0, 0, 0, 0, 0, 4, 0, 2, 0, 0,
486 65, 0, 65, 65, 65, 0, 65, 0, 0, 0,
487 0, 0, 0, 0, 5, 6, 7, 8, 65, 10,
488 11, 65, 13, 66, 15, 16, 17, 18, 19, 20,
489 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
490 0, 4, 0, 116, 132, 3, 0, 0, 58, 58,
491 58, 58, 58, 58, 58, 78, 58, 58, 58, 58,
492 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
493 58, 58, 58, 58, 58, 78, 4, 74, 116, 136,
494 3, 17, 78, 1, 5, 6, 7, 8, 9, 10,
495 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
496 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
497 4, 54, 116, 5, 56, 0, 31, 80, 80, 80,
498 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
499 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
500 80, 80, 88, 80, 88, 88, 88, 0, 88, 0,
501 80, 79, 79, 79, 79, 79, 79, 79, 79, 79,
502 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
503 79, 79, 79, 79, 79, 79, 89, 79, 89, 89,
504 89, 0, 89, 0, 79, 25, 25, 25, 25, 25,
505 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
506 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
507 86, 25, 86, 86, 5, 56, 86, 0, 25, 65,
508 65, 65, 65, 65, 65, 65, 0, 65, 65, 65,
509 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
510 65, 65, 65, 65, 65, 65, 75, 0, 75, 75,
511 75, 0, 75, 0, 0, 0, 0, 0, 0, 0,
512 5, 6, 7, 8, 65, 10, 11, 75, 13, 66,
513 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
514 25, 26, 27, 28, 29, 30, 117, 146, 0, 0,
515 0, 0, 0, 0, 0, 5, 6, 7, 8, 65,
516 10, 11, 0, 13, 66, 15, 16, 17, 18, 19,
517 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
518 30, 117, 4, 0, 2, 0, 3, 0, 0, 5,
519 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
520 0, 0, 0, 67, 0, 0, 0, 0, 41, 0,
521 41, 0, 41, 0, 0, 117, 0, 0, 0, 0,
522 0, 88, 88, 0, 0, 0, 0, 0, 0, 41,
523 0, 0, 0, 0, 0, 0, 45, 0, 45, 0,
524 45, 0, 0, 0, 0, 0, 0, 88, 0, 0,
525 0, 0, 0, 0, 0, 89, 89, 45, 0, 0,
526 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
528 0, 89, 0, 0, 0, 0, 0, 0, 0, 86,
529 86, 0, 0, 0, 0, 0, 0, 0, 0, 0,
530 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
531 0, 0, 0, 0, 0, 86, 0, 0, 0, 0,
532 0, 0, 0, 0, 0, 75, 75, 75, 75, 75,
533 75, 75, 0, 75, 75, 75, 75, 75, 75, 75,
534 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
535 75, 75, 0, 0, 0, 0, 0, 0, 0, 0,
536 0, 0, 0, 0, 82, 7, 8, 65, 10, 11,
537 0, 13, 66, 15, 16, 17, 18, 19, 20, 21,
538 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
539 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
540 0, 5, 6, 7, 8, 65, 10, 11, 0, 13,
541 66, 15, 16, 17, 18, 19, 20, 21, 22, 23,
542 24, 25, 26, 27, 28, 29, 30, 41, 41, 41,
543 41, 41, 41, 41, 0, 41, 41, 41, 41, 41,
544 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
545 41, 41, 41, 0, 0, 45, 45, 45, 45, 45,
546 45, 45, 0, 45, 45, 45, 45, 45, 45, 45,
547 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
548 45, 82, 7, 8, 65, 10, 11, 12, 13, 14,
549 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
550 25, 26, 27, 28, 29, 30, 0, 0, 82, 7,
551 8, 65, 10, 11, 95, 13, 66, 15, 16, 17,
552 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
553 28, 29, 30, 0, 0, 0, 138, 82, 7, 8,
554 65, 10, 11, 12, 13, 14, 15, 16, 17, 18,
555 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
556 29, 30, 0, 75, 82, 7, 8, 65, 10, 11,
557 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
558 22, 23, 24, 25, 26, 27, 28, 29, 30, 82,
559 7, 8, 65, 10, 11, 0, 13, 66, 15, 16,
560 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
563 static const short yycheck[] = { 38,
564 44, 40, 41, 42, 40, 44, 40, 4, 62, 2,
565 0, 257, 258, 288, 59, 3, 34, 264, 72, 259,
566 59, 41, 61, 290, 44, 41, 116, 41, 47, 42,
567 44, 59, 38, 44, 40, 38, 42, 40, 284, 42,
568 94, 34, 282, 62, 98, 135, 43, 285, 59, 61,
569 47, 284, 44, 59, 99, 59, 59, 76, 48, 41,
570 79, 284, 44, 53, 38, 83, 40, 59, 42, 87,
571 41, 116, 60, 44, 41, 41, 73, 121, 44, 257,
572 258, 99, 44, 73, 41, 44, 287, 284, 59, 285,
573 61, 59, 44, 41, 87, 41, 285, 41, 0, 92,
574 0, 284, 41, 284, 41, 41, 99, 44, 41, 59,
575 59, 92, 121, 123, 116, 94, 109, 48, -1, -1,
576 -1, -1, 59, 116, 61, -1, 116, -1, 125, -1,
577 -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
578 -1, 44, -1, -1, -1, 135, -1, -1, -1, 142,
579 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
580 -1, -1, -1, -1, -1, 38, -1, 40, -1, -1,
581 38, -1, 40, 41, 42, -1, 44, -1, -1, -1,
582 -1, -1, -1, -1, 257, 258, 259, 260, 261, 262,
583 263, 59, 265, 266, 267, 268, 269, 270, 271, 272,
584 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
585 -1, 38, -1, 40, 41, 42, -1, -1, 257, 258,
586 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
587 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
588 279, 280, 281, 282, 283, 284, 38, 283, 40, 283,
589 42, 257, 291, 256, 257, 258, 259, 260, 261, 262,
590 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
591 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
592 38, 285, 40, 257, 258, -1, 289, 258, 259, 260,
593 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
594 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
595 281, 282, 38, 284, 40, 41, 42, -1, 44, -1,
596 291, 258, 259, 260, 261, 262, 263, 264, 265, 266,
597 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
598 277, 278, 279, 280, 281, 282, 38, 284, 40, 41,
599 42, -1, 44, -1, 291, 258, 259, 260, 261, 262,
600 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
601 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
602 38, 284, 40, 41, 257, 258, 44, -1, 291, 257,
603 258, 259, 260, 261, 262, 263, -1, 265, 266, 267,
604 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
605 278, 279, 280, 281, 282, 283, 38, -1, 40, 41,
606 42, -1, 44, -1, -1, -1, -1, -1, -1, -1,
607 257, 258, 259, 260, 261, 262, 263, 59, 265, 266,
608 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
609 277, 278, 279, 280, 281, 282, 283, 41, -1, -1,
610 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
611 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
612 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
613 282, 283, 38, -1, 40, -1, 42, -1, -1, 257,
614 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
615 -1, -1, -1, 59, -1, -1, -1, -1, 38, -1,
616 40, -1, 42, -1, -1, 283, -1, -1, -1, -1,
617 -1, 257, 258, -1, -1, -1, -1, -1, -1, 59,
618 -1, -1, -1, -1, -1, -1, 38, -1, 40, -1,
619 42, -1, -1, -1, -1, -1, -1, 283, -1, -1,
620 -1, -1, -1, -1, -1, 257, 258, 59, -1, -1,
621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
623 -1, 283, -1, -1, -1, -1, -1, -1, -1, 257,
624 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
625 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
626 -1, -1, -1, -1, -1, 283, -1, -1, -1, -1,
627 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
628 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
629 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
630 282, 283, -1, -1, -1, -1, -1, -1, -1, -1,
631 -1, -1, -1, -1, 258, 259, 260, 261, 262, 263,
632 -1, 265, 266, 267, 268, 269, 270, 271, 272, 273,
633 274, 275, 276, 277, 278, 279, 280, 281, 282, -1,
634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
635 -1, 257, 258, 259, 260, 261, 262, 263, -1, 265,
636 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
637 276, 277, 278, 279, 280, 281, 282, 257, 258, 259,
638 260, 261, 262, 263, -1, 265, 266, 267, 268, 269,
639 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
640 280, 281, 282, -1, -1, 257, 258, 259, 260, 261,
641 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
642 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
643 282, 258, 259, 260, 261, 262, 263, 264, 265, 266,
644 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
645 277, 278, 279, 280, 281, 282, -1, -1, 258, 259,
646 260, 261, 262, 263, 291, 265, 266, 267, 268, 269,
647 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
648 280, 281, 282, -1, -1, -1, 286, 258, 259, 260,
649 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
650 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
651 281, 282, -1, 284, 258, 259, 260, 261, 262, 263,
652 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
653 274, 275, 276, 277, 278, 279, 280, 281, 282, 258,
654 259, 260, 261, 262, 263, -1, 265, 266, 267, 268,
655 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
662 #define YYMAXTOKEN 291
664 static const char *yyname[] = {
666 "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,
667 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
668 "'='",0,0,0,0,0,0,0,0,0,0,0,0,0,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,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,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,
673 "T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
674 "T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR",
675 "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED",
676 "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary",
677 "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS",
678 "T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
680 static const char *yyrule[] = {
683 "program : translation_unit",
684 "translation_unit : external_declaration",
685 "translation_unit : translation_unit external_declaration",
686 "external_declaration : declaration",
687 "external_declaration : function_definition",
688 "external_declaration : ';'",
689 "external_declaration : linkage_specification",
690 "external_declaration : T_ASM T_ASMARG ';'",
691 "external_declaration : error T_MATCHRBRACE",
692 "external_declaration : error ';'",
693 "braces : T_LBRACE T_MATCHRBRACE",
694 "linkage_specification : T_EXTERN T_STRING_LITERAL braces",
695 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
696 "declaration : decl_specifiers ';'",
697 "declaration : decl_specifiers init_declarator_list ';'",
699 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
700 "any_typedef : T_EXTENSION T_TYPEDEF",
701 "any_typedef : T_TYPEDEF",
702 "opt_declarator_list :",
703 "opt_declarator_list : declarator_list",
704 "declarator_list : declarator",
705 "declarator_list : declarator_list ',' declarator",
708 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
710 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
711 "opt_declaration_list :",
712 "opt_declaration_list : T_VA_DCL",
713 "opt_declaration_list : declaration_list",
714 "declaration_list : declaration",
715 "declaration_list : declaration_list declaration",
716 "decl_specifiers : decl_specifier",
717 "decl_specifiers : decl_specifiers decl_specifier",
718 "decl_specifier : storage_class",
719 "decl_specifier : type_specifier",
720 "decl_specifier : type_qualifier",
721 "storage_class : T_AUTO",
722 "storage_class : T_EXTERN",
723 "storage_class : T_REGISTER",
724 "storage_class : T_STATIC",
725 "storage_class : T_INLINE",
726 "storage_class : T_EXTENSION",
727 "type_specifier : T_CHAR",
728 "type_specifier : T_DOUBLE",
729 "type_specifier : T_FLOAT",
730 "type_specifier : T_INT",
731 "type_specifier : T_LONG",
732 "type_specifier : T_SHORT",
733 "type_specifier : T_SIGNED",
734 "type_specifier : T_UNSIGNED",
735 "type_specifier : T_VOID",
736 "type_specifier : T_Bool",
737 "type_specifier : T_Complex",
738 "type_specifier : T_Imaginary",
739 "type_specifier : T_TYPEDEF_NAME",
740 "type_specifier : struct_or_union_specifier",
741 "type_specifier : enum_specifier",
742 "type_qualifier : T_TYPE_QUALIFIER",
743 "type_qualifier : T_DEFINE_NAME",
744 "struct_or_union_specifier : struct_or_union any_id braces",
745 "struct_or_union_specifier : struct_or_union braces",
746 "struct_or_union_specifier : struct_or_union any_id",
747 "struct_or_union : T_STRUCT",
748 "struct_or_union : T_UNION",
749 "init_declarator_list : init_declarator",
750 "init_declarator_list : init_declarator_list ',' init_declarator",
751 "init_declarator : declarator",
753 "init_declarator : declarator '=' $$5 T_INITIALIZER",
754 "enum_specifier : enumeration any_id braces",
755 "enum_specifier : enumeration braces",
756 "enum_specifier : enumeration any_id",
757 "enumeration : T_ENUM",
758 "any_id : T_IDENTIFIER",
759 "any_id : T_TYPEDEF_NAME",
760 "declarator : pointer direct_declarator",
761 "declarator : direct_declarator",
762 "direct_declarator : identifier_or_ref",
763 "direct_declarator : '(' declarator ')'",
764 "direct_declarator : direct_declarator T_BRACKETS",
765 "direct_declarator : direct_declarator '(' parameter_type_list ')'",
766 "direct_declarator : direct_declarator '(' opt_identifier_list ')'",
767 "pointer : '*' opt_type_qualifiers",
768 "pointer : '*' opt_type_qualifiers pointer",
769 "opt_type_qualifiers :",
770 "opt_type_qualifiers : type_qualifier_list",
771 "type_qualifier_list : type_qualifier",
772 "type_qualifier_list : type_qualifier_list type_qualifier",
773 "parameter_type_list : parameter_list",
774 "parameter_type_list : parameter_list ',' T_ELLIPSIS",
775 "parameter_list : parameter_declaration",
776 "parameter_list : parameter_list ',' parameter_declaration",
777 "parameter_declaration : decl_specifiers declarator",
778 "parameter_declaration : decl_specifiers abs_declarator",
779 "parameter_declaration : decl_specifiers",
780 "opt_identifier_list :",
781 "opt_identifier_list : identifier_list",
782 "identifier_list : any_id",
783 "identifier_list : identifier_list ',' any_id",
784 "identifier_or_ref : any_id",
785 "identifier_or_ref : '&' any_id",
786 "abs_declarator : pointer",
787 "abs_declarator : pointer direct_abs_declarator",
788 "abs_declarator : direct_abs_declarator",
789 "direct_abs_declarator : '(' abs_declarator ')'",
790 "direct_abs_declarator : direct_abs_declarator T_BRACKETS",
791 "direct_abs_declarator : T_BRACKETS",
792 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
793 "direct_abs_declarator : direct_abs_declarator '(' ')'",
794 "direct_abs_declarator : '(' parameter_type_list ')'",
795 "direct_abs_declarator : '(' ')'",
808 /* define the initial stack-sizes */
811 #define YYMAXDEPTH YYSTACKSIZE
814 #define YYSTACKSIZE YYMAXDEPTH
816 #define YYSTACKSIZE 500
817 #define YYMAXDEPTH 500
821 #define YYINITSTACKSIZE 500
831 /* variables for the parser stack */
832 static YYSTACKDATA yystack;
833 #line 1014 "grammar.y"
836 #define BEGIN yy_start = 1 + 2 *
847 extern FILE *yyin, *yyout;
849 static int curly; /* number of curly brace nesting levels */
850 static int ly_count; /* number of occurances of %% */
851 static int inc_depth; /* include nesting level */
852 static SymbolTable *included_files; /* files already included */
853 static int yy_start = 0; /* start state number */
855 #define grammar_error(s) yaccError(s)
858 yaccError (const char *msg)
861 put_error(); /* tell what line we're on, and what file */
862 fprintf(stderr, "%s at token '%s'\n", msg, yytext);
865 /* Initialize the table of type qualifier keywords recognized by the lexical
871 static const char *keywords[] = {
880 #if defined(MSDOS) || defined(OS2)
938 /* Initialize type qualifier table. */
939 type_qualifiers = new_symbol_table();
940 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
941 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
945 /* Process the C source file. Write function prototypes to the standard
946 * output. Convert function definitions and write the converted source
947 * code to a temporary file.
950 process_file (FILE *infile, char *name)
954 if (strlen(name) > 2) {
955 s = name + strlen(name) - 2;
958 if (*s == 'l' || *s == 'y')
960 #if defined(MSDOS) || defined(OS2)
961 if (*s == 'L' || *s == 'Y')
967 included_files = new_symbol_table();
968 typedef_names = new_symbol_table();
969 define_names = new_symbol_table();
975 include_file(strcpy(base_file, name), func_style != FUNC_NONE);
979 put_blankline(stdout);
983 put_string(stdout, "/* ");
984 put_string(stdout, cur_file_name());
985 put_string(stdout, " */\n");
988 free_symbol_table(define_names);
989 free_symbol_table(typedef_names);
990 free_symbol_table(included_files);
997 free_symbol_table (type_qualifiers);
999 if (yy_current_buffer != 0)
1000 yy_delete_buffer(yy_current_buffer);
1004 #line 1004 "/dev/stdout"
1007 #include <stdio.h> /* needed for printf */
1010 #include <stdlib.h> /* needed for malloc, etc */
1011 #include <string.h> /* needed for memset */
1013 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1014 static int yygrowstack(YYSTACKDATA *data)
1021 if ((newsize = data->stacksize) == 0)
1022 newsize = YYINITSTACKSIZE;
1023 else if (newsize >= YYMAXDEPTH)
1025 else if ((newsize *= 2) > YYMAXDEPTH)
1026 newsize = YYMAXDEPTH;
1028 i = data->s_mark - data->s_base;
1029 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
1033 data->s_base = newss;
1034 data->s_mark = newss + i;
1036 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1040 data->l_base = newvs;
1041 data->l_mark = newvs + i;
1043 data->stacksize = newsize;
1044 data->s_last = data->s_base + newsize - 1;
1048 #if YYPURE || defined(YY_NO_LEAKS)
1049 static void yyfreestack(YYSTACKDATA *data)
1053 memset(data, 0, sizeof(*data));
1056 #define yyfreestack(data) /* nothing */
1059 #define YYABORT goto yyabort
1060 #define YYREJECT goto yyabort
1061 #define YYACCEPT goto yyaccept
1062 #define YYERROR goto yyerrlab
1067 int yym, yyn, yystate;
1071 if ((yys = getenv("YYDEBUG")) != 0)
1074 if (yyn >= '0' && yyn <= '9')
1075 yydebug = yyn - '0';
1085 memset(&yystack, 0, sizeof(yystack));
1088 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
1089 yystack.s_mark = yystack.s_base;
1090 yystack.l_mark = yystack.l_base;
1092 *yystack.s_mark = 0;
1095 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1098 if ((yychar = YYLEX) < 0) yychar = 0;
1103 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1104 if (!yys) yys = "illegal-symbol";
1105 printf("%sdebug: state %d, reading %d (%s)\n",
1106 YYPREFIX, yystate, yychar, yys);
1110 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1111 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1115 printf("%sdebug: state %d, shifting to state %d\n",
1116 YYPREFIX, yystate, yytable[yyn]);
1118 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1122 yystate = yytable[yyn];
1123 *++yystack.s_mark = yytable[yyn];
1124 *++yystack.l_mark = yylval;
1126 if (yyerrflag > 0) --yyerrflag;
1129 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1130 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1135 if (yyerrflag) goto yyinrecovery;
1137 yyerror("syntax error");
1150 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
1151 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1155 printf("%sdebug: state %d, error recovery shifting\
1156 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
1158 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1162 yystate = yytable[yyn];
1163 *++yystack.s_mark = yytable[yyn];
1164 *++yystack.l_mark = yylval;
1171 printf("%sdebug: error recovery discarding state %d\n",
1172 YYPREFIX, *yystack.s_mark);
1174 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1182 if (yychar == 0) goto yyabort;
1187 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1188 if (!yys) yys = "illegal-symbol";
1189 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1190 YYPREFIX, yystate, yychar, yys);
1200 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1201 YYPREFIX, yystate, yyn, yyrule[yyn]);
1205 yyval = yystack.l_mark[1-yym];
1207 memset(&yyval, 0, sizeof yyval);
1211 #line 377 "grammar.y"
1217 #line 381 "grammar.y"
1223 #line 392 "grammar.y"
1225 /* Provide an empty action here so bison will not complain about
1226 * incompatible types in the default action it normally would
1232 #line 399 "grammar.y"
1238 #line 406 "grammar.y"
1241 if (types_out && want_typedef()) {
1242 gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0);
1246 free_decl_spec(&yystack.l_mark[-1].decl_spec);
1251 #line 417 "grammar.y"
1253 if (func_params != NULL) {
1254 set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1256 gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1260 free_decl_list(&yystack.l_mark[-1].decl_list);
1262 free_decl_spec(&yystack.l_mark[-2].decl_spec);
1267 #line 431 "grammar.y"
1269 cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
1270 free_decl_spec(&yystack.l_mark[0].decl_spec);
1274 #line 436 "grammar.y"
1280 #line 443 "grammar.y"
1286 #line 447 "grammar.y"
1292 #line 459 "grammar.y"
1294 int flags = cur_decl_spec_flags;
1296 /* If the typedef is a pointer type, then reset the short type
1297 * flags so it does not get promoted.
1299 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1300 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1301 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1302 free_declarator(yystack.l_mark[0].declarator);
1306 #line 471 "grammar.y"
1308 int flags = cur_decl_spec_flags;
1310 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1311 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1312 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1313 free_declarator(yystack.l_mark[0].declarator);
1317 #line 483 "grammar.y"
1319 check_untagged(&yystack.l_mark[-1].decl_spec);
1320 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1321 yyerror("syntax error");
1324 func_params = &(yystack.l_mark[0].declarator->head->params);
1325 func_params->begin_comment = cur_file->begin_comment;
1326 func_params->end_comment = cur_file->end_comment;
1330 #line 494 "grammar.y"
1332 /* If we're converting to K&R and we've got a nominally K&R
1333 * function which has a parameter which is ANSI (i.e., a prototyped
1334 * function pointer), then we must override the deciphered value of
1335 * 'func_def' so that the parameter will be converted.
1337 if (func_style == FUNC_TRADITIONAL
1339 && yystack.l_mark[-3].declarator->head->func_def == func_style) {
1340 yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH;
1345 if (cur_file->convert)
1346 gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1347 gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1351 free_decl_spec(&yystack.l_mark[-4].decl_spec);
1352 free_declarator(yystack.l_mark[-3].declarator);
1356 #line 519 "grammar.y"
1358 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1359 yyerror("syntax error");
1362 func_params = &(yystack.l_mark[0].declarator->head->params);
1363 func_params->begin_comment = cur_file->begin_comment;
1364 func_params->end_comment = cur_file->end_comment;
1368 #line 529 "grammar.y"
1374 new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE);
1375 if (cur_file->convert)
1376 gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator);
1377 gen_prototype(&decl_spec, yystack.l_mark[-4].declarator);
1381 free_decl_spec(&decl_spec);
1382 free_declarator(yystack.l_mark[-4].declarator);
1386 #line 560 "grammar.y"
1388 join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
1389 free(yystack.l_mark[-1].decl_spec.text);
1390 free(yystack.l_mark[0].decl_spec.text);
1394 #line 575 "grammar.y"
1396 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1400 #line 579 "grammar.y"
1402 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
1406 #line 583 "grammar.y"
1408 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1412 #line 587 "grammar.y"
1414 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
1418 #line 591 "grammar.y"
1420 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
1424 #line 595 "grammar.y"
1426 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
1430 #line 602 "grammar.y"
1432 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1436 #line 606 "grammar.y"
1438 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1442 #line 610 "grammar.y"
1444 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
1448 #line 614 "grammar.y"
1450 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1454 #line 618 "grammar.y"
1456 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1460 #line 622 "grammar.y"
1462 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
1466 #line 626 "grammar.y"
1468 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1472 #line 630 "grammar.y"
1474 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1478 #line 634 "grammar.y"
1480 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1484 #line 638 "grammar.y"
1486 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1490 #line 642 "grammar.y"
1492 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1496 #line 646 "grammar.y"
1498 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1502 #line 650 "grammar.y"
1505 s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
1507 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1511 #line 662 "grammar.y"
1513 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1517 #line 666 "grammar.y"
1519 /* This rule allows the <pointer> nonterminal to scan #define
1520 * names as if they were type modifiers.
1523 s = find_symbol(define_names, yystack.l_mark[0].text.text);
1525 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1529 #line 679 "grammar.y"
1532 if ((s = implied_typedef()) == 0)
1533 (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
1534 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1538 #line 686 "grammar.y"
1541 if ((s = implied_typedef()) == 0)
1542 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1543 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1547 #line 693 "grammar.y"
1549 (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1550 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1554 #line 701 "grammar.y"
1556 imply_typedef(yyval.text.text);
1560 #line 705 "grammar.y"
1562 imply_typedef(yyval.text.text);
1566 #line 712 "grammar.y"
1568 new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
1572 #line 716 "grammar.y"
1574 add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
1578 #line 723 "grammar.y"
1580 if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
1581 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1582 gen_func_declarator(yystack.l_mark[0].declarator);
1583 fputs(cur_text(), cur_file->tmp_file);
1585 cur_declarator = yyval.declarator;
1589 #line 732 "grammar.y"
1591 if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
1592 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1593 gen_func_declarator(yystack.l_mark[-1].declarator);
1594 fputs(" =", cur_file->tmp_file);
1599 #line 744 "grammar.y"
1602 if ((s = implied_typedef()) == 0)
1603 (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
1604 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1608 #line 751 "grammar.y"
1611 if ((s = implied_typedef()) == 0)
1612 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1613 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1617 #line 758 "grammar.y"
1619 (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
1620 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1624 #line 766 "grammar.y"
1626 imply_typedef("enum");
1627 yyval.text = yystack.l_mark[0].text;
1631 #line 779 "grammar.y"
1633 yyval.declarator = yystack.l_mark[0].declarator;
1634 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1635 free(yyval.declarator->text);
1636 yyval.declarator->text = xstrdup(buf);
1637 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1638 yyval.declarator->pointer = TRUE;
1642 #line 792 "grammar.y"
1644 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
1648 #line 796 "grammar.y"
1650 yyval.declarator = yystack.l_mark[-1].declarator;
1651 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1652 free(yyval.declarator->text);
1653 yyval.declarator->text = xstrdup(buf);
1654 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1658 #line 804 "grammar.y"
1660 yyval.declarator = yystack.l_mark[-1].declarator;
1661 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1662 free(yyval.declarator->text);
1663 yyval.declarator->text = xstrdup(buf);
1667 #line 811 "grammar.y"
1669 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1670 yyval.declarator->params = yystack.l_mark[-1].param_list;
1671 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1672 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1673 yyval.declarator->func_def = FUNC_ANSI;
1677 #line 819 "grammar.y"
1679 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1680 yyval.declarator->params = yystack.l_mark[-1].param_list;
1681 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1682 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1683 yyval.declarator->func_def = FUNC_TRADITIONAL;
1687 #line 830 "grammar.y"
1689 (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
1690 yyval.text.begin = yystack.l_mark[-1].text.begin;
1694 #line 835 "grammar.y"
1696 (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1697 yyval.text.begin = yystack.l_mark[-2].text.begin;
1701 #line 843 "grammar.y"
1703 strcpy(yyval.text.text, "");
1704 yyval.text.begin = 0L;
1708 #line 852 "grammar.y"
1710 (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
1711 yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
1712 free(yystack.l_mark[0].decl_spec.text);
1716 #line 858 "grammar.y"
1718 (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
1719 yyval.text.begin = yystack.l_mark[-1].text.begin;
1720 free(yystack.l_mark[0].decl_spec.text);
1724 #line 868 "grammar.y"
1726 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
1730 #line 875 "grammar.y"
1732 new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
1736 #line 879 "grammar.y"
1738 add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
1742 #line 886 "grammar.y"
1744 check_untagged(&yystack.l_mark[-1].decl_spec);
1745 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1749 #line 891 "grammar.y"
1751 check_untagged(&yystack.l_mark[-1].decl_spec);
1752 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1756 #line 896 "grammar.y"
1758 check_untagged(&yystack.l_mark[0].decl_spec);
1759 yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
1763 #line 904 "grammar.y"
1765 new_ident_list(&yyval.param_list);
1769 #line 912 "grammar.y"
1771 new_ident_list(&yyval.param_list);
1772 add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
1776 #line 917 "grammar.y"
1778 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
1782 #line 924 "grammar.y"
1784 yyval.text = yystack.l_mark[0].text;
1788 #line 928 "grammar.y"
1791 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
1792 yyval.text = yystack.l_mark[0].text;
1795 (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
1796 yyval.text.begin = yystack.l_mark[-1].text.begin;
1800 #line 941 "grammar.y"
1802 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1806 #line 945 "grammar.y"
1808 yyval.declarator = yystack.l_mark[0].declarator;
1809 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1810 free(yyval.declarator->text);
1811 yyval.declarator->text = xstrdup(buf);
1812 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1816 #line 957 "grammar.y"
1818 yyval.declarator = yystack.l_mark[-1].declarator;
1819 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1820 free(yyval.declarator->text);
1821 yyval.declarator->text = xstrdup(buf);
1822 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1826 #line 965 "grammar.y"
1828 yyval.declarator = yystack.l_mark[-1].declarator;
1829 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1830 free(yyval.declarator->text);
1831 yyval.declarator->text = xstrdup(buf);
1835 #line 972 "grammar.y"
1837 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1841 #line 976 "grammar.y"
1843 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
1844 yyval.declarator->params = yystack.l_mark[-1].param_list;
1845 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1846 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1847 yyval.declarator->func_def = FUNC_ANSI;
1851 #line 984 "grammar.y"
1853 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
1854 yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
1855 yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head;
1856 yyval.declarator->func_def = FUNC_ANSI;
1860 #line 991 "grammar.y"
1864 d = new_declarator("", "", yystack.l_mark[-2].text.begin);
1865 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin);
1866 yyval.declarator->params = yystack.l_mark[-1].param_list;
1867 yyval.declarator->func_stack = d;
1868 yyval.declarator->head = yyval.declarator;
1869 yyval.declarator->func_def = FUNC_ANSI;
1873 #line 1002 "grammar.y"
1877 d = new_declarator("", "", yystack.l_mark[-1].text.begin);
1878 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin);
1879 yyval.declarator->func_stack = d;
1880 yyval.declarator->head = yyval.declarator;
1881 yyval.declarator->func_def = FUNC_ANSI;
1884 #line 1884 "/dev/stdout"
1886 yystack.s_mark -= yym;
1887 yystate = *yystack.s_mark;
1888 yystack.l_mark -= yym;
1890 if (yystate == 0 && yym == 0)
1894 printf("%sdebug: after reduction, shifting from state 0 to\
1895 state %d\n", YYPREFIX, YYFINAL);
1898 *++yystack.s_mark = YYFINAL;
1899 *++yystack.l_mark = yyval;
1902 if ((yychar = YYLEX) < 0) yychar = 0;
1907 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1908 if (!yys) yys = "illegal-symbol";
1909 printf("%sdebug: state %d, reading %d (%s)\n",
1910 YYPREFIX, YYFINAL, yychar, yys);
1914 if (yychar == 0) goto yyaccept;
1917 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1918 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1919 yystate = yytable[yyn];
1921 yystate = yydgoto[yym];
1924 printf("%sdebug: after reduction, shifting from state %d \
1925 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
1927 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1931 *++yystack.s_mark = (short) yystate;
1932 *++yystack.l_mark = yyval;
1936 yyerror("yacc stack overflow");
1939 yyfreestack(&yystack);
1943 yyfreestack(&yystack);