public virtual string RunSample(RunSampleArgs args) { if (_app == null || args.ParsedSample != _prevSample) _app = new ScriptApp(args.Language); _prevSample = args.ParsedSample; //for (int i = 0; i < 1000; i++) //for perf measurements, to execute 1000 times _app.Evaluate(args.ParsedSample); return _app.OutputBuffer.ToString(); }
public void BasicSetup() { string command = "a = 1+1\r\n" + "a + 1"; ParseTree _parseTree = GetParseTree(command); if (_parseTree.ParserMessages.Count > 0) return; var iRunner = _language.Grammar as ICanRunSample; var args = new RunSampleArgs(_language, command, _parseTree); string output = iRunner.RunSample(args); Assert.AreEqual("3\r\n", output); }
//public override LanguageRuntime CreateRuntime(LanguageData language) //{ // return new ExpressionEvaluatorRuntime(language); //} public object Run(RunSampleArgs args) { if (_evaluator == null) { _evaluator = new ExpressionEvaluator(this); _evaluator.Globals.Add("null", _evaluator.Runtime.NoneValue); _evaluator.Globals.Add("true", true); _evaluator.Globals.Add("false", false); _evaluator.Globals.Add("model", _model); } _evaluator.ClearOutput(); //for (int i = 0; i < 1000; i++) //for perf measurements, to execute 1000 times return _evaluator.Evaluate(args.ParsedSample); }
public static object Query(this XbimModel model, string query) { var grammar = new xBimQueryLanguage(model); var _language = new LanguageData(grammar); var parser = new Irony.Parsing.Parser(_language); ParseTree _parseTree = parser.Parse(query); if (_parseTree.ParserMessages.Count > 0) return null; var iRunner = _language.Grammar as ICanRunSample; var args = new RunSampleArgs(_language, query, _parseTree); // string output = iRunner.RunSample(args); return grammar.Run(args); }
public string RunSample(RunSampleArgs args) { var converter = new WikiHtmlConverter(); PreprocessTokens(args.ParsedSample.Tokens); var html = converter.Convert(this, args.ParsedSample.Tokens); var path = Path.Combine(Path.GetTempPath(), "@wikiSample.html"); File.WriteAllText(path, html); System.Diagnostics.Process.Start(path); return html; }
private void RunSample() { ClearRuntimeInfo(); Stopwatch sw = new Stopwatch(); int oldGcCount; txtOutput.Text = ""; try { if (_parseTree == null) ParseSample(); if (_parseTree.ParserMessages.Count > 0) return; GC.Collect(); //to avoid disruption of perf times with occasional collections oldGcCount = GC.CollectionCount(0); System.Threading.Thread.Sleep(100); sw.Start(); var iRunner = _grammar as ICanRunSample; var args = new RunSampleArgs(_language, txtSource.Text, _parseTree); string output = iRunner.RunSample(args); sw.Stop(); lblRunTime.Text = sw.ElapsedMilliseconds.ToString(); var gcCount = GC.CollectionCount(0) - oldGcCount; lblGCCount.Text = gcCount.ToString(); WriteOutput(output); tabBottom.SelectedTab = pageOutput; } catch (ScriptException ex) { ShowRuntimeError(ex); } finally { sw.Stop(); }//finally }//method
public string RunSample(RunSampleArgs args) { var sql = ConvertQuery(args.ParsedSample.Root); return sql; }
public override string RunSample(RunSampleArgs args) { Run(args); return _evaluator.GetOutput(); }
public override string RunSample(RunSampleArgs args) { if (_evaluator == null) _evaluator = new ExpressionEvaluator(this); _evaluator.ClearOutput(); //for (int i = 0; i < 1000; i++) //for perf measurements, to execute 1000 times _evaluator.Evaluate(args.ParsedSample); return _evaluator.GetOutput(); }