-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.h
28 lines (25 loc) · 826 Bytes
/
parser.h
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
#pragma once
#include "tok.h"
#include "ast.h"
typedef struct {
Tokenizer tokenizer;
BOOL statement;
BOOL function;
BOOL loop;
int pos;
} Parser;
#define curr(parser) __peek__(parser, 0)
#define curr_line(parser, tok) parser->tokenizer.data.lines[tok.line - 1]
#define next(parser) (parser->pos++, __peek__(parser, 0))
void __freeparser__(Parser *parser); // Also frees tokenizer
int operator_precedence(Parser *parser);
Parser __parser__();
Ast **__parse__(Parser *parser);
Ast *parse_assignment(Parser *parser, TokEntity name);
Ast *parse_stmt(Parser *parser);
Ast *parse_print(Parser *parser);
Ast* parse_rand(Parser *parser);
Ast *parse_expr(Parser *parser, int parent_precedence);
Ast *parse_input(Parser *parser);
Ast *parse_ifexpr(Parser *parser);
Ast *parse_while(Parser *parser);