diff options
| author | 2022-08-12 11:20:43 +0200 | |
|---|---|---|
| committer | 2022-08-12 11:20:43 +0200 | |
| commit | eff929f0d323559f3b2e9272e3c1d4aa82fc5c80 (patch) | |
| tree | c3dd54fe4ed4a3082f455c8fe37436f767760977 /src/all.hff | |
| parent | 19f1093f0929b989a06cdee2e7d175e6db15559c (diff) | |
va list, cont fix
Diffstat (limited to 'src/all.hff')
| -rw-r--r-- | src/all.hff | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/all.hff b/src/all.hff index e1cb26a..a35694b 100644 --- a/src/all.hff +++ b/src/all.hff @@ -4,11 +4,11 @@ import "option.hff"; /// Macros defmacro assert { -(ex, s) [ +(ex, s, ...args) [ (do if not (ex) { fprintf(stderr, "%s:%d: assertion failed: ", #FILE, #LINE); - fprintf(stderr, "`%s'", (s)); + fprintf(stderr, s, args); fprintf(stderr, "\n"); abort(); } @@ -44,7 +44,7 @@ struct Loc { } #[lax] -enum TokT { +enum TokT : i32 { // !sorted kw_and, kw_as, kw_break, kw_case, kw_const, kw_continue, kw_def, kw_defmacro, kw_do, @@ -68,10 +68,11 @@ enum TokT { strify, eof, } +def NUM_KEYWORDS = TokT:NUM_KEYWORDS; struct Tok { - t int, + t TokT, loc Loc, ty *const Type, u union { @@ -108,3 +109,17 @@ def FNV1A_INI u32 = 0x811c9dc5; extern fn fnv1a(h u32, [#]const u8) u32; extern fn fnv1a_s(h u32, *const u8) u32; extern fn addfilepath(*const u8) int; +extern fn fatal(*Parser, Loc, fmt *const u8, ...) void; + +// fmt.cff +extern fn vpfmt(proc *fn(u8, *void) void, parg *void, fmt *const u8, va_list) void; +extern fn vefmt(fmt *const u8, ap va_list) void; +extern fn efmt(fmt *const u8, ...) void; + +// Inline functions +fn bswap32(x u32) u32 { + return (x >> 24) + | ((x >> 8) & 0x00FF00) + | ((x << 8) & 0xFF0000) + | (x << 24); +} |