grammar.tab.c revision 1.1.1.8 1 /* $NetBSD: grammar.tab.c,v 1.1.1.8 2026/01/18 16:39:07 christos 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 != NULL) {
382 for (p = func_params->first; p != NULL; 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 #ifndef NULL
753 #define NULL (void*)0
754 #endif
755 static const char *const grammar_name[] = {
756
757 "end-of-file",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
758 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
759 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,"'&'",NULL,"'('","')'","'*'",NULL,"','",
760 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,"';'",
761 NULL,"'='",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
762 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
763 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
764 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
765 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
766 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
767 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
768 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
769 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
770 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
771 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
772 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
773 NULL,NULL,NULL,NULL,NULL,NULL,"T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME",
774 "T_AUTO","T_EXTERN","T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE",
775 "T_EXTENSION","T_CHAR","T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT",
776 "T_SIGNED","T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex",
777 "T_Imaginary","T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE",
778 "T_ELLIPSIS","T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
779 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
780 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
781 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,"illegal-symbol",
782 };
783 static const char *const grammar_rule[] = {
784 "$accept : program",
785 "program :",
786 "program : translation_unit",
787 "translation_unit : external_declaration",
788 "translation_unit : translation_unit external_declaration",
789 "external_declaration : declaration",
790 "external_declaration : function_definition",
791 "external_declaration : ';'",
792 "external_declaration : linkage_specification",
793 "external_declaration : T_ASM T_ASMARG ';'",
794 "external_declaration : error T_MATCHRBRACE",
795 "external_declaration : error ';'",
796 "braces : T_LBRACE T_MATCHRBRACE",
797 "linkage_specification : T_EXTERN T_STRING_LITERAL braces",
798 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
799 "declaration : decl_specifiers ';'",
800 "declaration : decl_specifiers init_declarator_list ';'",
801 "$$1 :",
802 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
803 "any_typedef : T_EXTENSION T_TYPEDEF",
804 "any_typedef : T_TYPEDEF",
805 "opt_declarator_list :",
806 "opt_declarator_list : declarator_list",
807 "declarator_list : declarator",
808 "declarator_list : declarator_list ',' declarator",
809 "$$2 :",
810 "$$3 :",
811 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
812 "$$4 :",
813 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
814 "opt_declaration_list :",
815 "opt_declaration_list : T_VA_DCL",
816 "opt_declaration_list : declaration_list",
817 "declaration_list : declaration",
818 "declaration_list : declaration_list declaration",
819 "decl_specifiers : decl_specifier",
820 "decl_specifiers : decl_specifiers decl_specifier",
821 "decl_specifier : storage_class",
822 "decl_specifier : type_specifier",
823 "decl_specifier : type_qualifier",
824 "storage_class : T_AUTO",
825 "storage_class : T_EXTERN",
826 "storage_class : T_REGISTER",
827 "storage_class : T_STATIC",
828 "storage_class : T_INLINE",
829 "storage_class : T_EXTENSION",
830 "type_specifier : T_CHAR",
831 "type_specifier : T_DOUBLE",
832 "type_specifier : T_FLOAT",
833 "type_specifier : T_INT",
834 "type_specifier : T_LONG",
835 "type_specifier : T_SHORT",
836 "type_specifier : T_SIGNED",
837 "type_specifier : T_UNSIGNED",
838 "type_specifier : T_VOID",
839 "type_specifier : T_Bool",
840 "type_specifier : T_Complex",
841 "type_specifier : T_Imaginary",
842 "type_specifier : T_TYPEDEF_NAME",
843 "type_specifier : struct_or_union_specifier",
844 "type_specifier : enum_specifier",
845 "type_qualifier : T_TYPE_QUALIFIER",
846 "type_qualifier : T_DEFINE_NAME",
847 "struct_or_union_specifier : struct_or_union any_id braces",
848 "struct_or_union_specifier : struct_or_union braces",
849 "struct_or_union_specifier : struct_or_union any_id",
850 "struct_or_union : T_STRUCT",
851 "struct_or_union : T_UNION",
852 "init_declarator_list : init_declarator",
853 "init_declarator_list : init_declarator_list ',' init_declarator",
854 "init_declarator : declarator",
855 "$$5 :",
856 "init_declarator : declarator '=' $$5 T_INITIALIZER",
857 "enum_specifier : enumeration any_id braces",
858 "enum_specifier : enumeration braces",
859 "enum_specifier : enumeration any_id",
860 "enumeration : T_ENUM",
861 "any_id : T_IDENTIFIER",
862 "any_id : T_TYPEDEF_NAME",
863 "declarator : pointer direct_declarator",
864 "declarator : direct_declarator",
865 "direct_declarator : identifier_or_ref",
866 "direct_declarator : '(' declarator ')'",
867 "direct_declarator : direct_declarator T_BRACKETS",
868 "direct_declarator : direct_declarator '(' parameter_type_list ')'",
869 "direct_declarator : direct_declarator '(' opt_identifier_list ')'",
870 "pointer : '*' opt_type_qualifiers",
871 "pointer : '*' opt_type_qualifiers pointer",
872 "opt_type_qualifiers :",
873 "opt_type_qualifiers : type_qualifier_list",
874 "type_qualifier_list : type_qualifier",
875 "type_qualifier_list : type_qualifier_list type_qualifier",
876 "parameter_type_list : parameter_list",
877 "parameter_type_list : parameter_list ',' T_ELLIPSIS",
878 "parameter_list : parameter_declaration",
879 "parameter_list : parameter_list ',' parameter_declaration",
880 "parameter_declaration : decl_specifiers declarator",
881 "parameter_declaration : decl_specifiers abs_declarator",
882 "parameter_declaration : decl_specifiers",
883 "opt_identifier_list :",
884 "opt_identifier_list : identifier_list",
885 "identifier_list : any_id",
886 "identifier_list : identifier_list ',' any_id",
887 "identifier_or_ref : any_id",
888 "identifier_or_ref : '&' any_id",
889 "abs_declarator : pointer",
890 "abs_declarator : pointer direct_abs_declarator",
891 "abs_declarator : direct_abs_declarator",
892 "direct_abs_declarator : '(' abs_declarator ')'",
893 "direct_abs_declarator : direct_abs_declarator T_BRACKETS",
894 "direct_abs_declarator : T_BRACKETS",
895 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
896 "direct_abs_declarator : direct_abs_declarator '(' ')'",
897 "direct_abs_declarator : '(' parameter_type_list ')'",
898 "direct_abs_declarator : '(' ')'",
899
900 };
901 #endif
902
903 #if YYDEBUG
904 int yydebug;
905 #endif
906
907 int yyerrflag;
908 int yychar;
909 YYSTYPE yyval;
910 YYSTYPE yylval;
911 int yynerrs;
912
913 /* define the initial stack-sizes */
914 #ifdef YYSTACKSIZE
915 #undef YYMAXDEPTH
916 #define YYMAXDEPTH YYSTACKSIZE
917 #else
918 #ifdef YYMAXDEPTH
919 #define YYSTACKSIZE YYMAXDEPTH
920 #else
921 #define YYSTACKSIZE 10000
922 #define YYMAXDEPTH 10000
923 #endif
924 #endif
925
926 #define YYINITSTACKSIZE 200
927
928 typedef struct {
929 unsigned stacksize;
930 YYINT *s_base;
931 YYINT *s_mark;
932 YYINT *s_last;
933 YYSTYPE *l_base;
934 YYSTYPE *l_mark;
935 } YYSTACKDATA;
936 /* variables for the parser stack */
937 static YYSTACKDATA yystack;
938 #line 1015 "grammar.y"
939
940 /* lex.yy.c */
941 #define BEGIN yy_start = 1 + 2 *
942
943 #define CPP1 1
944 #define INIT1 2
945 #define INIT2 3
946 #define CURLY 4
947 #define LEXYACC 5
948 #define ASM 6
949 #define CPP_INLINE 7
950
951 extern char *yytext;
952 extern FILE *yyin, *yyout;
953
954 static int curly; /* number of curly brace nesting levels */
955 static int ly_count; /* number of occurrences of %% */
956 static int inc_depth; /* include nesting level */
957 static SymbolTable *included_files; /* files already included */
958 static int yy_start = 0; /* start state number */
959
960 #define grammar_error(s) yaccError(s)
961
962 static void
963 yaccError (const char *msg)
964 {
965 func_params = NULL;
966 put_error(); /* tell what line we're on, and what file */
967 fprintf(stderr, "%s at token '%s'\n", msg, yytext);
968 }
969
970 /* Initialize the table of type qualifier keywords recognized by the lexical
971 * analyzer.
972 */
973 void
974 init_parser (void)
975 {
976 static const char *keywords[] = {
977 "const",
978 "restrict",
979 "volatile",
980 "interrupt",
981 #ifdef vms
982 "noshare",
983 "readonly",
984 #endif
985 #if defined(MSDOS) || defined(OS2)
986 "__cdecl",
987 "__export",
988 "__far",
989 "__fastcall",
990 "__fortran",
991 "__huge",
992 "__inline",
993 "__interrupt",
994 "__loadds",
995 "__near",
996 "__pascal",
997 "__saveregs",
998 "__segment",
999 "__stdcall",
1000 "__syscall",
1001 "_cdecl",
1002 "_cs",
1003 "_ds",
1004 "_es",
1005 "_export",
1006 "_far",
1007 "_fastcall",
1008 "_fortran",
1009 "_huge",
1010 "_interrupt",
1011 "_loadds",
1012 "_near",
1013 "_pascal",
1014 "_saveregs",
1015 "_seg",
1016 "_segment",
1017 "_ss",
1018 "cdecl",
1019 "far",
1020 "huge",
1021 "near",
1022 "pascal",
1023 #ifdef OS2
1024 "__far16",
1025 #endif
1026 #endif
1027 #ifdef __GNUC__
1028 /* gcc aliases */
1029 "__builtin_va_arg",
1030 "__builtin_va_list",
1031 "__const",
1032 "__const__",
1033 "__inline",
1034 "__inline__",
1035 "__restrict",
1036 "__restrict__",
1037 "__volatile",
1038 "__volatile__",
1039 #endif
1040 };
1041 unsigned i;
1042
1043 /* Initialize type qualifier table. */
1044 type_qualifiers = new_symbol_table();
1045 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
1046 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
1047 }
1048 }
1049
1050 /* Process the C source file. Write function prototypes to the standard
1051 * output. Convert function definitions and write the converted source
1052 * code to a temporary file.
1053 */
1054 void
1055 process_file (FILE *infile, char *name)
1056 {
1057 char *s;
1058
1059 if (strlen(name) > 2) {
1060 s = name + strlen(name) - 2;
1061 if (*s == '.') {
1062 ++s;
1063 if (*s == 'l' || *s == 'y')
1064 BEGIN LEXYACC;
1065 #if defined(MSDOS) || defined(OS2)
1066 if (*s == 'L' || *s == 'Y')
1067 BEGIN LEXYACC;
1068 #endif
1069 }
1070 }
1071
1072 included_files = new_symbol_table();
1073 typedef_names = new_symbol_table();
1074 define_names = new_symbol_table();
1075 inc_depth = -1;
1076 curly = 0;
1077 ly_count = 0;
1078 func_params = NULL;
1079 yyin = infile;
1080 include_file(strcpy(base_file, name), func_style != FUNC_NONE);
1081 if (file_comments) {
1082 #if OPT_LINTLIBRARY
1083 if (lintLibrary()) {
1084 put_blankline(stdout);
1085 begin_tracking();
1086 }
1087 #endif
1088 put_string(stdout, "/* ");
1089 put_string(stdout, cur_file_name());
1090 put_string(stdout, " */\n");
1091 }
1092 yyparse();
1093 free_symbol_table(define_names);
1094 free_symbol_table(typedef_names);
1095 free_symbol_table(included_files);
1096 }
1097
1098 #ifdef NO_LEAKS
1099 void
1100 free_parser(void)
1101 {
1102 free_symbol_table (type_qualifiers);
1103 #ifdef FLEX_SCANNER
1104 if (yy_current_buffer != 0)
1105 yy_delete_buffer(yy_current_buffer);
1106 #endif
1107 }
1108 #endif
1109 #line 1108 "grammar.tab.c"
1110
1111 #if YYDEBUG
1112 #include <stdio.h> /* needed for printf */
1113 #endif
1114
1115 #include <stdlib.h> /* needed for malloc, etc */
1116 #include <string.h> /* needed for memset */
1117
1118 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1119 static int yygrowstack(YYSTACKDATA *data)
1120 {
1121 int i;
1122 unsigned newsize;
1123 YYINT *newss;
1124 YYSTYPE *newvs;
1125
1126 if ((newsize = data->stacksize) == 0)
1127 newsize = YYINITSTACKSIZE;
1128 else if (newsize >= YYMAXDEPTH)
1129 return YYENOMEM;
1130 else if ((newsize *= 2) > YYMAXDEPTH)
1131 newsize = YYMAXDEPTH;
1132
1133 i = (int) (data->s_mark - data->s_base);
1134 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1135 if (newss == NULL)
1136 return YYENOMEM;
1137
1138 data->s_base = newss;
1139 data->s_mark = newss + i;
1140
1141 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1142 if (newvs == NULL)
1143 return YYENOMEM;
1144
1145 data->l_base = newvs;
1146 data->l_mark = newvs + i;
1147
1148 data->stacksize = newsize;
1149 data->s_last = data->s_base + newsize - 1;
1150 return 0;
1151 }
1152
1153 #if YYPURE || defined(YY_NO_LEAKS)
1154 static void yyfreestack(YYSTACKDATA *data)
1155 {
1156 free(data->s_base);
1157 free(data->l_base);
1158 memset(data, 0, sizeof(*data));
1159 }
1160 #else
1161 #define yyfreestack(data) /* nothing */
1162 #endif
1163
1164 #define YYABORT goto yyabort
1165 #define YYREJECT goto yyabort
1166 #define YYACCEPT goto yyaccept
1167 #define YYERROR goto yyerrlab
1168
1169 int
1170 YYPARSE_DECL()
1171 {
1172 int yym, yyn, yystate;
1173 #if YYDEBUG
1174 const char *yys;
1175
1176 if ((yys = getenv("YYDEBUG")) != NULL)
1177 {
1178 yyn = *yys;
1179 if (yyn >= '0' && yyn <= '9')
1180 yydebug = yyn - '0';
1181 }
1182 #endif
1183
1184 /* yym is set below */
1185 /* yyn is set below */
1186 yynerrs = 0;
1187 yyerrflag = 0;
1188 yychar = YYEMPTY;
1189 yystate = 0;
1190
1191 #if YYPURE
1192 memset(&yystack, 0, sizeof(yystack));
1193 #endif
1194
1195 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1196 yystack.s_mark = yystack.s_base;
1197 yystack.l_mark = yystack.l_base;
1198 yystate = 0;
1199 *yystack.s_mark = 0;
1200
1201 yyloop:
1202 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1203 if (yychar < 0)
1204 {
1205 yychar = YYLEX;
1206 if (yychar < 0) yychar = YYEOF;
1207 #if YYDEBUG
1208 if (yydebug)
1209 {
1210 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1211 printf("%sdebug: state %d, reading %d (%s)\n",
1212 YYPREFIX, yystate, yychar, yys);
1213 }
1214 #endif
1215 }
1216 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1217 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1218 {
1219 #if YYDEBUG
1220 if (yydebug)
1221 printf("%sdebug: state %d, shifting to state %d\n",
1222 YYPREFIX, yystate, yytable[yyn]);
1223 #endif
1224 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1225 yystate = yytable[yyn];
1226 *++yystack.s_mark = yytable[yyn];
1227 *++yystack.l_mark = yylval;
1228 yychar = YYEMPTY;
1229 if (yyerrflag > 0) --yyerrflag;
1230 goto yyloop;
1231 }
1232 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1233 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1234 {
1235 yyn = yytable[yyn];
1236 goto yyreduce;
1237 }
1238 if (yyerrflag != 0) goto yyinrecovery;
1239
1240 YYERROR_CALL("syntax error");
1241
1242 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1243 yyerrlab:
1244 ++yynerrs;
1245
1246 yyinrecovery:
1247 if (yyerrflag < 3)
1248 {
1249 yyerrflag = 3;
1250 for (;;)
1251 {
1252 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1253 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1254 {
1255 #if YYDEBUG
1256 if (yydebug)
1257 printf("%sdebug: state %d, error recovery shifting\
1258 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
1259 #endif
1260 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1261 yystate = yytable[yyn];
1262 *++yystack.s_mark = yytable[yyn];
1263 *++yystack.l_mark = yylval;
1264 goto yyloop;
1265 }
1266 else
1267 {
1268 #if YYDEBUG
1269 if (yydebug)
1270 printf("%sdebug: error recovery discarding state %d\n",
1271 YYPREFIX, *yystack.s_mark);
1272 #endif
1273 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1274 --yystack.s_mark;
1275 --yystack.l_mark;
1276 }
1277 }
1278 }
1279 else
1280 {
1281 if (yychar == YYEOF) goto yyabort;
1282 #if YYDEBUG
1283 if (yydebug)
1284 {
1285 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1286 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1287 YYPREFIX, yystate, yychar, yys);
1288 }
1289 #endif
1290 yychar = YYEMPTY;
1291 goto yyloop;
1292 }
1293
1294 yyreduce:
1295 #if YYDEBUG
1296 if (yydebug)
1297 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1298 YYPREFIX, yystate, yyn, yyrule[yyn]);
1299 #endif
1300 yym = yylen[yyn];
1301 if (yym > 0)
1302 yyval = yystack.l_mark[1-yym];
1303 else
1304 memset(&yyval, 0, sizeof yyval);
1305
1306 switch (yyn)
1307 {
1308 case 10:
1309 #line 378 "grammar.y"
1310 {
1311 yyerrok;
1312 }
1313 #line 1312 "grammar.tab.c"
1314 break;
1315 case 11:
1316 #line 382 "grammar.y"
1317 {
1318 yyerrok;
1319 }
1320 #line 1319 "grammar.tab.c"
1321 break;
1322 case 13:
1323 #line 393 "grammar.y"
1324 {
1325 /* Provide an empty action here so bison will not complain about
1326 * incompatible types in the default action it normally would
1327 * have generated.
1328 */
1329 }
1330 #line 1329 "grammar.tab.c"
1331 break;
1332 case 14:
1333 #line 400 "grammar.y"
1334 {
1335 /* empty */
1336 }
1337 #line 1336 "grammar.tab.c"
1338 break;
1339 case 15:
1340 #line 407 "grammar.y"
1341 {
1342 #if OPT_LINTLIBRARY
1343 if (types_out && want_typedef()) {
1344 gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0);
1345 flush_varargs();
1346 }
1347 #endif
1348 free_decl_spec(&yystack.l_mark[-1].decl_spec);
1349 end_typedef();
1350 }
1351 #line 1350 "grammar.tab.c"
1352 break;
1353 case 16:
1354 #line 418 "grammar.y"
1355 {
1356 if (func_params != NULL) {
1357 set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1358 } else {
1359 gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
1360 #if OPT_LINTLIBRARY
1361 flush_varargs();
1362 #endif
1363 free_decl_list(&yystack.l_mark[-1].decl_list);
1364 }
1365 free_decl_spec(&yystack.l_mark[-2].decl_spec);
1366 end_typedef();
1367 }
1368 #line 1367 "grammar.tab.c"
1369 break;
1370 case 17:
1371 #line 432 "grammar.y"
1372 {
1373 cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
1374 free_decl_spec(&yystack.l_mark[0].decl_spec);
1375 }
1376 #line 1375 "grammar.tab.c"
1377 break;
1378 case 18:
1379 #line 437 "grammar.y"
1380 {
1381 end_typedef();
1382 }
1383 #line 1382 "grammar.tab.c"
1384 break;
1385 case 19:
1386 #line 444 "grammar.y"
1387 {
1388 begin_typedef();
1389 }
1390 #line 1389 "grammar.tab.c"
1391 break;
1392 case 20:
1393 #line 448 "grammar.y"
1394 {
1395 begin_typedef();
1396 }
1397 #line 1396 "grammar.tab.c"
1398 break;
1399 case 23:
1400 #line 460 "grammar.y"
1401 {
1402 int flags = cur_decl_spec_flags;
1403
1404 /* If the typedef is a pointer type, then reset the short type
1405 * flags so it does not get promoted.
1406 */
1407 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1408 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1409 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1410 free_declarator(yystack.l_mark[0].declarator);
1411 }
1412 #line 1411 "grammar.tab.c"
1413 break;
1414 case 24:
1415 #line 472 "grammar.y"
1416 {
1417 int flags = cur_decl_spec_flags;
1418
1419 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
1420 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
1421 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
1422 free_declarator(yystack.l_mark[0].declarator);
1423 }
1424 #line 1423 "grammar.tab.c"
1425 break;
1426 case 25:
1427 #line 484 "grammar.y"
1428 {
1429 check_untagged(&yystack.l_mark[-1].decl_spec);
1430 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1431 yyerror("syntax error");
1432 YYERROR;
1433 }
1434 func_params = &(yystack.l_mark[0].declarator->head->params);
1435 func_params->begin_comment = cur_file->begin_comment;
1436 func_params->end_comment = cur_file->end_comment;
1437 }
1438 #line 1437 "grammar.tab.c"
1439 break;
1440 case 26:
1441 #line 495 "grammar.y"
1442 {
1443 /* If we're converting to K&R and we've got a nominally K&R
1444 * function which has a parameter which is ANSI (i.e., a prototyped
1445 * function pointer), then we must override the deciphered value of
1446 * 'func_def' so that the parameter will be converted.
1447 */
1448 if (func_style == FUNC_TRADITIONAL
1449 && haveAnsiParam()
1450 && yystack.l_mark[-3].declarator->head->func_def == func_style) {
1451 yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH;
1452 }
1453
1454 func_params = NULL;
1455
1456 if (cur_file->convert)
1457 gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1458 gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
1459 #if OPT_LINTLIBRARY
1460 flush_varargs();
1461 #endif
1462 free_decl_spec(&yystack.l_mark[-4].decl_spec);
1463 free_declarator(yystack.l_mark[-3].declarator);
1464 }
1465 #line 1464 "grammar.tab.c"
1466 break;
1467 case 28:
1468 #line 520 "grammar.y"
1469 {
1470 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
1471 yyerror("syntax error");
1472 YYERROR;
1473 }
1474 func_params = &(yystack.l_mark[0].declarator->head->params);
1475 func_params->begin_comment = cur_file->begin_comment;
1476 func_params->end_comment = cur_file->end_comment;
1477 }
1478 #line 1477 "grammar.tab.c"
1479 break;
1480 case 29:
1481 #line 530 "grammar.y"
1482 {
1483 DeclSpec decl_spec;
1484
1485 func_params = NULL;
1486
1487 new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE);
1488 if (cur_file->convert)
1489 gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator);
1490 gen_prototype(&decl_spec, yystack.l_mark[-4].declarator);
1491 #if OPT_LINTLIBRARY
1492 flush_varargs();
1493 #endif
1494 free_decl_spec(&decl_spec);
1495 free_declarator(yystack.l_mark[-4].declarator);
1496 }
1497 #line 1496 "grammar.tab.c"
1498 break;
1499 case 36:
1500 #line 561 "grammar.y"
1501 {
1502 join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
1503 free(yystack.l_mark[-1].decl_spec.text);
1504 free(yystack.l_mark[0].decl_spec.text);
1505 }
1506 #line 1505 "grammar.tab.c"
1507 break;
1508 case 40:
1509 #line 576 "grammar.y"
1510 {
1511 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1512 }
1513 #line 1512 "grammar.tab.c"
1514 break;
1515 case 41:
1516 #line 580 "grammar.y"
1517 {
1518 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
1519 }
1520 #line 1519 "grammar.tab.c"
1521 break;
1522 case 42:
1523 #line 584 "grammar.y"
1524 {
1525 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1526 }
1527 #line 1526 "grammar.tab.c"
1528 break;
1529 case 43:
1530 #line 588 "grammar.y"
1531 {
1532 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
1533 }
1534 #line 1533 "grammar.tab.c"
1535 break;
1536 case 44:
1537 #line 592 "grammar.y"
1538 {
1539 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
1540 }
1541 #line 1540 "grammar.tab.c"
1542 break;
1543 case 45:
1544 #line 596 "grammar.y"
1545 {
1546 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
1547 }
1548 #line 1547 "grammar.tab.c"
1549 break;
1550 case 46:
1551 #line 603 "grammar.y"
1552 {
1553 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1554 }
1555 #line 1554 "grammar.tab.c"
1556 break;
1557 case 47:
1558 #line 607 "grammar.y"
1559 {
1560 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1561 }
1562 #line 1561 "grammar.tab.c"
1563 break;
1564 case 48:
1565 #line 611 "grammar.y"
1566 {
1567 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
1568 }
1569 #line 1568 "grammar.tab.c"
1570 break;
1571 case 49:
1572 #line 615 "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 #line 1575 "grammar.tab.c"
1577 break;
1578 case 50:
1579 #line 619 "grammar.y"
1580 {
1581 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1582 }
1583 #line 1582 "grammar.tab.c"
1584 break;
1585 case 51:
1586 #line 623 "grammar.y"
1587 {
1588 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
1589 }
1590 #line 1589 "grammar.tab.c"
1591 break;
1592 case 52:
1593 #line 627 "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 #line 1596 "grammar.tab.c"
1598 break;
1599 case 53:
1600 #line 631 "grammar.y"
1601 {
1602 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1603 }
1604 #line 1603 "grammar.tab.c"
1605 break;
1606 case 54:
1607 #line 635 "grammar.y"
1608 {
1609 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1610 }
1611 #line 1610 "grammar.tab.c"
1612 break;
1613 case 55:
1614 #line 639 "grammar.y"
1615 {
1616 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
1617 }
1618 #line 1617 "grammar.tab.c"
1619 break;
1620 case 56:
1621 #line 643 "grammar.y"
1622 {
1623 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1624 }
1625 #line 1624 "grammar.tab.c"
1626 break;
1627 case 57:
1628 #line 647 "grammar.y"
1629 {
1630 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1631 }
1632 #line 1631 "grammar.tab.c"
1633 break;
1634 case 58:
1635 #line 651 "grammar.y"
1636 {
1637 Symbol *s;
1638 s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
1639 if (s != NULL)
1640 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1641 }
1642 #line 1641 "grammar.tab.c"
1643 break;
1644 case 61:
1645 #line 663 "grammar.y"
1646 {
1647 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
1648 }
1649 #line 1648 "grammar.tab.c"
1650 break;
1651 case 62:
1652 #line 667 "grammar.y"
1653 {
1654 /* This rule allows the <pointer> nonterminal to scan #define
1655 * names as if they were type modifiers.
1656 */
1657 Symbol *s;
1658 s = find_symbol(define_names, yystack.l_mark[0].text.text);
1659 if (s != NULL)
1660 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
1661 }
1662 #line 1661 "grammar.tab.c"
1663 break;
1664 case 63:
1665 #line 680 "grammar.y"
1666 {
1667 char *s;
1668 if ((s = implied_typedef()) == NULL)
1669 (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text);
1670 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1671 }
1672 #line 1671 "grammar.tab.c"
1673 break;
1674 case 64:
1675 #line 687 "grammar.y"
1676 {
1677 char *s;
1678 if ((s = implied_typedef()) == NULL)
1679 (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text);
1680 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1681 }
1682 #line 1681 "grammar.tab.c"
1683 break;
1684 case 65:
1685 #line 694 "grammar.y"
1686 {
1687 (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text);
1688 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1689 }
1690 #line 1689 "grammar.tab.c"
1691 break;
1692 case 66:
1693 #line 702 "grammar.y"
1694 {
1695 imply_typedef(yyval.text.text);
1696 }
1697 #line 1696 "grammar.tab.c"
1698 break;
1699 case 67:
1700 #line 706 "grammar.y"
1701 {
1702 imply_typedef(yyval.text.text);
1703 }
1704 #line 1703 "grammar.tab.c"
1705 break;
1706 case 68:
1707 #line 713 "grammar.y"
1708 {
1709 new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
1710 }
1711 #line 1710 "grammar.tab.c"
1712 break;
1713 case 69:
1714 #line 717 "grammar.y"
1715 {
1716 add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
1717 }
1718 #line 1717 "grammar.tab.c"
1719 break;
1720 case 70:
1721 #line 724 "grammar.y"
1722 {
1723 if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
1724 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1725 gen_func_declarator(yystack.l_mark[0].declarator);
1726 fputs(cur_text(), cur_file->tmp_file);
1727 }
1728 cur_declarator = yyval.declarator;
1729 }
1730 #line 1729 "grammar.tab.c"
1731 break;
1732 case 71:
1733 #line 733 "grammar.y"
1734 {
1735 if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
1736 func_style == FUNC_TRADITIONAL && cur_file->convert) {
1737 gen_func_declarator(yystack.l_mark[-1].declarator);
1738 fputs(" =", cur_file->tmp_file);
1739 }
1740 }
1741 #line 1740 "grammar.tab.c"
1742 break;
1743 case 73:
1744 #line 745 "grammar.y"
1745 {
1746 char *s;
1747 if ((s = implied_typedef()) == NULL)
1748 (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text);
1749 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
1750 }
1751 #line 1750 "grammar.tab.c"
1752 break;
1753 case 74:
1754 #line 752 "grammar.y"
1755 {
1756 char *s;
1757 if ((s = implied_typedef()) == NULL)
1758 (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text);
1759 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
1760 }
1761 #line 1760 "grammar.tab.c"
1762 break;
1763 case 75:
1764 #line 759 "grammar.y"
1765 {
1766 (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text);
1767 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
1768 }
1769 #line 1768 "grammar.tab.c"
1770 break;
1771 case 76:
1772 #line 767 "grammar.y"
1773 {
1774 imply_typedef("enum");
1775 yyval.text = yystack.l_mark[0].text;
1776 }
1777 #line 1776 "grammar.tab.c"
1778 break;
1779 case 79:
1780 #line 780 "grammar.y"
1781 {
1782 yyval.declarator = yystack.l_mark[0].declarator;
1783 (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text);
1784 free(yyval.declarator->text);
1785 yyval.declarator->text = xstrdup(buf);
1786 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1787 yyval.declarator->pointer = TRUE;
1788 }
1789 #line 1788 "grammar.tab.c"
1790 break;
1791 case 81:
1792 #line 793 "grammar.y"
1793 {
1794 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
1795 }
1796 #line 1795 "grammar.tab.c"
1797 break;
1798 case 82:
1799 #line 797 "grammar.y"
1800 {
1801 yyval.declarator = yystack.l_mark[-1].declarator;
1802 (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text);
1803 free(yyval.declarator->text);
1804 yyval.declarator->text = xstrdup(buf);
1805 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1806 }
1807 #line 1806 "grammar.tab.c"
1808 break;
1809 case 83:
1810 #line 805 "grammar.y"
1811 {
1812 yyval.declarator = yystack.l_mark[-1].declarator;
1813 (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text);
1814 free(yyval.declarator->text);
1815 yyval.declarator->text = xstrdup(buf);
1816 }
1817 #line 1816 "grammar.tab.c"
1818 break;
1819 case 84:
1820 #line 812 "grammar.y"
1821 {
1822 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1823 yyval.declarator->params = yystack.l_mark[-1].param_list;
1824 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1825 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1826 yyval.declarator->func_def = FUNC_ANSI;
1827 }
1828 #line 1827 "grammar.tab.c"
1829 break;
1830 case 85:
1831 #line 820 "grammar.y"
1832 {
1833 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
1834 yyval.declarator->params = yystack.l_mark[-1].param_list;
1835 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
1836 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
1837 yyval.declarator->func_def = FUNC_TRADITIONAL;
1838 }
1839 #line 1838 "grammar.tab.c"
1840 break;
1841 case 86:
1842 #line 831 "grammar.y"
1843 {
1844 (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text);
1845 yyval.text.begin = yystack.l_mark[-1].text.begin;
1846 }
1847 #line 1846 "grammar.tab.c"
1848 break;
1849 case 87:
1850 #line 836 "grammar.y"
1851 {
1852 (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text);
1853 yyval.text.begin = yystack.l_mark[-2].text.begin;
1854 }
1855 #line 1854 "grammar.tab.c"
1856 break;
1857 case 88:
1858 #line 844 "grammar.y"
1859 {
1860 strcpy(yyval.text.text, "");
1861 yyval.text.begin = 0L;
1862 }
1863 #line 1862 "grammar.tab.c"
1864 break;
1865 case 90:
1866 #line 853 "grammar.y"
1867 {
1868 (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
1869 yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
1870 free(yystack.l_mark[0].decl_spec.text);
1871 }
1872 #line 1871 "grammar.tab.c"
1873 break;
1874 case 91:
1875 #line 859 "grammar.y"
1876 {
1877 (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text);
1878 yyval.text.begin = yystack.l_mark[-1].text.begin;
1879 free(yystack.l_mark[0].decl_spec.text);
1880 }
1881 #line 1880 "grammar.tab.c"
1882 break;
1883 case 93:
1884 #line 869 "grammar.y"
1885 {
1886 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
1887 }
1888 #line 1887 "grammar.tab.c"
1889 break;
1890 case 94:
1891 #line 876 "grammar.y"
1892 {
1893 new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
1894 }
1895 #line 1894 "grammar.tab.c"
1896 break;
1897 case 95:
1898 #line 880 "grammar.y"
1899 {
1900 add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
1901 }
1902 #line 1901 "grammar.tab.c"
1903 break;
1904 case 96:
1905 #line 887 "grammar.y"
1906 {
1907 check_untagged(&yystack.l_mark[-1].decl_spec);
1908 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1909 }
1910 #line 1909 "grammar.tab.c"
1911 break;
1912 case 97:
1913 #line 892 "grammar.y"
1914 {
1915 check_untagged(&yystack.l_mark[-1].decl_spec);
1916 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
1917 }
1918 #line 1917 "grammar.tab.c"
1919 break;
1920 case 98:
1921 #line 897 "grammar.y"
1922 {
1923 check_untagged(&yystack.l_mark[0].decl_spec);
1924 yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
1925 }
1926 #line 1925 "grammar.tab.c"
1927 break;
1928 case 99:
1929 #line 905 "grammar.y"
1930 {
1931 new_ident_list(&yyval.param_list);
1932 }
1933 #line 1932 "grammar.tab.c"
1934 break;
1935 case 101:
1936 #line 913 "grammar.y"
1937 {
1938 new_ident_list(&yyval.param_list);
1939 add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
1940 }
1941 #line 1940 "grammar.tab.c"
1942 break;
1943 case 102:
1944 #line 918 "grammar.y"
1945 {
1946 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
1947 }
1948 #line 1947 "grammar.tab.c"
1949 break;
1950 case 103:
1951 #line 925 "grammar.y"
1952 {
1953 yyval.text = yystack.l_mark[0].text;
1954 }
1955 #line 1954 "grammar.tab.c"
1956 break;
1957 case 104:
1958 #line 929 "grammar.y"
1959 {
1960 #if OPT_LINTLIBRARY
1961 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
1962 yyval.text = yystack.l_mark[0].text;
1963 } else
1964 #endif
1965 (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text);
1966 yyval.text.begin = yystack.l_mark[-1].text.begin;
1967 }
1968 #line 1967 "grammar.tab.c"
1969 break;
1970 case 105:
1971 #line 942 "grammar.y"
1972 {
1973 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
1974 }
1975 #line 1974 "grammar.tab.c"
1976 break;
1977 case 106:
1978 #line 946 "grammar.y"
1979 {
1980 yyval.declarator = yystack.l_mark[0].declarator;
1981 (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text);
1982 free(yyval.declarator->text);
1983 yyval.declarator->text = xstrdup(buf);
1984 yyval.declarator->begin = yystack.l_mark[-1].text.begin;
1985 }
1986 #line 1985 "grammar.tab.c"
1987 break;
1988 case 108:
1989 #line 958 "grammar.y"
1990 {
1991 yyval.declarator = yystack.l_mark[-1].declarator;
1992 (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text);
1993 free(yyval.declarator->text);
1994 yyval.declarator->text = xstrdup(buf);
1995 yyval.declarator->begin = yystack.l_mark[-2].text.begin;
1996 }
1997 #line 1996 "grammar.tab.c"
1998 break;
1999 case 109:
2000 #line 966 "grammar.y"
2001 {
2002 yyval.declarator = yystack.l_mark[-1].declarator;
2003 (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text);
2004 free(yyval.declarator->text);
2005 yyval.declarator->text = xstrdup(buf);
2006 }
2007 #line 2006 "grammar.tab.c"
2008 break;
2009 case 110:
2010 #line 973 "grammar.y"
2011 {
2012 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
2013 }
2014 #line 2013 "grammar.tab.c"
2015 break;
2016 case 111:
2017 #line 977 "grammar.y"
2018 {
2019 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
2020 yyval.declarator->params = yystack.l_mark[-1].param_list;
2021 yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
2022 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
2023 yyval.declarator->func_def = FUNC_ANSI;
2024 }
2025 #line 2024 "grammar.tab.c"
2026 break;
2027 case 112:
2028 #line 985 "grammar.y"
2029 {
2030 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
2031 yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
2032 yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head;
2033 yyval.declarator->func_def = FUNC_ANSI;
2034 }
2035 #line 2034 "grammar.tab.c"
2036 break;
2037 case 113:
2038 #line 992 "grammar.y"
2039 {
2040 Declarator *d;
2041
2042 d = new_declarator("", "", yystack.l_mark[-2].text.begin);
2043 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin);
2044 yyval.declarator->params = yystack.l_mark[-1].param_list;
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 case 114:
2052 #line 1003 "grammar.y"
2053 {
2054 Declarator *d;
2055
2056 d = new_declarator("", "", yystack.l_mark[-1].text.begin);
2057 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin);
2058 yyval.declarator->func_stack = d;
2059 yyval.declarator->head = yyval.declarator;
2060 yyval.declarator->func_def = FUNC_ANSI;
2061 }
2062 #line 2061 "grammar.tab.c"
2063 break;
2064 #line 2063 "grammar.tab.c"
2065 }
2066 yystack.s_mark -= yym;
2067 yystate = *yystack.s_mark;
2068 yystack.l_mark -= yym;
2069 yym = yylhs[yyn];
2070 if (yystate == 0 && yym == 0)
2071 {
2072 #if YYDEBUG
2073 if (yydebug)
2074 printf("%sdebug: after reduction, shifting from state 0 to\
2075 state %d\n", YYPREFIX, YYFINAL);
2076 #endif
2077 yystate = YYFINAL;
2078 *++yystack.s_mark = YYFINAL;
2079 *++yystack.l_mark = yyval;
2080 if (yychar < 0)
2081 {
2082 yychar = YYLEX;
2083 if (yychar < 0) yychar = YYEOF;
2084 #if YYDEBUG
2085 if (yydebug)
2086 {
2087 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2088 printf("%sdebug: state %d, reading %d (%s)\n",
2089 YYPREFIX, YYFINAL, yychar, yys);
2090 }
2091 #endif
2092 }
2093 if (yychar == YYEOF) goto yyaccept;
2094 goto yyloop;
2095 }
2096 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2097 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2098 yystate = yytable[yyn];
2099 else
2100 yystate = yydgoto[yym];
2101 #if YYDEBUG
2102 if (yydebug)
2103 printf("%sdebug: after reduction, shifting from state %d \
2104 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
2105 #endif
2106 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2107 *++yystack.s_mark = (YYINT) yystate;
2108 *++yystack.l_mark = yyval;
2109 goto yyloop;
2110
2111 yyoverflow:
2112 YYERROR_CALL("yacc stack overflow");
2113
2114 yyabort:
2115 yyfreestack(&yystack);
2116 return (1);
2117
2118 yyaccept:
2119 yyfreestack(&yystack);
2120 return (0);
2121 }
2122