conditionally compile aoc solutions
This commit is contained in:
@@ -59,6 +59,7 @@ class Kiss {
|
||||
"reversed" => Symbol("Prelude.reversed"), // TODO test reversed
|
||||
"memoize" => Symbol("Prelude.memoize"), // TODO test memoize
|
||||
"symbolName" => Symbol("Prelude.symbolName"),
|
||||
"symbolNameValue" => Symbol("Prelude.symbolNameValue"),
|
||||
"symbol" => Symbol("Prelude.symbol"),
|
||||
"expList" => Symbol("Prelude.expList"),
|
||||
"map" => Symbol("Lambda.map"),
|
||||
|
||||
@@ -26,7 +26,6 @@ class KissInterp extends Interp {
|
||||
toDynamic: Operand.toDynamic
|
||||
}
|
||||
});
|
||||
trace(variables["kiss"]);
|
||||
variables.set("Lambda", Lambda);
|
||||
variables.set("Std", Std);
|
||||
variables.set("Keep", ExtraElementHandling.Keep);
|
||||
|
||||
@@ -189,15 +189,17 @@ class Macros {
|
||||
var conditionInterp = new KissInterp(true);
|
||||
var conditionStr = Reader.toString(conditionExp.def);
|
||||
for (flag => value in Context.getDefines()) {
|
||||
conditionInterp.variables.set(flag, value);
|
||||
if (flag != "kiss")
|
||||
conditionInterp.variables.set(flag, value);
|
||||
}
|
||||
try {
|
||||
var hscriptStr = Prelude.convertToHScript(conditionStr);
|
||||
#if test
|
||||
Prelude.print(hscriptStr);
|
||||
Prelude.print("#if condition hscript: " + hscriptStr);
|
||||
#end
|
||||
var conditionHScript = parser.parseString(hscriptStr);
|
||||
return if (Prelude.truthy(conditionInterp.execute(conditionHScript))) {
|
||||
trace("using thenExp");
|
||||
thenExp;
|
||||
} else {
|
||||
elseExp;
|
||||
@@ -239,10 +241,15 @@ class Macros {
|
||||
caseInterp.variables.set(Prelude.symbolNameValue(matchBodySymbol), matchBodies.shift());
|
||||
}
|
||||
for (flag => value in Context.getDefines()) {
|
||||
caseInterp.variables.set(flag, value);
|
||||
if (flag != "kiss")
|
||||
caseInterp.variables.set(flag, value);
|
||||
}
|
||||
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);
|
||||
} catch (e) {
|
||||
throw CompileError.fromExp(caseExp, '#case evaluation threw error $e');
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(load "UtilMacros.kiss")
|
||||
(defun :Void main []
|
||||
(year 2020
|
||||
(Solutions2020.run)))
|
||||
@@ -1,5 +1,10 @@
|
||||
(defmacro year [num &rest body]
|
||||
`(#when ,(symbol (+ "year" (symbolNameValue num)))
|
||||
(print (+ "year " (Std.string ,num)))
|
||||
,@body))
|
||||
|
||||
(defmacro day [num &rest body]
|
||||
`(#when (+ "day" (Std.string ,num))
|
||||
`(#when ,(symbol (+ "day" (symbolNameValue num)))
|
||||
(print (+ "day " (Std.string ,num)))
|
||||
,@body))
|
||||
|
||||
|
||||
@@ -3,7 +3,5 @@ package year2020;
|
||||
import kiss.EmbeddedScript;
|
||||
import kiss.Prelude;
|
||||
|
||||
#if (day12 && year2020)
|
||||
@:build(kiss.EmbeddedScript.build("EvasionDSL.kiss", "inputs/day12.txt"))
|
||||
class EvasionScript extends EmbeddedScript {}
|
||||
#end
|
||||
|
||||
@@ -12,10 +12,16 @@ import year2020.Passports;
|
||||
import year2020.Seating;
|
||||
import year2020.Customs;
|
||||
import year2020.Bags;
|
||||
#if (day8 && year2020)
|
||||
import year2020.BootCode;
|
||||
#end
|
||||
import year2020.Adapters;
|
||||
#if (day11 && year2020)
|
||||
import year2020.FerrySim;
|
||||
#end
|
||||
#if (day12 && year2020)
|
||||
import year2020.Evasion;
|
||||
#end
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class Solutions {}
|
||||
|
||||
@@ -37,5 +37,5 @@ then
|
||||
# Test other projects with their test.sh file
|
||||
else
|
||||
(cd projects/$KISS_PROJECT && haxelib install all --always)
|
||||
(cd projects/$KISS_PROJECT && ./test.sh)
|
||||
(cd projects/$KISS_PROJECT && ./test.sh "${@:2}")
|
||||
fi
|
||||
Reference in New Issue
Block a user