/* ----------------------------------------------------------
%   (C)1992 Institute for New Generation Computer Technology
%       (Read COPYRIGHT for detailed information.)
----------------------------------------------------------- */
/*=====================================================================
*		cu-Prolog III (Constraint Unification Prolog)
*   Copyright: Institute for New Generation Computer Technology,Japan 
*                           1989--91
==================================================================== */
/*--------------------------------------------------------------------
*               <<<<   varset.h    >>>>
*		initialize global vars
*       93.7.30 heap, stack
*       94.8.10 unsigned char for Kanji
--------------------------------------------------------------------*/

long CONSTRAINT_HANDLING_TIME = 0L;

FILE *fp,*wfp,*lfp; /* read file pointer, write fp, log fp */
int tty;
int cbuf;		/* character buffer */
struct ustack *utop;
int ECHO_BACK = 0;
int Handle_Undefined = FALSE; /* fail return */
int Print_Depth = 32;

int tflag;   /* trace flag  0-> off, 1-> on 2->step trace on */
int sflag;   /* solution mode flag  1->all solutions, 0->one solution */
int CTmode;			/* trace mode 0,1,2 */
int refute_node_count = -1;	/* refute node counter in c.t. */

/* Classification of Characters */
#define BL  001  /* blank */
#define UC  002  /* Upper Character */
#define LC  003  /* Lower Character */
#define UL  004  /* Undef Line */
#define N   005  /* Numeric */
#define SG  006  /* sign, +- */
#define SP  007  /* special character */
#define Q   010  /* quote */
#define CT  011  /* Cut */
#define CM  012  /* comment character */
#define BR  013  /* Brackets, Commas */
#define CO  014  /* Constraint Marker */

int char_type[128] = {
/* 00, 01, 02, 03, 04, 05, 06, 07, 10, 11, 12, 13, 14, 15, 16, 17 */
   BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, 
/* 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37 */
   BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, 
/* sp,  !,  "   #   $   %   &   '   (   )   *   +   ,   -   .   / */
   BL, CT,  Q, SP, SP, CM, SP,  Q, BR, BR, SP, SG, BR, SG, SP, SP,
/*  0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ? */
    N,  N,  N,  N,  N,  N,  N,  N,  N,  N, SP, CO, SP, SP, SP,  SP,
/*  @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O */
   SP, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC,
/*  P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _ */
   UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, BR, SP, BR, SP, UL,
/*  `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o */
   SP, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC,
/*  p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  del */
   LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, BR, BR, BR, SP, BL };

unsigned char nbuf[NAMELEN_MAX];	/* name buffer */
int  v_number = 0;		/* temporary var number */
int  p_number = 0;
struct term *v_list = NULL;		/* temporary var list */
struct term *pv_list = NULL;
struct func *f_list = NULL;	 /* new function list entry */
/* struct node *n_last = NULL;	*/ /* node list */
struct operator *o_list = NULL;
struct itrace *newf_list = NULL;	/* new function definition  */
struct pst_item *psttable;

int FNUMBER = 0;		/* function number seed */
int Def_Modified = 0;		/* def modified flag */

/*  system predicates in cu-prolog  */
struct func *LIST,*CUNIFY;
struct term *NIL,*FAIL, *END_OF_FILE;
struct clause *MFAIL;
struct term *XF_P, *YF_P, *FX_P, *FY_P, *XFX_P, *XFY_P, *YFX_P;
struct term *S_GLOBAL_VAR, *S_VAR, *S_INTEGER, *S_FLOAT;
struct term *S_STRING, *S_FILE_POINTER, *S_PST, *S_CLAUSE;
struct term *S_LIST, *S_FUNCTOR, *S_ATOM, *S_PSTOBJ;
struct term *S_EQ, *S_GREATER, *S_LESS;
struct term *Anonymous_var;
struct pair *Anonymous_env;

int Refcount;	/* maximum of refute counter */
int MODULARMAX;	/* maximum number of Variables in Transformation */

struct node  *Last_BT, *Last_SKIP;

char	genname[8] = "c",	/* generate function name c0,c1,... */
	logfile[32] = "no",	/* no log  */
        Anonymous_VarName[4]="_";
int tokentype, reread;
int GENSYM = 0;

/* default heap sizes */
int HEAP_SIZE=500000;   /* user heap size (KBytes)*/
int SHEAP_SIZE=1000000;	/* system heap size */
int ESP_SIZE=80000;   /* environment heap size */
int CHEAP_SIZE=1000000;   /* constraints/pst heap size */
int USTACK_SIZE=50000;	/* user stack size */
int NAME_SIZE=50000;   /* name string sie */

int *sheap;	/* system heap */
int *shp;
int *SHEAPTOP;
int *heap;	/* user heap */
int *Heap_Max;
int *hp;
int *HEAPTOP;
int *cheap;  /* constraints/pst heap */
int *CHEAPTOP;
int *Cheap_Max;
int *chp;
struct pair *eheap;  /* environment heap */
struct pair *ep;
struct pair *Esp_Max;
struct pair *ESPTOP;
struct ustack *ustack;	/* user stack */
struct ustack *usp;
struct ustack *STACKTOP;
struct ustack *Stack_Max;
char *nheap;   /* name string heap */
char *nhp;
char *NHEAPTOP;

#include <setjmp.h>
jmp_buf reset;		/* error recovery */
jmp_buf unbreak_reset;		/* trace --- unbreak */

/* for statistics */
int STAT_BACKTRACK_DEEP, STAT_BACKTRACK_SHAL, STAT_REFUTE;
int STAT_UNFOLD, STAT_FOLD, STAT_DEF;


syntax highlighted by Code2HTML, v. 0.9.1