From e9543de5ab1de08a452de4b9df705c43aa9ff6ac Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 19 Aug 2022 10:41:25 +0200 Subject: templates --- src/cffc.hff | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/cffc.hff') diff --git a/src/cffc.hff b/src/cffc.hff index 686de57..c8c90ac 100644 --- a/src/cffc.hff +++ b/src/cffc.hff @@ -36,9 +36,9 @@ enum TokT : i32 { ident, macident, gensym, - type, label, strify, + typearg, eof, } def NUM_KEYWORDS int = TokT:NUM_KEYWORDS; @@ -68,8 +68,11 @@ struct AggField { ty *const Type, off usize, } + struct EnumVal { name *const u8, i i64 } +enum union TeplArg; + struct Type { size usize, align usize, @@ -101,6 +104,7 @@ struct Type { id int, fwd bool, enumty *const Type, + tpargs [#]TeplArg, flds [#]AggField, decls *Env, }, @@ -228,6 +232,33 @@ struct Macro { cs [#]MacroCase } +struct TeplParam { + name *const u8, + u enum union { + Ty, + Val *const Type, + } +} + +enum union TeplArg { + Ty *const Type, + Val Tok, +} + +struct TeplCache { + next *TeplCache, + args [#]TeplArg, + ty *const Type, +} + +struct Tepl { + kind AggKind, + env *Env, + params [#]TeplParam, + toks [#]Tok, + cache *TeplCache, +} + struct Decl { name *const u8, loc Loc, @@ -235,10 +266,11 @@ struct Decl { u enum union { Let Var, Static Var, + Ty *const Type, Def Expr, Fn Fn, Macro Macro, - Ty *const Type, + Tepl Tepl, }, myenv *Env, } @@ -253,6 +285,7 @@ struct Expan { toks [#]Tok, name *const u8, loc Loc, + tepl bool, idx int, peektok Option } -- cgit v1.2.3