1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
   2: /* $Header: b.h,v 1.1 84/06/28 00:48:39 timo Exp $ */
   3: 
   4: /* b.h: general */
   5: 
   6: #include <stdio.h>
   7: #include <math.h>
   8: #include <setjmp.h>
   9: 
  10: #define Forward
  11: #define Visible
  12: #define Hidden static
  13: #define Procedure
  14: 
  15: #define EQ ==
  16: #define NE !=
  17: 
  18: /* The following are not intended as pseudo-encapsulation, */
  19: /* but to emphasize intention. */
  20: typedef char literal;
  21: typedef char bool;
  22: typedef char *txptr;
  23: typedef char *string; /* Strings are always terminated with a char '\0'. */
  24: 
  25: #define Yes ((bool) 1)
  26: #define No  ((bool) 0)
  27: typedef short intlet;
  28: extern bool bugs;
  29: 
  30: /************************************************************************/
  31: /*                                                                      */
  32: /* Values                                                               */
  33: /*                                                                      */
  34: /* There are different modules for values, however all agree that       */
  35: /* the first field of a value is its type, and the second its reference */
  36: /* count. All other fields depend on the module.                        */
  37: /*                                                                      */
  38: /************************************************************************/
  39: 
  40: typedef struct{literal type; intlet refcnt, len; string *cts;} *value;
  41: 
  42: #define Dummy 0
  43: #define Dumval ((value) Dummy)
  44: #define Vnil ((value) 0)
  45: #define Pnil ((value *) 0)
  46: 
  47: /* Types: */
  48: #define Num '0'
  49: #define Tex '"'
  50: #define Com ','
  51: #define Lis 'L'
  52: #define Tab 'M'
  53: #define ELT '}'
  54: /* locations: */
  55: #define Sim 'S'
  56: #define Tri '@'
  57: #define Tse '['
  58: #define Glo 'g'
  59: #define Per 'p'
  60: /* units: */
  61: #define How 'h'
  62: #define For 'f'
  63: #define Ref 'r'
  64: #define Fun '+'
  65: #define Prd 'i'
  66: 
  67: #define Type(v) ((v)->type)
  68: #define Length(v) ((v)->len)
  69: #define Refcnt(v) ((v)->refcnt)
  70: #define Unique(v) ((v)->refcnt==1)
  71: 
  72: #define Overall for (k= 0; k < len; k++)
  73: 
  74: #define k_Over_len for (k= 0; k < len; k++)
  75: #define Last(k) (k == len-1)
  76: 
  77: #define Ats(v) ((value *)&((v)->cts))
  78: #define Str(v) ((string)&((v)->cts)) /* only for use in part1 */
  79: 
  80: /* Environments and context */
  81: 
  82: typedef value envtab;
  83: typedef struct ec{envtab tab; struct ec *inv_env;} envchain;
  84: typedef envchain *env;
  85: 
  86: typedef struct{env curnv; value *bndtgs;
  87:     literal cntxt, resexp; value uname; literal utype;
  88:     intlet cur_ilev, lino; txptr tx, ceol;} context;
  89: 
  90: #define Enil ((env) 0)
  91: 
  92: /* contexts: */
  93: #define In_command 'c'
  94: #define In_read '?'
  95: #define In_unit 'u'
  96: #define In_value 'v'
  97: #define In_formal 'f'
  98: #define In_prmnv 'p'
  99: 
 100: /* results */
 101: #define Ret 'V'
 102: #define Rep '+'
 103: #define Voi ' '
 104: 
 105: /* adicity */
 106: #define Zer '0'
 107: #define Mon '1'
 108: #define Dya '2'
 109: 
 110: /* funprd.def */
 111: #define Pre 'P'
 112: #define Use 'U'
 113: 
 114: /************************************************************************/
 115: /*                                                                      */
 116: /* A function or predicate is modelled as a compound consisting of      */
 117: /* (i)   two short integers for (L, H) priority                         */
 118: /*           (relevant only for functions);                             */
 119: /* (ii)  Zer/Mon/Dya for zero-, mon- or dyadicity;                      */
 120: /* (iii) Pre/Use for pre- or user-definedness;                          */
 121: /* (iv)  if Pre, a literal to switch on;                                */
 122: /*       if Use, a pointer to the yield/test-unit text.                 */
 123: /*                                                                      */
 124: /************************************************************************/
 125: 
 126: typedef struct{envtab reftab; txptr fux, lux; bool filed;} how;
 127: typedef struct{envtab reftab; txptr fux, lux; bool filed;
 128:     intlet L, H; literal adic, def;} funprd;
 129: /* The first four fields should have the same structure as those of 'hows' */
 130: 
 131: typedef struct{context con; txptr ftx;} formal;
 132: typedef struct{txptr rp; intlet rlino;} ref;
 133: 
 134: /************************************************************************/
 135: /*                                                                      */
 136: /* Locations                                                            */
 137: /*                                                                      */
 138: /* A simple location is modelled as a pair basic-identifier and         */
 139: /*     environment, where a basic-identifier is modelled as a text      */
 140: /*     and an environment as a pointer to a pair (T, E), where T is a   */
 141: /*     table with basic-identifiers as keys and content values as       */
 142: /*     associates, and E is the invoking environment or nil.            */
 143: /*                                                                      */
 144: /* A trimmed-text location is modelled as a triple (R, B, C).           */
 145: /*                                                                      */
 146: /* A compound location is modelled as a compound whose fields are       */
 147: /*     locations, rather than values.                                   */
 148: /*                                                                      */
 149: /* A table-selection location is modelled as a pair (R, K).             */
 150: /*                                                                      */
 151: /************************************************************************/
 152: 
 153: typedef value loc;
 154: 
 155: typedef value basidf;
 156: typedef struct{basidf i; env e;} simploc;
 157: typedef struct{loc R; intlet B, C;} trimloc;
 158: typedef struct{loc R; value K;} tbseloc;
 159: 
 160: /* Functions and Predicates */
 161: typedef value fun;
 162: typedef value prd;
 163: 
 164: char *malloc(), *realloc();
 165: char *getenv();

Defined struct's

ec defined in line 83; used 2 times
  • in line 83(2)

Defined typedef's

envchain defined in line 83; used 4 times
intlet defined in line 27; used 126 times

Defined macros

Com defined in line 50; used 2 times
Dumval defined in line 43; never used
Dya defined in line 108; used 26 times
EQ defined in line 15; never used
Enil defined in line 90; used 6 times
For defined in line 62; used 1 times
Fun defined in line 64; used 1 times
Glo defined in line 58; used 1 times
How defined in line 61; used 1 times
In_formal defined in line 97; used 6 times
In_read defined in line 94; used 6 times
Last defined in line 75; used 4 times
Lis defined in line 51; used 4 times
NE defined in line 16; never used
No defined in line 26; used 187 times
Num defined in line 48; used 6 times
Per defined in line 59; used 1 times
Prd defined in line 65; used 1 times
Pre defined in line 111; used 3 times
Ref defined in line 63; used 1 times
Refcnt defined in line 69; never used
Sim defined in line 55; used 1 times
Str defined in line 78; used 28 times
Tri defined in line 56; used 1 times
Tse defined in line 57; used 1 times
Type defined in line 67; used 2 times
Unique defined in line 70; used 3 times
Visible defined in line 11; used 206 times
Yes defined in line 25; used 159 times

Usage of this include

Last modified: 1985-08-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1574
Valid CSS Valid XHTML 1.0 Strict