home *** CD-ROM | disk | FTP | other *** search
- /* COM - Common constants, types and declarations
- for BASTOC
-
- Copyright (c) 1983 by James F. Gimpel
- Copyright (c) 1983, 1984, 1985 by JMI Software Consultants, Inc.
-
- Not included here are constants and declarations required
- to build customizable tables defined in the administrative
- module. These are found in at.h
-
- Contents:
-
- 1. Manifest Constants and Macros
- 1.1 System Dependent Constants
- 1.2 Version (of Basic) Dependencies
- 1.3 Limits
- 1.4 Tokens
- 1.4.1 Allocation types (at_)
- 1.4.2 Symbol table ops
- 1.5 Buffered I/O constants
- 1.6 Miscellaneous constants
- 1.7 Macros
- 1.8 Unreachable code constants
-
- 2. Typedef's
-
- 3. Structure Declarations
- 3.1 attr
- 3.2 bnd_info
- 3.3 dim_info
- 3.4 lineinfo
- 3.5 scan_buf
- 3.6 sym
- 3.7 symtab
- 3.8 bfstruct
-
- */
-
- #include "at.h"
-
- /* 1. Manifest Constants
- */
-
- /* 1.3 Limits
- */
-
- #define MAXINC 6 /* Maximum include level */
- #define li_LEN 257 /* Line length (input line) */
- #define MAXWS 20 /* Maximum Write Stack */
- #define MAXFNL 100 /* Maximum file name length */
- #define SP_LEN 1000 /* Size of Semi-Permanent String Store blocks */
- #define tok_LEN li_LEN /* Maximum token size */
- #define MAXFLDS 100 /* Maximum no. of fields in a FIELD stmt */
- #define MAXEBUF 2000 /* Maximum size for BASIC statement storage */
-
- /* 1.4 Miscellaneous Tokens
- */
-
- /* 1.4.1 Allocation types
- one for each type of block allocated
- */
-
- #define at_SYMBOL 1 /* element of a symbol table */
- #define at_SYMTAB 2 /* symbol table root */
- #define at_DIMINFO 3 /* one dimension of an array */
-
- /* 1.4.2 Symbol Table Operations
- */
-
- #define LOCATE 1 /* Locate Symbol in Table */
- #define INSTALL 2 /* Insert if not found */
- #define INSERT 3 /* Insert only */
- #define FINSTALL 4 /* Insert into function's local symbol table */
-
- /* 1.5 Constants associated with buffered I/O
- */
-
- #define sf_NULL -1 /* Null Device */
- #define sf_IN 0 /* Standard INput */
- #define sf_OUT 1 /* Standard OUTput */
- #define sf_ERR 2 /* Standard ERRor */
- #define IN_SLOT 3 /* regular input slot */
- #define OUT_SLOT 4 /* regular output slot */
- #define DEF_SLOT 5 /* DEF output slot */
- #define SUB_SLOT 6 /* subroutine output slot */
- #define COM_SLOT 7 /* COMMON output slot */
- #define FUN_SLOT 8 /* main(){} output slot for pgm with FIELD stmts */
- #define INC_SLOTS 9 /* the first of the include slots */
-
- #define NSLOTS INC_SLOTS + MAXINC
-
- #define BBUFSIZE 256 /* Basic BUFfer SIZE */
-
- /* 1.6 Miscellany
- */
-
- #define EOS -1 /* End of statement */
-
-
- /* 1.7 Macros
- */
-
- #define isgrey(x) ((x)==' ' || (x)=='\t')
-
- /* 1.8 Unreachable code constants
- */
-
- #define dis_INCOM 001 /* In comment */
- #define dis_NW 002 /* Newline */
- #define dis_CHGPROC 004 /* Change procedure */
- #define dis_LABEL 010 /* Label (no indent) */
-
- /* 2. Typedefs -- Types not defined are here are defined
- in acom.h or appear with structures.
- */
-
- typedef BITS TRBITS; /* Trace Bits */
-
- /* 3. Structure declarations
- */
-
- /* 3.1 attr
-
- An ATTRibute structure encapsulates the result of translation
- */
-
- struct attr
- {
- STRING a_str;
- BITS a_flags;
- TOKEN a_type;
- };
- typedef struct attr ATTR;
-
- #define a_CONST 01 /* Constant expression */
- #define a_NEG 02 /* Explicit Negative sign */
- #define a_ONE 04 /* The constant 1 (+ or -) */
- #define a_LHS 010 /* The result is a valid left-hand-side */
- #define a_FLD 020 /* a field was encountered */
- #define a_SLH 040 /* same primary as left hand side of assignment */
- #define a_MM 0100 /* expression equivalent to --var */
- #define a_PP 0200 /* expression equivalent to ++var */
- #define a_PA 0400 /* expression equivalent to x += y */
- #define a_MA 01000 /* expression equivalent to x -= y */
-
- /*
- #define a_VAR 0x0010 */ /* just a variable name (scalar or array) */
- /*
- #define a_ARR 0x0020 */ /* array element */
-
-
- /* 3.3 dim_info
-
- dim_info gives all the information for one dimension;
- a two dimensional array requires two of these, etc.
- */
-
- struct dim_info
- {
- struct dim_info *dim_next;
- COUNT dim_int; /* either a constant bound or an index
- to a multiplier variable */
- };
- typedef struct dim_info DIMINFO;
-
- /* 3.4 lineinfo
-
- lineinfo is a structure containing the current line
- together with the current position within it.
- */
-
- struct lineinfo
- {
- STRING li_ch;
- STRING li_ptr;
- };
- typedef struct lineinfo LINEINFO;
-
- /* 3.5 scan_buf
-
- This structure enables the scanner to save state
- */
-
- struct scan_buf
- {
- STRING sb_ptr; /* pointer into current input line */
- COUNT sb_char; /* current character */
- };
- typedef struct scan_buf SCANBUF;
-
- /* 3.6 sym
-
- One of these structures is allocated for each symbol.
- */
-
- typedef struct sym
- {
- struct sym *sym_lson, *sym_rson;
- BITS sym_flags;
- STRING sym_name;
- TOKEN sym_type; /* token of the form dt_... */
- TINY *sym_ptr; /* a pointer to ancillary information */
- COUNT sym_int; /* a handy, multi-purpose integer -- see below */
- COUNT sym_pre; /* name prefix code for de-conflicting */
- } *SYMBOL;
-
- #define sym_pno sym_int /* procedure no. */
- #define sym_nd sym_int /* No. of dimension */
- #define sym_level sym_type /* Label level no. */
-
- #define sym_CNC 01 /* Created Name Conflict */
- #define sym_ARR 02 /* An Array */
- #define sym_DLBL 04 /* A defined (and referenced) label */
- #define sym_DEF 010 /* a DEFined function */
- #define sym_DUM 020 /* a dummy parameter of a DEFine stmt */
- #define sym_TOL 040 /* a GOTO label */
- #define sym_SUL 0100 /* a GOSUB label */
- #define sym_BFN 0200 /* a built-in function */
- #define sym_FIRST 0400 /* the first label */
- #define sym_DCL 01000 /* Declared type */
- #define sym_FLD 02000 /* An identifier of a FIELD stmt */
- #define sym_FVAR 04000 /* The function variable */
- #define sym_DARR 010000 /* Dynamic array, implies sym_ARR */
- #define sym_SUB 020000 /* subroutines inside a defined function */
- #define sym_COM 040000 /* this is a common variable */
-
- typedef struct
- {
- struct symtab *fi_labels; /* symbol table for labels in function */
- struct symtab *fi_scalars; /* symbol table for scalars in function */
- TEXT *fi_trap; /* trap list for function */
- BOOL fi_onerrors; /* ON ERROR GOTOs in function */
- BOOL fi_ifends; /* IF ENDS in function */
- COUNT fi_tmps; /* number of string temps in function */
- } FUNCINFO;
-
- /* 3.7 symtab
-
- One of these is allocated for each symbol table.
- It is really a symbol table root.
- */
-
- struct symtab
- {
- SYMBOL st_head; /* The head of the tree of symbols */
- STRING st_name; /* The symbol name */
- TOKEN st_type; /* an allocation type */
- };
- typedef struct symtab SYMTAB;
-
- #define ST_ARRAY 0 /* symbol table(s) for arrays */
- #define ST_SCALAR 1 /* symbol table(s) for scalars */
- #define ST_LABEL 2 /* symbol table(s) for labels */
- #define ST_FUNC 3 /* symbol table for functons */
- #define ST_SEARCH 4 /* ??? */
-
- /* 3.8 bfstruct
- One of these is allocated for each open file.
- */
-
- struct bfstruct
- {
- FILE bf_fd; /* file descriptor */
- STRING bf_buf; /* points to buffer */
- STRING bf_bufptr; /* current position within buffer */
- COUNT bf_reclen; /* record or buffer length */
- COUNT bf_count; /* chars. or pos. remaining in buffer */
- BITS bf_flags;
- TEXT bf_char; /* place to store an unget */
- };
- typedef struct bfstruct BF;
-
- /* bf_flags */
-
- #define bf_ASSOC 01 /* slot is in use */
- #define bf_READ 02 /* open for reading */
- #define bf_WRITE 04 /* open for writing */
- #define bf_ERROR 010 /* an error has been detected */
- #define bf_CHAR 020 /* bf_char holds a character */
- #define bf_EOF 040 /* end-of-file has been pushed back */
-
- /* 4. Diagnostic Trace Control
-
- */
-
-
- #ifdef TRACE
- #define TRACE0(x,a) tr_form(x,a)
- #define TRACE1(x,a,b) tr_form(x,a,b)
- #define TRACE2(x,a,b,c) tr_form(x,a,b,c)
- #define TRACE3(x,a,b,c,d) tr_form(x,a,b,c,d)
- #define TRACE4(x,a,b,c,d,e) tr_form(x,a,b,c,d,e)
- #define TRACE5(x,a,b,c,d,e,f) tr_form(x,a,b,c,d,e,f)
- #define TRACE6(x,a,b,c,d,e,f,g) tr_form(x,a,b,c,d,e,f,g)
-
- #else
- #define TRACE0(x,a)
- #define TRACE1(x,a,b)
- #define TRACE2(x,a,b,c)
- #define TRACE3(x,a,b,c,d)
- #define TRACE4(x,a,b,c,d,e)
- #define TRACE5(x,a,b,c,d,e,f)
- #define TRACE6(x,a,b,c,d,e,f,g)
- #endif