From 73c04db73163d1d2719bb97a6b8c133065df75c3 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Mon, 18 May 2020 18:22:42 -0700 Subject: feat: macro expansion and constant evaluation prototype --- sys/cmd/cc/cc.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sys/cmd/cc/cc.h') diff --git a/sys/cmd/cc/cc.h b/sys/cmd/cc/cc.h index 9871e99..84f173f 100644 --- a/sys/cmd/cc/cc.h +++ b/sys/cmd/cc/cc.h @@ -100,6 +100,7 @@ void errorat(Pos x, byte *fmt, ...); DIRECTIVE(Ddefine,"define", ppdef) \ DIRECTIVE(Dundef,"undef", ppund) \ DIRECTIVE(Dif,"if", ppif0) \ + DIRECTIVE(Delif,"elif", ppif1) \ DIRECTIVE(Delse, "else", ppif1) \ DIRECTIVE(Difdef,"ifdef", ppif2) \ DIRECTIVE(Difndef,"ifndef", ppif3) \ @@ -184,6 +185,8 @@ enum Vusgn = iota(12), Vfloat = iota(13), Vstr = iota(14), + + Vmask = Vchar - 1, }; #undef TOK @@ -221,6 +224,17 @@ struct Sym }; }; +struct SymTab +{ + int32 n_buckets; + int32 size; + int32 n_occupied; + int32 upper_bound; + int32 *flags; + string *keys; + Sym **vals; +}; + Sym *lookup(SymTab *tab, string ident); Sym *define(SymTab *tab, string ident, int kind); @@ -228,7 +242,7 @@ struct Lexer { Pos pos; Io *io; - SymTab *sym; + SymTab sym; byte *b; byte buf[2*1024]; }; -- cgit v1.2.1