#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.IO; using System.Linq; using System.Text; using HeuristicLab.MainForm.WindowsForms; using HeuristicLab.Problems.Instances; using HeuristicLab.Problems.Instances.Views; namespace HeuristicLab.Problems.GPDL.Views { public partial class GpdlEditor : AsynchronousContentView, IProblemInstanceConsumer { public GpdlEditor() { InitializeComponent(); viewHost.Content = null; //necessary to enable the change of the ViewType viewHost.ViewType = typeof(GpdlProblemInstanceConsumerView); viewHost.Content = this; ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)viewHost.ActiveView; splitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any(); } private void compileButton_Click(object sender, EventArgs e) { using (var src = new MemoryStream(Encoding.UTF8.GetBytes(codeEditor.textEditor.Text))) { Scanner scanner = new Scanner(src); Parser parser = new Parser(scanner); parser.Parse(); MainForm.MainFormManager.MainForm.ShowContent(parser.problem); } codeEditor.ClearErrors(); // TODO adapt to Coco/R error handling to show errors in the GUI //if (Errors.NumOfErrors() == 0) { // GPDefLex.InitLex(); // GPDefSyn.Interpret(); //} else { // int nLexErrors = Errors.NumOfLexErrors(); // for (int i = 0; i < nLexErrors; i++) { // var lexErr = Errors.GetLexError(i == 0); // codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col); // } // int nSynErrors = Errors.NumOfSynErrors(); // for (int i = 0; i < nSynErrors; i++) { // var synErr = Errors.GetSynError(i == 0); // codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col); // } //} } void IProblemInstanceConsumer.Load(string data) { codeEditor.textEditor.Text = data; } } }