summaryrefslogtreecommitdiff
path: root/include/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/parser.h')
-rw-r--r--include/parser.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/parser.h b/include/parser.h
new file mode 100644
index 0000000..d5e7acf
--- /dev/null
+++ b/include/parser.h
@@ -0,0 +1,34 @@
+/*
+ * Quark parser.
+ * Turns tokens into an AST (Abstract Syntax Tree).
+ * Copyright (c) 2023-2024, Quinn Stephens and the OSMORA team.
+ * Provided under the BSD 3-Clause license.
+ */
+
+#ifndef _PARSER_H
+#define _PARSER_H
+
+#include "lexer/token.h"
+#include "lexer.h"
+
+struct parser {
+ struct lexer lexer;
+ struct token tok;
+ struct hashmap *types;
+ struct hashmap *procs;
+};
+
+static inline struct token *
+next_token(struct parser *ctx)
+{
+ lexer_next(&ctx->lexer, &ctx->tok);
+ return &ctx->tok;
+}
+
+void tok_error(struct token *tok, const char *fmt, ...);
+void tok_warn(struct token *tok, const char *fmt, ...);
+
+void parser_parse(struct parser *ctx);
+void parser_init(struct parser *ctx, char *source);
+
+#endif /* !_PARSER_H */