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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import "libc.hff";
import "option.hff";
/// Macros
defmacro assert {
(ex, s) [
(do
if not (ex) {
fprintf(stderr, "%s:%d: assertion failed: ", #FILE, #LINE);
fprintf(stderr, "`%s'", (s));
fprintf(stderr, "\n");
abort();
}
)
]
}
/// Types
struct Type;
struct Decl;
struct Expr;
struct Loc {
fileid u16,
idx isize,
col int,
line int,
}
#[lax]
enum TokT {
kw_and, kw_as, kw_break, kw_case, kw_const,
kw_continue, kw_def, kw_defmacro, kw_do,
kw_else, kw_enum, kw_extern, kw_fn,
kw_for, kw_if, kw_import, kw_let, kw_not,
kw_or, kw_return, kw_sizeof, kw_static,
kw_struct, kw_switch, kw_typedef, kw_typeof,
kw_union, kw_while,
}
struct Tok {
t int,
ty *const Type,
u union {
int i64,
uint u64,
float f64,
bool bool,
str [#]const u8,
},
}
struct Decl {
}
struct Parser {
fp *FILE,
curfile [#]const u8,
tokloc Loc,
curloc Loc,
eof bool,
peekchr Option<int>,
}
// parse.cff
extern fn parse(P *Parser, path *const u8) [#]Decl;
// util.cff
extern fn xmalloc(n usize) *void;
extern fn xrealloc(p *void, n usize) *void;
|