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