Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/AST.cs @ 9518

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

initial import of GPDL parser plugin

File size: 3.1 KB
Line 
1using System.Collections.Generic;
2using System;
3using System.Text;
4
5public class GPDefNode {
6  public string Name { get; set; }
7  public CodeNode ClassCodeNode { get; set; }
8  public CodeNode InitCodeNode { get; set; }
9  public List<SymbolNode> NonTerminals { get; private set; }
10  public List<SymbolNode> Terminals { get; private set; }
11  public List<RuleNode> Rules { get; private set; }
12  public FitnessFunctionNode FitnessFunctionNode { get; set; }
13
14  public GPDefNode() {
15    this.NonTerminals = new List<SymbolNode>();
16    this.Terminals = new List<SymbolNode>();
17    this.Rules = new List<RuleNode>();
18    this.ClassCodeNode = new CodeNode();
19    this.InitCodeNode = new CodeNode();
20  }
21}
22
23public class CodeNode {
24  public string SrcCode { get; set; }
25}
26
27public class FitnessFunctionNode {
28  public bool Maximization { get; set; }
29  public string SrcCode { get; set; }
30}
31
32public class SymbolNode {
33  public string Ident { get; set; }
34  public string FormalParameters { get; set; }
35
36}
37
38public class NonTerminalNode : SymbolNode {
39}
40
41public class TerminalNode : SymbolNode {
42  public class FieldDefinition {
43    private readonly string refOrOut;
44    private readonly string type;
45    private readonly string identifier;
46
47    public FieldDefinition(string refOrOut, string type, string identifier) {
48      this.type = type;
49      this.identifier = identifier;
50      this.refOrOut = refOrOut;
51    }
52    public string RefOrOut { get { return this.refOrOut; } }
53    public string Type { get { return this.type; } }
54    public string Identifier { get { return this.identifier; } }
55  }
56  public IEnumerable<ConstraintNode> Constraints { get; set; }
57  public IEnumerable<FieldDefinition> FieldDefinitions { get; set; }
58}
59
60
61public enum ConstraintNodeType { Set, Range };
62public class ConstraintNode {
63  public string Ident { get; set; }
64  public ConstraintNodeType Type { get; set; }
65  public string SetExpression { get; set; }
66  public string RangeMinExpression { get; set; }
67  public string RangeMaxExpression { get; set; }
68  public ConstraintNode(string ident) {
69    this.Ident = ident;
70  }
71}
72
73public class RuleNode {
74  public string NtSymbol { get; set; }
75  public string LocalCode { get; set; }
76  public RuleExprNode RuleExpr { get; set; }
77}
78
79public class RuleExprNode { }
80
81public class AlternativesNode : RuleExprNode {
82  private List<RuleExprNode> alt;
83  public IEnumerable<RuleExprNode> Alternatives { get { return alt; } }
84  public AlternativesNode() {
85    this.alt = new List<RuleExprNode>();
86  }
87  public void Add(RuleExprNode expr) {
88    alt.Add(expr);
89  }
90}
91
92public class SequenceNode : RuleExprNode {
93  private readonly List<RuleExprNode> seq;
94  public IEnumerable<RuleExprNode> Sequence { get { return seq; } }
95  public SequenceNode() {
96    seq = new List<RuleExprNode>();
97  }
98  public void Add(RuleExprNode expr) {
99    seq.Add(expr);
100  }
101}
102
103public class CallSymbolNode : RuleExprNode {
104  public string Ident { get; set; }
105  public string ActualParameter { get; set; }
106}
107
108public class RuleActionNode : RuleExprNode {
109  public string SrcCode { get; set; }
110}
Note: See TracBrowser for help on using the repository browser.