source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs @ 9724

Last change on this file since 9724 was 9724, checked in by gkronber, 6 years ago

#2026 changed ATG to Coco/R syntax and use Coco/R (C#) to generate scanner and parser for GPDL

File size: 2.5 KB
Line 
1using System;
2using System.IO;
3using System.Linq;
4using System.Text;
5using HeuristicLab.MainForm.WindowsForms;
6using HeuristicLab.Problems.Instances;
7using HeuristicLab.Problems.Instances.Views;
8
9namespace 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      //Utils.InstallModule("Utils", Utils.UtilsMethod);
23      //Utils.InstallModule("Sets", Sets.SetsMethod);
24      //Utils.InstallModule("Errors", Errors.ErrorsMethod);
25
26      //Utils.InstallModule("GPDefLex", GPDefLex.GPDefLexMethod);
27      //Utils.InstallModule("GPDefSem", GPDefSem.GPDefSemMethod);
28      //Utils.InstallModule("GPDefSyn", GPDefSyn.GPDefSynMethod);
29
30      //// --- initialize modules ---
31      //Utils.Modules(Utils.ModuleAction.initModule);
32
33      //Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
34
35      using (var src = new MemoryStream(Encoding.UTF8.GetBytes(codeEditor.textEditor.Text))) {
36        Scanner scanner = new Scanner(src);
37        Parser parser = new Parser(scanner);
38        parser.Parse();
39      }
40
41      codeEditor.ClearErrors();
42
43      //if (Errors.NumOfErrors() == 0) {
44      //  GPDefLex.InitLex();
45      //  GPDefSyn.Interpret();
46
47      //  MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
48      //} else {
49      //  int nLexErrors = Errors.NumOfLexErrors();
50      //  for (int i = 0; i < nLexErrors; i++) {
51      //    var lexErr = Errors.GetLexError(i == 0);
52      //    codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col);
53      //  }
54      //  int nSynErrors = Errors.NumOfSynErrors();
55      //  for (int i = 0; i < nSynErrors; i++) {
56      //    var synErr = Errors.GetSynError(i == 0);
57      //    codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col);
58      //  }
59      //}
60    }
61
62    private void Abort(string abortKind, string moduleName, string methodName, string descr) {
63
64    }
65
66    void IProblemInstanceConsumer<string>.Load(string data) {
67      codeEditor.textEditor.Text = data;
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.