blob: 2171fe40e9288c4c0f1a0df2dfc06c99d0af9abe (
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
45
46
47
48
49
50
51
52
53
54
55
|
#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;
};
// result<prog>
struct result parse_prog(struct allocator * alct, struct token_stream * ts);
// result<stmt>
struct result parse_stmt(struct allocator * alct, struct token_stream * ts);
// result<stmts>
struct result parse_stmts(struct allocator * alct, struct token_stream * ts);
// result<instr>
struct result parse_instr(struct allocator * alct, struct token_stream * ts);
// result<label>
struct result parse_label(struct allocator * alct, struct token_stream * ts);
// result<enum op>
struct result parse_op(struct allocator * alct, struct token_stream * ts);
#endif
|