aboutsummaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMarvin Borner2024-01-17 00:59:12 +0100
committerMarvin Borner2024-01-17 01:10:36 +0100
commitb754e71ca502a5027ea3479eb3ea1a0ac28e5282 (patch)
treea7d4d9e45f289c6ba08abe56931f8b2f6dea39af /inc
Initial commit
Diffstat (limited to 'inc')
-rw-r--r--inc/log.h11
-rw-r--r--inc/parse.h20
-rw-r--r--inc/spec.h20
-rw-r--r--inc/target.h18
-rw-r--r--inc/term.h33
5 files changed, 102 insertions, 0 deletions
diff --git a/inc/log.h b/inc/log.h
new file mode 100644
index 0000000..fcae172
--- /dev/null
+++ b/inc/log.h
@@ -0,0 +1,11 @@
+// Copyright (c) 2024, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#ifndef BLOCADE_LOG_H
+#define BLOCADE_LOG_H
+
+void debug(const char *format, ...);
+void debug_enable(int enable);
+void fatal(const char *format, ...) __attribute__((noreturn));
+
+#endif
diff --git a/inc/parse.h b/inc/parse.h
new file mode 100644
index 0000000..2368199
--- /dev/null
+++ b/inc/parse.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#ifndef BLOC_PARSE_H
+#define BLOC_PARSE_H
+
+#include <stddef.h>
+
+#include <term.h>
+#include <spec.h>
+
+struct bloc_parsed {
+ size_t length;
+ struct term **entries;
+};
+
+struct bloc_parsed *parse_bloc(const void *bloc);
+void free_bloc(struct bloc_parsed *bloc);
+
+#endif
diff --git a/inc/spec.h b/inc/spec.h
new file mode 100644
index 0000000..3d8300c
--- /dev/null
+++ b/inc/spec.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#ifndef BLOC_SPEC_H
+#define BLOC_SPEC_H
+
+#define BLOC_IDENTIFIER "BLoC"
+#define BLOC_IDENTIFIER_LENGTH 4
+
+struct bloc_header {
+ char identifier[BLOC_IDENTIFIER_LENGTH];
+ short length;
+ void *entries;
+} __attribute__((packed));
+
+struct bloc_entry {
+ void *expression;
+} __attribute__((packed));
+
+#endif
diff --git a/inc/target.h b/inc/target.h
new file mode 100644
index 0000000..9196637
--- /dev/null
+++ b/inc/target.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2024, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#ifndef BLOCADE_TARGET_H
+#define BLOCADE_TARGET_H
+
+#include <stdio.h>
+
+#include <parse.h>
+
+struct target_spec {
+ const char *name;
+ void (*exec)(struct bloc_parsed *bloc, FILE *file);
+};
+
+void exec_target(char *name, struct bloc_parsed *bloc, FILE *file);
+
+#endif
diff --git a/inc/term.h b/inc/term.h
new file mode 100644
index 0000000..9823fc1
--- /dev/null
+++ b/inc/term.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2024, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#ifndef BLOCADE_TERM_H
+#define BLOCADE_TERM_H
+
+#include <stddef.h>
+
+typedef enum { INV, ABS, APP, VAR, REF } term_type;
+
+struct term {
+ term_type type;
+ union {
+ struct {
+ struct term *term;
+ } abs;
+ struct {
+ struct term *lhs;
+ struct term *rhs;
+ } app;
+ struct {
+ int index;
+ } var;
+ struct {
+ size_t index;
+ } ref;
+ } u;
+};
+
+struct term *new_term(term_type type);
+void free_term(struct term *term);
+
+#endif