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