summaryrefslogtreecommitdiff
path: root/include/parser
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-11-01 23:46:08 -0400
committerIan Moffett <ian@osmora.org>2024-11-01 23:46:08 -0400
commita515dfb3b8f8e999362db7a6b52b3104c03b750a (patch)
treed0180f0cbc39d9c3e367af30791ad774e4d419ff /include/parser
Import quark sources
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'include/parser')
-rw-r--r--include/parser/ast.h20
-rw-r--r--include/parser/type.h57
2 files changed, 77 insertions, 0 deletions
diff --git a/include/parser/ast.h b/include/parser/ast.h
new file mode 100644
index 0000000..03be1bd
--- /dev/null
+++ b/include/parser/ast.h
@@ -0,0 +1,20 @@
+/*
+ * AST (Abstract Syntax Tree) definitions.
+ * Copyright (c) 2023-2024, Quinn Stephens and the OSMORA team.
+ * Provided under the BSD 3-Clause license.
+ */
+
+#ifndef _PARSER_AST_H
+#define _PARSER_AST_H
+
+enum ast_node_kind {
+ NK_UNKNOWN,
+
+ NK_
+};
+
+struct ast_node {
+ enum ast_node_kind kind;
+};
+
+#endif /* !_PARSER_AST_H */
diff --git a/include/parser/type.h b/include/parser/type.h
new file mode 100644
index 0000000..6a939ab
--- /dev/null
+++ b/include/parser/type.h
@@ -0,0 +1,57 @@
+/*
+ * Type parser.
+ * Copyright (c) 2023-2024, Quinn Stephens and the OSMORA team.
+ * Provided under the BSD 3-Clause license.
+ */
+
+#ifndef _PARSER_TYPE_H
+#define _PARSER_TYPE_H
+
+#include <stddef.h>
+#include "hashmap.h"
+#include "parser.h"
+
+enum type_kind {
+ TYK_ALIAS,
+ TYK_ENUM,
+ TYK_STRUCT
+};
+
+struct enum_member {
+ struct hashmap_entry hashmap_entry;
+
+ char *name;
+ size_t name_len;
+
+ uint64_t value;
+};
+
+struct struct_member {
+ struct hashmap_entry hashmap_entry;
+
+ char *name;
+ size_t name_len;
+
+ size_t off, size;
+ struct type *typ;
+ int n_ptrs;
+};
+
+struct type {
+ struct hashmap_entry hashmap_entry;
+
+ enum type_kind kind;
+ char *name;
+ size_t name_len;
+
+ size_t size;
+
+ union {
+ int n_ptrs;
+ struct hashmap members;
+ };
+};
+
+void parse_type(struct parser *ctx);
+
+#endif /* !_PARSER_TYPE_H */