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