ref: 9d5c9d3fe5d8951fac0902abf125c68a6e720e52
dir: /dat.h/
typedef struct Term Term; typedef struct Binding Binding; typedef struct Goal Goal; typedef struct Choicepoint Choicepoint; typedef struct Clause Clause; typedef struct Predicate Predicate; typedef struct Module Module; typedef int (*Builtin)(Term *, Binding **, Module *); struct Term { int tag; Rune *text; int arity; Term *next; Term *children; vlong ival; double dval; uvlong clausenr; }; struct Binding { Rune *name; uvlong nr; /* Unique number for each clause. Every time a clause is used, it gets a new number. */ Term *value; Binding *next; }; struct Goal { Term *goal; Module *module; /* What module is this goal to be evaluated in? */ Term *catcher; /* When this is non-nil, the goal is a catch frame, goal is the recovery. */ Goal *next; }; struct Choicepoint { Goal *goalstack; Clause *alternative; Binding *altbindings; uvlong id; /* Unique number for each clause. Used to know where to cut to. */ Module *currentmodule; Choicepoint *next; }; struct Clause { Term *head; Term *body; uvlong clausenr; Clause *next; }; struct Predicate { Rune *name; int arity; int public; int builtin; /* All the predicates from the system module are builtin */ int dynamic; Clause *clauses; Predicate *next; }; struct Module { /* What about imports */ Rune *name; Predicate *predicates; Module *next; }; /* Sorted so that a lower value means it comes earlier in the standard ordering */ enum { VariableTerm, FloatTerm, IntegerTerm, AtomTerm, CompoundTerm, }; int debug; /* Flags */ enum { DoubleQuotesChars, DoubleQuotesCodes, DoubleQuotesAtom, }; int flagdoublequotes; /* State of the running system */ Choicepoint *choicestack; Goal *goalstack; Module *modules; Module *systemmodule; /* The module for the builtins. Everything has access to those */ Module *usermodule; /* The default module for user defined predicates */ uvlong clausenr; Binding *replbindings; /* The bindings used by the repl */ Term *replquery; /* The currently active repl query */