summaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-07-16 00:42:49 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-07-16 00:42:49 +0000
commit1c8789198373a52da9e80dc9b2b1ee2b67af61c4 (patch)
tree980040a8d1828a85428b175eef9f6a4106248309 /dat.h
parent2a77288e28f2725b5621c239d2393d49f61993e8 (diff)
Make operators local to each module, and implement some more correct prettyprint code, used by write_term
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/dat.h b/dat.h
index f2e7e81..b5f6f4f 100644
--- a/dat.h
+++ b/dat.h
@@ -1,3 +1,6 @@
+#define PrecedenceLevels 1200
+
+typedef struct Operator Operator;
typedef struct Term Term;
typedef struct Binding Binding;
typedef struct Goal Goal;
@@ -7,6 +10,14 @@ typedef struct Predicate Predicate;
typedef struct Module Module;
typedef int (*Builtin)(Term *, Binding **, Module *);
+struct Operator
+{
+ int type;
+ int level;
+ Rune *spelling;
+ Operator *next;
+};
+
struct Term
{
int tag;
@@ -70,9 +81,21 @@ struct Module
/* What about imports */
Rune *name;
Predicate *predicates;
+ Operator *operators[PrecedenceLevels];
Module *next;
};
+/* Operator types */
+enum {
+ Xf = 1<<0, /* 1 */
+ Yf = 1<<1, /* 2 */
+ Xfx = 1<<2, /* 4 */
+ Xfy = 1<<3, /* 8 */
+ Yfx = 1<<4, /* 16 */
+ Fy = 1<<5, /* 32 */
+ Fx = 1<<6, /* 64 */
+};
+
/* Sorted so that a lower value means it comes earlier in the standard ordering */
enum {
VariableTerm,