aboutsummaryrefslogtreecommitdiff
path: root/src/all.hff
diff options
context:
space:
mode:
Diffstat (limited to 'src/all.hff')
-rw-r--r--src/all.hff38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/all.hff b/src/all.hff
index 13051c6..e1cb26a 100644
--- a/src/all.hff
+++ b/src/all.hff
@@ -26,6 +26,10 @@ defmacro foreach(x, i, a, ...body) [
}
]
+defmacro ALIGNUP(x,a) [ (((x) + ((a) - 1)) & -(a)) ]
+
+defmacro streq(a,b) [ (strcmp(a,b) == 0) ]
+
/// Types
struct Type;
@@ -33,14 +37,15 @@ struct Decl;
struct Expr;
struct Loc {
- fileid u16,
- idx isize,
- col int,
+ fileid i16,
+ col i16,
line int,
+ idx isize,
}
#[lax]
enum TokT {
+ // !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,
@@ -48,16 +53,31 @@ enum TokT {
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,
}
struct Tok {
t int,
+ loc Loc,
ty *const Type,
u union {
int i64,
uint u64,
- float f64,
+ flo f64,
bool bool,
str [#]const u8,
},
@@ -68,17 +88,23 @@ struct Decl {
struct Parser {
fp *FILE,
- curfile [#]const u8,
+ curfile *const u8,
tokloc Loc,
curloc Loc,
eof bool,
peekchr Option<int>,
+ peektok Option<Tok>,
}
// parse.cff
-extern fn parse(P *Parser, path *const u8) [#]Decl;
+extern fn parser_init(*Parser, path *const u8) void;
+extern fn parse(*Parser) [#]Decl;
// util.cff
extern fn xmalloc(n usize) *void;
extern fn xrealloc(p *void, n usize) *void;
+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;