aboutsummaryrefslogtreecommitdiff
path: root/src/as_parser.h
blob: 5d850c938ae2cb349901d39747e8743fc3ad34c6 (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 result parse_prog(struct allocator * alct, struct token_stream * ts);
struct result parse_stmt(struct allocator * alct, struct token_stream * ts);
struct result parse_stmts(struct allocator * alct, struct token_stream * ts);
struct result parse_instr(struct allocator * alct, struct token_stream * ts);
struct result parse_label(struct allocator * alct, struct token_stream * ts);
struct result parse_op(struct allocator * alct, struct token_stream * ts);

#endif