Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/MethodBuilder.cs @ 9430

Last change on this file since 9430 was 9430, checked in by gkronber, 11 years ago

initial import of GPDL parser plugin

File size: 1.2 KB
Line 
1using System.Collections.Generic;
2using System;
3using System.Text;
4
5public class MethodBuilder {
6  private string name;
7  private string formalParameter;
8  private StringBuilder srcBuilder;
9
10  public MethodBuilder() {
11    this.srcBuilder = new StringBuilder();
12  }
13
14  public void SetName(string name) {
15    this.name = name;
16  }
17  public void SetFormalParameters(string formalParameter) {
18    this.formalParameter = formalParameter;
19  }
20
21  public void BeginAlternatives() {
22    srcBuilder.AppendLine("switch(curSy) { ");
23  }
24
25  public void StartAlternative()
26  {
27    srcBuilder.AppendLine();
28  }
29
30  public void EndAlternatives() {
31    srcBuilder.AppendLine("} ");
32  }
33
34  public void AddSource(string src) {
35    srcBuilder.AppendLine(src);
36  }
37
38  public void AddCall(string symbol, string actualParameter) {
39
40    Console.WriteLine("Call: " + symbol + " " + actualParameter);
41    srcBuilder.Append(symbol).Append("(").Append(actualParameter).Append(");");
42  }
43
44  public void Write() {
45    Console.WriteLine(GetCode());
46  }
47
48  public string GetCode() {
49    return "private void " + name + "(" + formalParameter + ") {" + Environment.NewLine +
50           srcBuilder.ToString() + Environment.NewLine +
51           "}";
52  }
53}
Note: See TracBrowser for help on using the repository browser.