1 /* original parser id follows */ 2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3 /* (use YYMAJOR/YYMINOR for ifdefs dependent of 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 destroy2_parse 22 #endif /* yyparse */ 23 24 #ifndef yylex 25 #define yylex destroy2_lex 26 #endif /* yylex */ 27 28 #ifndef yyerror 29 #define yyerror destroy2_error 30 #endif /* yyerror */ 31 32 #ifndef yychar 33 #define yychar destroy2_char 34 #endif /* yychar */ 35 36 #ifndef yyval 37 #define yyval destroy2_val 38 #endif /* yyval */ 39 40 #ifndef yylval 41 #define yylval destroy2_lval 42 #endif /* yylval */ 43 44 #ifndef yydebug 45 #define yydebug destroy2_debug 46 #endif /* yydebug */ 47 48 #ifndef yynerrs 49 #define yynerrs destroy2_nerrs 50 #endif /* yynerrs */ 51 52 #ifndef yyerrflag 53 #define yyerrflag destroy2_errflag 54 #endif /* yyerrflag */ 55 56 #ifndef yylhs 57 #define yylhs destroy2_lhs 58 #endif /* yylhs */ 59 60 #ifndef yylen 61 #define yylen destroy2_len 62 #endif /* yylen */ 63 64 #ifndef yydefred 65 #define yydefred destroy2_defred 66 #endif /* yydefred */ 67 68 #ifndef yystos 69 #define yystos destroy2_stos 70 #endif /* yystos */ 71 72 #ifndef yydgoto 73 #define yydgoto destroy2_dgoto 74 #endif /* yydgoto */ 75 76 #ifndef yysindex 77 #define yysindex destroy2_sindex 78 #endif /* yysindex */ 79 80 #ifndef yyrindex 81 #define yyrindex destroy2_rindex 82 #endif /* yyrindex */ 83 84 #ifndef yygindex 85 #define yygindex destroy2_gindex 86 #endif /* yygindex */ 87 88 #ifndef yytable 89 #define yytable destroy2_table 90 #endif /* yytable */ 91 92 #ifndef yycheck 93 #define yycheck destroy2_check 94 #endif /* yycheck */ 95 96 #ifndef yyname 97 #define yyname destroy2_name 98 #endif /* yyname */ 99 100 #ifndef yyrule 101 #define yyrule destroy2_rule 102 #endif /* yyrule */ 103 104 #if YYBTYACC 105 106 #ifndef yycindex 107 #define yycindex destroy2_cindex 108 #endif /* yycindex */ 109 110 #ifndef yyctable 111 #define yyctable destroy2_ctable 112 #endif /* yyctable */ 113 114 #endif /* YYBTYACC */ 115 116 #define YYPREFIX "destroy2_" 117 118 #define YYPURE 0 119 120 #line 4 "btyacc_destroy2.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 #line 50 "btyacc_destroy2.y" 145 #ifdef YYSTYPE 146 #undef YYSTYPE_IS_DECLARED 147 #define YYSTYPE_IS_DECLARED 1 148 #endif 149 #ifndef YYSTYPE_IS_DECLARED 150 #define YYSTYPE_IS_DECLARED 1 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_destroy2.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 destroy2_lhs[] = { -1, 207 0, 0, 2, 2, 3, 3, 4, 4, 1, 208 }; 209 static const YYINT destroy2_len[] = { 2, 210 8, 5, 1, 1, 1, 1, 2, 1, 6, 211 }; 212 static const YYINT destroy2_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 destroy2_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 destroy2_dgoto[] = { 5, 223 10, 6, 7, 11, 224 }; 225 static const YYINT destroy2_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 destroy2_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 destroy2_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 destroy2_gindex[] = { 0, 243 0, -6, -4, 15, 244 }; 245 #define YYTABLESIZE 222 246 static const YYINT destroy2_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 destroy2_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 destroy2_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 destroy2_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 destroy2_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 short *s_base; 419 short *s_mark; 420 short *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 89 "btyacc_destroy2.y" 483 484 extern int YYLEX_DECL(); 485 extern void YYERROR_DECL(); 486 #line 487 "btyacc_destroy2.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 41 "btyacc_destroy2.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_destroy2.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 short *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 = (short *)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 = (short *) malloc(size * sizeof(short)); 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 yynerrs = 0; 669 yyerrflag = 0; 670 yychar = YYEMPTY; 671 yystate = 0; 672 673 #if YYPURE 674 memset(&yystack, 0, sizeof(yystack)); 675 #endif 676 677 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 678 yystack.s_mark = yystack.s_base; 679 yystack.l_mark = yystack.l_base; 680 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 681 yystack.p_mark = yystack.p_base; 682 #endif 683 yystate = 0; 684 *yystack.s_mark = 0; 685 686 yyloop: 687 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 688 if (yychar < 0) 689 { 690 #if YYBTYACC 691 do { 692 if (yylvp < yylve) 693 { 694 /* we're currently re-reading tokens */ 695 yylval = *yylvp++; 696 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 697 yylloc = *yylpp++; 698 #endif 699 yychar = *yylexp++; 700 break; 701 } 702 if (yyps->save) 703 { 704 /* in trial mode; save scanner results for future parse attempts */ 705 if (yylvp == yylvlim) 706 { /* Enlarge lexical value queue */ 707 size_t p = (size_t) (yylvp - yylvals); 708 size_t s = (size_t) (yylvlim - yylvals); 709 710 s += YYLVQUEUEGROWTH; 711 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; 712 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 713 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 714 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 715 #endif 716 yylvp = yylve = yylvals + p; 717 yylvlim = yylvals + s; 718 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 719 yylpp = yylpe = yylpsns + p; 720 yylplim = yylpsns + s; 721 #endif 722 yylexp = yylexemes + p; 723 } 724 *yylexp = (short) YYLEX; 725 *yylvp++ = yylval; 726 yylve++; 727 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 728 *yylpp++ = yylloc; 729 yylpe++; 730 #endif 731 yychar = *yylexp++; 732 break; 733 } 734 /* normal operation, no conflict encountered */ 735 #endif /* YYBTYACC */ 736 yychar = YYLEX; 737 #if YYBTYACC 738 } while (0); 739 #endif /* YYBTYACC */ 740 if (yychar < 0) yychar = YYEOF; 741 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 742 #if YYDEBUG 743 if (yydebug) 744 { 745 yys = yyname[YYTRANSLATE(yychar)]; 746 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 747 YYDEBUGSTR, yydepth, yystate, yychar, yys); 748 #ifdef YYSTYPE_TOSTRING 749 #if YYBTYACC 750 if (!yytrial) 751 #endif /* YYBTYACC */ 752 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 753 #endif 754 fputc('\n', stderr); 755 } 756 #endif 757 } 758 #if YYBTYACC 759 760 /* Do we have a conflict? */ 761 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 762 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 763 { 764 YYINT ctry; 765 766 if (yypath) 767 { 768 YYParseState *save; 769 #if YYDEBUG 770 if (yydebug) 771 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 772 YYDEBUGSTR, yydepth, yystate); 773 #endif 774 /* Switch to the next conflict context */ 775 save = yypath; 776 yypath = save->save; 777 save->save = NULL; 778 ctry = save->ctry; 779 if (save->state != yystate) YYABORT; 780 yyFreeState(save); 781 782 } 783 else 784 { 785 786 /* Unresolved conflict - start/continue trial parse */ 787 YYParseState *save; 788 #if YYDEBUG 789 if (yydebug) 790 { 791 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 792 if (yyps->save) 793 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 794 else 795 fputs("Starting trial parse.\n", stderr); 796 } 797 #endif 798 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 799 if (save == NULL) goto yyenomem; 800 save->save = yyps->save; 801 save->state = yystate; 802 save->errflag = yyerrflag; 803 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 804 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 805 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 806 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 807 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 808 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 809 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 810 #endif 811 ctry = yytable[yyn]; 812 if (yyctable[ctry] == -1) 813 { 814 #if YYDEBUG 815 if (yydebug && yychar >= YYEOF) 816 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 817 #endif 818 ctry++; 819 } 820 save->ctry = ctry; 821 if (yyps->save == NULL) 822 { 823 /* If this is a first conflict in the stack, start saving lexemes */ 824 if (!yylexemes) 825 { 826 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); 827 if (yylexemes == NULL) goto yyenomem; 828 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 829 if (yylvals == NULL) goto yyenomem; 830 yylvlim = yylvals + YYLVQUEUEGROWTH; 831 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 832 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 833 if (yylpsns == NULL) goto yyenomem; 834 yylplim = yylpsns + YYLVQUEUEGROWTH; 835 #endif 836 } 837 if (yylvp == yylve) 838 { 839 yylvp = yylve = yylvals; 840 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 841 yylpp = yylpe = yylpsns; 842 #endif 843 yylexp = yylexemes; 844 if (yychar >= YYEOF) 845 { 846 *yylve++ = yylval; 847 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 848 *yylpe++ = yylloc; 849 #endif 850 *yylexp = (short) yychar; 851 yychar = YYEMPTY; 852 } 853 } 854 } 855 if (yychar >= YYEOF) 856 { 857 yylvp--; 858 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 859 yylpp--; 860 #endif 861 yylexp--; 862 yychar = YYEMPTY; 863 } 864 save->lexeme = (int) (yylvp - yylvals); 865 yyps->save = save; 866 } 867 if (yytable[yyn] == ctry) 868 { 869 #if YYDEBUG 870 if (yydebug) 871 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 872 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 873 #endif 874 if (yychar < 0) 875 { 876 yylvp++; 877 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 878 yylpp++; 879 #endif 880 yylexp++; 881 } 882 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 883 goto yyoverflow; 884 yystate = yyctable[ctry]; 885 *++yystack.s_mark = (short) yystate; 886 *++yystack.l_mark = yylval; 887 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 888 *++yystack.p_mark = yylloc; 889 #endif 890 yychar = YYEMPTY; 891 if (yyerrflag > 0) --yyerrflag; 892 goto yyloop; 893 } 894 else 895 { 896 yyn = yyctable[ctry]; 897 goto yyreduce; 898 } 899 } /* End of code dealing with conflicts */ 900 #endif /* YYBTYACC */ 901 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 902 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 903 { 904 #if YYDEBUG 905 if (yydebug) 906 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 907 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 908 #endif 909 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 910 yystate = yytable[yyn]; 911 *++yystack.s_mark = yytable[yyn]; 912 *++yystack.l_mark = yylval; 913 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 914 *++yystack.p_mark = yylloc; 915 #endif 916 yychar = YYEMPTY; 917 if (yyerrflag > 0) --yyerrflag; 918 goto yyloop; 919 } 920 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 921 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 922 { 923 yyn = yytable[yyn]; 924 goto yyreduce; 925 } 926 if (yyerrflag != 0) goto yyinrecovery; 927 #if YYBTYACC 928 929 yynewerrflag = 1; 930 goto yyerrhandler; 931 goto yyerrlab; 932 933 yyerrlab: 934 yynewerrflag = 0; 935 yyerrhandler: 936 while (yyps->save) 937 { 938 int ctry; 939 YYParseState *save = yyps->save; 940 #if YYDEBUG 941 if (yydebug) 942 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 943 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 944 (int)(yylvp - yylvals - yyps->save->lexeme)); 945 #endif 946 /* Memorize most forward-looking error state in case it's really an error. */ 947 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 948 { 949 /* Free old saved error context state */ 950 if (yyerrctx) yyFreeState(yyerrctx); 951 /* Create and fill out new saved error context state */ 952 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 953 if (yyerrctx == NULL) goto yyenomem; 954 yyerrctx->save = yyps->save; 955 yyerrctx->state = yystate; 956 yyerrctx->errflag = yyerrflag; 957 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 958 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 959 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 960 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 961 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 962 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 963 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 964 #endif 965 yyerrctx->lexeme = (int) (yylvp - yylvals); 966 } 967 yylvp = yylvals + save->lexeme; 968 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 969 yylpp = yylpsns + save->lexeme; 970 #endif 971 yylexp = yylexemes + save->lexeme; 972 yychar = YYEMPTY; 973 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 974 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 975 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 976 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 977 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 978 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 979 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 980 #endif 981 ctry = ++save->ctry; 982 yystate = save->state; 983 /* We tried shift, try reduce now */ 984 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 985 yyps->save = save->save; 986 save->save = NULL; 987 yyFreeState(save); 988 989 /* Nothing left on the stack -- error */ 990 if (!yyps->save) 991 { 992 #if YYDEBUG 993 if (yydebug) 994 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 995 YYPREFIX, yydepth); 996 #endif 997 /* Restore state as it was in the most forward-advanced error */ 998 yylvp = yylvals + yyerrctx->lexeme; 999 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1000 yylpp = yylpsns + yyerrctx->lexeme; 1001 #endif 1002 yylexp = yylexemes + yyerrctx->lexeme; 1003 yychar = yylexp[-1]; 1004 yylval = yylvp[-1]; 1005 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1006 yylloc = yylpp[-1]; 1007 #endif 1008 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1009 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1010 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1011 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1012 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1013 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1014 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1015 #endif 1016 yystate = yyerrctx->state; 1017 yyFreeState(yyerrctx); 1018 yyerrctx = NULL; 1019 } 1020 yynewerrflag = 1; 1021 } 1022 if (yynewerrflag == 0) goto yyinrecovery; 1023 #endif /* YYBTYACC */ 1024 1025 YYERROR_CALL("syntax error"); 1026 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1027 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1028 #endif 1029 1030 #if !YYBTYACC 1031 goto yyerrlab; 1032 yyerrlab: 1033 #endif 1034 ++yynerrs; 1035 1036 yyinrecovery: 1037 if (yyerrflag < 3) 1038 { 1039 yyerrflag = 3; 1040 for (;;) 1041 { 1042 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1043 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1044 { 1045 #if YYDEBUG 1046 if (yydebug) 1047 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1048 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1049 #endif 1050 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1051 yystate = yytable[yyn]; 1052 *++yystack.s_mark = yytable[yyn]; 1053 *++yystack.l_mark = yylval; 1054 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1055 /* lookahead position is error end position */ 1056 yyerror_loc_range[1] = yylloc; 1057 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1058 *++yystack.p_mark = yyloc; 1059 #endif 1060 goto yyloop; 1061 } 1062 else 1063 { 1064 #if YYDEBUG 1065 if (yydebug) 1066 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1067 YYDEBUGSTR, yydepth, *yystack.s_mark); 1068 #endif 1069 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1070 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1071 /* the current TOS position is the error start position */ 1072 yyerror_loc_range[0] = *yystack.p_mark; 1073 #endif 1074 #if defined(YYDESTRUCT_CALL) 1075 #if YYBTYACC 1076 if (!yytrial) 1077 #endif /* YYBTYACC */ 1078 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1079 YYDESTRUCT_CALL("error: discarding state", 1080 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1081 #else 1082 YYDESTRUCT_CALL("error: discarding state", 1083 yystos[*yystack.s_mark], yystack.l_mark); 1084 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1085 #endif /* defined(YYDESTRUCT_CALL) */ 1086 --yystack.s_mark; 1087 --yystack.l_mark; 1088 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1089 --yystack.p_mark; 1090 #endif 1091 } 1092 } 1093 } 1094 else 1095 { 1096 if (yychar == YYEOF) goto yyabort; 1097 #if YYDEBUG 1098 if (yydebug) 1099 { 1100 yys = yyname[YYTRANSLATE(yychar)]; 1101 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1102 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1103 } 1104 #endif 1105 #if defined(YYDESTRUCT_CALL) 1106 #if YYBTYACC 1107 if (!yytrial) 1108 #endif /* YYBTYACC */ 1109 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1110 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1111 #else 1112 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1113 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1114 #endif /* defined(YYDESTRUCT_CALL) */ 1115 yychar = YYEMPTY; 1116 goto yyloop; 1117 } 1118 1119 yyreduce: 1120 yym = yylen[yyn]; 1121 #if YYDEBUG 1122 if (yydebug) 1123 { 1124 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1125 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1126 #ifdef YYSTYPE_TOSTRING 1127 #if YYBTYACC 1128 if (!yytrial) 1129 #endif /* YYBTYACC */ 1130 if (yym > 0) 1131 { 1132 int i; 1133 fputc('<', stderr); 1134 for (i = yym; i > 0; i--) 1135 { 1136 if (i != yym) fputs(", ", stderr); 1137 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1138 yystack.l_mark[1-i]), stderr); 1139 } 1140 fputc('>', stderr); 1141 } 1142 #endif 1143 fputc('\n', stderr); 1144 } 1145 #endif 1146 if (yym > 0) 1147 yyval = yystack.l_mark[1-yym]; 1148 else 1149 memset(&yyval, 0, sizeof yyval); 1150 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1151 1152 /* Perform position reduction */ 1153 memset(&yyloc, 0, sizeof(yyloc)); 1154 #if YYBTYACC 1155 if (!yytrial) 1156 #endif /* YYBTYACC */ 1157 { 1158 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1159 /* just in case YYERROR is invoked within the action, save 1160 the start of the rhs as the error start position */ 1161 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1162 } 1163 #endif 1164 1165 switch (yyn) 1166 { 1167 case 1: 1168 if (!yytrial) 1169 #line 62 "btyacc_destroy2.y" 1170 { yyval.nlist = yystack.l_mark[-5].nlist; } 1171 break; 1172 case 2: 1173 if (!yytrial) 1174 #line 64 "btyacc_destroy2.y" 1175 { yyval.nlist = yystack.l_mark[-3].nlist; } 1176 break; 1177 case 3: 1178 if (!yytrial) 1179 #line 67 "btyacc_destroy2.y" 1180 { yyval.cval = cGLOBAL; } 1181 break; 1182 case 4: 1183 if (!yytrial) 1184 #line 68 "btyacc_destroy2.y" 1185 { yyval.cval = cLOCAL; } 1186 break; 1187 case 5: 1188 if (!yytrial) 1189 #line 71 "btyacc_destroy2.y" 1190 { yyval.tval = tREAL; } 1191 break; 1192 case 6: 1193 if (!yytrial) 1194 #line 72 "btyacc_destroy2.y" 1195 { yyval.tval = tINTEGER; } 1196 break; 1197 case 7: 1198 if (!yytrial) 1199 #line 76 "btyacc_destroy2.y" 1200 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); 1201 yyval.nlist->next = yystack.l_mark[-1].nlist; 1202 } 1203 break; 1204 case 8: 1205 if (!yytrial) 1206 #line 80 "btyacc_destroy2.y" 1207 { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); 1208 yyval.nlist->next = NULL; 1209 } 1210 break; 1211 case 9: 1212 if (!yytrial) 1213 #line 86 "btyacc_destroy2.y" 1214 { yyval.nlist = yystack.l_mark[-5].nlist; } 1215 break; 1216 #line 1217 "btyacc_destroy2.tab.c" 1217 default: 1218 break; 1219 } 1220 yystack.s_mark -= yym; 1221 yystate = *yystack.s_mark; 1222 yystack.l_mark -= yym; 1223 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1224 yystack.p_mark -= yym; 1225 #endif 1226 yym = yylhs[yyn]; 1227 if (yystate == 0 && yym == 0) 1228 { 1229 #if YYDEBUG 1230 if (yydebug) 1231 { 1232 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1233 #ifdef YYSTYPE_TOSTRING 1234 #if YYBTYACC 1235 if (!yytrial) 1236 #endif /* YYBTYACC */ 1237 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1238 #endif 1239 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1240 } 1241 #endif 1242 yystate = YYFINAL; 1243 *++yystack.s_mark = YYFINAL; 1244 *++yystack.l_mark = yyval; 1245 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1246 *++yystack.p_mark = yyloc; 1247 #endif 1248 if (yychar < 0) 1249 { 1250 #if YYBTYACC 1251 do { 1252 if (yylvp < yylve) 1253 { 1254 /* we're currently re-reading tokens */ 1255 yylval = *yylvp++; 1256 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1257 yylloc = *yylpp++; 1258 #endif 1259 yychar = *yylexp++; 1260 break; 1261 } 1262 if (yyps->save) 1263 { 1264 /* in trial mode; save scanner results for future parse attempts */ 1265 if (yylvp == yylvlim) 1266 { /* Enlarge lexical value queue */ 1267 size_t p = (size_t) (yylvp - yylvals); 1268 size_t s = (size_t) (yylvlim - yylvals); 1269 1270 s += YYLVQUEUEGROWTH; 1271 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) 1272 goto yyenomem; 1273 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1274 goto yyenomem; 1275 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1276 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1277 goto yyenomem; 1278 #endif 1279 yylvp = yylve = yylvals + p; 1280 yylvlim = yylvals + s; 1281 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1282 yylpp = yylpe = yylpsns + p; 1283 yylplim = yylpsns + s; 1284 #endif 1285 yylexp = yylexemes + p; 1286 } 1287 *yylexp = (short) YYLEX; 1288 *yylvp++ = yylval; 1289 yylve++; 1290 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1291 *yylpp++ = yylloc; 1292 yylpe++; 1293 #endif 1294 yychar = *yylexp++; 1295 break; 1296 } 1297 /* normal operation, no conflict encountered */ 1298 #endif /* YYBTYACC */ 1299 yychar = YYLEX; 1300 #if YYBTYACC 1301 } while (0); 1302 #endif /* YYBTYACC */ 1303 if (yychar < 0) yychar = YYEOF; 1304 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 1305 #if YYDEBUG 1306 if (yydebug) 1307 { 1308 yys = yyname[YYTRANSLATE(yychar)]; 1309 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n", 1310 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1311 } 1312 #endif 1313 } 1314 if (yychar == YYEOF) goto yyaccept; 1315 goto yyloop; 1316 } 1317 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1318 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1319 yystate = yytable[yyn]; 1320 else 1321 yystate = yydgoto[yym]; 1322 #if YYDEBUG 1323 if (yydebug) 1324 { 1325 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1326 #ifdef YYSTYPE_TOSTRING 1327 #if YYBTYACC 1328 if (!yytrial) 1329 #endif /* YYBTYACC */ 1330 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1331 #endif 1332 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1333 } 1334 #endif 1335 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1336 *++yystack.s_mark = (short) yystate; 1337 *++yystack.l_mark = yyval; 1338 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1339 *++yystack.p_mark = yyloc; 1340 #endif 1341 goto yyloop; 1342 #if YYBTYACC 1343 1344 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1345 yyvalid: 1346 if (yypath) YYABORT; 1347 while (yyps->save) 1348 { 1349 YYParseState *save = yyps->save; 1350 yyps->save = save->save; 1351 save->save = yypath; 1352 yypath = save; 1353 } 1354 #if YYDEBUG 1355 if (yydebug) 1356 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1357 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1358 #endif 1359 if (yyerrctx) 1360 { 1361 yyFreeState(yyerrctx); 1362 yyerrctx = NULL; 1363 } 1364 yylvp = yylvals + yypath->lexeme; 1365 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1366 yylpp = yylpsns + yypath->lexeme; 1367 #endif 1368 yylexp = yylexemes + yypath->lexeme; 1369 yychar = YYEMPTY; 1370 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1371 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1372 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1373 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1374 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1375 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1376 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1377 #endif 1378 yystate = yypath->state; 1379 goto yyloop; 1380 #endif /* YYBTYACC */ 1381 1382 yyoverflow: 1383 YYERROR_CALL("yacc stack overflow"); 1384 #if YYBTYACC 1385 goto yyabort_nomem; 1386 yyenomem: 1387 YYERROR_CALL("memory exhausted"); 1388 yyabort_nomem: 1389 #endif /* YYBTYACC */ 1390 yyresult = 2; 1391 goto yyreturn; 1392 1393 yyabort: 1394 yyresult = 1; 1395 goto yyreturn; 1396 1397 yyaccept: 1398 #if YYBTYACC 1399 if (yyps->save) goto yyvalid; 1400 #endif /* YYBTYACC */ 1401 yyresult = 0; 1402 1403 yyreturn: 1404 #if defined(YYDESTRUCT_CALL) 1405 if (yychar != YYEOF && yychar != YYEMPTY) 1406 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1407 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1408 #else 1409 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1410 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1411 1412 { 1413 YYSTYPE *pv; 1414 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1415 YYLTYPE *pp; 1416 1417 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1418 YYDESTRUCT_CALL("cleanup: discarding state", 1419 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1420 #else 1421 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1422 YYDESTRUCT_CALL("cleanup: discarding state", 1423 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1424 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1425 } 1426 #endif /* defined(YYDESTRUCT_CALL) */ 1427 1428 #if YYBTYACC 1429 if (yyerrctx) 1430 { 1431 yyFreeState(yyerrctx); 1432 yyerrctx = NULL; 1433 } 1434 while (yyps) 1435 { 1436 YYParseState *save = yyps; 1437 yyps = save->save; 1438 save->save = NULL; 1439 yyFreeState(save); 1440 } 1441 while (yypath) 1442 { 1443 YYParseState *save = yypath; 1444 yypath = save->save; 1445 save->save = NULL; 1446 yyFreeState(save); 1447 } 1448 #endif /* YYBTYACC */ 1449 yyfreestack(&yystack); 1450 return (yyresult); 1451 } 1452