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