1/* output from Ox version G1.04 */
2#line 1 "expr.Y"
3#line 4 "expr.oxout.y"
4%{
5#include <stdlib.h>
6#include <string.h>
7%}
8#line 1 "expr.Y"
9/* Y-file for translation of infix expressions to prefix and postfix */
10%token ID CONST
11%start yyyAugNonterm
12%left '+' '-'
13%left '*' '/'
14%nonassoc '*'
15
16%{
17#include "expr.oxout.h"
18#include <stdio.h>
19
20extern int yylex(void);
21extern void yyerror(const char *);
22%}
23
24#line 25 "expr.oxout.y"
25
26%{
27#include <limits.h>
28#define yyyR USHRT_MAX
29%}
30%type <yyyOxAttrbs> yyyAugNonterm
31%union {
32struct yyyOxAttrbs {
33struct yyyStackItem *yyyOxStackItem;
34} yyyOxAttrbs;
35}
36
37%{
38#include <stdio.h>
39#include <stdarg.h>
40
41static int yyyYok = 1;
42
43extern yyyFT yyyRCIL[];
44
45void yyyExecuteRRsection(yyyGNT *rootNode);
46void yyyYoxInit(void);
47void yyyDecorate(void);
48struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */
49void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...);
50void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...);
51void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum);
52void yyyUnsolvedInstSearchTrav(yyyGNT *pNode);
53void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode);
54void yyyabort(void);
55
56%}
57
58
59#line 20 "expr.Y"
60%%
61
62#line 63 "expr.oxout.y"
63yyyAugNonterm
64	:	{yyyYoxInit();}
65		s
66		{
67		 yyyDecorate(); yyyExecuteRRsection($<yyyOxAttrbs>2.yyyOxStackItem->node);
68		}
69	;
70#line 21 "expr.Y"
71s       :       expr
72#line 73 "expr.oxout.y"
73{if(yyyYok){
74yyyGenIntNode(1,1,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1);
75yyyAdjustINRC(1,1,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1);}}
76
77#line 27 "expr.Y"
78expr    :       expr    '*'     expr
79#line 80 "expr.oxout.y"
80{if(yyyYok){
81yyyGenIntNode(2,3,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);
82yyyAdjustINRC(2,3,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);}}
83
84#line 31 "expr.Y"
85        |       expr    '+'     expr
86#line 87 "expr.oxout.y"
87{if(yyyYok){
88yyyGenIntNode(3,3,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);
89yyyAdjustINRC(3,3,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);}}
90
91#line 35 "expr.Y"
92        |       expr    '/'     expr
93#line 94 "expr.oxout.y"
94{if(yyyYok){
95yyyGenIntNode(4,3,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);
96yyyAdjustINRC(4,3,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);}}
97
98#line 39 "expr.Y"
99        |       expr    '-'     expr
100#line 101 "expr.oxout.y"
101{if(yyyYok){
102yyyGenIntNode(5,3,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);
103yyyAdjustINRC(5,3,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);}}
104
105#line 43 "expr.Y"
106        |       '('     expr    ')'
107#line 108 "expr.oxout.y"
108{if(yyyYok){
109yyyGenIntNode(6,3,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);
110yyyAdjustINRC(6,3,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1,&$<yyyOxAttrbs>2,&$<yyyOxAttrbs>3);}}
111#line 44 "expr.Y"
112        |       ID
113#line 114 "expr.oxout.y"
114{if(yyyYok){
115yyyGenIntNode(7,1,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1);
116yyyAdjustINRC(7,1,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1);}}
117
118#line 48 "expr.Y"
119        |       CONST
120#line 121 "expr.oxout.y"
121{if(yyyYok){
122yyyGenIntNode(8,1,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1);
123yyyAdjustINRC(8,1,0,0,&$<yyyOxAttrbs>$,&$<yyyOxAttrbs>1);}}
124
125#line 52 "expr.Y"
126        ;
127%%
128
129int yyparse(void);
130
131int main()
132  {yyparse();
133  }
134
135
136
137#line 138 "expr.oxout.y"
138long yyySSALspaceSize =    20000;
139long yyyRSmaxSize =        1000;
140long yyyTravStackMaxSize = 2000;
141
142struct yyySolvedSAlistCell {yyyWAT attrbNum;
143                            long next;
144                           };
145
146#define yyyLambdaSSAL 0
147long yyySSALCfreeList = yyyLambdaSSAL;
148long yyyNewSSALC = 1;
149
150struct yyySolvedSAlistCell *yyySSALspace;
151
152long yyyNbytesStackStg;
153
154
155
156yyyFT yyyRCIL[1];
157
158short yyyIIIEL[] = {0,
1590,2,6,10,14,18,22,24,
160};
161
162long yyyIIEL[] = {
1630,0,0,0,0,0,0,0,0,0,0,0,
1640,0,0,0,0,0,0,0,0,0,0,0,
1651,1,
166};
167
168long yyyIEL[] = {
1690,0,0,
170};
171
172yyyFT yyyEntL[1];
173
174void yyyfatal(char *msg)
175{fputs(msg,stderr);exit(-1);}
176
177
178
179#define yyySSALof 'S'
180#define yyyRSof   'q'
181#define yyyTSof   't'
182
183
184
185void yyyHandleOverflow(char which)
186  {char *msg1,*msg2;
187   long  oldSize,newSize;
188   switch(which)
189     {
190      case yyySSALof :
191           msg1 = "SSAL overflow: ";
192           oldSize = yyySSALspaceSize;
193           break;
194      case yyyRSof   :
195           msg1 = "ready set overflow: ";
196           oldSize = yyyRSmaxSize;
197           break;
198      case yyyTSof   :
199           msg1 = "traversal stack overflow: ";
200           oldSize = yyyTravStackMaxSize;
201           break;
202      default        :;
203     }
204   newSize = (3*oldSize)/2;
205   if (newSize < 100) newSize = 100;
206   fputs(msg1,stderr);
207   fprintf(stderr,"size was %ld.\n",oldSize);
208   msg2 = "     Have to modify evaluator:  -Y%c%ld.\n";
209   fprintf(stderr,msg2,which,newSize);
210   exit(-1);
211  }
212
213
214
215void yyySignalEnts(yyyGNT *node,long startP,long stopP)
216  {yyyGNT *dumNode;
217
218   while (startP < stopP)
219     {
220      if (!yyyEntL[startP]) dumNode = node;
221         else dumNode = (node->cL)[yyyEntL[startP]-1];
222      if (!(--((dumNode->refCountList)[yyyEntL[startP+1]]
223              )
224           )
225         )
226         {
227          if (++yyyRSTop == yyyAfterRS)
228             {yyyHandleOverflow(yyyRSof);
229              break;
230             }
231          yyyRSTop->node = dumNode;
232          yyyRSTop->whichSym = yyyEntL[startP];
233          yyyRSTop->wa = yyyEntL[startP+1];
234         }
235      startP += 2;
236     }
237  }
238
239
240
241
242
243
244void yyySolveAndSignal() {
245long yyyiDum,*yyypL;
246int yyyws,yyywa;
247yyyGNT *yyyRSTopN,*yyyRefN;
248yyyParent yyyRSTopNp;
249
250
251yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent;
252yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN;
253yyywa = yyyRSTop->wa;
254yyyRSTop--;
255switch(yyyRefN->prodNum) {
256case 1:  /***yacc rule 1***/
257  switch (yyyws) {
258  }
259break;
260case 2:  /***yacc rule 2***/
261  switch (yyyws) {
262  }
263break;
264case 3:  /***yacc rule 3***/
265  switch (yyyws) {
266  }
267break;
268case 4:  /***yacc rule 4***/
269  switch (yyyws) {
270  }
271break;
272case 5:  /***yacc rule 5***/
273  switch (yyyws) {
274  }
275break;
276case 6:  /***yacc rule 6***/
277  switch (yyyws) {
278  }
279break;
280case 7:  /***yacc rule 7***/
281  switch (yyyws) {
282  case 1:  /**/
283    switch (yyywa) {
284    }
285  break;
286  }
287break;
288case 8:  /***yacc rule 8***/
289  switch (yyyws) {
290  case 1:  /**/
291    switch (yyywa) {
292    }
293  break;
294  }
295break;
296} /* switch */
297
298if (yyyws)  /* the just-solved instance was inherited. */
299   {if (yyyRSTopN->prodNum)
300       {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa;
301        yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum],
302                                yyyIEL[yyyiDum+1]
303                     );
304       }
305   }
306   else     /* the just-solved instance was synthesized. */
307   {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */
308       {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] +
309                          yyyRSTopN->whichSym
310                         ] +
311                  yyywa;
312        yyySignalEnts(yyyRSTopNp.noderef,
313                      yyyIEL[yyyiDum],
314                      yyyIEL[yyyiDum+1]
315                     );
316       }
317       else   /* node is still on the stack--it has no parent yet. */
318       {yyypL = &(yyyRSTopNp.stackref->solvedSAlist);
319        if (yyySSALCfreeList == yyyLambdaSSAL)
320           {yyySSALspace[yyyNewSSALC].next = *yyypL;
321            if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize)
322               yyyHandleOverflow(yyySSALof);
323           }
324           else
325           {yyyiDum = yyySSALCfreeList;
326            yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next;
327            yyySSALspace[yyyiDum].next = *yyypL;
328            *yyypL = yyyiDum;
329           }
330        yyySSALspace[*yyypL].attrbNum = yyywa;
331       }
332   }
333
334} /* yyySolveAndSignal */
335
336
337
338
339
340
341#define condStg unsigned int conds;
342#define yyyClearConds {yyyTST->conds = 0;}
343#define yyySetCond(n) {yyyTST->conds += (1<<(n));}
344#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0)
345
346
347
348struct yyyTravStackItem {yyyGNT *node;
349                         char isReady;
350                         condStg
351                        };
352
353
354
355void yyyDoTraversals(yyyGNT *rootNode)
356{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack;
357 yyyGNT *yyyTSTn,**yyyCLptr2;
358 int yyyi,yyyRL,yyyPass;
359 int i;
360
361 if (!yyyYok) return;
362 if ((yyyTravStack =
363                 ((struct yyyTravStackItem *)
364                  calloc((size_t)yyyTravStackMaxSize,
365                         (size_t)sizeof(struct yyyTravStackItem)
366                        )
367                 )
368     )
369     ==
370     (struct yyyTravStackItem *)NULL
371    )
372    {fputs("malloc error in traversal stack allocation\n",stderr);
373     exit(-1);
374    }
375
376yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize;
377yyyTravStack++;
378
379
380for (yyyi=0; yyyi<2; yyyi++) {
381yyyTST = yyyTravStack;
382yyyTST->node = rootNode;
383yyyTST->isReady = 0;
384yyyClearConds
385
386while(yyyTST >= yyyTravStack)
387  {yyyTSTn = yyyTST->node;
388   if (yyyTST->isReady)
389      {yyyPass = 1;
390       goto yyyTravSwitch;
391yyyTpop:
392       yyyTST--;
393      }
394      else
395      {yyyPass = 0;
396       goto yyyTravSwitch;
397yyyTpush:
398       yyyTST->isReady = 1;
399       if (yyyTSTn->prodNum)
400          {if (yyyRL)
401             {yyyCLptr2 = yyyTSTn->cL;
402              i = yyyTSTn->cLlen;
403              while (i--)
404                {if (++yyyTST == yyyAfterTravStack)
405                    yyyHandleOverflow(yyyTSof);
406                    else
407                    {yyyTST->node = *yyyCLptr2;
408                     yyyTST->isReady = 0;
409                     yyyClearConds
410                    }
411                 yyyCLptr2++;
412                }
413             } /* right to left */
414             else  /* left to right */
415             {i = yyyTSTn->cLlen;
416              yyyCLptr2 = yyyTSTn->cL + i;
417              while (i--)
418                {yyyCLptr2--;
419                 if (++yyyTST == yyyAfterTravStack)
420                    yyyHandleOverflow(yyyTSof);
421                    else
422                    {yyyTST->node = *yyyCLptr2;
423                     yyyTST->isReady = 0;
424                     yyyClearConds
425                    }
426                }
427             } /* left to right */
428          }
429      } /* else */
430   continue;
431yyyTravSwitch:
432				switch(yyyTSTn->prodNum)	{
433case 1:
434	switch(yyyi)	{
435		case 0:
436			switch(yyyPass)	{
437				case 0:
438yyyRL = 0;yyySetCond(0)
439
440if (!
441#line 24 "expr.Y"
442  (1)
443#line 444 "expr.oxout.y"
444) yyySetCond(1)
445yyySetCond(2)
446
447				case 1:
448
449if (yyyCond(0) != yyyPass) {
450#line 24 "expr.Y"
451
452#line 453 "expr.oxout.y"
453}
454if (yyyCond(1) != yyyPass) {
455#line 24 "expr.Y"
456 printf("\n");
457
458#line 459 "expr.oxout.y"
459}
460if (yyyCond(2) != yyyPass) {
461#line 25 "expr.Y"
462  printf("prefix:   ");
463
464#line 465 "expr.oxout.y"
465}
466				break;
467					}
468		break;
469		case 1:
470			switch(yyyPass)	{
471				case 0:
472yyyRL = 0;
473if (
474#line 23 "expr.Y"
475  (1)
476#line 477 "expr.oxout.y"
477) yyySetCond(2)
478
479				case 1:
480
481if (yyyCond(0) != yyyPass) {
482#line 22 "expr.Y"
483 printf("\n");
484
485#line 486 "expr.oxout.y"
486}
487if (yyyCond(1) != yyyPass) {
488#line 23 "expr.Y"
489
490#line 491 "expr.oxout.y"
491}
492if (yyyCond(2) != yyyPass) {
493#line 23 "expr.Y"
494 printf("postfix:  ")/* missing ; */
495
496#line 497 "expr.oxout.y"
497}
498				break;
499					}
500		break;
501			}
502
503break;
504case 2:
505	switch(yyyi)	{
506		case 0:
507			switch(yyyPass)	{
508				case 0:
509yyyRL = 0;yyySetCond(0)
510
511				case 1:
512
513if (yyyCond(0) != yyyPass) {
514#line 29 "expr.Y"
515  printf(" * ");
516
517#line 518 "expr.oxout.y"
518}
519				break;
520					}
521		break;
522		case 1:
523			switch(yyyPass)	{
524				case 0:
525yyyRL = 0;
526				case 1:
527
528if (yyyCond(0) != yyyPass) {
529#line 28 "expr.Y"
530 printf(" * ");
531
532#line 533 "expr.oxout.y"
533}
534				break;
535					}
536		break;
537			}
538
539break;
540case 3:
541	switch(yyyi)	{
542		case 0:
543			switch(yyyPass)	{
544				case 0:
545yyyRL = 0;yyySetCond(0)
546
547				case 1:
548
549if (yyyCond(0) != yyyPass) {
550#line 32 "expr.Y"
551  printf(" + ");
552
553#line 554 "expr.oxout.y"
554}
555				break;
556					}
557		break;
558		case 1:
559			switch(yyyPass)	{
560				case 0:
561yyyRL = 0;
562				case 1:
563
564if (yyyCond(0) != yyyPass) {
565#line 33 "expr.Y"
566 printf(" + ");
567
568#line 569 "expr.oxout.y"
569}
570				break;
571					}
572		break;
573			}
574
575break;
576case 4:
577	switch(yyyi)	{
578		case 0:
579			switch(yyyPass)	{
580				case 0:
581yyyRL = 0;yyySetCond(0)
582
583				case 1:
584
585if (yyyCond(0) != yyyPass) {
586#line 37 "expr.Y"
587  printf(" / ");
588
589#line 590 "expr.oxout.y"
590}
591				break;
592					}
593		break;
594		case 1:
595			switch(yyyPass)	{
596				case 0:
597yyyRL = 0;
598				case 1:
599
600if (yyyCond(0) != yyyPass) {
601#line 36 "expr.Y"
602 printf(" / ");
603
604#line 605 "expr.oxout.y"
605}
606				break;
607					}
608		break;
609			}
610
611break;
612case 5:
613	switch(yyyi)	{
614		case 0:
615			switch(yyyPass)	{
616				case 0:
617yyyRL = 0;yyySetCond(0)
618
619				case 1:
620
621if (yyyCond(0) != yyyPass) {
622#line 41 "expr.Y"
623  printf(" - ");
624
625#line 626 "expr.oxout.y"
626}
627				break;
628					}
629		break;
630		case 1:
631			switch(yyyPass)	{
632				case 0:
633yyyRL = 0;
634				case 1:
635
636if (yyyCond(0) != yyyPass) {
637#line 40 "expr.Y"
638 printf(" - ");
639
640#line 641 "expr.oxout.y"
641}
642				break;
643					}
644		break;
645			}
646
647break;
648case 6:
649	switch(yyyi)	{
650		case 0:
651			switch(yyyPass)	{
652				case 0:
653yyyRL = 0;
654				case 1:
655
656				break;
657					}
658		break;
659		case 1:
660			switch(yyyPass)	{
661				case 0:
662yyyRL = 0;
663				case 1:
664
665				break;
666					}
667		break;
668			}
669
670break;
671case 7:
672	switch(yyyi)	{
673		case 0:
674			switch(yyyPass)	{
675				case 0:
676yyyRL = 0;yyySetCond(0)
677
678				case 1:
679
680if (yyyCond(0) != yyyPass) {
681#line 46 "expr.Y"
682  printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme);
683
684#line 685 "expr.oxout.y"
685}
686				break;
687					}
688		break;
689		case 1:
690			switch(yyyPass)	{
691				case 0:
692yyyRL = 0;
693				case 1:
694
695if (yyyCond(0) != yyyPass) {
696#line 45 "expr.Y"
697 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme);
698
699#line 700 "expr.oxout.y"
700}
701				break;
702					}
703		break;
704			}
705
706break;
707case 8:
708	switch(yyyi)	{
709		case 0:
710			switch(yyyPass)	{
711				case 0:
712yyyRL = 0;yyySetCond(0)
713
714				case 1:
715
716if (yyyCond(0) != yyyPass) {
717#line 50 "expr.Y"
718  printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme);
719
720#line 721 "expr.oxout.y"
721}
722				break;
723					}
724		break;
725		case 1:
726			switch(yyyPass)	{
727				case 0:
728yyyRL = 0;
729				case 1:
730
731if (yyyCond(0) != yyyPass) {
732#line 49 "expr.Y"
733 printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme);
734
735#line 736 "expr.oxout.y"
736}
737				break;
738					}
739		break;
740			}
741
742break;
743								} /* switch */
744   if (yyyPass) goto yyyTpop; else goto yyyTpush;
745  } /* while */
746 } /* for */
747} /* yyyDoTraversals */
748
749void yyyExecuteRRsection(yyyGNT *rootNode)  {
750   int yyyi;
751   long cycleSum = 0;
752   long nNZrc = 0;
753
754   if (!yyyYok) return;
755   yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum);
756   if (nNZrc)
757      {
758       fputs("\n\n\n**********\n",stderr);
759       fputs("cycle detected in completed parse tree",stderr);
760       fputs(" after decoration.\n",stderr);
761#if CYCLE_VERBOSE
762       fprintf(stderr,
763               "number of unsolved attribute instances == %ld.\n",
764               nNZrc
765              );
766       fprintf(stderr,
767               "total number of remaining dependencies == %ld.\n",
768               cycleSum
769              );
770       fputs("average number of remaining dependencies\n",stderr);
771       fprintf(stderr,"  per unsolved instance == %f.\n",
772               ((float)(cycleSum)/(float)(nNZrc))
773              );
774#endif
775       fprintf(stderr,
776         "searching parse tree for %ld unsolved instances:\n",
777               nNZrc
778              );
779       yyyUnsolvedInstSearchTravAux(rootNode);
780      }
781   yyyDoTraversals(rootNode);
782} /* yyyExecuteRRsection */
783
784
785
786yyyWAT yyyLRCIL[2] = {0,0,
787};
788
789
790
791void yyyYoxInit(void)
792  {
793   static int yyyInitDone = 0;
794   if (yyyInitDone) return;
795
796   if ((yyyRS = (struct yyyRSitem *)
797         calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(struct yyyRSitem))
798       )
799       ==
800       ((struct yyyRSitem *) NULL)
801      )
802      yyyfatal("malloc error in ox ready set space allocation\n");
803   yyyRS++;
804   yyyAfterRS = yyyRS + yyyRSmaxSize;
805
806
807   if ((yyySSALspace = (struct yyySolvedSAlistCell *)
808          calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell))
809       )
810       ==
811       ((struct yyySolvedSAlistCell *) NULL)
812      )
813      yyyfatal("malloc error in stack solved list space allocation\n");
814   yyyInitDone = 1;
815
816   yyyRSTop = yyyRS - 1;
817  } /* yyyYoxInit */
818
819
820
821void yyyDecorate(void)
822  {
823   while (yyyRSTop >= yyyRS)
824      yyySolveAndSignal();
825  }
826
827
828
829void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...)
830  {yyyWST i;
831   yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem;
832   yyyGNT *gnpDum;
833   va_list ap;
834
835   *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT));
836   if (*yyyOxStackItem == (yyySIT *) NULL)
837      yyyfatal("malloc error in ox yacc semantic stack space allocation\n");
838   (*yyyOxStackItem)->node =
839                                (yyyGNT *) malloc((size_t)sizeof(yyyGNT));
840   if ((*yyyOxStackItem)->node == (yyyGNT *) NULL)
841      yyyfatal("malloc error in ox node space allocation\n");
842   (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL;
843   (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem;
844   (*yyyOxStackItem)->node->parentIsStack = 1;
845   (*yyyOxStackItem)->node->cLlen  = yyyRHSlength;
846   (*yyyOxStackItem)->node->cL =
847            (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *));
848   if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL)
849      yyyfatal("malloc error in ox child list space allocation\n");
850   (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs;
851   (*yyyOxStackItem)->node->refCountList =
852            (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT));
853   if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL)
854      yyyfatal("malloc error in ox reference count list space allocation\n");
855   (*yyyOxStackItem)->node->prodNum = yyyProdNum;
856   va_start(ap, yyval_OxAttrbs);
857   for (i=1;i<=yyyRHSlength;i++)
858     {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem;
859      gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node;
860      gnpDum->whichSym = i;
861      gnpDum->parent.noderef = (*yyyOxStackItem)->node;
862      gnpDum->parentIsStack = 0;
863     }
864   va_end(ap);
865  }
866
867
868
869#define yyyDECORfREQ 50
870
871
872
873void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...)
874  {yyyWST i;
875   yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem;
876   long SSALptr,SSALptrHead,*cPtrPtr;
877   long *pL;
878   yyyGNT *gnpDum;
879   long iTemp;
880   long nextP;
881   static unsigned short intNodeCount = yyyDECORfREQ;
882   va_list ap;
883
884   nextP = startP;
885   while (nextP < stopP)
886     {if (yyyRCIL[nextP] == yyyR)
887         {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2];
888         }
889         else
890         {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2];
891         }
892      nextP += 3;
893     }
894   pL = yyyIIEL + yyyIIIEL[yyyProdNum];
895   va_start(ap, yyval_OxAttrbs);
896   for (i=1;i<=yyyRHSlength;i++)
897     {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem;
898      pL++;
899      SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist));
900      if (SSALptr != yyyLambdaSSAL)
901         {*cPtrPtr = yyyLambdaSSAL;
902          do
903            {
904             iTemp = (*pL+yyySSALspace[SSALptr].attrbNum);
905             yyySignalEnts(yyyOxStackItem->node,
906                           yyyIEL[iTemp],
907                           yyyIEL[iTemp+1]
908                          );
909             SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next));
910            }
911            while (SSALptr != yyyLambdaSSAL);
912          *cPtrPtr = yyySSALCfreeList;
913          yyySSALCfreeList = SSALptrHead;
914         }
915     }
916   va_end(ap);
917   nextP = startP + 2;
918   while (nextP < stopP)
919     {if (!yyyRCIL[nextP])
920         {if (yyyRCIL[nextP-2] == yyyR)
921             {pL = &(yyyOxStackItem->solvedSAlist);
922              if (yyySSALCfreeList == yyyLambdaSSAL)
923                 {yyySSALspace[yyyNewSSALC].next = *pL;
924                  if ((*pL = yyyNewSSALC++) == yyySSALspaceSize)
925                     yyyHandleOverflow(yyySSALof);
926                 }
927                 else
928                 {iTemp = yyySSALCfreeList;
929                  yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next;
930                  yyySSALspace[iTemp].next = *pL;
931                  *pL = iTemp;
932                 }
933              yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1];
934             }
935             else
936             {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0)
937                 {
938                  iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1];
939                  yyySignalEnts(gnpDum,
940                                yyyIEL[iTemp],
941                                yyyIEL[iTemp+1]
942                               );
943                 }
944             }
945         }
946      nextP += 3;
947     }
948   if (!--intNodeCount)
949      {intNodeCount = yyyDECORfREQ;
950       yyyDecorate();
951      }
952  }
953
954
955
956void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *yylval)
957  {yyyRCT *rcPdum;
958   yyySIT **yyyOxStackItem = &yylval->yyyOxAttrbs.yyyOxStackItem;
959   (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT));
960   if ((*yyyOxStackItem) == (yyySIT *) NULL)
961      yyyfatal("malloc error in ox yacc semantic stack space allocation\n");
962   (*yyyOxStackItem)->node =
963                          (yyyGNT *) malloc((size_t)sizeof(yyyGNT))
964                         ;
965   if ((*yyyOxStackItem)->node == (yyyGNT *) NULL)
966      yyyfatal("malloc error in ox node space allocation\n");
967   (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL;
968   (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem;
969   (*yyyOxStackItem)->node->parentIsStack = 1;
970   (*yyyOxStackItem)->node->cLlen = 0;
971   (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL;
972   (*yyyOxStackItem)->node->refCountListLen = nAttrbs;
973   rcPdum = (*yyyOxStackItem)->node->refCountList =
974            (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT));
975   if (rcPdum == (yyyRCT *) NULL)
976      yyyfatal("malloc error in ox reference count list space allocation\n");
977   while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0;
978   (*yyyOxStackItem)->node->prodNum = 0;
979   (*yyyOxStackItem)->node->whichSym = 0;
980  }
981
982
983
984void yyyabort(void)
985  {yyyYok = 0;
986  }
987
988
989
990
991
992#define yyyLastProdNum 8
993
994
995#define yyyNsorts 1
996
997
998int yyyProdsInd[] = {
999   0,
1000   0,   2,   6,  10,  14,  18,  22,  24,
1001  26,
1002};
1003
1004
1005int yyyProds[][2] = {
1006{ 116,   0},{ 462,   0},{ 462,   0},{ 462,   0},{ 412,   0},
1007{ 462,   0},{ 462,   0},{ 462,   0},{ 420,   0},{ 462,   0},
1008{ 462,   0},{ 462,   0},{ 452,   0},{ 462,   0},{ 462,   0},
1009{ 462,   0},{ 436,   0},{ 462,   0},{ 462,   0},{ 396,   0},
1010{ 462,   0},{ 404,   0},{ 462,   0},{ 619,   1},{ 462,   0},
1011{ 567,   1},
1012};
1013
1014
1015int yyySortsInd[] = {
1016  0,
1017  0,
1018  1,
1019};
1020
1021
1022int yyySorts[] = {
1023  413,
1024};
1025
1026
1027
1028char *yyyStringTab[] = {
10290,0,0,0,0,
10300,0,0,0,0,
10310,0,0,0,0,
10320,0,0,0,0,
10330,0,0,0,0,
10340,0,0,0,0,
10350,0,0,0,0,
10360,0,0,0,0,
10370,0,0,0,0,
10380,0,0,0,0,
10390,0,0,0,0,
10400,0,0,0,0,
10410,0,0,0,0,
10420,0,0,0,0,
10430,0,0,0,0,
10440,0,0,0,0,
10450,0,0,0,0,
10460,0,0,0,0,
10470,0,0,0,0,
10480,0,0,0,0,
10490,0,0,0,0,
10500,0,0,0,0,
10510,0,0,0,0,
10520,"s",0,0,0,
10530,0,"y",0,0,
10540,0,0,0,0,
10550,0,0,0,0,
10560,0,0,0,0,
10570,0,0,0,0,
10580,0,0,0,0,
10590,0,0,0,0,
10600,0,0,0,0,
10610,0,0,0,0,
10620,0,0,0,0,
10630,0,0,0,0,
10640,0,0,0,0,
10650,0,0,0,0,
10660,0,0,0,0,
10670,0,0,0,0,
10680,0,0,0,0,
10690,0,0,0,0,
10700,0,0,0,0,
10710,0,0,0,0,
10720,0,0,0,0,
10730,0,0,0,0,
10740,0,0,0,0,
10750,0,0,0,0,
10760,0,0,0,0,
10770,0,0,0,0,
10780,0,0,0,0,
10790,0,0,0,0,
10800,0,0,0,0,
10810,0,0,0,0,
10820,0,0,0,0,
10830,0,0,0,0,
10840,0,0,0,0,
10850,0,0,0,0,
10860,0,0,0,0,
10870,0,0,0,0,
10880,0,0,0,0,
10890,0,0,0,0,
10900,0,0,0,0,
10910,0,0,0,0,
10920,0,0,0,0,
10930,0,0,0,0,
10940,"LRpre",0,0,0,
10950,0,0,0,0,
10960,0,0,0,0,
10970,0,0,0,0,
10980,0,0,0,0,
10990,0,0,0,0,
11000,0,0,0,0,
11010,0,0,0,0,
11020,0,0,0,0,
11030,0,0,0,0,
11040,0,0,0,0,
11050,0,0,0,0,
11060,0,0,0,0,
11070,0,0,0,0,
11080,"'('",0,0,0,
11090,0,0,0,"')'",
11100,0,0,0,0,
11110,0,"'*'","lexeme",0,
11120,0,0,0,0,
1113"'+'",0,0,0,0,
11140,0,0,0,0,
11150,0,0,0,0,
11160,"'-'",0,0,0,
11170,0,0,0,0,
11180,0,0,0,0,
11190,0,"'/'",0,0,
11200,0,0,0,0,
11210,0,"expr",0,0,
11220,0,0,0,0,
11230,0,0,0,0,
11240,"printf",0,0,0,
11250,0,0,0,0,
11260,0,0,0,0,
11270,0,0,0,0,
11280,0,0,0,0,
11290,0,0,0,0,
11300,0,0,0,0,
11310,0,0,0,0,
11320,0,0,0,0,
11330,0,0,0,0,
11340,0,0,0,0,
11350,0,0,0,0,
11360,0,0,0,0,
11370,0,0,0,0,
11380,0,0,0,0,
11390,0,0,0,0,
11400,0,0,0,0,
11410,0,0,0,0,
11420,0,"CONST","LRpost",0,
11430,0,0,0,0,
11440,0,0,0,0,
11450,0,0,0,0,
11460,0,0,0,0,
11470,0,0,0,0,
11480,0,0,0,0,
11490,0,0,0,0,
11500,0,0,0,0,
11510,0,0,0,0,
11520,0,0,0,"ID",
11530,0,0,0,0,
11540,0,0,0,0,
11550,0,0,0,0,
11560,0,0,0,0,
11570,0,0,0,0,
11580,0,0,0,0,
11590,0,0,0,0,
11600,0,0,0,0,
11610,0,0,0,0,
11620,0,0,0,0,
11630,0,0,0,0,
11640,0,0,0,0,
11650,0,0,0,0,
11660,0,0,0,0,
11670,0,0,0,0,
11680,0,0,0,0,
11690,0,0,0,0,
11700,0,0,0,0,
11710,0,0,0,0,
11720,0,0,0,0,
11730,0,0,0,0,
11740,0,0,0,0,
11750,0,0,0,0,
11760,0,0,0,0,
11770,0,0,0,0,
11780,0,0,0,0,
11790,0,0,0,0,
11800,0,0,0,0,
11810,0,0,0,0,
11820,0,0,0,0,
11830,0,0,0,0,
11840,0,0,0,0,
11850,0,0,0,0,
11860,0,0,0,0,
11870,0,0,0,0,
11880,0,0,0,0,
11890,0,0,0,0,
11900,0,0,0,0,
11910,0,0,0,0,
11920,0,0,0,0,
11930,0,0,0,0,
11940,0,0,0,0,
11950,0,0,0,0,
11960,0,0,0,0,
11970,0,0,0,0,
11980,0,0,0,0,
11990,0,0,0,0,
12000,0,0,0,0,
12010,0,0,0,0,
12020,0,0,0,0,
12030,0,0,0,0,
12040,0,0,0,0,
12050,0,0,0,0,
12060,0,0,0,0,
12070,0,0,0,0,
12080,0,0,0,0,
12090,0,0,0,0,
12100,0,0,0,0,
12110,0,0,0,0,
12120,0,0,0,0,
12130,0,0,0,0,
12140,0,0,0,0,
12150,0,0,0,0,
12160,0,0,0,0,
12170,0,0,0,0,
12180,0,0,0,0,
12190,0,0,0,0,
12200,0,0,0,0,
12210,0,0,0,0,
12220,0,0,0,0,
12230,0,0,0,0,
12240,0,0,0,0,
12250,0,0,0,0,
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,0,0,0,0,
12500,0,0,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,
1276};
1277
1278
1279
1280#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)])
1281
1282#define yyyGSoccurStr(prodNum,symPos) \
1283   (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]])
1284
1285#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)])
1286
1287#define yyySortOf(prodNum,symPos) \
1288  (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1])
1289
1290#define yyyAttrbStr(prodNum,symPos,attrbNum)                      \
1291  (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \
1292                         (attrbNum)                               \
1293                        ]                                         \
1294               ]                                                  \
1295  )
1296
1297
1298
1299void yyyShowProd(int i)
1300  {int j,nSyms;
1301
1302   nSyms = yyySizeofProd(i);
1303   for (j=0; j<nSyms; j++)
1304     {
1305      fprintf(stderr,"%s",yyyGSoccurStr(i,j));
1306      if (j == 0) fputs(" : ",stderr); else putc(' ',stderr);
1307     }
1308   fputs(";\n",stderr);
1309  }
1310
1311
1312
1313void yyyShowProds()
1314  {int i; for (i=1; i<=yyyLastProdNum; i++) yyyShowProd(i);}
1315
1316
1317
1318void yyyShowSymsAndSorts()
1319  {int i;
1320
1321   for (i=1; i<=yyyLastProdNum; i++)
1322     {int j, nSyms;
1323
1324      fprintf(stderr,
1325              "\n\n\n---------------------------------- %3.1d\n",i);
1326      /* yyyShowProd(i); */
1327      nSyms = yyySizeofProd(i);
1328      for (j=0; j<nSyms; j++)
1329        {int k, sortSize;
1330
1331         fprintf(stderr,"%s\n",yyyGSoccurStr(i,j));
1332         sortSize = yyySizeofSort(yyySortOf(i,j));
1333         for (k=0; k<sortSize; k++)
1334            fprintf(stderr,"  %s\n",yyyAttrbStr(i,j,k));
1335         if (j == 0) fputs("->\n",stderr);
1336              else
1337              putc('\n',stderr);
1338        }
1339     }
1340  }
1341
1342
1343
1344void yyyCheckNodeInstancesSolved(yyyGNT *np)
1345  {int mysort,sortSize,i,prodNum,symPos,inTerminalNode;
1346   int nUnsolvedInsts = 0;
1347
1348   if (np->prodNum != 0)
1349     {inTerminalNode = 0;
1350      prodNum = np->prodNum;
1351      symPos = 0;
1352     }
1353   else
1354     {inTerminalNode = 1;
1355      prodNum = np->parent.noderef->prodNum;
1356      symPos = np->whichSym;
1357     }
1358   mysort = yyySortOf(prodNum,symPos);
1359   sortSize = yyySizeofSort(mysort);
1360   for (i=0; i<sortSize; i++)
1361     if ((np->refCountList)[i] != 0) nUnsolvedInsts += 1;
1362   if (nUnsolvedInsts)
1363     {fprintf(stderr,
1364      "\nFound node that has %d unsolved attribute instance(s).\n",
1365              nUnsolvedInsts
1366             );
1367      fprintf(stderr,"Node is labeled \"%s\".\n",
1368             yyyGSoccurStr(prodNum,symPos));
1369      if (inTerminalNode)
1370        {fputs("Node is terminal.  Its parent production is:\n  ",stderr);
1371         yyyShowProd(prodNum);
1372        }
1373      else
1374        {fputs("Node is nonterminal.  ",stderr);
1375         if (!(np->parentIsStack))
1376           {fprintf(stderr,
1377                    "Node is %dth child in its parent production:\n  ",
1378                   np->whichSym
1379                  );
1380            yyyShowProd(np->parent.noderef->prodNum);
1381           }
1382         fputs("Node is on left hand side of this production:\n  ",stderr);
1383         yyyShowProd(np->prodNum);
1384        }
1385      fputs("The following instances are unsolved:\n",stderr);
1386      for (i=0; i<sortSize; i++)
1387        if ((np->refCountList)[i] != 0)
1388          fprintf(stderr,"     %-16s still has %1d dependencies.\n",
1389                  yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]);
1390     }
1391  }
1392
1393
1394
1395void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum)
1396  {yyyGNT **yyyCLpdum;
1397   yyyRCT *rcp;
1398   int i;
1399
1400   /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */
1401   rcp = pNode->refCountList;
1402   i = pNode->refCountListLen;
1403   while (i--)
1404      if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;}
1405   yyyCLpdum = pNode->cL;
1406   i = pNode->cLlen;
1407   while (i--)
1408     {
1409      yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum);
1410      yyyCLpdum++;
1411     }
1412  }
1413
1414
1415
1416void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode)
1417  {yyyGNT **yyyCLpdum;
1418   int i;
1419
1420   yyyCheckNodeInstancesSolved(pNode);
1421   yyyCLpdum = pNode->cL;
1422   i = pNode->cLlen;
1423   while (i--)
1424     {
1425      yyyUnsolvedInstSearchTravAux(*yyyCLpdum);
1426      yyyCLpdum++;
1427     }
1428  }
1429
1430
1431
1432void yyyUnsolvedInstSearchTrav(yyyGNT *pNode)
1433  {yyyGNT **yyyCLpdum;
1434   int i;
1435
1436   yyyCLpdum = pNode->cL;
1437   i = pNode->cLlen;
1438   while (i--)
1439     {
1440      yyyUnsolvedInstSearchTravAux(*yyyCLpdum);
1441      yyyCLpdum++;
1442     }
1443  }
1444
1445
1446
1447