aboutsummaryrefslogtreecommitdiff
path: root/src/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/parser.h b/src/parser.h
new file mode 100644
index 0000000..8da762d
--- /dev/null
+++ b/src/parser.h
@@ -0,0 +1,32 @@
+#ifndef ORYX_PARSER_H
+#define ORYX_PARSER_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "lexer.h"
+
+enum {
+ PRSBINADD = '+',
+ PRSBINSUB = '-',
+};
+
+typedef uint8_t ast_kind;
+
+#define AST_SOA_BLKSZ (sizeof(ast_kind) + sizeof(size_t) * 3)
+
+struct ast_soa {
+ ast_kind *kinds;
+ size_t *lexemes;
+ struct {
+ size_t lhs, rhs;
+ } *kids;
+ size_t len, cap;
+};
+
+#define ast_free(x) free((x).kinds)
+
+/* Parse the tokens in TOKS into an abstract syntax tree */
+struct ast_soa parsetoks(struct lexemes_soa toks);
+
+#endif /* !ORYX_PARSER_H */