diff options
| author | 2022-08-11 06:25:30 +0200 | |
|---|---|---|
| committer | 2022-08-11 06:25:30 +0200 | |
| commit | 99cb50d4f13d587e3a0e0f2a44485f301409afb4 (patch) | |
| tree | c285338782ae3cd760252337a488f10fe940e45b /src | |
| parent | 8d3c3d919183a4a6ba7ad8010587dee6f5f96baa (diff) | |
fixs
Diffstat (limited to 'src')
| -rw-r--r-- | src/all.hff | 27 | ||||
| -rw-r--r-- | src/option.hff | 4 | ||||
| -rw-r--r-- | src/vec.hff | 8 |
3 files changed, 37 insertions, 2 deletions
diff --git a/src/all.hff b/src/all.hff index 89f2b71..e8298b0 100644 --- a/src/all.hff +++ b/src/all.hff @@ -1,4 +1,5 @@ import "libc.hff"; +import "option.hff"; /// Macros @@ -17,6 +18,10 @@ defmacro assert { /// Types +struct Type; +struct Decl; +struct Expr; + struct Loc { fileid u16, idx isize, @@ -26,13 +31,25 @@ struct Loc { #[lax] enum TokT { - kw_or + 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 { - i i64 + int i64, + uint u64, + float f64, + bool bool, + str [#]const u8, }, } @@ -40,6 +57,12 @@ struct Decl { } struct Parser { + fp *FILE, + curfile [#]const u8, + tokloc Loc, + curloc Loc, + eof bool, + peekchr Option<int>, } diff --git a/src/option.hff b/src/option.hff new file mode 100644 index 0000000..ef32725 --- /dev/null +++ b/src/option.hff @@ -0,0 +1,4 @@ +enum union Option<T> { + None, + Some T, +} diff --git a/src/vec.hff b/src/vec.hff index 8f794c9..fb44196 100644 --- a/src/vec.hff +++ b/src/vec.hff @@ -25,6 +25,14 @@ struct Vec<T> { vec.len = 0; vec.cap = 0; } + + fn compact(vec *Vec) [#]T { + if vec.dat { + vec.cap = vec.len; + vec.dat = realloc(vec.dat, vec.cap * sizeof T); + } + return vec.dat[0::vec.len]; + } } defmacro vec_each(x, i, v, ...body) [ |