conditionally compile aoc solutions
This commit is contained in:
@@ -59,6 +59,7 @@ class Kiss {
|
|||||||
"reversed" => Symbol("Prelude.reversed"), // TODO test reversed
|
"reversed" => Symbol("Prelude.reversed"), // TODO test reversed
|
||||||
"memoize" => Symbol("Prelude.memoize"), // TODO test memoize
|
"memoize" => Symbol("Prelude.memoize"), // TODO test memoize
|
||||||
"symbolName" => Symbol("Prelude.symbolName"),
|
"symbolName" => Symbol("Prelude.symbolName"),
|
||||||
|
"symbolNameValue" => Symbol("Prelude.symbolNameValue"),
|
||||||
"symbol" => Symbol("Prelude.symbol"),
|
"symbol" => Symbol("Prelude.symbol"),
|
||||||
"expList" => Symbol("Prelude.expList"),
|
"expList" => Symbol("Prelude.expList"),
|
||||||
"map" => Symbol("Lambda.map"),
|
"map" => Symbol("Lambda.map"),
|
||||||
|
@@ -26,7 +26,6 @@ class KissInterp extends Interp {
|
|||||||
toDynamic: Operand.toDynamic
|
toDynamic: Operand.toDynamic
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
trace(variables["kiss"]);
|
|
||||||
variables.set("Lambda", Lambda);
|
variables.set("Lambda", Lambda);
|
||||||
variables.set("Std", Std);
|
variables.set("Std", Std);
|
||||||
variables.set("Keep", ExtraElementHandling.Keep);
|
variables.set("Keep", ExtraElementHandling.Keep);
|
||||||
|
@@ -189,15 +189,17 @@ class Macros {
|
|||||||
var conditionInterp = new KissInterp(true);
|
var conditionInterp = new KissInterp(true);
|
||||||
var conditionStr = Reader.toString(conditionExp.def);
|
var conditionStr = Reader.toString(conditionExp.def);
|
||||||
for (flag => value in Context.getDefines()) {
|
for (flag => value in Context.getDefines()) {
|
||||||
conditionInterp.variables.set(flag, value);
|
if (flag != "kiss")
|
||||||
|
conditionInterp.variables.set(flag, value);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var hscriptStr = Prelude.convertToHScript(conditionStr);
|
var hscriptStr = Prelude.convertToHScript(conditionStr);
|
||||||
#if test
|
#if test
|
||||||
Prelude.print(hscriptStr);
|
Prelude.print("#if condition hscript: " + hscriptStr);
|
||||||
#end
|
#end
|
||||||
var conditionHScript = parser.parseString(hscriptStr);
|
var conditionHScript = parser.parseString(hscriptStr);
|
||||||
return if (Prelude.truthy(conditionInterp.execute(conditionHScript))) {
|
return if (Prelude.truthy(conditionInterp.execute(conditionHScript))) {
|
||||||
|
trace("using thenExp");
|
||||||
thenExp;
|
thenExp;
|
||||||
} else {
|
} else {
|
||||||
elseExp;
|
elseExp;
|
||||||
@@ -239,10 +241,15 @@ class Macros {
|
|||||||
caseInterp.variables.set(Prelude.symbolNameValue(matchBodySymbol), matchBodies.shift());
|
caseInterp.variables.set(Prelude.symbolNameValue(matchBodySymbol), matchBodies.shift());
|
||||||
}
|
}
|
||||||
for (flag => value in Context.getDefines()) {
|
for (flag => value in Context.getDefines()) {
|
||||||
caseInterp.variables.set(flag, value);
|
if (flag != "kiss")
|
||||||
|
caseInterp.variables.set(flag, value);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var caseHScript = parser.parseString(Prelude.convertToHScript(caseStr));
|
var hscriptStr = Prelude.convertToHScript(caseStr);
|
||||||
|
#if test
|
||||||
|
Prelude.print("#case hscript: " + hscriptStr);
|
||||||
|
#end
|
||||||
|
var caseHScript = parser.parseString(hscriptStr);
|
||||||
return caseInterp.execute(caseHScript);
|
return caseInterp.execute(caseHScript);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw CompileError.fromExp(caseExp, '#case evaluation threw error $e');
|
throw CompileError.fromExp(caseExp, '#case evaluation threw error $e');
|
||||||
|
Reference in New Issue
Block a user