aboutsummaryrefslogtreecommitdiff
path: root/src/as_parser.h
blob: 463018652a04750d82f7c67149a8168ef394a999 (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
35
36
37
38
39
40
41
42
43
44
#ifndef FVM_AS_PARSER_H_
#define FVM_AS_PARSER_H_

#include "as_tokenizer.h"
#include "utils.h"

#include "as_op.h"

struct arg {
    int64_t ival;
    double fval;
};

struct instr {
    enum op op;
    struct arg * arg;
    const char* tag_name;
};

struct label {
    const char* name;
};

struct stmt {
    struct label * label;
    struct instr * instr;
};

struct stmts {
    struct stmt ** stmts;
};

struct prog {
    struct stmts * stmts;
};

struct prog * parse_prog(struct allocator * alct, struct token_stream * ts);
struct stmt * parse_stmt(struct allocator * alct, struct token_stream * ts);
struct stmts * parse_stmts(struct allocator * alct, struct token_stream * ts);
struct instr * parse_instr(struct allocator * alct, struct token_stream * ts);
struct label * parse_label(struct allocator * alct, struct token_stream * ts);
enum op parse_op(struct allocator * alct, struct token_stream * ts);

#endif