Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Benchmark Generator/Benchmark Generator/BenchmarkGeneratorView.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 
1using System;
2using System.Linq;
3using System.Windows.Forms;
4using Irony.Parsing;
5
6namespace Benchmark_Generator {
7  public partial class BenchmarkGeneratorView : Form {
8    private readonly ExpressionGrammar grammar;
9
10    public BenchmarkGeneratorView() {
11      InitializeComponent();
12      grammar = new ExpressionGrammar();
13    }
14
15    private void button2_Click(object sender, EventArgs e) {
16      var language = new LanguageData(grammar);
17      var parser = new Parser(language);
18      try {
19        var sample = richTextBox1.Text;
20        string output = string.Empty;
21        parser.Parse(sample);
22        var tree = parser.Context.CurrentParseTree;
23        if (tree.Status == ParseTreeStatus.Error) {
24          // if there's a parse error then the root of the tree will be null
25          output = tree.ParserMessages.Aggregate(output, (current, m) => current + m.Message);
26        } else {
27          //          output = grammar.RunSample(new RunSampleArgs(language, sample, tree));
28          output = "Parsing successful.";
29        }
30        richTextBox2.Text = output;
31      }
32      catch (Exception ex) {
33        richTextBox2.Text = ex.Message;
34      }
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.