/*
	struct.h	rt1 structure definitions

	Copyright 1984 Terry Disz and Dan Sadowski
*/

#define CMD struct cmd		/*structure for command pointers*/
#define MIB struct mib		/*structure for macro invocation block*/
#define NBLOCK struct nblock	/*structure for name blocks*/
#define OPRTAB struct optab	/*structure for expression operators*/
#define TEMP struct tmp		/* structure for temp objects (string/array)*/
#define UVAL union uval		/*union to hold values*/
#define VAL struct valstk	/*structure for value stack*/
#define TABDAT struct tabdat	/*tablet data structure */

UVAL				/* union to store values */
{
	ITYPE ival;		/*integer value*/
	FTYPE fval;		/*floating point value*/
	char ch;		/*single character*/
	CMD *cmdptr;		/*pointer to command block*/
	TEMP *tptr;		/*pointer to temp list structure*/
	NBLOCK *nptr;		/*pointer to name block*/
	VAL *vptr;		/*pointer to compile block*/
	OPRTAB *optr;		/*pointer to operator table*/
	char *cptr;		/*pointer to character string*/
};

NBLOCK		/*  crt name and command block structure */
{
     TINY type;
     UVAL nvalue;
     BITS flags;
     char *name;		/* pointer to the name */
     NBLOCK *next;		/* link to next block */
};


CMD		/*  crt command name block  */
{
	char *(*funptr)();		/* pointer to the function */
	char *switches;			/* ascii for switches*/
};

OPRTAB		/*  operator table structure*/
{
	char opr0;		/*1st character of operator*/
	char opr1;		/*2nd character of operator*/
	TINY prec;		/*precedence*/
	int (*oprfun)();	/*pointer to operator function*/
};

VAL		/*  value/operand stack structure*/
{
	TINY valtype;		/*value type*/
	TINY valsw;		/*bits for switches*/
	UVAL value;		/*value*/
};

MIB		/*   MIB STRUCTURE  */
{
	TINY miballoc;		/* alloc type - PERM or TEMP */
	TINY mibtype;
	TINY mibargnum;		/* arg error number */
	BITS mibflags;
	MIB *mibnext;		/* free mib list link */
	TEMP *mibstrptr;	/* pointer to TEMP structure with macro */
	char *miblinptr;	/* pointer to line in the macro */
	NBLOCK *miblocptr;	/* list header for local variables */
	MIB *mibcaller;		/* back pointer in mib list */
	MIB *mibbgptr;		/* .b list pointer */
	VAL *mibargptr;		/* pointer to arg list in calling mac*/
	VAL *mibrv;		/* pointer to return value area*/
	char *mibonelpt;	/* onerror line pointer */
	char *mibonelab;	/* onerror label addr */
	short mibfcount;	/* to be used by .f for timeout */
	short mibfnow;		/* current foreground count */
	short mibwcount;	/* count for wait command */
	COORD mibxcurse;	/* old x for line cmd */
	COORD mibycurse;	/* old y */
};

TEMP		/*temp list structure*/
{
	TINY ttype;		/* type of data */
	TINY atype;		/* type of array element */
	TINY aflag;		/* flag for array */
	short use;		/* use count */
	TEMP *tnext;		/* pointer to next list item */
	int size;		/* size of item (in bytes) */
	char *adr;		/* pointer to actual string, array, compiled */
	short dim[4];		/* array dimensions */
	short nexti;		/* next available array element */
};

TABDAT		/* tablet data structure */
{
	int x;			/* tablet x coordinate */
	int y;			/* tablet y coordinate */
	int fcn;		/* tablet function key */
};