(symbol) and (expList) for macros

This commit is contained in:
2021-06-12 21:28:48 -06:00
parent 4b93292b32
commit 5a4686d977
4 changed files with 22 additions and 5 deletions

View File

@@ -12,8 +12,10 @@ import js.node.Buffer;
#elseif sys
import sys.io.Process;
#end
import uuid.Uuid;
using StringTools;
using uuid.Uuid;
/** What functions that process Lists should do when there are more elements than expected **/
enum ExtraElementHandling {
@@ -278,6 +280,12 @@ class Prelude {
}
// ReaderExp helpers for macros:
public static function symbol(?name:String):ReaderExpDef {
if (name == null)
name = '_${Uuid.v4().toShort()}';
return Symbol(name);
}
public static function symbolName(s:ReaderExp):ReaderExpDef {
return switch (s.def) {
case Symbol(name): StrExp(name);
@@ -285,6 +293,14 @@ class Prelude {
};
}
public static function expList(s:ReaderExp):Array<ReaderExp> {
return switch (s.def) {
case ListExp(exps):
exps;
default: throw 'expected $s to be a list expression';
}
}
#if sys
private static var kissProcess:Process = null;
#end