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 #line 20 "rename_debug.c" 20 #include "rename_debug.i" 21 #include "rename_debug.h" 22 typedef short YYINT; 23 static const YYINT yylhs[] = { -1, 24 0, 25 }; 26 static const YYINT yylen[] = { 2, 27 1, 28 }; 29 static const YYINT yydefred[] = { 0, 30 1, 0, 31 }; 32 static const YYINT yystos[] = { 0, 33 256, 258, 34 }; 35 static const YYINT yydgoto[] = { 2, 36 }; 37 static const YYINT yysindex[] = { -256, 38 0, 0, 39 }; 40 static const YYINT yyrindex[] = { 0, 41 0, 0, 42 }; 43 #if YYBTYACC 44 static const YYINT yycindex[] = { 0, 45 0, 0, 46 }; 47 #endif 48 static const YYINT yygindex[] = { 0, 49 }; 50 #define YYTABLESIZE 0 51 static const YYINT yytable[] = { 1, 52 }; 53 static const YYINT yycheck[] = { 256, 54 }; 55 #define YYFINAL 2 56 #ifndef YYDEBUG 57 #define YYDEBUG 1 58 #endif 59 #define YYMAXTOKEN 256 60 #define YYUNDFTOKEN 259 61 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 62 #if YYDEBUG 63 static const char *const yyname[] = { 64 65 "$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, 66 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 67 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 68 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 69 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 70 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 71 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","$accept","S","illegal-symbol", 72 }; 73 static const char *const yyrule[] = { 74 "$accept : S", 75 "S : error", 76 77 }; 78 #endif 79 80 int yydebug; 81 int yynerrs; 82 83 int yyerrflag; 84 int yychar; 85 YYSTYPE yyval; 86 YYSTYPE yylval; 87 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 88 YYLTYPE yyloc; /* position returned by actions */ 89 YYLTYPE yylloc; /* position from the lexer */ 90 #endif 91 92 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 93 #ifndef YYLLOC_DEFAULT 94 #define YYLLOC_DEFAULT(loc, rhs, n) \ 95 do \ 96 { \ 97 if (n == 0) \ 98 { \ 99 (loc).first_line = ((rhs)[-1]).last_line; \ 100 (loc).first_column = ((rhs)[-1]).last_column; \ 101 (loc).last_line = ((rhs)[-1]).last_line; \ 102 (loc).last_column = ((rhs)[-1]).last_column; \ 103 } \ 104 else \ 105 { \ 106 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 107 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 108 (loc).last_line = ((rhs)[n-1]).last_line; \ 109 (loc).last_column = ((rhs)[n-1]).last_column; \ 110 } \ 111 } while (0) 112 #endif /* YYLLOC_DEFAULT */ 113 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 114 #if YYBTYACC 115 116 #ifndef YYLVQUEUEGROWTH 117 #define YYLVQUEUEGROWTH 32 118 #endif 119 #endif /* YYBTYACC */ 120 121 /* define the initial stack-sizes */ 122 #ifdef YYSTACKSIZE 123 #undef YYMAXDEPTH 124 #define YYMAXDEPTH YYSTACKSIZE 125 #else 126 #ifdef YYMAXDEPTH 127 #define YYSTACKSIZE YYMAXDEPTH 128 #else 129 #define YYSTACKSIZE 10000 130 #define YYMAXDEPTH 10000 131 #endif 132 #endif 133 134 #ifndef YYINITSTACKSIZE 135 #define YYINITSTACKSIZE 200 136 #endif 137 138 typedef struct { 139 unsigned stacksize; 140 short *s_base; 141 short *s_mark; 142 short *s_last; 143 YYSTYPE *l_base; 144 YYSTYPE *l_mark; 145 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 146 YYLTYPE *p_base; 147 YYLTYPE *p_mark; 148 #endif 149 } YYSTACKDATA; 150 #if YYBTYACC 151 152 struct YYParseState_s 153 { 154 struct YYParseState_s *save; /* Previously saved parser state */ 155 YYSTACKDATA yystack; /* saved parser stack */ 156 int state; /* saved parser state */ 157 int errflag; /* saved error recovery status */ 158 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 159 YYINT ctry; /* saved index in yyctable[] for this conflict */ 160 }; 161 typedef struct YYParseState_s YYParseState; 162 #endif /* YYBTYACC */ 163 /* variables for the parser stack */ 164 static YYSTACKDATA yystack; 165 #if YYBTYACC 166 167 /* Current parser state */ 168 static YYParseState *yyps = 0; 169 170 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 171 static YYParseState *yypath = 0; 172 173 /* Base of the lexical value queue */ 174 static YYSTYPE *yylvals = 0; 175 176 /* Current position at lexical value queue */ 177 static YYSTYPE *yylvp = 0; 178 179 /* End position of lexical value queue */ 180 static YYSTYPE *yylve = 0; 181 182 /* The last allocated position at the lexical value queue */ 183 static YYSTYPE *yylvlim = 0; 184 185 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 186 /* Base of the lexical position queue */ 187 static YYLTYPE *yylpsns = 0; 188 189 /* Current position at lexical position queue */ 190 static YYLTYPE *yylpp = 0; 191 192 /* End position of lexical position queue */ 193 static YYLTYPE *yylpe = 0; 194 195 /* The last allocated position at the lexical position queue */ 196 static YYLTYPE *yylplim = 0; 197 #endif 198 199 /* Current position at lexical token queue */ 200 static short *yylexp = 0; 201 202 static short *yylexemes = 0; 203 #endif /* YYBTYACC */ 204 #line 12 "code_debug.y" 205 206 #include <stdio.h> 207 208 #ifdef YYBYACC 209 extern int YYLEX_DECL(); 210 #endif 211 212 int 213 main(void) 214 { 215 printf("yyparse() = %d\n", yyparse()); 216 return 0; 217 } 218 219 int 220 yylex(void) 221 { 222 return -1; 223 } 224 225 static void 226 yyerror(const char* s) 227 { 228 printf("%s\n", s); 229 } 230 #line 232 "rename_debug.c" 231 232 /* For use in generated program */ 233 #define yydepth (int)(yystack.s_mark - yystack.s_base) 234 #if YYBTYACC 235 #define yytrial (yyps->save) 236 #endif /* YYBTYACC */ 237 238 #if YYDEBUG 239 #include <stdio.h> /* needed for printf */ 240 #endif 241 242 #include <stdlib.h> /* needed for malloc, etc */ 243 #include <string.h> /* needed for memset */ 244 245 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 246 static int yygrowstack(YYSTACKDATA *data) 247 { 248 int i; 249 unsigned newsize; 250 short *newss; 251 YYSTYPE *newvs; 252 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 253 YYLTYPE *newps; 254 #endif 255 256 if ((newsize = data->stacksize) == 0) 257 newsize = YYINITSTACKSIZE; 258 else if (newsize >= YYMAXDEPTH) 259 return YYENOMEM; 260 else if ((newsize *= 2) > YYMAXDEPTH) 261 newsize = YYMAXDEPTH; 262 263 i = (int) (data->s_mark - data->s_base); 264 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); 265 if (newss == 0) 266 return YYENOMEM; 267 268 data->s_base = newss; 269 data->s_mark = newss + i; 270 271 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 272 if (newvs == 0) 273 return YYENOMEM; 274 275 data->l_base = newvs; 276 data->l_mark = newvs + i; 277 278 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 279 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 280 if (newps == 0) 281 return YYENOMEM; 282 283 data->p_base = newps; 284 data->p_mark = newps + i; 285 #endif 286 287 data->stacksize = newsize; 288 data->s_last = data->s_base + newsize - 1; 289 290 #if YYDEBUG 291 if (yydebug) 292 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 293 #endif 294 return 0; 295 } 296 297 #if YYPURE || defined(YY_NO_LEAKS) 298 static void yyfreestack(YYSTACKDATA *data) 299 { 300 free(data->s_base); 301 free(data->l_base); 302 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 303 free(data->p_base); 304 #endif 305 memset(data, 0, sizeof(*data)); 306 } 307 #else 308 #define yyfreestack(data) /* nothing */ 309 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 310 #if YYBTYACC 311 312 static YYParseState * 313 yyNewState(unsigned size) 314 { 315 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 316 if (p == NULL) return NULL; 317 318 p->yystack.stacksize = size; 319 if (size == 0) 320 { 321 p->yystack.s_base = NULL; 322 p->yystack.l_base = NULL; 323 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 324 p->yystack.p_base = NULL; 325 #endif 326 return p; 327 } 328 p->yystack.s_base = (short *) malloc(size * sizeof(short)); 329 if (p->yystack.s_base == NULL) return NULL; 330 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 331 if (p->yystack.l_base == NULL) return NULL; 332 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 334 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 335 if (p->yystack.p_base == NULL) return NULL; 336 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 337 #endif 338 339 return p; 340 } 341 342 static void 343 yyFreeState(YYParseState *p) 344 { 345 yyfreestack(&p->yystack); 346 free(p); 347 } 348 #endif /* YYBTYACC */ 349 350 #define YYABORT goto yyabort 351 #define YYREJECT goto yyabort 352 #define YYACCEPT goto yyaccept 353 #define YYERROR goto yyerrlab 354 #if YYBTYACC 355 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 356 #define YYVALID_NESTED do { if (yyps->save && \ 357 yyps->save->save == 0) goto yyvalid; } while(0) 358 #endif /* YYBTYACC */ 359 360 int 361 YYPARSE_DECL() 362 { 363 int yym, yyn, yystate, yyresult; 364 #if YYBTYACC 365 int yynewerrflag; 366 YYParseState *yyerrctx = NULL; 367 #endif /* YYBTYACC */ 368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 369 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 370 #endif 371 #if YYDEBUG 372 const char *yys; 373 374 if ((yys = getenv("YYDEBUG")) != 0) 375 { 376 yyn = *yys; 377 if (yyn >= '0' && yyn <= '9') 378 yydebug = yyn - '0'; 379 } 380 if (yydebug) 381 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 382 #endif 383 384 #if YYBTYACC 385 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 386 yyps->save = 0; 387 #endif /* YYBTYACC */ 388 yynerrs = 0; 389 yyerrflag = 0; 390 yychar = YYEMPTY; 391 yystate = 0; 392 393 #if YYPURE 394 memset(&yystack, 0, sizeof(yystack)); 395 #endif 396 397 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 398 yystack.s_mark = yystack.s_base; 399 yystack.l_mark = yystack.l_base; 400 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 401 yystack.p_mark = yystack.p_base; 402 #endif 403 yystate = 0; 404 *yystack.s_mark = 0; 405 406 yyloop: 407 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 408 if (yychar < 0) 409 { 410 #if YYBTYACC 411 do { 412 if (yylvp < yylve) 413 { 414 /* we're currently re-reading tokens */ 415 yylval = *yylvp++; 416 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 417 yylloc = *yylpp++; 418 #endif 419 yychar = *yylexp++; 420 break; 421 } 422 if (yyps->save) 423 { 424 /* in trial mode; save scanner results for future parse attempts */ 425 if (yylvp == yylvlim) 426 { /* Enlarge lexical value queue */ 427 int p = yylvp - yylvals; 428 int s = yylvlim - yylvals; 429 430 s += YYLVQUEUEGROWTH; 431 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; 432 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 433 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 434 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 435 #endif 436 yylvp = yylve = yylvals + p; 437 yylvlim = yylvals + s; 438 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 439 yylpp = yylpe = yylpsns + p; 440 yylplim = yylpsns + s; 441 #endif 442 yylexp = yylexemes + p; 443 } 444 *yylexp = (short) YYLEX; 445 *yylvp++ = yylval; 446 yylve++; 447 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 448 *yylpp++ = yylloc; 449 yylpe++; 450 #endif 451 yychar = *yylexp++; 452 break; 453 } 454 /* normal operation, no conflict encountered */ 455 #endif /* YYBTYACC */ 456 yychar = YYLEX; 457 #if YYBTYACC 458 } while (0); 459 #endif /* YYBTYACC */ 460 if (yychar < 0) yychar = YYEOF; 461 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 462 #if YYDEBUG 463 if (yydebug) 464 { 465 yys = yyname[YYTRANSLATE(yychar)]; 466 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 467 YYDEBUGSTR, yydepth, yystate, yychar, yys); 468 #ifdef YYSTYPE_TOSTRING 469 #if YYBTYACC 470 if (!yytrial) 471 #endif /* YYBTYACC */ 472 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 473 #endif 474 fputc('\n', stderr); 475 } 476 #endif 477 } 478 #if YYBTYACC 479 480 /* Do we have a conflict? */ 481 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 482 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 483 { 484 YYINT ctry; 485 486 if (yypath) 487 { 488 YYParseState *save; 489 #if YYDEBUG 490 if (yydebug) 491 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 492 YYDEBUGSTR, yydepth, yystate); 493 #endif 494 /* Switch to the next conflict context */ 495 save = yypath; 496 yypath = save->save; 497 save->save = NULL; 498 ctry = save->ctry; 499 if (save->state != yystate) YYABORT; 500 yyFreeState(save); 501 502 } 503 else 504 { 505 506 /* Unresolved conflict - start/continue trial parse */ 507 YYParseState *save; 508 #if YYDEBUG 509 if (yydebug) 510 { 511 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 512 if (yyps->save) 513 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 514 else 515 fputs("Starting trial parse.\n", stderr); 516 } 517 #endif 518 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 519 if (save == NULL) goto yyenomem; 520 save->save = yyps->save; 521 save->state = yystate; 522 save->errflag = yyerrflag; 523 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 524 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 525 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 526 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 527 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 528 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 529 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 530 #endif 531 ctry = yytable[yyn]; 532 if (yyctable[ctry] == -1) 533 { 534 #if YYDEBUG 535 if (yydebug && yychar >= YYEOF) 536 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 537 #endif 538 ctry++; 539 } 540 save->ctry = ctry; 541 if (yyps->save == NULL) 542 { 543 /* If this is a first conflict in the stack, start saving lexemes */ 544 if (!yylexemes) 545 { 546 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); 547 if (yylexemes == NULL) goto yyenomem; 548 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 549 if (yylvals == NULL) goto yyenomem; 550 yylvlim = yylvals + YYLVQUEUEGROWTH; 551 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 552 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 553 if (yylpsns == NULL) goto yyenomem; 554 yylplim = yylpsns + YYLVQUEUEGROWTH; 555 #endif 556 } 557 if (yylvp == yylve) 558 { 559 yylvp = yylve = yylvals; 560 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 561 yylpp = yylpe = yylpsns; 562 #endif 563 yylexp = yylexemes; 564 if (yychar >= YYEOF) 565 { 566 *yylve++ = yylval; 567 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 568 *yylpe++ = yylloc; 569 #endif 570 *yylexp = (short) yychar; 571 yychar = YYEMPTY; 572 } 573 } 574 } 575 if (yychar >= YYEOF) 576 { 577 yylvp--; 578 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 579 yylpp--; 580 #endif 581 yylexp--; 582 yychar = YYEMPTY; 583 } 584 save->lexeme = yylvp - yylvals; 585 yyps->save = save; 586 } 587 if (yytable[yyn] == ctry) 588 { 589 #if YYDEBUG 590 if (yydebug) 591 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 592 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 593 #endif 594 if (yychar < 0) 595 { 596 yylvp++; 597 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 598 yylpp++; 599 #endif 600 yylexp++; 601 } 602 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 603 goto yyoverflow; 604 yystate = yyctable[ctry]; 605 *++yystack.s_mark = (short) yystate; 606 *++yystack.l_mark = yylval; 607 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 608 *++yystack.p_mark = yylloc; 609 #endif 610 yychar = YYEMPTY; 611 if (yyerrflag > 0) --yyerrflag; 612 goto yyloop; 613 } 614 else 615 { 616 yyn = yyctable[ctry]; 617 goto yyreduce; 618 } 619 } /* End of code dealing with conflicts */ 620 #endif /* YYBTYACC */ 621 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 622 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 623 { 624 #if YYDEBUG 625 if (yydebug) 626 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 627 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 628 #endif 629 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 630 yystate = yytable[yyn]; 631 *++yystack.s_mark = yytable[yyn]; 632 *++yystack.l_mark = yylval; 633 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 634 *++yystack.p_mark = yylloc; 635 #endif 636 yychar = YYEMPTY; 637 if (yyerrflag > 0) --yyerrflag; 638 goto yyloop; 639 } 640 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 641 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 642 { 643 yyn = yytable[yyn]; 644 goto yyreduce; 645 } 646 if (yyerrflag != 0) goto yyinrecovery; 647 #if YYBTYACC 648 649 yynewerrflag = 1; 650 goto yyerrhandler; 651 goto yyerrlab; 652 653 yyerrlab: 654 yynewerrflag = 0; 655 yyerrhandler: 656 while (yyps->save) 657 { 658 int ctry; 659 YYParseState *save = yyps->save; 660 #if YYDEBUG 661 if (yydebug) 662 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 663 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 664 (int)(yylvp - yylvals - yyps->save->lexeme)); 665 #endif 666 /* Memorize most forward-looking error state in case it's really an error. */ 667 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 668 { 669 /* Free old saved error context state */ 670 if (yyerrctx) yyFreeState(yyerrctx); 671 /* Create and fill out new saved error context state */ 672 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 673 if (yyerrctx == NULL) goto yyenomem; 674 yyerrctx->save = yyps->save; 675 yyerrctx->state = yystate; 676 yyerrctx->errflag = yyerrflag; 677 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 678 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 679 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 680 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 681 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 682 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 683 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 684 #endif 685 yyerrctx->lexeme = yylvp - yylvals; 686 } 687 yylvp = yylvals + save->lexeme; 688 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 689 yylpp = yylpsns + save->lexeme; 690 #endif 691 yylexp = yylexemes + save->lexeme; 692 yychar = YYEMPTY; 693 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 694 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 695 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 696 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 697 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 698 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 699 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 700 #endif 701 ctry = ++save->ctry; 702 yystate = save->state; 703 /* We tried shift, try reduce now */ 704 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 705 yyps->save = save->save; 706 save->save = NULL; 707 yyFreeState(save); 708 709 /* Nothing left on the stack -- error */ 710 if (!yyps->save) 711 { 712 #if YYDEBUG 713 if (yydebug) 714 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 715 YYPREFIX, yydepth); 716 #endif 717 /* Restore state as it was in the most forward-advanced error */ 718 yylvp = yylvals + yyerrctx->lexeme; 719 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 720 yylpp = yylpsns + yyerrctx->lexeme; 721 #endif 722 yylexp = yylexemes + yyerrctx->lexeme; 723 yychar = yylexp[-1]; 724 yylval = yylvp[-1]; 725 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 726 yylloc = yylpp[-1]; 727 #endif 728 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 729 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 730 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 731 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 732 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 733 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 734 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 735 #endif 736 yystate = yyerrctx->state; 737 yyFreeState(yyerrctx); 738 yyerrctx = NULL; 739 } 740 yynewerrflag = 1; 741 } 742 if (yynewerrflag == 0) goto yyinrecovery; 743 #endif /* YYBTYACC */ 744 745 YYERROR_CALL("syntax error"); 746 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 747 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 748 #endif 749 750 #if !YYBTYACC 751 goto yyerrlab; 752 yyerrlab: 753 #endif 754 ++yynerrs; 755 756 yyinrecovery: 757 if (yyerrflag < 3) 758 { 759 yyerrflag = 3; 760 for (;;) 761 { 762 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 763 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 764 { 765 #if YYDEBUG 766 if (yydebug) 767 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 768 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 769 #endif 770 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 771 yystate = yytable[yyn]; 772 *++yystack.s_mark = yytable[yyn]; 773 *++yystack.l_mark = yylval; 774 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 775 /* lookahead position is error end position */ 776 yyerror_loc_range[1] = yylloc; 777 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 778 *++yystack.p_mark = yyloc; 779 #endif 780 goto yyloop; 781 } 782 else 783 { 784 #if YYDEBUG 785 if (yydebug) 786 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 787 YYDEBUGSTR, yydepth, *yystack.s_mark); 788 #endif 789 if (yystack.s_mark <= yystack.s_base) goto yyabort; 790 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 791 /* the current TOS position is the error start position */ 792 yyerror_loc_range[0] = *yystack.p_mark; 793 #endif 794 #if defined(YYDESTRUCT_CALL) 795 #if YYBTYACC 796 if (!yytrial) 797 #endif /* YYBTYACC */ 798 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 799 YYDESTRUCT_CALL("error: discarding state", 800 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 801 #else 802 YYDESTRUCT_CALL("error: discarding state", 803 yystos[*yystack.s_mark], yystack.l_mark); 804 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 805 #endif /* defined(YYDESTRUCT_CALL) */ 806 --yystack.s_mark; 807 --yystack.l_mark; 808 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 809 --yystack.p_mark; 810 #endif 811 } 812 } 813 } 814 else 815 { 816 if (yychar == YYEOF) goto yyabort; 817 #if YYDEBUG 818 if (yydebug) 819 { 820 yys = yyname[YYTRANSLATE(yychar)]; 821 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 822 YYDEBUGSTR, yydepth, yystate, yychar, yys); 823 } 824 #endif 825 #if defined(YYDESTRUCT_CALL) 826 #if YYBTYACC 827 if (!yytrial) 828 #endif /* YYBTYACC */ 829 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 830 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 831 #else 832 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 833 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 834 #endif /* defined(YYDESTRUCT_CALL) */ 835 yychar = YYEMPTY; 836 goto yyloop; 837 } 838 839 yyreduce: 840 yym = yylen[yyn]; 841 #if YYDEBUG 842 if (yydebug) 843 { 844 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 845 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 846 #ifdef YYSTYPE_TOSTRING 847 #if YYBTYACC 848 if (!yytrial) 849 #endif /* YYBTYACC */ 850 if (yym > 0) 851 { 852 int i; 853 fputc('<', stderr); 854 for (i = yym; i > 0; i--) 855 { 856 if (i != yym) fputs(", ", stderr); 857 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 858 yystack.l_mark[1-i]), stderr); 859 } 860 fputc('>', stderr); 861 } 862 #endif 863 fputc('\n', stderr); 864 } 865 #endif 866 if (yym > 0) 867 yyval = yystack.l_mark[1-yym]; 868 else 869 memset(&yyval, 0, sizeof yyval); 870 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 871 872 /* Perform position reduction */ 873 memset(&yyloc, 0, sizeof(yyloc)); 874 #if YYBTYACC 875 if (!yytrial) 876 #endif /* YYBTYACC */ 877 { 878 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 879 /* just in case YYERROR is invoked within the action, save 880 the start of the rhs as the error start position */ 881 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 882 } 883 #endif 884 885 switch (yyn) 886 { 887 default: 888 break; 889 } 890 yystack.s_mark -= yym; 891 yystate = *yystack.s_mark; 892 yystack.l_mark -= yym; 893 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 894 yystack.p_mark -= yym; 895 #endif 896 yym = yylhs[yyn]; 897 if (yystate == 0 && yym == 0) 898 { 899 #if YYDEBUG 900 if (yydebug) 901 { 902 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 903 #ifdef YYSTYPE_TOSTRING 904 #if YYBTYACC 905 if (!yytrial) 906 #endif /* YYBTYACC */ 907 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 908 #endif 909 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 910 } 911 #endif 912 yystate = YYFINAL; 913 *++yystack.s_mark = YYFINAL; 914 *++yystack.l_mark = yyval; 915 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 916 *++yystack.p_mark = yyloc; 917 #endif 918 if (yychar < 0) 919 { 920 #if YYBTYACC 921 do { 922 if (yylvp < yylve) 923 { 924 /* we're currently re-reading tokens */ 925 yylval = *yylvp++; 926 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 927 yylloc = *yylpp++; 928 #endif 929 yychar = *yylexp++; 930 break; 931 } 932 if (yyps->save) 933 { 934 /* in trial mode; save scanner results for future parse attempts */ 935 if (yylvp == yylvlim) 936 { /* Enlarge lexical value queue */ 937 int p = yylvp - yylvals; 938 int s = yylvlim - yylvals; 939 940 s += YYLVQUEUEGROWTH; 941 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) 942 goto yyenomem; 943 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 944 goto yyenomem; 945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 946 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 947 goto yyenomem; 948 #endif 949 yylvp = yylve = yylvals + p; 950 yylvlim = yylvals + s; 951 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 952 yylpp = yylpe = yylpsns + p; 953 yylplim = yylpsns + s; 954 #endif 955 yylexp = yylexemes + p; 956 } 957 *yylexp = (short) YYLEX; 958 *yylvp++ = yylval; 959 yylve++; 960 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 961 *yylpp++ = yylloc; 962 yylpe++; 963 #endif 964 yychar = *yylexp++; 965 break; 966 } 967 /* normal operation, no conflict encountered */ 968 #endif /* YYBTYACC */ 969 yychar = YYLEX; 970 #if YYBTYACC 971 } while (0); 972 #endif /* YYBTYACC */ 973 if (yychar < 0) yychar = YYEOF; 974 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 975 #if YYDEBUG 976 if (yydebug) 977 { 978 yys = yyname[YYTRANSLATE(yychar)]; 979 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n", 980 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 981 } 982 #endif 983 } 984 if (yychar == YYEOF) goto yyaccept; 985 goto yyloop; 986 } 987 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 988 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 989 yystate = yytable[yyn]; 990 else 991 yystate = yydgoto[yym]; 992 #if YYDEBUG 993 if (yydebug) 994 { 995 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 996 #ifdef YYSTYPE_TOSTRING 997 #if YYBTYACC 998 if (!yytrial) 999 #endif /* YYBTYACC */ 1000 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1001 #endif 1002 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1003 } 1004 #endif 1005 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1006 *++yystack.s_mark = (short) yystate; 1007 *++yystack.l_mark = yyval; 1008 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1009 *++yystack.p_mark = yyloc; 1010 #endif 1011 goto yyloop; 1012 #if YYBTYACC 1013 1014 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1015 yyvalid: 1016 if (yypath) YYABORT; 1017 while (yyps->save) 1018 { 1019 YYParseState *save = yyps->save; 1020 yyps->save = save->save; 1021 save->save = yypath; 1022 yypath = save; 1023 } 1024 #if YYDEBUG 1025 if (yydebug) 1026 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1027 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1028 #endif 1029 if (yyerrctx) 1030 { 1031 yyFreeState(yyerrctx); 1032 yyerrctx = NULL; 1033 } 1034 yylvp = yylvals + yypath->lexeme; 1035 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1036 yylpp = yylpsns + yypath->lexeme; 1037 #endif 1038 yylexp = yylexemes + yypath->lexeme; 1039 yychar = YYEMPTY; 1040 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1041 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1042 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1043 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1044 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1045 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1046 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1047 #endif 1048 yystate = yypath->state; 1049 goto yyloop; 1050 #endif /* YYBTYACC */ 1051 1052 yyoverflow: 1053 YYERROR_CALL("yacc stack overflow"); 1054 #if YYBTYACC 1055 goto yyabort_nomem; 1056 yyenomem: 1057 YYERROR_CALL("memory exhausted"); 1058 yyabort_nomem: 1059 #endif /* YYBTYACC */ 1060 yyresult = 2; 1061 goto yyreturn; 1062 1063 yyabort: 1064 yyresult = 1; 1065 goto yyreturn; 1066 1067 yyaccept: 1068 #if YYBTYACC 1069 if (yyps->save) goto yyvalid; 1070 #endif /* YYBTYACC */ 1071 yyresult = 0; 1072 1073 yyreturn: 1074 #if defined(YYDESTRUCT_CALL) 1075 if (yychar != YYEOF && yychar != YYEMPTY) 1076 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1077 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1078 #else 1079 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1080 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1081 1082 { 1083 YYSTYPE *pv; 1084 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1085 YYLTYPE *pp; 1086 1087 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1088 YYDESTRUCT_CALL("cleanup: discarding state", 1089 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1090 #else 1091 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1092 YYDESTRUCT_CALL("cleanup: discarding state", 1093 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1094 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1095 } 1096 #endif /* defined(YYDESTRUCT_CALL) */ 1097 1098 #if YYBTYACC 1099 if (yyerrctx) 1100 { 1101 yyFreeState(yyerrctx); 1102 yyerrctx = NULL; 1103 } 1104 while (yyps) 1105 { 1106 YYParseState *save = yyps; 1107 yyps = save->save; 1108 save->save = NULL; 1109 yyFreeState(save); 1110 } 1111 while (yypath) 1112 { 1113 YYParseState *save = yypath; 1114 yypath = save->save; 1115 save->save = NULL; 1116 yyFreeState(save); 1117 } 1118 #endif /* YYBTYACC */ 1119 yyfreestack(&yystack); 1120 return (yyresult); 1121 } 1122