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