home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l200 / 6.ddi / TRAN / AT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-21  |  7.1 KB  |  243 lines

  1. /*    at.h  --  Administrator - Translator Header
  2.  
  3.     Information needed by both the administrative routines 
  4.     and the rest of the translator.
  5.  
  6.     Copyright (c) 1983 by James F. Gimpel
  7.     Copyright (c) 1983, 1984 by JMI Software Consultants, Inc.
  8.     
  9.                 Contents
  10.                 --------
  11.  
  12.     1.    Identification
  13.     
  14.     2.    Tokens
  15.         2.1  Lexical Units (t_)
  16.         2.2  Statement types (st_)
  17.         2.3  Data types (dt_)
  18.         2.4  Operator types (op_)
  19.         2.5     Character types (ct_)
  20.  
  21.     3.    Structures
  22.         3.1  str_tok
  23.         3.2  opstruct
  24.  
  25.     */
  26.  
  27. #include "acom.h"
  28.  
  29. /*    2.    Tokens
  30.  
  31.     A token is a quantity returned by the lexical analyzer
  32.     (t_...) or statement analyzer (st_...) or used to designate
  33.     an operator (op_...) or datatype (dt_...) and in addition has 
  34.     numerous other uses.
  35. */
  36.  
  37. /*    2.1  Lexical tokens (t_) and associated flags (tf_).
  38. */
  39.  
  40. #define tf_STMT 0002000 /* a statement */
  41. #define tf_CAST    0004000    /* one of CDBL, CINT, CSNG */
  42. #define tf_OP    0010000 /* OPerator FLAG */
  43. #define tf_LPAR    0020000    /* must be followed by a left paren */
  44. #define tf_BFUN 0040000    /* Function Flag */
  45. #define tf_PART 0100000    /* Forms only part of a total identifier */
  46.  
  47. #define   t_IDENT    1    /*  Identifier  */
  48. #define   t_STRING    2    /*  String constant  */
  49. #define   t_INT        3    /*  Integer constant */
  50. #define   t_DBL        4    /*  Floating double constant  */
  51. #define   t_FLOAT    5    /*  Floating constant  */
  52. #define   t_COLON    6
  53. #define   t_COMMA    7
  54. #define   t_LP        8    /*  Left parenthesis  */
  55. #define   t_RP        9    /*  Right parenthesis */
  56. #define   t_TO        10
  57. #define   t_STEP    11
  58. #define   t_THEN    12
  59. #define   t_GOTO    13
  60. #define   t_ILL        14    /*  Illegal token */
  61. #define   t_EOS        15    /*  End of statement  */
  62. #define   t_NONE    16    /*  Denotes absence of a token  */
  63. #define   t_BNDSEP    17    /*  Bounds separator for multi-dimensioning */
  64. #define   t_OP        18    /*  Operator  */
  65. #define   t_SEMI    19    /*    Semi-colon */
  66. #define   t_UFN        20    /*    User-defined function  */
  67. #define   t_BFN        21    /*    Built-in FunctioN    */
  68. #define      t_SHARP    22    /*  A # character */
  69. #define   t_GOSUB    23    /*  the GOSUB keyword */
  70. #define      t_END        24    /*  END as it appears in a then clause */
  71. #define      t_CAST    25    /*    One of CINT, CSNG, CDBL */
  72. #define   t_ELSE    26    /*    ELSE  */
  73. #define   t_AS        27    /*  AS    */
  74. #define   t_USING    28    /*    USING  */
  75. #define   t_INPUT    31    /*    2nd half of line input */
  76. #define   t_ERROR    32
  77. #define   t_NEXT    33
  78. #define   t_REM        34
  79. #define t_OUT        35
  80. #define t_APP        36
  81. #define t_FOR        37
  82. #define    t_SPC        38
  83. #define t_TAB        39
  84. #define t_BASE        40
  85. #define t_RAND        41
  86. #define t_WAIT        42
  87.  
  88. /*  2.2  Statement Types (st_) and associated flags (stf_).
  89. */
  90.  
  91. #define stf_GENERIC 01000  /* arguments described by pattern,
  92.                               see 3.3 */
  93.  
  94. #define st_DATA        tf_STMT + 1
  95. #define st_DEF        tf_STMT + 2
  96. #define st_DIM        tf_STMT + 3
  97. #define st_END        tf_STMT + 4
  98. #define st_FOR        tf_STMT + 5
  99. #define st_GOSUB    tf_STMT + 6
  100. #define st_GOTO        tf_STMT + 7
  101. #define st_IF        tf_STMT + 8
  102. #define st_LET        tf_STMT + 9
  103. #define st_NEXT        tf_STMT + 10
  104. #define st_ON        tf_STMT + 11
  105. #define st_PRINT    tf_STMT + 12
  106. #define st_COMMON    tf_STMT + 13
  107. #define st_READ        tf_STMT + 14
  108. #define st_REM        tf_STMT + 15
  109. #define st_RET        tf_STMT + 16
  110. #define st_OPTION    tf_STMT + 22
  111. #define st_INPUT    tf_STMT + 24
  112. #define st_CALL     tf_STMT + 25
  113. #define st_DDBL     tf_STMT + 27    /* DEFDBL */
  114. #define st_DINT        tf_STMT + 28    /* DEFINT */
  115. #define st_DSNG        tf_STMT + 29    /* DEFSNG */
  116. #define st_DSTR        tf_STMT + 30    /* DEFSTR */
  117. #define st_LINE        tf_STMT + 31    /* LINE input */
  118. #define st_NONE        tf_STMT + 32    /* No keyword found */
  119. #define st_SWAP        tf_STMT + 35    /* SWAP statement */
  120. #define st_WEND        tf_STMT + 36    /* WEND statement */
  121. #define st_WHILE    tf_STMT + 37    /* WHILE statement */
  122. #define st_FIELD    tf_STMT + 38    /* FIELD statement */
  123. #define st_NULL        tf_STMT + 42    /* NULL statement */
  124. #define st_INCLUDE    tf_STMT + 43    /* %INCLUDE directive */
  125. #define st_IGNORE    tf_STMT + 44    /* Ignore this statement */
  126. #define st_PRAT        tf_STMT + 45    /* PRINT@ */
  127. #define st_LPRINT    tf_STMT + 46    /* LPRINT */
  128. #define st_ELSE        tf_STMT + 48    /* ELSE */
  129. #define st_RESUME    tf_STMT + 49    /* RESUME */
  130. #define st_RUN        tf_STMT + 50    /* RUN */
  131. #define st_ERASE    tf_STMT + 51    /* ERASE */
  132. #define st_WRITE    tf_STMT + 52    /* WRITE */
  133.  
  134. /*    2.3  Data types (dt_)
  135. */
  136.  
  137. #define dt_INT        1    /* Integer */
  138. #define dt_FLOAT    2    /* Float   */
  139. #define dt_DBL        3    /* Double  */
  140. #define dt_BOOL        1    /* Boolean (same as Integer) */
  141. #define dt_RBOOL    4    /* Relational Boolean (ie. result of a comparison) */
  142. #define dt_STR        5    /* String  */
  143. #define dt_VOID        6    /* no result */
  144. #define dt_ADDR        7    /* Address */
  145. #define dt_ANY        8    /* A pattern to match any type */
  146. #define dt_PRED        9    /* IF style predicate */
  147. #define dt_UINT        10    /* Unsigned Integer */
  148.  
  149. /*    dt flags and masks  */
  150.  
  151. #define dtf_COERC    0100    /* coercion needed */
  152. #define DT_FLD 017    /* A mask for the data-type field */
  153. #define DT_SHIFT 4    /* The no. of bits in DT_FLD */
  154.  
  155. /*    2.4  Operators
  156. */
  157.  
  158. #define  op_FENCE    tf_OP + 1    /* last operator in table */
  159. #define  op_PLUS    tf_OP + 2
  160. #define  op_MINUS    tf_OP + 3
  161. #define  op_MUL        tf_OP + 4
  162. #define  op_DIV        tf_OP + 5
  163. #define  op_EXPON    tf_OP + 6
  164. #define  op_GT        tf_OP + 7
  165. #define  op_GE        tf_OP + 8
  166. #define  op_EQ        tf_OP + 9
  167. #define  op_NE        tf_OP + 10
  168. #define  op_LT        tf_OP + 11
  169. #define  op_LE        tf_OP + 12
  170. #define  op_NOT        tf_OP + 13
  171. #define  op_OR        tf_OP + 14
  172. #define  op_AND        tf_OP + 15
  173. #define     op_XOR        tf_OP + 16
  174. #define  op_EQV        tf_OP + 17
  175. #define  op_IMP        tf_OP + 18
  176. #define  op_ADDR    tf_OP + 19
  177. #define  op_MOD        tf_OP + 20
  178. #define  op_IDIV    tf_OP + 21
  179.  
  180. /*  2.5  Character types
  181.           On input each character is identified as being a 
  182.           member of one of the following classes.
  183.           These classes almost partition the set of characters.
  184. */
  185.  
  186. #define  ct_ILL        1    /* Illegal */
  187. #define  ct_LET        2    /* Letter  */
  188. #define  ct_DIGIT    3    /* Digit   */
  189. #define  ct_QT        4    /* one of the Quotes */
  190. #define  ct_STAR    5    /* asterisk */
  191. #define  ct_REL        7    /* Relational operator */
  192. #define  ct_DOL        8    /* Dollar sign */
  193. #define  ct_MINUS    9    /* Minus sign */
  194. #define     ct_AMPER    10    /* Ampersand (&) */
  195. #define  ct_PER        11    /* Period */
  196.  
  197. /*    The following flags enable sets of character types to
  198.     be formed.
  199. */
  200.  
  201. #define    ctf_ID  0040    /* Identifier characters */
  202. #define ctf_CID 0100    /* C Identifier characters */
  203. #define ctf_SIMP 020    /* a simple (self-contained) token */
  204.  
  205. #define CT_FLD  0017    /* used to select the ct_ portion */
  206.  
  207. /*    Some special combinations follow  */
  208.  
  209. #define CT_DIGIT (ct_DIGIT|ctf_ID|ctf_CID)
  210. #define CT_LET   (ct_LET|ctf_ID|ctf_CID)
  211.  
  212. /*    3.  Structures  */
  213.  
  214. /*    3.1        str_tok
  215.  
  216.     a structure that associates a string with
  217.     a token.
  218. */
  219.  
  220. typedef struct str_tok
  221.     {
  222.     TEXT *sk_str;
  223.     TOKEN sk_int;
  224.     TBOOL sk_err;
  225.     } STRTOK;
  226.  
  227. /*    3.2        opstruct
  228.  
  229.     This structure defines the format of the operator table.
  230.     Expressions are table-driven from an array of these.
  231. */
  232.  
  233. typedef struct opstruct
  234.     {
  235.     TOKEN op_tok;        /* associated token */
  236.     COUNT op_nargs;        /* Number of arguments */
  237.     TINY op_prec;        /* precedence */
  238.     TINY op_lr;            /* YES if left-to-right */
  239.     TEXT *op_trans;        /* translation prototype */
  240.     TOKEN op_argtp;        /* argument(s) type */
  241.     TOKEN op_restp;        /* result type */
  242.     } OPDEF;
  243.