BSD 4_3_Tahoe development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 26 Aug 1985 19:22:41 +0000 (11:22 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 26 Aug 1985 19:22:41 +0000 (11:22 -0800)
Work on file usr/src/new/B/src/bint/b.h
Work on file usr/src/new/B/src/bint/b0fea.h
Work on file usr/src/new/B/src/bint/b0con.h
Work on file usr/src/new/B/src/bint/b0fil.h
Work on file usr/src/new/B/src/bint/b1btr.h
Work on file usr/src/new/B/src/bint/b1mem.h
Work on file usr/src/new/B/src/bint/b1num.h
Work on file usr/src/new/B/src/bint/b1obj.h
Work on file usr/src/new/B/src/bint/b1tlt.h
Work on file usr/src/new/B/src/bint/b1val.h
Work on file usr/src/new/B/src/bint/b2exp.h
Work on file usr/src/new/B/src/bint/b2gen.h
Work on file usr/src/new/B/src/bint/b2key.h
Work on file usr/src/new/B/src/bint/b2nod.h
Work on file usr/src/new/B/src/bint/b2par.h
Work on file usr/src/new/B/src/bint/b2syn.h
Work on file usr/src/new/B/src/bint/b2tcE.h
Work on file usr/src/new/B/src/bint/b2tcP.h
Work on file usr/src/new/B/src/bint/b2tcU.h
Work on file usr/src/new/B/src/bint/b3env.h
Work on file usr/src/new/B/src/bint/b3err.h
Work on file usr/src/new/B/src/bint/b3ext.h
Work on file usr/src/new/B/src/bint/b3fil.h

Synthesized-from: CSRG/cd2/4.3tahoe

23 files changed:
usr/src/new/B/src/bint/b.h [new file with mode: 0644]
usr/src/new/B/src/bint/b0con.h [new file with mode: 0644]
usr/src/new/B/src/bint/b0fea.h [new file with mode: 0644]
usr/src/new/B/src/bint/b0fil.h [new file with mode: 0644]
usr/src/new/B/src/bint/b1btr.h [new file with mode: 0644]
usr/src/new/B/src/bint/b1mem.h [new file with mode: 0644]
usr/src/new/B/src/bint/b1num.h [new file with mode: 0644]
usr/src/new/B/src/bint/b1obj.h [new file with mode: 0644]
usr/src/new/B/src/bint/b1tlt.h [new file with mode: 0644]
usr/src/new/B/src/bint/b1val.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2exp.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2gen.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2key.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2nod.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2par.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2syn.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2tcE.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2tcP.h [new file with mode: 0644]
usr/src/new/B/src/bint/b2tcU.h [new file with mode: 0644]
usr/src/new/B/src/bint/b3env.h [new file with mode: 0644]
usr/src/new/B/src/bint/b3err.h [new file with mode: 0644]
usr/src/new/B/src/bint/b3ext.h [new file with mode: 0644]
usr/src/new/B/src/bint/b3fil.h [new file with mode: 0644]

diff --git a/usr/src/new/B/src/bint/b.h b/usr/src/new/B/src/bint/b.h
new file mode 100644 (file)
index 0000000..6c5b809
--- /dev/null
@@ -0,0 +1,207 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b.h,v 1.4 85/08/22 16:41:03 timo Exp $
+*/
+
+/* b.h: general */
+
+#define MESS(nr, text) nr
+
+#include <stdio.h>
+#include <math.h>
+
+#define Forward
+#define Visible
+#define Hidden static
+#define Procedure
+
+#define EQ ==
+#define NE !=
+
+/* The following are not intended as pseudo-encapsulation, */
+/* but to emphasize intention. */
+
+typedef char literal;
+typedef char bool;
+typedef char *txptr;
+typedef char *string; /* Strings are always terminated with a char '\0'. */
+
+#define Yes ((bool) 1)
+#define No  ((bool) 0)
+typedef short intlet;
+extern bool bugs, testing;
+
+/************************************************************************/
+/*                                                                      */
+/* Values                                                               */
+/*                                                                      */
+/* There are different modules for values, however all agree that       */
+/* the first field of a value is its type, and the second its reference */
+/* count. All other fields depend on the module.                        */
+/*                                                                      */
+/************************************************************************/
+
+/*
+ * "SMALL INTEGERS":
+ *
+ * When a "value" pointer has its low bit set, it is not a pointer.
+ * By casting to int and shifting one bit to the right, it is converted
+ * to its "int" value.  This can save a lot of heap space used for
+ * small integers.
+ * Sorry, you have to change this on machines with word rather than byte
+ * addressing (maybe you can use the sign bit as tag).
+ */
+
+#define IsSmallInt(v) (((int)(v)) & 1)
+#define SmallIntVal(v) (((int)(v) & ~1) / 2)
+#define MkSmallInt(i) ((value)((i)*2 | 1))
+       /* (Can't use << and >> because their effect on negative numbers
+               is not defined.) */
+
+#ifdef IBMPC
+#define HEADER literal type, refcnt; intlet len
+#else
+#define HEADER literal type; intlet refcnt, len
+#endif
+
+typedef struct value {HEADER; string *cts;} *value;
+typedef value parsetree;
+
+
+#define Dummy NULL
+#define Dumval ((value) Dummy)
+#define Vnil ((value) NULL)
+#define Pnil ((value *) NULL)
+#define NilTree ((parsetree) NULL)
+
+/* Types: */
+#define Num '0'
+#define Tex '"'
+#define Com ','
+#define Lis 'L'
+#define Tab 'M'
+#define ELT '}'
+/* parsetree node */
+#define Ptn 'T'
+/* locations: */
+#define Sim 'S'
+#define Tri '@'
+#define Tse '['
+#define Per 'p'
+/* units: */
+#define How 'h'
+#define For 'f'
+#define Ref 'r'
+#define Fun '+'
+#define Prd 'i'
+
+/* targets */
+#define Tar 't'
+
+#ifdef INTEGRATION
+#define Nod 'N'
+#define Pat 'P'
+#endif INTEGRATION
+
+#define Type(v) (IsSmallInt(v) ? Num : (v)->type)
+#define Length(v) ((v)->len)
+#define Refcnt(v) ((v)->refcnt)
+#define Unique(v) ((v)->refcnt==1)
+
+#define Overall for (k= 0; k < len; k++)
+
+#define k_Over_len for (k= 0; k < len; k++)
+#define Last(k)        (k == len-1)
+
+#define Ats(v) ((value *)&((v)->cts))
+#define Str(v) ((string)&((v)->cts)) /* only for use in part1 */
+
+/* Environments and context */
+
+typedef value envtab;
+typedef struct ec{envtab tab; struct ec *inv_env;} envchain;
+typedef envchain *env;
+
+typedef struct {
+       value uname;
+       env curnv;
+       value r_names, *bndtgs;
+       literal cntxt, resexp;
+       parsetree cur_line;
+       value cur_lino;
+} context;
+
+#define Enil ((env) NULL)
+
+/* contexts: */
+#define In_command 'c'
+#define In_read '?'
+#define In_unit 'u'
+#define In_edval 'e'
+#define In_tarval 't'
+#define In_formal 'f'
+#define In_prmnv 'p'
+
+/* results */
+#define Ret 'V'
+#define Rep '+'
+#define Voi ' '
+
+/* adicity */
+#define Zer '0'
+#define Mon '1'
+#define Dya '2'
+
+/************************************************************************/
+/*                                                                      */
+/* A function or predicate is modelled as a compound consisting of      */
+/* (i)  Zer/Mon/Dya for zero-, mon- or dyadicity;                      */
+/* (ii) If a predefined function, an identifying number, otherwise -1  */
+/* (iii)  If a user-defined function/predicate, its parse-tree           */
+/*                                                                      */
+/************************************************************************/
+
+typedef struct{parsetree unit; bool unparsed, filed; parsetree code;} how;
+typedef struct{parsetree unit; bool unparsed, filed; parsetree code;
+       literal adic; intlet pre;} funprd;
+/* The first four fields of hows and funprds must be the same. */
+#define Use (-1) /* funprd.pre==Use for user-defined funprds */
+
+typedef struct{context con; parsetree fp;} formal;
+typedef struct{parsetree rp;} ref;
+typedef struct{parsetree val;} per;
+
+/************************************************************************/
+/*                                                                      */
+/* Locations                                                            */
+/*                                                                      */
+/* A simple location is modelled as a pair basic-identifier and         */
+/*     environment, where a basic-identifier is modelled as a text      */
+/*     and an environment as a pointer to a pair (T, E), where T is a   */
+/*     table with basic-identifiers as keys and content values as       */
+/*     associates, and E is the invoking environment or nil.            */
+/*                                                                      */
+/* A trimmed-text location is modelled as a triple (R, B, C).           */
+/*                                                                      */
+/* A compound location is modelled as a compound whose fields are       */
+/*     locations, rather than values.                                   */
+/*                                                                      */
+/* A table-selection location is modelled as a pair (R, K).             */
+/*                                                                      */
+/************************************************************************/
+
+typedef value loc;
+#define Lnil ((loc) NULL)
+
+typedef value basidf;
+typedef struct{basidf i; env e;} simploc;
+typedef struct{loc R; value B, C;} trimloc;
+typedef struct{loc R; value K;} tbseloc;
+
+/* Functions and Predicates */
+typedef value fun;
+typedef value prd;
+
+char *malloc(), *realloc();
+char *getenv();
diff --git a/usr/src/new/B/src/bint/b0con.h b/usr/src/new/B/src/bint/b0con.h
new file mode 100644 (file)
index 0000000..fcf5d66
--- /dev/null
@@ -0,0 +1,62 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b0con.h,v 1.4 85/08/26 10:42:23 timo Exp $
+*/
+
+/* Configuration file: some easy changes to the system                      */
+/* As much as possible, this is done automatically these days               */
+/* You only need to change this file under rare circumstances               */
+
+/* At the end, this file #includes another file, config.h, which is       */
+/* generated automatically (by running mkconfig).  Most machine-dependent   */
+/* changes are put there.                                                   */
+
+/* VOID is used to keep lint quiet(er)                                      */
+/* (This could be moved to "b.h", as it is never necessary to change it)    */
+#ifdef lint
+#define VOID (void)
+#else
+#define VOID /*empty*/
+#endif
+
+/* some un*xes demand that you reset stdin in some way if you get eof, and  */
+/* want to read from it still. If yours doesn't, delete "clearerr(stdin)"   */
+/* Actually, it never harms, so why should you want to delete it?           */
+#define CLEAR_EOF clearerr(stdin)
+
+
+/* Miscellaneous definitions*/
+typedef int expint;            /*The 2nd argument of frexp points to this */
+                               /*(see manual page frexp(3)).              */
+                               /*On some 68K systems must be short (foo!) */
+
+#define Maxtrig 1e16           /*Max x for sin(x), cos(x), tan(x)         */
+                               /*(Can anybody find a way to compute this  */
+                               /*automatically?)                          */
+
+#ifdef IBMPC
+#define Maxrefcnt 255
+#else
+#define Maxrefcnt Maxintlet
+#endif
+
+#define MaxSmallInt (BASE-1) /* This must be so! */
+#define MinSmallInt (-BASE) /* This must be so!!! */
+
+#ifndef INTEGRATION
+#define CMBUFSIZE 1000         /*Buffer used for commands*/
+#define RDBUFSIZE 1000         /*Buffer used for reading*/
+#else
+#define CMBUFSIZE 200          /*Buffer used for commands*/
+#define RDBUFSIZE 100          /*Buffer used for reading*/
+#endif
+
+#ifdef unix
+#define SEED getpid()          /*Any suitable random int (eg date or time) */
+                               /*to start the random number generator with */
+#else
+#define SEED getseed()
+#endif
+
+#include "config.h"            /* Chain to real machine dependencies       */
diff --git a/usr/src/new/B/src/bint/b0fea.h b/usr/src/new/B/src/bint/b0fea.h
new file mode 100644 (file)
index 0000000..08a2c2f
--- /dev/null
@@ -0,0 +1,59 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b0fea.h,v 1.4 85/08/22 16:41:18 timo Exp $
+*/
+
+#ifdef CWI
+#define CONVERSION
+#endif
+
+#ifdef unix
+#define PRMNVFILE ".prmnv"
+#define SAVEPRMNVFILE ".prmnv_save"
+#define SIGNAL
+#define SETJMP
+#define KILL
+#define TIMING
+#define ISATTY
+#endif unix
+
+/* ********************************************************************        */
+
+#ifndef unix
+
+#define RENAME
+
+#endif !unix
+
+/* ********************************************************************        */
+
+#ifdef vax
+
+#define BSD_SELECT
+
+#endif vax
+
+/* ********************************************************************        */
+
+#ifdef IBMPC
+
+#define LATTICE
+#define SIGNAL
+#define START_MESSAGE
+#define NO_ABS
+#define SETJMP
+#define ISATTY
+
+#endif IBMPC
+
+/* ********************************************************************        */
+
+#ifndef IBMPC
+
+/* #define EXT_COMMAND */
+#define TYPE_CHECK
+#define PRINT_APPROX
+
+#endif !IBMPC
+
diff --git a/usr/src/new/B/src/bint/b0fil.h b/usr/src/new/B/src/bint/b0fil.h
new file mode 100644 (file)
index 0000000..ccf2563
--- /dev/null
@@ -0,0 +1,18 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b0fil.h,v 1.4 85/08/22 16:41:24 timo Exp $
+*/
+
+/* Declarations for variables containing file names. */
+/* The corresponding initializations are in b0fil.c. */
+
+extern char *bpermfile;
+extern char *tempfile;
+extern char *messfile;
+
+#ifndef INTEGRATION
+extern char *editorfile;
+#endif
+
+#define BPERMFILE bpermfile
diff --git a/usr/src/new/B/src/bint/b1btr.h b/usr/src/new/B/src/bint/b1btr.h
new file mode 100644 (file)
index 0000000..27f63ad
--- /dev/null
@@ -0,0 +1,222 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b1btr.h,v 1.4 85/08/22 16:41:40 timo Exp $
+*/
+
+/* Private definitions for the b-tree module */
+
+#ifndef INTEGRATION
+
+extern bool comp_ok;
+#define reqerr(s) error(s)
+
+/*********************************************************************/
+/* items
+/*********************************************************************/
+
+typedef char texitem;
+typedef value lisitem;
+typedef struct pair {value k, a;} tabitem;
+typedef struct onpair {value ka, u;} keysitem;
+typedef union itm {
+    texitem c;
+    lisitem l;
+    tabitem t;
+} item, *itemarray, *itemptr;
+
+#define Charval(pitm) ((pitm)->c)
+#define Keyval(pitm) ((pitm)->l)
+#define Ascval(pitm) ((pitm)->t.a)
+
+/* Xt = itemtype, do not change these, their order is used */
+#define Ct (0)
+#define Lt (1)
+#define Tt (2)
+#define Kt (3)
+
+/* Itemwidth, used for offset in btreenodes */
+typedef char width;
+#define Itemwidth(it) (itemwidth[it])
+extern char itemwidth[];       /*  uses: */
+#define Cw (sizeof(texitem))
+#define Lw (sizeof(lisitem))
+#define Tw (sizeof(tabitem))
+#define Kw (sizeof(keysitem))
+
+/*********************************************************************/
+/* sizes of btrees
+/*********************************************************************/
+
+#define Bigsize (-1)
+#define Stail(r,s) ((r) > Maxint - (s) ? Bigsize : (r)+(s))
+#define Ssum(r,s)  ((r) EQ Bigsize || (s) EQ Bigsize ? Bigsize : Stail(r,s))
+#define Sincr(r)   ((r) EQ Bigsize ? Bigsize : Stail(r,1))
+#define Sadd2(r)   ((r) EQ Bigsize ? Bigsize : Stail(r,2))
+#define Sdiff(r,s) ((r) EQ Bigsize || (s) EQ Bigsize ? Bigsize : (r)-(s))
+#define Sdecr(r)   ((r) EQ Bigsize ? Bigsize : (r)-(1))
+value treesize();      /* btreeptr pnode */
+
+/*********************************************************************/
+/* (A,B)-btrees
+/*********************************************************************/
+
+/* innernodes: using A=6 B=12 */
+#define Mininner 5             /* A - 1 */
+#define Maxinner 11            /* B - 1 */
+/* bottomnodes */
+#define Minbottom 11
+#define Maxbottom 22
+/* rangenodes */
+#define Biglim         (Maxbottom+1)
+
+typedef struct btrnode {
+    HEADER; int size;
+    char **g;
+}
+btreenode, *btreeptr;
+
+typedef struct innernode {
+    HEADER; int size;
+    btreeptr ptr[Maxinner+1]; itemarray iitm;
+}
+innernode, *innerptr;
+
+typedef struct itexnode {
+    HEADER; int size;
+    btreeptr ptr[Maxinner+1]; texitem icitm[Maxinner];
+}
+itexnode, *itexptr;
+
+typedef struct ilisnode {
+    HEADER; int size;
+    btreeptr ptr[Maxinner+1]; lisitem ilitm[Maxinner];
+}
+ilisnode, *ilisptr;
+
+typedef struct itabnode {
+    HEADER; int size;
+    btreeptr ptr[Maxinner+1]; tabitem ititm[Maxinner];
+}
+itabnode, *itabptr;
+
+typedef struct bottomnode {
+    HEADER; int size;
+    itemarray bitm;
+}
+bottomnode, *bottomptr;
+
+typedef struct btexnode {
+    HEADER; int size;
+    texitem bcitm[Maxbottom];
+}
+btexnode, *btexptr;
+
+typedef struct blisnode {
+    HEADER; int size;
+    lisitem blitm[Maxbottom];
+}
+blisnode, *blisptr;
+
+typedef struct btabnode {
+    HEADER; int size;
+    tabitem btitm[Maxbottom];
+}
+btabnode, *btabptr;
+
+typedef struct rangenode {
+    HEADER; int size;
+    lisitem lwb, upb;
+}
+rangenode, *rangeptr;
+
+#define Bnil ((btreeptr) 0)
+
+#define Flag(pnode)    ((pnode)->type)
+#define Inner  'i'
+#define Bottom 'b'
+#define Irange  '.'
+#define Crange  '\''
+
+#define Lim(pnode)     ((pnode)->len)
+#define Minlim(pnode)  (Flag(pnode) EQ Inner ? Mininner : Minbottom)
+#define Maxlim(pnode)  (Flag(pnode) EQ Inner ? Maxinner : Maxbottom)
+#define SetRangeLim(pnode) (Size(pnode) EQ Bigsize || Size(pnode) > Maxbottom\
+                           ? Biglim : Size(pnode))
+
+#define Size(pnode)    ((pnode)->size)
+
+#define Ptr(pnode,l)   (((innerptr) (pnode))->ptr[l])
+/* pointer to item in innernode: */
+#define Piitm(pnode,l,w) ((itemptr) (((char*)&(((innerptr) (pnode))->iitm)) + ((l)*(w))))
+/* pointer to item in bottomnode: */
+#define Pbitm(pnode,l,w) ((itemptr) (((char*)&(((bottomptr) (pnode))->bitm)) + ((l)*(w))))
+#define Ichar(pnode,l) (((itexptr) (pnode))->icitm[l])
+#define Bchar(pnode,l) (((btexptr) (pnode))->bcitm[l])
+
+#define Lwbval(pnode)  (((rangeptr) (pnode))->lwb)
+#define Upbval(pnode)  (((rangeptr) (pnode))->upb)
+#define Lwbchar(pnode)  (Bchar(Root(Lwbval(pnode)), 0))
+#define Upbchar(pnode)  (Bchar(Root(Upbval(pnode)), 0))
+
+#define Maxheight 20        /* should be some function of B */
+
+/* Procedure merge(); */
+    /* btreeptr pleft; itemptr pitm; btreeptr pright; literal it; */
+bool rebalance();
+    /* btreeptr *pptr1; itemptr pitm; btreeptr pptr2;
+       intlet minlim, maxlim; literal it; */
+/* Procedure restore_child(); */
+    /* btreeptr pparent; intlet ichild, minl, maxl; literal it; */
+bool inodeinsert();
+    /* btreeptr pnode, *pptr; itemptr pitm; intlet at; literal it; */
+bool bnodeinsert();
+    /* btreeptr pnode, *pptr; itemptr pitm; intlet at; literal it; */
+bool i_search();
+    /* btreeptr pnode; value key; intlet *pl; width iw; */
+bool b_search();
+    /* btreeptr pnode; value key; intlet *pl; width iw; */
+
+/*********************************************************************/
+/* texts only (mbte.c)
+/*********************************************************************/
+
+btreeptr trimbtextnode(); /* btreeptr pnode, intlet from,to */
+btreeptr trimitextnode(); /* btreeptr pnode, intlet from,to */
+bool join_itm();
+    /* btreeptr pnode, *pptr; itemptr pitm; bool after */
+
+/*********************************************************************/
+/* lists only (mbli.c)
+/*********************************************************************/
+
+btreeptr spawncrangenode(); /* value lwb, upb */
+/* Procedure set_size_and_lim(); */    /* btreeptr pnode */
+/* PRrocedure ir_to_bottomnode(); */   /* btreeptr *pptr; */
+bool ins_itm();
+    /* btreeptr *pptr1; itemptr pitm; btreeptr *pptr2; literal it; */
+/* Procedure rem_greatest(); */
+    /* btreeptr *pptr; itemptr prepl_itm; literal it; */
+bool rem_itm(); 
+    /* btreeptr *pptr1; itemptr pitm;
+       itemptr p_insitm; btreeptr *pptr2; bool *psplit;
+       literal it; */
+
+/*********************************************************************/
+/* tables only (mbla.c)
+/*********************************************************************/
+
+bool rpl_itm(); 
+    /* btreeptr *pptr1, *pptr2; itemptr pitm; bool *p_added */
+bool del_itm(); 
+    /* btreeptr *pptr1; itemptr pitm */
+value assocval();      /* btreeptr pnode; value key; */
+bool assocloc();
+    /* value **ploc; btreeptr pnode; value key; */
+bool u_assoc();        /* btreeptr pnode; value key; */
+
+/***************** Texts, lists and tables ********************/
+/* Procedure move_itm(); */    /* itemptr pdes, psrc; literal it; */
+bool get_th_item();    /* itemptr pitm; value num, v; */
+
+#endif !INTEGRATION
diff --git a/usr/src/new/B/src/bint/b1mem.h b/usr/src/new/B/src/bint/b1mem.h
new file mode 100644 (file)
index 0000000..6563a14
--- /dev/null
@@ -0,0 +1,19 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b1mem.h,v 1.4 85/08/22 16:41:48 timo Exp $
+*/
+
+/* bmem.h: B memory management */
+
+typedef char *ptr;
+#define Nil ((ptr) 0)
+
+#define getmem get_mem
+
+ptr getmem();
+
+/* Procedure regetmem(); */
+/* Procedure freemem(); */
+/* Procedure prgr(); */
+/* Procedure initmem(); */
diff --git a/usr/src/new/B/src/bint/b1num.h b/usr/src/new/B/src/bint/b1num.h
new file mode 100644 (file)
index 0000000..0888ac7
--- /dev/null
@@ -0,0 +1,154 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b1num.h,v 1.4 85/08/22 16:41:53 timo Exp $
+*/
+
+/************************************************************************/
+/* Full numeric package: private definitions                            */
+/*                                                                      */
+/* A number is modelled as one of zero, unbounded integer,              */
+/*        unbounded rational or approximate.                            */
+/*     Zero has a 'length' field of zero, and nothing else.             */
+/*     A length field of +n means the number is an n digit integer,     */
+/*        (with digits to some large base).                             */
+/*     A length of -1 means there follow two floating point numbers,    */
+/*        one the fraction (zero or .5 <= frac <= 1), one the exponent  */
+/*        with respect to base 2 (should be an integral value).         */
+/*        (This is so when EXT_RANGE is defined.  Otherwise, there is   */
+/*        only one field, frac, which is not normalized.  This saves    */
+/*        code and data space on e.g. the IBM PC, where the natural     */
+/*        range of double's is sufficient (~1E307).)                    */
+/*     A length of -2 means there follow two values, pointers to two    */
+/*        unbounded integers, ie a rational number.                     */
+/*     A length of -n, n>2, means it is a rational with a print width   */
+/*        of n-2.                                                       */
+/*                                                                      */
+/************************************************************************/
+
+/*************** Definitions exported for integers *****************/
+
+typedef int digit;
+
+typedef struct integer {
+       HEADER;
+       digit   dig[1];
+} *integer;
+
+#define FreezeSmallInt(v, vv) \
+       (IsSmallInt(v) && (Freeze1(v, vv), Freeze2(v, vv)))
+#define Freeze1(v, vv) ((vv).type= Num, (vv).refcnt= Maxrefcnt)
+#define Freeze2(v, vv) \
+       ((vv).len= (v) != 0, (vv).dig[0]= SmallIntVal(v), (v)= &(vv))
+
+integer int_gadd();
+integer int_canon();
+integer int_prod();
+integer int_quot();
+integer int_gcd();
+integer mk_int();
+integer int1mul();
+integer int_tento();
+integer int_half();
+integer int_mod();
+digit int_ldiv();
+
+#define int_0 ((integer) MkSmallInt(0))
+#define int_1 ((integer) MkSmallInt(1))
+#define int_2 ((integer) MkSmallInt(2))
+#define int_10 ((integer) MkSmallInt(10))
+
+#define int_sum(v, w) int_gadd(v, w, 1)
+#define int_diff(v, w) int_gadd(v, w, -1)
+#define int_neg(v) int_gadd(int_0, v, -1)
+
+#define Integral(v) (IsSmallInt(v) || Length(v)>=0)
+#define Modulo(a,b) (((a)%(b)+(b))%(b))
+#define Digit(v,n) ((v)->dig[n])
+#define Msd(v) (IsSmallInt(v) ? SmallIntVal(v) : Digit(v,Length(v)-1))
+#define Lsd(v) (IsSmallInt(v) ? SmallIntVal(v) : Digit(v,0))
+
+#define Odd(x) ((x)&1)
+#define Even(x) (!Odd(x))
+
+/* Provisional definitions */
+
+value copy();
+#define Copy(x) copy((value)(x))
+
+/***************** Definitions exported for rationals *****************/
+
+typedef struct {
+       HEADER;
+       integer num, den;
+} *rational;
+
+
+#define Numerator(a) ((a)->num)
+#define Denominator(a) ((a)->den)
+#define Rational(a) (!IsSmallInt(a) && Length(a)<-1)
+#define Roundsize(a) (-2-Length(a))
+
+rational mk_rat();
+rational rat_sum();
+rational rat_diff();
+rational rat_neg();
+rational rat_prod();
+rational rat_quot();
+rational rat_power();
+
+extern rational rat_zero;
+extern rational rat_half;
+
+value tento();
+value mk_exact();
+
+/***************** Definitions exported for approximate numbers *************/
+
+#ifdef vax
+#define EXT_RANGE
+#endif
+
+typedef struct real {
+       HEADER;
+       double  frac;
+#ifdef EXT_RANGE
+       double  expo;
+#endif EXT_RANGE
+} *real;
+
+#define Frac(v) ((v)->frac)
+#ifdef EXT_RANGE
+#define Expo(v) ((v)->expo)
+#else
+#define Expo(v) 0.0
+#endif
+
+#define Approximate(v) (!IsSmallInt(v) && Length(v)==-1)
+#define Exact(v) (!Approximate(v))
+
+extern real app_0;
+
+real mk_approx();
+
+real app_sum();
+real app_diff();
+real app_prod();
+real app_quot();
+real app_neg();
+
+real app_exp();
+real app_log();
+real app_power();
+
+value app_floor();
+
+
+/* Numeric constants. */
+/* (Source: Knuth, The Art of Computer Programming, Vol. 1, Appendix B-1.) */
+
+#define logtwo 0.6931471805599453094172321214581765680755
+#define invlogtwo 1.4426950408889634073599246810018921374266
+#define logten 2.3025850929940456840179914546843642076011
+#define logBASE (logten*tenlogBASE)
+#define twologBASE (logBASE*invlogtwo)
diff --git a/usr/src/new/B/src/bint/b1obj.h b/usr/src/new/B/src/bint/b1obj.h
new file mode 100644 (file)
index 0000000..fd0b352
--- /dev/null
@@ -0,0 +1,201 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b1obj.h,v 1.4 85/08/22 16:42:02 timo Exp $
+*/
+
+/* B values, locations, environments: the B abstract machine */
+
+/****************************** general ******************************/
+
+typedef int relation; /* < 0, == 0, > 0 */
+relation compare();
+
+#define Is_text(v) (Type(v) == Tex)
+#define Is_number(v) (Type(v) == Num)
+#define Is_compound(v) (Type(v) == Com)
+#define Is_list(v) (Type(v) == Lis || Type(v) == ELT)
+#define Is_table(v) (Type(v) == Tab || Type(v) == ELT)
+#define Is_tlt(v) (Type(v)==Tex || Type(v)==Lis || Type(v)==Tab || Type(v)==ELT)
+#define Is_ELT(v) (Type(v) == ELT)
+
+#define Is_parsetree(v) (Type(v) == Ptn)
+#define Is_locloc(v) IsSmallInt(v)
+#define Is_simploc(v) (Type(v) == Sim)
+#define Is_tbseloc(v) (Type(v) == Tse)
+#define Is_trimloc(v) (Type(v) == Tri)
+#define Is_refinement(v) (Type(v) == Ref)
+#define Is_formal(v) (Type(v) == For)
+#define Is_filed(v) (Type(v) == Per)
+#define Is_function(v) (Type(v) == Fun)
+#define Is_predicate(v) (Type(v) == Prd)
+#define Is_howto(v) (Type(v) == How)
+
+value grab_num();
+value regrab_num();
+value grab_rat();
+value grab_tex();
+value grab_com();
+value grab_elt();
+value grab_lis();
+value grab_tab();
+value grab_ptn();
+value grab_sim();
+value grab_tri();
+value grab_tse();
+value grab_how();
+value grab_for();
+value grab_per();
+value grab_fun();
+value grab_prd();
+value grab_ref();
+
+value copy();
+/* Procedure release(); */
+/* Procedure uniql(); */
+/* Procedure uniq_assoc(); */
+double hash();
+
+/****************************** Texts ******************************/
+string strcpy(), strncpy(), strcat(), sprintf(), index();
+
+bool character();
+
+value mk_text();
+char charval();
+string strval();
+
+value concat();
+value behead();
+value curtail();
+#ifdef INTEGRATION
+value trim();
+#endif
+value repeat();
+
+value adjleft();
+value centre();
+value adjright();
+
+value convert();
+
+/****************************** Numbers ******************************/
+
+/* Predicates */
+bool integral();           /* is the value an integer? */
+bool large();      /* can a number be represented by a C int? */
+
+/* Constants */
+#define zero MkSmallInt(0)
+#define one MkSmallInt(1)
+
+/* Conversion of abstract values to concrete objects */
+double numval();     /* numeric value of any number */
+int intval();        /* numeric value of integral number */
+intlet propintlet(); /* converts int to intlet */
+string convnum();    /* character string approximation of any number */
+relation numcomp();  /* comparison of two numbers: yields -1, 0 or 1 */
+double numhash();    /* hashes any abstract number to a 'double' */
+
+/* Conversion of concrete objects to abstract numbers */
+value numconst();    /* string argument */
+value mk_integer();  /* int argument */
+
+/* Functions on numbers */
+value sum();
+value diff();
+value negated();
+value prod();
+value quot();
+value modulo();
+value floorf();
+value ceilf();
+value round1();
+value round2();
+value mod();
+value power();
+value absval();
+value signum();
+value numerator();
+value denominator();
+value approximate();
+value random();
+value root1();
+value sin1();
+value cos1();
+value tan1();
+value atn1();
+value exp1();
+value log1();
+value root2();
+value atn2();
+value log2();
+value pi();
+value e();
+
+/****************************** Compounds ******************************/
+#define Nfields(c) Length(c)
+#define Field(c, i) ((Ats(c)+(i)))
+#define k_Overfields for (k= 0; k < len; k++)
+#define Lastfield(k) ((k) == len-1)
+
+#define mk_compound(len) grab_com(len)
+
+/****************************** Lists ******************************/
+value mk_numrange();
+value mk_charrange();
+
+/* Procedure insert(); */
+/* Procedure remove(); */
+
+/****************************** Tables ******************************/
+
+value keys();
+bool in_keys();
+value associate();
+
+/* Procedure replace(); */
+/* Procedure delete(); */
+
+value* adrassoc();
+value* key();
+value* assoc();
+
+/****************************** Texts, Lists, and Tables *******************/
+value mk_elt();
+
+bool in();
+
+value size();
+value size2();
+value min1();
+value min2();
+value max1();
+value max2();
+value th_of();
+value thof();
+
+int length(); /* The same as size, temporary until part2 is written in B */
+bool empty(); /* whether #v=0: also temporary */
+
+/****************************** Other kinds of value ************************/
+
+#define Simploc(l) ((simploc *)Ats(l))
+#define Tbseloc(l) ((tbseloc *)Ats(l))
+#define Trimloc(l) ((trimloc *)Ats(l))
+#define Funprd(f)  ((funprd *)Ats(f))
+#define How_to(u)  ((how *)Ats(u))
+#define Formal(f)  ((formal *)Ats(f))
+#define Refinement(r) ((ref *)Ats(r))
+#define Perm(p) ((per *)Ats(p))
+
+loc mk_simploc();
+loc mk_trimloc();
+loc mk_tbseloc();
+
+value mk_per();
+fun mk_fun();
+prd mk_prd();
+value mk_how();
+value mk_ref();
+
diff --git a/usr/src/new/B/src/bint/b1tlt.h b/usr/src/new/B/src/bint/b1tlt.h
new file mode 100644 (file)
index 0000000..c1e8779
--- /dev/null
@@ -0,0 +1,47 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b1tlt.h,v 1.4 85/08/22 16:42:12 timo Exp $
+*/
+
+#ifndef INTEGRATION
+
+/* Private definitions for B texts, lists and tables */
+
+typedef struct telita {
+    HEADER; btreeptr root;
+} a_telita, *telita;
+
+#define Itemtype(v) (((telita) (v))->len) /* Itemtype */
+#define Root(v) (((telita) (v))->root)
+#define Tltsize(v) (Root(v) EQ Bnil ? 0 : Size(Root(v)))
+
+#define Character(v)   ((bool) (Type(v) EQ Tex && Tltsize(v) EQ 1))
+value mkchar();        /* char c */
+
+#else INTEGRATION
+
+/************************************************************************/
+/* Private definitions for small texts, lists and tables module         */
+/* A text is modelled as a sequence of len characters.                  */
+/*                                                                      */
+/* A list is modelled as a sequence of len values,                      */
+/*         each of which corresponds to a list entry.                   */
+/*                                                                      */
+/* A table is modelled as a sequence of len values,                     */
+/*         each of which corresponds to a table entry;                  */
+/*     table entries are modelled as a compound with two fields.        */
+/************************************************************************/
+
+#define Cts(v) (*Ats(v))
+#define Dts(v) (*(Ats(v)+1))
+
+#define List_elem(l, i) (*(Ats(l)+i)) /*counts from 0; takes no copy*/
+#define Key(t, i) (Ats(*(Ats(t)+i))) /*Ditto*/
+#define Assoc(t, i) (Ats(*(Ats(t)+i))+1) /*Ditto*/
+
+bool found();
+value list_elem();
+value key_elem();
+
+#endif INTEGRATION
diff --git a/usr/src/new/B/src/bint/b1val.h b/usr/src/new/B/src/bint/b1val.h
new file mode 100644 (file)
index 0000000..e172451
--- /dev/null
@@ -0,0 +1,22 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b1val.h,v 1.4 85/08/22 16:42:19 timo Exp $
+*/
+
+#ifndef INTEGRATION
+
+/* Private definitions for grabbing and ref count scheme */
+
+value grab_tlt();      /* literal type, it; */
+
+btreeptr grabbtreenode();      /* literal flag, it */
+btreeptr copybtree();          /* btreeptr pnode */
+/* Procedure uniqlbtreenode(); */      /* btreeptr *pptr; literal it */
+btreeptr ccopybtreenode();     /* btreeptr pnode; literal it */
+btreeptr mknewroot();
+    /* btreeptr ptr0, itemptr pitm0, btreeptr ptr1, literal it */
+/* Procedure relbtree(); */            /* btreeptr pnode; literal it */
+/* Procedure freebtreenode(); */       /* btreeptr pnode; */
+
+#endif !INTEGRATION
diff --git a/usr/src/new/B/src/bint/b2exp.h b/usr/src/new/B/src/bint/b2exp.h
new file mode 100644 (file)
index 0000000..7db9449
--- /dev/null
@@ -0,0 +1,67 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2exp.h,v 1.4 85/08/22 16:42:25 timo Exp $
+*/
+
+/* General definitions for parsing expressions */
+
+typedef struct { bool parsed, prop, trim;
+                intlet state, level, field;
+                value comp;
+               } expadm;
+
+typedef struct { bool prop, trim;
+                intlet level, field;
+                parsetree node;
+               } unpadm;
+
+#define Parsed(adm)    ((adm)->parsed)
+#define Prop(adm)      ((adm)->prop)
+#define Trim(adm)      ((adm)->trim)
+#define State(adm)     ((adm)->state)
+#define Level(adm)     ((adm)->level)
+#define N_fld(adm)     ((adm)->field)
+#define Unp_comp(adm)  ((adm)->comp)
+#define Node(adm)      ((adm)->node)
+
+/* ********************************************************************        */
+/* Levels:                                                             */
+/*                                                                     */
+#define L_bottom       0
+#define L_term         1 /* plus, minus, join */
+#define L_factor       2 /* times, over */
+#define L_power                3 /* power */
+#define L_number       4 /* number  */
+#define L_expr         5 /* tag, repeat_text, center, (left|right)_adjust */
+
+#define Prio \
+       MESS(1900, "cannot determine priorities; use ( and ) to resolve")
+
+/* ******************************************************************** */
+/* States:                                                             */
+/*                                                                     */
+#define S_t    1
+#define S_tt   2
+#define S_else 3
+
+/* ******************************************************************** */
+
+bool b_about();
+bool b_numtor();
+bool b_denomtor();
+bool b_plus();
+bool b_minus();
+bool b_number();
+bool b_behead();
+bool b_curtail();
+#ifdef NOT_USED
+bool b_times();
+bool b_over();
+bool b_power();
+bool b_join();
+bool b_reptext();
+bool b_center();
+bool b_leftadj();
+bool b_rightadj();
+#endif
diff --git a/usr/src/new/B/src/bint/b2gen.h b/usr/src/new/B/src/bint/b2gen.h
new file mode 100644 (file)
index 0000000..dfd357e
--- /dev/null
@@ -0,0 +1,25 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2gen.h,v 1.4 85/08/22 16:42:31 timo Exp $
+*/
+
+#define Is_node(t) ((t) != NilTree && Is_parsetree(t))
+
+extern int nextvarnumber; /* Counts local targets (including formals) */
+extern value formals, locals, globals, mysteries, refinements;
+extern string gentab[];
+
+#define NTYPES (FORMAL+1)
+
+struct state {
+       parsetree h_last;
+       parsetree *h_wanthere;
+       parsetree h_bpchain;
+};
+
+#define f_expr(p) fix(p, 'v') /* "evaluate" */
+#define f_targ(p) fix(p, 'l') /* "locate" */
+
+value copydef();
+bool modify_tag();
diff --git a/usr/src/new/B/src/bint/b2key.h b/usr/src/new/B/src/bint/b2key.h
new file mode 100644 (file)
index 0000000..1fab5f1
--- /dev/null
@@ -0,0 +1,66 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2key.h,v 1.4 85/08/22 16:42:35 timo Exp $
+*/
+
+/* Keywords collected together to aid the production of national variants */
+/* Predefined functions can be found in bfpr.c                           */
+/* All error messages will have to be changed as well, of course.        */
+
+#define K_PUT "PUT"
+#define K_IN_put "IN"
+
+#define K_INSERT "INSERT"
+#define K_IN_insert "IN"
+
+#define K_REMOVE "REMOVE"
+#define K_FROM_remove "FROM"
+
+#define K_DELETE "DELETE"
+
+#define K_READ "READ"
+#define K_RAW "RAW"
+#define K_EG "EG"
+
+#define K_WRITE "WRITE"
+
+#define K_CHOOSE "CHOOSE"
+#define K_FROM_choose "FROM"
+
+#define K_DRAW "DRAW"
+#define K_SET_RANDOM "SET'RANDOM"
+
+#define K_CHECK "CHECK"
+
+#define K_IF "IF"
+
+#define K_SELECT "SELECT"
+#define K_ELSE "ELSE"
+
+#define K_WHILE "WHILE"
+
+#define K_FOR "FOR"
+#define K_IN_for "IN"
+
+#define K_SUCCEED "SUCCEED"
+#define K_FAIL "FAIL"
+#define K_QUIT "QUIT"
+#define K_RETURN "RETURN"
+#define K_REPORT "REPORT"
+
+#define K_HOW_TO "HOW'TO"
+#define K_YIELD "YIELD"
+#define K_TEST "TEST"
+#define K_SHARE "SHARE"
+
+#define K_AND "AND"
+#define K_OR "OR"
+#define K_NOT "NOT"
+
+#define K_SOME "SOME"
+#define K_EACH "EACH"
+#define K_NO "NO"
+#define K_IN_quant "IN"
+#define K_PARSING "PARSING"
+#define K_HAS "HAS"
diff --git a/usr/src/new/B/src/bint/b2nod.h b/usr/src/new/B/src/bint/b2nod.h
new file mode 100644 (file)
index 0000000..6d425e1
--- /dev/null
@@ -0,0 +1,261 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2nod.h,v 1.4 85/08/22 16:42:43 timo Exp $
+*/
+
+/* Units */
+
+typedef intlet typenode;
+
+#define _Nodetype(len)   ((len) & 0377)
+#define _Nbranches(len)  ((len) >> 8)
+#define Nodetype(v)   _Nodetype((v)->len)
+#define Nbranches(v)  _Nbranches((v)->len)
+#define Branch(v, n)  ((Ats(v)+(n)))
+
+#define Unit(n)              (n>=HOW_TO && n<=REFINEMENT)
+#define Command(n)    (n>=SUITE && n<=EXTENDED_COMMAND)
+#define Expression(n) ((n>=TAG && n<=TAB_DIS)||(n>=TAGformal && n<=TAGzerprd))
+#define Comparison(n) (n>=LESS_THAN && n<=UNEQUAL)
+
+#define HOW_TO                 0
+#define YIELD                  1
+#define TEST                   2
+#define REFINEMENT             3
+
+/* Commands */
+
+#define SUITE                  4
+#define PUT                    5
+#define INSERT                 6
+#define REMOVE                 7
+#define CHOOSE                 8
+#define DRAW                   9
+#define SET_RANDOM             10
+#define DELETE                 11
+#define CHECK                  12
+#define SHARE                  13
+
+#define WRITE                  14
+#define READ                   15
+#define READ_RAW               16
+
+#define IF                     17
+#define WHILE                  18
+#define FOR                    19
+
+#define SELECT                 20
+#define TEST_SUITE             21
+#define ELSE                   22
+
+#define QUIT                   23
+#define RETURN                 24
+#define REPORT                 25
+#define SUCCEED                        26
+#define FAIL                   27
+
+#define USER_COMMAND           28
+#define EXTENDED_COMMAND       29
+
+/* Expressions, targets, tests */
+
+#define TAG                    30
+#define COMPOUND               31
+
+/* Expressions, targets */
+
+#define COLLATERAL             32
+#define SELECTION              33
+#define BEHEAD                 34
+#define CURTAIL                        35
+
+/* Expressions, tests */
+
+#define UNPARSED               36
+
+/* Expressions */
+
+#define MONF                   37
+#define DYAF                   38
+#define NUMBER                 39
+#define TEXT_DIS               40
+#define TEXT_LIT               41
+#define TEXT_CONV              42
+#define ELT_DIS                        43
+#define LIST_DIS               44
+#define RANGE_DIS              45
+#define TAB_DIS                        46
+
+/* Tests */
+
+#define AND                    47
+#define OR                     48
+#define NOT                    49
+#define SOME_IN                        50
+#define EACH_IN                        51
+#define NO_IN                  52
+#define SOME_PARSING           53
+#define EACH_PARSING           54
+#define NO_PARSING             55
+#define MONPRD                 56
+#define DYAPRD                 57
+#define LESS_THAN              58
+#define AT_MOST                        59
+#define GREATER_THAN           60
+#define AT_LEAST               61
+#define EQUAL                  62
+#define UNEQUAL                        63
+#define Nonode                 64
+
+#define TAGformal              65
+#define TAGlocal               66
+#define TAGglobal              67
+#define TAGmystery             68
+#define TAGrefinement          69
+#define TAGzerfun              70
+#define TAGzerprd              71
+
+#define ACTUAL                 72
+#define FORMAL                 73
+
+value node1();
+value node2();
+value node3();
+value node4();
+value node5();
+value node6();
+value node8();
+value node9();
+typenode nodetype();
+/* Procedure display(); */
+/* Procedure fix_nodes(); */
+
+#define First_fieldnr  0
+
+#define UNIT_NAME      First_fieldnr
+#define HOW_FORMALS    First_fieldnr + 1       /* HOW'TO */
+#define HOW_COMMENT    First_fieldnr + 2
+#define HOW_SUITE      First_fieldnr + 3
+#define HOW_REFINEMENT First_fieldnr + 4
+#define HOW_R_NAMES    First_fieldnr + 5
+#define HOW_NLOCALS    First_fieldnr + 6
+#define FPR_ADICITY    First_fieldnr + 1       /* YIELD, TEST */
+#define FPR_FORMALS    First_fieldnr + 2
+#define FPR_COMMENT    First_fieldnr + 3
+#define FPR_SUITE      First_fieldnr + 4
+#define FPR_REFINEMENT First_fieldnr + 5
+#define FPR_R_NAMES    First_fieldnr + 6
+#define FPR_NLOCALS    First_fieldnr + 7
+
+#define FML_KEYW       First_fieldnr           /* FORMALS HOW'TO */
+#define FML_TAG                First_fieldnr + 1
+#define FML_NEXT       First_fieldnr + 2
+
+#define SUI_LINO       First_fieldnr           /* SUITE */
+#define SUI_CMD                First_fieldnr + 1
+#define SUI_COMMENT    First_fieldnr + 2
+#define SUI_NEXT       First_fieldnr + 3
+#define REF_NAME       First_fieldnr           /* REFINEMENT */
+#define REF_COMMENT    First_fieldnr + 1
+#define REF_SUITE      First_fieldnr + 2
+#define REF_NEXT       First_fieldnr + 3
+#define REF_START      First_fieldnr + 4
+
+#define PUT_EXPR       First_fieldnr           /* PUT */
+#define PUT_TARGET     First_fieldnr + 1
+#define INS_EXPR       First_fieldnr           /* INSERT */
+#define INS_TARGET     First_fieldnr + 1
+#define RMV_EXPR       First_fieldnr           /* REMOVE */
+#define RMV_TARGET     First_fieldnr + 1
+#define CHS_TARGET     First_fieldnr           /* CHOOSE */
+#define CHS_EXPR       First_fieldnr + 1
+#define DRW_TARGET     First_fieldnr           /* DRAW */
+#define SET_EXPR       First_fieldnr           /* SET'RANDOM */
+#define DEL_TARGET     First_fieldnr           /* DELETE */
+#define CHK_TEST       First_fieldnr           /* CHECK */
+#define SHR_TARGET     First_fieldnr           /* SHARE */
+
+#define WRT_L_LINES    First_fieldnr           /* WRITE */
+#define WRT_EXPR       First_fieldnr + 1
+#define WRT_R_LINES    First_fieldnr + 2
+#define RD_TARGET      First_fieldnr           /* READ */
+#define RD_EXPR                First_fieldnr + 1
+#define RDW_TARGET     First_fieldnr           /* READ'RAW */
+
+#define IF_TEST                First_fieldnr           /* IF */
+#define IF_COMMENT     First_fieldnr + 1
+#define IF_SUITE       First_fieldnr + 2
+#define WHL_TEST       First_fieldnr           /* WHILE */
+#define WHL_COMMENT    First_fieldnr + 1
+#define WHL_SUITE      First_fieldnr + 2
+#define FOR_TARGET     First_fieldnr           /* FOR */
+#define FOR_EXPR       First_fieldnr + 1
+#define FOR_COMMENT    First_fieldnr + 2
+#define FOR_SUITE      First_fieldnr + 3
+
+#define SLT_COMMENT    First_fieldnr           /* SELECT */
+#define SLT_TSUITE     First_fieldnr + 1
+#define TSUI_LINO      First_fieldnr           /* TEST SUITE */
+#define TSUI_TEST      First_fieldnr + 1
+#define TSUI_COMMENT   First_fieldnr + 2
+#define TSUI_SUITE     First_fieldnr + 3
+#define TSUI_NEXT      First_fieldnr + 4
+#define ELSE_LINO      First_fieldnr           /* ELSE */
+#define ELSE_COMMENT   First_fieldnr + 1
+#define ELSE_SUITE     First_fieldnr + 2
+
+#define RTN_EXPR       First_fieldnr           /* RETURN */
+#define RPT_TEST       First_fieldnr           /* REPORT */
+
+#define UCMD_NAME      First_fieldnr           /* USER COMMAND */
+#define UCMD_ACTUALS   First_fieldnr + 1
+#define UCMD_DEF       First_fieldnr + 2
+#define ACT_KEYW       First_fieldnr           /* ACTUALS USER COMMAND */
+#define ACT_EXPR       First_fieldnr + 1
+#define ACT_NEXT       First_fieldnr + 2
+#define ACT_START      First_fieldnr + 3
+
+#define ECMD_NAME      First_fieldnr           /* EXTENDED COMMAND */
+#define ECMD_ACTUALS   First_fieldnr + 1
+
+#define COMP_FIELD     First_fieldnr           /* COMPOUND */
+#define COLL_SEQ       First_fieldnr           /* COLLATERAL */
+#define MON_NAME       First_fieldnr           /* MONADIC FUNCTION */
+#define MON_RIGHT      First_fieldnr + 1
+#define MON_FCT                First_fieldnr + 2
+#define DYA_NAME       First_fieldnr + 1       /* DYADIC FUNCTION */
+#define DYA_LEFT       First_fieldnr
+#define DYA_RIGHT      First_fieldnr + 2
+#define DYA_FCT                First_fieldnr + 3
+#define TAG_NAME       First_fieldnr           /* TAG */
+#define TAG_ID         First_fieldnr + 1
+#define NUM_VALUE      First_fieldnr           /* NUMBER */
+#define NUM_TEXT       First_fieldnr + 1
+#define XDIS_QUOTE     First_fieldnr           /* TEXT DIS */
+#define XDIS_NEXT      First_fieldnr + 1
+#define XLIT_TEXT      First_fieldnr           /* TEXT LIT */
+#define XLIT_NEXT      First_fieldnr + 1
+#define XCON_EXPR      First_fieldnr           /* TEXT CONV */
+#define XCON_NEXT      First_fieldnr + 1
+#define LDIS_SEQ       First_fieldnr           /* LIST DIS */
+#define RDIS_LWB       First_fieldnr           /* RANGE DIS */
+#define RDIS_UPB       First_fieldnr + 1
+#define TDIS_SEQ       First_fieldnr           /* TAB_DIS */
+#define SEL_TABLE      First_fieldnr           /* SELECTION */
+#define SEL_KEY                First_fieldnr + 1
+#define TRIM_LEFT      First_fieldnr           /* BEHEAD, CURTAIL */
+#define TRIM_RIGHT     First_fieldnr + 1
+#define UNP_SEQ                First_fieldnr           /* UNPARSED */
+#define UNP_TEXT       First_fieldnr + 1
+
+#define AND_LEFT       First_fieldnr           /* AND */
+#define AND_RIGHT      First_fieldnr + 1
+#define OR_LEFT                First_fieldnr           /* OR */
+#define OR_RIGHT       First_fieldnr + 1
+#define NOT_RIGHT      First_fieldnr           /* NOT */
+#define QUA_TARGET     First_fieldnr           /* QUANTIFICATION */
+#define QUA_EXPR       First_fieldnr + 1
+#define QUA_TEST       First_fieldnr + 2
+#define REL_LEFT       First_fieldnr           /* ORDER TEST */
+#define REL_RIGHT      First_fieldnr + 1
diff --git a/usr/src/new/B/src/bint/b2par.h b/usr/src/new/B/src/bint/b2par.h
new file mode 100644 (file)
index 0000000..3dc13e2
--- /dev/null
@@ -0,0 +1,50 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2par.h,v 1.4 85/08/22 16:42:58 timo Exp $
+*/
+
+/* General definitions for the parser */
+
+/* contexts: */
+#define In_share 's'
+#define In_ranger 'q'
+#define In_ref 'r'
+
+/* Expressions: */
+
+parsetree expr();
+parsetree singexpr();
+bool tag_operator();
+bool is_b_tag();
+/* Procedure selection(); */
+
+/* Targets: */
+
+parsetree targ(); 
+/* Procedure tar_trimmed_text(); */
+
+/* Tests: */
+
+parsetree test(); 
+parsetree unp_test();
+extern bool dya_proposition;
+
+/* Commands: */
+
+parsetree cmd_suite();
+/* Procedure suite_command(); */
+bool simple_command();
+bool control_command();
+bool term_com();
+bool is_comment();
+value tail_line();
+
+/* B units */
+
+parsetree unit();
+bool unit_keyword();
+parsetree collateral();
+parsetree compound();
+parsetree idf();
+extern literal idf_cntxt;
diff --git a/usr/src/new/B/src/bint/b2syn.h b/usr/src/new/B/src/bint/b2syn.h
new file mode 100644 (file)
index 0000000..9f03fed
--- /dev/null
@@ -0,0 +1,132 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2syn.h,v 1.4 85/08/22 16:43:04 timo Exp $
+*/
+
+/* General parsing routines */
+
+#define Eotc '\0'
+
+#define Char(tx)       (*(tx))
+#define Eol(tx)                (Char(tx) == '\n')
+#define Ceol(tx)       (Char(tx) == '\\' || Eol(tx))
+#define Text(q)        (tx < q)
+
+#define Space(c)       ((c) == ' ' || (c) == '\t')
+
+#define Letter(c)      ('a'<=c&&c<='z')
+#define Cap(c)         ('A'<=c&&c<='Z')
+#define Dig(c)         ('0'<=c&&c<='9')
+
+/* Procedure skipsp(); */
+/* Procedure upto(); */
+/* Procedure need(); */
+/* Procedure findceol(); */
+/* Procedure req(); */
+/* Procedure veli(); */
+
+bool keymark();
+
+txptr fcol();
+bool nothing(); 
+bool ateol();
+bool findkw(); 
+value keyword();
+value tag();
+bool find();
+
+extern txptr tx, ceol, first_col;
+extern intlet cur_ilev;
+intlet ilev();
+
+extern value kwlist;
+
+value cr_text();
+bool is_keyword();
+bool is_tag();
+bool findrel();
+extern string textsign;
+
+bool is_expr();
+
+#ifdef NOT_USED
+bool colon_sign();
+#endif
+bool comment_sign();
+bool nwl_sign();
+bool open_sign();
+#ifdef NOT_USED
+bool close_sign();
+bool comma_sign();
+#endif
+bool point_sign();
+bool apostrophe_sign();
+bool quote_sign();
+bool conv_sign();
+bool curlyopen_sign();
+bool curlyclose_sign();
+bool sub_sign();
+#ifdef NOT_USED
+bool bus_sign();
+#endif
+bool behead_sign();
+bool curtl_sign();
+bool about_sign();
+bool plus_sign();
+bool minus_sign();
+bool times_sign();
+bool over_sign();
+bool power_sign();
+bool numtor_sign();
+bool denomtor_sign();
+bool join_sign();
+bool reptext_sign();
+bool leftadj_sign();
+bool center_sign();
+bool rightadj_sign();
+bool number_sign();
+bool less_than_sign();
+bool at_most_sign();
+bool equals_sign();
+bool unequal_sign();
+bool at_least_sign();
+bool greater_than_sign();
+
+bool dyamon_sign();
+bool dya_sign();
+bool mon_sign();
+bool trim_sign();
+
+bool check_keyword();
+bool choose_keyword();
+bool delete_keyword();
+bool draw_keyword();
+bool insert_keyword();
+bool put_keyword();
+bool read_keyword();
+bool remove_keyword();
+bool setrandom_keyword();
+bool write_keyword();
+bool fail_keyword();
+bool quit_keyword();
+bool return_keyword();
+bool report_keyword();
+bool succeed_keyword();
+bool if_keyword();
+bool select_keyword();
+bool while_keyword();
+bool for_keyword();
+bool else_keyword();
+#ifdef NOT_USED
+bool and_keyword();
+bool or_keyword();
+#endif
+bool not_keyword();
+bool some_keyword();
+bool each_keyword();
+bool no_keyword();
+bool how_to_keyword();
+bool yield_keyword();
+bool test_keyword();
+bool share_keyword();
diff --git a/usr/src/new/B/src/bint/b2tcE.h b/usr/src/new/B/src/bint/b2tcE.h
new file mode 100644 (file)
index 0000000..8c3c6c8
--- /dev/null
@@ -0,0 +1,17 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2tcE.h,v 1.4 85/08/22 16:43:15 timo Exp $
+*/
+
+/* type unification errors */
+
+/* Procedure start_vars(); */          /* */
+/* Procedure add_var(); */             /* polytype tvar */
+/* Procedure end_vars(); */            /* */
+
+/* Procedure setreprtable(); */        /* */
+/* Procedure delreprtable(); */                /* */
+
+/* Procedure badtyperr(); */           /* polytype a, b */
+/* Procedure cyctyperr(); */           /* polytype a */
diff --git a/usr/src/new/B/src/bint/b2tcP.h b/usr/src/new/B/src/bint/b2tcP.h
new file mode 100644 (file)
index 0000000..e44ee3d
--- /dev/null
@@ -0,0 +1,76 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2tcP.h,v 1.4 85/08/22 16:43:20 timo Exp $
+*/
+
+/* polytype representation */
+
+typedef value typekind;
+typedef value polytype;
+
+/* accessing, NOT giving new values */
+
+typekind kind();       /* polytype u */
+intlet nsubtypes();    /* polytype u */
+polytype subtype();    /* polytype u, intlet i */
+polytype asctype();    /* polytype u */
+polytype keytype();    /* polytype u */
+value ident();                 /* polytype u */
+
+/* MaKe Types, where subtypes are "eaten" */
+
+polytype mkt_polytype(); /* typekind k; intlet nsub */
+                               /* visible only in bunif.c */
+/* Procedure putsubtype(); */  /* polytype sub, *pcomp; intlet isub */
+                               /* to be used after mkt_polytype or
+                                * mkt_compound */
+
+polytype mkt_number();
+polytype mkt_text();
+polytype mkt_tn();
+polytype mkt_error();
+polytype mkt_list();   /* polytype s */
+polytype mkt_table();  /* polytype k, a */
+polytype mkt_lt();     /* polytype s */
+polytype mkt_tlt();    /* polytype s */
+/* next to be used with putsubtype() calls */
+polytype mkt_compound();       /* intlet nsub */
+polytype mkt_var();    /* value id */
+polytype mkt_newvar();
+
+polytype p_copy();     /* polytype u */
+/* Procedure p_release(); */           /* polytype u */
+
+/* predicates */
+
+bool are_same_types();         /* polytype u, v */
+bool have_same_structure();/* polytype u, v */
+
+bool t_is_number();    /* typekind k */
+bool t_is_text();      /* typekind k */
+bool t_is_tn();                /* typekind k */
+bool t_is_error();     /* typekind k */
+bool t_is_list();      /* typekind k */
+bool t_is_table();     /* typekind k */
+bool t_is_lt();                /* typekind k */
+bool t_is_tlt();               /* typekind k */
+bool t_is_compound();  /* typekind k */
+bool t_is_var();               /* typekind k */
+bool has_number();     /* typekind k */
+bool has_text();       /* typekind k */
+bool has_lt();         /* typekind k */
+
+/* typetable */
+
+/* Procedure repl_type_of(); */ /* polytype u, tu */
+bool table_has_type_of();      /* polytype u */
+polytype type_of();            /* polytype u */
+polytype bottom_var();                 /* polytype u */
+
+/* Procedure usetypetable(); */                /* value t */
+/* Procedure deltypetable(); */
+
+/* init */
+
+/* Procedure initpol(); */     /* */
diff --git a/usr/src/new/B/src/bint/b2tcU.h b/usr/src/new/B/src/bint/b2tcU.h
new file mode 100644 (file)
index 0000000..b1ec751
--- /dev/null
@@ -0,0 +1,12 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b2tcU.h,v 1.4 85/08/22 16:43:30 timo Exp $
+*/
+
+/* unification of polytypes */
+
+/* Procedure unify(); */       /* polytype a, b, &u; bool &bad */
+
+bool contains();       /* polytype u, a */
+bool equal_vars();     /* polytype s, a */
diff --git a/usr/src/new/B/src/bint/b3env.h b/usr/src/new/B/src/bint/b3env.h
new file mode 100644 (file)
index 0000000..0c142cd
--- /dev/null
@@ -0,0 +1,31 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b3env.h,v 1.4 85/08/22 16:43:37 timo Exp $
+*/
+
+/* environments and context */
+
+value* lookup();
+bool in_env();
+value* envassoc();
+
+extern env curnv; extern value r_names, *bndtgs;
+extern literal cntxt, resexp; extern value uname;
+extern intlet lino;
+extern intlet f_lino;
+
+extern context read_context;
+
+extern envtab prmnvtab;
+extern envchain prmnvchain;
+extern env prmnv;
+
+/* Procedure sv_context(); */
+/* Procedure set_context(); */
+/* Procedure initenv(); */
+/* Procedure re_env(); */
+/* Procedure setprmnv(); */
+/* Procedure extbnd_tags(); */
+/* Procedure e_replace(); */
+/* Procedure e_delete(); */
diff --git a/usr/src/new/B/src/bint/b3err.h b/usr/src/new/B/src/bint/b3err.h
new file mode 100644 (file)
index 0000000..d366dfe
--- /dev/null
@@ -0,0 +1,25 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b3err.h,v 1.4 85/08/22 16:43:46 timo Exp $
+*/
+
+/* berr.h: B error message handling */
+
+extern intlet errlino; extern value erruname;
+extern parsetree curline;
+extern value curlino;
+extern context how_context, act_context;
+extern bool still_ok, interrupted;
+extern bool tracing;
+extern Procedure bye();
+
+/* Procedure syserr(); */
+/* Procedure memexh(); */
+/* Procedure error(); */
+/* Procedure parerr(); */
+/* Procedure pprerr(); */
+/* Procedure checkerr(); */
+/* Procedure debug(); */
+/* Procedure trace(); */
+/* Procedure int_signal(); */
diff --git a/usr/src/new/B/src/bint/b3ext.h b/usr/src/new/B/src/bint/b3ext.h
new file mode 100644 (file)
index 0000000..ab105e1
--- /dev/null
@@ -0,0 +1,15 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b3ext.h,v 1.4 85/08/22 16:43:52 timo Exp $
+*/
+
+#define MAXEARGS 10
+
+typedef struct ext {
+       string e_name;
+       string e_args[MAXEARGS];
+       int (*e_exec)(); /* should be void, but portability... */
+} ext;
+
+extern ext extensions[];
diff --git a/usr/src/new/B/src/bint/b3fil.h b/usr/src/new/B/src/bint/b3fil.h
new file mode 100644 (file)
index 0000000..60a72b9
--- /dev/null
@@ -0,0 +1,22 @@
+/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+
+/*
+  $Header: b3fil.h,v 1.4 85/08/22 16:43:58 timo Exp $
+*/
+
+/* File accessing */
+
+bool ws_writable();            /* enquire if write permission in workspace */
+unsigned f_size();             /* size of a file */
+bool f_exists();               /* enquire if a file exists */
+value f_save();                        /* temporarily copy a file to somewhere safe */
+#ifndef INTEGRATION
+bool f_interactive();          /* enquire if a file is the keyboard/screen */
+#endif
+value new_fname();             /* devise a filename for a unit or target */
+
+extern value file_names;       /* list of file names */
+
+/* Procedure f_edit(); */      /* call the editor for a file */
+/* Procedure f_rename(); */    /* rename a file */
+/* Procedure f_delete(); */    /* delete a file */