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 2 7 #define YYMINOR 0 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 108 extern int yylex(void); 109 extern 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" 120 typedef union { 121 struct yyyOxAttrbs { 122 struct 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 130 static int yyyYok = 1; 131 132 extern yyyFT yyyRCIL[]; 133 134 void yyyExecuteRRsection(yyyGNT *rootNode); 135 void yyyYoxInit(void); 136 void yyyDecorate(void); 137 struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ 138 void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); 139 void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); 140 void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); 141 void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); 142 void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); 143 void 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 176 extern int YYPARSE_DECL(); 177 178 #define ID 257 179 #define CONST 258 180 #define YYERRCODE 256 181 typedef int YYINT; 182 static const YYINT expr_oxout_lhs[] = { -1, 183 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, 184 }; 185 static const YYINT expr_oxout_len[] = { 2, 186 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, 187 }; 188 static 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 }; 192 static const YYINT expr_oxout_dgoto[] = { 1, 193 6, 2, 7, 194 }; 195 static 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 }; 199 static 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 }; 203 static const YYINT expr_oxout_gindex[] = { 0, 204 0, 0, 4, 205 }; 206 #define YYTABLESIZE 218 207 static 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 }; 231 static 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 263 static 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, 266 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,"ID", 272 "CONST",0,0,0,0,0,"illegal-symbol", 273 }; 274 static 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 290 #if YYDEBUG 291 int yydebug; 292 #endif 293 294 int yyerrflag; 295 int yychar; 296 YYSTYPE yyval; 297 YYSTYPE yylval; 298 int yynerrs; 299 300 /* define the initial stack-sizes */ 301 #ifdef YYSTACKSIZE 302 #undef YYMAXDEPTH 303 #define YYMAXDEPTH YYSTACKSIZE 304 #else 305 #ifdef YYMAXDEPTH 306 #define YYSTACKSIZE YYMAXDEPTH 307 #else 308 #define YYSTACKSIZE 10000 309 #define YYMAXDEPTH 10000 310 #endif 311 #endif 312 313 #define YYINITSTACKSIZE 200 314 315 typedef struct { 316 unsigned stacksize; 317 YYINT *s_base; 318 YYINT *s_mark; 319 YYINT *s_last; 320 YYSTYPE *l_base; 321 YYSTYPE *l_mark; 322 } YYSTACKDATA; 323 /* variables for the parser stack */ 324 static YYSTACKDATA yystack; 325 #line 53 "expr.Y" 326 327 328 int yyparse(void); 329 330 int main() 331 {yyparse(); 332 } 333 334 335 336 #line 138 "expr.oxout.y" 337 long yyySSALspaceSize = 20000; 338 long yyyRSmaxSize = 1000; 339 long yyyTravStackMaxSize = 2000; 340 341 struct yyySolvedSAlistCell {yyyWAT attrbNum; 342 long next; 343 }; 344 345 #define yyyLambdaSSAL 0 346 long yyySSALCfreeList = yyyLambdaSSAL; 347 long yyyNewSSALC = 1; 348 349 struct yyySolvedSAlistCell *yyySSALspace; 350 351 long yyyNbytesStackStg; 352 353 354 355 yyyFT yyyRCIL[1]; 356 357 short yyyIIIEL[] = {0, 358 0,2,6,10,14,18,22,24, 359 }; 360 361 long yyyIIEL[] = { 362 0,0,0,0,0,0,0,0,0,0,0,0, 363 0,0,0,0,0,0,0,0,0,0,0,0, 364 1,1, 365 }; 366 367 long yyyIEL[] = { 368 0,0,0, 369 }; 370 371 yyyFT yyyEntL[1]; 372 373 void yyyfatal(char *msg) 374 {fputs(msg,stderr);exit(-1);} 375 376 377 378 #define yyySSALof 'S' 379 #define yyyRSof 'q' 380 #define yyyTSof 't' 381 382 383 384 void yyyHandleOverflow(char which) 385 {char *msg1 = "?", *msg2; 386 long oldSize = 0, newSize; 387 switch(which) 388 { 389 case yyySSALof : 390 msg1 = "SSAL overflow: "; 391 oldSize = yyySSALspaceSize; 392 break; 393 case yyyRSof : 394 msg1 = "ready set overflow: "; 395 oldSize = yyyRSmaxSize; 396 break; 397 case yyyTSof : 398 msg1 = "traversal stack overflow: "; 399 oldSize = yyyTravStackMaxSize; 400 break; 401 default :; 402 } 403 newSize = (3*oldSize)/2; 404 if (newSize < 100) newSize = 100; 405 fputs(msg1,stderr); 406 fprintf(stderr,"size was %ld.\n",oldSize); 407 msg2 = " Have to modify evaluator: -Y%c%ld.\n"; 408 fprintf(stderr,msg2,which,newSize); 409 exit(-1); 410 } 411 412 413 414 void yyySignalEnts(yyyGNT *node,long startP,long stopP) 415 {yyyGNT *dumNode; 416 417 while (startP < stopP) 418 { 419 if (!yyyEntL[startP]) dumNode = node; 420 else dumNode = (node->cL)[yyyEntL[startP]-1]; 421 if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] 422 ) 423 ) 424 ) 425 { 426 if (++yyyRSTop == yyyAfterRS) 427 {yyyHandleOverflow(yyyRSof); 428 break; 429 } 430 yyyRSTop->node = dumNode; 431 yyyRSTop->whichSym = yyyEntL[startP]; 432 yyyRSTop->wa = yyyEntL[startP+1]; 433 } 434 startP += 2; 435 } 436 } 437 438 439 440 441 442 443 void yyySolveAndSignal() { 444 long yyyiDum,*yyypL; 445 int yyyws,yyywa; 446 yyyGNT *yyyRSTopN,*yyyRefN; 447 yyyParent yyyRSTopNp; 448 449 450 yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; 451 yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; 452 yyywa = yyyRSTop->wa; 453 yyyRSTop--; 454 switch(yyyRefN->prodNum) { 455 case 1: /***yacc rule 1***/ 456 switch (yyyws) { 457 } 458 break; 459 case 2: /***yacc rule 2***/ 460 switch (yyyws) { 461 } 462 break; 463 case 3: /***yacc rule 3***/ 464 switch (yyyws) { 465 } 466 break; 467 case 4: /***yacc rule 4***/ 468 switch (yyyws) { 469 } 470 break; 471 case 5: /***yacc rule 5***/ 472 switch (yyyws) { 473 } 474 break; 475 case 6: /***yacc rule 6***/ 476 switch (yyyws) { 477 } 478 break; 479 case 7: /***yacc rule 7***/ 480 switch (yyyws) { 481 case 1: /**/ 482 switch (yyywa) { 483 } 484 break; 485 } 486 break; 487 case 8: /***yacc rule 8***/ 488 switch (yyyws) { 489 case 1: /**/ 490 switch (yyywa) { 491 } 492 break; 493 } 494 break; 495 } /* switch */ 496 497 if (yyyws) /* the just-solved instance was inherited. */ 498 {if (yyyRSTopN->prodNum) 499 {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; 500 yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], 501 yyyIEL[yyyiDum+1] 502 ); 503 } 504 } 505 else /* the just-solved instance was synthesized. */ 506 {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ 507 {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + 508 yyyRSTopN->whichSym 509 ] + 510 yyywa; 511 yyySignalEnts(yyyRSTopNp.noderef, 512 yyyIEL[yyyiDum], 513 yyyIEL[yyyiDum+1] 514 ); 515 } 516 else /* node is still on the stack--it has no parent yet. */ 517 {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); 518 if (yyySSALCfreeList == yyyLambdaSSAL) 519 {yyySSALspace[yyyNewSSALC].next = *yyypL; 520 if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) 521 yyyHandleOverflow(yyySSALof); 522 } 523 else 524 {yyyiDum = yyySSALCfreeList; 525 yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; 526 yyySSALspace[yyyiDum].next = *yyypL; 527 *yyypL = yyyiDum; 528 } 529 yyySSALspace[*yyypL].attrbNum = yyywa; 530 } 531 } 532 533 } /* yyySolveAndSignal */ 534 535 536 537 538 539 540 #define condStg unsigned int conds; 541 #define yyyClearConds {yyyTST->conds = 0;} 542 #define yyySetCond(n) {yyyTST->conds += (1<<(n));} 543 #define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) 544 545 546 547 struct yyyTravStackItem {yyyGNT *node; 548 char isReady; 549 condStg 550 }; 551 552 553 554 void yyyDoTraversals(yyyGNT *rootNode) 555 {struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; 556 yyyGNT *yyyTSTn,**yyyCLptr2; 557 int yyyi,yyyRL,yyyPass; 558 int i; 559 560 if (!yyyYok) return; 561 if ((yyyTravStack = 562 ((struct yyyTravStackItem *) 563 calloc((size_t)yyyTravStackMaxSize, 564 (size_t)sizeof(struct yyyTravStackItem) 565 ) 566 ) 567 ) 568 == 569 (struct yyyTravStackItem *)NULL 570 ) 571 {fputs("malloc error in traversal stack allocation\n",stderr); 572 exit(-1); 573 } 574 575 yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; 576 yyyTravStack++; 577 578 579 for (yyyi=0; yyyi<2; yyyi++) { 580 yyyTST = yyyTravStack; 581 yyyTST->node = rootNode; 582 yyyTST->isReady = 0; 583 yyyClearConds 584 585 while(yyyTST >= yyyTravStack) 586 {yyyTSTn = yyyTST->node; 587 if (yyyTST->isReady) 588 {yyyPass = 1; 589 goto yyyTravSwitch; 590 yyyTpop: 591 yyyTST--; 592 } 593 else 594 {yyyPass = 0; 595 goto yyyTravSwitch; 596 yyyTpush: 597 yyyTST->isReady = 1; 598 if (yyyTSTn->prodNum) 599 {if (yyyRL) 600 {yyyCLptr2 = yyyTSTn->cL; 601 i = yyyTSTn->cLlen; 602 while (i--) 603 {if (++yyyTST == yyyAfterTravStack) 604 yyyHandleOverflow(yyyTSof); 605 else 606 {yyyTST->node = *yyyCLptr2; 607 yyyTST->isReady = 0; 608 yyyClearConds 609 } 610 yyyCLptr2++; 611 } 612 } /* right to left */ 613 else /* left to right */ 614 {i = yyyTSTn->cLlen; 615 yyyCLptr2 = yyyTSTn->cL + i; 616 while (i--) 617 {yyyCLptr2--; 618 if (++yyyTST == yyyAfterTravStack) 619 yyyHandleOverflow(yyyTSof); 620 else 621 {yyyTST->node = *yyyCLptr2; 622 yyyTST->isReady = 0; 623 yyyClearConds 624 } 625 } 626 } /* left to right */ 627 } 628 } /* else */ 629 continue; 630 yyyTravSwitch: 631 switch(yyyTSTn->prodNum) { 632 case 1: 633 switch(yyyi) { 634 case 0: 635 switch(yyyPass) { 636 case 0: 637 yyyRL = 0;yyySetCond(0) 638 639 if (! 640 #line 24 "expr.Y" 641 (1) 642 #line 444 "expr.oxout.y" 643 ) yyySetCond(1) 644 yyySetCond(2) 645 646 case 1: 647 648 if (yyyCond(0) != yyyPass) { 649 #line 24 "expr.Y" 650 651 #line 453 "expr.oxout.y" 652 } 653 if (yyyCond(1) != yyyPass) { 654 #line 24 "expr.Y" 655 printf("\n"); 656 657 #line 459 "expr.oxout.y" 658 } 659 if (yyyCond(2) != yyyPass) { 660 #line 25 "expr.Y" 661 printf("prefix: "); 662 663 #line 465 "expr.oxout.y" 664 } 665 break; 666 } 667 break; 668 case 1: 669 switch(yyyPass) { 670 case 0: 671 yyyRL = 0; 672 if ( 673 #line 23 "expr.Y" 674 (1) 675 #line 477 "expr.oxout.y" 676 ) yyySetCond(2) 677 678 case 1: 679 680 if (yyyCond(0) != yyyPass) { 681 #line 22 "expr.Y" 682 printf("\n"); 683 684 #line 486 "expr.oxout.y" 685 } 686 if (yyyCond(1) != yyyPass) { 687 #line 23 "expr.Y" 688 689 #line 491 "expr.oxout.y" 690 } 691 if (yyyCond(2) != yyyPass) { 692 #line 23 "expr.Y" 693 printf("postfix: "); 694 695 #line 497 "expr.oxout.y" 696 } 697 break; 698 } 699 break; 700 } 701 702 break; 703 case 2: 704 switch(yyyi) { 705 case 0: 706 switch(yyyPass) { 707 case 0: 708 yyyRL = 0;yyySetCond(0) 709 710 case 1: 711 712 if (yyyCond(0) != yyyPass) { 713 #line 29 "expr.Y" 714 printf(" * "); 715 716 #line 518 "expr.oxout.y" 717 } 718 break; 719 } 720 break; 721 case 1: 722 switch(yyyPass) { 723 case 0: 724 yyyRL = 0; 725 case 1: 726 727 if (yyyCond(0) != yyyPass) { 728 #line 28 "expr.Y" 729 printf(" * "); 730 731 #line 533 "expr.oxout.y" 732 } 733 break; 734 } 735 break; 736 } 737 738 break; 739 case 3: 740 switch(yyyi) { 741 case 0: 742 switch(yyyPass) { 743 case 0: 744 yyyRL = 0;yyySetCond(0) 745 746 case 1: 747 748 if (yyyCond(0) != yyyPass) { 749 #line 32 "expr.Y" 750 printf(" + "); 751 752 #line 554 "expr.oxout.y" 753 } 754 break; 755 } 756 break; 757 case 1: 758 switch(yyyPass) { 759 case 0: 760 yyyRL = 0; 761 case 1: 762 763 if (yyyCond(0) != yyyPass) { 764 #line 33 "expr.Y" 765 printf(" + "); 766 767 #line 569 "expr.oxout.y" 768 } 769 break; 770 } 771 break; 772 } 773 774 break; 775 case 4: 776 switch(yyyi) { 777 case 0: 778 switch(yyyPass) { 779 case 0: 780 yyyRL = 0;yyySetCond(0) 781 782 case 1: 783 784 if (yyyCond(0) != yyyPass) { 785 #line 37 "expr.Y" 786 printf(" / "); 787 788 #line 590 "expr.oxout.y" 789 } 790 break; 791 } 792 break; 793 case 1: 794 switch(yyyPass) { 795 case 0: 796 yyyRL = 0; 797 case 1: 798 799 if (yyyCond(0) != yyyPass) { 800 #line 36 "expr.Y" 801 printf(" / "); 802 803 #line 605 "expr.oxout.y" 804 } 805 break; 806 } 807 break; 808 } 809 810 break; 811 case 5: 812 switch(yyyi) { 813 case 0: 814 switch(yyyPass) { 815 case 0: 816 yyyRL = 0;yyySetCond(0) 817 818 case 1: 819 820 if (yyyCond(0) != yyyPass) { 821 #line 41 "expr.Y" 822 printf(" - "); 823 824 #line 626 "expr.oxout.y" 825 } 826 break; 827 } 828 break; 829 case 1: 830 switch(yyyPass) { 831 case 0: 832 yyyRL = 0; 833 case 1: 834 835 if (yyyCond(0) != yyyPass) { 836 #line 40 "expr.Y" 837 printf(" - "); 838 839 #line 641 "expr.oxout.y" 840 } 841 break; 842 } 843 break; 844 } 845 846 break; 847 case 6: 848 switch(yyyi) { 849 case 0: 850 switch(yyyPass) { 851 case 0: 852 yyyRL = 0; 853 case 1: 854 855 break; 856 } 857 break; 858 case 1: 859 switch(yyyPass) { 860 case 0: 861 yyyRL = 0; 862 case 1: 863 864 break; 865 } 866 break; 867 } 868 869 break; 870 case 7: 871 switch(yyyi) { 872 case 0: 873 switch(yyyPass) { 874 case 0: 875 yyyRL = 0;yyySetCond(0) 876 877 case 1: 878 879 if (yyyCond(0) != yyyPass) { 880 #line 46 "expr.Y" 881 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 882 883 #line 685 "expr.oxout.y" 884 } 885 break; 886 } 887 break; 888 case 1: 889 switch(yyyPass) { 890 case 0: 891 yyyRL = 0; 892 case 1: 893 894 if (yyyCond(0) != yyyPass) { 895 #line 45 "expr.Y" 896 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 897 898 #line 700 "expr.oxout.y" 899 } 900 break; 901 } 902 break; 903 } 904 905 break; 906 case 8: 907 switch(yyyi) { 908 case 0: 909 switch(yyyPass) { 910 case 0: 911 yyyRL = 0;yyySetCond(0) 912 913 case 1: 914 915 if (yyyCond(0) != yyyPass) { 916 #line 50 "expr.Y" 917 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 918 919 #line 721 "expr.oxout.y" 920 } 921 break; 922 } 923 break; 924 case 1: 925 switch(yyyPass) { 926 case 0: 927 yyyRL = 0; 928 case 1: 929 930 if (yyyCond(0) != yyyPass) { 931 #line 49 "expr.Y" 932 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); 933 934 #line 736 "expr.oxout.y" 935 } 936 break; 937 } 938 break; 939 } 940 941 break; 942 } /* switch */ 943 if (yyyPass) goto yyyTpop; else goto yyyTpush; 944 } /* while */ 945 } /* for */ 946 } /* yyyDoTraversals */ 947 948 void yyyExecuteRRsection(yyyGNT *rootNode) { 949 int yyyi; 950 long cycleSum = 0; 951 long nNZrc = 0; 952 953 if (!yyyYok) return; 954 yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); 955 if (nNZrc) 956 { 957 fputs("\n\n\n**********\n",stderr); 958 fputs("cycle detected in completed parse tree",stderr); 959 fputs(" after decoration.\n",stderr); 960 #if CYCLE_VERBOSE 961 fprintf(stderr, 962 "number of unsolved attribute instances == %ld.\n", 963 nNZrc 964 ); 965 fprintf(stderr, 966 "total number of remaining dependencies == %ld.\n", 967 cycleSum 968 ); 969 fputs("average number of remaining dependencies\n",stderr); 970 fprintf(stderr," per unsolved instance == %f.\n", 971 ((float)(cycleSum)/(float)(nNZrc)) 972 ); 973 #endif 974 fprintf(stderr, 975 "searching parse tree for %ld unsolved instances:\n", 976 nNZrc 977 ); 978 yyyUnsolvedInstSearchTravAux(rootNode); 979 } 980 yyyDoTraversals(rootNode); 981 } /* yyyExecuteRRsection */ 982 983 984 985 yyyWAT yyyLRCIL[2] = {0,0, 986 }; 987 988 989 990 void yyyYoxInit(void) 991 { 992 static int yyyInitDone = 0; 993 if (yyyInitDone) return; 994 995 if ((yyyRS = (yyyRSitem *) 996 calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) 997 ) 998 == 999 ((yyyRSitem *) NULL) 1000 ) 1001 yyyfatal("malloc error in ox ready set space allocation\n"); 1002 yyyRS++; 1003 yyyAfterRS = yyyRS + yyyRSmaxSize; 1004 1005 1006 if ((yyySSALspace = (struct yyySolvedSAlistCell *) 1007 calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) 1008 ) 1009 == 1010 ((struct yyySolvedSAlistCell *) NULL) 1011 ) 1012 yyyfatal("malloc error in stack solved list space allocation\n"); 1013 yyyInitDone = 1; 1014 1015 yyyRSTop = yyyRS - 1; 1016 } /* yyyYoxInit */ 1017 1018 1019 1020 void yyyDecorate(void) 1021 { 1022 while (yyyRSTop >= yyyRS) 1023 yyySolveAndSignal(); 1024 } 1025 1026 1027 1028 void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) 1029 {yyyWST i; 1030 yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; 1031 yyyGNT *gnpDum; 1032 va_list ap; 1033 1034 *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); 1035 if (*yyyOxStackItem == (yyySIT *) NULL) 1036 yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); 1037 (*yyyOxStackItem)->node = 1038 (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); 1039 if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) 1040 yyyfatal("malloc error in ox node space allocation\n"); 1041 (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; 1042 (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; 1043 (*yyyOxStackItem)->node->parentIsStack = 1; 1044 (*yyyOxStackItem)->node->cLlen = yyyRHSlength; 1045 (*yyyOxStackItem)->node->cL = 1046 (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); 1047 if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) 1048 yyyfatal("malloc error in ox child list space allocation\n"); 1049 (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; 1050 (*yyyOxStackItem)->node->refCountList = 1051 (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); 1052 if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) 1053 yyyfatal("malloc error in ox reference count list space allocation\n"); 1054 (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; 1055 va_start(ap, yyval_OxAttrbs); 1056 for (i=1;i<=yyyRHSlength;i++) 1057 {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; 1058 gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; 1059 gnpDum->whichSym = i; 1060 gnpDum->parent.noderef = (*yyyOxStackItem)->node; 1061 gnpDum->parentIsStack = 0; 1062 } 1063 va_end(ap); 1064 } 1065 1066 1067 1068 #define yyyDECORfREQ 50 1069 1070 1071 1072 void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) 1073 {yyyWST i; 1074 yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; 1075 long SSALptr,SSALptrHead,*cPtrPtr; 1076 long *pL; 1077 yyyGNT *gnpDum; 1078 long iTemp; 1079 long nextP; 1080 static unsigned short intNodeCount = yyyDECORfREQ; 1081 va_list ap; 1082 1083 nextP = startP; 1084 while (nextP < stopP) 1085 {if (yyyRCIL[nextP] == yyyR) 1086 {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; 1087 } 1088 else 1089 {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; 1090 } 1091 nextP += 3; 1092 } 1093 pL = yyyIIEL + yyyIIIEL[yyyProdNum]; 1094 va_start(ap, yyval_OxAttrbs); 1095 for (i=1;i<=yyyRHSlength;i++) 1096 {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; 1097 pL++; 1098 SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); 1099 if (SSALptr != yyyLambdaSSAL) 1100 {*cPtrPtr = yyyLambdaSSAL; 1101 do 1102 { 1103 iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); 1104 yyySignalEnts(yyyOxStackItem->node, 1105 yyyIEL[iTemp], 1106 yyyIEL[iTemp+1] 1107 ); 1108 SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); 1109 } 1110 while (SSALptr != yyyLambdaSSAL); 1111 *cPtrPtr = yyySSALCfreeList; 1112 yyySSALCfreeList = SSALptrHead; 1113 } 1114 } 1115 va_end(ap); 1116 nextP = startP + 2; 1117 while (nextP < stopP) 1118 {if (!yyyRCIL[nextP]) 1119 {if (yyyRCIL[nextP-2] == yyyR) 1120 {pL = &(yyyOxStackItem->solvedSAlist); 1121 if (yyySSALCfreeList == yyyLambdaSSAL) 1122 {yyySSALspace[yyyNewSSALC].next = *pL; 1123 if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) 1124 yyyHandleOverflow(yyySSALof); 1125 } 1126 else 1127 {iTemp = yyySSALCfreeList; 1128 yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; 1129 yyySSALspace[iTemp].next = *pL; 1130 *pL = iTemp; 1131 } 1132 yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; 1133 } 1134 else 1135 {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) 1136 { 1137 iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; 1138 yyySignalEnts(gnpDum, 1139 yyyIEL[iTemp], 1140 yyyIEL[iTemp+1] 1141 ); 1142 } 1143 } 1144 } 1145 nextP += 3; 1146 } 1147 if (!--intNodeCount) 1148 {intNodeCount = yyyDECORfREQ; 1149 yyyDecorate(); 1150 } 1151 } 1152 1153 1154 1155 void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) 1156 {yyyRCT *rcPdum; 1157 yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; 1158 (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); 1159 if ((*yyyOxStackItem) == (yyySIT *) NULL) 1160 yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); 1161 (*yyyOxStackItem)->node = 1162 (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) 1163 ; 1164 if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) 1165 yyyfatal("malloc error in ox node space allocation\n"); 1166 (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; 1167 (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; 1168 (*yyyOxStackItem)->node->parentIsStack = 1; 1169 (*yyyOxStackItem)->node->cLlen = 0; 1170 (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; 1171 (*yyyOxStackItem)->node->refCountListLen = nAttrbs; 1172 rcPdum = (*yyyOxStackItem)->node->refCountList = 1173 (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); 1174 if (rcPdum == (yyyRCT *) NULL) 1175 yyyfatal("malloc error in ox reference count list space allocation\n"); 1176 while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; 1177 (*yyyOxStackItem)->node->prodNum = 0; 1178 (*yyyOxStackItem)->node->whichSym = 0; 1179 } 1180 1181 1182 1183 void yyyabort(void) 1184 {yyyYok = 0; 1185 } 1186 1187 1188 1189 1190 1191 #define yyyLastProdNum 8 1192 1193 1194 #define yyyNsorts 1 1195 1196 1197 int yyyProdsInd[] = { 1198 0, 1199 0, 2, 6, 10, 14, 18, 22, 24, 1200 26, 1201 }; 1202 1203 1204 int yyyProds[][2] = { 1205 { 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, 1206 { 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, 1207 { 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, 1208 { 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, 1209 { 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, 1210 { 567, 1}, 1211 }; 1212 1213 1214 int yyySortsInd[] = { 1215 0, 1216 0, 1217 1, 1218 }; 1219 1220 1221 int yyySorts[] = { 1222 413, 1223 }; 1224 1225 1226 1227 char *yyyStringTab[] = { 1228 0,0,0,0,0, 1229 0,0,0,0,0, 1230 0,0,0,0,0, 1231 0,0,0,0,0, 1232 0,0,0,0,0, 1233 0,0,0,0,0, 1234 0,0,0,0,0, 1235 0,0,0,0,0, 1236 0,0,0,0,0, 1237 0,0,0,0,0, 1238 0,0,0,0,0, 1239 0,0,0,0,0, 1240 0,0,0,0,0, 1241 0,0,0,0,0, 1242 0,0,0,0,0, 1243 0,0,0,0,0, 1244 0,0,0,0,0, 1245 0,0,0,0,0, 1246 0,0,0,0,0, 1247 0,0,0,0,0, 1248 0,0,0,0,0, 1249 0,0,0,0,0, 1250 0,0,0,0,0, 1251 0,"s",0,0,0, 1252 0,0,"y",0,0, 1253 0,0,0,0,0, 1254 0,0,0,0,0, 1255 0,0,0,0,0, 1256 0,0,0,0,0, 1257 0,0,0,0,0, 1258 0,0,0,0,0, 1259 0,0,0,0,0, 1260 0,0,0,0,0, 1261 0,0,0,0,0, 1262 0,0,0,0,0, 1263 0,0,0,0,0, 1264 0,0,0,0,0, 1265 0,0,0,0,0, 1266 0,0,0,0,0, 1267 0,0,0,0,0, 1268 0,0,0,0,0, 1269 0,0,0,0,0, 1270 0,0,0,0,0, 1271 0,0,0,0,0, 1272 0,0,0,0,0, 1273 0,0,0,0,0, 1274 0,0,0,0,0, 1275 0,0,0,0,0, 1276 0,0,0,0,0, 1277 0,0,0,0,0, 1278 0,0,0,0,0, 1279 0,0,0,0,0, 1280 0,0,0,0,0, 1281 0,0,0,0,0, 1282 0,0,0,0,0, 1283 0,0,0,0,0, 1284 0,0,0,0,0, 1285 0,0,0,0,0, 1286 0,0,0,0,0, 1287 0,0,0,0,0, 1288 0,0,0,0,0, 1289 0,0,0,0,0, 1290 0,0,0,0,0, 1291 0,0,0,0,0, 1292 0,0,0,0,0, 1293 0,"LRpre",0,0,0, 1294 0,0,0,0,0, 1295 0,0,0,0,0, 1296 0,0,0,0,0, 1297 0,0,0,0,0, 1298 0,0,0,0,0, 1299 0,0,0,0,0, 1300 0,0,0,0,0, 1301 0,0,0,0,0, 1302 0,0,0,0,0, 1303 0,0,0,0,0, 1304 0,0,0,0,0, 1305 0,0,0,0,0, 1306 0,0,0,0,0, 1307 0,"'('",0,0,0, 1308 0,0,0,0,"')'", 1309 0,0,0,0,0, 1310 0,0,"'*'","lexeme",0, 1311 0,0,0,0,0, 1312 "'+'",0,0,0,0, 1313 0,0,0,0,0, 1314 0,0,0,0,0, 1315 0,"'-'",0,0,0, 1316 0,0,0,0,0, 1317 0,0,0,0,0, 1318 0,0,"'/'",0,0, 1319 0,0,0,0,0, 1320 0,0,"expr",0,0, 1321 0,0,0,0,0, 1322 0,0,0,0,0, 1323 0,"printf",0,0,0, 1324 0,0,0,0,0, 1325 0,0,0,0,0, 1326 0,0,0,0,0, 1327 0,0,0,0,0, 1328 0,0,0,0,0, 1329 0,0,0,0,0, 1330 0,0,0,0,0, 1331 0,0,0,0,0, 1332 0,0,0,0,0, 1333 0,0,0,0,0, 1334 0,0,0,0,0, 1335 0,0,0,0,0, 1336 0,0,0,0,0, 1337 0,0,0,0,0, 1338 0,0,0,0,0, 1339 0,0,0,0,0, 1340 0,0,0,0,0, 1341 0,0,"CONST","LRpost",0, 1342 0,0,0,0,0, 1343 0,0,0,0,0, 1344 0,0,0,0,0, 1345 0,0,0,0,0, 1346 0,0,0,0,0, 1347 0,0,0,0,0, 1348 0,0,0,0,0, 1349 0,0,0,0,0, 1350 0,0,0,0,0, 1351 0,0,0,0,"ID", 1352 0,0,0,0,0, 1353 0,0,0,0,0, 1354 0,0,0,0,0, 1355 0,0,0,0,0, 1356 0,0,0,0,0, 1357 0,0,0,0,0, 1358 0,0,0,0,0, 1359 0,0,0,0,0, 1360 0,0,0,0,0, 1361 0,0,0,0,0, 1362 0,0,0,0,0, 1363 0,0,0,0,0, 1364 0,0,0,0,0, 1365 0,0,0,0,0, 1366 0,0,0,0,0, 1367 0,0,0,0,0, 1368 0,0,0,0,0, 1369 0,0,0,0,0, 1370 0,0,0,0,0, 1371 0,0,0,0,0, 1372 0,0,0,0,0, 1373 0,0,0,0,0, 1374 0,0,0,0,0, 1375 0,0,0,0,0, 1376 0,0,0,0,0, 1377 0,0,0,0,0, 1378 0,0,0,0,0, 1379 0,0,0,0,0, 1380 0,0,0,0,0, 1381 0,0,0,0,0, 1382 0,0,0,0,0, 1383 0,0,0,0,0, 1384 0,0,0,0,0, 1385 0,0,0,0,0, 1386 0,0,0,0,0, 1387 0,0,0,0,0, 1388 0,0,0,0,0, 1389 0,0,0,0,0, 1390 0,0,0,0,0, 1391 0,0,0,0,0, 1392 0,0,0,0,0, 1393 0,0,0,0,0, 1394 0,0,0,0,0, 1395 0,0,0,0,0, 1396 0,0,0,0,0, 1397 0,0,0,0,0, 1398 0,0,0,0,0, 1399 0,0,0,0,0, 1400 0,0,0,0,0, 1401 0,0,0,0,0, 1402 0,0,0,0,0, 1403 0,0,0,0,0, 1404 0,0,0,0,0, 1405 0,0,0,0,0, 1406 0,0,0,0,0, 1407 0,0,0,0,0, 1408 0,0,0,0,0, 1409 0,0,0,0,0, 1410 0,0,0,0,0, 1411 0,0,0,0,0, 1412 0,0,0,0,0, 1413 0,0,0,0,0, 1414 0,0,0,0,0, 1415 0,0,0,0,0, 1416 0,0,0,0,0, 1417 0,0,0,0,0, 1418 0,0,0,0,0, 1419 0,0,0,0,0, 1420 0,0,0,0,0, 1421 0,0,0,0,0, 1422 0,0,0,0,0, 1423 0,0,0,0,0, 1424 0,0,0,0,0, 1425 0,0,0,0,0, 1426 0,0,0,0,0, 1427 0,0,0,0,0, 1428 0,0,0,0,0, 1429 0,0,0,0,0, 1430 0,0,0,0,0, 1431 0,0,0,0,0, 1432 0,0,0,0,0, 1433 0,0,0,0,0, 1434 0,0,0,0,0, 1435 0,0,0,0,0, 1436 0,0,0,0,0, 1437 0,0,0,0,0, 1438 0,0,0,0,0, 1439 0,0,0,0,0, 1440 0,0,0,0,0, 1441 0,0,0,0,0, 1442 0,0,0,0,0, 1443 0,0,0,0,0, 1444 0,0,0,0,0, 1445 0,0,0,0,0, 1446 0,0,0,0,0, 1447 0,0,0,0,0, 1448 0,0,0,0,0, 1449 0,0,0,0,0, 1450 0,0,0,0,0, 1451 0,0,0,0,0, 1452 0,0,0,0,0, 1453 0,0,0,0,0, 1454 0,0,0,0,0, 1455 0,0,0,0,0, 1456 0,0,0,0,0, 1457 0,0,0,0,0, 1458 0,0,0,0,0, 1459 0,0,0,0,0, 1460 0,0,0,0,0, 1461 0,0,0,0,0, 1462 0,0,0,0,0, 1463 0,0,0,0,0, 1464 0,0,0,0,0, 1465 0,0,0,0,0, 1466 0,0,0,0,0, 1467 0,0,0,0,0, 1468 0,0,0,0,0, 1469 0,0,0,0,0, 1470 0,0,0,0,0, 1471 0,0,0,0,0, 1472 0,0,0,0,0, 1473 0,0,0,0,0, 1474 0, 1475 }; 1476 1477 1478 1479 #define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) 1480 1481 #define yyyGSoccurStr(prodNum,symPos) \ 1482 (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) 1483 1484 #define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) 1485 1486 #define yyySortOf(prodNum,symPos) \ 1487 (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) 1488 1489 #define yyyAttrbStr(prodNum,symPos,attrbNum) \ 1490 (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ 1491 (attrbNum) \ 1492 ] \ 1493 ] \ 1494 ) 1495 1496 1497 1498 void yyyShowProd(int i) 1499 {int j,nSyms; 1500 1501 nSyms = yyySizeofProd(i); 1502 for (j=0; j<nSyms; j++) 1503 { 1504 fprintf(stderr,"%s",yyyGSoccurStr(i,j)); 1505 if (j == 0) fputs(" : ",stderr); else putc(' ',stderr); 1506 } 1507 fputs(";\n",stderr); 1508 } 1509 1510 1511 1512 void yyyShowProds() 1513 {int i; for (i=1; i<=yyyLastProdNum; i++) yyyShowProd(i);} 1514 1515 1516 1517 void yyyShowSymsAndSorts() 1518 {int i; 1519 1520 for (i=1; i<=yyyLastProdNum; i++) 1521 {int j, nSyms; 1522 1523 fprintf(stderr, 1524 "\n\n\n---------------------------------- %3.1d\n",i); 1525 /* yyyShowProd(i); */ 1526 nSyms = yyySizeofProd(i); 1527 for (j=0; j<nSyms; j++) 1528 {int k, sortSize; 1529 1530 fprintf(stderr,"%s\n",yyyGSoccurStr(i,j)); 1531 sortSize = yyySizeofSort(yyySortOf(i,j)); 1532 for (k=0; k<sortSize; k++) 1533 fprintf(stderr," %s\n",yyyAttrbStr(i,j,k)); 1534 if (j == 0) fputs("->\n",stderr); 1535 else 1536 putc('\n',stderr); 1537 } 1538 } 1539 } 1540 1541 1542 1543 void yyyCheckNodeInstancesSolved(yyyGNT *np) 1544 {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; 1545 int nUnsolvedInsts = 0; 1546 1547 if (np->prodNum != 0) 1548 {inTerminalNode = 0; 1549 prodNum = np->prodNum; 1550 symPos = 0; 1551 } 1552 else 1553 {inTerminalNode = 1; 1554 prodNum = np->parent.noderef->prodNum; 1555 symPos = np->whichSym; 1556 } 1557 mysort = yyySortOf(prodNum,symPos); 1558 sortSize = yyySizeofSort(mysort); 1559 for (i=0; i<sortSize; i++) 1560 if ((np->refCountList)[i] != 0) nUnsolvedInsts += 1; 1561 if (nUnsolvedInsts) 1562 {fprintf(stderr, 1563 "\nFound node that has %d unsolved attribute instance(s).\n", 1564 nUnsolvedInsts 1565 ); 1566 fprintf(stderr,"Node is labeled \"%s\".\n", 1567 yyyGSoccurStr(prodNum,symPos)); 1568 if (inTerminalNode) 1569 {fputs("Node is terminal. Its parent production is:\n ",stderr); 1570 yyyShowProd(prodNum); 1571 } 1572 else 1573 {fputs("Node is nonterminal. ",stderr); 1574 if (!(np->parentIsStack)) 1575 {fprintf(stderr, 1576 "Node is %dth child in its parent production:\n ", 1577 np->whichSym 1578 ); 1579 yyyShowProd(np->parent.noderef->prodNum); 1580 } 1581 fputs("Node is on left hand side of this production:\n ",stderr); 1582 yyyShowProd(np->prodNum); 1583 } 1584 fputs("The following instances are unsolved:\n",stderr); 1585 for (i=0; i<sortSize; i++) 1586 if ((np->refCountList)[i] != 0) 1587 fprintf(stderr," %-16s still has %1d dependencies.\n", 1588 yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); 1589 } 1590 } 1591 1592 1593 1594 void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) 1595 {yyyGNT **yyyCLpdum; 1596 yyyRCT *rcp; 1597 int i; 1598 1599 /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ 1600 rcp = pNode->refCountList; 1601 i = pNode->refCountListLen; 1602 while (i--) 1603 if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} 1604 yyyCLpdum = pNode->cL; 1605 i = pNode->cLlen; 1606 while (i--) 1607 { 1608 yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); 1609 yyyCLpdum++; 1610 } 1611 } 1612 1613 1614 1615 void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) 1616 {yyyGNT **yyyCLpdum; 1617 int i; 1618 1619 yyyCheckNodeInstancesSolved(pNode); 1620 yyyCLpdum = pNode->cL; 1621 i = pNode->cLlen; 1622 while (i--) 1623 { 1624 yyyUnsolvedInstSearchTravAux(*yyyCLpdum); 1625 yyyCLpdum++; 1626 } 1627 } 1628 1629 1630 1631 void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) 1632 {yyyGNT **yyyCLpdum; 1633 int i; 1634 1635 yyyCLpdum = pNode->cL; 1636 i = pNode->cLlen; 1637 while (i--) 1638 { 1639 yyyUnsolvedInstSearchTravAux(*yyyCLpdum); 1640 yyyCLpdum++; 1641 } 1642 } 1643 1644 1645 1646 #line 1647 "expr.oxout.tab.c" 1647 1648 #if YYDEBUG 1649 #include <stdio.h> /* needed for printf */ 1650 #endif 1651 1652 #include <stdlib.h> /* needed for malloc, etc */ 1653 #include <string.h> /* needed for memset */ 1654 1655 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 1656 static int yygrowstack(YYSTACKDATA *data) 1657 { 1658 int i; 1659 unsigned newsize; 1660 YYINT *newss; 1661 YYSTYPE *newvs; 1662 1663 if ((newsize = data->stacksize) == 0) 1664 newsize = YYINITSTACKSIZE; 1665 else if (newsize >= YYMAXDEPTH) 1666 return YYENOMEM; 1667 else if ((newsize *= 2) > YYMAXDEPTH) 1668 newsize = YYMAXDEPTH; 1669 1670 i = (int) (data->s_mark - data->s_base); 1671 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 1672 if (newss == NULL) 1673 return YYENOMEM; 1674 1675 data->s_base = newss; 1676 data->s_mark = newss + i; 1677 1678 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 1679 if (newvs == NULL) 1680 return YYENOMEM; 1681 1682 data->l_base = newvs; 1683 data->l_mark = newvs + i; 1684 1685 data->stacksize = newsize; 1686 data->s_last = data->s_base + newsize - 1; 1687 return 0; 1688 } 1689 1690 #if YYPURE || defined(YY_NO_LEAKS) 1691 static void yyfreestack(YYSTACKDATA *data) 1692 { 1693 free(data->s_base); 1694 free(data->l_base); 1695 memset(data, 0, sizeof(*data)); 1696 } 1697 #else 1698 #define yyfreestack(data) /* nothing */ 1699 #endif 1700 1701 #define YYABORT goto yyabort 1702 #define YYREJECT goto yyabort 1703 #define YYACCEPT goto yyaccept 1704 #define YYERROR goto yyerrlab 1705 1706 int 1707 YYPARSE_DECL() 1708 { 1709 int yym, yyn, yystate; 1710 #if YYDEBUG 1711 const char *yys; 1712 1713 if ((yys = getenv("YYDEBUG")) != NULL) 1714 { 1715 yyn = *yys; 1716 if (yyn >= '0' && yyn <= '9') 1717 yydebug = yyn - '0'; 1718 } 1719 #endif 1720 1721 /* yym is set below */ 1722 /* yyn is set below */ 1723 yynerrs = 0; 1724 yyerrflag = 0; 1725 yychar = YYEMPTY; 1726 yystate = 0; 1727 1728 #if YYPURE 1729 memset(&yystack, 0, sizeof(yystack)); 1730 #endif 1731 1732 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1733 yystack.s_mark = yystack.s_base; 1734 yystack.l_mark = yystack.l_base; 1735 yystate = 0; 1736 *yystack.s_mark = 0; 1737 1738 yyloop: 1739 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 1740 if (yychar < 0) 1741 { 1742 yychar = YYLEX; 1743 if (yychar < 0) yychar = YYEOF; 1744 #if YYDEBUG 1745 if (yydebug) 1746 { 1747 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1748 printf("%sdebug: state %d, reading %d (%s)\n", 1749 YYPREFIX, yystate, yychar, yys); 1750 } 1751 #endif 1752 } 1753 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1754 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1755 { 1756 #if YYDEBUG 1757 if (yydebug) 1758 printf("%sdebug: state %d, shifting to state %d\n", 1759 YYPREFIX, yystate, yytable[yyn]); 1760 #endif 1761 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1762 yystate = yytable[yyn]; 1763 *++yystack.s_mark = yytable[yyn]; 1764 *++yystack.l_mark = yylval; 1765 yychar = YYEMPTY; 1766 if (yyerrflag > 0) --yyerrflag; 1767 goto yyloop; 1768 } 1769 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1770 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1771 { 1772 yyn = yytable[yyn]; 1773 goto yyreduce; 1774 } 1775 if (yyerrflag != 0) goto yyinrecovery; 1776 1777 YYERROR_CALL("syntax error"); 1778 1779 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1780 yyerrlab: 1781 ++yynerrs; 1782 1783 yyinrecovery: 1784 if (yyerrflag < 3) 1785 { 1786 yyerrflag = 3; 1787 for (;;) 1788 { 1789 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1790 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1791 { 1792 #if YYDEBUG 1793 if (yydebug) 1794 printf("%sdebug: state %d, error recovery shifting\ 1795 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 1796 #endif 1797 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1798 yystate = yytable[yyn]; 1799 *++yystack.s_mark = yytable[yyn]; 1800 *++yystack.l_mark = yylval; 1801 goto yyloop; 1802 } 1803 else 1804 { 1805 #if YYDEBUG 1806 if (yydebug) 1807 printf("%sdebug: error recovery discarding state %d\n", 1808 YYPREFIX, *yystack.s_mark); 1809 #endif 1810 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1811 --yystack.s_mark; 1812 --yystack.l_mark; 1813 } 1814 } 1815 } 1816 else 1817 { 1818 if (yychar == YYEOF) goto yyabort; 1819 #if YYDEBUG 1820 if (yydebug) 1821 { 1822 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1823 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 1824 YYPREFIX, yystate, yychar, yys); 1825 } 1826 #endif 1827 yychar = YYEMPTY; 1828 goto yyloop; 1829 } 1830 1831 yyreduce: 1832 #if YYDEBUG 1833 if (yydebug) 1834 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 1835 YYPREFIX, yystate, yyn, yyrule[yyn]); 1836 #endif 1837 yym = yylen[yyn]; 1838 if (yym > 0) 1839 yyval = yystack.l_mark[1-yym]; 1840 else 1841 memset(&yyval, 0, sizeof yyval); 1842 1843 switch (yyn) 1844 { 1845 case 1: 1846 #line 64 "expr.oxout.y" 1847 {yyyYoxInit();} 1848 #line 1849 "expr.oxout.tab.c" 1849 break; 1850 case 2: 1851 #line 66 "expr.oxout.y" 1852 { 1853 yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); 1854 } 1855 #line 1856 "expr.oxout.tab.c" 1856 break; 1857 case 3: 1858 #line 73 "expr.oxout.y" 1859 {if(yyyYok){ 1860 yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1861 yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1862 #line 1863 "expr.oxout.tab.c" 1863 break; 1864 case 4: 1865 #line 80 "expr.oxout.y" 1866 {if(yyyYok){ 1867 yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1868 yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1869 #line 1870 "expr.oxout.tab.c" 1870 break; 1871 case 5: 1872 #line 87 "expr.oxout.y" 1873 {if(yyyYok){ 1874 yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1875 yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1876 #line 1877 "expr.oxout.tab.c" 1877 break; 1878 case 6: 1879 #line 94 "expr.oxout.y" 1880 {if(yyyYok){ 1881 yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1882 yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1883 #line 1884 "expr.oxout.tab.c" 1884 break; 1885 case 7: 1886 #line 101 "expr.oxout.y" 1887 {if(yyyYok){ 1888 yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1889 yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1890 #line 1891 "expr.oxout.tab.c" 1891 break; 1892 case 8: 1893 #line 108 "expr.oxout.y" 1894 {if(yyyYok){ 1895 yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1896 yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1897 #line 1898 "expr.oxout.tab.c" 1898 break; 1899 case 9: 1900 #line 114 "expr.oxout.y" 1901 {if(yyyYok){ 1902 yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1903 yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1904 #line 1905 "expr.oxout.tab.c" 1905 break; 1906 case 10: 1907 #line 121 "expr.oxout.y" 1908 {if(yyyYok){ 1909 yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); 1910 yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} 1911 #line 1912 "expr.oxout.tab.c" 1912 break; 1913 #line 1914 "expr.oxout.tab.c" 1914 } 1915 yystack.s_mark -= yym; 1916 yystate = *yystack.s_mark; 1917 yystack.l_mark -= yym; 1918 yym = yylhs[yyn]; 1919 if (yystate == 0 && yym == 0) 1920 { 1921 #if YYDEBUG 1922 if (yydebug) 1923 printf("%sdebug: after reduction, shifting from state 0 to\ 1924 state %d\n", YYPREFIX, YYFINAL); 1925 #endif 1926 yystate = YYFINAL; 1927 *++yystack.s_mark = YYFINAL; 1928 *++yystack.l_mark = yyval; 1929 if (yychar < 0) 1930 { 1931 yychar = YYLEX; 1932 if (yychar < 0) yychar = YYEOF; 1933 #if YYDEBUG 1934 if (yydebug) 1935 { 1936 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1937 printf("%sdebug: state %d, reading %d (%s)\n", 1938 YYPREFIX, YYFINAL, yychar, yys); 1939 } 1940 #endif 1941 } 1942 if (yychar == YYEOF) goto yyaccept; 1943 goto yyloop; 1944 } 1945 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1946 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1947 yystate = yytable[yyn]; 1948 else 1949 yystate = yydgoto[yym]; 1950 #if YYDEBUG 1951 if (yydebug) 1952 printf("%sdebug: after reduction, shifting from state %d \ 1953 to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 1954 #endif 1955 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1956 *++yystack.s_mark = (YYINT) yystate; 1957 *++yystack.l_mark = yyval; 1958 goto yyloop; 1959 1960 yyoverflow: 1961 YYERROR_CALL("yacc stack overflow"); 1962 1963 yyabort: 1964 yyfreestack(&yystack); 1965 return (1); 1966 1967 yyaccept: 1968 yyfreestack(&yystack); 1969 return (0); 1970 } 1971