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 | //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 | }
|
---|