KissInterp evalKiss
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package kiss;
|
||||
|
||||
import hscript.Parser;
|
||||
import hscript.Interp;
|
||||
import kiss.Prelude;
|
||||
|
||||
@@ -12,6 +13,7 @@ import kiss.Prelude;
|
||||
*/
|
||||
class KissInterp extends Interp {
|
||||
var nullForUnknownVar:Bool;
|
||||
var parser = new Parser();
|
||||
|
||||
// TODO standardize this with KissConfig.prepareInterp
|
||||
public function new(nullForUnknownVar = false) {
|
||||
@@ -30,6 +32,11 @@ class KissInterp extends Interp {
|
||||
variables.set("kiss", {});
|
||||
}
|
||||
|
||||
public function evalKiss(kissStr:String):Dynamic {
|
||||
return execute(parser.parseString(Prelude.convertToHScript(kissStr)));
|
||||
}
|
||||
|
||||
// In some contexts, undefined variables should just return "null" as a falsy value
|
||||
override function resolve(id:String):Dynamic {
|
||||
if (nullForUnknownVar) {
|
||||
return try {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package nat;
|
||||
|
||||
import kiss.KissInterp;
|
||||
import hscript.Parser;
|
||||
import kiss.Prelude;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
|
@@ -1,9 +1,5 @@
|
||||
(function eval [:String expStr :Array<String> activeConditions]
|
||||
(let [hscript (Prelude.convertToHScript expStr)
|
||||
parser (new Parser)
|
||||
hscriptExp (parser.parseString hscript)
|
||||
interp (new BoolExpInterp)]
|
||||
|
||||
(let [interp (new BoolExpInterp)]
|
||||
(doFor condition activeConditions
|
||||
(interp.variables.set condition true))
|
||||
?(interp.execute hscriptExp)))
|
||||
?(interp.evalKiss expStr)))
|
||||
|
Reference in New Issue
Block a user