ftp.nice.ch/pub/next/unix/audio/Cmix.N.s.tar.gz#/cmix/Minc/y.tab.c

This is y.tab.c in view mode; [Download] [Up]

# line 5 "p.y"
#include "defs.h"
#include "lex.yy.c"
#include "ext.h"
#define YYDEBUG
#define MAXIDLIST 200

int   i1,i2,i3,i4,i5,i6,i7,i8,i9;
double atof(),f1,f2,f3,f4,f5,f6,f7,f8,f9,d1;
char  *c1,*c2,*c3;
Tree	tp1,tp2,tp3,tp4,tp5,tp6,tp7,tp8,tp9;
SYMBOL	*sp1,*sp2,*sp3,*sp4,*sp5,*sp6,*sp7,*sp8,*sp9;
int 	idcount =0;	
char	*idlist[MAXIDLIST];  
int     interactive;
char    str[200];
char    strp;
int     flerror;      /* set if there was an error during parsing */
int	level=0;        /* keeps track whether we are in a structure*/
# define LOWPRIO 257
# define T_OR 258
# define T_AND 259
# define T_EQU 260
# define UNEQU 261
# define LESSEQU 262
# define GTREQU 263
# define T_POW 264
# define CASTTOKEN 265
# define FLT 266
# define CTOO 267
# define CTOL 268
# define OTOL 269
# define OTOC 270
# define LTOO 271
# define LTOC 272
# define ID 273
# define NUM 274
# define T_NOT 275
# define IF 276
# define ELSE 277
# define FOR 278
# define WHILE 279
# define T_TRUE 280
# define T_FALSE 281
# define STRING 282
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern short yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
YYSTYPE yylval, yyval;
# define YYERRCODE 256

# line 186 "p.y"


declare(type)
int   type;
{

int  i1;
SYMBOL  *sp1;

  for (i1=0;i1<idcount;i1++) {

	sp1 = lookup (idlist[i1]);
	if (sp1 != NULL) {
		sprintf(str,"warning: variable redefined: %s",idlist[i1]);
/*  note this handling may be illegal in arbitrary scoping */
		sp1->type = type;
		yyerror(str);
	}
	else install(idlist[i1],S_GLOBAL,type);
  }
}	

Tree go (t1)
Tree t1;
{
	if (interactive && level==0)   exct(t1);
	if (interactive && level==0)   free_tree(t1);
	return (t1);
}
short yyexca[] ={
-1, 1,
	0, -1,
	-2, 0,
	};
# define YYNPROD 54
# define YYLAST 253
short yyact[]={

   9,  38,  27,  72,  38,  67,  40,  12,   9,  40,
  44,  60,  92,  86,  38,  54,   9,  61,  63,  40,
  64,  61,  62,  52,  54,  48,  62,  87,  30,  14,
  61,  63,  29,  64,  31,  62,  41,  11,  94,  11,
  70,  16,  43,  71,  15,   1,  11,  17,  55,   2,
  56,  37,   5,  28,   5,  18,  19,  11,  46,  20,
   0,   5,   0,   0,  32,   0,  25,   3,  50,  11,
  13,   0,   5,   0,   0,   0,   0,   0,   0,  11,
  11,   0,   0,  42,   5,   0,   0,   0,  13,   0,
   0,   0,   0,   0,   5,   5,   0,  89,   0,  65,
  51,   0,   0,  66,   0,   0,   0,   0,   0,  11,
  68,  69,   0,   0,   0,   0,   0,  73,  74,  75,
   0,   0,   0,   0,   5,   0,   0,   0,   0,  11,
   0,  11,   0,  10,   0,  53,  52,  54,  33,   0,
  90,  10,   0,   4,   5,   0,   5,   0,   0,  10,
  12,   4,  91,   6,   0,   8,   7,   0,  12,   4,
  93,   6,  95,   8,   7,   0,  12,  45,  47,   6,
   0,   8,   7,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,  76,  77,  78,  79,  80,  81,
  82,  83,  84,  85,   0,   0,   0,   0,   0,  21,
  88,  53,  52,  54,   0,   0,   0,   0,   0,  22,
  26,  24,  23,   0,   0,   0,   0,   0,   0,   0,
  53,  52,  54,   0,  12,  39,  34,  12,  39,  60,
   0,  35,  36,  60,   0,   0,  49,  12,  39,  57,
  58,  59,  60 };
short yypact[]={

-107,-1000,-107, -30,-266,-1000,-1000,-1000,-1000,-107,
 -57,  -8,-1000, -31,-1000, -10,-1000, -39, -39,   2,
-115,-1000,-1000,-1000,-1000,-1000,-1000,-1000, -26, -36,
-1000,-266,-123, -12, -39,-1000,-1000,-1000, -39,-1000,
-269,  -8,-123,-107,-1000, -25,  -1, -25,-1000,-1000,
-1000,-274, -39, -39, -39, -26, -26, -26, -26, -26,
 -26, -26, -26, -26, -26,-1000, -28,-1000,-1000, -32,
-1000, -36,-107,-245,-236,-1000, -25, -25, -25, -25,
 -25,-1000,-253,-253, -21, -21,-1000, -39, -25,-1000,
-1000, -47,-107,  -3,-107,-1000 };
short yypgo[]={

   0,  49,  67,  51,  64,  58, 138,  25,  36,  45,
  44,  47 };
short yyr1[]={

   0,   9,   1,   1,   1,   1,   2,   2,   2,   2,
   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,
  11,   3,   3,  10,  10,   8,   5,   5,   5,   5,
   5,   7,   4,   4,   4,   4,   4,   4,   4,   4,
   4,   4,   4,   4,   6,   6,   6,   6,   6,   6,
   6,   6,   6,   6 };
short yyr2[]={

   0,   1,   1,   2,   2,   3,   2,   1,   4,   6,
   4,  10,   3,   2,   2,   2,   2,   2,   2,   2,
   0,   3,   4,   1,   3,   1,   1,   3,   1,   3,
   0,   1,   1,   2,   3,   3,   3,   3,   3,   3,
   3,   3,   1,   1,   3,   1,   3,   3,   3,   3,
   3,   1,   2,   1 };
short yychk[]={

-1000,  -9,  -1,  -2, 266,  -3, 276, 279, 278, 123,
 256,  -8, 273,  -2,  59, -10,  -8, -11, -11, -11,
  -1, 266, 276, 279, 278, 123, 277,  59,  61,  40,
  59,  44,  -4,  -6, 275, 280, 281,  -3,  40, 274,
  45,  -8,  -4,  40, 125,  -6,  -5,  -6,  -7, 282,
  -8,  -2, 259, 258, 260,  60,  62, 261, 262, 263,
 264,  42,  47,  43,  45,  -4,  -4, 274,  -2,  -2,
  41,  44, 277,  -4,  -4,  -4,  -6,  -6,  -6,  -6,
  -6,  -6,  -6,  -6,  -6,  -6,  41,  59,  -6,  -7,
  -2,  -4,  59,  -2,  41,  -2 };
short yydef[]={

   0,  -2,   1,   2,   0,   7,  20,  20,  20,   0,
   0,   0,  25,   3,   4,   6,  23,   0,   0,   0,
   0,  13,  14,  15,  16,  17,  18,  19,   0,  30,
   5,   0,   0,  32,   0,  42,  43,  45,   0,  51,
   0,  53,   0,   0,  12,  21,   0,  26,  28,  31,
  24,   8,   0,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,   0,  33,   0,  52,  10,   0,
  22,   0,   0,  34,  35,  36,  37,  38,  39,  40,
  41,  44,  46,  47,  48,  49,  50,   0,  27,  29,
   9,   0,   0,   0,   0,  11 };
# line 1 "/usr/lib/yaccpar"
#ifndef lint
static char yaccpar_sccsid[] = "@(#)yaccpar	4.1	(Berkeley)	2/11/83";
#endif not lint

# define YYFLAG -1000
# define YYERROR goto yyerrlab
# define YYACCEPT return(0)
# define YYABORT return(1)

/*	parser for yacc output	*/

#ifdef YYDEBUG
int yydebug = 0; /* 1 for debugging */
#endif
YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
int yychar = -1; /* current input token number */
int yynerrs = 0;  /* number of errors */
short yyerrflag = 0;  /* error recovery flag */

yyparse() {

	short yys[YYMAXDEPTH];
	short yyj, yym;
	register YYSTYPE *yypvt;
	register short yystate, *yyps, yyn;
	register YYSTYPE *yypv;
	register short *yyxi;

	yystate = 0;
	yychar = -1;
	yynerrs = 0;
	yyerrflag = 0;
	yyps= &yys[-1];
	yypv= &yyv[-1];

 yystack:    /* put a state and value onto the stack */

#ifdef YYDEBUG
	if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
#endif
		if( ++yyps>= &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
		*yyps = yystate;
		++yypv;
		*yypv = yyval;

 yynewstate:

	yyn = yypact[yystate];

	if( yyn<= YYFLAG ) goto yydefault; /* simple state */

	if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
	if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;

	if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
		yychar = -1;
		yyval = yylval;
		yystate = yyn;
		if( yyerrflag > 0 ) --yyerrflag;
		goto yystack;
		}

 yydefault:
	/* default state action */

	if( (yyn=yydef[yystate]) == -2 ) {
		if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
		/* look through exception table */

		for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */

		while( *(yyxi+=2) >= 0 ){
			if( *yyxi == yychar ) break;
			}
		if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
		}

	if( yyn == 0 ){ /* error */
		/* error ... attempt to resume parsing */

		switch( yyerrflag ){

		case 0:   /* brand new error */

			yyerror( "syntax error" );
		yyerrlab:
			++yynerrs;

		case 1:
		case 2: /* incompletely recovered error ... try again */

			yyerrflag = 3;

			/* find a state where "error" is a legal shift action */

			while ( yyps >= yys ) {
			   yyn = yypact[*yyps] + YYERRCODE;
			   if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
			      yystate = yyact[yyn];  /* simulate a shift of "error" */
			      goto yystack;
			      }
			   yyn = yypact[*yyps];

			   /* the current yyps has no shift onn "error", pop stack */

#ifdef YYDEBUG
			   if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
#endif
			   --yyps;
			   --yypv;
			   }

			/* there is no state on the stack with an error shift ... abort */

	yyabort:
			return(1);


		case 3:  /* no shift yet; clobber input char */

#ifdef YYDEBUG
			if( yydebug ) printf( "error recovery discards char %d\n", yychar );
#endif

			if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
			yychar = -1;
			goto yynewstate;   /* try again in the same state */

			}

		}

	/* reduction by production yyn */

#ifdef YYDEBUG
		if( yydebug ) printf("reduce %d\n",yyn);
#endif
		yyps -= yyr2[yyn];
		yypvt = yypv;
		yypv -= yyr2[yyn];
		yyval = yypv[1];
		yym=yyn;
			/* consult goto table to find next state */
		yyn = yyr1[yyn];
		yyj = yypgo[yyn] + *yyps + 1;
		if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
		switch(yym){
			
case 1:
# line 42 "p.y"
{program = yypvt[-0].trees;return (0);} break;
case 2:
# line 45 "p.y"
{yyval.trees = yypvt[-0].trees;} break;
case 3:
# line 46 "p.y"
{yyval.trees = tseq(yypvt[-1].trees,yypvt[-0].trees);} break;
case 4:
# line 47 "p.y"
{yyval.trees = yypvt[-1].trees;} break;
case 5:
# line 48 "p.y"
{yyval.trees = tseq(yypvt[-2].trees,yypvt[-1].trees);} break;
case 6:
# line 51 "p.y"
{ declare(T_FLOAT);idcount=0;} break;
case 7:
# line 52 "p.y"
{
				if (level==0) 
					yyval.trees = go(yypvt[-0].trees); 
				else    yyval.trees = yypvt[-0].trees;
				} break;
case 8:
# line 57 "p.y"
{
					level--;
					yyval.trees = go(tif(yypvt[-1].trees,yypvt[-0].trees));
					} break;
case 9:
# line 61 "p.y"
{
					level--;
					yyval.trees = go(tifelse(yypvt[-3].trees,yypvt[-2].trees,yypvt[-0].trees));
					} break;
case 10:
# line 65 "p.y"
{
					level--;
					yyval.trees = go(twhile(yypvt[-1].trees,yypvt[-0].trees));
					} break;
case 11:
# line 69 "p.y"
{
					level--;
					yyval.trees = go(tfor(yypvt[-6].trees,yypvt[-4].trees,yypvt[-2].trees,yypvt[-0].trees));
					} break;
case 12:
# line 73 "p.y"
{yyval.trees = yypvt[-1].trees;} break;
case 13:
# line 74 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 14:
# line 75 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 15:
# line 76 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 16:
# line 77 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 17:
# line 78 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 18:
# line 79 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 19:
# line 80 "p.y"
{flerror = 1;yyval.trees=tnoop();} break;
case 20:
# line 83 "p.y"
{
					level++;
				} break;
case 21:
# line 87 "p.y"
{
					sp1=lookup(yypvt[-2].str);
					if (sp1==NULL) {
			   sprintf(str,"note: %s has been auto declared",yypvt[-2].str);
				sp1=install(yypvt[-2].str,S_GLOBAL,T_FLOAT);
	      				   yyerror (str); 	
					}
					yyval.trees = tstore(tname(sp1),yypvt[-0].trees); 
				} break;
case 22:
# line 96 "p.y"
{yyval.trees = tcall (yypvt[-1].trees,yypvt[-3].str);} break;
case 23:
# line 100 "p.y"
{ idlist[idcount++]=yypvt[-0].str;} break;
case 24:
# line 101 "p.y"
{ idlist[idcount++]=yypvt[-0].str;} break;
case 25:
# line 104 "p.y"
{ yyval.str = strsave(yytext);} break;
case 26:
# line 107 "p.y"
{yyval.trees = targ(tnoargs(),yypvt[-0].trees);} break;
case 27:
# line 108 "p.y"
{ yyval.trees = targ(yypvt[-2].trees,yypvt[-0].trees); } break;
case 28:
# line 112 "p.y"
{ 
			yyval.trees = targ(tnoargs(),yypvt[-0].trees);
			} break;
case 29:
# line 115 "p.y"
{
			yyval.trees = targ(yypvt[-2].trees,yypvt[-0].trees);
			} break;
case 30:
# line 118 "p.y"
{yyval.trees = tnoargs();} break;
case 31:
# line 120 "p.y"
{
			c1 = yytext + 1;
			c1[strlen(c1)-1]= '\0';
/* Here we do some weird conversion from char* to int to double.
 * It is a hack that allows to pass strings to cmix functions, 
 * in a way, that only the function needs to know about it.
 * It very likely to be machine dependent, so you might have to hack it
 * if it doesn't work on your system.  If you do, send me mail. ***lars.
 * (It might help to look at the assembler output produced by cc)
 */
			i1 =  strsave(c1);
			d1 = (double) i1;
			yyval.trees = tconstf(d1);
			} break;
case 32:
# line 136 "p.y"
{ yyval.trees = yypvt[-0].trees;} break;
case 33:
# line 137 "p.y"
{ yyval.trees = tnot(yypvt[-0].trees);	} break;
case 34:
# line 138 "p.y"
{ yyval.trees = tcand(yypvt[-2].trees,yypvt[-0].trees);   } break;
case 35:
# line 139 "p.y"
{ yyval.trees = tcor(yypvt[-2].trees,yypvt[-0].trees);  } break;
case 36:
# line 141 "p.y"
{ yyval.trees = trel(EQ,yypvt[-2].trees,yypvt[-0].trees); } break;
case 37:
# line 142 "p.y"
{ yyval.trees = trel(LT,yypvt[-2].trees,yypvt[-0].trees); } break;
case 38:
# line 143 "p.y"
{ yyval.trees = trel(GT,yypvt[-2].trees,yypvt[-0].trees);} break;
case 39:
# line 144 "p.y"
{ yyval.trees = trel(NEQ,yypvt[-2].trees,yypvt[-0].trees);} break;
case 40:
# line 145 "p.y"
{ yyval.trees = trel(LEQ,yypvt[-2].trees,yypvt[-0].trees); } break;
case 41:
# line 146 "p.y"
{ yyval.trees = trel(GEQ,yypvt[-2].trees,yypvt[-0].trees); } break;
case 42:
# line 147 "p.y"
{
			yyval.trees = trel (EQ,tconstf(1.0),tconstf(1.0));
		    } break;
case 43:
# line 150 "p.y"
{
			yyval.trees = trel (NEQ,tconstf(1.0),tconstf(1.0));
		    } break;
case 44:
# line 155 "p.y"
{ yyval.trees = top(POW,yypvt[-2].trees,yypvt[-0].trees); } break;
case 45:
# line 156 "p.y"
{ yyval.trees = yypvt[-0].trees;} break;
case 46:
# line 157 "p.y"
{ yyval.trees = top(MUL,yypvt[-2].trees,yypvt[-0].trees); } break;
case 47:
# line 158 "p.y"
{ yyval.trees = top(DIV,yypvt[-2].trees,yypvt[-0].trees); } break;
case 48:
# line 159 "p.y"
{ yyval.trees = top(PLUS,yypvt[-2].trees,yypvt[-0].trees); } break;
case 49:
# line 160 "p.y"
{ yyval.trees = top(MINUS,yypvt[-2].trees,yypvt[-0].trees); } break;
case 50:
# line 161 "p.y"
{ yyval.trees = yypvt[-1].trees;} break;
case 51:
# line 162 "p.y"
{
			f1 = atof(yytext);
			yyval.trees = tconstf(f1);
	           } break;
case 52:
# line 166 "p.y"
{
			f1 = atof(yytext);
			yyval.trees = tconstf(-f1);
	           } break;
case 53:
# line 170 "p.y"
{
		
		sp1=lookup(yypvt[-0].str);
		if (sp1==NULL) {
		  sprintf(str,"error: %s is not declared",yypvt[-0].str);
			yyerror (str); 	
		  yyval.trees = tconstf(0.0);
		}else  yyval.trees = tname(sp1);
	} break;
# line 148 "/usr/lib/yaccpar"

		}
		goto yystack;  /* stack new state and value */

	}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.