@@ -11,9 +11,10 @@ import polemy.parse; import polemy.value; import std.typecons; import std.stdio; - + +/// Table createGlobalContext() { auto ctx = new Table; // [TODO] autogenerate these typechecks @@ -89,19 +90,27 @@ { return eval( polemy.parse.parseString(str, fn_ln_cn) ); } +/// Entry point of this module + Tuple!(Value,"val",Table,"ctx") evalFile(S, T...)(S filename, T ln_cn) { return eval( polemy.parse.parseFile(filename, ln_cn) ); } +/// Entry point of this module + Tuple!(Value,"val",Table,"ctx") eval(AST e) { Table ctx = createGlobalContext(); return typeof(return)(eval(e, ctx, false, "@v"), ctx); } +/// Entry point of this module +/// If splitCtx = true, then inner variable declaration do not overwrite ctx. +/// lay is the layer ID for evaluation (standard value semantics uses "@v"). + Value eval(AST _e, Table ctx, bool splitCtx, Layer lay) { if( auto e = cast(StrLiteral)_e ) {