macroExpand the expressions

This commit is contained in:
2024-02-17 13:24:32 -07:00
parent 0e02c6c910
commit 1e887693ea
3 changed files with 21 additions and 0 deletions

View File

@@ -955,4 +955,13 @@ class Helpers {
expMap(exp, expandTypeAliases.bind(_, k));
};
}
public static function expandTypeSymbol(exp:ReaderExp, k:KissState) {
return switch (exp.def) {
case Symbol(path):
Symbol(replaceTypeAliases(path, k)).withPosOf(exp);
default:
exp;
};
}
}

View File

@@ -707,6 +707,12 @@ class SpecialForms {
forExpander("for");
forExpander("doFor");
map["the"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
var b = wholeExp.expBuilder();
b.callSymbol("the", [Helpers.expandTypeSymbol(args[0], k), macroExpand(args[1])]);
};
return map;
}

View File

@@ -71,4 +71,10 @@
(doFor [:Texty t1 :Texty t2 :Texty t3] lol
null))
// the
(makeExample
.content (the Stream (Stream.fromString "hey"))
(Assert.equals normal "hey\n")
(Assert.equals expanded "hey\n"))
)