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