public ScriptOutput Execute(Ast.Script script, ScriptEnv env, IReadOnlyDictionary <string, object> args) { foreach (var arg in args) { var lowercaseKey = arg.Key.ToLower(); env.Vars[lowercaseKey] = arg.Value; } Execute(script, env); return(env.Output); }
private Ast.Script ParseScript(TokenQueue q) { var script = new Ast.Script { SourceToken = q.SourceToken }; script.Block = new Ast.Block { SourceToken = q.SourceToken }; while (!q.Eof()) { var stmt = ParseStmt(q); if (stmt != null) { script.Block.Statements.Add(stmt); } } return(script); }
public void Execute(Ast.Script script, ScriptEnv env) { try { ExecuteBlock(script.Block, env); if (env.DidBreak) { throw new ScriptException($"Attempted to BREAK outside of a WHILE loop."); } else if (env.DidContinue) { throw new ScriptException($"Attempted to CONTINUE outside of a WHILE loop."); } } catch (Exception ex) { var snippet = ex is SqliteException s ? s.Snippet : null; throw new UncaughtErrorScriptException(ex.GetExceptionMessage(), ex) { Snippet = snippet }; } }
// must be run from the SQLite thread public ScriptOutput Execute(Ast.Script script, IReadOnlyDictionary <string, object> args) { return(Execute(script, new ScriptEnv(), args)); }