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) { //Utils.InstallModule("Utils", Utils.UtilsMethod); //Utils.InstallModule("Sets", Sets.SetsMethod); //Utils.InstallModule("Errors", Errors.ErrorsMethod); //Utils.InstallModule("GPDefLex", GPDefLex.GPDefLexMethod); //Utils.InstallModule("GPDefSem", GPDefSem.GPDefSemMethod); //Utils.InstallModule("GPDefSyn", GPDefSyn.GPDefSynMethod); //// --- initialize modules --- //Utils.Modules(Utils.ModuleAction.initModule); //Errors.PushAbortMethod(new Errors.AbortMethod(Abort)); using (var src = new MemoryStream(Encoding.UTF8.GetBytes(codeEditor.textEditor.Text))) { Scanner scanner = new Scanner(src); Parser parser = new Parser(scanner); parser.Parse(); } codeEditor.ClearErrors(); //if (Errors.NumOfErrors() == 0) { // GPDefLex.InitLex(); // GPDefSyn.Interpret(); // MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem); //} 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); // } //} } private void Abort(string abortKind, string moduleName, string methodName, string descr) { } void IProblemInstanceConsumer.Load(string data) { codeEditor.textEditor.Text = data; } } }