/* * 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 */