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