1/* original parser id follows */ 2/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3/* (use YYMAJOR/YYMINOR for ifdefs dependent on 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 17#ifndef yyparse 18#define yyparse expr.oxout_parse 19#endif /* yyparse */ 20 21#ifndef yylex 22#define yylex expr.oxout_lex 23#endif /* yylex */ 24 25#ifndef yyerror 26#define yyerror expr.oxout_error 27#endif /* yyerror */ 28 29#ifndef yychar 30#define yychar expr.oxout_char 31#endif /* yychar */ 32 33#ifndef yyval 34#define yyval expr.oxout_val 35#endif /* yyval */ 36 37#ifndef yylval 38#define yylval expr.oxout_lval 39#endif /* yylval */ 40 41#ifndef yydebug 42#define yydebug expr.oxout_debug 43#endif /* yydebug */ 44 45#ifndef yynerrs 46#define yynerrs expr.oxout_nerrs 47#endif /* yynerrs */ 48 49#ifndef yyerrflag 50#define yyerrflag expr.oxout_errflag 51#endif /* yyerrflag */ 52 53#ifndef yylhs 54#define yylhs expr.oxout_lhs 55#endif /* yylhs */ 56 57#ifndef yylen 58#define yylen expr.oxout_len 59#endif /* yylen */ 60 61#ifndef yydefred 62#define yydefred expr.oxout_defred 63#endif /* yydefred */ 64 65#ifndef yydgoto 66#define yydgoto expr.oxout_dgoto 67#endif /* yydgoto */ 68 69#ifndef yysindex 70#define yysindex expr.oxout_sindex 71#endif /* yysindex */ 72 73#ifndef yyrindex 74#define yyrindex expr.oxout_rindex 75#endif /* yyrindex */ 76 77#ifndef yygindex 78#define yygindex expr.oxout_gindex 79#endif /* yygindex */ 80 81#ifndef yytable 82#define yytable expr.oxout_table 83#endif /* yytable */ 84 85#ifndef yycheck 86#define yycheck expr.oxout_check 87#endif /* yycheck */ 88 89#ifndef yyname 90#define yyname expr.oxout_name 91#endif /* yyname */ 92 93#ifndef yyrule 94#define yyrule expr.oxout_rule 95#endif /* yyrule */ 96#define YYPREFIX "expr.oxout_" 97 98#define YYPURE 0 99 100#line 5 "expr.oxout.y" 101#include <stdlib.h> 102#include <string.h> 103#line 8 "expr.Y" 104 105#include "expr.oxout.h" 106#include <stdio.h> 107 108extern int yylex(void); 109extern void yyerror(const char *); 110#line 27 "expr.oxout.y" 111#include <limits.h> 112#define yyyR USHRT_MAX 113#ifdef YYSTYPE 114#undef YYSTYPE_IS_DECLARED 115#define YYSTYPE_IS_DECLARED 1 116#endif 117#ifndef YYSTYPE_IS_DECLARED 118#define YYSTYPE_IS_DECLARED 1 119#line 31 "expr.oxout.y" 120typedef union { 121struct yyyOxAttrbs { 122struct yyyStackItem *yyyOxStackItem; 123} yyyOxAttrbs; 124} YYSTYPE; 125#endif /* !YYSTYPE_IS_DECLARED */ 126#line 38 "expr.oxout.y" 127#include <stdio.h> 128#include <stdarg.h> 129 130static int yyyYok = 1; 131 132extern yyyFT yyyRCIL[]; 133 134void yyyExecuteRRsection(yyyGNT *rootNode); 135void yyyYoxInit(void); 136void yyyDecorate(void); 137struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ 138void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); 139void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); 140void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); 141void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); 142void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); 143void yyyabort(void); 144 145#line 146 "expr.oxout.tab.c" 146 147/* compatibility with bison */ 148#ifdef YYPARSE_PARAM 149/* compatibility with FreeBSD */ 150# ifdef YYPARSE_PARAM_TYPE 151# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 152# else 153# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 154# endif 155#else 156# define YYPARSE_DECL() yyparse(void) 157#endif 158 159/* Parameters sent to lex. */ 160#ifdef YYLEX_PARAM 161# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 162# define YYLEX yylex(YYLEX_PARAM) 163#else 164# define YYLEX_DECL() yylex(void) 165# define YYLEX yylex() 166#endif 167 168/* Parameters sent to yyerror. */ 169#ifndef YYERROR_DECL 170#define YYERROR_DECL() yyerror(const char *s) 171#endif 172#ifndef YYERROR_CALL 173#define YYERROR_CALL(msg) yyerror(msg) 174#endif 175 176extern int YYPARSE_DECL(); 177 178#define ID 257 179#define CONST 258 180#define YYERRCODE 256 181typedef int YYINT; 182static const YYINT expr.oxout_lhs[] = { -1, 183 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, 184}; 185static const YYINT expr.oxout_len[] = { 2, 186 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, 187}; 188static const YYINT expr.oxout_defred[] = { 1, 189 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, 190 0, 0, 8, 0, 0, 4, 0, 191}; 192static const YYINT expr.oxout_dgoto[] = { 1, 193 6, 2, 7, 194}; 195static const YYINT expr.oxout_sindex[] = { 0, 196 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, 197 -40, -40, 0, -37, -37, 0, -39, 198}; 199static const YYINT expr.oxout_rindex[] = { 0, 200 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 201 0, 0, 0, 2, 8, 0, 1, 202}; 203static const YYINT expr.oxout_gindex[] = { 0, 204 0, 0, 4, 205}; 206#define YYTABLESIZE 218 207static const YYINT expr.oxout_table[] = { 5, 208 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, 209 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, 210 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, 211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, 213 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, 214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 218 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 229 0, 0, 0, 0, 0, 0, 3, 4, 230}; 231static const YYINT expr.oxout_check[] = { 40, 232 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, 233 -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, 234 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, 235 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 236 -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, 237 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, 238 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 239 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 240 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 241 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 242 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 243 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 244 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 245 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 246 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 247 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 248 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 249 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 250 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 251 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 252 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 253 -1, -1, -1, -1, -1, -1, 257, 258, 254}; 255#define YYFINAL 1 256#ifndef YYDEBUG 257#define YYDEBUG 0 258#endif 259#define YYMAXTOKEN 258 260#define YYUNDFTOKEN 264 261#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 262#if YYDEBUG 263static const char *const expr.oxout_name[] = { 264 265"end-of-file",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, 2660,0,0,0,0,0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2670,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, 2680,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, 2690,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, 2700,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, 2710,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,"ID", 272"CONST",0,0,0,0,0,"illegal-symbol", 273}; 274static const char *const expr.oxout_rule[] = { 275"$accept : yyyAugNonterm", 276"$$1 :", 277"yyyAugNonterm : $$1 s", 278"s : expr", 279"expr : expr '*' expr", 280"expr : expr '+' expr", 281"expr : expr '/' expr", 282"expr : expr '-' expr", 283"expr : '(' expr ')'", 284"expr : ID", 285"expr : CONST", 286 287}; 288#endif 289 290int yydebug; 291int yynerrs; 292 293int yyerrflag; 294int yychar; 295YYSTYPE yyval; 296YYSTYPE yylval; 297 298/* define the initial stack-sizes */ 299#ifdef YYSTACKSIZE 300#undef YYMAXDEPTH 301#define YYMAXDEPTH YYSTACKSIZE 302#else 303#ifdef YYMAXDEPTH 304#define YYSTACKSIZE YYMAXDEPTH 305#else 306#define YYSTACKSIZE 10000 307#define YYMAXDEPTH 10000 308#endif 309#endif 310 311#define YYINITSTACKSIZE 200 312 313typedef struct { 314 unsigned stacksize; 315 YYINT *s_base; 316 YYINT *s_mark; 317 YYINT *s_last; 318 YYSTYPE *l_base; 319 YYSTYPE *l_mark; 320} YYSTACKDATA; 321/* variables for the parser stack */ 322static YYSTACKDATA yystack; 323#line 53 "expr.Y" 324 325 326int yyparse(void); 327 328int main() 329 {yyparse(); 330 } 331 332 333 334#line 138 "expr.oxout.y" 335long yyySSALspaceSize = 20000; 336long yyyRSmaxSize = 1000; 337long yyyTravStackMaxSize = 2000; 338 339struct yyySolvedSAlistCell {yyyWAT attrbNum; 340 long next; 341 }; 342 343#define yyyLambdaSSAL 0 344long yyySSALCfreeList = yyyLambdaSSAL; 345long yyyNewSSALC = 1; 346 347struct yyySolvedSAlistCell *yyySSALspace; 348 349long yyyNbytesStackStg; 350 351 352 353yyyFT yyyRCIL[1]; 354 355short yyyIIIEL[] = {0, 3560,2,6,10,14,18,22,24, 357}; 358 359long yyyIIEL[] = { 3600,0,0,0,0,0,0,0,0,0,0,0, 3610,0,0,0,0,0,0,0,0,0,0,0, 3621,1, 363}; 364 365long yyyIEL[] = { 3660,0,0, 367}; 368 369yyyFT yyyEntL[1]; 370 371void yyyfatal(char *msg) 372{fputs(msg,stderr);exit(-1);} 373 374 375 376#define yyySSALof 'S' 377#define yyyRSof 'q' 378#define yyyTSof 't' 379 380 381 382void yyyHandleOverflow(char which) 383 {char *msg1,*msg2; 384 long oldSize,newSize; 385 switch(which) 386 { 387 case yyySSALof : 388 msg1 = "SSAL overflow: "; 389 oldSize = yyySSALspaceSize; 390 break; 391 case yyyRSof : 392 msg1 = "ready set overflow: "; 393 oldSize = yyyRSmaxSize; 394 break; 395 case yyyTSof : 396 msg1 = "traversal stack overflow: "; 397 oldSize = yyyTravStackMaxSize; 398 break; 399 default :; 400 } 401 newSize = (3*oldSize)/2; 402 if (newSize < 100) newSize = 100; 403 fputs(msg1,stderr); 404 fprintf(stderr,"size was %ld.\n",oldSize); 405 msg2 = " Have to modify evaluator: -Y%c%ld.\n"; 406 fprintf(stderr,msg2,which,newSize); 407 exit(-1); 408 } 409 410 411 412void yyySignalEnts(yyyGNT *node,long startP,long stopP) 413 {yyyGNT *dumNode; 414 415 while (startP < stopP) 416 { 417 if (!yyyEntL[startP]) dumNode = node; 418 else dumNode = (node->cL)[yyyEntL[startP]-1]; 419 if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] 420 ) 421 ) 422 ) 423 { 424 if (++yyyRSTop == yyyAfterRS) 425 {yyyHandleOverflow(yyyRSof); 426 break; 427 } 428 yyyRSTop->node = dumNode; 429 yyyRSTop->whichSym = yyyEntL[startP]; 430 yyyRSTop->wa = yyyEntL[startP+1]; 431 } 432 startP += 2; 433 } 434 } 435 436 437 438 439 440 441void yyySolveAndSignal() { 442long yyyiDum,*yyypL; 443int yyyws,yyywa; 444yyyGNT *yyyRSTopN,*yyyRefN; 445yyyParent yyyRSTopNp; 446 447 448yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; 449yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; 450yyywa = yyyRSTop->wa; 451yyyRSTop--; 452switch(yyyRefN->prodNum) { 453case 1: /***yacc rule 1***/ 454 switch (yyyws) { 455 } 456break; 457case 2: /***yacc rule 2***/ 458 switch (yyyws) { 459 } 460break; 461case 3: /***yacc rule 3***/ 462 switch (yyyws) { 463 } 464break; 465case 4: /***yacc rule 4***/ 466 switch (yyyws) { 467 } 468break; 469case 5: /***yacc rule 5***/ 470 switch (yyyws) { 471 } 472break; 473case 6: /***yacc rule 6***/ 474 switch (yyyws) { 475 } 476break; 477case 7: /***yacc rule 7***/ 478 switch (yyyws) { 479 case 1: /**/ 480 switch (yyywa) { 481 } 482 break; 483 } 484break; 485case 8: /***yacc rule 8***/ 486 switch (yyyws) { 487 case 1: /**/ 488 switch (yyywa) { 489 } 490 break; 491 } 492break; 493} /* switch */ 494 495if (yyyws) /* the just-solved instance was inherited. */ 496 {if (yyyRSTopN->prodNum) 497 {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; 498 yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], 499 yyyIEL[yyyiDum+1] 500 ); 501 } 502 } 503 else /* the just-solved instance was synthesized. */ 504 {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ 505 {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + 506 yyyRSTopN->whichSym 507 ] + 508 yyywa; 509 yyySignalEnts(yyyRSTopNp.noderef, 510 yyyIEL[yyyiDum], 511 yyyIEL[yyyiDum+1] 512 ); 513 } 514 else /* node is still on the stack--it has no parent yet. */ 515 {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); 516 if (yyySSALCfreeList == yyyLambdaSSAL) 517 {yyySSALspace[yyyNewSSALC].next = *yyypL; 518 if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) 519 yyyHandleOverflow(yyySSALof); 520 } 521 else 522 {yyyiDum = yyySSALCfreeList; 523 yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; 524 yyySSALspace[yyyiDum].next = *yyypL; 525 *yyypL = yyyiDum; 526 } 527 yyySSALspace[*yyypL].attrbNum = yyywa; 528 } 529 } 530 531} /* yyySolveAndSignal */ 532 533 534 535 536 537 538#define condStg unsigned int conds; 539#define yyyClearConds {yyyTST->conds = 0;} 540#define yyySetCond(n) {yyyTST->conds += (1<<(n));} 541#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) 542 543 544 545struct yyyTravStackItem {yyyGNT *node; 546 char isReady; 547 condStg 548 }; 549 550 551 552void yyyDoTraversals(yyyGNT *rootNode) 553{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; 554 yyyGNT *yyyTSTn,**yyyCLptr2; 555 int yyyi,yyyRL,yyyPass; 556 int i; 557 558 if (!yyyYok) return; 559 if ((yyyTravStack = 560 ((struct yyyTravStackItem *) 561 calloc((size_t)yyyTravStackMaxSize, 562 (size_t)sizeof(struct yyyTravStackItem) 563 ) 564 ) 565 ) 566 == 567 (struct yyyTravStackItem *)NULL 568 ) 569 {fputs("malloc error in traversal stack allocation\n",stderr); 570 exit(-1); 571 } 572 573yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; 574yyyTravStack++; 575 576 577for (yyyi=0; yyyi<2; yyyi++) { 578yyyTST = yyyTravStack; 579yyyTST->node = rootNode; 580yyyTST->isReady = 0; 581yyyClearConds 582 583while(yyyTST >= yyyTravStack) 584 {yyyTSTn = yyyTST->node; 585 if (yyyTST->isReady) 586 {yyyPass = 1; 587 goto yyyTravSwitch; 588yyyTpop: 589 yyyTST--; 590 } 591 else 592 {yyyPass = 0; 593 goto yyyTravSwitch; 594yyyTpush: 595 yyyTST->isReady = 1; 596 if (yyyTSTn->prodNum) 597 {if (yyyRL) 598 {yyyCLptr2 = yyyTSTn->cL; 599 i = yyyTSTn->cLlen; 600 while (i--) 601 {if (++yyyTST == yyyAfterTravStack) 602 yyyHandleOverflow(yyyTSof); 603 else 604 {yyyTST->node = *yyyCLptr2; 605 yyyTST->isReady = 0; 606 yyyClearConds 607 } 608 yyyCLptr2++; 609 } 610 } /* right to left */ 611 else /* left to right */ 612 {i = yyyTSTn->cLlen; 613 yyyCLptr2 = yyyTSTn->cL + i; 614 while (i--) 615 {yyyCLptr2--; 616 if (++yyyTST == yyyAfterTravStack) 617 yyyHandleOverflow(yyyTSof); 618 else 619 {yyyTST->node = *yyyCLptr2; 620 yyyTST->isReady = 0; 621 yyyClearConds 622 } 623 } 624 } /* left to right */ 625 } 626 } /* else */ 627 continue; 628yyyTravSwitch: 629 switch(yyyTSTn->prodNum) { 630case 1: 631 switch(yyyi) { 632 case 0: 633 switch(yyyPass) { 634 case 0: 635yyyRL = 0;yyySetCond(0) 636 637if (! 638#line 24 "expr.Y" 639 (1) 640#line 444 "expr.oxout.y" 641) yyySetCond(1) 642yyySetCond(2) 643 644 case 1: 645 646if (yyyCond(0) != yyyPass) { 647#line 24 "expr.Y" 648 649#line 453 "expr.oxout.y" 650} 651if (yyyCond(1) != yyyPass) { 652#line 24 "expr.Y" 653 printf("\n"); 654 655#line 459 "expr.oxout.y" 656} 657if (yyyCond(2) != yyyPass) { 658#line 25 "expr.Y" 659 printf("prefix: "); 660 661#line 465 "expr.oxout.y" 662} 663 break; 664 } 665 break; 666 case 1: 667 switch(yyyPass) { 668 case 0: 669yyyRL = 0; 670if ( 671#line 23 "expr.Y" 672 (1) 673#line 477 "expr.oxout.y" 674) yyySetCond(2) 675 676 case 1: 677 678if (yyyCond(0) != yyyPass) { 679#line 22 "expr.Y" 680 printf("\n"); 681 682#line 486 "expr.oxout.y" 683} 684if (yyyCond(1) != yyyPass) { 685#line 23 "expr.Y" 686 687#line 491 "expr.oxout.y" 688} 689if (yyyCond(2) != yyyPass) { 690#line 23 "expr.Y" 691 printf("postfix: ")/* missing ; */ 692 693#line 497 "expr.oxout.y" 694} 695 break; 696 } 697 break; 698 } 699 700break; 701case 2: 702 switch(yyyi) { 703 case 0: 704 switch(yyyPass) { 705 case 0: 706yyyRL = 0;yyySetCond(0) 707 708 case 1: 709 710if (yyyCond(0) != yyyPass) { 711#line 29 "expr.Y" 712 printf(" * "); 713 714#line 518 "expr.oxout.y" 715} 716 break; 717 } 718 break; 719 case 1: 720 switch(yyyPass) { 721 case 0: 722yyyRL = 0; 723 case 1: 724 725if (yyyCond(0) != yyyPass) { 726#line 28 "expr.Y" 727 printf(" * "); 728 729#line 533 "expr.oxout.y" 730} 731 break; 732 } 733 break; 734 } 735 736break; 737case 3: 738 switch(yyyi) { 739 case 0: 740 switch(yyyPass) { 741 case 0: 742yyyRL = 0;yyySetCond(0) 743 744 case 1: 745 746if (yyyCond(0) != yyyPass) { 747#line 32 "expr.Y" 748 printf(" + "); 749 750#line 554 "expr.oxout.y" 751} 752 break; 753 } 754 break; 755 case 1: 756 switch(yyyPass) { 757 case 0: 758yyyRL = 0; 759 case 1: 760 761if (yyyCond(0) != yyyPass) { 762#line 33 "expr.Y" 763 printf(" + "); 764 765#line 569 "expr.oxout.y" 766} 767 break; 768 } 769 break; 770 } 771 772break; 773case 4: 774 switch(yyyi) { 775 case 0: 776 switch(yyyPass) { 777 case 0: 778yyyRL = 0;yyySetCond(0) 779 780 case 1: 781 782if (yyyCond(0) != yyyPass) { 783#line 37 "expr.Y" 784 printf(" / "); 785 786#line 590 "expr.oxout.y" 787} 788 break; 789 } 790 break; 791 case 1: 792 switch(yyyPass) { 793 case 0: 794yyyRL = 0; 795 case 1: 796 797if (yyyCond(0) != yyyPass) { 798#line 36 "expr.Y" 799 printf(" / "); 800 801#line 605 "expr.oxout.y" 802} 803 break; 804 } 805 break; 806 } 807 808break; 809case 5: 810 switch(yyyi) { 811 case 0: 812 switch(yyyPass) { 813 case 0: 814yyyRL = 0;yyySetCond(0) 815 816 case 1: 817 818if (yyyCond(0) != yyyPass) { 819#line 41 "expr.Y" 820 printf(" - "); 821 822#line 626 "expr.oxout.y" 823} 824 break; 825 } 826 break; 827 case 1: 828 switch(yyyPass) { 829 case 0: 830yyyRL = 0; 831 case 1: 832 833if (yyyCond(0) != yyyPass) { 834#line 40 "expr.Y" 835 printf(" - "); 836 837#line 641 "expr.oxout.y" 838} 839 break; 840 } 841 break; 842 } 843 844break; 845case 6: 846 switch(yyyi) { 847 case 0: 848 switch(yyyPass) { 849 case 0: 850yyyRL = 0; 851 case 1: 852 853 break; 854 } 855 break; 856 case 1: 857 switch(yyyPass) { 858 case 0: 859yyyRL = 0; 860 case 1: 861 862 break; 863 } 864 break; 865 } 866 867break; 868case 7: 869 switch(yyyi) { 870 case 0: 871 switch(yyyPass) { 872 case 0: 873yyyRL = 0;yyySetCond(0) 874 875 case 1: 876 877if (yyyCond(0) != yyyPass) { 878#line 46 "expr.Y" 879 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 880 881#line 685 "expr.oxout.y" 882} 883 break; 884 } 885 break; 886 case 1: 887 switch(yyyPass) { 888 case 0: 889yyyRL = 0; 890 case 1: 891 892if (yyyCond(0) != yyyPass) { 893#line 45 "expr.Y" 894 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 895 896#line 700 "expr.oxout.y" 897} 898 break; 899 } 900 break; 901 } 902 903break; 904case 8: 905 switch(yyyi) { 906 case 0: 907 switch(yyyPass) { 908 case 0: 909yyyRL = 0;yyySetCond(0) 910 911 case 1: 912 913if (yyyCond(0) != yyyPass) { 914#line 50 "expr.Y" 915 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 916 917#line 721 "expr.oxout.y" 918} 919 break; 920 } 921 break; 922 case 1: 923 switch(yyyPass) { 924 case 0: 925yyyRL = 0; 926 case 1: 927 928if (yyyCond(0) != yyyPass) { 929#line 49 "expr.Y" 930 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 931 932#line 736 "expr.oxout.y" 933} 934 break; 935 } 936 break; 937 } 938 939break; 940 } /* switch */ 941 if (yyyPass) goto yyyTpop; else goto yyyTpush; 942 } /* while */ 943 } /* for */ 944} /* yyyDoTraversals */ 945 946void yyyExecuteRRsection(yyyGNT *rootNode) { 947 int yyyi; 948 long cycleSum = 0; 949 long nNZrc = 0; 950 951 if (!yyyYok) return; 952 yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); 953 if (nNZrc) 954 { 955 fputs("\n\n\n**********\n",stderr); 956 fputs("cycle detected in completed parse tree",stderr); 957 fputs(" after decoration.\n",stderr); 958#if CYCLE_VERBOSE 959 fprintf(stderr, 960 "number of unsolved attribute instances == %ld.\n", 961 nNZrc 962 ); 963 fprintf(stderr, 964 "total number of remaining dependencies == %ld.\n", 965 cycleSum 966 ); 967 fputs("average number of remaining dependencies\n",stderr); 968 fprintf(stderr," per unsolved instance == %f.\n", 969 ((float)(cycleSum)/(float)(nNZrc)) 970 ); 971#endif 972 fprintf(stderr, 973 "searching parse tree for %ld unsolved instances:\n", 974 nNZrc 975 ); 976 yyyUnsolvedInstSearchTravAux(rootNode); 977 } 978 yyyDoTraversals(rootNode); 979} /* yyyExecuteRRsection */ 980 981 982 983yyyWAT yyyLRCIL[2] = {0,0, 984}; 985 986 987 988void yyyYoxInit(void) 989 { 990 static int yyyInitDone = 0; 991 if (yyyInitDone) return; 992 993 if ((yyyRS = (struct yyyRSitem *) 994 calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(struct yyyRSitem)) 995 ) 996 == 997 ((struct yyyRSitem *) NULL) 998 ) 999 yyyfatal("malloc error in ox ready set space allocation\n"); 1000 yyyRS++; 1001 yyyAfterRS = yyyRS + yyyRSmaxSize; 1002 1003 1004 if ((yyySSALspace = (struct yyySolvedSAlistCell *) 1005 calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) 1006 ) 1007 == 1008 ((struct yyySolvedSAlistCell *) NULL) 1009 ) 1010 yyyfatal("malloc error in stack solved list space allocation\n"); 1011 yyyInitDone = 1; 1012 1013 yyyRSTop = yyyRS - 1; 1014 } /* yyyYoxInit */ 1015 1016 1017 1018void yyyDecorate(void) 1019 { 1020 while (yyyRSTop >= yyyRS) 1021 yyySolveAndSignal(); 1022 } 1023 1024 1025 1026void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) 1027 {yyyWST i; 1028 yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; 1029 yyyGNT *gnpDum; 1030 va_list ap; 1031 1032 *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); 1033 if (*yyyOxStackItem == (yyySIT *) NULL) 1034 yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); 1035 (*yyyOxStackItem)->node = 1036 (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); 1037 if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) 1038 yyyfatal("malloc error in ox node space allocation\n"); 1039 (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; 1040 (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; 1041 (*yyyOxStackItem)->node->parentIsStack = 1; 1042 (*yyyOxStackItem)->node->cLlen = yyyRHSlength; 1043 (*yyyOxStackItem)->node->cL = 1044 (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); 1045 if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) 1046 yyyfatal("malloc error in ox child list space allocation\n"); 1047 (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; 1048 (*yyyOxStackItem)->node->refCountList = 1049 (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); 1050 if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) 1051 yyyfatal("malloc error in ox reference count list space allocation\n"); 1052 (*yyyOxStackItem)->node->prodNum = yyyProdNum; 1053 va_start(ap, yyval_OxAttrbs); 1054 for (i=1;i<=yyyRHSlength;i++) 1055 {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; 1056 gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; 1057 gnpDum->whichSym = i; 1058 gnpDum->parent.noderef = (*yyyOxStackItem)->node; 1059 gnpDum->parentIsStack = 0; 1060 } 1061 va_end(ap); 1062 } 1063 1064 1065 1066#define yyyDECORfREQ 50 1067 1068 1069 1070void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) 1071 {yyyWST i; 1072 yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; 1073 long SSALptr,SSALptrHead,*cPtrPtr; 1074 long *pL; 1075 yyyGNT *gnpDum; 1076 long iTemp; 1077 long nextP; 1078 static unsigned short intNodeCount = yyyDECORfREQ; 1079 va_list ap; 1080 1081 nextP = startP; 1082 while (nextP < stopP) 1083 {if (yyyRCIL[nextP] == yyyR) 1084 {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; 1085 } 1086 else 1087 {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; 1088 } 1089 nextP += 3; 1090 } 1091 pL = yyyIIEL + yyyIIIEL[yyyProdNum]; 1092 va_start(ap, yyval_OxAttrbs); 1093 for (i=1;i<=yyyRHSlength;i++) 1094 {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; 1095 pL++; 1096 SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); 1097 if (SSALptr != yyyLambdaSSAL) 1098 {*cPtrPtr = yyyLambdaSSAL; 1099 do 1100 { 1101 iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); 1102 yyySignalEnts(yyyOxStackItem->node, 1103 yyyIEL[iTemp], 1104 yyyIEL[iTemp+1] 1105 ); 1106 SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); 1107 } 1108 while (SSALptr != yyyLambdaSSAL); 1109 *cPtrPtr = yyySSALCfreeList; 1110 yyySSALCfreeList = SSALptrHead; 1111 } 1112 } 1113 va_end(ap); 1114 nextP = startP + 2; 1115 while (nextP < stopP) 1116 {if (!yyyRCIL[nextP]) 1117 {if (yyyRCIL[nextP-2] == yyyR) 1118 {pL = &(yyyOxStackItem->solvedSAlist); 1119 if (yyySSALCfreeList == yyyLambdaSSAL) 1120 {yyySSALspace[yyyNewSSALC].next = *pL; 1121 if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) 1122 yyyHandleOverflow(yyySSALof); 1123 } 1124 else 1125 {iTemp = yyySSALCfreeList; 1126 yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; 1127 yyySSALspace[iTemp].next = *pL; 1128 *pL = iTemp; 1129 } 1130 yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; 1131 } 1132 else 1133 {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) 1134 { 1135 iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; 1136 yyySignalEnts(gnpDum, 1137 yyyIEL[iTemp], 1138 yyyIEL[iTemp+1] 1139 ); 1140 } 1141 } 1142 } 1143 nextP += 3; 1144 } 1145 if (!--intNodeCount) 1146 {intNodeCount = yyyDECORfREQ; 1147 yyyDecorate(); 1148 } 1149 } 1150 1151 1152 1153void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *yylval) 1154 {yyyRCT *rcPdum; 1155 yyySIT **yyyOxStackItem = &yylval->yyyOxAttrbs.yyyOxStackItem; 1156 (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); 1157 if ((*yyyOxStackItem) == (yyySIT *) NULL) 1158 yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); 1159 (*yyyOxStackItem)->node = 1160 (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) 1161 ; 1162 if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) 1163 yyyfatal("malloc error in ox node space allocation\n"); 1164 (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; 1165 (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; 1166 (*yyyOxStackItem)->node->parentIsStack = 1; 1167 (*yyyOxStackItem)->node->cLlen = 0; 1168 (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; 1169 (*yyyOxStackItem)->node->refCountListLen = nAttrbs; 1170 rcPdum = (*yyyOxStackItem)->node->refCountList = 1171 (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); 1172 if (rcPdum == (yyyRCT *) NULL) 1173 yyyfatal("malloc error in ox reference count list space allocation\n"); 1174 while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; 1175 (*yyyOxStackItem)->node->prodNum = 0; 1176 (*yyyOxStackItem)->node->whichSym = 0; 1177 } 1178 1179 1180 1181void yyyabort(void) 1182 {yyyYok = 0; 1183 } 1184 1185 1186 1187 1188 1189#define yyyLastProdNum 8 1190 1191 1192#define yyyNsorts 1 1193 1194 1195int yyyProdsInd[] = { 1196 0, 1197 0, 2, 6, 10, 14, 18, 22, 24, 1198 26, 1199}; 1200 1201 1202int yyyProds[][2] = { 1203{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, 1204{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, 1205{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, 1206{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, 1207{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, 1208{ 567, 1}, 1209}; 1210 1211 1212int yyySortsInd[] = { 1213 0, 1214 0, 1215 1, 1216}; 1217 1218 1219int yyySorts[] = { 1220 413, 1221}; 1222 1223 1224 1225char *yyyStringTab[] = { 12260,0,0,0,0, 12270,0,0,0,0, 12280,0,0,0,0, 12290,0,0,0,0, 12300,0,0,0,0, 12310,0,0,0,0, 12320,0,0,0,0, 12330,0,0,0,0, 12340,0,0,0,0, 12350,0,0,0,0, 12360,0,0,0,0, 12370,0,0,0,0, 12380,0,0,0,0, 12390,0,0,0,0, 12400,0,0,0,0, 12410,0,0,0,0, 12420,0,0,0,0, 12430,0,0,0,0, 12440,0,0,0,0, 12450,0,0,0,0, 12460,0,0,0,0, 12470,0,0,0,0, 12480,0,0,0,0, 12490,"s",0,0,0, 12500,0,"y",0,0, 12510,0,0,0,0, 12520,0,0,0,0, 12530,0,0,0,0, 12540,0,0,0,0, 12550,0,0,0,0, 12560,0,0,0,0, 12570,0,0,0,0, 12580,0,0,0,0, 12590,0,0,0,0, 12600,0,0,0,0, 12610,0,0,0,0, 12620,0,0,0,0, 12630,0,0,0,0, 12640,0,0,0,0, 12650,0,0,0,0, 12660,0,0,0,0, 12670,0,0,0,0, 12680,0,0,0,0, 12690,0,0,0,0, 12700,0,0,0,0, 12710,0,0,0,0, 12720,0,0,0,0, 12730,0,0,0,0, 12740,0,0,0,0, 12750,0,0,0,0, 12760,0,0,0,0, 12770,0,0,0,0, 12780,0,0,0,0, 12790,0,0,0,0, 12800,0,0,0,0, 12810,0,0,0,0, 12820,0,0,0,0, 12830,0,0,0,0, 12840,0,0,0,0, 12850,0,0,0,0, 12860,0,0,0,0, 12870,0,0,0,0, 12880,0,0,0,0, 12890,0,0,0,0, 12900,0,0,0,0, 12910,"LRpre",0,0,0, 12920,0,0,0,0, 12930,0,0,0,0, 12940,0,0,0,0, 12950,0,0,0,0, 12960,0,0,0,0, 12970,0,0,0,0, 12980,0,0,0,0, 12990,0,0,0,0, 13000,0,0,0,0, 13010,0,0,0,0, 13020,0,0,0,0, 13030,0,0,0,0, 13040,0,0,0,0, 13050,"'('",0,0,0, 13060,0,0,0,"')'", 13070,0,0,0,0, 13080,0,"'*'","lexeme",0, 13090,0,0,0,0, 1310"'+'",0,0,0,0, 13110,0,0,0,0, 13120,0,0,0,0, 13130,"'-'",0,0,0, 13140,0,0,0,0, 13150,0,0,0,0, 13160,0,"'/'",0,0, 13170,0,0,0,0, 13180,0,"expr",0,0, 13190,0,0,0,0, 13200,0,0,0,0, 13210,"printf",0,0,0, 13220,0,0,0,0, 13230,0,0,0,0, 13240,0,0,0,0, 13250,0,0,0,0, 13260,0,0,0,0, 13270,0,0,0,0, 13280,0,0,0,0, 13290,0,0,0,0, 13300,0,0,0,0, 13310,0,0,0,0, 13320,0,0,0,0, 13330,0,0,0,0, 13340,0,0,0,0, 13350,0,0,0,0, 13360,0,0,0,0, 13370,0,0,0,0, 13380,0,0,0,0, 13390,0,"CONST","LRpost",0, 13400,0,0,0,0, 13410,0,0,0,0, 13420,0,0,0,0, 13430,0,0,0,0, 13440,0,0,0,0, 13450,0,0,0,0, 13460,0,0,0,0, 13470,0,0,0,0, 13480,0,0,0,0, 13490,0,0,0,"ID", 13500,0,0,0,0, 13510,0,0,0,0, 13520,0,0,0,0, 13530,0,0,0,0, 13540,0,0,0,0, 13550,0,0,0,0, 13560,0,0,0,0, 13570,0,0,0,0, 13580,0,0,0,0, 13590,0,0,0,0, 13600,0,0,0,0, 13610,0,0,0,0, 13620,0,0,0,0, 13630,0,0,0,0, 13640,0,0,0,0, 13650,0,0,0,0, 13660,0,0,0,0, 13670,0,0,0,0, 13680,0,0,0,0, 13690,0,0,0,0, 13700,0,0,0,0, 13710,0,0,0,0, 13720,0,0,0,0, 13730,0,0,0,0, 13740,0,0,0,0, 13750,0,0,0,0, 13760,0,0,0,0, 13770,0,0,0,0, 13780,0,0,0,0, 13790,0,0,0,0, 13800,0,0,0,0, 13810,0,0,0,0, 13820,0,0,0,0, 13830,0,0,0,0, 13840,0,0,0,0, 13850,0,0,0,0, 13860,0,0,0,0, 13870,0,0,0,0, 13880,0,0,0,0, 13890,0,0,0,0, 13900,0,0,0,0, 13910,0,0,0,0, 13920,0,0,0,0, 13930,0,0,0,0, 13940,0,0,0,0, 13950,0,0,0,0, 13960,0,0,0,0, 13970,0,0,0,0, 13980,0,0,0,0, 13990,0,0,0,0, 14000,0,0,0,0, 14010,0,0,0,0, 14020,0,0,0,0, 14030,0,0,0,0, 14040,0,0,0,0, 14050,0,0,0,0, 14060,0,0,0,0, 14070,0,0,0,0, 14080,0,0,0,0, 14090,0,0,0,0, 14100,0,0,0,0, 14110,0,0,0,0, 14120,0,0,0,0, 14130,0,0,0,0, 14140,0,0,0,0, 14150,0,0,0,0, 14160,0,0,0,0, 14170,0,0,0,0, 14180,0,0,0,0, 14190,0,0,0,0, 14200,0,0,0,0, 14210,0,0,0,0, 14220,0,0,0,0, 14230,0,0,0,0, 14240,0,0,0,0, 14250,0,0,0,0, 14260,0,0,0,0, 14270,0,0,0,0, 14280,0,0,0,0, 14290,0,0,0,0, 14300,0,0,0,0, 14310,0,0,0,0, 14320,0,0,0,0, 14330,0,0,0,0, 14340,0,0,0,0, 14350,0,0,0,0, 14360,0,0,0,0, 14370,0,0,0,0, 14380,0,0,0,0, 14390,0,0,0,0, 14400,0,0,0,0, 14410,0,0,0,0, 14420,0,0,0,0, 14430,0,0,0,0, 14440,0,0,0,0, 14450,0,0,0,0, 14460,0,0,0,0, 14470,0,0,0,0, 14480,0,0,0,0, 14490,0,0,0,0, 14500,0,0,0,0, 14510,0,0,0,0, 14520,0,0,0,0, 14530,0,0,0,0, 14540,0,0,0,0, 14550,0,0,0,0, 14560,0,0,0,0, 14570,0,0,0,0, 14580,0,0,0,0, 14590,0,0,0,0, 14600,0,0,0,0, 14610,0,0,0,0, 14620,0,0,0,0, 14630,0,0,0,0, 14640,0,0,0,0, 14650,0,0,0,0, 14660,0,0,0,0, 14670,0,0,0,0, 14680,0,0,0,0, 14690,0,0,0,0, 14700,0,0,0,0, 14710,0,0,0,0, 14720, 1473}; 1474 1475 1476 1477#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) 1478 1479#define yyyGSoccurStr(prodNum,symPos) \ 1480 (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) 1481 1482#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) 1483 1484#define yyySortOf(prodNum,symPos) \ 1485 (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) 1486 1487#define yyyAttrbStr(prodNum,symPos,attrbNum) \ 1488 (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ 1489 (attrbNum) \ 1490 ] \ 1491 ] \ 1492 ) 1493 1494 1495 1496void yyyShowProd(int i) 1497 {int j,nSyms; 1498 1499 nSyms = yyySizeofProd(i); 1500 for (j=0; j<nSyms; j++) 1501 { 1502 fprintf(stderr,"%s",yyyGSoccurStr(i,j)); 1503 if (j == 0) fputs(" : ",stderr); else putc(' ',stderr); 1504 } 1505 fputs(";\n",stderr); 1506 } 1507 1508 1509 1510void yyyShowProds() 1511 {int i; for (i=1; i<=yyyLastProdNum; i++) yyyShowProd(i);} 1512 1513 1514 1515void yyyShowSymsAndSorts() 1516 {int i; 1517 1518 for (i=1; i<=yyyLastProdNum; i++) 1519 {int j, nSyms; 1520 1521 fprintf(stderr, 1522 "\n\n\n---------------------------------- %3.1d\n",i); 1523 /* yyyShowProd(i); */ 1524 nSyms = yyySizeofProd(i); 1525 for (j=0; j<nSyms; j++) 1526 {int k, sortSize; 1527 1528 fprintf(stderr,"%s\n",yyyGSoccurStr(i,j)); 1529 sortSize = yyySizeofSort(yyySortOf(i,j)); 1530 for (k=0; k<sortSize; k++) 1531 fprintf(stderr," %s\n",yyyAttrbStr(i,j,k)); 1532 if (j == 0) fputs("->\n",stderr); 1533 else 1534 putc('\n',stderr); 1535 } 1536 } 1537 } 1538 1539 1540 1541void yyyCheckNodeInstancesSolved(yyyGNT *np) 1542 {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; 1543 int nUnsolvedInsts = 0; 1544 1545 if (np->prodNum != 0) 1546 {inTerminalNode = 0; 1547 prodNum = np->prodNum; 1548 symPos = 0; 1549 } 1550 else 1551 {inTerminalNode = 1; 1552 prodNum = np->parent.noderef->prodNum; 1553 symPos = np->whichSym; 1554 } 1555 mysort = yyySortOf(prodNum,symPos); 1556 sortSize = yyySizeofSort(mysort); 1557 for (i=0; i<sortSize; i++) 1558 if ((np->refCountList)[i] != 0) nUnsolvedInsts += 1; 1559 if (nUnsolvedInsts) 1560 {fprintf(stderr, 1561 "\nFound node that has %d unsolved attribute instance(s).\n", 1562 nUnsolvedInsts 1563 ); 1564 fprintf(stderr,"Node is labeled \"%s\".\n", 1565 yyyGSoccurStr(prodNum,symPos)); 1566 if (inTerminalNode) 1567 {fputs("Node is terminal. Its parent production is:\n ",stderr); 1568 yyyShowProd(prodNum); 1569 } 1570 else 1571 {fputs("Node is nonterminal. ",stderr); 1572 if (!(np->parentIsStack)) 1573 {fprintf(stderr, 1574 "Node is %dth child in its parent production:\n ", 1575 np->whichSym 1576 ); 1577 yyyShowProd(np->parent.noderef->prodNum); 1578 } 1579 fputs("Node is on left hand side of this production:\n ",stderr); 1580 yyyShowProd(np->prodNum); 1581 } 1582 fputs("The following instances are unsolved:\n",stderr); 1583 for (i=0; i<sortSize; i++) 1584 if ((np->refCountList)[i] != 0) 1585 fprintf(stderr," %-16s still has %1d dependencies.\n", 1586 yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); 1587 } 1588 } 1589 1590 1591 1592void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) 1593 {yyyGNT **yyyCLpdum; 1594 yyyRCT *rcp; 1595 int i; 1596 1597 /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ 1598 rcp = pNode->refCountList; 1599 i = pNode->refCountListLen; 1600 while (i--) 1601 if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} 1602 yyyCLpdum = pNode->cL; 1603 i = pNode->cLlen; 1604 while (i--) 1605 { 1606 yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); 1607 yyyCLpdum++; 1608 } 1609 } 1610 1611 1612 1613void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) 1614 {yyyGNT **yyyCLpdum; 1615 int i; 1616 1617 yyyCheckNodeInstancesSolved(pNode); 1618 yyyCLpdum = pNode->cL; 1619 i = pNode->cLlen; 1620 while (i--) 1621 { 1622 yyyUnsolvedInstSearchTravAux(*yyyCLpdum); 1623 yyyCLpdum++; 1624 } 1625 } 1626 1627 1628 1629void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) 1630 {yyyGNT **yyyCLpdum; 1631 int i; 1632 1633 yyyCLpdum = pNode->cL; 1634 i = pNode->cLlen; 1635 while (i--) 1636 { 1637 yyyUnsolvedInstSearchTravAux(*yyyCLpdum); 1638 yyyCLpdum++; 1639 } 1640 } 1641 1642 1643 1644#line 1645 "expr.oxout.tab.c" 1645 1646#if YYDEBUG 1647#include <stdio.h> /* needed for printf */ 1648#endif 1649 1650#include <stdlib.h> /* needed for malloc, etc */ 1651#include <string.h> /* needed for memset */ 1652 1653/* allocate initial stack or double stack size, up to YYMAXDEPTH */ 1654static int yygrowstack(YYSTACKDATA *data) 1655{ 1656 int i; 1657 unsigned newsize; 1658 YYINT *newss; 1659 YYSTYPE *newvs; 1660 1661 if ((newsize = data->stacksize) == 0) 1662 newsize = YYINITSTACKSIZE; 1663 else if (newsize >= YYMAXDEPTH) 1664 return YYENOMEM; 1665 else if ((newsize *= 2) > YYMAXDEPTH) 1666 newsize = YYMAXDEPTH; 1667 1668 i = (int) (data->s_mark - data->s_base); 1669 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 1670 if (newss == 0) 1671 return YYENOMEM; 1672 1673 data->s_base = newss; 1674 data->s_mark = newss + i; 1675 1676 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 1677 if (newvs == 0) 1678 return YYENOMEM; 1679 1680 data->l_base = newvs; 1681 data->l_mark = newvs + i; 1682 1683 data->stacksize = newsize; 1684 data->s_last = data->s_base + newsize - 1; 1685 return 0; 1686} 1687 1688#if YYPURE || defined(YY_NO_LEAKS) 1689static void yyfreestack(YYSTACKDATA *data) 1690{ 1691 free(data->s_base); 1692 free(data->l_base); 1693 memset(data, 0, sizeof(*data)); 1694} 1695#else 1696#define yyfreestack(data) /* nothing */ 1697#endif 1698 1699#define YYABORT goto yyabort 1700#define YYREJECT goto yyabort 1701#define YYACCEPT goto yyaccept 1702#define YYERROR goto yyerrlab 1703 1704int 1705YYPARSE_DECL() 1706{ 1707 int yym, yyn, yystate; 1708#if YYDEBUG 1709 const char *yys; 1710 1711 if ((yys = getenv("YYDEBUG")) != 0) 1712 { 1713 yyn = *yys; 1714 if (yyn >= '0' && yyn <= '9') 1715 yydebug = yyn - '0'; 1716 } 1717#endif 1718 1719 yym = 0; 1720 yyn = 0; 1721 yynerrs = 0; 1722 yyerrflag = 0; 1723 yychar = YYEMPTY; 1724 yystate = 0; 1725 1726#if YYPURE 1727 memset(&yystack, 0, sizeof(yystack)); 1728#endif 1729 1730 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1731 yystack.s_mark = yystack.s_base; 1732 yystack.l_mark = yystack.l_base; 1733 yystate = 0; 1734 *yystack.s_mark = 0; 1735 1736yyloop: 1737 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 1738 if (yychar < 0) 1739 { 1740 yychar = YYLEX; 1741 if (yychar < 0) yychar = YYEOF; 1742#if YYDEBUG 1743 if (yydebug) 1744 { 1745 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1746 printf("%sdebug: state %d, reading %d (%s)\n", 1747 YYPREFIX, yystate, yychar, yys); 1748 } 1749#endif 1750 } 1751 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1752 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1753 { 1754#if YYDEBUG 1755 if (yydebug) 1756 printf("%sdebug: state %d, shifting to state %d\n", 1757 YYPREFIX, yystate, yytable[yyn]); 1758#endif 1759 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1760 yystate = yytable[yyn]; 1761 *++yystack.s_mark = yytable[yyn]; 1762 *++yystack.l_mark = yylval; 1763 yychar = YYEMPTY; 1764 if (yyerrflag > 0) --yyerrflag; 1765 goto yyloop; 1766 } 1767 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1768 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1769 { 1770 yyn = yytable[yyn]; 1771 goto yyreduce; 1772 } 1773 if (yyerrflag != 0) goto yyinrecovery; 1774 1775 YYERROR_CALL("syntax error"); 1776 1777 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1778yyerrlab: 1779 ++yynerrs; 1780 1781yyinrecovery: 1782 if (yyerrflag < 3) 1783 { 1784 yyerrflag = 3; 1785 for (;;) 1786 { 1787 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1788 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1789 { 1790#if YYDEBUG 1791 if (yydebug) 1792 printf("%sdebug: state %d, error recovery shifting\ 1793 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 1794#endif 1795 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1796 yystate = yytable[yyn]; 1797 *++yystack.s_mark = yytable[yyn]; 1798 *++yystack.l_mark = yylval; 1799 goto yyloop; 1800 } 1801 else 1802 { 1803#if YYDEBUG 1804 if (yydebug) 1805 printf("%sdebug: error recovery discarding state %d\n", 1806 YYPREFIX, *yystack.s_mark); 1807#endif 1808 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1809 --yystack.s_mark; 1810 --yystack.l_mark; 1811 } 1812 } 1813 } 1814 else 1815 { 1816 if (yychar == YYEOF) goto yyabort; 1817#if YYDEBUG 1818 if (yydebug) 1819 { 1820 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1821 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 1822 YYPREFIX, yystate, yychar, yys); 1823 } 1824#endif 1825 yychar = YYEMPTY; 1826 goto yyloop; 1827 } 1828 1829yyreduce: 1830#if YYDEBUG 1831 if (yydebug) 1832 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 1833 YYPREFIX, yystate, yyn, yyrule[yyn]); 1834#endif 1835 yym = yylen[yyn]; 1836 if (yym > 0) 1837 yyval = yystack.l_mark[1-yym]; 1838 else 1839 memset(&yyval, 0, sizeof yyval); 1840 1841 switch (yyn) 1842 { 1843case 1: 1844#line 64 "expr.oxout.y" 1845 {yyyYoxInit();} 1846break; 1847case 2: 1848#line 66 "expr.oxout.y" 1849 { 1850 yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); 1851 } 1852break; 1853case 3: 1854#line 73 "expr.oxout.y" 1855 {if(yyyYok){ 1856yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1857yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1858break; 1859case 4: 1860#line 80 "expr.oxout.y" 1861 {if(yyyYok){ 1862yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1863yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1864break; 1865case 5: 1866#line 87 "expr.oxout.y" 1867 {if(yyyYok){ 1868yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1869yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1870break; 1871case 6: 1872#line 94 "expr.oxout.y" 1873 {if(yyyYok){ 1874yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1875yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1876break; 1877case 7: 1878#line 101 "expr.oxout.y" 1879 {if(yyyYok){ 1880yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1881yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1882break; 1883case 8: 1884#line 108 "expr.oxout.y" 1885 {if(yyyYok){ 1886yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1887yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1888break; 1889case 9: 1890#line 114 "expr.oxout.y" 1891 {if(yyyYok){ 1892yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1893yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1894break; 1895case 10: 1896#line 121 "expr.oxout.y" 1897 {if(yyyYok){ 1898yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1899yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1900break; 1901#line 1902 "expr.oxout.tab.c" 1902 } 1903 yystack.s_mark -= yym; 1904 yystate = *yystack.s_mark; 1905 yystack.l_mark -= yym; 1906 yym = yylhs[yyn]; 1907 if (yystate == 0 && yym == 0) 1908 { 1909#if YYDEBUG 1910 if (yydebug) 1911 printf("%sdebug: after reduction, shifting from state 0 to\ 1912 state %d\n", YYPREFIX, YYFINAL); 1913#endif 1914 yystate = YYFINAL; 1915 *++yystack.s_mark = YYFINAL; 1916 *++yystack.l_mark = yyval; 1917 if (yychar < 0) 1918 { 1919 yychar = YYLEX; 1920 if (yychar < 0) yychar = YYEOF; 1921#if YYDEBUG 1922 if (yydebug) 1923 { 1924 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1925 printf("%sdebug: state %d, reading %d (%s)\n", 1926 YYPREFIX, YYFINAL, yychar, yys); 1927 } 1928#endif 1929 } 1930 if (yychar == YYEOF) goto yyaccept; 1931 goto yyloop; 1932 } 1933 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1934 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1935 yystate = yytable[yyn]; 1936 else 1937 yystate = yydgoto[yym]; 1938#if YYDEBUG 1939 if (yydebug) 1940 printf("%sdebug: after reduction, shifting from state %d \ 1941to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 1942#endif 1943 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1944 *++yystack.s_mark = (YYINT) yystate; 1945 *++yystack.l_mark = yyval; 1946 goto yyloop; 1947 1948yyoverflow: 1949 YYERROR_CALL("yacc stack overflow"); 1950 1951yyabort: 1952 yyfreestack(&yystack); 1953 return (1); 1954 1955yyaccept: 1956 yyfreestack(&yystack); 1957 return (0); 1958} 1959