From eff929f0d323559f3b2e9272e3c1d4aa82fc5c80 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 12 Aug 2022 11:20:43 +0200 Subject: va list, cont fix --- src/all.hff | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/all.hff') 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); +} -- cgit v1.2.3