home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / suntar1.cpt / gc / gc.h next >
Encoding:
C/C++ Source or Header  |  1992-03-14  |  2.3 KB  |  108 lines

  1. /* E_parser input values */
  2. #define Normal 8
  3. #define commaIsNotOp 020
  4. #define externalCall 0x8000
  5.  
  6. /* associativity codes */
  7. #define prefix 2
  8. #define postfix 1
  9. #define leftass 5
  10. #define rightass 7
  11. #define noass 6
  12. #define ternary 4
  13.  
  14. #define ass 0
  15. #define dyn 1
  16. #define const 2
  17. #define string 3
  18.  
  19. #define F  0
  20. #define T  1
  21. #define EQ 2
  22. #define NE 3
  23. #define LE 4
  24. #define GT 5
  25. #define LT 6
  26. #define GE 7
  27.  
  28. /* lazy code generator classes */
  29. #define immediate   0
  30. #define simplevar   2
  31. #define relocatable 4
  32. #define based       5
  33. #define generated   6
  34. #define flags       7
  35.  
  36. /* features: */
  37. #define lval1op 2
  38. #define lval2op 1
  39. #define unaryToo 4
  40. #define asgnOpToo 8
  41. #define assignOp 16
  42.  
  43. #define TOLONG(x) (char*)(&symbolTable[-1])+x
  44. #define TOWORD(x) (char *)x-(char*)(&symbolTable[-1])
  45.  
  46.  
  47. typedef unsigned char byte;
  48. typedef unsigned short word;
  49. typedef struct tabel{
  50.       short typ;
  51.       char name[10];
  52.       long val;
  53. }tabel;
  54.  
  55. /* code generator struct: it's horribly tricky with all those overlays,
  56. but you haven't yet seen what happens when the "right" and "this" structs
  57. are really overlayed, occupying the same memory, and the fields of "this" 
  58. are computed from the fields of "right", doing the most tricky things to
  59. avoid reading a field after it was overwritten (and to avoid assigning
  60. values since they are already there): a very pretty set of tricks !
  61. */
  62.  
  63.  
  64. typedef struct localmem{
  65.    byte op,opfea;
  66.    word counter;
  67.    struct GCI{
  68.       byte Lval;
  69.       byte Class;
  70.       word Displacement,Symplus;
  71.       union bb{
  72.          struct cc{
  73.             byte Auxternary,IsCExpr;
  74.          }cc;
  75.          word AuxLname;
  76.       }bb;
  77.       union aa{
  78.          long Eval;
  79.          tabel *STable;
  80.          word Label[2];
  81.       }aa;
  82.    } gci;
  83. #define auxlabel counter
  84. #define auxternary gci.bb.cc.Auxternary
  85. #define isCExpr gci.bb.cc.IsCExpr
  86. #define auxLname gci.bb.AuxLname
  87. #define lval gci.Lval
  88. #define class gci.Class
  89. #define displacement gci.Displacement
  90. #define condition displacement
  91. #define symminus displacement
  92. #define symplus gci.Symplus
  93. #define place symplus
  94. #define eval gci.aa.Eval
  95. #define sTable gci.aa.STable
  96. #define label gci.aa.Label
  97. } localmem;
  98.  
  99. extern struct t{
  100.    byte asc,index;
  101.    tabel *symTable;
  102.    word priority,features;
  103. }token;
  104. extern FILE *out;
  105. extern localmem currentExpr;
  106.  
  107. extern tabel symbolTable[];
  108.