aboutsummaryrefslogtreecommitdiff
path: root/src/all.hff
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2022-08-14 11:16:03 +0200
committer lemon<lsof@mailbox.org>2022-08-14 11:16:03 +0200
commit0d1e125832d0fd8ca31c5f782e7c3db774ae5a02 (patch)
treee4622f75a8307d8ee1970f8bd6cc92766582f0ba /src/all.hff
parentc129f77ad724aa940b53a125de0e1e4de0ca7240 (diff)
woa
Diffstat (limited to 'src/all.hff')
-rw-r--r--src/all.hff185
1 files changed, 0 insertions, 185 deletions
diff --git a/src/all.hff b/src/all.hff
deleted file mode 100644
index 4ae3e26..0000000
--- a/src/all.hff
+++ /dev/null
@@ -1,185 +0,0 @@
-import "mem.hff";
-import "libc.hff";
-import "option.hff";
-
-/// Macros
-
-defmacro assert {
-(ex, s, ...args) [
- (do
- if not (ex) {
- fprintf(stderr, "%s:%d: assertion failed: ", #FILE, #LINE);
- fprintf(stderr, s, args);
- fprintf(stderr, "\n");
- abort();
- }
- )
-]
-}
-
-defmacro foreach(x, i, a, ...body) [
- {
- let $a = a;
- for let i = 0; i < $a.#len; ++i {
- let x = $a[i];
- { body }
- }
- }
-]
-
-defmacro streq(a,b) [ (strcmp(a,b) == 0) ]
-
-/// Types
-
-struct Type;
-struct Decl;
-struct Expr;
-struct Env;
-
-struct Loc {
- fileid i16,
- col i16,
- line int,
- idx isize,
-}
-
-#[lax]
-enum TokT : i32 {
- // !sorted
- 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,
- NUM_KEYWORDS,
- int = -100,
- flo,
- bool,
- str,
- chr,
- null,
- ident,
- macident,
- gensym,
- type,
- label,
- strify,
- eof,
-}
-def NUM_KEYWORDS = TokT:NUM_KEYWORDS;
-
-
-struct Tok {
- t TokT,
- loc Loc,
- ty *const Type,
- u union {
- int i64,
- uint u64,
- flo f64,
- bool bool,
- str [#]const u8,
- ident *const u8,
- },
-}
-
-struct Type {
- size usize,
- align usize,
- konst bool,
- id uint,
- u enum union {
- Void,
- Bool,
- Int struct { sgn bool },
- Flo,
- Ptr *Type,
- Arr struct { child *Type, length i64 },
- Slice *Type,
- }
-}
-
-struct Parser {
- fp *FILE,
- alloc *Allocator,
- curfile *const u8,
- tokloc Loc,
- curloc Loc,
- eof bool,
- peekchr Option<int>,
- peektok Option<Tok>,
-}
-
-struct Decl {
- name *const u8,
-}
-
-struct DeclList {
- link *DeclList,
- decl Decl,
-}
-
-struct Targ {
- name *const u8,
- ptrsize u8,
- intsize u8,
- longsize u8, longalign u8,
- llongsize u8, llongalign u8,
- sizesize u8,
- f64align u8,
- valistsize u8, valistalign u8,
- charsigned bool,
- shortenum bool,
-}
-
-// parse.cff
-extern fn parser_init(*Parser, path *const u8) void;
-extern fn parse(*Parser) [#]Decl;
-
-// util.cff
-extern fn xmalloc(n usize) *void;
-extern fn xcalloc(n usize, m usize) *void;
-extern fn xrealloc(p *void, n usize) *void;
-extern fn xstrdup(str *const u8) *u8;
-def FNV1A_INI u32 = 0x811c9dc5;
-extern fn fnv1a(h u32, [#]const u8) u32;
-extern fn fnv1a_s(h u32, *const u8) u32;
-extern fn fnv1a_i(h u32, i64) u32;
-extern fn addfilepath(*const u8) int;
-extern fn fatal(*Parser, Loc, fmt *const u8, ...) void;
-extern fn internstr(*const u8) *const u8;
-
-// fmt.cff
-extern fn vpfmt(proc *fn(u8, *void) void, parg *void, fmt *const u8, va_list) void;
-extern fn pfmt(proc *fn(u8, *void) void, parg *void, fmt *const u8, ...) void;
-extern fn vefmt(fmt *const u8, ap va_list) void;
-extern fn efmt(fmt *const u8, ...) void;
-
-// type.cff
-
-// env.cff
-extern fn mkenv(parent *Env, alloc *Allocator) *Env;
-extern fn envput(*Env, *const Decl) *Decl;
-
-// targ.cff
-extern static g_targ *const Targ;
-extern fn targ_ini(name *const u8) bool;
-
-// Inline functions
-fn bswap32(x u32) u32 {
- return (x >> 24)
- | ((x >> 8) & 0x00FF00)
- | ((x << 8) & 0xFF0000)
- | (x << 24);
-}
-
-fn bswap64(x u64) u64 {
- return (as(u64)bswap32(x) << 32)
- | (bswap32(x >> 32));
-}
-
-fn spanz(x *const u8) [#]const u8 {
- return x[0::strlen(x)];
-}