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