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