Fahad/MCG-CS/AST.cs
author Christian Urban <urbanc@in.tum.de>
Fri, 10 May 2019 11:56:37 +0100
changeset 318 43e070803c1c
parent 45 7545b1bc1514
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     1
using System;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     2
using System.Collections.Generic;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     3
using System.Text;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     4
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     5
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     6
public abstract class Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     7
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     8
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     9
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    10
public class DeclareVariable : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    11
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    12
    public string Identifier;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    13
    public Expression Expression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    14
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    15
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    16
public class DeclareFunction : Statement 
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    17
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    18
    public string FunctionName;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    19
    public DeclareVariable Parameter1;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    20
    public DeclareVariable Parameter2;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    21
    public DeclareVariable Parameter3;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    22
    public String ReturnType;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    23
    public Statement Body;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    24
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    25
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    26
public class CallFunction : Statement 
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    27
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    28
    public string FunctionName;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    29
    public Expression Parameter1;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    30
    public Expression Parameter2;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    31
    public Expression Parameter3;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    32
    public Identifier ReturnVariable;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    33
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    34
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    35
public class Write : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    36
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    37
    public Expression Expression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    38
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    39
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    40
public class Assignment : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    41
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    42
    public string Identifier;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    43
    public Expression Expression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    44
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    45
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    46
public class For : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    47
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    48
    public string Identifier;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    49
    public Expression From;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    50
    public Expression To;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    51
    public Statement Body;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    52
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    53
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    54
public class IfThenElse : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    55
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    56
    public Expression If;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    57
    public Statement Then;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    58
    public Statement Else;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    59
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    60
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    61
public class IfThen : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    62
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    63
    public Expression LeftExpression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    64
    public RelationalOperands Operand;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    65
    public Expression RightExpression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    66
    public Statement ThenBody;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    67
    public Statement ElseBody;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    68
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    69
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    70
public class While : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    71
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    72
    public Expression LeftExpression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    73
    public RelationalOperands Operand;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    74
    public Expression RightExpression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    75
    public Statement Body;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    76
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    77
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    78
public class ReadInput : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    79
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    80
    public string Identifier;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    81
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    82
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    83
public class StatementSequence : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    84
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    85
    public Statement Left;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    86
    public Statement Right;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    87
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    88
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    89
public abstract class Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    90
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    91
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    92
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    93
public class AlphaNumericValue : Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    94
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    95
    public string Value;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    96
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    97
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    98
public class NumericValue : Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    99
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   100
    public int Value;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   101
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   102
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   103
public class Identifier : Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   104
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   105
    public string IdentifierName;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   106
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   107
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   108
public class ArithmaticExpression : Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   109
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   110
    public Expression Left;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   111
    public Expression Right;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   112
    public ArithmaticOperands Operand;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   113
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   114
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   115
public enum ArithmaticOperands
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   116
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   117
    Add,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   118
    Subtract,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   119
    Multiply,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   120
    Division
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   121
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   122
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   123
public class LogicalExpression : Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   124
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   125
    public Expression Left;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   126
    public Expression Right;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   127
    public LogicalOperands Operand;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   128
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   129
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   130
public enum LogicalOperands
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   131
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   132
    Or,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   133
    And,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   134
    Xor,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   135
    Not
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   136
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   137
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   138
public class RelationalExpression : Expression
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   139
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   140
    public Expression Left;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   141
    public Expression Right;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   142
    public RelationalOperands Operand;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   143
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   144
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   145
public class CompareVariable : Statement
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   146
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   147
    public string Identifier;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   148
    public Expression Expression;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   149
    public RelationalOperands Operand;
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   150
}
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   151
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   152
public enum RelationalOperands
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   153
{
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   154
    EqualTo,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   155
    NotEqualTo,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   156
    LessThan,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   157
    LessThanOrEqualTo,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   158
    GreaterThan,
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   159
    GreaterThanOrEqualTo
7545b1bc1514 msc project
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   160
}