//Default constructor, creates default evaluator public ReportingExpressionEvaluator(InterpretedLanguageGrammar grammar) { Grammar = grammar; Language = new LanguageData(Grammar); Parser = new Parser(Language); Runtime = Grammar.CreateRuntime(Language); App = new ScriptApp(Runtime); }
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 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()); }
//Default constructor, creates default evaluator public ExpressionEvaluator(MathGrammar grammar) { Grammar = grammar; Language = new LanguageData(Grammar); Parser = new Parser(Language); Runtime = Grammar.CreateRuntime(Language); App = new ScriptApp(Runtime); Globals.Add("null", Runtime.NoneValue); Globals.Add("true", true); Globals.Add("false", false); }
public CommandLine(LanguageRuntime runtime, IConsoleAdaptor console = null) { Runtime = runtime; _console = console ?? new ConsoleAdapter(); var grammar = runtime.Language.Grammar; Title = grammar.ConsoleTitle; Greeting = grammar.ConsoleGreeting; Prompt = grammar.ConsolePrompt; PromptMoreInput = grammar.ConsolePromptMoreInput; App = new ScriptApp(Runtime); App.ParserMode = ParseMode.CommandLine; // App.PrintParseErrors = false; App.RethrowExceptions = false; }
public CommandLine(LanguageRuntime runtime, IConsoleAdapter console = null) { Runtime = runtime; _console = console ?? new SystemConsoleAdapter(); var grammar = runtime.Language.Grammar; Title = grammar.ConsoleTitle; Greeting = grammar.ConsoleGreeting; Prompt = grammar.ConsolePrompt; PromptMoreInput = grammar.ConsolePromptMoreInput; App = new ScriptApp(Runtime); App.ParserMode = ParseMode.CommandLine; // App.PrintParseErrors = false; App.RethrowExceptions = false; }
public CommandLine(LanguageRuntime runtime, IConsoleAdapter adapter) { Runtime = runtime; Adapter = adapter ?? new ConsoleAdapter(); var grammar = runtime.Language.Grammar; Title = grammar.ConsoleTitle; Greeting = grammar.ConsoleGreeting; Prompt = grammar.ConsolePrompt; PromptMoreInput = grammar.ConsolePromptMoreInput; App = new ScriptApp(Runtime) { ParserMode = ParseMode.CommandLine, RethrowExceptions = false }; // App.PrintParseErrors = false; }
protected static MtCompiler InternCreateScriptApp(Stream output, Stream debugStream) { var grammar = new MtGrammar(); var lang = new LanguageData(grammar); var parser = new Parser(grammar); var runtime = grammar.CreateRuntime(lang) as MultiTasksRuntime; if (output != null) { runtime.OutputStream = output; } #if DEBUG && !SILVERLIGHT if (debugStream != null) { // Add as a listener to debug var listener = new TextWriterTraceListener(debugStream); Debug.Listeners.Add(listener); } #endif var app = new ScriptApp(runtime); // Add constants app.Globals.Add("TRUE", MtResult.True); app.Globals.Add("FALSE", MtResult.False); #if DEBUG && !SILVERLIGHT MultiTasksRuntime.DebugDisplayInfo(); #endif return new MtCompiler(app); }
protected MtCompiler(ScriptApp scriptApp) { _scriptApp = scriptApp; }
public ScriptThread(ScriptApp app) { App = app; Runtime = App.Runtime; CurrentScope = app.MainScope; }
public void Setup() { grammar = new Portugol(); parser = new Parser(grammar); scriptApp = new ScriptApp(parser.Language); }