Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9528 was 9528, checked in by gkronber, 11 years ago

#2026 worked on HL integration of GPDL compiler

File size: 2.0 KB
Line 
1using System;
2using System.IO;
3using System.Linq;
4using HeuristicLab.MainForm.WindowsForms;
5using HeuristicLab.Problems.Instances;
6using HeuristicLab.Problems.Instances.Views;
7
8namespace HeuristicLab.Problems.GPDL.Views {
9  public partial class GpdlEditor : AsynchronousContentView, IProblemInstanceConsumer<string> {
10    public GpdlEditor() {
11      InitializeComponent();
12
13      viewHost.Content = null; //necessary to enable the change of the ViewType
14      viewHost.ViewType = typeof(GpdlProblemInstanceConsumerView);
15      viewHost.Content = this;
16      ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)viewHost.ActiveView;
17      splitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
18    }
19
20    private void compileButton_Click(object sender, EventArgs e) {
21      Utils.InstallModule("Utils", new Utils.ModuleMethodDelegate(Utils.UtilsMethod));
22      Utils.InstallModule("Sets", new Utils.ModuleMethodDelegate(Sets.SetsMethod));
23      Utils.InstallModule("Errors", new Utils.ModuleMethodDelegate(Errors.ErrorsMethod));
24
25      Utils.InstallModule("GPDefLex", new Utils.ModuleMethodDelegate(GPDefLex.GPDefLexMethod));
26      Utils.InstallModule("GPDefSem", new Utils.ModuleMethodDelegate(GPDefSem.GPDefSemMethod));
27      Utils.InstallModule("GPDefSyn", new Utils.ModuleMethodDelegate(GPDefSyn.GPDefSynMethod));
28
29      // --- initialize modules ---
30      Utils.Modules(Utils.ModuleAction.initModule);
31
32      Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
33
34      using (var src = new StringReader(gpdlTextBox.Text)) {
35        GPDefLex.src = src;
36        GPDefSyn.Parse();
37      }
38
39      GPDefLex.InitLex();
40      GPDefSyn.Interpret();
41
42      MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
43    }
44
45    private void Abort(string abortKind, string moduleName, string methodName, string descr) {
46
47    }
48
49    void IProblemInstanceConsumer<string>.Load(string data) {
50      this.gpdlTextBox.Text = data;
51    }
52
53  }
54}
Note: See TracBrowser for help on using the repository browser.