aboutsummaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/spec.h6
-rw-r--r--inc/tree.h46
2 files changed, 47 insertions, 5 deletions
diff --git a/inc/spec.h b/inc/spec.h
index 8bd8ace..3d8300c 100644
--- a/inc/spec.h
+++ b/inc/spec.h
@@ -10,15 +10,11 @@
struct bloc_header {
char identifier[BLOC_IDENTIFIER_LENGTH];
short length;
- void *data;
+ void *entries;
} __attribute__((packed));
struct bloc_entry {
void *expression;
} __attribute__((packed));
-struct bloc_structure {
- void *expression;
-} __attribute__((packed));
-
#endif
diff --git a/inc/tree.h b/inc/tree.h
new file mode 100644
index 0000000..8f11f1b
--- /dev/null
+++ b/inc/tree.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#ifndef BLOC_TREE_H
+#define BLOC_TREE_H
+
+#include <stdint.h>
+
+#include <term.h>
+
+#define VALIDATED_TREE ((int)0x0)
+#define INVALIDATED_TREE ((int)0xffffffff)
+#define FREEABLE_TREE(t) \
+ ((t)->state != VALIDATED_TREE && (t)->state != INVALIDATED_TREE)
+
+struct tree {
+ term_type type;
+ uint32_t hash;
+ int state; // zero or index to ref
+ int size; // blc length
+ union {
+ struct {
+ struct tree *term;
+ } abs;
+ struct {
+ struct tree *lhs;
+ struct tree *rhs;
+ } app;
+ struct {
+ int index;
+ } var;
+ struct {
+ size_t index;
+ } ref;
+ } u;
+};
+
+struct list {
+ int val; // length or priority
+ void *data;
+ struct list *next;
+};
+
+struct list *tree_merge_duplicates(struct term *term);
+
+#endif