Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Benchmark Generator/Benchmark Generator/ExpressionEvaluator.cs @ 9693

Last change on this file since 9693 was 9693, checked in by bburlacu, 11 years ago

#2083: Initial commit of benchmark generator application skeleton.

File size: 1.2 KB
Line 
1
2using System.Collections.Generic;
3using Irony.Interpreter;
4using Irony.Parsing;
5
6namespace Benchmark_Generator {
7  class ExpressionEvaluator {
8    public ExpressionGrammar Grammar { get; private set; }
9    public Parser Parser { get; private set; }
10    public LanguageData Language { get; private set; }
11    public LanguageRuntime Runtime { get; private set; }
12    public ScriptApp App { get; private set; }
13    public IDictionary<string, object> Globals { get { return App.Globals; } }
14
15    public ExpressionEvaluator() : this(new ExpressionGrammar()) { }
16
17    public ExpressionEvaluator(ExpressionGrammar grammar) {
18      Grammar = grammar;
19      Language = new LanguageData(Grammar);
20      Parser = new Parser(Language);
21      Runtime = Grammar.CreateRuntime(Language);
22      App = new ScriptApp(Runtime);
23    }
24
25    public object Evaluate(ParseTree parsedScript) {
26      var result = App.Evaluate(parsedScript);
27      return result;
28    }
29
30    public object Evaluate() {
31      return App.Evaluate();
32    }
33
34    public void ClearOutput() {
35      App.ClearOutputBuffer();
36    }
37
38    public string GetOutput() {
39      return App.GetOutput();
40    }
41  }
42}
Note: See TracBrowser for help on using the repository browser.