1 /* original parser id follows */ 2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4 5 #define YYBYACC 1 6 #define YYMAJOR 1 7 #define YYMINOR 9 8 #define YYCHECK "yyyymmdd" 9 10 #define YYEMPTY (-1) 11 #define yyclearin (yychar = YYEMPTY) 12 #define yyerrok (yyerrflag = 0) 13 #define YYRECOVERING() (yyerrflag != 0) 14 #define YYENOMEM (-2) 15 #define YYEOF 0 16 #undef YYBTYACC 17 #define YYBTYACC 0 18 #define YYDEBUGSTR YYPREFIX "debug" 19 20 #ifndef yyparse 21 #define yyparse grammar_parse 22 #endif /* yyparse */ 23 24 #ifndef yylex 25 #define yylex grammar_lex 26 #endif /* yylex */ 27 28 #ifndef yyerror 29 #define yyerror grammar_error 30 #endif /* yyerror */ 31 32 #ifndef yychar 33 #define yychar grammar_char 34 #endif /* yychar */ 35 36 #ifndef yyval 37 #define yyval grammar_val 38 #endif /* yyval */ 39 40 #ifndef yylval 41 #define yylval grammar_lval 42 #endif /* yylval */ 43 44 #ifndef yydebug 45 #define yydebug grammar_debug 46 #endif /* yydebug */ 47 48 #ifndef yynerrs 49 #define yynerrs grammar_nerrs 50 #endif /* yynerrs */ 51 52 #ifndef yyerrflag 53 #define yyerrflag grammar_errflag 54 #endif /* yyerrflag */ 55 56 #ifndef yylhs 57 #define yylhs grammar_lhs 58 #endif /* yylhs */ 59 60 #ifndef yylen 61 #define yylen grammar_len 62 #endif /* yylen */ 63 64 #ifndef yydefred 65 #define yydefred grammar_defred 66 #endif /* yydefred */ 67 68 #ifndef yystos 69 #define yystos grammar_stos 70 #endif /* yystos */ 71 72 #ifndef yydgoto 73 #define yydgoto grammar_dgoto 74 #endif /* yydgoto */ 75 76 #ifndef yysindex 77 #define yysindex grammar_sindex 78 #endif /* yysindex */ 79 80 #ifndef yyrindex 81 #define yyrindex grammar_rindex 82 #endif /* yyrindex */ 83 84 #ifndef yygindex 85 #define yygindex grammar_gindex 86 #endif /* yygindex */ 87 88 #ifndef yytable 89 #define yytable grammar_table 90 #endif /* yytable */ 91 92 #ifndef yycheck 93 #define yycheck grammar_check 94 #endif /* yycheck */ 95 96 #ifndef yyname 97 #define yyname grammar_name 98 #endif /* yyname */ 99 100 #ifndef yyrule 101 #define yyrule grammar_rule 102 #endif /* yyrule */ 103 104 #if YYBTYACC 105 106 #ifndef yycindex 107 #define yycindex grammar_cindex 108 #endif /* yycindex */ 109 110 #ifndef yyctable 111 #define yyctable grammar_ctable 112 #endif /* yyctable */ 113 114 #endif /* YYBTYACC */ 115 116 #define YYPREFIX "grammar_" 117 118 #define YYPURE 0 119 120 #line 9 "grammar.y" 121 #ifdef YYBISON 122 #include <stdlib.h> 123 #define YYSTYPE_IS_DECLARED 124 #define yyerror yaccError 125 #endif 126 127 #if defined(YYBISON) || !defined(YYBYACC) 128 static void yyerror(const char *s); 129 #endif 130 #line 81 "grammar.y" 131 #include <stdio.h> 132 #include <ctype.h> 133 #include <string.h> 134 135 #define OPT_LINTLIBRARY 1 136 137 #ifndef TRUE 138 #define TRUE (1) 139 #endif 140 141 #ifndef FALSE 142 #define FALSE (0) 143 #endif 144 145 /* #include "cproto.h" */ 146 #define MAX_TEXT_SIZE 1024 147 148 /* Prototype styles */ 149 #if OPT_LINTLIBRARY 150 #define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */ 151 #define PROTO_LINTLIBRARY -1 /* form lint-library source */ 152 #endif 153 #define PROTO_NONE 0 /* do not output any prototypes */ 154 #define PROTO_TRADITIONAL 1 /* comment out parameters */ 155 #define PROTO_ABSTRACT 2 /* comment out parameter names */ 156 #define PROTO_ANSI 3 /* ANSI C prototype */ 157 158 typedef int PrototypeStyle; 159 160 typedef char boolean; 161 162 extern boolean types_out; 163 extern PrototypeStyle proto_style; 164 165 #define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB) 166 #define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY) 167 #define lintLibrary() (knrLintLibrary() || ansiLintLibrary()) 168 169 #if OPT_LINTLIBRARY 170 #define FUNC_UNKNOWN -1 /* unspecified */ 171 #else 172 #define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */ 173 #endif 174 #define FUNC_NONE 0 /* not a function definition */ 175 #define FUNC_TRADITIONAL 1 /* traditional style */ 176 #define FUNC_ANSI 2 /* ANSI style */ 177 #define FUNC_BOTH 3 /* both styles */ 178 179 typedef int FuncDefStyle; 180 181 /* Source file text */ 182 typedef struct text { 183 char text[MAX_TEXT_SIZE]; /* source text */ 184 long begin; /* offset in temporary file */ 185 } Text; 186 187 /* Declaration specifier flags */ 188 #define DS_NONE 0 /* default */ 189 #define DS_EXTERN 1 /* contains "extern" specifier */ 190 #define DS_STATIC 2 /* contains "static" specifier */ 191 #define DS_CHAR 4 /* contains "char" type specifier */ 192 #define DS_SHORT 8 /* contains "short" type specifier */ 193 #define DS_FLOAT 16 /* contains "float" type specifier */ 194 #define DS_INLINE 32 /* contains "inline" specifier */ 195 #define DS_JUNK 64 /* we're not interested in this declaration */ 196 197 /* This structure stores information about a declaration specifier. */ 198 typedef struct decl_spec { 199 unsigned short flags; /* flags defined above */ 200 char *text; /* source text */ 201 long begin; /* offset in temporary file */ 202 } DeclSpec; 203 204 /* This is a list of function parameters. */ 205 typedef struct _ParameterList { 206 struct parameter *first; /* pointer to first parameter in list */ 207 struct parameter *last; /* pointer to last parameter in list */ 208 long begin_comment; /* begin offset of comment */ 209 long end_comment; /* end offset of comment */ 210 char *comment; /* comment at start of parameter list */ 211 } ParameterList; 212 213 /* This structure stores information about a declarator. */ 214 typedef struct _Declarator { 215 char *name; /* name of variable or function */ 216 char *text; /* source text */ 217 long begin; /* offset in temporary file */ 218 long begin_comment; /* begin offset of comment */ 219 long end_comment; /* end offset of comment */ 220 FuncDefStyle func_def; /* style of function definition */ 221 ParameterList params; /* function parameters */ 222 boolean pointer; /* TRUE if it declares a pointer */ 223 struct _Declarator *head; /* head function declarator */ 224 struct _Declarator *func_stack; /* stack of function declarators */ 225 struct _Declarator *next; /* next declarator in list */ 226 } Declarator; 227 228 /* This structure stores information about a function parameter. */ 229 typedef struct parameter { 230 struct parameter *next; /* next parameter in list */ 231 DeclSpec decl_spec; 232 Declarator *declarator; 233 char *comment; /* comment following the parameter */ 234 } Parameter; 235 236 /* This is a list of declarators. */ 237 typedef struct declarator_list { 238 Declarator *first; /* pointer to first declarator in list */ 239 Declarator *last; /* pointer to last declarator in list */ 240 } DeclaratorList; 241 242 /* #include "symbol.h" */ 243 typedef struct symbol { 244 struct symbol *next; /* next symbol in list */ 245 char *name; /* name of symbol */ 246 char *value; /* value of symbol (for defines) */ 247 short flags; /* symbol attributes */ 248 } Symbol; 249 250 /* parser stack entry type */ 251 typedef union { 252 Text text; 253 DeclSpec decl_spec; 254 Parameter *parameter; 255 ParameterList param_list; 256 Declarator *declarator; 257 DeclaratorList decl_list; 258 } YYSTYPE; 259 260 /* The hash table length should be a prime number. */ 261 #define SYM_MAX_HASH 251 262 263 typedef struct symbol_table { 264 Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */ 265 } SymbolTable; 266 267 extern SymbolTable *new_symbol_table /* Create symbol table */ 268 (void); 269 extern void free_symbol_table /* Destroy symbol table */ 270 (SymbolTable *s); 271 extern Symbol *find_symbol /* Lookup symbol name */ 272 (SymbolTable *s, const char *n); 273 extern Symbol *new_symbol /* Define new symbol */ 274 (SymbolTable *s, const char *n, const char *v, int f); 275 276 /* #include "semantic.h" */ 277 extern void new_decl_spec (DeclSpec *, const char *, long, int); 278 extern void free_decl_spec (DeclSpec *); 279 extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *); 280 extern void check_untagged (DeclSpec *); 281 extern Declarator *new_declarator (const char *, const char *, long); 282 extern void free_declarator (Declarator *); 283 extern void new_decl_list (DeclaratorList *, Declarator *); 284 extern void free_decl_list (DeclaratorList *); 285 extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *); 286 extern Parameter *new_parameter (DeclSpec *, Declarator *); 287 extern void free_parameter (Parameter *); 288 extern void new_param_list (ParameterList *, Parameter *); 289 extern void free_param_list (ParameterList *); 290 extern void add_param_list (ParameterList *, ParameterList *, Parameter *); 291 extern void new_ident_list (ParameterList *); 292 extern void add_ident_list (ParameterList *, ParameterList *, const char *); 293 extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *); 294 extern void gen_declarations (DeclSpec *, DeclaratorList *); 295 extern void gen_prototype (DeclSpec *, Declarator *); 296 extern void gen_func_declarator (Declarator *); 297 extern void gen_func_definition (DeclSpec *, Declarator *); 298 299 extern void init_parser (void); 300 extern void process_file (FILE *infile, char *name); 301 extern char *cur_text (void); 302 extern char *cur_file_name (void); 303 extern char *implied_typedef (void); 304 extern void include_file (char *name, int convert); 305 extern char *supply_parm (int count); 306 extern char *xstrdup (const char *); 307 extern int already_declared (char *name); 308 extern int is_actual_func (Declarator *d); 309 extern int lint_ellipsis (Parameter *p); 310 extern int want_typedef (void); 311 extern void begin_tracking (void); 312 extern void begin_typedef (void); 313 extern void copy_typedef (char *s); 314 extern void ellipsis_varargs (Declarator *d); 315 extern void end_typedef (void); 316 extern void flush_varargs (void); 317 extern void fmt_library (int code); 318 extern void imply_typedef (const char *s); 319 extern void indent (FILE *outf); 320 extern void put_blankline (FILE *outf); 321 extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator); 322 extern void put_char (FILE *outf, int c); 323 extern void put_error (void); 324 extern void put_newline (FILE *outf); 325 extern void put_padded (FILE *outf, const char *s); 326 extern void put_string (FILE *outf, const char *s); 327 extern void track_in (void); 328 329 extern boolean file_comments; 330 extern FuncDefStyle func_style; 331 extern char base_file[]; 332 333 extern int yylex (void); 334 335 /* declaration specifier attributes for the typedef statement currently being 336 * scanned 337 */ 338 static int cur_decl_spec_flags; 339 340 /* pointer to parameter list for the current function definition */ 341 static ParameterList *func_params; 342 343 /* A parser semantic action sets this pointer to the current declarator in 344 * a function parameter declaration in order to catch any comments following 345 * the parameter declaration on the same line. If the lexer scans a comment 346 * and <cur_declarator> is not NULL, then the comment is attached to the 347 * declarator. To ignore subsequent comments, the lexer sets this to NULL 348 * after scanning a comment or end of line. 349 */ 350 static Declarator *cur_declarator; 351 352 /* temporary string buffer */ 353 static char buf[MAX_TEXT_SIZE]; 354 355 /* table of typedef names */ 356 static SymbolTable *typedef_names; 357 358 /* table of define names */ 359 static SymbolTable *define_names; 360 361 /* table of type qualifiers */ 362 static SymbolTable *type_qualifiers; 363 364 /* information about the current input file */ 365 typedef struct { 366 char *base_name; /* base input file name */ 367 char *file_name; /* current file name */ 368 FILE *file; /* input file */ 369 unsigned line_num; /* current line number in input file */ 370 FILE *tmp_file; /* temporary file */ 371 long begin_comment; /* tmp file offset after last written ) or ; */ 372 long end_comment; /* tmp file offset after last comment */ 373 boolean convert; /* if TRUE, convert function definitions */ 374 boolean changed; /* TRUE if conversion done in this file */ 375 } IncludeStack; 376 377 static IncludeStack *cur_file; /* current input file */ 378 379 /* #include "yyerror.c" */ 380 381 static int haveAnsiParam (void); 382 383 384 /* Flags to enable us to find if a procedure returns a value. 385 */ 386 static int return_val; /* nonzero on BRACES iff return-expression found */ 387 388 static const char * 389 dft_decl_spec (void) 390 { 391 return (lintLibrary() && !return_val) ? "void" : "int"; 392 } 393 394 static int 395 haveAnsiParam (void) 396 { 397 Parameter *p; 398 if (func_params != 0) { 399 for (p = func_params->first; p != 0; p = p->next) { 400 if (p->declarator->func_def == FUNC_ANSI) { 401 return TRUE; 402 } 403 } 404 } 405 return FALSE; 406 } 407 #line 408 "grammar.tab.c" 408 409 /* compatibility with bison */ 410 #ifdef YYPARSE_PARAM 411 /* compatibility with FreeBSD */ 412 # ifdef YYPARSE_PARAM_TYPE 413 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 414 # else 415 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 416 # endif 417 #else 418 # define YYPARSE_DECL() yyparse(void) 419 #endif 420 421 /* Parameters sent to lex. */ 422 #ifdef YYLEX_PARAM 423 # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 424 # define YYLEX yylex(YYLEX_PARAM) 425 #else 426 # define YYLEX_DECL() yylex(void) 427 # define YYLEX yylex() 428 #endif 429 430 /* Parameters sent to yyerror. */ 431 #ifndef YYERROR_DECL 432 #define YYERROR_DECL() yyerror(const char *s) 433 #endif 434 #ifndef YYERROR_CALL 435 #define YYERROR_CALL(msg) yyerror(msg) 436 #endif 437 438 extern int YYPARSE_DECL(); 439 440 #define T_IDENTIFIER 257 441 #define T_TYPEDEF_NAME 258 442 #define T_DEFINE_NAME 259 443 #define T_AUTO 260 444 #define T_EXTERN 261 445 #define T_REGISTER 262 446 #define T_STATIC 263 447 #define T_TYPEDEF 264 448 #define T_INLINE 265 449 #define T_EXTENSION 266 450 #define T_CHAR 267 451 #define T_DOUBLE 268 452 #define T_FLOAT 269 453 #define T_INT 270 454 #define T_VOID 271 455 #define T_LONG 272 456 #define T_SHORT 273 457 #define T_SIGNED 274 458 #define T_UNSIGNED 275 459 #define T_ENUM 276 460 #define T_STRUCT 277 461 #define T_UNION 278 462 #define T_Bool 279 463 #define T_Complex 280 464 #define T_Imaginary 281 465 #define T_TYPE_QUALIFIER 282 466 #define T_BRACKETS 283 467 #define T_LBRACE 284 468 #define T_MATCHRBRACE 285 469 #define T_ELLIPSIS 286 470 #define T_INITIALIZER 287 471 #define T_STRING_LITERAL 288 472 #define T_ASM 289 473 #define T_ASMARG 290 474 #define T_VA_DCL 291 475 #define YYERRCODE 256 476 typedef short YYINT; 477 static const YYINT grammar_lhs[] = { -1, 478 0, 0, 26, 26, 27, 27, 27, 27, 27, 27, 479 27, 31, 30, 30, 28, 28, 34, 28, 32, 32, 480 33, 33, 35, 35, 37, 38, 29, 39, 29, 36, 481 36, 36, 40, 40, 1, 1, 2, 2, 2, 3, 482 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 483 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 484 5, 5, 6, 6, 6, 19, 19, 8, 8, 9, 485 41, 9, 7, 7, 7, 25, 23, 23, 10, 10, 486 11, 11, 11, 11, 11, 20, 20, 21, 21, 22, 487 22, 14, 14, 15, 15, 16, 16, 16, 17, 17, 488 18, 18, 24, 24, 12, 12, 12, 13, 13, 13, 489 13, 13, 13, 13, 490 }; 491 static const YYINT grammar_len[] = { 2, 492 0, 1, 1, 2, 1, 1, 1, 1, 3, 2, 493 2, 2, 3, 3, 2, 3, 0, 5, 2, 1, 494 0, 1, 1, 3, 0, 0, 7, 0, 5, 0, 495 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 496 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 497 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 498 1, 1, 3, 2, 2, 1, 1, 1, 3, 1, 499 0, 4, 3, 2, 2, 1, 1, 1, 2, 1, 500 1, 3, 2, 4, 4, 2, 3, 0, 1, 1, 501 2, 1, 3, 1, 3, 2, 2, 1, 0, 1, 502 1, 3, 1, 2, 1, 2, 1, 3, 2, 1, 503 4, 3, 3, 2, 504 }; 505 static const YYINT grammar_defred[] = { 0, 506 0, 0, 0, 0, 77, 0, 62, 40, 0, 42, 507 43, 20, 44, 0, 46, 47, 48, 49, 54, 50, 508 51, 52, 53, 76, 66, 67, 55, 56, 57, 61, 509 0, 7, 0, 0, 35, 37, 38, 39, 59, 60, 510 28, 0, 0, 0, 103, 81, 0, 0, 3, 5, 511 6, 8, 0, 10, 11, 78, 0, 90, 0, 0, 512 104, 0, 19, 0, 41, 45, 15, 36, 0, 68, 513 0, 0, 0, 83, 0, 0, 64, 0, 0, 74, 514 4, 58, 0, 82, 87, 91, 0, 14, 13, 9, 515 16, 0, 71, 0, 31, 33, 0, 0, 0, 0, 516 0, 94, 0, 0, 101, 12, 63, 73, 0, 0, 517 69, 0, 0, 0, 34, 0, 110, 96, 97, 0, 518 0, 84, 0, 85, 0, 23, 0, 0, 72, 26, 519 29, 114, 0, 0, 0, 109, 0, 93, 95, 102, 520 18, 0, 0, 108, 113, 112, 0, 24, 27, 111, 521 }; 522 static const YYINT grammar_stos[] = { 0, 523 256, 40, 42, 38, 257, 258, 259, 260, 261, 262, 524 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 525 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 526 289, 59, 293, 294, 295, 296, 297, 298, 299, 300, 527 303, 304, 312, 313, 316, 317, 318, 319, 320, 321, 528 322, 323, 325, 285, 59, 258, 303, 298, 314, 315, 529 316, 288, 264, 290, 261, 266, 59, 295, 301, 302, 530 303, 332, 40, 283, 284, 316, 324, 304, 316, 324, 531 320, 258, 294, 41, 313, 298, 294, 321, 324, 59, 532 59, 44, 61, 330, 291, 321, 329, 333, 294, 307, 533 308, 309, 310, 311, 316, 285, 324, 324, 327, 303, 534 302, 334, 329, 284, 321, 40, 283, 303, 305, 306, 535 313, 41, 44, 41, 44, 303, 326, 328, 287, 284, 536 285, 41, 305, 307, 40, 283, 306, 286, 309, 316, 537 59, 44, 331, 41, 41, 41, 307, 303, 285, 41, 538 }; 539 static const YYINT grammar_dgoto[] = { 33, 540 87, 35, 36, 37, 38, 39, 40, 69, 70, 41, 541 42, 119, 120, 100, 101, 102, 103, 104, 43, 44, 542 59, 60, 45, 46, 47, 48, 49, 50, 51, 52, 543 77, 53, 127, 109, 128, 97, 94, 143, 72, 98, 544 112, 545 }; 546 static const YYINT grammar_sindex[] = { -2, 547 -3, 27, -239, -177, 0, 0, 0, 0, -274, 0, 548 0, 0, 0, -246, 0, 0, 0, 0, 0, 0, 549 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 550 -266, 0, 0, 455, 0, 0, 0, 0, 0, 0, 551 0, -35, -245, 128, 0, 0, -245, -2, 0, 0, 552 0, 0, 642, 0, 0, 0, -15, 0, -12, -239, 553 0, 590, 0, -27, 0, 0, 0, 0, -10, 0, 554 -11, 534, -72, 0, -237, -232, 0, -35, -232, 0, 555 0, 0, 642, 0, 0, 0, 455, 0, 0, 0, 556 0, 27, 0, 534, 0, 0, -222, 617, 209, 34, 557 39, 0, 44, 42, 0, 0, 0, 0, 27, -11, 558 0, -200, -196, -195, 0, 174, 0, 0, 0, -33, 559 243, 0, 561, 0, -177, 0, 33, 49, 0, 0, 560 0, 0, 53, 55, 417, 0, -33, 0, 0, 0, 561 0, 27, -188, 0, 0, 0, 57, 0, 0, 0, 562 }; 563 static const YYINT grammar_rindex[] = { 99, 564 0, 0, 275, 0, 0, -38, 0, 0, 481, 0, 565 0, 0, 0, 509, 0, 0, 0, 0, 0, 0, 566 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 567 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 568 0, 30, 0, 0, 0, 0, 0, 101, 0, 0, 569 0, 0, 0, 0, 0, 0, 0, 0, 343, 309, 570 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 571 98, -182, 62, 0, 0, 133, 0, 64, 379, 0, 572 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 573 0, 0, 0, -182, 0, 0, 0, -180, -19, 0, 574 65, 0, 0, 68, 0, 0, 0, 0, 51, 9, 575 0, 0, 0, 0, 0, 0, 0, 0, 0, -13, 576 19, 0, 0, 0, 0, 0, 0, 52, 0, 0, 577 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 578 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 579 }; 580 #if YYBTYACC 581 static const YYINT grammar_cindex[] = { 0, 582 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 583 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 584 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 585 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 586 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 587 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 588 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 589 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 590 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 591 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 592 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 593 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 594 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 595 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 596 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 597 }; 598 #endif 599 static const YYINT grammar_gindex[] = { 0, 600 11, -17, 0, 0, 13, 0, 0, 0, 20, 8, 601 -43, -1, -8, -89, 0, -9, 0, 0, 0, -44, 602 0, 0, 4, 0, 0, 0, 70, -53, 0, 0, 603 -18, 0, 0, 0, 0, 22, 0, 0, 0, 0, 604 0, 605 }; 606 #define YYTABLESIZE 924 607 static const YYINT grammar_table[] = { 58, 608 78, 58, 58, 58, 73, 58, 135, 61, 88, 57, 609 34, 5, 56, 62, 85, 58, 68, 63, 96, 7, 610 58, 98, 78, 64, 98, 84, 134, 107, 80, 3, 611 107, 90, 17, 92, 17, 4, 17, 2, 75, 3, 612 96, 71, 30, 89, 115, 147, 76, 106, 91, 93, 613 79, 75, 70, 17, 121, 55, 32, 107, 34, 105, 614 108, 114, 105, 83, 4, 68, 2, 70, 3, 68, 615 80, 121, 86, 80, 122, 106, 105, 78, 106, 5, 616 56, 68, 123, 99, 124, 125, 129, 130, 80, 131, 617 80, 141, 142, 144, 110, 145, 149, 150, 1, 110, 618 2, 30, 99, 32, 79, 92, 118, 79, 100, 21, 619 22, 111, 137, 139, 133, 113, 126, 81, 0, 0, 620 0, 0, 79, 57, 79, 0, 99, 0, 140, 0, 621 0, 0, 0, 99, 0, 0, 0, 0, 0, 0, 622 0, 70, 0, 0, 0, 99, 0, 0, 0, 148, 623 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, 624 0, 0, 0, 0, 0, 4, 0, 2, 0, 0, 625 65, 0, 65, 65, 65, 0, 65, 0, 0, 0, 626 0, 0, 0, 0, 5, 6, 7, 8, 65, 10, 627 11, 65, 13, 66, 15, 16, 17, 18, 19, 20, 628 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 629 0, 4, 0, 116, 132, 3, 0, 0, 58, 58, 630 58, 58, 58, 58, 58, 78, 58, 58, 58, 58, 631 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 632 58, 58, 58, 58, 58, 78, 4, 74, 116, 136, 633 3, 17, 78, 1, 5, 6, 7, 8, 9, 10, 634 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 635 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 636 4, 54, 116, 5, 56, 0, 31, 80, 80, 80, 637 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 638 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 639 80, 80, 88, 80, 88, 88, 88, 0, 88, 0, 640 80, 79, 79, 79, 79, 79, 79, 79, 79, 79, 641 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 642 79, 79, 79, 79, 79, 79, 89, 79, 89, 89, 643 89, 0, 89, 0, 79, 25, 25, 25, 25, 25, 644 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 645 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 646 86, 25, 86, 86, 5, 56, 86, 0, 25, 65, 647 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 648 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 649 65, 65, 65, 65, 65, 65, 75, 0, 75, 75, 650 75, 0, 75, 0, 0, 0, 0, 0, 0, 0, 651 5, 6, 7, 8, 65, 10, 11, 75, 13, 66, 652 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 653 25, 26, 27, 28, 29, 30, 117, 146, 0, 0, 654 0, 0, 0, 0, 0, 5, 6, 7, 8, 65, 655 10, 11, 0, 13, 66, 15, 16, 17, 18, 19, 656 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 657 30, 117, 4, 0, 2, 0, 3, 0, 0, 5, 658 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 659 0, 0, 0, 67, 0, 0, 0, 0, 41, 0, 660 41, 0, 41, 0, 0, 117, 0, 0, 0, 0, 661 0, 88, 88, 0, 0, 0, 0, 0, 0, 41, 662 0, 0, 0, 0, 0, 0, 45, 0, 45, 0, 663 45, 0, 0, 0, 0, 0, 0, 88, 0, 0, 664 0, 0, 0, 0, 0, 89, 89, 45, 0, 0, 665 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 666 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 667 0, 89, 0, 0, 0, 0, 0, 0, 0, 86, 668 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 669 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 670 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 671 0, 0, 0, 0, 0, 75, 75, 75, 75, 75, 672 75, 75, 0, 75, 75, 75, 75, 75, 75, 75, 673 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 674 75, 75, 0, 0, 0, 0, 0, 0, 0, 0, 675 0, 0, 0, 0, 82, 7, 8, 65, 10, 11, 676 0, 13, 66, 15, 16, 17, 18, 19, 20, 21, 677 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 678 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 679 0, 5, 6, 7, 8, 65, 10, 11, 0, 13, 680 66, 15, 16, 17, 18, 19, 20, 21, 22, 23, 681 24, 25, 26, 27, 28, 29, 30, 41, 41, 41, 682 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 683 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 684 41, 41, 41, 0, 0, 45, 45, 45, 45, 45, 685 45, 45, 0, 45, 45, 45, 45, 45, 45, 45, 686 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 687 45, 82, 7, 8, 65, 10, 11, 12, 13, 14, 688 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 689 25, 26, 27, 28, 29, 30, 0, 0, 82, 7, 690 8, 65, 10, 11, 95, 13, 66, 15, 16, 17, 691 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 692 28, 29, 30, 0, 0, 0, 138, 82, 7, 8, 693 65, 10, 11, 12, 13, 14, 15, 16, 17, 18, 694 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 695 29, 30, 0, 75, 82, 7, 8, 65, 10, 11, 696 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 697 22, 23, 24, 25, 26, 27, 28, 29, 30, 82, 698 7, 8, 65, 10, 11, 0, 13, 66, 15, 16, 699 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 700 27, 28, 29, 30, 701 }; 702 static const YYINT grammar_check[] = { 38, 703 44, 40, 41, 42, 40, 44, 40, 4, 62, 2, 704 0, 257, 258, 288, 59, 3, 34, 264, 72, 259, 705 59, 41, 61, 290, 44, 41, 116, 41, 47, 42, 706 44, 59, 38, 44, 40, 38, 42, 40, 284, 42, 707 94, 34, 282, 62, 98, 135, 43, 285, 59, 61, 708 47, 284, 44, 59, 99, 59, 59, 76, 48, 41, 709 79, 284, 44, 53, 38, 83, 40, 59, 42, 87, 710 41, 116, 60, 44, 41, 41, 73, 121, 44, 257, 711 258, 99, 44, 73, 41, 44, 287, 284, 59, 285, 712 61, 59, 44, 41, 87, 41, 285, 41, 0, 92, 713 0, 284, 41, 284, 41, 41, 99, 44, 41, 59, 714 59, 92, 121, 123, 116, 94, 109, 48, -1, -1, 715 -1, -1, 59, 116, 61, -1, 116, -1, 125, -1, 716 -1, -1, -1, 123, -1, -1, -1, -1, -1, -1, 717 -1, 44, -1, -1, -1, 135, -1, -1, -1, 142, 718 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, 719 -1, -1, -1, -1, -1, 38, -1, 40, -1, -1, 720 38, -1, 40, 41, 42, -1, 44, -1, -1, -1, 721 -1, -1, -1, -1, 257, 258, 259, 260, 261, 262, 722 263, 59, 265, 266, 267, 268, 269, 270, 271, 272, 723 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 724 -1, 38, -1, 40, 41, 42, -1, -1, 257, 258, 725 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 726 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 727 279, 280, 281, 282, 283, 284, 38, 283, 40, 283, 728 42, 257, 291, 256, 257, 258, 259, 260, 261, 262, 729 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 730 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 731 38, 285, 40, 257, 258, -1, 289, 258, 259, 260, 732 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 733 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 734 281, 282, 38, 284, 40, 41, 42, -1, 44, -1, 735 291, 258, 259, 260, 261, 262, 263, 264, 265, 266, 736 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 737 277, 278, 279, 280, 281, 282, 38, 284, 40, 41, 738 42, -1, 44, -1, 291, 258, 259, 260, 261, 262, 739 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 740 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 741 38, 284, 40, 41, 257, 258, 44, -1, 291, 257, 742 258, 259, 260, 261, 262, 263, -1, 265, 266, 267, 743 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 744 278, 279, 280, 281, 282, 283, 38, -1, 40, 41, 745 42, -1, 44, -1, -1, -1, -1, -1, -1, -1, 746 257, 258, 259, 260, 261, 262, 263, 59, 265, 266, 747 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 748 277, 278, 279, 280, 281, 282, 283, 41, -1, -1, 749 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, 750 262, 263, -1, 265, 266, 267, 268, 269, 270, 271, 751 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 752 282, 283, 38, -1, 40, -1, 42, -1, -1, 257, 753 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, 754 -1, -1, -1, 59, -1, -1, -1, -1, 38, -1, 755 40, -1, 42, -1, -1, 283, -1, -1, -1, -1, 756 -1, 257, 258, -1, -1, -1, -1, -1, -1, 59, 757 -1, -1, -1, -1, -1, -1, 38, -1, 40, -1, 758 42, -1, -1, -1, -1, -1, -1, 283, -1, -1, 759 -1, -1, -1, -1, -1, 257, 258, 59, -1, -1, 760 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 761 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 762 -1, 283, -1, -1, -1, -1, -1, -1, -1, 257, 763 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, 764 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 765 -1, -1, -1, -1, -1, 283, -1, -1, -1, -1, 766 -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, 767 262, 263, -1, 265, 266, 267, 268, 269, 270, 271, 768 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 769 282, 283, -1, -1, -1, -1, -1, -1, -1, -1, 770 -1, -1, -1, -1, 258, 259, 260, 261, 262, 263, 771 -1, 265, 266, 267, 268, 269, 270, 271, 272, 273, 772 274, 275, 276, 277, 278, 279, 280, 281, 282, -1, 773 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 774 -1, 257, 258, 259, 260, 261, 262, 263, -1, 265, 775 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 776 276, 277, 278, 279, 280, 281, 282, 257, 258, 259, 777 260, 261, 262, 263, -1, 265, 266, 267, 268, 269, 778 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 779 280, 281, 282, -1, -1, 257, 258, 259, 260, 261, 780 262, 263, -1, 265, 266, 267, 268, 269, 270, 271, 781 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 782 282, 258, 259, 260, 261, 262, 263, 264, 265, 266, 783 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 784 277, 278, 279, 280, 281, 282, -1, -1, 258, 259, 785 260, 261, 262, 263, 291, 265, 266, 267, 268, 269, 786 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 787 280, 281, 282, -1, -1, -1, 286, 258, 259, 260, 788 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 789 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 790 281, 282, -1, 284, 258, 259, 260, 261, 262, 263, 791 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 792 274, 275, 276, 277, 278, 279, 280, 281, 282, 258, 793 259, 260, 261, 262, 263, -1, 265, 266, 267, 268, 794 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 795 279, 280, 281, 282, 796 }; 797 #define YYFINAL 33 798 #ifndef YYDEBUG 799 #define YYDEBUG 0 800 #endif 801 #define YYMAXTOKEN 291 802 #define YYUNDFTOKEN 335 803 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 804 #if YYDEBUG 805 static const char *const grammar_name[] = { 806 807 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 808 0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,"'='",0, 809 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 810 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 811 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 812 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 813 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error", 814 "T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN", 815 "T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR", 816 "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED", 817 "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary", 818 "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS", 819 "T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL","$accept", 820 "program","decl_specifiers","decl_specifier","storage_class","type_specifier", 821 "type_qualifier","struct_or_union_specifier","enum_specifier", 822 "init_declarator_list","init_declarator","declarator","direct_declarator", 823 "abs_declarator","direct_abs_declarator","parameter_type_list","parameter_list", 824 "parameter_declaration","opt_identifier_list","identifier_list", 825 "struct_or_union","pointer","opt_type_qualifiers","type_qualifier_list", 826 "any_id","identifier_or_ref","enumeration","translation_unit", 827 "external_declaration","declaration","function_definition", 828 "linkage_specification","braces","any_typedef","opt_declarator_list","$$1", 829 "declarator_list","opt_declaration_list","$$2","$$3","$$4","declaration_list", 830 "$$5","illegal-symbol", 831 }; 832 static const char *const grammar_rule[] = { 833 "$accept : program", 834 "program :", 835 "program : translation_unit", 836 "translation_unit : external_declaration", 837 "translation_unit : translation_unit external_declaration", 838 "external_declaration : declaration", 839 "external_declaration : function_definition", 840 "external_declaration : ';'", 841 "external_declaration : linkage_specification", 842 "external_declaration : T_ASM T_ASMARG ';'", 843 "external_declaration : error T_MATCHRBRACE", 844 "external_declaration : error ';'", 845 "braces : T_LBRACE T_MATCHRBRACE", 846 "linkage_specification : T_EXTERN T_STRING_LITERAL braces", 847 "linkage_specification : T_EXTERN T_STRING_LITERAL declaration", 848 "declaration : decl_specifiers ';'", 849 "declaration : decl_specifiers init_declarator_list ';'", 850 "$$1 :", 851 "declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'", 852 "any_typedef : T_EXTENSION T_TYPEDEF", 853 "any_typedef : T_TYPEDEF", 854 "opt_declarator_list :", 855 "opt_declarator_list : declarator_list", 856 "declarator_list : declarator", 857 "declarator_list : declarator_list ',' declarator", 858 "$$2 :", 859 "$$3 :", 860 "function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE", 861 "$$4 :", 862 "function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE", 863 "opt_declaration_list :", 864 "opt_declaration_list : T_VA_DCL", 865 "opt_declaration_list : declaration_list", 866 "declaration_list : declaration", 867 "declaration_list : declaration_list declaration", 868 "decl_specifiers : decl_specifier", 869 "decl_specifiers : decl_specifiers decl_specifier", 870 "decl_specifier : storage_class", 871 "decl_specifier : type_specifier", 872 "decl_specifier : type_qualifier", 873 "storage_class : T_AUTO", 874 "storage_class : T_EXTERN", 875 "storage_class : T_REGISTER", 876 "storage_class : T_STATIC", 877 "storage_class : T_INLINE", 878 "storage_class : T_EXTENSION", 879 "type_specifier : T_CHAR", 880 "type_specifier : T_DOUBLE", 881 "type_specifier : T_FLOAT", 882 "type_specifier : T_INT", 883 "type_specifier : T_LONG", 884 "type_specifier : T_SHORT", 885 "type_specifier : T_SIGNED", 886 "type_specifier : T_UNSIGNED", 887 "type_specifier : T_VOID", 888 "type_specifier : T_Bool", 889 "type_specifier : T_Complex", 890 "type_specifier : T_Imaginary", 891 "type_specifier : T_TYPEDEF_NAME", 892 "type_specifier : struct_or_union_specifier", 893 "type_specifier : enum_specifier", 894 "type_qualifier : T_TYPE_QUALIFIER", 895 "type_qualifier : T_DEFINE_NAME", 896 "struct_or_union_specifier : struct_or_union any_id braces", 897 "struct_or_union_specifier : struct_or_union braces", 898 "struct_or_union_specifier : struct_or_union any_id", 899 "struct_or_union : T_STRUCT", 900 "struct_or_union : T_UNION", 901 "init_declarator_list : init_declarator", 902 "init_declarator_list : init_declarator_list ',' init_declarator", 903 "init_declarator : declarator", 904 "$$5 :", 905 "init_declarator : declarator '=' $$5 T_INITIALIZER", 906 "enum_specifier : enumeration any_id braces", 907 "enum_specifier : enumeration braces", 908 "enum_specifier : enumeration any_id", 909 "enumeration : T_ENUM", 910 "any_id : T_IDENTIFIER", 911 "any_id : T_TYPEDEF_NAME", 912 "declarator : pointer direct_declarator", 913 "declarator : direct_declarator", 914 "direct_declarator : identifier_or_ref", 915 "direct_declarator : '(' declarator ')'", 916 "direct_declarator : direct_declarator T_BRACKETS", 917 "direct_declarator : direct_declarator '(' parameter_type_list ')'", 918 "direct_declarator : direct_declarator '(' opt_identifier_list ')'", 919 "pointer : '*' opt_type_qualifiers", 920 "pointer : '*' opt_type_qualifiers pointer", 921 "opt_type_qualifiers :", 922 "opt_type_qualifiers : type_qualifier_list", 923 "type_qualifier_list : type_qualifier", 924 "type_qualifier_list : type_qualifier_list type_qualifier", 925 "parameter_type_list : parameter_list", 926 "parameter_type_list : parameter_list ',' T_ELLIPSIS", 927 "parameter_list : parameter_declaration", 928 "parameter_list : parameter_list ',' parameter_declaration", 929 "parameter_declaration : decl_specifiers declarator", 930 "parameter_declaration : decl_specifiers abs_declarator", 931 "parameter_declaration : decl_specifiers", 932 "opt_identifier_list :", 933 "opt_identifier_list : identifier_list", 934 "identifier_list : any_id", 935 "identifier_list : identifier_list ',' any_id", 936 "identifier_or_ref : any_id", 937 "identifier_or_ref : '&' any_id", 938 "abs_declarator : pointer", 939 "abs_declarator : pointer direct_abs_declarator", 940 "abs_declarator : direct_abs_declarator", 941 "direct_abs_declarator : '(' abs_declarator ')'", 942 "direct_abs_declarator : direct_abs_declarator T_BRACKETS", 943 "direct_abs_declarator : T_BRACKETS", 944 "direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'", 945 "direct_abs_declarator : direct_abs_declarator '(' ')'", 946 "direct_abs_declarator : '(' parameter_type_list ')'", 947 "direct_abs_declarator : '(' ')'", 948 949 }; 950 #endif 951 952 int yydebug; 953 int yynerrs; 954 955 int yyerrflag; 956 int yychar; 957 YYSTYPE yyval; 958 YYSTYPE yylval; 959 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 960 YYLTYPE yyloc; /* position returned by actions */ 961 YYLTYPE yylloc; /* position from the lexer */ 962 #endif 963 964 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 965 #ifndef YYLLOC_DEFAULT 966 #define YYLLOC_DEFAULT(loc, rhs, n) \ 967 do \ 968 { \ 969 if (n == 0) \ 970 { \ 971 (loc).first_line = ((rhs)[-1]).last_line; \ 972 (loc).first_column = ((rhs)[-1]).last_column; \ 973 (loc).last_line = ((rhs)[-1]).last_line; \ 974 (loc).last_column = ((rhs)[-1]).last_column; \ 975 } \ 976 else \ 977 { \ 978 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 979 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 980 (loc).last_line = ((rhs)[n-1]).last_line; \ 981 (loc).last_column = ((rhs)[n-1]).last_column; \ 982 } \ 983 } while (0) 984 #endif /* YYLLOC_DEFAULT */ 985 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 986 #if YYBTYACC 987 988 #ifndef YYLVQUEUEGROWTH 989 #define YYLVQUEUEGROWTH 32 990 #endif 991 #endif /* YYBTYACC */ 992 993 /* define the initial stack-sizes */ 994 #ifdef YYSTACKSIZE 995 #undef YYMAXDEPTH 996 #define YYMAXDEPTH YYSTACKSIZE 997 #else 998 #ifdef YYMAXDEPTH 999 #define YYSTACKSIZE YYMAXDEPTH 1000 #else 1001 #define YYSTACKSIZE 10000 1002 #define YYMAXDEPTH 10000 1003 #endif 1004 #endif 1005 1006 #ifndef YYINITSTACKSIZE 1007 #define YYINITSTACKSIZE 200 1008 #endif 1009 1010 typedef struct { 1011 unsigned stacksize; 1012 short *s_base; 1013 short *s_mark; 1014 short *s_last; 1015 YYSTYPE *l_base; 1016 YYSTYPE *l_mark; 1017 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1018 YYLTYPE *p_base; 1019 YYLTYPE *p_mark; 1020 #endif 1021 } YYSTACKDATA; 1022 #if YYBTYACC 1023 1024 struct YYParseState_s 1025 { 1026 struct YYParseState_s *save; /* Previously saved parser state */ 1027 YYSTACKDATA yystack; /* saved parser stack */ 1028 int state; /* saved parser state */ 1029 int errflag; /* saved error recovery status */ 1030 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 1031 YYINT ctry; /* saved index in yyctable[] for this conflict */ 1032 }; 1033 typedef struct YYParseState_s YYParseState; 1034 #endif /* YYBTYACC */ 1035 /* variables for the parser stack */ 1036 static YYSTACKDATA yystack; 1037 #if YYBTYACC 1038 1039 /* Current parser state */ 1040 static YYParseState *yyps = 0; 1041 1042 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 1043 static YYParseState *yypath = 0; 1044 1045 /* Base of the lexical value queue */ 1046 static YYSTYPE *yylvals = 0; 1047 1048 /* Current position at lexical value queue */ 1049 static YYSTYPE *yylvp = 0; 1050 1051 /* End position of lexical value queue */ 1052 static YYSTYPE *yylve = 0; 1053 1054 /* The last allocated position at the lexical value queue */ 1055 static YYSTYPE *yylvlim = 0; 1056 1057 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1058 /* Base of the lexical position queue */ 1059 static YYLTYPE *yylpsns = 0; 1060 1061 /* Current position at lexical position queue */ 1062 static YYLTYPE *yylpp = 0; 1063 1064 /* End position of lexical position queue */ 1065 static YYLTYPE *yylpe = 0; 1066 1067 /* The last allocated position at the lexical position queue */ 1068 static YYLTYPE *yylplim = 0; 1069 #endif 1070 1071 /* Current position at lexical token queue */ 1072 static short *yylexp = 0; 1073 1074 static short *yylexemes = 0; 1075 #endif /* YYBTYACC */ 1076 #line 1014 "grammar.y" 1077 1078 /* lex.yy.c */ 1079 #define BEGIN yy_start = 1 + 2 * 1080 1081 #define CPP1 1 1082 #define INIT1 2 1083 #define INIT2 3 1084 #define CURLY 4 1085 #define LEXYACC 5 1086 #define ASM 6 1087 #define CPP_INLINE 7 1088 1089 extern char *yytext; 1090 extern FILE *yyin, *yyout; 1091 1092 static int curly; /* number of curly brace nesting levels */ 1093 static int ly_count; /* number of occurances of %% */ 1094 static int inc_depth; /* include nesting level */ 1095 static SymbolTable *included_files; /* files already included */ 1096 static int yy_start = 0; /* start state number */ 1097 1098 #define grammar_error(s) yaccError(s) 1099 1100 static void 1101 yaccError (const char *msg) 1102 { 1103 func_params = NULL; 1104 put_error(); /* tell what line we're on, and what file */ 1105 fprintf(stderr, "%s at token '%s'\n", msg, yytext); 1106 } 1107 1108 /* Initialize the table of type qualifier keywords recognized by the lexical 1109 * analyzer. 1110 */ 1111 void 1112 init_parser (void) 1113 { 1114 static const char *keywords[] = { 1115 "const", 1116 "restrict", 1117 "volatile", 1118 "interrupt", 1119 #ifdef vms 1120 "noshare", 1121 "readonly", 1122 #endif 1123 #if defined(MSDOS) || defined(OS2) 1124 "__cdecl", 1125 "__export", 1126 "__far", 1127 "__fastcall", 1128 "__fortran", 1129 "__huge", 1130 "__inline", 1131 "__interrupt", 1132 "__loadds", 1133 "__near", 1134 "__pascal", 1135 "__saveregs", 1136 "__segment", 1137 "__stdcall", 1138 "__syscall", 1139 "_cdecl", 1140 "_cs", 1141 "_ds", 1142 "_es", 1143 "_export", 1144 "_far", 1145 "_fastcall", 1146 "_fortran", 1147 "_huge", 1148 "_interrupt", 1149 "_loadds", 1150 "_near", 1151 "_pascal", 1152 "_saveregs", 1153 "_seg", 1154 "_segment", 1155 "_ss", 1156 "cdecl", 1157 "far", 1158 "huge", 1159 "near", 1160 "pascal", 1161 #ifdef OS2 1162 "__far16", 1163 #endif 1164 #endif 1165 #ifdef __GNUC__ 1166 /* gcc aliases */ 1167 "__builtin_va_arg", 1168 "__builtin_va_list", 1169 "__const", 1170 "__const__", 1171 "__inline", 1172 "__inline__", 1173 "__restrict", 1174 "__restrict__", 1175 "__volatile", 1176 "__volatile__", 1177 #endif 1178 }; 1179 unsigned i; 1180 1181 /* Initialize type qualifier table. */ 1182 type_qualifiers = new_symbol_table(); 1183 for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) { 1184 new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE); 1185 } 1186 } 1187 1188 /* Process the C source file. Write function prototypes to the standard 1189 * output. Convert function definitions and write the converted source 1190 * code to a temporary file. 1191 */ 1192 void 1193 process_file (FILE *infile, char *name) 1194 { 1195 char *s; 1196 1197 if (strlen(name) > 2) { 1198 s = name + strlen(name) - 2; 1199 if (*s == '.') { 1200 ++s; 1201 if (*s == 'l' || *s == 'y') 1202 BEGIN LEXYACC; 1203 #if defined(MSDOS) || defined(OS2) 1204 if (*s == 'L' || *s == 'Y') 1205 BEGIN LEXYACC; 1206 #endif 1207 } 1208 } 1209 1210 included_files = new_symbol_table(); 1211 typedef_names = new_symbol_table(); 1212 define_names = new_symbol_table(); 1213 inc_depth = -1; 1214 curly = 0; 1215 ly_count = 0; 1216 func_params = NULL; 1217 yyin = infile; 1218 include_file(strcpy(base_file, name), func_style != FUNC_NONE); 1219 if (file_comments) { 1220 #if OPT_LINTLIBRARY 1221 if (lintLibrary()) { 1222 put_blankline(stdout); 1223 begin_tracking(); 1224 } 1225 #endif 1226 put_string(stdout, "/* "); 1227 put_string(stdout, cur_file_name()); 1228 put_string(stdout, " */\n"); 1229 } 1230 yyparse(); 1231 free_symbol_table(define_names); 1232 free_symbol_table(typedef_names); 1233 free_symbol_table(included_files); 1234 } 1235 1236 #ifdef NO_LEAKS 1237 void 1238 free_parser(void) 1239 { 1240 free_symbol_table (type_qualifiers); 1241 #ifdef FLEX_SCANNER 1242 if (yy_current_buffer != 0) 1243 yy_delete_buffer(yy_current_buffer); 1244 #endif 1245 } 1246 #endif 1247 #line 1248 "grammar.tab.c" 1248 1249 /* For use in generated program */ 1250 #define yydepth (int)(yystack.s_mark - yystack.s_base) 1251 #if YYBTYACC 1252 #define yytrial (yyps->save) 1253 #endif /* YYBTYACC */ 1254 1255 #if YYDEBUG 1256 #include <stdio.h> /* needed for printf */ 1257 #endif 1258 1259 #include <stdlib.h> /* needed for malloc, etc */ 1260 #include <string.h> /* needed for memset */ 1261 1262 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 1263 static int yygrowstack(YYSTACKDATA *data) 1264 { 1265 int i; 1266 unsigned newsize; 1267 short *newss; 1268 YYSTYPE *newvs; 1269 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1270 YYLTYPE *newps; 1271 #endif 1272 1273 if ((newsize = data->stacksize) == 0) 1274 newsize = YYINITSTACKSIZE; 1275 else if (newsize >= YYMAXDEPTH) 1276 return YYENOMEM; 1277 else if ((newsize *= 2) > YYMAXDEPTH) 1278 newsize = YYMAXDEPTH; 1279 1280 i = (int) (data->s_mark - data->s_base); 1281 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); 1282 if (newss == 0) 1283 return YYENOMEM; 1284 1285 data->s_base = newss; 1286 data->s_mark = newss + i; 1287 1288 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 1289 if (newvs == 0) 1290 return YYENOMEM; 1291 1292 data->l_base = newvs; 1293 data->l_mark = newvs + i; 1294 1295 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1296 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 1297 if (newps == 0) 1298 return YYENOMEM; 1299 1300 data->p_base = newps; 1301 data->p_mark = newps + i; 1302 #endif 1303 1304 data->stacksize = newsize; 1305 data->s_last = data->s_base + newsize - 1; 1306 1307 #if YYDEBUG 1308 if (yydebug) 1309 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 1310 #endif 1311 return 0; 1312 } 1313 1314 #if YYPURE || defined(YY_NO_LEAKS) 1315 static void yyfreestack(YYSTACKDATA *data) 1316 { 1317 free(data->s_base); 1318 free(data->l_base); 1319 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1320 free(data->p_base); 1321 #endif 1322 memset(data, 0, sizeof(*data)); 1323 } 1324 #else 1325 #define yyfreestack(data) /* nothing */ 1326 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 1327 #if YYBTYACC 1328 1329 static YYParseState * 1330 yyNewState(unsigned size) 1331 { 1332 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 1333 if (p == NULL) return NULL; 1334 1335 p->yystack.stacksize = size; 1336 if (size == 0) 1337 { 1338 p->yystack.s_base = NULL; 1339 p->yystack.l_base = NULL; 1340 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1341 p->yystack.p_base = NULL; 1342 #endif 1343 return p; 1344 } 1345 p->yystack.s_base = (short *) malloc(size * sizeof(short)); 1346 if (p->yystack.s_base == NULL) return NULL; 1347 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 1348 if (p->yystack.l_base == NULL) return NULL; 1349 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 1350 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1351 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 1352 if (p->yystack.p_base == NULL) return NULL; 1353 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 1354 #endif 1355 1356 return p; 1357 } 1358 1359 static void 1360 yyFreeState(YYParseState *p) 1361 { 1362 yyfreestack(&p->yystack); 1363 free(p); 1364 } 1365 #endif /* YYBTYACC */ 1366 1367 #define YYABORT goto yyabort 1368 #define YYREJECT goto yyabort 1369 #define YYACCEPT goto yyaccept 1370 #define YYERROR goto yyerrlab 1371 #if YYBTYACC 1372 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 1373 #define YYVALID_NESTED do { if (yyps->save && \ 1374 yyps->save->save == 0) goto yyvalid; } while(0) 1375 #endif /* YYBTYACC */ 1376 1377 int 1378 YYPARSE_DECL() 1379 { 1380 int yym, yyn, yystate, yyresult; 1381 #if YYBTYACC 1382 int yynewerrflag; 1383 YYParseState *yyerrctx = NULL; 1384 #endif /* YYBTYACC */ 1385 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1386 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 1387 #endif 1388 #if YYDEBUG 1389 const char *yys; 1390 1391 if ((yys = getenv("YYDEBUG")) != 0) 1392 { 1393 yyn = *yys; 1394 if (yyn >= '0' && yyn <= '9') 1395 yydebug = yyn - '0'; 1396 } 1397 if (yydebug) 1398 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 1399 #endif 1400 1401 #if YYBTYACC 1402 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 1403 yyps->save = 0; 1404 #endif /* YYBTYACC */ 1405 yynerrs = 0; 1406 yyerrflag = 0; 1407 yychar = YYEMPTY; 1408 yystate = 0; 1409 1410 #if YYPURE 1411 memset(&yystack, 0, sizeof(yystack)); 1412 #endif 1413 1414 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1415 yystack.s_mark = yystack.s_base; 1416 yystack.l_mark = yystack.l_base; 1417 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1418 yystack.p_mark = yystack.p_base; 1419 #endif 1420 yystate = 0; 1421 *yystack.s_mark = 0; 1422 1423 yyloop: 1424 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 1425 if (yychar < 0) 1426 { 1427 #if YYBTYACC 1428 do { 1429 if (yylvp < yylve) 1430 { 1431 /* we're currently re-reading tokens */ 1432 yylval = *yylvp++; 1433 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1434 yylloc = *yylpp++; 1435 #endif 1436 yychar = *yylexp++; 1437 break; 1438 } 1439 if (yyps->save) 1440 { 1441 /* in trial mode; save scanner results for future parse attempts */ 1442 if (yylvp == yylvlim) 1443 { /* Enlarge lexical value queue */ 1444 int p = yylvp - yylvals; 1445 int s = yylvlim - yylvals; 1446 1447 s += YYLVQUEUEGROWTH; 1448 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; 1449 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 1450 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1451 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 1452 #endif 1453 yylvp = yylve = yylvals + p; 1454 yylvlim = yylvals + s; 1455 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1456 yylpp = yylpe = yylpsns + p; 1457 yylplim = yylpsns + s; 1458 #endif 1459 yylexp = yylexemes + p; 1460 } 1461 *yylexp = (short) YYLEX; 1462 *yylvp++ = yylval; 1463 yylve++; 1464 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1465 *yylpp++ = yylloc; 1466 yylpe++; 1467 #endif 1468 yychar = *yylexp++; 1469 break; 1470 } 1471 /* normal operation, no conflict encountered */ 1472 #endif /* YYBTYACC */ 1473 yychar = YYLEX; 1474 #if YYBTYACC 1475 } while (0); 1476 #endif /* YYBTYACC */ 1477 if (yychar < 0) yychar = YYEOF; 1478 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 1479 #if YYDEBUG 1480 if (yydebug) 1481 { 1482 yys = yyname[YYTRANSLATE(yychar)]; 1483 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 1484 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1485 #ifdef YYSTYPE_TOSTRING 1486 #if YYBTYACC 1487 if (!yytrial) 1488 #endif /* YYBTYACC */ 1489 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 1490 #endif 1491 fputc('\n', stderr); 1492 } 1493 #endif 1494 } 1495 #if YYBTYACC 1496 1497 /* Do we have a conflict? */ 1498 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1499 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1500 { 1501 YYINT ctry; 1502 1503 if (yypath) 1504 { 1505 YYParseState *save; 1506 #if YYDEBUG 1507 if (yydebug) 1508 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 1509 YYDEBUGSTR, yydepth, yystate); 1510 #endif 1511 /* Switch to the next conflict context */ 1512 save = yypath; 1513 yypath = save->save; 1514 save->save = NULL; 1515 ctry = save->ctry; 1516 if (save->state != yystate) YYABORT; 1517 yyFreeState(save); 1518 1519 } 1520 else 1521 { 1522 1523 /* Unresolved conflict - start/continue trial parse */ 1524 YYParseState *save; 1525 #if YYDEBUG 1526 if (yydebug) 1527 { 1528 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 1529 if (yyps->save) 1530 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 1531 else 1532 fputs("Starting trial parse.\n", stderr); 1533 } 1534 #endif 1535 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1536 if (save == NULL) goto yyenomem; 1537 save->save = yyps->save; 1538 save->state = yystate; 1539 save->errflag = yyerrflag; 1540 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 1541 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1542 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 1543 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1544 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1545 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 1546 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1547 #endif 1548 ctry = yytable[yyn]; 1549 if (yyctable[ctry] == -1) 1550 { 1551 #if YYDEBUG 1552 if (yydebug && yychar >= YYEOF) 1553 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 1554 #endif 1555 ctry++; 1556 } 1557 save->ctry = ctry; 1558 if (yyps->save == NULL) 1559 { 1560 /* If this is a first conflict in the stack, start saving lexemes */ 1561 if (!yylexemes) 1562 { 1563 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); 1564 if (yylexemes == NULL) goto yyenomem; 1565 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 1566 if (yylvals == NULL) goto yyenomem; 1567 yylvlim = yylvals + YYLVQUEUEGROWTH; 1568 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1569 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 1570 if (yylpsns == NULL) goto yyenomem; 1571 yylplim = yylpsns + YYLVQUEUEGROWTH; 1572 #endif 1573 } 1574 if (yylvp == yylve) 1575 { 1576 yylvp = yylve = yylvals; 1577 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1578 yylpp = yylpe = yylpsns; 1579 #endif 1580 yylexp = yylexemes; 1581 if (yychar >= YYEOF) 1582 { 1583 *yylve++ = yylval; 1584 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1585 *yylpe++ = yylloc; 1586 #endif 1587 *yylexp = (short) yychar; 1588 yychar = YYEMPTY; 1589 } 1590 } 1591 } 1592 if (yychar >= YYEOF) 1593 { 1594 yylvp--; 1595 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1596 yylpp--; 1597 #endif 1598 yylexp--; 1599 yychar = YYEMPTY; 1600 } 1601 save->lexeme = yylvp - yylvals; 1602 yyps->save = save; 1603 } 1604 if (yytable[yyn] == ctry) 1605 { 1606 #if YYDEBUG 1607 if (yydebug) 1608 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1609 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 1610 #endif 1611 if (yychar < 0) 1612 { 1613 yylvp++; 1614 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1615 yylpp++; 1616 #endif 1617 yylexp++; 1618 } 1619 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 1620 goto yyoverflow; 1621 yystate = yyctable[ctry]; 1622 *++yystack.s_mark = (short) yystate; 1623 *++yystack.l_mark = yylval; 1624 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1625 *++yystack.p_mark = yylloc; 1626 #endif 1627 yychar = YYEMPTY; 1628 if (yyerrflag > 0) --yyerrflag; 1629 goto yyloop; 1630 } 1631 else 1632 { 1633 yyn = yyctable[ctry]; 1634 goto yyreduce; 1635 } 1636 } /* End of code dealing with conflicts */ 1637 #endif /* YYBTYACC */ 1638 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1639 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1640 { 1641 #if YYDEBUG 1642 if (yydebug) 1643 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1644 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 1645 #endif 1646 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1647 yystate = yytable[yyn]; 1648 *++yystack.s_mark = yytable[yyn]; 1649 *++yystack.l_mark = yylval; 1650 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1651 *++yystack.p_mark = yylloc; 1652 #endif 1653 yychar = YYEMPTY; 1654 if (yyerrflag > 0) --yyerrflag; 1655 goto yyloop; 1656 } 1657 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1658 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1659 { 1660 yyn = yytable[yyn]; 1661 goto yyreduce; 1662 } 1663 if (yyerrflag != 0) goto yyinrecovery; 1664 #if YYBTYACC 1665 1666 yynewerrflag = 1; 1667 goto yyerrhandler; 1668 goto yyerrlab; 1669 1670 yyerrlab: 1671 yynewerrflag = 0; 1672 yyerrhandler: 1673 while (yyps->save) 1674 { 1675 int ctry; 1676 YYParseState *save = yyps->save; 1677 #if YYDEBUG 1678 if (yydebug) 1679 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 1680 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 1681 (int)(yylvp - yylvals - yyps->save->lexeme)); 1682 #endif 1683 /* Memorize most forward-looking error state in case it's really an error. */ 1684 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 1685 { 1686 /* Free old saved error context state */ 1687 if (yyerrctx) yyFreeState(yyerrctx); 1688 /* Create and fill out new saved error context state */ 1689 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1690 if (yyerrctx == NULL) goto yyenomem; 1691 yyerrctx->save = yyps->save; 1692 yyerrctx->state = yystate; 1693 yyerrctx->errflag = yyerrflag; 1694 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 1695 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1696 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 1697 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1698 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1699 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 1700 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1701 #endif 1702 yyerrctx->lexeme = yylvp - yylvals; 1703 } 1704 yylvp = yylvals + save->lexeme; 1705 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1706 yylpp = yylpsns + save->lexeme; 1707 #endif 1708 yylexp = yylexemes + save->lexeme; 1709 yychar = YYEMPTY; 1710 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 1711 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1712 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 1713 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1714 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1715 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 1716 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1717 #endif 1718 ctry = ++save->ctry; 1719 yystate = save->state; 1720 /* We tried shift, try reduce now */ 1721 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 1722 yyps->save = save->save; 1723 save->save = NULL; 1724 yyFreeState(save); 1725 1726 /* Nothing left on the stack -- error */ 1727 if (!yyps->save) 1728 { 1729 #if YYDEBUG 1730 if (yydebug) 1731 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1732 YYPREFIX, yydepth); 1733 #endif 1734 /* Restore state as it was in the most forward-advanced error */ 1735 yylvp = yylvals + yyerrctx->lexeme; 1736 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1737 yylpp = yylpsns + yyerrctx->lexeme; 1738 #endif 1739 yylexp = yylexemes + yyerrctx->lexeme; 1740 yychar = yylexp[-1]; 1741 yylval = yylvp[-1]; 1742 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1743 yylloc = yylpp[-1]; 1744 #endif 1745 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1746 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1747 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1748 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1749 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1750 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1751 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1752 #endif 1753 yystate = yyerrctx->state; 1754 yyFreeState(yyerrctx); 1755 yyerrctx = NULL; 1756 } 1757 yynewerrflag = 1; 1758 } 1759 if (yynewerrflag == 0) goto yyinrecovery; 1760 #endif /* YYBTYACC */ 1761 1762 YYERROR_CALL("syntax error"); 1763 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1764 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1765 #endif 1766 1767 #if !YYBTYACC 1768 goto yyerrlab; 1769 yyerrlab: 1770 #endif 1771 ++yynerrs; 1772 1773 yyinrecovery: 1774 if (yyerrflag < 3) 1775 { 1776 yyerrflag = 3; 1777 for (;;) 1778 { 1779 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1780 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1781 { 1782 #if YYDEBUG 1783 if (yydebug) 1784 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1785 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1786 #endif 1787 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1788 yystate = yytable[yyn]; 1789 *++yystack.s_mark = yytable[yyn]; 1790 *++yystack.l_mark = yylval; 1791 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1792 /* lookahead position is error end position */ 1793 yyerror_loc_range[1] = yylloc; 1794 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1795 *++yystack.p_mark = yyloc; 1796 #endif 1797 goto yyloop; 1798 } 1799 else 1800 { 1801 #if YYDEBUG 1802 if (yydebug) 1803 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1804 YYDEBUGSTR, yydepth, *yystack.s_mark); 1805 #endif 1806 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1807 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1808 /* the current TOS position is the error start position */ 1809 yyerror_loc_range[0] = *yystack.p_mark; 1810 #endif 1811 #if defined(YYDESTRUCT_CALL) 1812 #if YYBTYACC 1813 if (!yytrial) 1814 #endif /* YYBTYACC */ 1815 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1816 YYDESTRUCT_CALL("error: discarding state", 1817 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1818 #else 1819 YYDESTRUCT_CALL("error: discarding state", 1820 yystos[*yystack.s_mark], yystack.l_mark); 1821 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1822 #endif /* defined(YYDESTRUCT_CALL) */ 1823 --yystack.s_mark; 1824 --yystack.l_mark; 1825 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1826 --yystack.p_mark; 1827 #endif 1828 } 1829 } 1830 } 1831 else 1832 { 1833 if (yychar == YYEOF) goto yyabort; 1834 #if YYDEBUG 1835 if (yydebug) 1836 { 1837 yys = yyname[YYTRANSLATE(yychar)]; 1838 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1839 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1840 } 1841 #endif 1842 #if defined(YYDESTRUCT_CALL) 1843 #if YYBTYACC 1844 if (!yytrial) 1845 #endif /* YYBTYACC */ 1846 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1847 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1848 #else 1849 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1850 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1851 #endif /* defined(YYDESTRUCT_CALL) */ 1852 yychar = YYEMPTY; 1853 goto yyloop; 1854 } 1855 1856 yyreduce: 1857 yym = yylen[yyn]; 1858 #if YYDEBUG 1859 if (yydebug) 1860 { 1861 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1862 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1863 #ifdef YYSTYPE_TOSTRING 1864 #if YYBTYACC 1865 if (!yytrial) 1866 #endif /* YYBTYACC */ 1867 if (yym > 0) 1868 { 1869 int i; 1870 fputc('<', stderr); 1871 for (i = yym; i > 0; i--) 1872 { 1873 if (i != yym) fputs(", ", stderr); 1874 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1875 yystack.l_mark[1-i]), stderr); 1876 } 1877 fputc('>', stderr); 1878 } 1879 #endif 1880 fputc('\n', stderr); 1881 } 1882 #endif 1883 if (yym > 0) 1884 yyval = yystack.l_mark[1-yym]; 1885 else 1886 memset(&yyval, 0, sizeof yyval); 1887 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1888 1889 /* Perform position reduction */ 1890 memset(&yyloc, 0, sizeof(yyloc)); 1891 #if YYBTYACC 1892 if (!yytrial) 1893 #endif /* YYBTYACC */ 1894 { 1895 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1896 /* just in case YYERROR is invoked within the action, save 1897 the start of the rhs as the error start position */ 1898 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1899 } 1900 #endif 1901 1902 switch (yyn) 1903 { 1904 case 10: 1905 #line 377 "grammar.y" 1906 { 1907 yyerrok; 1908 } 1909 break; 1910 case 11: 1911 #line 381 "grammar.y" 1912 { 1913 yyerrok; 1914 } 1915 break; 1916 case 13: 1917 #line 392 "grammar.y" 1918 { 1919 /* Provide an empty action here so bison will not complain about 1920 * incompatible types in the default action it normally would 1921 * have generated. 1922 */ 1923 } 1924 break; 1925 case 14: 1926 #line 399 "grammar.y" 1927 { 1928 /* empty */ 1929 } 1930 break; 1931 case 15: 1932 #line 406 "grammar.y" 1933 { 1934 #if OPT_LINTLIBRARY 1935 if (types_out && want_typedef()) { 1936 gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0); 1937 flush_varargs(); 1938 } 1939 #endif 1940 free_decl_spec(&yystack.l_mark[-1].decl_spec); 1941 end_typedef(); 1942 } 1943 break; 1944 case 16: 1945 #line 417 "grammar.y" 1946 { 1947 if (func_params != NULL) { 1948 set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); 1949 } else { 1950 gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); 1951 #if OPT_LINTLIBRARY 1952 flush_varargs(); 1953 #endif 1954 free_decl_list(&yystack.l_mark[-1].decl_list); 1955 } 1956 free_decl_spec(&yystack.l_mark[-2].decl_spec); 1957 end_typedef(); 1958 } 1959 break; 1960 case 17: 1961 #line 431 "grammar.y" 1962 { 1963 cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; 1964 free_decl_spec(&yystack.l_mark[0].decl_spec); 1965 } 1966 break; 1967 case 18: 1968 #line 436 "grammar.y" 1969 { 1970 end_typedef(); 1971 } 1972 break; 1973 case 19: 1974 #line 443 "grammar.y" 1975 { 1976 begin_typedef(); 1977 } 1978 break; 1979 case 20: 1980 #line 447 "grammar.y" 1981 { 1982 begin_typedef(); 1983 } 1984 break; 1985 case 23: 1986 #line 459 "grammar.y" 1987 { 1988 int flags = cur_decl_spec_flags; 1989 1990 /* If the typedef is a pointer type, then reset the short type 1991 * flags so it does not get promoted. 1992 */ 1993 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0) 1994 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); 1995 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags); 1996 free_declarator(yystack.l_mark[0].declarator); 1997 } 1998 break; 1999 case 24: 2000 #line 471 "grammar.y" 2001 { 2002 int flags = cur_decl_spec_flags; 2003 2004 if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0) 2005 flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); 2006 new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags); 2007 free_declarator(yystack.l_mark[0].declarator); 2008 } 2009 break; 2010 case 25: 2011 #line 483 "grammar.y" 2012 { 2013 check_untagged(&yystack.l_mark[-1].decl_spec); 2014 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { 2015 yyerror("syntax error"); 2016 YYERROR; 2017 } 2018 func_params = &(yystack.l_mark[0].declarator->head->params); 2019 func_params->begin_comment = cur_file->begin_comment; 2020 func_params->end_comment = cur_file->end_comment; 2021 } 2022 break; 2023 case 26: 2024 #line 494 "grammar.y" 2025 { 2026 /* If we're converting to K&R and we've got a nominally K&R 2027 * function which has a parameter which is ANSI (i.e., a prototyped 2028 * function pointer), then we must override the deciphered value of 2029 * 'func_def' so that the parameter will be converted. 2030 */ 2031 if (func_style == FUNC_TRADITIONAL 2032 && haveAnsiParam() 2033 && yystack.l_mark[-3].declarator->head->func_def == func_style) { 2034 yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH; 2035 } 2036 2037 func_params = NULL; 2038 2039 if (cur_file->convert) 2040 gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator); 2041 gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator); 2042 #if OPT_LINTLIBRARY 2043 flush_varargs(); 2044 #endif 2045 free_decl_spec(&yystack.l_mark[-4].decl_spec); 2046 free_declarator(yystack.l_mark[-3].declarator); 2047 } 2048 break; 2049 case 28: 2050 #line 519 "grammar.y" 2051 { 2052 if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { 2053 yyerror("syntax error"); 2054 YYERROR; 2055 } 2056 func_params = &(yystack.l_mark[0].declarator->head->params); 2057 func_params->begin_comment = cur_file->begin_comment; 2058 func_params->end_comment = cur_file->end_comment; 2059 } 2060 break; 2061 case 29: 2062 #line 529 "grammar.y" 2063 { 2064 DeclSpec decl_spec; 2065 2066 func_params = NULL; 2067 2068 new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE); 2069 if (cur_file->convert) 2070 gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator); 2071 gen_prototype(&decl_spec, yystack.l_mark[-4].declarator); 2072 #if OPT_LINTLIBRARY 2073 flush_varargs(); 2074 #endif 2075 free_decl_spec(&decl_spec); 2076 free_declarator(yystack.l_mark[-4].declarator); 2077 } 2078 break; 2079 case 36: 2080 #line 560 "grammar.y" 2081 { 2082 join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); 2083 free(yystack.l_mark[-1].decl_spec.text); 2084 free(yystack.l_mark[0].decl_spec.text); 2085 } 2086 break; 2087 case 40: 2088 #line 575 "grammar.y" 2089 { 2090 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2091 } 2092 break; 2093 case 41: 2094 #line 579 "grammar.y" 2095 { 2096 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); 2097 } 2098 break; 2099 case 42: 2100 #line 583 "grammar.y" 2101 { 2102 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2103 } 2104 break; 2105 case 43: 2106 #line 587 "grammar.y" 2107 { 2108 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); 2109 } 2110 break; 2111 case 44: 2112 #line 591 "grammar.y" 2113 { 2114 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); 2115 } 2116 break; 2117 case 45: 2118 #line 595 "grammar.y" 2119 { 2120 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); 2121 } 2122 break; 2123 case 46: 2124 #line 602 "grammar.y" 2125 { 2126 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); 2127 } 2128 break; 2129 case 47: 2130 #line 606 "grammar.y" 2131 { 2132 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2133 } 2134 break; 2135 case 48: 2136 #line 610 "grammar.y" 2137 { 2138 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); 2139 } 2140 break; 2141 case 49: 2142 #line 614 "grammar.y" 2143 { 2144 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2145 } 2146 break; 2147 case 50: 2148 #line 618 "grammar.y" 2149 { 2150 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2151 } 2152 break; 2153 case 51: 2154 #line 622 "grammar.y" 2155 { 2156 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); 2157 } 2158 break; 2159 case 52: 2160 #line 626 "grammar.y" 2161 { 2162 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2163 } 2164 break; 2165 case 53: 2166 #line 630 "grammar.y" 2167 { 2168 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2169 } 2170 break; 2171 case 54: 2172 #line 634 "grammar.y" 2173 { 2174 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2175 } 2176 break; 2177 case 55: 2178 #line 638 "grammar.y" 2179 { 2180 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); 2181 } 2182 break; 2183 case 56: 2184 #line 642 "grammar.y" 2185 { 2186 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2187 } 2188 break; 2189 case 57: 2190 #line 646 "grammar.y" 2191 { 2192 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2193 } 2194 break; 2195 case 58: 2196 #line 650 "grammar.y" 2197 { 2198 Symbol *s; 2199 s = find_symbol(typedef_names, yystack.l_mark[0].text.text); 2200 if (s != NULL) 2201 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags); 2202 } 2203 break; 2204 case 61: 2205 #line 662 "grammar.y" 2206 { 2207 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); 2208 } 2209 break; 2210 case 62: 2211 #line 666 "grammar.y" 2212 { 2213 /* This rule allows the <pointer> nonterminal to scan #define 2214 * names as if they were type modifiers. 2215 */ 2216 Symbol *s; 2217 s = find_symbol(define_names, yystack.l_mark[0].text.text); 2218 if (s != NULL) 2219 new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags); 2220 } 2221 break; 2222 case 63: 2223 #line 679 "grammar.y" 2224 { 2225 char *s; 2226 if ((s = implied_typedef()) == 0) 2227 (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text); 2228 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); 2229 } 2230 break; 2231 case 64: 2232 #line 686 "grammar.y" 2233 { 2234 char *s; 2235 if ((s = implied_typedef()) == 0) 2236 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text); 2237 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); 2238 } 2239 break; 2240 case 65: 2241 #line 693 "grammar.y" 2242 { 2243 (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); 2244 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); 2245 } 2246 break; 2247 case 66: 2248 #line 701 "grammar.y" 2249 { 2250 imply_typedef(yyval.text.text); 2251 } 2252 break; 2253 case 67: 2254 #line 705 "grammar.y" 2255 { 2256 imply_typedef(yyval.text.text); 2257 } 2258 break; 2259 case 68: 2260 #line 712 "grammar.y" 2261 { 2262 new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); 2263 } 2264 break; 2265 case 69: 2266 #line 716 "grammar.y" 2267 { 2268 add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); 2269 } 2270 break; 2271 case 70: 2272 #line 723 "grammar.y" 2273 { 2274 if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL && 2275 func_style == FUNC_TRADITIONAL && cur_file->convert) { 2276 gen_func_declarator(yystack.l_mark[0].declarator); 2277 fputs(cur_text(), cur_file->tmp_file); 2278 } 2279 cur_declarator = yyval.declarator; 2280 } 2281 break; 2282 case 71: 2283 #line 732 "grammar.y" 2284 { 2285 if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL && 2286 func_style == FUNC_TRADITIONAL && cur_file->convert) { 2287 gen_func_declarator(yystack.l_mark[-1].declarator); 2288 fputs(" =", cur_file->tmp_file); 2289 } 2290 } 2291 break; 2292 case 73: 2293 #line 744 "grammar.y" 2294 { 2295 char *s; 2296 if ((s = implied_typedef()) == 0) 2297 (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text); 2298 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); 2299 } 2300 break; 2301 case 74: 2302 #line 751 "grammar.y" 2303 { 2304 char *s; 2305 if ((s = implied_typedef()) == 0) 2306 (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text); 2307 new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); 2308 } 2309 break; 2310 case 75: 2311 #line 758 "grammar.y" 2312 { 2313 (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text); 2314 new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); 2315 } 2316 break; 2317 case 76: 2318 #line 766 "grammar.y" 2319 { 2320 imply_typedef("enum"); 2321 yyval.text = yystack.l_mark[0].text; 2322 } 2323 break; 2324 case 79: 2325 #line 779 "grammar.y" 2326 { 2327 yyval.declarator = yystack.l_mark[0].declarator; 2328 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); 2329 free(yyval.declarator->text); 2330 yyval.declarator->text = xstrdup(buf); 2331 yyval.declarator->begin = yystack.l_mark[-1].text.begin; 2332 yyval.declarator->pointer = TRUE; 2333 } 2334 break; 2335 case 81: 2336 #line 792 "grammar.y" 2337 { 2338 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); 2339 } 2340 break; 2341 case 82: 2342 #line 796 "grammar.y" 2343 { 2344 yyval.declarator = yystack.l_mark[-1].declarator; 2345 (void)sprintf(buf, "(%s)", yyval.declarator->text); 2346 free(yyval.declarator->text); 2347 yyval.declarator->text = xstrdup(buf); 2348 yyval.declarator->begin = yystack.l_mark[-2].text.begin; 2349 } 2350 break; 2351 case 83: 2352 #line 804 "grammar.y" 2353 { 2354 yyval.declarator = yystack.l_mark[-1].declarator; 2355 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); 2356 free(yyval.declarator->text); 2357 yyval.declarator->text = xstrdup(buf); 2358 } 2359 break; 2360 case 84: 2361 #line 811 "grammar.y" 2362 { 2363 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); 2364 yyval.declarator->params = yystack.l_mark[-1].param_list; 2365 yyval.declarator->func_stack = yystack.l_mark[-3].declarator; 2366 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head; 2367 yyval.declarator->func_def = FUNC_ANSI; 2368 } 2369 break; 2370 case 85: 2371 #line 819 "grammar.y" 2372 { 2373 yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); 2374 yyval.declarator->params = yystack.l_mark[-1].param_list; 2375 yyval.declarator->func_stack = yystack.l_mark[-3].declarator; 2376 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head; 2377 yyval.declarator->func_def = FUNC_TRADITIONAL; 2378 } 2379 break; 2380 case 86: 2381 #line 830 "grammar.y" 2382 { 2383 (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text); 2384 yyval.text.begin = yystack.l_mark[-1].text.begin; 2385 } 2386 break; 2387 case 87: 2388 #line 835 "grammar.y" 2389 { 2390 (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); 2391 yyval.text.begin = yystack.l_mark[-2].text.begin; 2392 } 2393 break; 2394 case 88: 2395 #line 843 "grammar.y" 2396 { 2397 strcpy(yyval.text.text, ""); 2398 yyval.text.begin = 0L; 2399 } 2400 break; 2401 case 90: 2402 #line 852 "grammar.y" 2403 { 2404 (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); 2405 yyval.text.begin = yystack.l_mark[0].decl_spec.begin; 2406 free(yystack.l_mark[0].decl_spec.text); 2407 } 2408 break; 2409 case 91: 2410 #line 858 "grammar.y" 2411 { 2412 (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text); 2413 yyval.text.begin = yystack.l_mark[-1].text.begin; 2414 free(yystack.l_mark[0].decl_spec.text); 2415 } 2416 break; 2417 case 93: 2418 #line 868 "grammar.y" 2419 { 2420 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); 2421 } 2422 break; 2423 case 94: 2424 #line 875 "grammar.y" 2425 { 2426 new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); 2427 } 2428 break; 2429 case 95: 2430 #line 879 "grammar.y" 2431 { 2432 add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); 2433 } 2434 break; 2435 case 96: 2436 #line 886 "grammar.y" 2437 { 2438 check_untagged(&yystack.l_mark[-1].decl_spec); 2439 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); 2440 } 2441 break; 2442 case 97: 2443 #line 891 "grammar.y" 2444 { 2445 check_untagged(&yystack.l_mark[-1].decl_spec); 2446 yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); 2447 } 2448 break; 2449 case 98: 2450 #line 896 "grammar.y" 2451 { 2452 check_untagged(&yystack.l_mark[0].decl_spec); 2453 yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); 2454 } 2455 break; 2456 case 99: 2457 #line 904 "grammar.y" 2458 { 2459 new_ident_list(&yyval.param_list); 2460 } 2461 break; 2462 case 101: 2463 #line 912 "grammar.y" 2464 { 2465 new_ident_list(&yyval.param_list); 2466 add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); 2467 } 2468 break; 2469 case 102: 2470 #line 917 "grammar.y" 2471 { 2472 add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); 2473 } 2474 break; 2475 case 103: 2476 #line 924 "grammar.y" 2477 { 2478 yyval.text = yystack.l_mark[0].text; 2479 } 2480 break; 2481 case 104: 2482 #line 928 "grammar.y" 2483 { 2484 #if OPT_LINTLIBRARY 2485 if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ 2486 yyval.text = yystack.l_mark[0].text; 2487 } else 2488 #endif 2489 (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text); 2490 yyval.text.begin = yystack.l_mark[-1].text.begin; 2491 } 2492 break; 2493 case 105: 2494 #line 941 "grammar.y" 2495 { 2496 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); 2497 } 2498 break; 2499 case 106: 2500 #line 945 "grammar.y" 2501 { 2502 yyval.declarator = yystack.l_mark[0].declarator; 2503 (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); 2504 free(yyval.declarator->text); 2505 yyval.declarator->text = xstrdup(buf); 2506 yyval.declarator->begin = yystack.l_mark[-1].text.begin; 2507 } 2508 break; 2509 case 108: 2510 #line 957 "grammar.y" 2511 { 2512 yyval.declarator = yystack.l_mark[-1].declarator; 2513 (void)sprintf(buf, "(%s)", yyval.declarator->text); 2514 free(yyval.declarator->text); 2515 yyval.declarator->text = xstrdup(buf); 2516 yyval.declarator->begin = yystack.l_mark[-2].text.begin; 2517 } 2518 break; 2519 case 109: 2520 #line 965 "grammar.y" 2521 { 2522 yyval.declarator = yystack.l_mark[-1].declarator; 2523 (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); 2524 free(yyval.declarator->text); 2525 yyval.declarator->text = xstrdup(buf); 2526 } 2527 break; 2528 case 110: 2529 #line 972 "grammar.y" 2530 { 2531 yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); 2532 } 2533 break; 2534 case 111: 2535 #line 976 "grammar.y" 2536 { 2537 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin); 2538 yyval.declarator->params = yystack.l_mark[-1].param_list; 2539 yyval.declarator->func_stack = yystack.l_mark[-3].declarator; 2540 yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head; 2541 yyval.declarator->func_def = FUNC_ANSI; 2542 } 2543 break; 2544 case 112: 2545 #line 984 "grammar.y" 2546 { 2547 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin); 2548 yyval.declarator->func_stack = yystack.l_mark[-2].declarator; 2549 yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head; 2550 yyval.declarator->func_def = FUNC_ANSI; 2551 } 2552 break; 2553 case 113: 2554 #line 991 "grammar.y" 2555 { 2556 Declarator *d; 2557 2558 d = new_declarator("", "", yystack.l_mark[-2].text.begin); 2559 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin); 2560 yyval.declarator->params = yystack.l_mark[-1].param_list; 2561 yyval.declarator->func_stack = d; 2562 yyval.declarator->head = yyval.declarator; 2563 yyval.declarator->func_def = FUNC_ANSI; 2564 } 2565 break; 2566 case 114: 2567 #line 1002 "grammar.y" 2568 { 2569 Declarator *d; 2570 2571 d = new_declarator("", "", yystack.l_mark[-1].text.begin); 2572 yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin); 2573 yyval.declarator->func_stack = d; 2574 yyval.declarator->head = yyval.declarator; 2575 yyval.declarator->func_def = FUNC_ANSI; 2576 } 2577 break; 2578 #line 2579 "grammar.tab.c" 2579 default: 2580 break; 2581 } 2582 yystack.s_mark -= yym; 2583 yystate = *yystack.s_mark; 2584 yystack.l_mark -= yym; 2585 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2586 yystack.p_mark -= yym; 2587 #endif 2588 yym = yylhs[yyn]; 2589 if (yystate == 0 && yym == 0) 2590 { 2591 #if YYDEBUG 2592 if (yydebug) 2593 { 2594 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 2595 #ifdef YYSTYPE_TOSTRING 2596 #if YYBTYACC 2597 if (!yytrial) 2598 #endif /* YYBTYACC */ 2599 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 2600 #endif 2601 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 2602 } 2603 #endif 2604 yystate = YYFINAL; 2605 *++yystack.s_mark = YYFINAL; 2606 *++yystack.l_mark = yyval; 2607 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2608 *++yystack.p_mark = yyloc; 2609 #endif 2610 if (yychar < 0) 2611 { 2612 #if YYBTYACC 2613 do { 2614 if (yylvp < yylve) 2615 { 2616 /* we're currently re-reading tokens */ 2617 yylval = *yylvp++; 2618 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2619 yylloc = *yylpp++; 2620 #endif 2621 yychar = *yylexp++; 2622 break; 2623 } 2624 if (yyps->save) 2625 { 2626 /* in trial mode; save scanner results for future parse attempts */ 2627 if (yylvp == yylvlim) 2628 { /* Enlarge lexical value queue */ 2629 int p = yylvp - yylvals; 2630 int s = yylvlim - yylvals; 2631 2632 s += YYLVQUEUEGROWTH; 2633 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) 2634 goto yyenomem; 2635 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 2636 goto yyenomem; 2637 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2638 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 2639 goto yyenomem; 2640 #endif 2641 yylvp = yylve = yylvals + p; 2642 yylvlim = yylvals + s; 2643 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2644 yylpp = yylpe = yylpsns + p; 2645 yylplim = yylpsns + s; 2646 #endif 2647 yylexp = yylexemes + p; 2648 } 2649 *yylexp = (short) YYLEX; 2650 *yylvp++ = yylval; 2651 yylve++; 2652 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2653 *yylpp++ = yylloc; 2654 yylpe++; 2655 #endif 2656 yychar = *yylexp++; 2657 break; 2658 } 2659 /* normal operation, no conflict encountered */ 2660 #endif /* YYBTYACC */ 2661 yychar = YYLEX; 2662 #if YYBTYACC 2663 } while (0); 2664 #endif /* YYBTYACC */ 2665 if (yychar < 0) yychar = YYEOF; 2666 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 2667 #if YYDEBUG 2668 if (yydebug) 2669 { 2670 yys = yyname[YYTRANSLATE(yychar)]; 2671 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n", 2672 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 2673 } 2674 #endif 2675 } 2676 if (yychar == YYEOF) goto yyaccept; 2677 goto yyloop; 2678 } 2679 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 2680 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 2681 yystate = yytable[yyn]; 2682 else 2683 yystate = yydgoto[yym]; 2684 #if YYDEBUG 2685 if (yydebug) 2686 { 2687 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 2688 #ifdef YYSTYPE_TOSTRING 2689 #if YYBTYACC 2690 if (!yytrial) 2691 #endif /* YYBTYACC */ 2692 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 2693 #endif 2694 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 2695 } 2696 #endif 2697 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 2698 *++yystack.s_mark = (short) yystate; 2699 *++yystack.l_mark = yyval; 2700 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2701 *++yystack.p_mark = yyloc; 2702 #endif 2703 goto yyloop; 2704 #if YYBTYACC 2705 2706 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 2707 yyvalid: 2708 if (yypath) YYABORT; 2709 while (yyps->save) 2710 { 2711 YYParseState *save = yyps->save; 2712 yyps->save = save->save; 2713 save->save = yypath; 2714 yypath = save; 2715 } 2716 #if YYDEBUG 2717 if (yydebug) 2718 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 2719 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 2720 #endif 2721 if (yyerrctx) 2722 { 2723 yyFreeState(yyerrctx); 2724 yyerrctx = NULL; 2725 } 2726 yylvp = yylvals + yypath->lexeme; 2727 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2728 yylpp = yylpsns + yypath->lexeme; 2729 #endif 2730 yylexp = yylexemes + yypath->lexeme; 2731 yychar = YYEMPTY; 2732 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 2733 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 2734 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 2735 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 2736 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2737 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 2738 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 2739 #endif 2740 yystate = yypath->state; 2741 goto yyloop; 2742 #endif /* YYBTYACC */ 2743 2744 yyoverflow: 2745 YYERROR_CALL("yacc stack overflow"); 2746 #if YYBTYACC 2747 goto yyabort_nomem; 2748 yyenomem: 2749 YYERROR_CALL("memory exhausted"); 2750 yyabort_nomem: 2751 #endif /* YYBTYACC */ 2752 yyresult = 2; 2753 goto yyreturn; 2754 2755 yyabort: 2756 yyresult = 1; 2757 goto yyreturn; 2758 2759 yyaccept: 2760 #if YYBTYACC 2761 if (yyps->save) goto yyvalid; 2762 #endif /* YYBTYACC */ 2763 yyresult = 0; 2764 2765 yyreturn: 2766 #if defined(YYDESTRUCT_CALL) 2767 if (yychar != YYEOF && yychar != YYEMPTY) 2768 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2769 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 2770 #else 2771 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 2772 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 2773 2774 { 2775 YYSTYPE *pv; 2776 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2777 YYLTYPE *pp; 2778 2779 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 2780 YYDESTRUCT_CALL("cleanup: discarding state", 2781 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 2782 #else 2783 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 2784 YYDESTRUCT_CALL("cleanup: discarding state", 2785 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 2786 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 2787 } 2788 #endif /* defined(YYDESTRUCT_CALL) */ 2789 2790 #if YYBTYACC 2791 if (yyerrctx) 2792 { 2793 yyFreeState(yyerrctx); 2794 yyerrctx = NULL; 2795 } 2796 while (yyps) 2797 { 2798 YYParseState *save = yyps; 2799 yyps = save->save; 2800 save->save = NULL; 2801 yyFreeState(save); 2802 } 2803 while (yypath) 2804 { 2805 YYParseState *save = yypath; 2806 yypath = save->save; 2807 save->save = NULL; 2808 yyFreeState(save); 2809 } 2810 #endif /* YYBTYACC */ 2811 yyfreestack(&yystack); 2812 return (yyresult); 2813 } 2814