home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume23 / abc / patch1 / bint.h
Text File  |  1991-01-08  |  5KB  |  145 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1988. */
  2.  
  3. /* interpreter values */
  4.  
  5. /* Types */
  6.  
  7. #define Ptn 'T'        /* parsetree */
  8. #define How 'h'        /* command howto */
  9. #define Fun '+'        /* function */
  10. #define Ref 'r'        /* refinement */
  11. #define Prd 'i'        /* predicate */
  12. #define Sim 'S'        /* simple location */
  13. #define Tri '@'        /* trimmed text location */
  14. #define Tse '['        /* table selection location */
  15. #define Rangebounds 'B'    /* for range as list_item */
  16. #define Ind 'p'        /* indirection node for targets and formals */
  17.  
  18. /************************************************************************/
  19. /* environment                                */
  20. /************************************************************************/
  21.  
  22. typedef value envtab;
  23. typedef struct ec{envtab tab; struct ec *inv_env;} envchain;
  24. typedef envchain *env;
  25.  
  26. /************************************************************************/
  27. /* parsetrees                                */
  28. /************************************************************************/
  29.  
  30. typedef value parsetree;
  31. #define NilTree ((parsetree) Vnil)
  32. #define Is_parsetree(v) (Type(v) == Ptn)
  33. #define ValidTree(v) ((v) != NilTree)
  34.  
  35. /************************************************************************/
  36. /*                                                                      */
  37. /* A function or predicate is modelled as a compound consisting of      */
  38. /* (i)  Zer/Mon/Dya for zero-, mon- or dyadicity;                       */
  39. /* (ii) If a predefined function, an identifying number, otherwise -1   */
  40. /* (iii)  If a user-defined function/predicate, its parse-tree          */
  41. /*                                                                      */
  42. /************************************************************************/
  43.  
  44. typedef struct {
  45.     parsetree unit; 
  46.     char /* bool */ unparsed;
  47.     char /* bool */ filed; 
  48.     parsetree code;
  49. } how;
  50.  
  51. typedef struct {
  52.     parsetree unit; 
  53.     char /* bool */ unparsed;
  54.     char /* bool */ filed; 
  55.     parsetree code;
  56.     literal adic; 
  57.     intlet pre;
  58. } funprd;
  59.  
  60. /* The first four fields of hows and funprds must be the same. */
  61. #define Use (-1) /* funprd.pre==Use for user-defined funprds */
  62.  
  63. #define How_to(u)  ((how *)Ats(u))
  64. #define Funprd(f)  ((funprd *)Ats(f))
  65.  
  66. typedef value fun;
  67. typedef value prd;
  68.  
  69. fun mk_fun();
  70. prd mk_prd();
  71. value mk_how();
  72.  
  73. #define Is_howto(v) (Type(v) == How)
  74. #define Is_function(v) (Type(v) == Fun)
  75. #define Is_predicate(v) (Type(v) == Prd)
  76.  
  77. /************************************************************************/
  78. /* refinements                                */
  79. /************************************************************************/
  80.  
  81. typedef struct{parsetree rp;} ref;
  82. #define Refinement(r) ((ref *)Ats(r))
  83. #define Is_refinement(v) (Type(v) == Ref)
  84. value mk_ref();
  85.  
  86. /************************************************************************/
  87. /*                                                                      */
  88. /* Locations                                                            */
  89. /*                                                                      */
  90. /* A simple location is modelled as a pair basic-identifier and         */
  91. /*     environment, where a basic-identifier is modelled as a text      */
  92. /*     and an environment as a pointer to a pair (T, E), where T is a   */
  93. /*     table with basic-identifiers as keys and content values as       */
  94. /*     associates, and E is the invoking environment or nil.            */
  95. /*                                                                      */
  96. /* A trimmed-text location is modelled as a triple (R, B, C).           */
  97. /*                                                                      */
  98. /* A compound location is modelled as a compound whose fields are       */
  99. /*     locations, rather than values.                                   */
  100. /*                                                                      */
  101. /* A table-selection location is modelled as a pair (R, K).             */
  102. /*                                                                      */
  103. /************************************************************************/
  104.  
  105. typedef value loc;
  106. #define Lnil ((loc) Vnil)
  107.  
  108. typedef value basidf;
  109. typedef struct{basidf i; env e;} simploc;
  110. typedef struct{loc R; value B, C;} trimloc;
  111. typedef struct{loc R; value K;} tbseloc;
  112.  
  113. #define Simploc(l) ((simploc *)Ats(l))
  114. #define Tbseloc(l) ((tbseloc *)Ats(l))
  115. #define Trimloc(l) ((trimloc *)Ats(l))
  116.  
  117. loc mk_simploc();
  118. loc mk_trimloc();
  119. loc mk_tbseloc();
  120.  
  121. #define Is_locloc(v) IsSmallInt(v)
  122. #define Is_simploc(v) (Type(v) == Sim)
  123. #define Is_tbseloc(v) (Type(v) == Tse)
  124. #define Is_trimloc(v) (Type(v) == Tri)
  125.  
  126. /************************************************************************/
  127. /* rangebounds                                */
  128. /************************************************************************/
  129.  
  130. #define R_LWB(v) ((value) *Field((v), 0))
  131. #define R_UPB(v) ((value) *Field((v), 1))
  132. #define Is_rangebounds(v) (Type(v) == Rangebounds)
  133. value mk_rbounds();
  134.  
  135. /************************************************************************/
  136. /* indirection                                */
  137. /************************************************************************/
  138.  
  139. typedef struct{value val;} indirect;
  140. #define Indirect(v) ((indirect *)Ats(v))
  141. #define Is_indirect(v) (Type(v) == Ind)
  142. value mk_indirect();
  143.  
  144. /************************************************************************/
  145.