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)
16 #define yyparse grammar_parse
20 #define yylex grammar_lex
24 #define yyerror grammar_error
28 #define yychar grammar_char
32 #define yyval grammar_val
36 #define yylval grammar_lval
40 #define yydebug grammar_debug
44 #define yynerrs grammar_nerrs
48 #define yyerrflag grammar_errflag
49 #endif /* yyerrflag */
52 #define yylhs grammar_lhs
56 #define yylen grammar_len
60 #define yydefred grammar_defred
64 #define yydgoto grammar_dgoto
68 #define yysindex grammar_sindex
72 #define yyrindex grammar_rindex
76 #define yygindex grammar_gindex
80 #define yytable grammar_table
84 #define yycheck grammar_check
88 #define yyname grammar_name
92 #define yyrule grammar_rule
94 #define YYPREFIX "grammar_"
101 #define YYSTYPE_IS_DECLARED
102 #define yyerror yaccError
105 #if defined(YYBISON) || !defined(YYBYACC)
106 static void yyerror(const char *s);
113 #define OPT_LINTLIBRARY 1
123 /* #include "cproto.h" */
124 #define MAX_TEXT_SIZE 1024
126 /* Prototype styles */
128 #define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
129 #define PROTO_LINTLIBRARY -1 /* form lint-library source */
131 #define PROTO_NONE 0 /* do not output any prototypes */
132 #define PROTO_TRADITIONAL 1 /* comment out parameters */
133 #define PROTO_ABSTRACT 2 /* comment out parameter names */
134 #define PROTO_ANSI 3 /* ANSI C prototype */
136 typedef int PrototypeStyle;
138 typedef char boolean;
140 extern boolean types_out;
141 extern PrototypeStyle proto_style;
143 #define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
144 #define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
145 #define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
148 #define FUNC_UNKNOWN -1 /* unspecified */
150 #define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
152 #define FUNC_NONE 0 /* not a function definition */
153 #define FUNC_TRADITIONAL 1 /* traditional style */
154 #define FUNC_ANSI 2 /* ANSI style */
155 #define FUNC_BOTH 3 /* both styles */
157 typedef int FuncDefStyle;
159 /* Source file text */
160 typedef struct text {
161 char text[MAX_TEXT_SIZE]; /* source text */
162 long begin; /* offset in temporary file */
165 /* Declaration specifier flags */
166 #define DS_NONE 0 /* default */
167 #define DS_EXTERN 1 /* contains "extern" specifier */
168 #define DS_STATIC 2 /* contains "static" specifier */
169 #define DS_CHAR 4 /* contains "char" type specifier */
170 #define DS_SHORT 8 /* contains "short" type specifier */
171 #define DS_FLOAT 16 /* contains "float" type specifier */
172 #define DS_INLINE 32 /* contains "inline" specifier */
173 #define DS_JUNK 64 /* we're not interested in this declaration */
175 /* This structure stores information about a declaration specifier. */
176 typedef struct decl_spec {
177 unsigned short flags; /* flags defined above */
178 char *text; /* source text */
179 long begin; /* offset in temporary file */
182 /* This is a list of function parameters. */
183 typedef struct _ParameterList {
184 struct parameter *first; /* pointer to first parameter in list */
185 struct parameter *last; /* pointer to last parameter in list */
186 long begin_comment; /* begin offset of comment */
187 long end_comment; /* end offset of comment */
188 char *comment; /* comment at start of parameter list */
191 /* This structure stores information about a declarator. */
192 typedef struct _Declarator {
193 char *name; /* name of variable or function */
194 char *text; /* source text */
195 long begin; /* offset in temporary file */
196 long begin_comment; /* begin offset of comment */
197 long end_comment; /* end offset of comment */
198 FuncDefStyle func_def; /* style of function definition */
199 ParameterList params; /* function parameters */
200 boolean pointer; /* TRUE if it declares a pointer */
201 struct _Declarator *head; /* head function declarator */
202 struct _Declarator *func_stack; /* stack of function declarators */
203 struct _Declarator *next; /* next declarator in list */
206 /* This structure stores information about a function parameter. */
207 typedef struct parameter {
208 struct parameter *next; /* next parameter in list */
210 Declarator *declarator;
211 char *comment; /* comment following the parameter */
214 /* This is a list of declarators. */
215 typedef struct declarator_list {
216 Declarator *first; /* pointer to first declarator in list */
217 Declarator *last; /* pointer to last declarator in list */
220 /* #include "symbol.h" */
221 typedef struct symbol {
222 struct symbol *next; /* next symbol in list */
223 char *name; /* name of symbol */
224 char *value; /* value of symbol (for defines) */
225 short flags; /* symbol attributes */
228 /* parser stack entry type */
232 Parameter *parameter;
233 ParameterList param_list;
234 Declarator *declarator;
235 DeclaratorList decl_list;
238 /* The hash table length should be a prime number. */
239 #define SYM_MAX_HASH 251
241 typedef struct symbol_table {
242 Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */
245 extern SymbolTable *new_symbol_table /* Create symbol table */
247 extern void free_symbol_table /* Destroy symbol table */
249 extern Symbol *find_symbol /* Lookup symbol name */
250 (SymbolTable *s, const char *n);
251 extern Symbol *new_symbol /* Define new symbol */
252 (SymbolTable *s, const char *n, const char *v, int f);
254 /* #include "semantic.h" */
255 extern void new_decl_spec (DeclSpec *, const char *, long, int);
256 extern void free_decl_spec (DeclSpec *);
257 extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *);
258 extern void check_untagged (DeclSpec *);
259 extern Declarator *new_declarator (const char *, const char *, long);
260 extern void free_declarator (Declarator *);
261 extern void new_decl_list (DeclaratorList *, Declarator *);
262 extern void free_decl_list (DeclaratorList *);
263 extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *);
264 extern Parameter *new_parameter (DeclSpec *, Declarator *);
265 extern void free_parameter (Parameter *);
266 extern void new_param_list (ParameterList *, Parameter *);
267 extern void free_param_list (ParameterList *);
268 extern void add_param_list (ParameterList *, ParameterList *, Parameter *);
269 extern void new_ident_list (ParameterList *);
270 extern void add_ident_list (ParameterList *, ParameterList *, const char *);
271 extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *);
272 extern void gen_declarations (DeclSpec *, DeclaratorList *);
273 extern void gen_prototype (DeclSpec *, Declarator *);
274 extern void gen_func_declarator (Declarator *);
275 extern void gen_func_definition (DeclSpec *, Declarator *);
277 extern void init_parser (void);
278 extern void process_file (FILE *infile, char *name);
279 extern char *cur_text (void);
280 extern char *cur_file_name (void);
281 extern char *implied_typedef (void);
282 extern void include_file (char *name, int convert);
283 extern char *supply_parm (int count);
284 extern char *xstrdup (const char *);
285 extern int already_declared (char *name);
286 extern int is_actual_func (Declarator *d);
287 extern int lint_ellipsis (Parameter *p);
288 extern int want_typedef (void);
289 extern void begin_tracking (void);
290 extern void begin_typedef (void);
291 extern void copy_typedef (char *s);
292 extern void ellipsis_varargs (Declarator *d);
293 extern void end_typedef (void);
294 extern void flush_varargs (void);
295 extern void fmt_library (int code);
296 extern void imply_typedef (const char *s);
297 extern void indent (FILE *outf);
298 extern void put_blankline (FILE *outf);
299 extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator);
300 extern void put_char (FILE *outf, int c);
301 extern void put_error (void);
302 extern void put_newline (FILE *outf);
303 extern void put_padded (FILE *outf, const char *s);
304 extern void put_string (FILE *outf, const char *s);
305 extern void track_in (void);
307 extern boolean file_comments;
308 extern FuncDefStyle func_style;
309 extern char base_file[];
311 extern int yylex (void);
313 /* declaration specifier attributes for the typedef statement currently being
316 static int cur_decl_spec_flags;
318 /* pointer to parameter list for the current function definition */
319 static ParameterList *func_params;
321 /* A parser semantic action sets this pointer to the current declarator in
322 * a function parameter declaration in order to catch any comments following
323 * the parameter declaration on the same line. If the lexer scans a comment
324 * and <cur_declarator> is not NULL, then the comment is attached to the
325 * declarator. To ignore subsequent comments, the lexer sets this to NULL
326 * after scanning a comment or end of line.
328 static Declarator *cur_declarator;
330 /* temporary string buffer */
331 static char buf[MAX_TEXT_SIZE];
333 /* table of typedef names */
334 static SymbolTable *typedef_names;
336 /* table of define names */
337 static SymbolTable *define_names;
339 /* table of type qualifiers */
340 static SymbolTable *type_qualifiers;
342 /* information about the current input file */
344 char *base_name; /* base input file name */
345 char *file_name; /* current file name */
346 FILE *file; /* input file */
347 unsigned line_num; /* current line number in input file */
348 FILE *tmp_file; /* temporary file */
349 long begin_comment; /* tmp file offset after last written ) or ; */
350 long end_comment; /* tmp file offset after last comment */
351 boolean convert; /* if TRUE, convert function definitions */
352 boolean changed; /* TRUE if conversion done in this file */
355 static IncludeStack *cur_file; /* current input file */
357 /* #include "yyerror.c" */
359 static int haveAnsiParam (void);
362 /* Flags to enable us to find if a procedure returns a value.
364 static int return_val; /* nonzero on BRACES iff return-expression found */
369 return (lintLibrary() && !return_val) ? "void" : "int";
376 if (func_params != 0) {
377 for (p = func_params->first; p != 0; p = p->next) {
378 if (p->declarator->func_def == FUNC_ANSI) {
385 #line 386 "grammar.tab.c"
387 /* compatibility with bison */
389 /* compatibility with FreeBSD */
390 # ifdef YYPARSE_PARAM_TYPE
391 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
393 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
396 # define YYPARSE_DECL() yyparse(void)
399 /* Parameters sent to lex. */
401 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
402 # define YYLEX yylex(YYLEX_PARAM)
404 # define YYLEX_DECL() yylex(void)
405 # define YYLEX yylex()
408 /* Parameters sent to yyerror. */
410 #define YYERROR_DECL() yyerror(const char *s)
413 #define YYERROR_CALL(msg) yyerror(msg)
416 extern int YYPARSE_DECL();
418 #define T_IDENTIFIER 257
419 #define T_TYPEDEF_NAME 258
420 #define T_DEFINE_NAME 259
423 #define T_REGISTER 262
425 #define T_TYPEDEF 264
427 #define T_EXTENSION 266
436 #define T_UNSIGNED 275
441 #define T_Complex 280
442 #define T_Imaginary 281
443 #define T_TYPE_QUALIFIER 282
444 #define T_BRACKETS 283
446 #define T_MATCHRBRACE 285
447 #define T_ELLIPSIS 286
448 #define T_INITIALIZER 287
449 #define T_STRING_LITERAL 288
453 #define YYERRCODE 256
454 static const short grammar_lhs[] = { -1,
455 0, 0, 26, 26, 27, 27, 27, 27, 27, 27,
456 27, 31, 30, 30, 28, 28, 34, 28, 32, 32,
457 33, 33, 35, 35, 37, 38, 29, 39, 29, 36,
458 36, 36, 40, 40, 1, 1, 2, 2, 2, 3,
459 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
460 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
461 5, 5, 6, 6, 6, 19, 19, 8, 8, 9,
462 41, 9, 7, 7, 7, 25, 23, 23, 10, 10,
463 11, 11, 11, 11, 11, 20, 20, 21, 21, 22,
464 22, 14, 14, 15, 15, 16, 16, 16, 17, 17,
465 18, 18, 24, 24, 12, 12, 12, 13, 13, 13,
468 static const short grammar_len[] = { 2,
469 0, 1, 1, 2, 1, 1, 1, 1, 3, 2,
470 2, 2, 3, 3, 2, 3, 0, 5, 2, 1,
471 0, 1, 1, 3, 0, 0, 7, 0, 5, 0,
472 1, 1, 1, 2, 1, 2, 1, 1, 1, 1,
473 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
474 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
475 1, 1, 3, 2, 2, 1, 1, 1, 3, 1,
476 0, 4, 3, 2, 2, 1, 1, 1, 2, 1,
477 1, 3, 2, 4, 4, 2, 3, 0, 1, 1,
478 2, 1, 3, 1, 3, 2, 2, 1, 0, 1,
479 1, 3, 1, 2, 1, 2, 1, 3, 2, 1,
482 static const short grammar_defred[] = { 0,
483 0, 0, 0, 0, 77, 0, 62, 40, 0, 42,
484 43, 20, 44, 0, 46, 47, 48, 49, 54, 50,
485 51, 52, 53, 76, 66, 67, 55, 56, 57, 61,
486 0, 7, 0, 0, 35, 37, 38, 39, 59, 60,
487 28, 0, 0, 0, 103, 81, 0, 0, 3, 5,
488 6, 8, 0, 10, 11, 78, 0, 90, 0, 0,
489 104, 0, 19, 0, 41, 45, 15, 36, 0, 68,
490 0, 0, 0, 83, 0, 0, 64, 0, 0, 74,
491 4, 58, 0, 82, 87, 91, 0, 14, 13, 9,
492 16, 0, 71, 0, 31, 33, 0, 0, 0, 0,
493 0, 94, 0, 0, 101, 12, 63, 73, 0, 0,
494 69, 0, 0, 0, 34, 0, 110, 96, 97, 0,
495 0, 84, 0, 85, 0, 23, 0, 0, 72, 26,
496 29, 114, 0, 0, 0, 109, 0, 93, 95, 102,
497 18, 0, 0, 108, 113, 112, 0, 24, 27, 111,
499 static const short grammar_dgoto[] = { 33,
500 87, 35, 36, 37, 38, 39, 40, 69, 70, 41,
501 42, 119, 120, 100, 101, 102, 103, 104, 43, 44,
502 59, 60, 45, 46, 47, 48, 49, 50, 51, 52,
503 77, 53, 127, 109, 128, 97, 94, 143, 72, 98,
506 static const short grammar_sindex[] = { -2,
507 -3, 27, -239, -177, 0, 0, 0, 0, -274, 0,
508 0, 0, 0, -246, 0, 0, 0, 0, 0, 0,
509 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
510 -266, 0, 0, 455, 0, 0, 0, 0, 0, 0,
511 0, -35, -245, 128, 0, 0, -245, -2, 0, 0,
512 0, 0, 642, 0, 0, 0, -15, 0, -12, -239,
513 0, 590, 0, -27, 0, 0, 0, 0, -10, 0,
514 -11, 534, -72, 0, -237, -232, 0, -35, -232, 0,
515 0, 0, 642, 0, 0, 0, 455, 0, 0, 0,
516 0, 27, 0, 534, 0, 0, -222, 617, 209, 34,
517 39, 0, 44, 42, 0, 0, 0, 0, 27, -11,
518 0, -200, -196, -195, 0, 174, 0, 0, 0, -33,
519 243, 0, 561, 0, -177, 0, 33, 49, 0, 0,
520 0, 0, 53, 55, 417, 0, -33, 0, 0, 0,
521 0, 27, -188, 0, 0, 0, 57, 0, 0, 0,
523 static const short grammar_rindex[] = { 99,
524 0, 0, 275, 0, 0, -38, 0, 0, 481, 0,
525 0, 0, 0, 509, 0, 0, 0, 0, 0, 0,
526 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
528 0, 30, 0, 0, 0, 0, 0, 101, 0, 0,
529 0, 0, 0, 0, 0, 0, 0, 0, 343, 309,
530 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
531 98, -182, 62, 0, 0, 133, 0, 64, 379, 0,
532 0, 0, -5, 0, 0, 0, 0, 0, 0, 0,
533 0, 0, 0, -182, 0, 0, 0, -180, -19, 0,
534 65, 0, 0, 68, 0, 0, 0, 0, 51, 9,
535 0, 0, 0, 0, 0, 0, 0, 0, 0, -13,
536 19, 0, 0, 0, 0, 0, 0, 52, 0, 0,
537 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
538 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
540 static const short grammar_gindex[] = { 0,
541 11, -17, 0, 0, 13, 0, 0, 0, 20, 8,
542 -43, -1, -8, -89, 0, -9, 0, 0, 0, -44,
543 0, 0, 4, 0, 0, 0, 70, -53, 0, 0,
544 -18, 0, 0, 0, 0, 22, 0, 0, 0, 0,
547 #define YYTABLESIZE 924
548 static const short grammar_table[] = { 58,
549 78, 58, 58, 58, 73, 58, 135, 61, 88, 57,
550 34, 5, 56, 62, 85, 58, 68, 63, 96, 7,
551 58, 98, 78, 64, 98, 84, 134, 107, 80, 3,
552 107, 90, 17, 92, 17, 4, 17, 2, 75, 3,
553 96, 71, 30, 89, 115, 147, 76, 106, 91, 93,
554 79, 75, 70, 17, 121, 55, 32, 107, 34, 105,
555 108, 114, 105, 83, 4, 68, 2, 70, 3, 68,
556 80, 121, 86, 80, 122, 106, 105, 78, 106, 5,
557 56, 68, 123, 99, 124, 125, 129, 130, 80, 131,
558 80, 141, 142, 144, 110, 145, 149, 150, 1, 110,
559 2, 30, 99, 32, 79, 92, 118, 79, 100, 21,
560 22, 111, 137, 139, 133, 113, 126, 81, 0, 0,
561 0, 0, 79, 57, 79, 0, 99, 0, 140, 0,
562 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
563 0, 70, 0, 0, 0, 99, 0, 0, 0, 148,
564 0, 0, 0, 0, 0, 0, 70, 0, 0, 0,
565 0, 0, 0, 0, 0, 4, 0, 2, 0, 0,
566 65, 0, 65, 65, 65, 0, 65, 0, 0, 0,
567 0, 0, 0, 0, 5, 6, 7, 8, 65, 10,
568 11, 65, 13, 66, 15, 16, 17, 18, 19, 20,
569 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
570 0, 4, 0, 116, 132, 3, 0, 0, 58, 58,
571 58, 58, 58, 58, 58, 78, 58, 58, 58, 58,
572 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
573 58, 58, 58, 58, 58, 78, 4, 74, 116, 136,
574 3, 17, 78, 1, 5, 6, 7, 8, 9, 10,
575 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
576 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
577 4, 54, 116, 5, 56, 0, 31, 80, 80, 80,
578 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
579 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
580 80, 80, 88, 80, 88, 88, 88, 0, 88, 0,
581 80, 79, 79, 79, 79, 79, 79, 79, 79, 79,
582 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
583 79, 79, 79, 79, 79, 79, 89, 79, 89, 89,
584 89, 0, 89, 0, 79, 25, 25, 25, 25, 25,
585 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
586 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
587 86, 25, 86, 86, 5, 56, 86, 0, 25, 65,
588 65, 65, 65, 65, 65, 65, 0, 65, 65, 65,
589 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
590 65, 65, 65, 65, 65, 65, 75, 0, 75, 75,
591 75, 0, 75, 0, 0, 0, 0, 0, 0, 0,
592 5, 6, 7, 8, 65, 10, 11, 75, 13, 66,
593 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
594 25, 26, 27, 28, 29, 30, 117, 146, 0, 0,
595 0, 0, 0, 0, 0, 5, 6, 7, 8, 65,
596 10, 11, 0, 13, 66, 15, 16, 17, 18, 19,
597 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
598 30, 117, 4, 0, 2, 0, 3, 0, 0, 5,
599 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
600 0, 0, 0, 67, 0, 0, 0, 0, 41, 0,
601 41, 0, 41, 0, 0, 117, 0, 0, 0, 0,
602 0, 88, 88, 0, 0, 0, 0, 0, 0, 41,
603 0, 0, 0, 0, 0, 0, 45, 0, 45, 0,
604 45, 0, 0, 0, 0, 0, 0, 88, 0, 0,
605 0, 0, 0, 0, 0, 89, 89, 45, 0, 0,
606 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
607 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
608 0, 89, 0, 0, 0, 0, 0, 0, 0, 86,
609 86, 0, 0, 0, 0, 0, 0, 0, 0, 0,
610 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
611 0, 0, 0, 0, 0, 86, 0, 0, 0, 0,
612 0, 0, 0, 0, 0, 75, 75, 75, 75, 75,
613 75, 75, 0, 75, 75, 75, 75, 75, 75, 75,
614 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
615 75, 75, 0, 0, 0, 0, 0, 0, 0, 0,
616 0, 0, 0, 0, 82, 7, 8, 65, 10, 11,
617 0, 13, 66, 15, 16, 17, 18, 19, 20, 21,
618 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
619 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
620 0, 5, 6, 7, 8, 65, 10, 11, 0, 13,
621 66, 15, 16, 17, 18, 19, 20, 21, 22, 23,
622 24, 25, 26, 27, 28, 29, 30, 41, 41, 41,
623 41, 41, 41, 41, 0, 41, 41, 41, 41, 41,
624 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
625 41, 41, 41, 0, 0, 45, 45, 45, 45, 45,
626 45, 45, 0, 45, 45, 45, 45, 45, 45, 45,
627 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
628 45, 82, 7, 8, 65, 10, 11, 12, 13, 14,
629 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
630 25, 26, 27, 28, 29, 30, 0, 0, 82, 7,
631 8, 65, 10, 11, 95, 13, 66, 15, 16, 17,
632 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
633 28, 29, 30, 0, 0, 0, 138, 82, 7, 8,
634 65, 10, 11, 12, 13, 14, 15, 16, 17, 18,
635 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
636 29, 30, 0, 75, 82, 7, 8, 65, 10, 11,
637 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
638 22, 23, 24, 25, 26, 27, 28, 29, 30, 82,
639 7, 8, 65, 10, 11, 0, 13, 66, 15, 16,
640 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
643 static const short grammar_check[] = { 38,
644 44, 40, 41, 42, 40, 44, 40, 4, 62, 2,
645 0, 257, 258, 288, 59, 3, 34, 264, 72, 259,
646 59, 41, 61, 290, 44, 41, 116, 41, 47, 42,
647 44, 59, 38, 44, 40, 38, 42, 40, 284, 42,
648 94, 34, 282, 62, 98, 135, 43, 285, 59, 61,
649 47, 284, 44, 59, 99, 59, 59, 76, 48, 41,
650 79, 284, 44, 53, 38, 83, 40, 59, 42, 87,
651 41, 116, 60, 44, 41, 41, 73, 121, 44, 257,
652 258, 99, 44, 73, 41, 44, 287, 284, 59, 285,
653 61, 59, 44, 41, 87, 41, 285, 41, 0, 92,
654 0, 284, 41, 284, 41, 41, 99, 44, 41, 59,
655 59, 92, 121, 123, 116, 94, 109, 48, -1, -1,
656 -1, -1, 59, 116, 61, -1, 116, -1, 125, -1,
657 -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
658 -1, 44, -1, -1, -1, 135, -1, -1, -1, 142,
659 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
660 -1, -1, -1, -1, -1, 38, -1, 40, -1, -1,
661 38, -1, 40, 41, 42, -1, 44, -1, -1, -1,
662 -1, -1, -1, -1, 257, 258, 259, 260, 261, 262,
663 263, 59, 265, 266, 267, 268, 269, 270, 271, 272,
664 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
665 -1, 38, -1, 40, 41, 42, -1, -1, 257, 258,
666 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
667 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
668 279, 280, 281, 282, 283, 284, 38, 283, 40, 283,
669 42, 257, 291, 256, 257, 258, 259, 260, 261, 262,
670 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
671 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
672 38, 285, 40, 257, 258, -1, 289, 258, 259, 260,
673 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
674 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
675 281, 282, 38, 284, 40, 41, 42, -1, 44, -1,
676 291, 258, 259, 260, 261, 262, 263, 264, 265, 266,
677 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
678 277, 278, 279, 280, 281, 282, 38, 284, 40, 41,
679 42, -1, 44, -1, 291, 258, 259, 260, 261, 262,
680 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
681 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
682 38, 284, 40, 41, 257, 258, 44, -1, 291, 257,
683 258, 259, 260, 261, 262, 263, -1, 265, 266, 267,
684 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
685 278, 279, 280, 281, 282, 283, 38, -1, 40, 41,
686 42, -1, 44, -1, -1, -1, -1, -1, -1, -1,
687 257, 258, 259, 260, 261, 262, 263, 59, 265, 266,
688 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
689 277, 278, 279, 280, 281, 282, 283, 41, -1, -1,
690 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
691 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
692 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
693 282, 283, 38, -1, 40, -1, 42, -1, -1, 257,
694 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
695 -1, -1, -1, 59, -1, -1, -1, -1, 38, -1,
696 40, -1, 42, -1, -1, 283, -1, -1, -1, -1,
697 -1, 257, 258, -1, -1, -1, -1, -1, -1, 59,
698 -1, -1, -1, -1, -1, -1, 38, -1, 40, -1,
699 42, -1, -1, -1, -1, -1, -1, 283, -1, -1,
700 -1, -1, -1, -1, -1, 257, 258, 59, -1, -1,
701 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
702 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
703 -1, 283, -1, -1, -1, -1, -1, -1, -1, 257,
704 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
705 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
706 -1, -1, -1, -1, -1, 283, -1, -1, -1, -1,
707 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
708 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
709 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
710 282, 283, -1, -1, -1, -1, -1, -1, -1, -1,
711 -1, -1, -1, -1, 258, 259, 260, 261, 262, 263,
712 -1, 265, 266, 267, 268, 269, 270, 271, 272, 273,
713 274, 275, 276, 277, 278, 279, 280, 281, 282, -1,
714 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
715 -1, 257, 258, 259, 260, 261, 262, 263, -1, 265,
716 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
717 276, 277, 278, 279, 280, 281, 282, 257, 258, 259,
718 260, 261, 262, 263, -1, 265, 266, 267, 268, 269,
719 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
720 280, 281, 282, -1, -1, 257, 258, 259, 260, 261,
721 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
722 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
723 282, 258, 259, 260, 261, 262, 263, 264, 265, 266,
724 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
725 277, 278, 279, 280, 281, 282, -1, -1, 258, 259,
726 260, 261, 262, 263, 291, 265, 266, 267, 268, 269,
727 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
728 280, 281, 282, -1, -1, -1, 286, 258, 259, 260,
729 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
730 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
731 281, 282, -1, 284, 258, 259, 260, 261, 262, 263,
732 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
733 274, 275, 276, 277, 278, 279, 280, 281, 282, 258,
734 259, 260, 261, 262, 263, -1, 265, 266, 267, 268,
735 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
742 #define YYMAXTOKEN 291
744 static const char *yyname[] = {
746 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
747 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
748 "'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
749 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
750 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
751 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
752 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
753 "T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
754 "T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR",
755 "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED",
756 "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary",
757 "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS",
758 "T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
760 static const char *yyrule[] = {
763 "program : translation_unit",
764 "translation_unit : external_declaration",
765 "translation_unit : translation_unit external_declaration",
766 "external_declaration : declaration",
767 "external_declaration : function_definition",
768 "external_declaration : ';'",
769 "external_declaration : linkage_specification",
770 "external_declaration : T_ASM T_ASMARG ';'",
771 "external_declaration : error T_MATCHRBRACE",
772 "external_declaration : error ';'",
773 "braces : T_LBRACE T_MATCHRBRACE",
774 "linkage_specification : T_EXTERN T_STRING_LITERAL braces",
775 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
776 "declaration : decl_specifiers ';'",
777 "declaration : decl_specifiers init_declarator_list ';'",
779 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
780 "any_typedef : T_EXTENSION T_TYPEDEF",
781 "any_typedef : T_TYPEDEF",
782 "opt_declarator_list :",
783 "opt_declarator_list : declarator_list",
784 "declarator_list : declarator",
785 "declarator_list : declarator_list ',' declarator",
788 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
790 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
791 "opt_declaration_list :",
792 "opt_declaration_list : T_VA_DCL",
793 "opt_declaration_list : declaration_list",
794 "declaration_list : declaration",
795 "declaration_list : declaration_list declaration",
796 "decl_specifiers : decl_specifier",
797 "decl_specifiers : decl_specifiers decl_specifier",
798 "decl_specifier : storage_class",
799 "decl_specifier : type_specifier",
800 "decl_specifier : type_qualifier",
801 "storage_class : T_AUTO",
802 "storage_class : T_EXTERN",
803 "storage_class : T_REGISTER",
804 "storage_class : T_STATIC",
805 "storage_class : T_INLINE",
806 "storage_class : T_EXTENSION",
807 "type_specifier : T_CHAR",
808 "type_specifier : T_DOUBLE",
809 "type_specifier : T_FLOAT",
810 "type_specifier : T_INT",
811 "type_specifier : T_LONG",
812 "type_specifier : T_SHORT",
813 "type_specifier : T_SIGNED",
814 "type_specifier : T_UNSIGNED",
815 "type_specifier : T_VOID",
816 "type_specifier : T_Bool",
817 "type_specifier : T_Complex",
818 "type_specifier : T_Imaginary",
819 "type_specifier : T_TYPEDEF_NAME",
820 "type_specifier : struct_or_union_specifier",
821 "type_specifier : enum_specifier",
822 "type_qualifier : T_TYPE_QUALIFIER",
823 "type_qualifier : T_DEFINE_NAME",
824 "struct_or_union_specifier : struct_or_union any_id braces",
825 "struct_or_union_specifier : struct_or_union braces",
826 "struct_or_union_specifier : struct_or_union any_id",
827 "struct_or_union : T_STRUCT",
828 "struct_or_union : T_UNION",
829 "init_declarator_list : init_declarator",
830 "init_declarator_list : init_declarator_list ',' init_declarator",
831 "init_declarator : declarator",
833 "init_declarator : declarator '=' $$5 T_INITIALIZER",
834 "enum_specifier : enumeration any_id braces",
835 "enum_specifier : enumeration braces",
836 "enum_specifier : enumeration any_id",
837 "enumeration : T_ENUM",
838 "any_id : T_IDENTIFIER",
839 "any_id : T_TYPEDEF_NAME",
840 "declarator : pointer direct_declarator",
841 "declarator : direct_declarator",
842 "direct_declarator : identifier_or_ref",
843 "direct_declarator : '(' declarator ')'",
844 "direct_declarator : direct_declarator T_BRACKETS",
845 "direct_declarator : direct_declarator '(' parameter_type_list ')'",
846 "direct_declarator : direct_declarator '(' opt_identifier_list ')'",
847 "pointer : '*' opt_type_qualifiers",
848 "pointer : '*' opt_type_qualifiers pointer",
849 "opt_type_qualifiers :",
850 "opt_type_qualifiers : type_qualifier_list",
851 "type_qualifier_list : type_qualifier",
852 "type_qualifier_list : type_qualifier_list type_qualifier",
853 "parameter_type_list : parameter_list",
854 "parameter_type_list : parameter_list ',' T_ELLIPSIS",
855 "parameter_list : parameter_declaration",
856 "parameter_list : parameter_list ',' parameter_declaration",
857 "parameter_declaration : decl_specifiers declarator",
858 "parameter_declaration : decl_specifiers abs_declarator",
859 "parameter_declaration : decl_specifiers",
860 "opt_identifier_list :",
861 "opt_identifier_list : identifier_list",
862 "identifier_list : any_id",
863 "identifier_list : identifier_list ',' any_id",
864 "identifier_or_ref : any_id",
865 "identifier_or_ref : '&' any_id",
866 "abs_declarator : pointer",
867 "abs_declarator : pointer direct_abs_declarator",
868 "abs_declarator : direct_abs_declarator",
869 "direct_abs_declarator : '(' abs_declarator ')'",
870 "direct_abs_declarator : direct_abs_declarator T_BRACKETS",
871 "direct_abs_declarator : T_BRACKETS",
872 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
873 "direct_abs_declarator : direct_abs_declarator '(' ')'",
874 "direct_abs_declarator : '(' parameter_type_list ')'",
875 "direct_abs_declarator : '(' ')'",
888 /* define the initial stack-sizes */
891 #define YYMAXDEPTH YYSTACKSIZE
894 #define YYSTACKSIZE YYMAXDEPTH
896 #define YYSTACKSIZE 500
897 #define YYMAXDEPTH 500
901 #define YYINITSTACKSIZE 500
911 /* variables for the parser stack */
912 static YYSTACKDATA yystack;
913 #line 1014 "grammar.y"
916 #define BEGIN yy_start = 1 + 2 *
927 extern FILE *yyin, *yyout;
929 static int curly; /* number of curly brace nesting levels */
930 static int ly_count; /* number of occurances of %% */
931 static int inc_depth; /* include nesting level */
932 static SymbolTable *included_files; /* files already included */
933 static int yy_start = 0; /* start state number */
935 #define grammar_error(s) yaccError(s)
938 yaccError (const char *msg)
941 put_error(); /* tell what line we're on, and what file */
942 fprintf(stderr, "%s at token '%s'\n", msg, yytext);
945 /* Initialize the table of type qualifier keywords recognized by the lexical
951 static const char *keywords[] = {
960 #if defined(MSDOS) || defined(OS2)
1005 "__builtin_va_list",
1018 /* Initialize type qualifier table. */
1019 type_qualifiers = new_symbol_table();
1020 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
1021 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
1025 /* Process the C source file. Write function prototypes to the standard
1026 * output. Convert function definitions and write the converted source
1027 * code to a temporary file.
1030 process_file (FILE *infile, char *name)
1034 if (strlen(name) > 2) {
1035 s = name + strlen(name) - 2;
1038 if (*s == 'l' || *s == 'y')
1040 #if defined(MSDOS) || defined(OS2)
1041 if (*s == 'L' || *s == 'Y')
1047 included_files = new_symbol_table();
1048 typedef_names = new_symbol_table();
1049 define_names = new_symbol_table();
1055 include_file(strcpy(base_file, name), func_style != FUNC_NONE);
1056 if (file_comments) {
1058 if (lintLibrary()) {
1059 put_blankline(stdout);
1063 put_string(stdout, "/* ");
1064 put_string(stdout, cur_file_name());
1065 put_string(stdout, " */\n");
1068 free_symbol_table(define_names);
1069 free_symbol_table(typedef_names);
1070 free_symbol_table(included_files);
1077 free_symbol_table (type_qualifiers);
1079 if (yy_current_buffer != 0)
1080 yy_delete_buffer(yy_current_buffer);
1084 #line 1085 "grammar.tab.c"
1087 #include <stdio.h> /* needed for printf */
1090 #include <stdlib.h> /* needed for malloc, etc */
1091 #include <string.h> /* needed for memset */
1093 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1094 static int yygrowstack(YYSTACKDATA *data)
1101 if ((newsize = data->stacksize) == 0)
1102 newsize = YYINITSTACKSIZE;
1103 else if (newsize >= YYMAXDEPTH)
1105 else if ((newsize *= 2) > YYMAXDEPTH)
1106 newsize = YYMAXDEPTH;
1108 i = (int) (data->s_mark - data->s_base);
1109 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
1113 data->s_base = newss;
1114 data->s_mark = newss + i;
1116 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1120 data->l_base = newvs;
1121 data->l_mark = newvs + i;
1123 data->stacksize = newsize;
1124 data->s_last = data->s_base + newsize - 1;
1128 #if YYPURE || defined(YY_NO_LEAKS)
1129 static void yyfreestack(YYSTACKDATA *data)
1133 memset(data, 0, sizeof(*data));
1136 #define yyfreestack(data) /* nothing */
1139 #define YYABORT goto yyabort
1140 #define YYREJECT goto yyabort
1141 #define YYACCEPT goto yyaccept
1142 #define YYERROR goto yyerrlab
1147 int yym, yyn, yystate;
1151 if ((yys = getenv("YYDEBUG")) != 0)
1154 if (yyn >= '0' && yyn <= '9')
1155 yydebug = yyn - '0';
1165 memset(&yystack, 0, sizeof(yystack));
1168 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
1169 yystack.s_mark = yystack.s_base;
1170 yystack.l_mark = yystack.l_base;
1172 *yystack.s_mark = 0;
1175 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1178 if ((yychar = YYLEX) < 0) yychar = 0;
1183 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1184 if (!yys) yys = "illegal-symbol";
1185 printf("%sdebug: state %d, reading %d (%s)\n",
1186 YYPREFIX, yystate, yychar, yys);
1190 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1191 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1195 printf("%sdebug: state %d, shifting to state %d\n",
1196 YYPREFIX, yystate, yytable[yyn]);
1198 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1202 yystate = yytable[yyn];
1203 *++yystack.s_mark = yytable[yyn];
1204 *++yystack.l_mark = yylval;
1206 if (yyerrflag > 0) --yyerrflag;
1209 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1210 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1215 if (yyerrflag) goto yyinrecovery;
1217 yyerror("syntax error");
1230 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
1231 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1235 printf("%sdebug: state %d, error recovery shifting\
1236 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
1238 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1242 yystate = yytable[yyn];
1243 *++yystack.s_mark = yytable[yyn];
1244 *++yystack.l_mark = yylval;
1251 printf("%sdebug: error recovery discarding state %d\n",
1252 YYPREFIX, *yystack.s_mark);
1254 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1262 if (yychar == 0) goto yyabort;
1267 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1268 if (!yys) yys = "illegal-symbol";
1269 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1270 YYPREFIX, yystate, yychar, yys);
1280 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1281 YYPREFIX, yystate, yyn, yyrule[yyn]);
1285 yyval = yystack.l_mark[1-yym];
1287 memset(&yyval, 0, sizeof yyval);
1291 #line 377 "grammar.y"
1297 #line 381 "grammar.y"
1303 #line 392 "grammar.y"
1305 /* Provide an empty action here so bison will not complain about
1306 * incompatible types in the default action it normally would
1312 #line 399 "grammar.y"
1318 #line 406 "grammar.y"
1321 if (types_out && want_typedef()) {
1322 gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0);
1326 free_decl_spec(&yystack.l_mark[-1].decl_spec);
1331 #line 417 "grammar.y"
1333 if (func_params != NULL) {
1334 set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1336 gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1340 free_decl_list(&yystack.l_mark[-1].decl_list);
1342 free_decl_spec(&yystack.l_mark[-2].decl_spec);
1347 #line 431 "grammar.y"
1349 cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
1350 free_decl_spec(&yystack.l_mark[0].decl_spec);
1354 #line 436 "grammar.y"
1360 #line 443 "grammar.y"
1366 #line 447 "grammar.y"
1372 #line 459 "grammar.y"
1374 int flags = cur_decl_spec_flags;
1376 /* If the typedef is a pointer type, then reset the short type
1377 * flags so it does not get promoted.
1379 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1380 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1381 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1382 free_declarator(yystack.l_mark[0].declarator);
1386 #line 471 "grammar.y"
1388 int flags = cur_decl_spec_flags;
1390 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1391 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1392 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1393 free_declarator(yystack.l_mark[0].declarator);
1397 #line 483 "grammar.y"
1399 check_untagged(&yystack.l_mark[-1].decl_spec);
1400 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1401 yyerror("syntax error");
1404 func_params = &(yystack.l_mark[0].declarator->head->params);
1405 func_params->begin_comment = cur_file->begin_comment;
1406 func_params->end_comment = cur_file->end_comment;
1410 #line 494 "grammar.y"
1412 /* If we're converting to K&R and we've got a nominally K&R
1413 * function which has a parameter which is ANSI (i.e., a prototyped
1414 * function pointer), then we must override the deciphered value of
1415 * 'func_def' so that the parameter will be converted.
1417 if (func_style == FUNC_TRADITIONAL
1419 && yystack.l_mark[-3].declarator->head->func_def == func_style) {
1420 yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH;
1425 if (cur_file->convert)
1426 gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1427 gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1431 free_decl_spec(&yystack.l_mark[-4].decl_spec);
1432 free_declarator(yystack.l_mark[-3].declarator);
1436 #line 519 "grammar.y"
1438 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1439 yyerror("syntax error");
1442 func_params = &(yystack.l_mark[0].declarator->head->params);
1443 func_params->begin_comment = cur_file->begin_comment;
1444 func_params->end_comment = cur_file->end_comment;
1448 #line 529 "grammar.y"
1454 new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE);
1455 if (cur_file->convert)
1456 gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator);
1457 gen_prototype(&decl_spec, yystack.l_mark[-4].declarator);
1461 free_decl_spec(&decl_spec);
1462 free_declarator(yystack.l_mark[-4].declarator);
1466 #line 560 "grammar.y"
1468 join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
1469 free(yystack.l_mark[-1].decl_spec.text);
1470 free(yystack.l_mark[0].decl_spec.text);
1474 #line 575 "grammar.y"
1476 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1480 #line 579 "grammar.y"
1482 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
1486 #line 583 "grammar.y"
1488 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1492 #line 587 "grammar.y"
1494 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
1498 #line 591 "grammar.y"
1500 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
1504 #line 595 "grammar.y"
1506 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
1510 #line 602 "grammar.y"
1512 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1516 #line 606 "grammar.y"
1518 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1522 #line 610 "grammar.y"
1524 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
1528 #line 614 "grammar.y"
1530 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1534 #line 618 "grammar.y"
1536 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1540 #line 622 "grammar.y"
1542 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
1546 #line 626 "grammar.y"
1548 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1552 #line 630 "grammar.y"
1554 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1558 #line 634 "grammar.y"
1560 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1564 #line 638 "grammar.y"
1566 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1570 #line 642 "grammar.y"
1572 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1576 #line 646 "grammar.y"
1578 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1582 #line 650 "grammar.y"
1585 s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
1587 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1591 #line 662 "grammar.y"
1593 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1597 #line 666 "grammar.y"
1599 /* This rule allows the <pointer> nonterminal to scan #define
1600 * names as if they were type modifiers.
1603 s = find_symbol(define_names, yystack.l_mark[0].text.text);
1605 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1609 #line 679 "grammar.y"
1612 if ((s = implied_typedef()) == 0)
1613 (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
1614 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1618 #line 686 "grammar.y"
1621 if ((s = implied_typedef()) == 0)
1622 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1623 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1627 #line 693 "grammar.y"
1629 (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1630 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1634 #line 701 "grammar.y"
1636 imply_typedef(yyval.text.text);
1640 #line 705 "grammar.y"
1642 imply_typedef(yyval.text.text);
1646 #line 712 "grammar.y"
1648 new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
1652 #line 716 "grammar.y"
1654 add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
1658 #line 723 "grammar.y"
1660 if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
1661 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1662 gen_func_declarator(yystack.l_mark[0].declarator);
1663 fputs(cur_text(), cur_file->tmp_file);
1665 cur_declarator = yyval.declarator;
1669 #line 732 "grammar.y"
1671 if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
1672 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1673 gen_func_declarator(yystack.l_mark[-1].declarator);
1674 fputs(" =", cur_file->tmp_file);
1679 #line 744 "grammar.y"
1682 if ((s = implied_typedef()) == 0)
1683 (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
1684 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1688 #line 751 "grammar.y"
1691 if ((s = implied_typedef()) == 0)
1692 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
1693 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1697 #line 758 "grammar.y"
1699 (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
1700 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1704 #line 766 "grammar.y"
1706 imply_typedef("enum");
1707 yyval.text = yystack.l_mark[0].text;
1711 #line 779 "grammar.y"
1713 yyval.declarator = yystack.l_mark[0].declarator;
1714 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1715 free(yyval.declarator->text);
1716 yyval.declarator->text = xstrdup(buf);
1717 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1718 yyval.declarator->pointer = TRUE;
1722 #line 792 "grammar.y"
1724 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
1728 #line 796 "grammar.y"
1730 yyval.declarator = yystack.l_mark[-1].declarator;
1731 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1732 free(yyval.declarator->text);
1733 yyval.declarator->text = xstrdup(buf);
1734 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1738 #line 804 "grammar.y"
1740 yyval.declarator = yystack.l_mark[-1].declarator;
1741 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1742 free(yyval.declarator->text);
1743 yyval.declarator->text = xstrdup(buf);
1747 #line 811 "grammar.y"
1749 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1750 yyval.declarator->params = yystack.l_mark[-1].param_list;
1751 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1752 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1753 yyval.declarator->func_def = FUNC_ANSI;
1757 #line 819 "grammar.y"
1759 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1760 yyval.declarator->params = yystack.l_mark[-1].param_list;
1761 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1762 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1763 yyval.declarator->func_def = FUNC_TRADITIONAL;
1767 #line 830 "grammar.y"
1769 (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
1770 yyval.text.begin = yystack.l_mark[-1].text.begin;
1774 #line 835 "grammar.y"
1776 (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
1777 yyval.text.begin = yystack.l_mark[-2].text.begin;
1781 #line 843 "grammar.y"
1783 strcpy(yyval.text.text, "");
1784 yyval.text.begin = 0L;
1788 #line 852 "grammar.y"
1790 (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
1791 yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
1792 free(yystack.l_mark[0].decl_spec.text);
1796 #line 858 "grammar.y"
1798 (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
1799 yyval.text.begin = yystack.l_mark[-1].text.begin;
1800 free(yystack.l_mark[0].decl_spec.text);
1804 #line 868 "grammar.y"
1806 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
1810 #line 875 "grammar.y"
1812 new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
1816 #line 879 "grammar.y"
1818 add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
1822 #line 886 "grammar.y"
1824 check_untagged(&yystack.l_mark[-1].decl_spec);
1825 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1829 #line 891 "grammar.y"
1831 check_untagged(&yystack.l_mark[-1].decl_spec);
1832 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1836 #line 896 "grammar.y"
1838 check_untagged(&yystack.l_mark[0].decl_spec);
1839 yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
1843 #line 904 "grammar.y"
1845 new_ident_list(&yyval.param_list);
1849 #line 912 "grammar.y"
1851 new_ident_list(&yyval.param_list);
1852 add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
1856 #line 917 "grammar.y"
1858 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
1862 #line 924 "grammar.y"
1864 yyval.text = yystack.l_mark[0].text;
1868 #line 928 "grammar.y"
1871 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
1872 yyval.text = yystack.l_mark[0].text;
1875 (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
1876 yyval.text.begin = yystack.l_mark[-1].text.begin;
1880 #line 941 "grammar.y"
1882 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1886 #line 945 "grammar.y"
1888 yyval.declarator = yystack.l_mark[0].declarator;
1889 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
1890 free(yyval.declarator->text);
1891 yyval.declarator->text = xstrdup(buf);
1892 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1896 #line 957 "grammar.y"
1898 yyval.declarator = yystack.l_mark[-1].declarator;
1899 (void)sprintf(buf, "(%s)", yyval.declarator->text);
1900 free(yyval.declarator->text);
1901 yyval.declarator->text = xstrdup(buf);
1902 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1906 #line 965 "grammar.y"
1908 yyval.declarator = yystack.l_mark[-1].declarator;
1909 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
1910 free(yyval.declarator->text);
1911 yyval.declarator->text = xstrdup(buf);
1915 #line 972 "grammar.y"
1917 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1921 #line 976 "grammar.y"
1923 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
1924 yyval.declarator->params = yystack.l_mark[-1].param_list;
1925 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1926 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1927 yyval.declarator->func_def = FUNC_ANSI;
1931 #line 984 "grammar.y"
1933 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
1934 yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
1935 yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head;
1936 yyval.declarator->func_def = FUNC_ANSI;
1940 #line 991 "grammar.y"
1944 d = new_declarator("", "", yystack.l_mark[-2].text.begin);
1945 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin);
1946 yyval.declarator->params = yystack.l_mark[-1].param_list;
1947 yyval.declarator->func_stack = d;
1948 yyval.declarator->head = yyval.declarator;
1949 yyval.declarator->func_def = FUNC_ANSI;
1953 #line 1002 "grammar.y"
1957 d = new_declarator("", "", yystack.l_mark[-1].text.begin);
1958 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin);
1959 yyval.declarator->func_stack = d;
1960 yyval.declarator->head = yyval.declarator;
1961 yyval.declarator->func_def = FUNC_ANSI;
1964 #line 1965 "grammar.tab.c"
1966 yystack.s_mark -= yym;
1967 yystate = *yystack.s_mark;
1968 yystack.l_mark -= yym;
1970 if (yystate == 0 && yym == 0)
1974 printf("%sdebug: after reduction, shifting from state 0 to\
1975 state %d\n", YYPREFIX, YYFINAL);
1978 *++yystack.s_mark = YYFINAL;
1979 *++yystack.l_mark = yyval;
1982 if ((yychar = YYLEX) < 0) yychar = 0;
1987 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1988 if (!yys) yys = "illegal-symbol";
1989 printf("%sdebug: state %d, reading %d (%s)\n",
1990 YYPREFIX, YYFINAL, yychar, yys);
1994 if (yychar == 0) goto yyaccept;
1997 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1998 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1999 yystate = yytable[yyn];
2001 yystate = yydgoto[yym];
2004 printf("%sdebug: after reduction, shifting from state %d \
2005 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
2007 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
2011 *++yystack.s_mark = (short) yystate;
2012 *++yystack.l_mark = yyval;
2016 yyerror("yacc stack overflow");
2019 yyfreestack(&yystack);
2023 yyfreestack(&yystack);