extern pperror(3),yyerror(3);














extern int yychar;
extern short yyerrflag;






int yylval, yyval;







/*	#if '\377' < 0		it would be nice if this worked properly!!!!! */




yylex() {
	static int ifdef=0;
	static char *op2[]={
		"||",  "&&" , ">>", "<<", ">=", "<=", "!=", "=="	};
	static int  val2[]={
		267, 266,  265,   264,   263,   262,   261,   260	};
	static char *opc="b\bt\tn\nf\fr\r\\\\";
	extern char fastab[];
	extern char *outp,*inp,*newp;
	extern int flslvl;
	register char savc, *s;
	char *skipbl();
	int val;
	register char **p2;
	struct symtab {
		char *name;
		char *value;
	}
	*sp, *lookup();

	for (;;) {
		newp=skipbl(newp);
		if (*inp=='\n') return(258);	/* end of #if */
		savc= *newp;
		*newp='\0';
		for (p2=op2+8; --p2>=op2; )	/* check 2-char ops */
			if (0==strcmp(*p2,inp)) {
				val=val2[p2-op2];
				goto ret;
			}
		s="+-*/%<>&^|?:!~(),";	/* check 1-char ops */
		while (*s) if (*s++== *inp) {
			val= *--s;
			goto ret;
		}
		if (*inp<='9' && *inp>='0') {/* a number */
			if (*inp=='0') yylval= (inp[1]=='x' || inp[1]=='X') ?
			tobinary(inp+2,16) : tobinary(inp+1,8);
			else yylval=tobinary(inp,10);
			val=257;
		}
		else if (  ((fastab+128)[*inp]&1)) {
			if (0==strcmp(inp,"defined")) {
				ifdef=1;
				++flslvl;
				val=259;
			}
			else {
				sp=lookup(inp,-1);
				if (ifdef!=0) {
					ifdef=0;
					--flslvl;
				}
				yylval= (sp->value==0) ? 0 : 1;
				val=257;
			}
		}
		else 	if (*inp=='\'') {/* character constant */
			val=257;
			if (inp[1]=='\\') {/* escaped */
				char c;
				if (newp[-1]=='\'') newp[-1]='\0';
				s=opc;
				while (*s) if (*s++!=inp[2]) ++s;
				else {
					yylval= *s;
					goto ret;
				}
				if (inp[2]<='9' && inp[2]>='0') yylval=c=tobinary(inp+2,8);
				else yylval=inp[2];
			}
			else yylval=inp[1];
		}
		else if (0==strcmp("\\\n",inp)) {
			*newp=savc;
			continue;
		}
		else {
			*newp=savc;
			pperror("Illegal character %c in preprocessor if", *inp);
			continue;
		}
ret:
		*newp=savc;
		outp=inp=newp;
		return(val);
	}
}

tobinary(st, b) char *st;
{
	int n, c, t;
	char *s;
	n=0;
	s=st;
	while (c = *s++) {
		switch(c) {
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			t = c-'0';
			break;
		case 'a':
		case 'b':
		case 'c':
		case 'd':
		case 'e':
		case 'f':
			t = c-'a';
			if (b>10) break;
		case 'A':
		case 'B':
		case 'C':
		case 'D':
		case 'E':
		case 'F':
			t = c - 'A';
			if (b>10) break;
		default:
			t = -1;
			if ( c=='l' || c=='L') if (*s=='\0') break;
			pperror("Illegal number %s", st);
		}
		if (t<0) break;
		n = n*b+t;
	}
	return(n);
}
short yyexca[] ={
	-1, 1,
	0, -1,
	-2, 0,
	-1, 44,
	262, 0,
	263, 0,
	60, 0,
	62, 0,
	-2, 9,
	-1, 45,
	262, 0,
	263, 0,
	60, 0,
	62, 0,
	-2, 10,
	-1, 46,
	262, 0,
	263, 0,
	60, 0,
	62, 0,
	-2, 11,
	-1, 47,
	262, 0,
	263, 0,
	60, 0,
	62, 0,
	-2, 12,
	-1, 48,
	260, 0,
	261, 0,
	-2, 13,
	-1, 49,
	260, 0,
	261, 0,
	-2, 14,
};


short yyact[]={

	13,  24,  35,  58,  13,  11,  14,  30,  15,  11,
	12,  60,  13,  24,  12,   1,  57,  11,  14,  30,
	15,  59,  12,  18,  13,  19,  29,   0,   0,  11,
	14,   0,  15,   0,  12,  18,   3,  19,  29,  13,
	24,  31,  32,  33,  11,  14,  30,  15,   0,  12,
	13,  24,   0,   0,   0,  11,  14,  25,  15,   5,
	12,   0,  18,   0,  19,  29,   7,   0,   0,  25,
	0,   4,   0,  18,   0,  19,  29,   0,  13,  24,
	0,   0,   0,  11,  14,   0,  15,  26,  12,   0,
	0,   0,  13,  24,   0,   0,  25,  11,  14,  26,
	15,  18,  12,  19,  13,  24,   0,  25,   0,  11,
	14,   0,  15,  13,  12,  18,   0,  19,  11,  14,
	0,  15,   0,  12,   0,   0,  26,  18,   0,  19,
	0,   0,   0,   0,  13,  25,  18,  26,  19,  11,
	14,   0,  15,   0,  12,  13,   0,   0,   0,  25,
	11,  14,   6,  15,   0,  12,   0,  18,   0,  19,
	0,   0,   0,   0,   0,  26,   0,   0,   0,   0,
	0,   0,   2,   0,   0,   0,   0,   0,   0,  26,
	34,   0,   0,   0,  37,  38,  39,  40,  41,  42,
	43,  44,  45,  46,  47,  48,  49,  50,  51,  52,
	53,  54,  55,  56,   0,   0,   0,   0,   0,   0,
	0,   0,   0,   0,   0,   0,   0,   0,   0,  36,
	0,   0,   0,  22,  23,  20,  21,  16,  17,  27,
	28,   0,  61,   0,   0,  22,  23,  20,  21,  16,
	17,  27,  28,   0,   0,   0,   0,   0,   0,   0,
	0,  16,  17,   0,   0,   0,   0,   0,   0,   0,
	10,   0,  22,  23,  20,  21,  16,  17,  27,  28,
	0,   0,   0,  22,  23,  20,  21,  16,  17,  27,
	28,   0,   0,   9,   0,   8,   0,   0,   0,   0,
	0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	0,  22,  23,  20,  21,  16,  17,  27,   0,   0,
	0,   0,   0,   0,   0,  22,  23,  20,  21,  16,
	17,   0,   0,   0,   0,   0,   0,  22,  23,  20,
	21,  16,  17,   0,   0,   0,  22,  23,  20,  21,
	16,  17,   0,   0,   0,   0,   0,   0,   0,   0,
	0,   0,   0,   0,   0,   0,   0,   0,   0,  20,
	21,  16,  17 };
short yypact[]={

	26,-1000,   2,-1000,  26,  26,  26,  26, -38,-1000,
	-1000,  26,  26,  26,  26,  26,  26,  26,  26,  26,
	26,  26,  26,  26,  26,  26,  26,  26,  26,  26,
	26,-1000,-1000,-1000, -25,-254,-1000,-1000,-1000,-1000,
	-33, -33, 108, 108, -13, -13, -13, -13,  97,  97,
	76,  67,  67,  55,  41, -37,  13,-1000, -30,  26,
	-1000,  13 };
short yypgo[]={

	0,  15, 172,  36 };
short yyr1[]={

	0,   1,   2,   2,   2,   2,   2,   2,   2,   2,
	2,   2,   2,   2,   2,   2,   2,   2,   2,   2,
	2,   2,   2,   3,   3,   3,   3,   3,   3,   3 };
short yyr2[]={

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

	-1000,  -1,  -2,  -3,  45,  33, 126,  40, 259, 257,
	258,  42,  47,  37,  43,  45, 264, 265,  60,  62,
	262, 263, 260, 261,  38,  94, 124, 266, 267,  63,
	44,  -3,  -3,  -3,  -2,  40, 257,  -2,  -2,  -2,
	-2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,
	-2,  -2,  -2,  -2,  -2,  -2,  -2,  41, 257,  58,
	41,  -2 };
short yydef[]={

	0,  -2,   0,  22,   0,   0,   0,   0,   0,  29,
	1,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	0,  23,  24,  25,   0,   0,  28,   2,   3,   4,
	5,   6,   7,   8,  -2,  -2,  -2,  -2,  -2,  -2,
	15,  16,  17,  18,  19,   0,  21,  26,   0,   0,
	27,  20 };






/*	parser for yacc output	*/


int yyv[150]; /* 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[150];
	short yyj, yym;
	register int *yypvt;
	register short yystate, *yyps, yyn;
	register int *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( ++yyps> &yys[150] ) {
		yyerror( "yacc stack overflow" );
		return(1);
	}
	*yyps = yystate;
	++yypv;
	*yypv = yyval;

yynewstate:

	yyn = yypact[yystate];

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

	if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
	if( (yyn += yychar)<0 || yyn >= 363 ) 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] + 256;
				if( yyn>= 0 && yyn < 363 && yychk[yyact[yyn]] == 256 ){
					yystate = yyact[yyn];  /* simulate a shift of "error" */
					goto yystack;
				}
				yyn = yypact[*yyps];

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


				--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( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
			yychar = -1;
			goto yynewstate;   /* try again in the same state */

		}

	}

	/* reduction by production 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>=363 || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[y
yn]];
	switch(yym){

	case 1:

		{
			return(yypvt[-1]);
		}
		break;
	case 2:

		{
			yyval = yypvt[-2] * yypvt[-0];
		}
		break;
	case 3:

		{
			yyval = yypvt[-2] / yypvt[-0];
		}
		break;
	case 4:

		{
			yyval = yypvt[-2] % yypvt[-0];
		}
		break;
	case 5:

		{
			yyval = yypvt[-2] + yypvt[-0];
		}
		break;
	case 6:

		{
			yyval = yypvt[-2] - yypvt[-0];
		}
		break;
	case 7:

		{
			yyval = yypvt[-2] << yypvt[-0];
		}
		break;
	case 8:

		{
			yyval = yypvt[-2] >> yypvt[-0];
		}
		break;
	case 9:

		{
			yyval = yypvt[-2] < yypvt[-0];
		}
		break;
	case 10:

		{
			yyval = yypvt[-2] > yypvt[-0];
		}
		break;
	case 11:

		{
			yyval = yypvt[-2] <= yypvt[-0];
		}
		break;
	case 12:

		{
			yyval = yypvt[-2] >= yypvt[-0];
		}
		break;
	case 13:

		{
			yyval = yypvt[-2] == yypvt[-0];
		}
		break;
	case 14:

		{
			yyval = yypvt[-2] != yypvt[-0];
		}
		break;
	case 15:

		{
			yyval = yypvt[-2] & yypvt[-0];
		}
		break;
	case 16:

		{
			yyval = yypvt[-2] ^ yypvt[-0];
		}
		break;
	case 17:

		{
			yyval = yypvt[-2] | yypvt[-0];
		}
		break;
	case 18:

		{
			yyval = yypvt[-2] && yypvt[-0];
		}
		break;
	case 19:

		{
			yyval = yypvt[-2] || yypvt[-0];
		}
		break;
	case 20:

		{
			yyval = yypvt[-4] ? yypvt[-2] : yypvt[-0];
		}
		break;
	case 21:

		{
			yyval = yypvt[-0];
		}
		break;
	case 22:

		{
			yyval = yypvt[-0];
		}
		break;
	case 23:

		{
			yyval = -yypvt[-1];
		}
		break;
	case 24:

		{
			yyval = !yypvt[-0];
		}
		break;
	case 25:

		{
			yyval = ~yypvt[-0];
		}
		break;
	case 26:

		{
			yyval = yypvt[-1];
		}
		break;
	case 27:

		{
			yyval= yypvt[-1];
		}
		break;
	case 28:

		{
			yyval = yypvt[-0];
		}
		break;
	case 29:

		{
			yyval= yypvt[-0];
		}
		break;
	}
	goto yystack;  /* stack new state and value */

}
