1 | using System;
|
---|
2 | using System.IO;
|
---|
3 | using System.Linq;
|
---|
4 | using HeuristicLab.MainForm.WindowsForms;
|
---|
5 | using HeuristicLab.Problems.Instances;
|
---|
6 | using HeuristicLab.Problems.Instances.Views;
|
---|
7 |
|
---|
8 | namespace 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 | }
|
---|