aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--include/type.h75
2 files changed, 76 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index afa9407..a7848d3 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@
BINOUT = .bin
HDR = \
include/lex.h \
+ include/type.h \
include/utf8.h \
include/util.h
OBJ = \
diff --git a/include/type.h b/include/type.h
new file mode 100644
index 0000000..aa745b7
--- /dev/null
+++ b/include/type.h
@@ -0,0 +1,75 @@
+#ifndef CERC_TYPE_H
+#define CERC_TYPE_H
+#include <stdbool.h>
+#include <stdint.h>
+
+struct cer_int {
+ bool sign;
+ short bits;
+};
+
+struct cer_float {
+ bool is64;
+};
+
+struct cer_array {
+ struct type *member_type;
+ int length;
+};
+
+struct cer_slice {
+ struct type *member_type;
+};
+
+struct field {
+ const char *name;
+ struct type *type;
+};
+
+struct cer_struct {
+ struct field *fields;
+};
+
+struct variant {
+ const char *name;
+ uint64_t tag;
+};
+
+struct cer_enum {
+ struct cer_int *tag_type;
+ struct variant variants[];
+};
+
+struct cer_union {
+ struct type *alts;
+};
+
+enum type_kind {
+ TYP_INT,
+ TYP_FLOAT,
+ TYP_ARRAY,
+ TYP_SLICE,
+ TYP_STRUCT,
+ TYP_ENUM,
+ TYP_UNION,
+ TYP_POINTER,
+ TYP_OPTIONAL,
+ TYP_FALLIBLE,
+};
+
+union type_desc {
+ struct cer_int *i;
+ struct cer_float *f;
+ struct cer_array *array;
+ struct cer_slice *slice;
+ struct cer_struct *s;
+ struct cer_enum *en;
+ struct cer_union *un;
+};
+
+struct type {
+ enum type_kind kind;
+ union type_desc desc;
+};
+
+#endif