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