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