source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs @ 9725

Last change on this file since 9725 was 9725, checked in by gkronber, 6 years ago

#2026 re-enabled code generation from within HL and added missing file.

File size: 1.9 KB
Line 
1using System;
2using System.IO;
3using System.Linq;
4using System.Text;
5using HeuristicLab.MainForm.WindowsForms;
6using HeuristicLab.Problems.Instances;
7using HeuristicLab.Problems.Instances.Views;
8
9namespace HeuristicLab.Problems.GPDL.Views {
10  public partial class GpdlEditor : AsynchronousContentView, IProblemInstanceConsumer<string> {
11    public GpdlEditor() {
12      InitializeComponent();
13
14      viewHost.Content = null; //necessary to enable the change of the ViewType
15      viewHost.ViewType = typeof(GpdlProblemInstanceConsumerView);
16      viewHost.Content = this;
17      ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)viewHost.ActiveView;
18      splitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
19    }
20
21    private void compileButton_Click(object sender, EventArgs e) {
22
23      using (var src = new MemoryStream(Encoding.UTF8.GetBytes(codeEditor.textEditor.Text))) {
24        Scanner scanner = new Scanner(src);
25        Parser parser = new Parser(scanner);
26        parser.Parse();
27        MainForm.MainFormManager.MainForm.ShowContent(Parser.problem);
28      }
29
30      codeEditor.ClearErrors();
31
32      //if (Errors.NumOfErrors() == 0) {
33      //  GPDefLex.InitLex();
34      //  GPDefSyn.Interpret();
35
36      //} else {
37      //  int nLexErrors = Errors.NumOfLexErrors();
38      //  for (int i = 0; i < nLexErrors; i++) {
39      //    var lexErr = Errors.GetLexError(i == 0);
40      //    codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col);
41      //  }
42      //  int nSynErrors = Errors.NumOfSynErrors();
43      //  for (int i = 0; i < nSynErrors; i++) {
44      //    var synErr = Errors.GetSynError(i == 0);
45      //    codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col);
46      //  }
47      //}
48    }
49
50
51    void IProblemInstanceConsumer<string>.Load(string data) {
52      codeEditor.textEditor.Text = data;
53    }
54  }
55}
Note: See TracBrowser for help on using the repository browser.