home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / mip / manifest < prev    next >
Encoding:
Text File  |  1979-01-10  |  5.9 KB  |  319 lines

  1.  
  2. # include <stdio.h>
  3. /*    manifest constant file for the lex/yacc interface */
  4.  
  5. # define ERROR 1
  6. # define NAME 2
  7. # define STRING 3
  8. # define ICON 4
  9. # define FCON 5
  10. # define PLUS 6
  11. # define MINUS 8
  12. # define MUL 11
  13. # define AND 14
  14. # define OR 17
  15. # define ER 19
  16. # define QUEST 21
  17. # define COLON 22
  18. # define ANDAND 23
  19. # define OROR 24
  20.  
  21. /*    special interfaces for yacc alone */
  22. /*    These serve as abbreviations of 2 or more ops:
  23.     ASOP    =, = ops
  24.     RELOP    LE,LT,GE,GT
  25.     EQUOP    EQ,NE
  26.     DIVOP    DIV,MOD
  27.     SHIFTOP    LS,RS
  28.     ICOP    ICR,DECR
  29.     UNOP    NOT,COMPL
  30.     STROP    DOT,STREF
  31.  
  32.     */
  33. # define ASOP 25
  34. # define RELOP 26
  35. # define EQUOP 27
  36. # define DIVOP 28
  37. # define SHIFTOP 29
  38. # define INCOP 30
  39. # define UNOP 31
  40. # define STROP 32
  41.  
  42. /*    reserved words, etc */
  43. # define TYPE 33
  44. # define CLASS 34
  45. # define STRUCT 35
  46. # define RETURN 36
  47. # define GOTO 37
  48. # define IF 38
  49. # define ELSE 39
  50. # define SWITCH 40
  51. # define BREAK 41
  52. # define CONTINUE 42
  53. # define WHILE 43
  54. # define DO 44
  55. # define FOR 45
  56. # define DEFAULT 46
  57. # define CASE 47
  58. # define SIZEOF 48
  59. # define ENUM 49
  60.  
  61.  
  62. /*    little symbols, etc. */
  63. /*    namely,
  64.  
  65.     LP    (
  66.     RP    )
  67.  
  68.     LC    {
  69.     RC    }
  70.  
  71.     LB    [
  72.     RB    ]
  73.  
  74.     CM    ,
  75.     SM    ;
  76.  
  77.     */
  78.  
  79. # define LP 50
  80. # define RP 51
  81. # define LC 52
  82. # define RC 53
  83. # define LB 54
  84. # define RB 55
  85. # define CM 56
  86. # define SM 57
  87. # define ASSIGN 58
  88.  
  89. /*    END OF YACC */
  90.  
  91. /*    left over tree building operators */
  92. # define COMOP 59
  93. # define DIV 60
  94. # define MOD 62
  95. # define LS 64
  96. # define RS 66
  97. # define DOT 68
  98. # define STREF 69
  99. # define CALL 70
  100. # define FORTCALL 73
  101. # define NOT 76
  102. # define COMPL 77
  103. # define INCR 78
  104. # define DECR 79
  105. # define EQ 80
  106. # define NE 81
  107. # define LE 82
  108. # define LT 83
  109. # define GE 84
  110. # define GT 85
  111. # define ULE 86
  112. # define ULT 87
  113. # define UGE 88
  114. # define UGT 89
  115. # define SETBIT 90
  116. # define TESTBIT 91
  117. # define RESETBIT 92
  118. # define ARS 93
  119. # define REG 94
  120. # define OREG 95
  121. # define CCODES 96
  122. # define FREE 97
  123. # define STASG 98
  124. # define STARG 99
  125. # define STCALL 100
  126.  
  127. /*    some conversion operators */
  128. # define FLD 103
  129. # define SCONV 104
  130. # define PCONV 105
  131. # define PMCONV 106
  132. # define PVCONV 107
  133.  
  134. /*    special node operators, used for special contexts */
  135. # define FORCE 108
  136. # define CBRANCH 109
  137. # define INIT 110
  138. # define CAST 111
  139.  
  140. /*    node types */
  141. # define LTYPE 02
  142. # define UTYPE 04
  143. # define BITYPE 010
  144.  
  145.     /* DSIZE is the size of the dope array */
  146. # define DSIZE CAST+1
  147.  
  148. /*    type names, used in symbol table building */
  149. # define TNULL PTR    /* pointer to UNDEF */
  150. # define UNDEF 0
  151. # define FARG 1
  152. # define CHAR 2
  153. # define SHORT 3
  154. # define INT 4
  155. # define LONG 5
  156. # define FLOAT 6
  157. # define DOUBLE 7
  158. # define STRTY 8
  159. # define UNIONTY 9
  160. # define ENUMTY 10
  161. # define MOETY 11
  162. # define UCHAR 12
  163. # define USHORT 13
  164. # define UNSIGNED 14
  165. # define ULONG 15
  166.  
  167. # define ASG 1+
  168. # define UNARY 2+
  169. # define NOASG (-1)+
  170. # define NOUNARY (-2)+
  171.  
  172. /*    various flags */
  173. # define NOLAB (-1)
  174.  
  175. /* type modifiers */
  176.  
  177. # define PTR  020
  178. # define FTN  040
  179. # define ARY  060
  180.  
  181. /* type packing constants */
  182.  
  183. # define TMASK 060
  184. # define TMASK1 0300
  185. # define TMASK2  0360
  186. # define BTMASK 017
  187. # define BTSHIFT 4
  188. # define TSHIFT 2
  189.  
  190. /*    macros    */
  191.  
  192. # define MODTYPE(x,y) x = (x&(~BTMASK))|y  /* set basic type of x to y */
  193. # define BTYPE(x)  (x&BTMASK)   /* basic type of x */
  194. # define ISUNSIGNED(x) ((x)<=ULONG&&(x)>=UCHAR)
  195. # define UNSIGNABLE(x) ((x)<=LONG&&(x)>=CHAR)
  196. # define ENUNSIGN(x) ((x)+(UNSIGNED-INT))
  197. # define DEUNSIGN(x) ((x)+(INT-UNSIGNED))
  198. # define ISPTR(x) ((x&TMASK)==PTR)
  199. # define ISFTN(x)  ((x&TMASK)==FTN)  /* is x a function type */
  200. # define ISARY(x)   ((x&TMASK)==ARY)   /* is x an array type */
  201. # define INCREF(x) (((x&~BTMASK)<<TSHIFT)|PTR|(x&BTMASK))
  202. # define DECREF(x) (((x>>TSHIFT)&~BTMASK)|(x&BTMASK))
  203. # define SETOFF(x,y)   if( x%y != 0 ) x = ( (x/y + 1) * y)
  204.         /* advance x to a multiple of y */
  205. # define NOFIT(x,y,z)   ( (x%z + y) > z )
  206.         /* can y bits be added to x without overflowing z */
  207.     /* pack and unpack field descriptors (size and offset) */
  208. # define PKFIELD(s,o) ((o<<6)|s)
  209. # define UPKFSZ(v)  (v&077)
  210. # define UPKFOFF(v) (v>>6)
  211.  
  212. /*    operator information */
  213.  
  214. # define TYFLG 016
  215. # define ASGFLG 01
  216. # define LOGFLG 020
  217.  
  218. # define SIMPFLG 040
  219. # define COMMFLG 0100
  220. # define DIVFLG 0200
  221. # define FLOFLG 0400
  222. # define LTYFLG 01000
  223. # define CALLFLG 02000
  224. # define MULFLG 04000
  225. # define SHFFLG 010000
  226. # define ASGOPFLG 020000
  227.  
  228. # define SPFLG 040000
  229.  
  230. #define optype(o) (dope[o]&TYFLG)
  231. #define asgop(o) (dope[o]&ASGFLG)
  232. #define logop(o) (dope[o]&LOGFLG)
  233. #define callop(o) (dope[o]&CALLFLG)
  234.  
  235. /*    table sizes    */
  236.  
  237. # define BCSZ 100 /* size of the table to save break and continue labels */
  238. # define SYMTSZ 450 /* size of the symbol table */
  239. # define DIMTABSZ 750 /* size of the dimension/size table */
  240. # define PARAMSZ 150 /* size of the parameter stack */
  241. # ifndef FORT
  242. # define TREESZ 350 /* space for building parse tree */
  243. # else
  244. # define TREESZ 1000
  245. # endif
  246. # define SWITSZ 250 /* size of switch table */
  247.  
  248. # define NCHNAM 8  /* number of characters in a name */
  249.  
  250. /*    common defined variables */
  251.  
  252. extern int nerrors;  /* number of errors seen so far */
  253.  
  254. typedef union ndu NODE;
  255. typedef unsigned int TWORD;
  256. extern NODE *NIL;  /* a pointer which will always have 0 in it */
  257. extern int dope[];  /* a vector containing operator information */
  258. extern char *opst[];  /* a vector containing names for ops */
  259.  
  260. # ifdef ONEPASS
  261.     /* in one-pass operation, define the tree nodes */
  262.  
  263. union ndu {
  264.  
  265.     struct {
  266.         int op;
  267.         int rall;
  268.         TWORD type;
  269.         int su;
  270.         char name[NCHNAM];
  271.         NODE *left;
  272.         NODE *right;
  273.         };
  274.     
  275.     struct {
  276.         int op;
  277.         int rall;
  278.         TWORD type;
  279.         int su;
  280.         char name[NCHNAM];
  281.         CONSZ lval;
  282.         int rval;
  283.         };
  284.     
  285.     struct {
  286.         int op, rall;
  287.         TWORD type;
  288.         int su;
  289.         int label;  /* for use with branching */
  290.         };
  291.  
  292.     struct {
  293.         int op, rall;
  294.         TWORD type;
  295.         int su;
  296.         int stsize;  /* sizes of structure objects */
  297.         int stalign;  /* alignment of structure objects */
  298.         };
  299.  
  300.     struct {
  301.         int op;
  302.         int cdim;
  303.         TWORD type;
  304.         int csiz;
  305.         };
  306.     
  307.     struct {
  308.         /* this structure is used when a floating point constant
  309.            is being computed */
  310.         int op;
  311.         int cdim;
  312.         TWORD type;
  313.         int csiz;
  314.         double dval;
  315.         };
  316.  
  317.     };
  318. # endif
  319.