[9519] | 1 | using System;
|
---|
| 2 | using System.IO;
|
---|
| 3 | using System.Linq;
|
---|
[9724] | 4 | using System.Text;
|
---|
[9519] | 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 |
|
---|
[9724] | 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();
|
---|
[9725] | 27 | MainForm.MainFormManager.MainForm.ShowContent(Parser.problem);
|
---|
[9519] | 28 | }
|
---|
| 29 |
|
---|
[9674] | 30 | codeEditor.ClearErrors();
|
---|
[9519] | 31 |
|
---|
[9724] | 32 | //if (Errors.NumOfErrors() == 0) {
|
---|
| 33 | // GPDefLex.InitLex();
|
---|
| 34 | // GPDefSyn.Interpret();
|
---|
[9674] | 35 |
|
---|
[9724] | 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 | //}
|
---|
[9519] | 48 | }
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | void IProblemInstanceConsumer<string>.Load(string data) {
|
---|
[9674] | 52 | codeEditor.textEditor.Text = data;
|
---|
[9519] | 53 | }
|
---|
| 54 | }
|
---|
| 55 | }
|
---|