From a515dfb3b8f8e999362db7a6b52b3104c03b750a Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 1 Nov 2024 23:46:08 -0400 Subject: Import quark sources Signed-off-by: Ian Moffett --- include/parser.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/parser.h (limited to 'include/parser.h') 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 */ -- cgit v1.2.3