
# line 11 "gram.y"
#include "sc.h"

# line 14 "gram.y"
typedef union  {
    long ival;
    double fval;
    struct ent *ent;
    struct enode *enode;
    char *sval;
} YYSTYPE;
# define STRING 257
# define NUMBER 258
# define FNUMBER 259
# define WORD 260
# define S_FORMAT 261
# define S_LABEL 262
# define S_LEFTSTRING 263
# define S_RIGHTSTRING 264
# define S_GET 265
# define S_PUT 266
# define S_LET 267
# define S_WRITE 268
# define K_FIXED 269
# define K_R 270
# define K_C 271
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern short yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
YYSTYPE yylval; YYSTYPE yyval;
# define YYERRCODE 256
short yyexca[] ={
-1, 1,
	0, -1,
	-2, 0,
-1, 72,
	60, 0,
	61, 0,
	62, 0,
	-2, 33,
-1, 74,
	60, 0,
	61, 0,
	62, 0,
	-2, 34,
-1, 75,
	60, 0,
	61, 0,
	62, 0,
	-2, 35,
-1, 83,
	60, 0,
	61, 0,
	62, 0,
	-2, 38,
-1, 84,
	60, 0,
	61, 0,
	62, 0,
	-2, 40,
-1, 85,
	60, 0,
	61, 0,
	62, 0,
	-2, 39,
	};
# define YYNPROD 41
# define YYLAST 247
short yyact[]={

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

-227,-1000,-269,-269,-269,-269,-235,-224,-226,-230,
-1000, -15,-268,-265,-236,-237, -16, -17, -18,-239,
-1000,-1000,-1000, -25,-1000,-1000,-1000,-1000,-231,-232,
-233,-252,  43,-1000,-1000, -25,   2, -25, -25, -25,
-1000,-1000, -25, -25,-1000,-1000,-1000,-1000,-1000, -25,
 -25, -25, -25, -25, -29, -25, -33, -25, -25, -31,
-1000,-269,  17,-1000,-1000,-1000,-1000,  42,  42,  20,
  20,   9,  80, -25,  80,  80, -25, 150, 144, -25,
 -10,-1000, -25,  80,  80,  80,-269,  49,-1000 };
short yypgo[]={

   0,  98,  95, 112, 100,  61,  63,  57 };
short yyr1[]={

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

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

-1000,  -7, 267, 262, 263, 264, 261, 265, 266, 268,
 256,  -3,  -4,  -5, 270, 271,  -3,  -3,  -3, 258,
 257, 257, 257,  61,  -5,  -4, 258, 258,  61,  61,
  61, 258,  -1,  -2,  -3, 269,  -6,  40,  43,  45,
 258, 259, 126,  33,  42, 257, 257, 257, 258,  43,
  45,  42,  47,  63,  60,  61,  62,  38, 124,  33,
  -2,  47,  -1,  -2,  -2,  -2,  -2,  -1,  -1,  -1,
  -1,  -1,  -1,  61,  -1,  -1,  61,  -1,  -1,  61,
  -3,  41,  58,  -1,  -1,  -1,  58,  -1,  -3 };
short yydef[]={

   9,  -2,   0,   0,   0,   0,   0,   0,   0,   0,
  10,   0,   0,   0,   0,   0,   0,   0,   0,   0,
   6,   7,   8,   0,  13,  14,  11,  12,   0,   0,
   0,   0,   1,  31,  17,   0,   0,   0,  15,   0,
  23,  24,   0,   0,  16,   2,   3,   4,   5,   0,
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  18,   0,   0,  21,  22,  25,  26,  27,  28,  29,
  30,   0,  -2,   0,  -2,  -2,   0,  36,  37,   0,
   0,  20,   0,  -2,  -2,  -2,   0,  32,  19 };
#
# define YYFLAG -1000
# define YYERROR goto yyerrlab
# define YYACCEPT return(0)
# define YYABORT return(1)

/*	parser for yacc output	*/
/*      @(#)yaccpar	2.2 - 6/19/80 - IS/1 */

int yydebug = 0; /* 1 for debugging */
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 */

	if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
		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 */

			   if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
			   --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 */

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

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

			}

		}

	/* reduction by production yyn */

		if( yydebug ) printf("reduce %d\n",yyn);
		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 50 "gram.y"
{ let (yypvt[-2].ent, yypvt[-0].enode); } break;
case 2:
# line 52 "gram.y"
{ label (yypvt[-2].ent, yypvt[-0].sval, 0); } break;
case 3:
# line 54 "gram.y"
{ label (yypvt[-2].ent, yypvt[-0].sval, -1); } break;
case 4:
# line 56 "gram.y"
{ label (yypvt[-2].ent, yypvt[-0].sval, 1); } break;
case 5:
# line 58 "gram.y"
{ fwidth[yypvt[-2].ival] = yypvt[-1].ival;
				  FullUpdate++;
				  precision[yypvt[-2].ival] = yypvt[-0].ival; } break;
case 6:
# line 61 "gram.y"
{ readfile (yypvt[-0].sval); } break;
case 7:
# line 62 "gram.y"
{ writefile (yypvt[-0].sval); } break;
case 8:
# line 63 "gram.y"
{ printfile (yypvt[-0].sval); } break;
case 11:
# line 67 "gram.y"
{ yyval.ival = yypvt[-0].ival; } break;
case 12:
# line 68 "gram.y"
{ yyval.ival = yypvt[-0].ival; } break;
case 13:
# line 69 "gram.y"
{ yyval.ent = lookat(yypvt[-1].ival, yypvt[-0].ival); } break;
case 14:
# line 70 "gram.y"
{ yyval.ent = lookat(yypvt[-0].ival, yypvt[-1].ival); } break;
case 15:
# line 72 "gram.y"
{ yyval.ival = '+'; } break;
case 16:
# line 73 "gram.y"
{ yyval.ival = '*'; } break;
case 17:
# line 76 "gram.y"
{ yyval.enode = new ('v', yypvt[-0].ent); } break;
case 18:
# line 77 "gram.y"
{ yyval.enode = new ('f', 0, yypvt[-0].enode); } break;
case 19:
# line 79 "gram.y"
{ yyval.enode = new (O_REDUCE(yypvt[-4].ival), yypvt[-2].ent, yypvt[-0].ent); } break;
case 20:
# line 80 "gram.y"
{ yyval.enode = yypvt[-1].enode; } break;
case 21:
# line 81 "gram.y"
{ yyval.enode = yypvt[-0].enode; } break;
case 22:
# line 82 "gram.y"
{ yyval.enode = new ('m', 0, yypvt[-0].enode); } break;
case 23:
# line 83 "gram.y"
{ yyval.enode = new ('k', (double) yypvt[-0].ival); } break;
case 24:
# line 84 "gram.y"
{ yyval.enode = new ('k', yypvt[-0].fval); } break;
case 25:
# line 85 "gram.y"
{ yyval.enode = new ('~', 0, yypvt[-0].enode); } break;
case 26:
# line 86 "gram.y"
{ yyval.enode = new ('~', 0, yypvt[-0].enode); } break;
case 27:
# line 89 "gram.y"
{ yyval.enode = new ('+', yypvt[-2].enode, yypvt[-0].enode); } break;
case 28:
# line 90 "gram.y"
{ yyval.enode = new ('-', yypvt[-2].enode, yypvt[-0].enode); } break;
case 29:
# line 91 "gram.y"
{ yyval.enode = new ('*', yypvt[-2].enode, yypvt[-0].enode); } break;
case 30:
# line 92 "gram.y"
{ yyval.enode = new ('/', yypvt[-2].enode, yypvt[-0].enode); } break;
case 32:
# line 94 "gram.y"
{ yyval.enode = new ('?', yypvt[-4].enode, new(':', yypvt[-2].enode, yypvt[-0].enode)); } break;
case 33:
# line 95 "gram.y"
{ yyval.enode = new ('<', yypvt[-2].enode, yypvt[-0].enode); } break;
case 34:
# line 96 "gram.y"
{ yyval.enode = new ('=', yypvt[-2].enode, yypvt[-0].enode); } break;
case 35:
# line 97 "gram.y"
{ yyval.enode = new ('>', yypvt[-2].enode, yypvt[-0].enode); } break;
case 36:
# line 98 "gram.y"
{ yyval.enode = new ('&', yypvt[-2].enode, yypvt[-0].enode); } break;
case 37:
# line 99 "gram.y"
{ yyval.enode = new ('|', yypvt[-2].enode, yypvt[-0].enode); } break;
case 38:
# line 100 "gram.y"
{ yyval.enode = new ('~', 0, new ('>', yypvt[-3].enode, yypvt[-0].enode)); } break;
case 39:
# line 101 "gram.y"
{ yyval.enode = new ('~', 0, new ('=', yypvt[-3].enode, yypvt[-0].enode)); } break;
case 40:
# line 102 "gram.y"
{ yyval.enode = new ('~', 0, new ('<', yypvt[-3].enode, yypvt[-0].enode)); } break;

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

	}
