blob: d5e7acff0f06e78ba88d91b4c1a4403cd364e371 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 */
|