home *** CD-ROM | disk | FTP | other *** search
- /* bsdefs.h -- definition file for bs.
- */
-
- #include <stdio.h>
- #include <ctype.h>
-
- /* 'Machine' status */
- extern int status;
- #define M_COMPILE (1<<0)
- #define M_EXECUTE (1<<1)
- #define M_INPUT (1<<2)
- #define M_FIXUP (1<<3)
- #define M_READ (1<<4)
-
- #define XMODE (M_COMPILE|M_EXECUTE|M_INPUT|M_FIXUP|M_READ)
-
-
- /* line table. */
- #define LASTLINE (struct line *)(&lastline)
-
- struct line {
- struct line *nextline; /* next entry in list. */
- int lnum; /* its' number */
- int (*list)(); /* its' definition */
- char *text; /* the original definition */
- };
-
- extern struct line firstline,lastline,*curline;
-
-
- /* Variable types */
- #define Q_NRM 0 /* nice, ordinary variable */
- #define Q_ARY 1 /* array */
- #define Q_BF 2 /* builtin-function */
- #define Q_UFL 3 /* long user function */
- #define Q_UFS 4 /* short user function */
-
- /* in type part, a zero value is an undefined type. */
- #define T_INT (1<<6)
- #define T_CHR (2<<6)
- #define T_DBL (3<<6)
- #define T_LBL (4<<6)
-
- #define T_QMASK 037 /* lower 5 bits for type qualifier */
- #define T_TMASK (T_INT|T_CHR|T_DBL|T_LBL)
-
- /* variable table */
- #define VLSIZ 150
-
- struct label {
- char *name; /* what do we call it by. */
- int (*where)(); /* and where does it live */
- };
- /* For arrays, storage of them is defined as follows:
- *
- * 1st item: number of dimensions in array <NDIMS>.
- * next <NDIMS> items: size of each dimension.
- * rest of items: the actual values.
- *
- * Until we can support varrying sized arrays this is the setup:
- *
- * 1,10,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10
- *
- * for a total size of 13 items.
- */
- union value {
- long ival; /* T_INT */
- double rval; /* T_DBL */
- char *sval; /* T_CHR */
- struct label lval; /* T_LBL */
- struct line *locval; /* for pushing line# list entries */
- union value *arval; /* any+Q_ARY */
- struct dictnode *vpval; /* for use when pushing variable pointers */
- union value *plval; /* for use when pushing pointers to a value */
- };
-
- struct dictnode { /* format of vlist entry */
- struct dictnode *father,*daughter; /* doubly-linked list. */
- char *name; /* name of entry. */
- int type_of_value; /* its type. */
- union value val; /* and its value */
- };
-
- extern struct dictnode *dicthead,*dictail,*curvp;
-
- /* '_' Function table */
- extern
- _print(), _goto(), _if(), _else(),
- _for(), _next(), _read(), _data(),
- _dsep(), _spop(), _pop(), _stop(),
- _end(), _dlabel(), _rlabel(), _contin(),
- _leave(), _enter(), _exitlp(), _iadd(),
- _isub(), _imult(), _idiv(), _imod(),
- _comma(), _radd(), _rsub(), _rmult(),
- _rdiv(), _scolon(), _gosub(), _return(),
- _not(), _ieq(), _req(), _seq(),
- _ineq(), _rneq(), _sneq(), _ileq(),
- _rleq(), _sleq(), _ilt(), _rlt(),
- _slt(), _igeq(), _rgeq(), _sgeq(),
- _igt(), _rgt(), _sgt(), _or(),
- _and(), _itoa(), _rtoa(), _itor(),
- _rtoi(), _pushstate(), _popstate(), _scon(),
- _rcon(), _icon(), _val(), _store(),
- _var();
-
- /*
- * Data table.
- * Array of pointers into llist.
- * Each is a line which has data.
- */
- #define DLSIZ 100
- extern struct line *dlist[]; /* actual table, number of elems. is DLSIZ */
- extern int dlp; /* index into dlist for current line of data */
- extern int dlindx; /* index into current line for current data item. */
- extern int dtype; /* in M_READ, operators set this to the type of
- * their operation. When the expression is done
- * executing, this variable will indicate its type.
- */
-
- /* error routines */
- extern int ULerror();
- extern int STerror();
- extern int FNerror();
- extern int ODerror();
- extern int BDerror();
- extern int VTerror();
-
-
- /*
- * unions for storing data types in the code list
- *
- * Used to convert from a double (for instance) into "int" sized chunks
- * for the purpose of manipulating instances of them in code lists.
- */
-
-
- union doni {
- double d_in_doni;
- int i_in_doni[sizeof(double)/sizeof(int)];
- };
- union loni {
- long l_in_loni;
- int i_in_loni[sizeof(long)/sizeof(int)];
- };
- union voni {
- union value v_in_voni;
- int i_in_voni[sizeof(union value)/sizeof(int)];
- };
-
-
- /* miscellaneous definitions. */
-
- #define STKSIZ 500
- extern union value stack[];
- extern int stackp;
- extern int push();
- extern union value pop();
-
- #define CSTKSIZ 5
- #define BFSIZ 200 /* input buffer */
- extern char pbbuf[]; /* unput() buffer */
- extern char ibuf[];
- extern int iptr,pbptr;
- extern char input();
- extern rdlin(),unput();
-
- extern blcpy();
-
- extern char bslash();
- extern char *scon_in();
- extern int num_in();
-
- extern char *myalloc();
- extern union value *getplace();
- extern struct line *gllentry();
-
- extern FILE *bsin;
-
- extern int dbg; /* debugging flag. */
- extern long atol();
- extern double atof();
-