# define NEW 257
# define GRAPH 258
# define TITLE 259
# define SIZE 260
# define FONT 261
# define ANGLE 262
# define ALIGN 263
# define LEFT 264
# define RIGHT 265
# define CENTER 266
# define BAR 267
# define REGRESSION 268
# define STEP 269
# define XHISTOGRAM 270
# define YHISTOGRAM 271
# define SMOOTH 272
# define SPLINE 273
# define KEY 274
# define CURVE 275
# define POINTS 276
# define CONFIDENCE 277
# define LABEL 278
# define LABELS 279
# define TYPE 280
# define INTERPOLATION 281
# define GRAY 282
# define MAT 283
# define X 284
# define Y 285
# define MAXIMUM 286
# define MINIMUM 287
# define UNIT 288
# define INTERVAL 289
# define SCALE 290
# define LOGBASE 291
# define NUMBERSTYLE 292
# define TEXT 293
# define INPUT 294
# define LINE 295
# define SYMBOL 296
# define BOTH 297
# define NONE 298
# define SOLID 299
# define DASHES 300
# define STIPPLE 301
# define DOTS 302
# define PAT 303
# define FILL 304
# define BOLD 305
# define CROSS 306
# define TRIANGLE 307
# define TRIANGLEFILLED 308
# define DIAMOND 309
# define DIAMONDFILLED 310
# define SQUARE 311
# define BOX 312
# define SQUAREFILLED 313
# define SOLIDBOX 314
# define RECTANGLE 315
# define RECTANGLEFILLED 316
# define CIRCLE 317
# define CIRCLEFILLED 318
# define BULLET 319
# define PLUS 320
# define STAR 321
# define LINEAR 322
# define LOGS 323
# define UNKNOWNCMD 324
# define COMMENT 325
# define EXCLUDE 326
# define MINORTIC 327
# define MINORTICS 328
# define NUMBERS 329
# define FONTNAME 330
# define INTEGER 331
# define FLOATING 332
# define SCIENTIFIC 333
# define EXPONENT 334
# define MIRROR 335
# define ORIGIN 336
# define AXES 337
# define FUNCTION 338
# define DEF 339

# line 88 "plot.yacc"

#include <stdio.h>
#include <strings.h>
#include "plotio.h"
#include "defs.h"
#include "structs.h"
#include "plot.h"

static double currSSfreq=30.0, currSSang = 0.0; /* for setscreen */
static int currSSfnIndex = 0;

/* function related globals */
static char* curfn; /*ptr to function defs for a curce */
static float curfnstart, curfnend, curfndelta;/*start,end,incr for fn calcs */
static int FUNCTION_LEN = 10000;

char pstr[MAXLABEL];/*stores previous correct instring - for error reporting*/
char errorpos[MAXLABEL];/* stores prev correct text word */
double tmpfloat;
int tmpint;
pointType *ptPtr;/*temp pointer for current point in curve */
boolean intext = FALSE;
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern short yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
#ifndef YYSTYPE
#define YYSTYPE int
#endif
YYSTYPE yylval, yyval;
# define YYERRCODE 256

# line 941 "plot.yacc"
 

#include "lex.yy.c"


addPointsPair1()
{
	ptPtr = (pointType *)GetSp(sizeof(pointType));
	ptPtr->conf = NoConfInterval; /* initialized */
	if ((curves[curcur])->fstPtr == nil)
	{
		/*means first point in curve */
		(curves[curcur])->fstPtr = ptPtr;
		ptPtr->prvPtr = nil;
	}
	else 
	{
		ptPtr->prvPtr = (curves[curcur])->lstPtr;
		(curves[curcur])->lstPtr->nxtPtr = ptPtr;
	}
	(curves[curcur])->lstPtr = ptPtr;
	ptPtr->nxtPtr = nil;
	(curves[curcur])->lastpoint += 1;
	/* incr point count; after 1st pt is 0 */
	ptPtr->pt[xpt]= atof(yytext);
}

addPointsPair2()
{
	ptPtr->pt[ypt] = atof(yytext);
}

addPointsConf()
{
	ptPtr->conf = atof(yytext);
}

unknowncmderror()
{
	fprintf(stderr,	
		"***splot::Warning: unknown command near line %d\n", lineno);
	fprintf(stderr,"previous text: %s, ",errorpos);
	fprintf(stderr,"current text: %s\n",yytext);
}

newgraphproc()
{
	graph.includekey = FALSE;
	*graph.title = '\0';
	*graph.label = '\0';
	graph.font = defGraphFont;
	graph.keyfont = defGraphKeyFont;
	graph.key = kboth;
	graph.size[xpt] = defGraphXsize * 2.54;
	graph.size[ypt] = defGraphYsize * 2.54;
	setaxisdefs(xpt);
	setaxisdefs(ypt);
	currSSang = 0.0;
	currSSfnIndex = 0;
	currSSfreq = 30;
}

setaxisdefs(z)
int z;
{
	*axis[z].label = '\0';
	axis[z].scale.type = linear;
	axis[z].interval = 0.0;
	axis[z].axismax = BIG;
	axis[z].axismin = BIG;
	axis[z].numberstyle = floating;
	axis[z].signif = 0;
	axis[z].unit = 1.0;
	axis[z].font = defAxisFont;
}

newcurveproc()
{
	curcur++;/*go to first empty slot*/
	curves[curcur] = (curvetype *) 
		GetSp(sizeof(curvetype));  
	(curves[curcur])->validcurve = TRUE;
	*curves[curcur]->label = '\0';
	(curves[curcur])->symbol = nonesymbol;
	(curves[curcur])->symbolsize = defSymbolSize;
	(curves[curcur])->interp = linearinterp;
	(curves[curcur])->type = solid;
	(curves[curcur])->fstPtr = nil;
	(curves[curcur])->lstPtr = nil;
	(curves[curcur])->lastpoint = -1;
	(curves[curcur])->include = TRUE;
	(curves[curcur])->showConf = FALSE;
	(curves[curcur])->thick = defGraphThick;
	(curves[curcur])->gray = 0.0;
	(curves[curcur])->mat.grayset = FALSE;
	(curves[curcur])->mat.freq = 0.0;
	(curves[curcur])->mat.ang = 30.0;
	(curves[curcur])->mat.indx = 0;
	(curves[curcur])->mat.matset = FALSE;
	(curves[curcur])->mat.showline = TRUE;
	/* bounding curve appears by default */
}

handlefillproc()
{
	currSSang += 45.0; 
	/* rotate 45 degrees for each new curve */
	if (currSSang > 181.0) 
	{
		currSSang = 45.0;
		currSSfnIndex += 1;
		if (currSSfnIndex == MAXSSFNS)
		{
			currSSfnIndex = 0;
			currSSfreq += 15.0;
			if (currSSfreq > 61.0)
			{
				currSSfreq = 5.0;
			}
		}
	}
	(curves[curcur])->type = fill;
	/* bounding curve true by default */
	if ((!(curves[curcur])->mat.grayset))
		(curves[curcur])->gray = defFillGray;
	if ((!(curves[curcur])->mat.matset))
	{
	    (curves[curcur])->mat.freq = currSSfreq;
	    (curves[curcur])->mat.ang = currSSang;
	    (curves[curcur])->mat.indx= currSSfnIndex;
	}
}

nocurverr()
{
	fprintf(stderr,
		"splot error: no new curve command, near line %d\n", lineno);
}

notexterr()
{
	fprintf(stderr,
	"***splot warning: error on line %d, no text entered yet!\n", lineno);
}

newtextproc()
{
	curtext++;
	text[curtext] = (texttype *) GetSp(sizeof(texttype));
	(text[curtext])->font = defTextFont;
	(text[curtext])->angle = 0;
	(text[curtext])->include = TRUE;
	(text[curtext])->validtext = TRUE;
}


fnerror()
{
	fprintf(stderr,
	"***splot warning: error on line %d, incorrect function declaration!\n", 
		lineno);
}

char *prc[] = { "%f" };
char *comf[] = { "/usr/tmp/ZZcomf.c" };
char *inf[] = { "/usr/tmp/ZZinf" };
char *outf[] = { "/usr/tmp/ZZoutf" };
#define MAXSIZEOFNUM 100

computfn(curfnstart,curfnend,curfndelta,curfn)
char* curfn; 
float curfnstart, curfnend, curfndelta;
{
float x, y;
FILE *fp_comf, *fp_inf, *fp_outf, *fopen();
char ytxt[MAXSIZEOFNUM], xtxt[MAXSIZEOFNUM];

	if (curcur < 0) nocurverr();

	/* first write out function program */
	fp_comf = fopen(*comf,"w");
	fprintf(fp_comf,"#include <stdio.h>\n");
	fprintf(fp_comf,"#include <math.h>\n");
	fprintf(fp_comf,"main(){\n");
	fprintf(fp_comf,"float y,x;\n");
	fprintf(fp_comf,"while (scanf(\"%s\",&x) != EOF){\n",*prc);
	fprintf(fp_comf,"y = %s;\n",curfn);	
	fprintf(fp_comf,"printf(\"%s\\n\",y);}}\n",*prc);
	fclose(fp_comf);

	/* then compile the function program */
	system("cd /usr/tmp; cc -o /usr/tmp/ZZexef /usr/tmp/ZZcomf.c -lm");

	/* write out input to function */
	fp_inf = fopen(*inf,"w");
	x = curfnstart;
	while (x <= curfnend)
	{
		fprintf(fp_inf,"%f\n",x);
		x += curfndelta;
	}
	fclose(fp_inf);

	/* run the function program */
	system("/usr/tmp/ZZexef </usr/tmp/ZZinf > /usr/tmp/ZZoutf");

	/* read the function out file and put points into curve */
	fp_inf = fopen(*inf,"r");
	fp_outf = fopen(*outf,"r");
	while(fscanf(fp_inf, "%s", xtxt) != EOF)
	{
		strcpy(yytext, xtxt);
		addPointsPair1();
		if (fscanf(fp_outf,"%s", ytxt) != EOF) 
			strcpy(yytext, ytxt);
		else 
		{
			fnerror();
			strcpy(yytext, "0.0");
			addPointsPair2();
			return;
		}
		addPointsPair2();
	}
	fclose(fp_outf);

	/* delete all files generated by function computations */
/*	system("rm /usr/tmp/ZZcomf.c /usr/tmp/ZZinf /usr/tmp/ZZoutf /usr/tmp/ZZexef");*/
}
short yyexca[] ={
-1, 1,
	0, -1,
	-2, 0,
-1, 302,
	10, 105,
	-2, 103,
	};
# define YYNPROD 244
# define YYLAST 374
short yyact[]={

   4, 132, 327, 123,  78, 191, 192, 193, 194, 314,
 129, 130, 227, 175, 176, 177, 178, 215, 212, 125,
 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
 238, 239, 240, 241, 242, 243, 211, 202, 200, 197,
 181, 165, 162, 146, 198, 186, 187, 319,  94, 205,
 137, 170, 171, 127, 128, 316, 304, 296, 297, 298,
 324, 126, 313, 131,  93,  95, 272,  96,  98,  99,
 101, 201, 199, 247, 248, 246, 251, 249, 250, 206,
 138, 115,  81,  97, 158,  85, 271,  87, 331, 196,
 218, 219, 220, 221, 222, 223, 224, 225, 114,  83,
  84,  89, 330, 106,  86, 320, 116, 117, 118, 121,
 119, 120, 122, 100, 263, 322, 321,  82, 258,  88,
 105, 309, 308, 305, 300, 299, 295, 245, 107, 108,
 109, 112, 110, 111, 113, 291, 328, 289, 288, 287,
 286, 285, 273, 281, 280, 279, 278, 275, 274, 268,
 264, 262, 259, 257, 216, 214, 213, 210, 209, 207,
 204, 195, 189, 188, 184, 183, 182, 180, 173, 172,
 168, 167, 166, 164, 160, 159, 157, 153, 145, 143,
 135, 133,  92,  91, 254, 256, 255, 104, 102, 103,
 148, 147, 277, 302, 208, 139,  80,  79,   2, 190,
  77, 185, 179, 174, 169, 163, 326, 311, 303, 283,
 270, 141, 329, 315, 293, 267, 124, 292, 252, 244,
 156, 276, 226, 155, 217, 154, 152, 151, 203, 253,
 161, 318, 317, 310, 301, 294, 269, 140, 290, 284,
 150, 149,  90, 144, 142, 134,   3,  62,  63, 136,
  64,  62,  63,  74,  64,  61,  60,  59,  58,  57,
  56,  55,  54,  53,  65,  66,  52,  51,  65,  66,
  50,  49,  48,  47,  68,  69,  46,  45,  68,  69,
  44,  43,  42,  67,  41,  40,  39,  67,  38,  37,
  36,  35,  34,  33,  32,  31, 260, 261,  30,  29,
  28,  27,  26,  25,  24,  23,  22,  21, 265, 266,
  20,  19,  18,  17,  76,  75,  72,  16,  76,  75,
  72,  15,  14,  13,  12,  70,  73,  11,  71,  70,
  73,  10,  71,   9,   8,   7,   6,   5,   1,   0,
   0,   0,   0,   0, 320,   0, 312,   0,   0,   0,
 273,   0,   0,   0, 306, 307,   0, 282,   0,   0,
   0,   0,   0,   0,   0,   0, 325,   0,   0,   0,
   0,   0,   0, 323 };
short yypact[]={

 -10,  -6, 187, 186,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-176,-174,-111,-112,-213, -74,-158,-180,
-334,-1000,-274,-113,-1000,-114,-244, 185,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-115,-116,-287, -70, -71,
-1000,-1000,-1000,-1000,-1000,-117,-1000,-1000,-1000,-118,
-211,-119,-120,-1000,-288,-121,-289,-122,-123,-124,
-271,-125,-126,-318,-127,-290,-128,-129,-130,-277,
-131,-132,-326,-1000,-133,-1000,-240,-285,-1000,-257,
-258,-1000,-1000,-1000,-134,-1000,-245,-1000,-1000,-1000,
-135, 184,-136,-1000,-137,-1000,-1000,-294,-312,-138,
-139,-313,-140,-1000,-208,-286,-195,-1000,-1000,-1000,
-1000, -80,-1000,-141,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-142,-142,-142,-143,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-144,-144,-144,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-145,-1000,-1000,-1000,-1000,  56,-1000,
-1000,-1000,-1000,-146,-147,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000, -68,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-148,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-149,-150,-151,
-152,-1000,-1000,-1000,-1000,-1000,-1000,-153,-154,-155,
-1000,-156,-1000,-157,-159,-1000,-1000,-1000,-1000,-168,
-1000,-238,-169,-170, 183,-1000,-171,-171,-171,-172,
-173,-1000,-1000,  52,-1000,-321,-1000,-1000,-1000,-1000,
-189,-1000,-178,-1000,-1000,-179,-1000,-189,  50,-1000,
-1000,-1000,-337,-1000,-1000,-1000, 126,-192,-1000,-206,
-1000,-1000 };
short yypgo[]={

   0, 338, 198, 337, 336, 335, 334, 333, 331, 327,
 324, 323, 322, 321, 317, 313, 312, 311, 310, 307,
 306, 305, 304, 303, 302, 301, 300, 299, 298, 295,
 294, 293, 292, 291, 290, 289, 288, 286, 285, 284,
 282, 281, 280, 277, 276, 273, 272, 271, 270, 267,
 266, 263, 262, 261, 260, 259, 258, 257, 256, 255,
 253, 249, 245, 244, 243, 242, 241, 240, 239, 238,
  56, 237, 236, 235, 234, 233,  55, 232, 231,  47,
 230, 229, 228, 227, 226, 225, 224, 223, 222, 221,
 220, 219, 218, 217, 216, 215, 214, 213, 212, 211,
 210,  86, 209, 208, 207, 206, 205, 204, 203, 118,
 202, 201, 199, 114 };
short yyr1[]={

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

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

-1000,  -1,  -2, 256,  10,  -3,  -4,  -5,  -6,  -7,
  -8,  -9, -10, -11, -12, -13, -14, -15, -16, -17,
 -18, -19, -20, -21, -22, -23, -24, -25, -26, -27,
 -28, -29, -30, -31, -32, -33, -34, -35, -36, -37,
 -38, -39, -40, -41, -42, -43, -44, -45, -46, -47,
 -48, -49, -50, -51, -52, -53, -54, -55, -56, -57,
 -58, -59, 257, 258, 260, 274, 275, 293, 284, 285,
 335, 338, 326, 336, -60, 325, 324,  -2,  10,  10,
  10, 258, 293, 275, 276, 259, 278, 261, 293, 275,
 -65, 294, 294, 277, 261, 278, 280, 296, 281, 282,
 326, 283, 262, 263, 261, 278, 261, 286, 287, 288,
 290, 291, 289, 292, 278, 261, 286, 287, 288, 290,
 291, 289, 292, 337, -94, 293, 335, 327, 328, 284,
 285, 337, 275, 294, -62, 294, -61, 294, 324,  10,
 -71, -99, -63, 294, -64, 294, 330, 261, 261, -66,
 -67, -83, -84, 294, -85, -87, -90, 294, 295, 294,
 294, -80, 330,-106, 294, 330, 294, 294, 294,-107,
 322, 323, 294, 294,-108, 331, 332, 333, 334,-110,
 294, 330, 294, 294, 294,-111, 322, 323, 294, 294,
-112, 331, 332, 333, 334, 294, 329, 279, 329, 329,
 295, 329, 295, -82, 294, 294, 324, 294,  10, 294,
 294, 330, 330, 294, 294, 330, 294, -86, 298, 299,
 300, 301, 302, 303, 304, 305, -88, 298, 306, 307,
 308, 309, 310, 311, 312, 313, 314, 315, 316, 317,
 318, 319, 320, 321, -91, 322, 270, 268, 269, 272,
 273, 271, -92, -81, 264, 266, 265, 294,-109, 294,
-109,-109, 294,-113, 294,-113,-113, -95, 294, -72,
-100,-101,  10, 294, 294, 294, -89, 260, 294, 294,
 294, 294,-101,-102, -68, 294, 294, 294, 294, 294,
 -69, 294, -93, -96, -73, 294, 295, 296, 297, 294,
 294, -74,  10,-103, -70, 294, -70, -70, 294, 294,
 -75,-104, 294,  10, 330, -97, -76, -77, -78, -79,
 294, 294, 294, -76,  10, -79,-105, 339,  10, -98,
 294, 294 };
short yydef[]={

   0,  -2,   0,   0,   5,   6,   7,   8,   9,  10,
  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,
  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,
  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,
  41,  42,  43,  44,  45,  46,  47,  48,  49,  50,
  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,
  61,  62,   0,   0,  84,   0,   0,   0,   0,   0,
   0, 186,   0,   0,  63,  71,  64,   0,   3,   1,
   4,  74,  99, 132, 193,  76,  80,   0,   0,   0,
  83,  85,  90, 134, 135, 138, 141, 151, 172,   0,
   0,   0,   0, 114,   0, 205,   0,   0,   0,   0,
   0,   0,   0,   0, 225,   0,   0,   0,   0,   0,
   0,   0,   0, 120,   0, 112,   0,   0, 126,   0,
   0, 131, 133, 123,  70,  73,  65,  68,  69,   2,
   0,   0,  75,  78,  79,  82,  87,   0,   0,   0,
   0,   0, 137, 140,   0,   0,   0, 181, 182, 183,
 113,   0, 119, 204, 207, 208, 209, 210, 211, 212,
 213, 214, 215, 216, 217, 218, 223, 223, 223, 224,
 227, 228, 229, 230, 231, 232, 233, 234, 235, 236,
 237, 238, 243, 243, 243, 187, 121, 122, 125, 127,
 129, 128, 130,   0,  72,  66,  67, 100,   0,  77,
  81,  88,  89,   0,   0, 136, 139, 142, 143, 144,
 145, 146, 147, 148, 149, 150, 154, 155, 156, 157,
 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
 168, 169, 170, 171, 173, 174, 175, 176, 177, 178,
 179, 180,   0, 115, 116, 117, 118, 206, 219, 222,
 220, 221, 226, 239, 242, 240, 241,   0,   0,   0,
 194, 196, 197, 198,  86,  91, 152,   0,   0,   0,
 124,   0, 195,   0,  96, 153, 184, 188, 101,   0,
  92,   0,   0,   0,   0, 199,  98,  98,  98,   0,
   0, 102,  -2,   0,  93,   0,  94,  95, 185, 189,
   0, 200,   0, 203,  97,   0, 104, 107,   0, 110,
 111, 201,   0, 106, 108, 109,   0,   0, 202, 190,
 192, 191 };
#ifndef lint
static char yaccpar_sccsid[] = "@(#)yaccpar	4.1	(Berkeley)	2/11/83";
#endif

#
# 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 4:
# line 118 "plot.yacc"
{
				fprintf(stderr,
				"***splot::error near line %d\n", lineno);
				fprintf(stderr,
				"previous text: %s, ",errorpos);
/*				fprintf(stderr,"prev: %s, ",pstr);*/
				fprintf(stderr,"current text: %s\n",yytext);
				yyerrok;
			} break;
case 64:
# line 194 "plot.yacc"
{
				unknowncmderror();
			} break;
case 65:
# line 198 "plot.yacc"
{
				unknowncmderror();
			} break;
case 74:
# line 218 "plot.yacc"
{
				newgraphproc();
			} break;
case 77:
# line 228 "plot.yacc"
{strcat(graph.title, yytext);} break;
case 78:
# line 230 "plot.yacc"
{strcat(graph.title, yytext);} break;
case 81:
# line 238 "plot.yacc"
{strcat(graph.label, yytext);} break;
case 82:
# line 240 "plot.yacc"
{strcat(graph.label, yytext);} break;
case 84:
# line 247 "plot.yacc"
{
				graph.size[xpt] = 6;
				graphsize[xpt] = graph.size[xpt]*2.54;
				graph.size[ypt] = 6;
				graphsize[ypt] = graph.size[ypt]*2.54;
			} break;
case 85:
# line 254 "plot.yacc"
{
				graph.size[xpt] = atof(yytext);
				graphsize[xpt] = graph.size[xpt]*2.54;
			} break;
case 86:
# line 260 "plot.yacc"
{
				graph.size[ypt] = atof(yytext);
				graphsize[ypt] = graph.size[ypt]*2.54;
			} break;
case 87:
# line 267 "plot.yacc"
{
				graph.font = yylval;
			} break;
case 88:
# line 273 "plot.yacc"
{
				defTextFont = yylval;
			} break;
case 89:
# line 279 "plot.yacc"
{
				defGraphThick = FFthick(yylval);
			} break;
case 90:
# line 285 "plot.yacc"
{
				graph.keypos[xpt] = atof(yytext);
			} break;
case 91:
# line 290 "plot.yacc"
{
				graph.keypos[ypt] = atof(yytext);
				graph.includekey = TRUE;
			} break;
case 93:
# line 298 "plot.yacc"
{
				graph.key = ktype;
			} break;
case 94:
# line 302 "plot.yacc"
{
				graph.key = ksymbol;
			} break;
case 95:
# line 306 "plot.yacc"
{
				graph.key = kboth;
			} break;
case 97:
# line 313 "plot.yacc"
{
				graph.keyfont = yylval;
			} break;
case 99:
# line 320 "plot.yacc"
{
				newtextproc();
			} break;
case 100:
# line 324 "plot.yacc"
{
				(text[curtext])->pos[xpt] = atof(yytext);
			} break;
case 101:
# line 329 "plot.yacc"
{
				(text[curtext])->pos[ypt] = atof(yytext);
			} break;
case 103:
# line 336 "plot.yacc"
{intext = TRUE;} break;
case 104:
# line 338 "plot.yacc"
{
				 intext = FALSE;
			} break;
case 108:
# line 349 "plot.yacc"
{
				strcat((text[curtext])->label,yytext);
			} break;
case 111:
# line 359 "plot.yacc"
{
				strcat((text[curtext])->label,yytext);
			} break;
case 112:
# line 365 "plot.yacc"
{
				if (curtext == -1) notexterr();
				else (text[curtext])->include = FALSE;
			} break;
case 113:
# line 374 "plot.yacc"
{
				if (curtext == -1) notexterr();
				else
				(text[curtext])->angle = atof(yytext);
			} break;
case 114:
# line 384 "plot.yacc"
{
				if (curtext == -1) notexterr();
			} break;
case 116:
# line 391 "plot.yacc"
{
				(text[curtext])->align = left;
			} break;
case 117:
# line 395 "plot.yacc"
{
				(text[curtext])->align = center;
			} break;
case 118:
# line 399 "plot.yacc"
{
				(text[curtext])->align = right;
			} break;
case 119:
# line 408 "plot.yacc"
{
				if (curtext == -1) notexterr();
				else (text[curtext])->font = yylval;
			} break;
case 120:
# line 415 "plot.yacc"
{
				MirrorAxes = TRUE;
				MirrorAxisNumbers = TRUE;
				MirrorAxisLabels = TRUE;
			} break;
case 121:
# line 423 "plot.yacc"
{
				MirrorAxes = TRUE;
				MirrorAxisNumbers = FALSE;
			} break;
case 122:
# line 430 "plot.yacc"
{
				MirrorAxes = TRUE;
				MirrorAxisLabels = FALSE;
			} break;
case 123:
# line 437 "plot.yacc"
{
				NewOrigin = TRUE;
				origin[xpt] = atof(yytext);
			} break;
case 124:
# line 442 "plot.yacc"
{
				origin[ypt] = atof(yytext);
			} break;
case 125:
# line 448 "plot.yacc"
{
				MinticNos = FALSE;
			} break;
case 126:
# line 454 "plot.yacc"
{
				ShowMinTics = FALSE;
			} break;
case 127:
# line 460 "plot.yacc"
{
				ShowXNos = FALSE;
			} break;
case 128:
# line 466 "plot.yacc"
{
				ShowYNos = FALSE;
			} break;
case 129:
# line 472 "plot.yacc"
{
/* relic of ancient times. Not present in man page */
				ShowXLine = FALSE;
			} break;
case 130:
# line 479 "plot.yacc"
{
/* relic of ancient times. Not present in man page */
				ShowYLine = FALSE;
			} break;
case 131:
# line 486 "plot.yacc"
{
				ShowAxes = FALSE;
			} break;
case 132:
# line 492 "plot.yacc"
{	
				newcurveproc();
			 } break;
case 133:
# line 498 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				(curves[curcur])->include = FALSE;
				/*may want to do curcur-1 here*/
			} break;
case 134:
# line 506 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				(curves[curcur])->showConf = TRUE;
			} break;
case 135:
# line 513 "plot.yacc"
{
				if (curcur < 0) nocurverr();
			} break;
case 136:
# line 517 "plot.yacc"
{
				(curves[curcur])->thick = FFthick(yylval);
			} break;
case 137:
# line 523 "plot.yacc"
{
/*				strcpy(pstr,yytext);*/
			} break;
case 139:
# line 530 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				strcat((curves[curcur])->label, yytext);
			} break;
case 140:
# line 535 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				strcat((curves[curcur])->label, yytext);
			} break;
case 141:
# line 542 "plot.yacc"
{
				if (curcur < 0) nocurverr();
			} break;
case 143:
# line 549 "plot.yacc"
{(curves[curcur])->type = none;} break;
case 144:
# line 551 "plot.yacc"
{(curves[curcur])->type = solid;} break;
case 145:
# line 553 "plot.yacc"
{(curves[curcur])->type = dashes;} break;
case 146:
# line 555 "plot.yacc"
{(curves[curcur])->type = stipple;} break;
case 147:
# line 557 "plot.yacc"
{(curves[curcur])->type = dots;} break;
case 148:
# line 559 "plot.yacc"
{(curves[curcur])->type = pat;} break;
case 149:
# line 561 "plot.yacc"
{
				handlefillproc();
			} break;
case 150:
# line 565 "plot.yacc"
{
			    (curves[curcur])->type = solid;
			    (curves[curcur])->thick = 
				(curves[curcur])->thick * boldthickmul;
			} break;
case 151:
# line 574 "plot.yacc"
{
				if (curcur < 0) nocurverr();
			} break;
case 153:
# line 581 "plot.yacc"
{(curves[curcur])->symbolsize = atoi(yytext);} break;
case 155:
# line 586 "plot.yacc"
{(curves[curcur])->symbol = nonesymbol;} break;
case 156:
# line 588 "plot.yacc"
{(curves[curcur])->symbol = cross;} break;
case 157:
# line 590 "plot.yacc"
{(curves[curcur])->symbol = triangle;} break;
case 158:
# line 592 "plot.yacc"
{(curves[curcur])->symbol = trianglefilled;} break;
case 159:
# line 594 "plot.yacc"
{(curves[curcur])->symbol = diamond;} break;
case 160:
# line 596 "plot.yacc"
{(curves[curcur])->symbol = diamondfilled;} break;
case 161:
# line 598 "plot.yacc"
{(curves[curcur])->symbol = square;} break;
case 162:
# line 600 "plot.yacc"
{(curves[curcur])->symbol = square;} break;
case 163:
# line 602 "plot.yacc"
{(curves[curcur])->symbol = squarefilled;} break;
case 164:
# line 604 "plot.yacc"
{(curves[curcur])->symbol = squarefilled;} break;
case 165:
# line 606 "plot.yacc"
{(curves[curcur])->symbol = rectangle;} break;
case 166:
# line 608 "plot.yacc"
{(curves[curcur])->symbol = rectanglefilled;} break;
case 167:
# line 610 "plot.yacc"
{(curves[curcur])->symbol = circle;} break;
case 168:
# line 612 "plot.yacc"
{(curves[curcur])->symbol = circlefilled;} break;
case 169:
# line 614 "plot.yacc"
{(curves[curcur])->symbol = bullet;} break;
case 170:
# line 616 "plot.yacc"
{(curves[curcur])->symbol = plus;} break;
case 171:
# line 618 "plot.yacc"
{(curves[curcur])->symbol = star;} break;
case 172:
# line 622 "plot.yacc"
{
				if (curcur < 0) nocurverr();
			} break;
case 174:
# line 629 "plot.yacc"
{
				(curves[curcur])->interp = linearinterp;
			} break;
case 175:
# line 633 "plot.yacc"
{
				(curves[curcur])->interp = xhistogram;
				keySpacingMul = keySpacingMul ;/*  * 1.5; */
			} break;
case 176:
# line 638 "plot.yacc"
{
				(curves[curcur])->interp = lregression;
			} break;
case 177:
# line 642 "plot.yacc"
{
				(curves[curcur])->interp = step;
			} break;
case 178:
# line 646 "plot.yacc"
{
				(curves[curcur])->interp = smooth;
			} break;
case 179:
# line 650 "plot.yacc"
{
				(curves[curcur])->interp = smooth;
			} break;
case 180:
# line 654 "plot.yacc"
{
				(curves[curcur])->interp = yhistogram;
				keySpacingMul = keySpacingMul;/* * 1.5; */
			} break;
case 181:
# line 662 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				(curves[curcur])->mat.grayset = TRUE;
				(curves[curcur])->gray = atof(yytext);
			} break;
case 182:
# line 670 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				(curves[curcur])->mat.showline = FALSE;
			} break;
case 183:
# line 677 "plot.yacc"
{
				if (curcur < 0) nocurverr();
				(curves[curcur])->mat.matset = TRUE;
				(curves[curcur])->mat.freq = atof(yytext);
			} break;
case 184:
# line 683 "plot.yacc"
{
				(curves[curcur])->mat.ang = atof(yytext);
			} break;
case 185:
# line 687 "plot.yacc"
{
				(curves[curcur])->mat.indx = atoi(yytext);
			} break;
case 186:
# line 693 "plot.yacc"
{
				curfn = GetSp(FUNCTION_LEN);
			} break;
case 187:
# line 697 "plot.yacc"
{
				curfnstart = atof(yytext);
			} break;
case 188:
# line 702 "plot.yacc"
{
				curfnend = atof(yytext);
			} break;
case 189:
# line 707 "plot.yacc"
{
				curfndelta = atof(yytext);
			} break;
case 190:
# line 711 "plot.yacc"
{
				computfn(curfnstart,curfnend,curfndelta,curfn);
			} break;
case 191:
# line 717 "plot.yacc"
{
				strcat(curfn, yytext);
			} break;
case 192:
# line 721 "plot.yacc"
{
				strcat(curfn, yytext);
			} break;
case 193:
# line 727 "plot.yacc"
{
				if (curcur < 0) nocurverr();
			} break;
case 198:
# line 740 "plot.yacc"
{
				addPointsPair1();
			} break;
case 199:
# line 745 "plot.yacc"
{
				addPointsPair2();
			} break;
case 201:
# line 752 "plot.yacc"
{
				addPointsConf();
			} break;
case 206:
# line 764 "plot.yacc"
{strcat(axis[xpt].label, yytext);} break;
case 207:
# line 766 "plot.yacc"
{strcat(axis[xpt].label, yytext);} break;
case 208:
# line 770 "plot.yacc"
{
				axis[xpt].font = yylval;
			} break;
case 209:
# line 776 "plot.yacc"
{
				axis[xpt].axismax = atof(yytext);
				limits[xpt][maxval] = axis[xpt].axismax;
			} break;
case 210:
# line 783 "plot.yacc"
{
				axis[xpt].axismin = atof(yytext);
				limits[xpt][minval] = axis[xpt].axismin;
			} break;
case 211:
# line 789 "plot.yacc"
{
				axis[xpt].unit = atof(yytext);
			} break;
case 213:
# line 798 "plot.yacc"
{axis[xpt].scale.type = linear;} break;
case 214:
# line 800 "plot.yacc"
{
				axis[xpt].scale.type = logstype;
				axis[xpt].scale.base = 10.0; /* def logbase */
			} break;
case 215:
# line 807 "plot.yacc"
{
				axis[xpt].scale.base = atof(yytext);
			} break;
case 216:
# line 814 "plot.yacc"
{
				axis[xpt].interval = atof(yytext);
			} break;
case 218:
# line 823 "plot.yacc"
{
				axis[xpt].numberstyle = integer;
			} break;
case 219:
# line 827 "plot.yacc"
{
				axis[xpt].numberstyle = floating;
			} break;
case 220:
# line 831 "plot.yacc"
{
				axis[xpt].numberstyle = scientific;
			} break;
case 221:
# line 835 "plot.yacc"
{
				axis[xpt].numberstyle = exponent;
			} break;
case 222:
# line 841 "plot.yacc"
{
				axis[xpt].signif = atof(yytext);
			} break;
case 223:
# line 845 "plot.yacc"
{
				axis[xpt].signif = 1;
			} break;
case 226:
# line 855 "plot.yacc"
{strcat(axis[ypt].label, yytext);} break;
case 227:
# line 857 "plot.yacc"
{strcat(axis[ypt].label, yytext);} break;
case 228:
# line 861 "plot.yacc"
{
				axis[ypt].font = yylval;
			} break;
case 229:
# line 867 "plot.yacc"
{
				axis[ypt].axismax = atof(yytext);
				limits[ypt][maxval] = axis[ypt].axismax;
			} break;
case 230:
# line 874 "plot.yacc"
{
				axis[ypt].axismin = atof(yytext);
				limits[ypt][minval] = axis[ypt].axismin;
			} break;
case 231:
# line 880 "plot.yacc"
{
				axis[ypt].unit = atof(yytext);
			} break;
case 233:
# line 889 "plot.yacc"
{axis[ypt].scale.type = linear;} break;
case 234:
# line 891 "plot.yacc"
{
				axis[ypt].scale.type = logstype;
				axis[ypt].scale.base = 10.0; /* def logbase */
			} break;
case 235:
# line 898 "plot.yacc"
{
				axis[ypt].scale.base = atof(yytext);
			} break;
case 236:
# line 904 "plot.yacc"
{
				axis[ypt].interval = atof(yytext);
			} break;
case 238:
# line 913 "plot.yacc"
{
				axis[ypt].numberstyle = integer;
			} break;
case 239:
# line 917 "plot.yacc"
{
				axis[ypt].numberstyle = floating;
			} break;
case 240:
# line 921 "plot.yacc"
{
				axis[ypt].numberstyle = scientific;
			} break;
case 241:
# line 925 "plot.yacc"
{
				axis[ypt].numberstyle = exponent;
			} break;
case 242:
# line 931 "plot.yacc"
{
				axis[ypt].signif = atof(yytext);
			} break;
case 243:
# line 935 "plot.yacc"
{
				axis[ypt].signif = 1;
			} break; 
		}
		goto yystack;  /* stack new state and value */

	}
