home *** CD-ROM | disk | FTP | other *** search
- /* at.h -- Administrator - Translator Header
-
- Information needed by both the administrative routines
- and the rest of the translator.
-
- Copyright (c) 1983 by James F. Gimpel
- Copyright (c) 1983, 1984 by JMI Software Consultants, Inc.
-
- Contents
- --------
-
- 1. Identification
-
- 2. Tokens
- 2.1 Lexical Units (t_)
- 2.2 Statement types (st_)
- 2.3 Data types (dt_)
- 2.4 Operator types (op_)
- 2.5 Character types (ct_)
-
- 3. Structures
- 3.1 str_tok
- 3.2 opstruct
-
- */
-
- #include "acom.h"
-
- /* 2. Tokens
-
- A token is a quantity returned by the lexical analyzer
- (t_...) or statement analyzer (st_...) or used to designate
- an operator (op_...) or datatype (dt_...) and in addition has
- numerous other uses.
- */
-
- /* 2.1 Lexical tokens (t_) and associated flags (tf_).
- */
-
- #define tf_STMT 0002000 /* a statement */
- #define tf_CAST 0004000 /* one of CDBL, CINT, CSNG */
- #define tf_OP 0010000 /* OPerator FLAG */
- #define tf_LPAR 0020000 /* must be followed by a left paren */
- #define tf_BFUN 0040000 /* Function Flag */
- #define tf_PART 0100000 /* Forms only part of a total identifier */
-
- #define t_IDENT 1 /* Identifier */
- #define t_STRING 2 /* String constant */
- #define t_INT 3 /* Integer constant */
- #define t_DBL 4 /* Floating double constant */
- #define t_FLOAT 5 /* Floating constant */
- #define t_COLON 6
- #define t_COMMA 7
- #define t_LP 8 /* Left parenthesis */
- #define t_RP 9 /* Right parenthesis */
- #define t_TO 10
- #define t_STEP 11
- #define t_THEN 12
- #define t_GOTO 13
- #define t_ILL 14 /* Illegal token */
- #define t_EOS 15 /* End of statement */
- #define t_NONE 16 /* Denotes absence of a token */
- #define t_BNDSEP 17 /* Bounds separator for multi-dimensioning */
- #define t_OP 18 /* Operator */
- #define t_SEMI 19 /* Semi-colon */
- #define t_UFN 20 /* User-defined function */
- #define t_BFN 21 /* Built-in FunctioN */
- #define t_SHARP 22 /* A # character */
- #define t_GOSUB 23 /* the GOSUB keyword */
- #define t_END 24 /* END as it appears in a then clause */
- #define t_CAST 25 /* One of CINT, CSNG, CDBL */
- #define t_ELSE 26 /* ELSE */
- #define t_AS 27 /* AS */
- #define t_USING 28 /* USING */
- #define t_INPUT 31 /* 2nd half of line input */
- #define t_ERROR 32
- #define t_NEXT 33
- #define t_REM 34
- #define t_OUT 35
- #define t_APP 36
- #define t_FOR 37
- #define t_SPC 38
- #define t_TAB 39
- #define t_BASE 40
- #define t_RAND 41
- #define t_WAIT 42
-
- /* 2.2 Statement Types (st_) and associated flags (stf_).
- */
-
- #define stf_GENERIC 01000 /* arguments described by pattern,
- see 3.3 */
-
- #define st_DATA tf_STMT + 1
- #define st_DEF tf_STMT + 2
- #define st_DIM tf_STMT + 3
- #define st_END tf_STMT + 4
- #define st_FOR tf_STMT + 5
- #define st_GOSUB tf_STMT + 6
- #define st_GOTO tf_STMT + 7
- #define st_IF tf_STMT + 8
- #define st_LET tf_STMT + 9
- #define st_NEXT tf_STMT + 10
- #define st_ON tf_STMT + 11
- #define st_PRINT tf_STMT + 12
- #define st_COMMON tf_STMT + 13
- #define st_READ tf_STMT + 14
- #define st_REM tf_STMT + 15
- #define st_RET tf_STMT + 16
- #define st_OPTION tf_STMT + 22
- #define st_INPUT tf_STMT + 24
- #define st_CALL tf_STMT + 25
- #define st_DDBL tf_STMT + 27 /* DEFDBL */
- #define st_DINT tf_STMT + 28 /* DEFINT */
- #define st_DSNG tf_STMT + 29 /* DEFSNG */
- #define st_DSTR tf_STMT + 30 /* DEFSTR */
- #define st_LINE tf_STMT + 31 /* LINE input */
- #define st_NONE tf_STMT + 32 /* No keyword found */
- #define st_SWAP tf_STMT + 35 /* SWAP statement */
- #define st_WEND tf_STMT + 36 /* WEND statement */
- #define st_WHILE tf_STMT + 37 /* WHILE statement */
- #define st_FIELD tf_STMT + 38 /* FIELD statement */
- #define st_NULL tf_STMT + 42 /* NULL statement */
- #define st_INCLUDE tf_STMT + 43 /* %INCLUDE directive */
- #define st_IGNORE tf_STMT + 44 /* Ignore this statement */
- #define st_PRAT tf_STMT + 45 /* PRINT@ */
- #define st_LPRINT tf_STMT + 46 /* LPRINT */
- #define st_ELSE tf_STMT + 48 /* ELSE */
- #define st_RESUME tf_STMT + 49 /* RESUME */
- #define st_RUN tf_STMT + 50 /* RUN */
- #define st_ERASE tf_STMT + 51 /* ERASE */
- #define st_WRITE tf_STMT + 52 /* WRITE */
-
- /* 2.3 Data types (dt_)
- */
-
- #define dt_INT 1 /* Integer */
- #define dt_FLOAT 2 /* Float */
- #define dt_DBL 3 /* Double */
- #define dt_BOOL 1 /* Boolean (same as Integer) */
- #define dt_RBOOL 4 /* Relational Boolean (ie. result of a comparison) */
- #define dt_STR 5 /* String */
- #define dt_VOID 6 /* no result */
- #define dt_ADDR 7 /* Address */
- #define dt_ANY 8 /* A pattern to match any type */
- #define dt_PRED 9 /* IF style predicate */
- #define dt_UINT 10 /* Unsigned Integer */
-
- /* dt flags and masks */
-
- #define dtf_COERC 0100 /* coercion needed */
- #define DT_FLD 017 /* A mask for the data-type field */
- #define DT_SHIFT 4 /* The no. of bits in DT_FLD */
-
- /* 2.4 Operators
- */
-
- #define op_FENCE tf_OP + 1 /* last operator in table */
- #define op_PLUS tf_OP + 2
- #define op_MINUS tf_OP + 3
- #define op_MUL tf_OP + 4
- #define op_DIV tf_OP + 5
- #define op_EXPON tf_OP + 6
- #define op_GT tf_OP + 7
- #define op_GE tf_OP + 8
- #define op_EQ tf_OP + 9
- #define op_NE tf_OP + 10
- #define op_LT tf_OP + 11
- #define op_LE tf_OP + 12
- #define op_NOT tf_OP + 13
- #define op_OR tf_OP + 14
- #define op_AND tf_OP + 15
- #define op_XOR tf_OP + 16
- #define op_EQV tf_OP + 17
- #define op_IMP tf_OP + 18
- #define op_ADDR tf_OP + 19
- #define op_MOD tf_OP + 20
- #define op_IDIV tf_OP + 21
-
- /* 2.5 Character types
- On input each character is identified as being a
- member of one of the following classes.
- These classes almost partition the set of characters.
- */
-
- #define ct_ILL 1 /* Illegal */
- #define ct_LET 2 /* Letter */
- #define ct_DIGIT 3 /* Digit */
- #define ct_QT 4 /* one of the Quotes */
- #define ct_STAR 5 /* asterisk */
- #define ct_REL 7 /* Relational operator */
- #define ct_DOL 8 /* Dollar sign */
- #define ct_MINUS 9 /* Minus sign */
- #define ct_AMPER 10 /* Ampersand (&) */
- #define ct_PER 11 /* Period */
-
- /* The following flags enable sets of character types to
- be formed.
- */
-
- #define ctf_ID 0040 /* Identifier characters */
- #define ctf_CID 0100 /* C Identifier characters */
- #define ctf_SIMP 020 /* a simple (self-contained) token */
-
- #define CT_FLD 0017 /* used to select the ct_ portion */
-
- /* Some special combinations follow */
-
- #define CT_DIGIT (ct_DIGIT|ctf_ID|ctf_CID)
- #define CT_LET (ct_LET|ctf_ID|ctf_CID)
-
- /* 3. Structures */
-
- /* 3.1 str_tok
-
- a structure that associates a string with
- a token.
- */
-
- typedef struct str_tok
- {
- TEXT *sk_str;
- TOKEN sk_int;
- TBOOL sk_err;
- } STRTOK;
-
- /* 3.2 opstruct
-
- This structure defines the format of the operator table.
- Expressions are table-driven from an array of these.
- */
-
- typedef struct opstruct
- {
- TOKEN op_tok; /* associated token */
- COUNT op_nargs; /* Number of arguments */
- TINY op_prec; /* precedence */
- TINY op_lr; /* YES if left-to-right */
- TEXT *op_trans; /* translation prototype */
- TOKEN op_argtp; /* argument(s) type */
- TOKEN op_restp; /* result type */
- } OPDEF;