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