Project

General

Profile

root / trunk / compiler / cppAst / ast / Ast.hpp @ 6

1
/**
2
  *
3
  *                  OOAS Compiler - C++ AST
4
  *
5
  * Copyright 2015, AIT Austrian Institute of Technology.
6
  * All rights reserved.
7
  *
8
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
9
  *
10
  * If you modify the file please update the list of contributors below to in-
11
  * clude your name. Please also stick to the coding convention of using TABs
12
  * to do the basic (block-level) indentation and spaces for anything after
13
  * that. (Enable the display of special chars and it should be pretty obvious
14
  * what this means.) Also, remove all trailing whitespace.
15
  *
16
  * Contributors:
17
  *               Willibald Krenn (AIT)
18
  *               Stephan Zimmerer (AIT)
19
  *               Christoph Czurda (AIT)
20
  *
21
  */
22

    
23

    
24

    
25

    
26
#pragma once
27

    
28
#include <cstdint>
29
#include <deque>
30
#include <base/TiresiasObject.hpp>
31

    
32
class CallContext;
33

    
34
namespace Ast {
35

    
36
/**
37
 * Forward declarations of the AST classes
38
 */
39
class TypeIdentifier;
40
class EnumIdentifier;
41
//class ValuedEnumIdentifier;
42
class AttributeIdentifier;
43
class LocalVariableIdentifier;
44
class ParameterIdentifier;
45
class ExpressionVariableIdentifier;
46
class MethodIdentifier;
47
class NamedActionIdentifier;
48
class Module;
49
class ConstantIdentifier;
50
class IntType;
51
class BoolType;
52
class EnumType;
53
class ListType;
54
class TupleType;
55
class NullType;
56
class FunctionType;
57
class ActionSystemType;
58
class GuardedCommand;
59
class Call;
60
class Assignment;
61
class SeqBlock;
62
class NondetBlock;
63
class PrioBlock;
64
class Skip;
65
class Break;
66
class Abort;
67
class TernaryOperator;
68
class BinaryOperator;
69
class UnaryOperator;
70
class ExistsQuantifier;
71
class ForallQuantifier;
72
class ListConstructor;
73
class SetConstructor;
74
class TupleConstructor;
75
class ObjectConstructor;
76
class IdentifierExpression;
77
class BoolValueExpression;
78
class IntValueExpression;
79
class RefValueExpression;
80
class TypeExpression;
81
class TupleMapAccessExpression;
82
class CallExpression;
83
class AccessExpression;
84
class UnspecIdentifierBlock;
85
class SeqIdentifierBlock;
86
class NondetIdentifierBlock;
87
class PrioIdentifierBlock;
88
class MainModule;
89
class PointerType;
90
class ActionSystemInstance;
91
class ValuedEnumType;
92

    
93

    
94
class ExpressionList;
95
class StatementList;
96
class IdentifierList;
97
class ParameterList;
98
class TypeList;
99
class ActionSystemInstanceList;
100

    
101
enum class ExpressionKind: std::uint8_t;
102
enum class TypeKind : std::uint8_t;
103
enum class StatementKind: std::uint8_t;
104
enum class IdentifierKind: std::uint8_t;
105

    
106
class SymbolTable;
107
class Type;
108
class Statement;
109
class Identifier;
110
class Expression;
111
/**
112
 * Facade
113
 */
114
class Ast final {
115
private:
116
        CallContext* m_context;
117
        /* List of owned AST objects */
118
        std::deque<Base::TiresiasObject*> m_allocatedAstObjects;
119

    
120
        Base::TiresiasObject* takeOwnership(Base::TiresiasObject* obj);
121
public:
122
        Ast(CallContext* context);
123
        ~Ast();
124

    
125
        // Constructors: All the objects created are owned by this AST. IOW once
126
        // this object is gone, all the created elements as well.
127
        // ALL the copy constructors will do a shallow copy. Use the clone visitor to get a deep clone.
128

    
129
        Type* createType(TypeKind t);
130
        Type* createType(const Type& toCopy);
131

    
132
        Statement* createStatement(StatementKind t);            // new, empty statement
133
        Statement* createStatement(const Statement& toCopy);    // shallow copy statement
134
        Statement* deepCopyStatement(Statement* toCopy);        // deep copy statement
135

    
136
        Identifier* createIdentifier(IdentifierKind t);
137
        Identifier* createIdentifier(const Identifier& toCopy);
138

    
139
        Expression* createExpression(ExpressionKind t);         // new, empty expression
140
        Expression* createExpression(const Expression& toCopy); // shallow copy expression
141
        Expression* deepCopyExpression(Expression* toCopy);     // deep copy expression
142

    
143
        ActionSystemInstance* createActionSystemInstance();
144
        ActionSystemInstance* createActionSystemInstance(const ActionSystemInstance& toCopy);
145

    
146
        ExpressionList* createExpressionList();
147
        ExpressionList* createExpressionList(const ExpressionList& toCopy);
148

    
149
        IdentifierList* createIdentifierList();
150
        IdentifierList* createIdentifierList(const IdentifierList& toCopy);
151

    
152
        StatementList* createStatementList();
153
        StatementList* createStatementList(const StatementList& toCopy);
154

    
155
        ParameterList* createParameterList();
156
        ParameterList* createParameterList(const ParameterList& toCopy);
157

    
158
        TypeList* createTypeList();
159
        TypeList* createTypeList(const TypeList& toCopy);
160

    
161
        ActionSystemInstanceList* createActionSystemInstanceList();
162
        ActionSystemInstanceList* createActionSystemInstanceList(const ActionSystemInstanceList& toCopy);
163

    
164
        SymbolTable* createSymbolTable();
165
        SymbolTable* createSymbolTable(const SymbolTable& toCopy);
166
};
167

    
168
}