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