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 1 18 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") 19 20 #ifndef yyparse 21 #define yyparse destroy3_parse 22 #endif /* yyparse */ 23 24 #ifndef yylex 25 #define yylex destroy3_lex 26 #endif /* yylex */ 27 28 #ifndef yyerror 29 #define yyerror destroy3_error 30 #endif /* yyerror */ 31 32 #ifndef yychar 33 #define yychar destroy3_char 34 #endif /* yychar */ 35 36 #ifndef yyval 37 #define yyval destroy3_val 38 #endif /* yyval */ 39 40 #ifndef yylval 41 #define yylval destroy3_lval 42 #endif /* yylval */ 43 44 #ifndef yydebug 45 #define yydebug destroy3_debug 46 #endif /* yydebug */ 47 48 #ifndef yynerrs 49 #define yynerrs destroy3_nerrs 50 #endif /* yynerrs */ 51 52 #ifndef yyerrflag 53 #define yyerrflag destroy3_errflag 54 #endif /* yyerrflag */ 55 56 #ifndef yylhs 57 #define yylhs destroy3_lhs 58 #endif /* yylhs */ 59 60 #ifndef yylen 61 #define yylen destroy3_len 62 #endif /* yylen */ 63 64 #ifndef yydefred 65 #define yydefred destroy3_defred 66 #endif /* yydefred */ 67 68 #ifndef yystos 69 #define yystos destroy3_stos 70 #endif /* yystos */ 71 72 #ifndef yydgoto 73 #define yydgoto destroy3_dgoto 74 #endif /* yydgoto */ 75 76 #ifndef yysindex 77 #define yysindex destroy3_sindex 78 #endif /* yysindex */ 79 80 #ifndef yyrindex 81 #define yyrindex destroy3_rindex 82 #endif /* yyrindex */ 83 84 #ifndef yygindex 85 #define yygindex destroy3_gindex 86 #endif /* yygindex */ 87 88 #ifndef yytable 89 #define yytable destroy3_table 90 #endif /* yytable */ 91 92 #ifndef yycheck 93 #define yycheck destroy3_check 94 #endif /* yycheck */ 95 96 #ifndef yyname 97 #define yyname destroy3_name 98 #endif /* yyname */ 99 100 #ifndef yyrule 101 #define yyrule destroy3_rule 102 #endif /* yyrule */ 103 104 #if YYBTYACC 105 106 #ifndef yycindex 107 #define yycindex destroy3_cindex 108 #endif /* yycindex */ 109 110 #ifndef yyctable 111 #define yyctable destroy3_ctable 112 #endif /* yyctable */ 113 114 #endif /* YYBTYACC */ 115 116 #define YYPREFIX "destroy3_" 117 118 #define YYPURE 0 119 120 #line 7 "btyacc_destroy3.y" 121 #include <stdlib.h> 122 123 typedef enum {cGLOBAL, cLOCAL} class; 124 typedef enum {tREAL, tINTEGER} type; 125 typedef char * name; 126 127 struct symbol { class c; type t; name id; }; 128 typedef struct symbol symbol; 129 130 struct namelist { symbol *s; struct namelist *next; }; 131 typedef struct namelist namelist; 132 133 struct parser_param { 134 int *rtrn; 135 symbol ss; 136 }; 137 138 extern symbol *mksymbol(type t, class c, name id); 139 140 #ifdef YYBISON 141 #define YYLEX_DECL() yylex(void) 142 #define YYERROR_DECL() yyerror(const char *s) 143 #endif 144 #ifdef YYSTYPE 145 #undef YYSTYPE_IS_DECLARED 146 #define YYSTYPE_IS_DECLARED 1 147 #endif 148 #ifndef YYSTYPE_IS_DECLARED 149 #define YYSTYPE_IS_DECLARED 1 150 #line 53 "btyacc_destroy3.y" 151 typedef union 152 { 153 class cval; 154 type tval; 155 namelist * nlist; 156 name id; 157 } YYSTYPE; 158 #endif /* !YYSTYPE_IS_DECLARED */ 159 #line 160 "btyacc_destroy3.tab.c" 160 161 /* compatibility with bison */ 162 #ifdef YYPARSE_PARAM 163 /* compatibility with FreeBSD */ 164 # ifdef YYPARSE_PARAM_TYPE 165 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 166 # else 167 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 168 # endif 169 #else 170 # define YYPARSE_DECL() yyparse(struct parser_param *param, int flag) 171 #endif 172 173 /* Parameters sent to lex. */ 174 #ifdef YYLEX_PARAM 175 # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 176 # define YYLEX yylex(YYLEX_PARAM) 177 #else 178 # define YYLEX_DECL() yylex(void) 179 # define YYLEX yylex() 180 #endif 181 182 /* Parameters sent to yyerror. */ 183 #ifndef YYERROR_DECL 184 #define YYERROR_DECL() yyerror(struct parser_param *param, int flag, const char *s) 185 #endif 186 #ifndef YYERROR_CALL 187 #define YYERROR_CALL(msg) yyerror(param, flag, msg) 188 #endif 189 190 #ifndef YYDESTRUCT_DECL 191 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) 192 #endif 193 #ifndef YYDESTRUCT_CALL 194 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) 195 #endif 196 197 extern int YYPARSE_DECL(); 198 199 #define GLOBAL 257 200 #define LOCAL 258 201 #define REAL 259 202 #define INTEGER 260 203 #define NAME 261 204 #define YYERRCODE 256 205 typedef short YYINT; 206 static const YYINT destroy3_lhs[] = { -1, 207 0, 0, 2, 2, 3, 3, 4, 4, 1, 208 }; 209 static const YYINT destroy3_len[] = { 2, 210 8, 5, 1, 1, 1, 1, 2, 1, 6, 211 }; 212 static const YYINT destroy3_defred[] = { 0, 213 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, 214 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 215 0, 0, 0, 0, 9, 1, 216 }; 217 static const YYINT destroy3_stos[] = { 0, 218 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 219 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 220 44, 44, 266, 266, 41, 41, 221 }; 222 static const YYINT destroy3_dgoto[] = { 5, 223 10, 6, 7, 11, 224 }; 225 static const YYINT destroy3_sindex[] = { -254, 226 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, 227 -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, 228 -251, -251, -22, -19, 0, 0, 229 }; 230 static const YYINT destroy3_rindex[] = { 0, 231 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233 0, 0, 0, 0, 0, 0, 234 }; 235 #if YYBTYACC 236 static const YYINT destroy3_cindex[] = { 0, 237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 238 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239 0, 0, 0, 0, 0, 0, 240 }; 241 #endif 242 static const YYINT destroy3_gindex[] = { 0, 243 0, -6, -4, 15, 244 }; 245 #define YYTABLESIZE 222 246 static const YYINT destroy3_table[] = { 15, 247 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, 248 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, 249 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, 250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 269 14, 14, 270 }; 271 static const YYINT destroy3_check[] = { 40, 272 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, 273 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, 274 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, 275 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 279 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 280 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 281 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 282 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 294 261, 261, 295 }; 296 #if YYBTYACC 297 static const YYINT destroy3_ctable[] = { -1, 298 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 300 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 301 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 302 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 303 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 304 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 305 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 313 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 314 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 318 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 319 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 320 -1, 321 }; 322 #endif 323 #define YYFINAL 5 324 #ifndef YYDEBUG 325 #define YYDEBUG 0 326 #endif 327 #define YYMAXTOKEN 261 328 #define YYUNDFTOKEN 268 329 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 330 #if YYDEBUG 331 static const char *const destroy3_name[] = { 332 333 "$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, 334 0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 335 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 336 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 337 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 338 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 339 0,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","GLOBAL","LOCAL", 340 "REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", 341 "namelist","illegal-symbol", 342 }; 343 static const char *const destroy3_rule[] = { 344 "$accept : declaration", 345 "declaration : class type namelist '(' class ',' type ')'", 346 "declaration : type locnamelist '(' class ')'", 347 "class : GLOBAL", 348 "class : LOCAL", 349 "type : REAL", 350 "type : INTEGER", 351 "namelist : namelist NAME", 352 "namelist : NAME", 353 "locnamelist : namelist '(' LOCAL ',' type ')'", 354 355 }; 356 #endif 357 358 int yydebug; 359 int yynerrs; 360 361 int yyerrflag; 362 int yychar; 363 YYSTYPE yyval; 364 YYSTYPE yylval; 365 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 366 YYLTYPE yyloc; /* position returned by actions */ 367 YYLTYPE yylloc; /* position from the lexer */ 368 #endif 369 370 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 371 #ifndef YYLLOC_DEFAULT 372 #define YYLLOC_DEFAULT(loc, rhs, n) \ 373 do \ 374 { \ 375 if (n == 0) \ 376 { \ 377 (loc).first_line = ((rhs)[-1]).last_line; \ 378 (loc).first_column = ((rhs)[-1]).last_column; \ 379 (loc).last_line = ((rhs)[-1]).last_line; \ 380 (loc).last_column = ((rhs)[-1]).last_column; \ 381 } \ 382 else \ 383 { \ 384 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 385 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 386 (loc).last_line = ((rhs)[n-1]).last_line; \ 387 (loc).last_column = ((rhs)[n-1]).last_column; \ 388 } \ 389 } while (0) 390 #endif /* YYLLOC_DEFAULT */ 391 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 392 #if YYBTYACC 393 394 #ifndef YYLVQUEUEGROWTH 395 #define YYLVQUEUEGROWTH 32 396 #endif 397 #endif /* YYBTYACC */ 398 399 /* define the initial stack-sizes */ 400 #ifdef YYSTACKSIZE 401 #undef YYMAXDEPTH 402 #define YYMAXDEPTH YYSTACKSIZE 403 #else 404 #ifdef YYMAXDEPTH 405 #define YYSTACKSIZE YYMAXDEPTH 406 #else 407 #define YYSTACKSIZE 10000 408 #define YYMAXDEPTH 10000 409 #endif 410 #endif 411 412 #ifndef YYINITSTACKSIZE 413 #define YYINITSTACKSIZE 200 414 #endif 415 416 typedef struct { 417 unsigned stacksize; 418 YYINT *s_base; 419 YYINT *s_mark; 420 YYINT *s_last; 421 YYSTYPE *l_base; 422 YYSTYPE *l_mark; 423 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 424 YYLTYPE *p_base; 425 YYLTYPE *p_mark; 426 #endif 427 } YYSTACKDATA; 428 #if YYBTYACC 429 430 struct YYParseState_s 431 { 432 struct YYParseState_s *save; /* Previously saved parser state */ 433 YYSTACKDATA yystack; /* saved parser stack */ 434 int state; /* saved parser state */ 435 int errflag; /* saved error recovery status */ 436 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 437 YYINT ctry; /* saved index in yyctable[] for this conflict */ 438 }; 439 typedef struct YYParseState_s YYParseState; 440 #endif /* YYBTYACC */ 441 /* variables for the parser stack */ 442 static YYSTACKDATA yystack; 443 #if YYBTYACC 444 445 /* Current parser state */ 446 static YYParseState *yyps = 0; 447 448 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 449 static YYParseState *yypath = 0; 450 451 /* Base of the lexical value queue */ 452 static YYSTYPE *yylvals = 0; 453 454 /* Current position at lexical value queue */ 455 static YYSTYPE *yylvp = 0; 456 457 /* End position of lexical value queue */ 458 static YYSTYPE *yylve = 0; 459 460 /* The last allocated position at the lexical value queue */ 461 static YYSTYPE *yylvlim = 0; 462 463 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 464 /* Base of the lexical position queue */ 465 static YYLTYPE *yylpsns = 0; 466 467 /* Current position at lexical position queue */ 468 static YYLTYPE *yylpp = 0; 469 470 /* End position of lexical position queue */ 471 static YYLTYPE *yylpe = 0; 472 473 /* The last allocated position at the lexical position queue */ 474 static YYLTYPE *yylplim = 0; 475 #endif 476 477 /* Current position at lexical token queue */ 478 static short *yylexp = 0; 479 480 static short *yylexemes = 0; 481 #endif /* YYBTYACC */ 482 #line 92 "btyacc_destroy3.y" 483 484 extern int YYLEX_DECL(); 485 extern void YYERROR_DECL(); 486 #line 487 "btyacc_destroy3.tab.c" 487 488 /* Release memory associated with symbol. */ 489 #if ! defined YYDESTRUCT_IS_DECLARED 490 static void 491 YYDESTRUCT_DECL() 492 { 493 switch (psymb) 494 { 495 case 263: 496 #line 44 "btyacc_destroy3.y" 497 { 498 namelist *p = (*val).nlist; 499 while (p != NULL) 500 { namelist *pp = p; 501 p = p->next; 502 free(pp->s); free(pp); 503 } 504 } 505 break; 506 #line 507 "btyacc_destroy3.tab.c" 507 } 508 } 509 #define YYDESTRUCT_IS_DECLARED 1 510 #endif 511 512 /* For use in generated program */ 513 #define yydepth (int)(yystack.s_mark - yystack.s_base) 514 #if YYBTYACC 515 #define yytrial (yyps->save) 516 #endif /* YYBTYACC */ 517 518 #if YYDEBUG 519 #include <stdio.h> /* needed for printf */ 520 #endif 521 522 #include <stdlib.h> /* needed for malloc, etc */ 523 #include <string.h> /* needed for memset */ 524 525 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 526 static int yygrowstack(YYSTACKDATA *data) 527 { 528 int i; 529 unsigned newsize; 530 YYINT *newss; 531 YYSTYPE *newvs; 532 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 533 YYLTYPE *newps; 534 #endif 535 536 if ((newsize = data->stacksize) == 0) 537 newsize = YYINITSTACKSIZE; 538 else if (newsize >= YYMAXDEPTH) 539 return YYENOMEM; 540 else if ((newsize *= 2) > YYMAXDEPTH) 541 newsize = YYMAXDEPTH; 542 543 i = (int) (data->s_mark - data->s_base); 544 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 545 if (newss == 0) 546 return YYENOMEM; 547 548 data->s_base = newss; 549 data->s_mark = newss + i; 550 551 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 552 if (newvs == 0) 553 return YYENOMEM; 554 555 data->l_base = newvs; 556 data->l_mark = newvs + i; 557 558 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 559 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 560 if (newps == 0) 561 return YYENOMEM; 562 563 data->p_base = newps; 564 data->p_mark = newps + i; 565 #endif 566 567 data->stacksize = newsize; 568 data->s_last = data->s_base + newsize - 1; 569 570 #if YYDEBUG 571 if (yydebug) 572 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 573 #endif 574 return 0; 575 } 576 577 #if YYPURE || defined(YY_NO_LEAKS) 578 static void yyfreestack(YYSTACKDATA *data) 579 { 580 free(data->s_base); 581 free(data->l_base); 582 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 583 free(data->p_base); 584 #endif 585 memset(data, 0, sizeof(*data)); 586 } 587 #else 588 #define yyfreestack(data) /* nothing */ 589 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 590 #if YYBTYACC 591 592 static YYParseState * 593 yyNewState(unsigned size) 594 { 595 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 596 if (p == NULL) return NULL; 597 598 p->yystack.stacksize = size; 599 if (size == 0) 600 { 601 p->yystack.s_base = NULL; 602 p->yystack.l_base = NULL; 603 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 604 p->yystack.p_base = NULL; 605 #endif 606 return p; 607 } 608 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); 609 if (p->yystack.s_base == NULL) return NULL; 610 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 611 if (p->yystack.l_base == NULL) return NULL; 612 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 613 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 614 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 615 if (p->yystack.p_base == NULL) return NULL; 616 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 617 #endif 618 619 return p; 620 } 621 622 static void 623 yyFreeState(YYParseState *p) 624 { 625 yyfreestack(&p->yystack); 626 free(p); 627 } 628 #endif /* YYBTYACC */ 629 630 #define YYABORT goto yyabort 631 #define YYREJECT goto yyabort 632 #define YYACCEPT goto yyaccept 633 #define YYERROR goto yyerrlab 634 #if YYBTYACC 635 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 636 #define YYVALID_NESTED do { if (yyps->save && \ 637 yyps->save->save == 0) goto yyvalid; } while(0) 638 #endif /* YYBTYACC */ 639 640 int 641 YYPARSE_DECL() 642 { 643 int yym, yyn, yystate, yyresult; 644 #if YYBTYACC 645 int yynewerrflag; 646 YYParseState *yyerrctx = NULL; 647 #endif /* YYBTYACC */ 648 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 649 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 650 #endif 651 #if YYDEBUG 652 const char *yys; 653 654 if ((yys = getenv("YYDEBUG")) != 0) 655 { 656 yyn = *yys; 657 if (yyn >= '0' && yyn <= '9') 658 yydebug = yyn - '0'; 659 } 660 if (yydebug) 661 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 662 #endif 663 664 #if YYBTYACC 665 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 666 yyps->save = 0; 667 #endif /* YYBTYACC */ 668 yym = 0; 669 yyn = 0; 670 yynerrs = 0; 671 yyerrflag = 0; 672 yychar = YYEMPTY; 673 yystate = 0; 674 675 #if YYPURE 676 memset(&yystack, 0, sizeof(yystack)); 677 #endif 678 679 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 680 yystack.s_mark = yystack.s_base; 681 yystack.l_mark = yystack.l_base; 682 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 683 yystack.p_mark = yystack.p_base; 684 #endif 685 yystate = 0; 686 *yystack.s_mark = 0; 687 688 yyloop: 689 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 690 if (yychar < 0) 691 { 692 #if YYBTYACC 693 do { 694 if (yylvp < yylve) 695 { 696 /* we're currently re-reading tokens */ 697 yylval = *yylvp++; 698 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 699 yylloc = *yylpp++; 700 #endif 701 yychar = *yylexp++; 702 break; 703 } 704 if (yyps->save) 705 { 706 /* in trial mode; save scanner results for future parse attempts */ 707 if (yylvp == yylvlim) 708 { /* Enlarge lexical value queue */ 709 size_t p = (size_t) (yylvp - yylvals); 710 size_t s = (size_t) (yylvlim - yylvals); 711 712 s += YYLVQUEUEGROWTH; 713 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; 714 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 715 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 716 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 717 #endif 718 yylvp = yylve = yylvals + p; 719 yylvlim = yylvals + s; 720 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 721 yylpp = yylpe = yylpsns + p; 722 yylplim = yylpsns + s; 723 #endif 724 yylexp = yylexemes + p; 725 } 726 *yylexp = (short) YYLEX; 727 *yylvp++ = yylval; 728 yylve++; 729 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 730 *yylpp++ = yylloc; 731 yylpe++; 732 #endif 733 yychar = *yylexp++; 734 break; 735 } 736 /* normal operation, no conflict encountered */ 737 #endif /* YYBTYACC */ 738 yychar = YYLEX; 739 #if YYBTYACC 740 } while (0); 741 #endif /* YYBTYACC */ 742 if (yychar < 0) yychar = YYEOF; 743 #if YYDEBUG 744 if (yydebug) 745 { 746 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 747 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 748 YYDEBUGSTR, yydepth, yystate, yychar, yys); 749 #ifdef YYSTYPE_TOSTRING 750 #if YYBTYACC 751 if (!yytrial) 752 #endif /* YYBTYACC */ 753 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 754 #endif 755 fputc('\n', stderr); 756 } 757 #endif 758 } 759 #if YYBTYACC 760 761 /* Do we have a conflict? */ 762 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 763 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 764 { 765 YYINT ctry; 766 767 if (yypath) 768 { 769 YYParseState *save; 770 #if YYDEBUG 771 if (yydebug) 772 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 773 YYDEBUGSTR, yydepth, yystate); 774 #endif 775 /* Switch to the next conflict context */ 776 save = yypath; 777 yypath = save->save; 778 save->save = NULL; 779 ctry = save->ctry; 780 if (save->state != yystate) YYABORT; 781 yyFreeState(save); 782 783 } 784 else 785 { 786 787 /* Unresolved conflict - start/continue trial parse */ 788 YYParseState *save; 789 #if YYDEBUG 790 if (yydebug) 791 { 792 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 793 if (yyps->save) 794 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 795 else 796 fputs("Starting trial parse.\n", stderr); 797 } 798 #endif 799 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 800 if (save == NULL) goto yyenomem; 801 save->save = yyps->save; 802 save->state = yystate; 803 save->errflag = yyerrflag; 804 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 805 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 806 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 807 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 808 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 809 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 810 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 811 #endif 812 ctry = yytable[yyn]; 813 if (yyctable[ctry] == -1) 814 { 815 #if YYDEBUG 816 if (yydebug && yychar >= YYEOF) 817 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 818 #endif 819 ctry++; 820 } 821 save->ctry = ctry; 822 if (yyps->save == NULL) 823 { 824 /* If this is a first conflict in the stack, start saving lexemes */ 825 if (!yylexemes) 826 { 827 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); 828 if (yylexemes == NULL) goto yyenomem; 829 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 830 if (yylvals == NULL) goto yyenomem; 831 yylvlim = yylvals + YYLVQUEUEGROWTH; 832 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 833 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 834 if (yylpsns == NULL) goto yyenomem; 835 yylplim = yylpsns + YYLVQUEUEGROWTH; 836 #endif 837 } 838 if (yylvp == yylve) 839 { 840 yylvp = yylve = yylvals; 841 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 842 yylpp = yylpe = yylpsns; 843 #endif 844 yylexp = yylexemes; 845 if (yychar >= YYEOF) 846 { 847 *yylve++ = yylval; 848 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 849 *yylpe++ = yylloc; 850 #endif 851 *yylexp = (short) yychar; 852 yychar = YYEMPTY; 853 } 854 } 855 } 856 if (yychar >= YYEOF) 857 { 858 yylvp--; 859 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 860 yylpp--; 861 #endif 862 yylexp--; 863 yychar = YYEMPTY; 864 } 865 save->lexeme = (int) (yylvp - yylvals); 866 yyps->save = save; 867 } 868 if (yytable[yyn] == ctry) 869 { 870 #if YYDEBUG 871 if (yydebug) 872 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 873 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 874 #endif 875 if (yychar < 0) 876 { 877 yylvp++; 878 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 879 yylpp++; 880 #endif 881 yylexp++; 882 } 883 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 884 goto yyoverflow; 885 yystate = yyctable[ctry]; 886 *++yystack.s_mark = (YYINT) yystate; 887 *++yystack.l_mark = yylval; 888 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 889 *++yystack.p_mark = yylloc; 890 #endif 891 yychar = YYEMPTY; 892 if (yyerrflag > 0) --yyerrflag; 893 goto yyloop; 894 } 895 else 896 { 897 yyn = yyctable[ctry]; 898 goto yyreduce; 899 } 900 } /* End of code dealing with conflicts */ 901 #endif /* YYBTYACC */ 902 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 903 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 904 { 905 #if YYDEBUG 906 if (yydebug) 907 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 908 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 909 #endif 910 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 911 yystate = yytable[yyn]; 912 *++yystack.s_mark = yytable[yyn]; 913 *++yystack.l_mark = yylval; 914 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 915 *++yystack.p_mark = yylloc; 916 #endif 917 yychar = YYEMPTY; 918 if (yyerrflag > 0) --yyerrflag; 919 goto yyloop; 920 } 921 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 922 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 923 { 924 yyn = yytable[yyn]; 925 goto yyreduce; 926 } 927 if (yyerrflag != 0) goto yyinrecovery; 928 #if YYBTYACC 929 930 yynewerrflag = 1; 931 goto yyerrhandler; 932 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 933 934 yyerrlab: 935 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 936 * before looking for error recovery */ 937 yystack.s_mark -= yym; 938 yystate = *yystack.s_mark; 939 yystack.l_mark -= yym; 940 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 941 yystack.p_mark -= yym; 942 #endif 943 944 yynewerrflag = 0; 945 yyerrhandler: 946 while (yyps->save) 947 { 948 int ctry; 949 YYParseState *save = yyps->save; 950 #if YYDEBUG 951 if (yydebug) 952 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 953 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 954 (int)(yylvp - yylvals - yyps->save->lexeme)); 955 #endif 956 /* Memorize most forward-looking error state in case it's really an error. */ 957 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 958 { 959 /* Free old saved error context state */ 960 if (yyerrctx) yyFreeState(yyerrctx); 961 /* Create and fill out new saved error context state */ 962 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 963 if (yyerrctx == NULL) goto yyenomem; 964 yyerrctx->save = yyps->save; 965 yyerrctx->state = yystate; 966 yyerrctx->errflag = yyerrflag; 967 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 968 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 969 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 970 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 971 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 972 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 973 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 974 #endif 975 yyerrctx->lexeme = (int) (yylvp - yylvals); 976 } 977 yylvp = yylvals + save->lexeme; 978 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 979 yylpp = yylpsns + save->lexeme; 980 #endif 981 yylexp = yylexemes + save->lexeme; 982 yychar = YYEMPTY; 983 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 984 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 985 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 986 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 987 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 988 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 989 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 990 #endif 991 ctry = ++save->ctry; 992 yystate = save->state; 993 /* We tried shift, try reduce now */ 994 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 995 yyps->save = save->save; 996 save->save = NULL; 997 yyFreeState(save); 998 999 /* Nothing left on the stack -- error */ 1000 if (!yyps->save) 1001 { 1002 #if YYDEBUG 1003 if (yydebug) 1004 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1005 YYPREFIX, yydepth); 1006 #endif 1007 /* Restore state as it was in the most forward-advanced error */ 1008 yylvp = yylvals + yyerrctx->lexeme; 1009 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1010 yylpp = yylpsns + yyerrctx->lexeme; 1011 #endif 1012 yylexp = yylexemes + yyerrctx->lexeme; 1013 yychar = yylexp[-1]; 1014 yylval = yylvp[-1]; 1015 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1016 yylloc = yylpp[-1]; 1017 #endif 1018 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1019 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1020 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1021 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1022 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1023 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1024 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1025 #endif 1026 yystate = yyerrctx->state; 1027 yyFreeState(yyerrctx); 1028 yyerrctx = NULL; 1029 } 1030 yynewerrflag = 1; 1031 } 1032 if (yynewerrflag == 0) goto yyinrecovery; 1033 #endif /* YYBTYACC */ 1034 1035 YYERROR_CALL("syntax error"); 1036 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1037 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1038 #endif 1039 1040 #if !YYBTYACC 1041 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1042 yyerrlab: 1043 #endif 1044 ++yynerrs; 1045 1046 yyinrecovery: 1047 if (yyerrflag < 3) 1048 { 1049 yyerrflag = 3; 1050 for (;;) 1051 { 1052 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1053 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1054 { 1055 #if YYDEBUG 1056 if (yydebug) 1057 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1058 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1059 #endif 1060 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1061 yystate = yytable[yyn]; 1062 *++yystack.s_mark = yytable[yyn]; 1063 *++yystack.l_mark = yylval; 1064 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1065 /* lookahead position is error end position */ 1066 yyerror_loc_range[1] = yylloc; 1067 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1068 *++yystack.p_mark = yyloc; 1069 #endif 1070 goto yyloop; 1071 } 1072 else 1073 { 1074 #if YYDEBUG 1075 if (yydebug) 1076 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1077 YYDEBUGSTR, yydepth, *yystack.s_mark); 1078 #endif 1079 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1080 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1081 /* the current TOS position is the error start position */ 1082 yyerror_loc_range[0] = *yystack.p_mark; 1083 #endif 1084 #if defined(YYDESTRUCT_CALL) 1085 #if YYBTYACC 1086 if (!yytrial) 1087 #endif /* YYBTYACC */ 1088 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1089 YYDESTRUCT_CALL("error: discarding state", 1090 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1091 #else 1092 YYDESTRUCT_CALL("error: discarding state", 1093 yystos[*yystack.s_mark], yystack.l_mark); 1094 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1095 #endif /* defined(YYDESTRUCT_CALL) */ 1096 --yystack.s_mark; 1097 --yystack.l_mark; 1098 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1099 --yystack.p_mark; 1100 #endif 1101 } 1102 } 1103 } 1104 else 1105 { 1106 if (yychar == YYEOF) goto yyabort; 1107 #if YYDEBUG 1108 if (yydebug) 1109 { 1110 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1111 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1112 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1113 } 1114 #endif 1115 #if defined(YYDESTRUCT_CALL) 1116 #if YYBTYACC 1117 if (!yytrial) 1118 #endif /* YYBTYACC */ 1119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1120 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1121 #else 1122 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1123 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1124 #endif /* defined(YYDESTRUCT_CALL) */ 1125 yychar = YYEMPTY; 1126 goto yyloop; 1127 } 1128 1129 yyreduce: 1130 yym = yylen[yyn]; 1131 #if YYDEBUG 1132 if (yydebug) 1133 { 1134 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1135 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1136 #ifdef YYSTYPE_TOSTRING 1137 #if YYBTYACC 1138 if (!yytrial) 1139 #endif /* YYBTYACC */ 1140 if (yym > 0) 1141 { 1142 int i; 1143 fputc('<', stderr); 1144 for (i = yym; i > 0; i--) 1145 { 1146 if (i != yym) fputs(", ", stderr); 1147 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1148 yystack.l_mark[1-i]), stderr); 1149 } 1150 fputc('>', stderr); 1151 } 1152 #endif 1153 fputc('\n', stderr); 1154 } 1155 #endif 1156 if (yym > 0) 1157 yyval = yystack.l_mark[1-yym]; 1158 else 1159 memset(&yyval, 0, sizeof yyval); 1160 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1161 1162 /* Perform position reduction */ 1163 memset(&yyloc, 0, sizeof(yyloc)); 1164 #if YYBTYACC 1165 if (!yytrial) 1166 #endif /* YYBTYACC */ 1167 { 1168 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1169 /* just in case YYERROR is invoked within the action, save 1170 the start of the rhs as the error start position */ 1171 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1172 } 1173 #endif 1174 1175 switch (yyn) 1176 { 1177 case 1: 1178 if (!yytrial) 1179 #line 65 "btyacc_destroy3.y" 1180 { yyval.nlist = yystack.l_mark[-5].nlist; } 1181 break; 1182 case 2: 1183 if (!yytrial) 1184 #line 67 "btyacc_destroy3.y" 1185 { yyval.nlist = yystack.l_mark[-3].nlist; } 1186 break; 1187 case 3: 1188 if (!yytrial) 1189 #line 70 "btyacc_destroy3.y" 1190 { yyval.cval = cGLOBAL; } 1191 break; 1192 case 4: 1193 if (!yytrial) 1194 #line 71 "btyacc_destroy3.y" 1195 { yyval.cval = cLOCAL; } 1196 break; 1197 case 5: 1198 if (!yytrial) 1199 #line 74 "btyacc_destroy3.y" 1200 { yyval.tval = tREAL; } 1201 break; 1202 case 6: 1203 if (!yytrial) 1204 #line 75 "btyacc_destroy3.y" 1205 { yyval.tval = tINTEGER; } 1206 break; 1207 case 7: 1208 if (!yytrial) 1209 #line 79 "btyacc_destroy3.y" 1210 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); 1211 yyval.nlist->next = yystack.l_mark[-1].nlist; 1212 } 1213 break; 1214 case 8: 1215 if (!yytrial) 1216 #line 83 "btyacc_destroy3.y" 1217 { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); 1218 yyval.nlist->next = NULL; 1219 } 1220 break; 1221 case 9: 1222 if (!yytrial) 1223 #line 89 "btyacc_destroy3.y" 1224 { yyval.nlist = yystack.l_mark[-5].nlist; } 1225 break; 1226 #line 1227 "btyacc_destroy3.tab.c" 1227 default: 1228 break; 1229 } 1230 yystack.s_mark -= yym; 1231 yystate = *yystack.s_mark; 1232 yystack.l_mark -= yym; 1233 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1234 yystack.p_mark -= yym; 1235 #endif 1236 yym = yylhs[yyn]; 1237 if (yystate == 0 && yym == 0) 1238 { 1239 #if YYDEBUG 1240 if (yydebug) 1241 { 1242 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1243 #ifdef YYSTYPE_TOSTRING 1244 #if YYBTYACC 1245 if (!yytrial) 1246 #endif /* YYBTYACC */ 1247 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1248 #endif 1249 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1250 } 1251 #endif 1252 yystate = YYFINAL; 1253 *++yystack.s_mark = YYFINAL; 1254 *++yystack.l_mark = yyval; 1255 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1256 *++yystack.p_mark = yyloc; 1257 #endif 1258 if (yychar < 0) 1259 { 1260 #if YYBTYACC 1261 do { 1262 if (yylvp < yylve) 1263 { 1264 /* we're currently re-reading tokens */ 1265 yylval = *yylvp++; 1266 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1267 yylloc = *yylpp++; 1268 #endif 1269 yychar = *yylexp++; 1270 break; 1271 } 1272 if (yyps->save) 1273 { 1274 /* in trial mode; save scanner results for future parse attempts */ 1275 if (yylvp == yylvlim) 1276 { /* Enlarge lexical value queue */ 1277 size_t p = (size_t) (yylvp - yylvals); 1278 size_t s = (size_t) (yylvlim - yylvals); 1279 1280 s += YYLVQUEUEGROWTH; 1281 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) 1282 goto yyenomem; 1283 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1284 goto yyenomem; 1285 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1286 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1287 goto yyenomem; 1288 #endif 1289 yylvp = yylve = yylvals + p; 1290 yylvlim = yylvals + s; 1291 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1292 yylpp = yylpe = yylpsns + p; 1293 yylplim = yylpsns + s; 1294 #endif 1295 yylexp = yylexemes + p; 1296 } 1297 *yylexp = (short) YYLEX; 1298 *yylvp++ = yylval; 1299 yylve++; 1300 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1301 *yylpp++ = yylloc; 1302 yylpe++; 1303 #endif 1304 yychar = *yylexp++; 1305 break; 1306 } 1307 /* normal operation, no conflict encountered */ 1308 #endif /* YYBTYACC */ 1309 yychar = YYLEX; 1310 #if YYBTYACC 1311 } while (0); 1312 #endif /* YYBTYACC */ 1313 if (yychar < 0) yychar = YYEOF; 1314 #if YYDEBUG 1315 if (yydebug) 1316 { 1317 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1318 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 1319 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1320 } 1321 #endif 1322 } 1323 if (yychar == YYEOF) goto yyaccept; 1324 goto yyloop; 1325 } 1326 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1327 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1328 yystate = yytable[yyn]; 1329 else 1330 yystate = yydgoto[yym]; 1331 #if YYDEBUG 1332 if (yydebug) 1333 { 1334 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1335 #ifdef YYSTYPE_TOSTRING 1336 #if YYBTYACC 1337 if (!yytrial) 1338 #endif /* YYBTYACC */ 1339 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1340 #endif 1341 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1342 } 1343 #endif 1344 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1345 *++yystack.s_mark = (YYINT) yystate; 1346 *++yystack.l_mark = yyval; 1347 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1348 *++yystack.p_mark = yyloc; 1349 #endif 1350 goto yyloop; 1351 #if YYBTYACC 1352 1353 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1354 yyvalid: 1355 if (yypath) YYABORT; 1356 while (yyps->save) 1357 { 1358 YYParseState *save = yyps->save; 1359 yyps->save = save->save; 1360 save->save = yypath; 1361 yypath = save; 1362 } 1363 #if YYDEBUG 1364 if (yydebug) 1365 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1366 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1367 #endif 1368 if (yyerrctx) 1369 { 1370 yyFreeState(yyerrctx); 1371 yyerrctx = NULL; 1372 } 1373 yylvp = yylvals + yypath->lexeme; 1374 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1375 yylpp = yylpsns + yypath->lexeme; 1376 #endif 1377 yylexp = yylexemes + yypath->lexeme; 1378 yychar = YYEMPTY; 1379 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1380 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1381 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1382 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1383 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1384 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1385 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1386 #endif 1387 yystate = yypath->state; 1388 goto yyloop; 1389 #endif /* YYBTYACC */ 1390 1391 yyoverflow: 1392 YYERROR_CALL("yacc stack overflow"); 1393 #if YYBTYACC 1394 goto yyabort_nomem; 1395 yyenomem: 1396 YYERROR_CALL("memory exhausted"); 1397 yyabort_nomem: 1398 #endif /* YYBTYACC */ 1399 yyresult = 2; 1400 goto yyreturn; 1401 1402 yyabort: 1403 yyresult = 1; 1404 goto yyreturn; 1405 1406 yyaccept: 1407 #if YYBTYACC 1408 if (yyps->save) goto yyvalid; 1409 #endif /* YYBTYACC */ 1410 yyresult = 0; 1411 1412 yyreturn: 1413 #if defined(YYDESTRUCT_CALL) 1414 if (yychar != YYEOF && yychar != YYEMPTY) 1415 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1416 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1417 #else 1418 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1419 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1420 1421 { 1422 YYSTYPE *pv; 1423 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1424 YYLTYPE *pp; 1425 1426 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1427 YYDESTRUCT_CALL("cleanup: discarding state", 1428 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1429 #else 1430 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1431 YYDESTRUCT_CALL("cleanup: discarding state", 1432 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1433 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1434 } 1435 #endif /* defined(YYDESTRUCT_CALL) */ 1436 1437 #if YYBTYACC 1438 if (yyerrctx) 1439 { 1440 yyFreeState(yyerrctx); 1441 yyerrctx = NULL; 1442 } 1443 while (yyps) 1444 { 1445 YYParseState *save = yyps; 1446 yyps = save->save; 1447 save->save = NULL; 1448 yyFreeState(save); 1449 } 1450 while (yypath) 1451 { 1452 YYParseState *save = yypath; 1453 yypath = save->save; 1454 save->save = NULL; 1455 yyFreeState(save); 1456 } 1457 #endif /* YYBTYACC */ 1458 yyfreestack(&yystack); 1459 return (yyresult); 1460 } 1461