Project

General

Profile

root / trunk / compiler / cppAst / ast / AstFactory.hpp @ 10

1 7 krennw
/**
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 2 krennw
23
24
25
/*
26
 * AstFactory.hpp
27
 *
28
 *  Created on: Dec 22, 2013
29
 *      Author: willibald
30
 */
31
32
33
#pragma once
34
35
#include <string>
36
#include <CallContext.hpp>
37
#include <ast/identifiers/Identifier.hpp>
38
#include <ast/types/Type.hpp>
39
#include <ast/expressions/Expression.hpp>
40
#include <ast/statements/Statement.hpp>
41
#include <cstdint>
42
#include <ast/Containers.hpp>
43
44
/**
45
 * The Ast::Factory namespace defines all functions the can be used to
46
 * create new AST objects.
47
 */
48
49
namespace Ast{
50
namespace Factory {
51
52
        /** Creates an object and registers it with the context. */
53
        ActionSystemInstance* createActionSystemInstance(CallContext &context);
54
        SymbolTable* createSymbolTable(CallContext &context);
55
        ParameterList* createParameterList(CallContext &context);
56
        TypeList* createTypeList(CallContext &context);
57
        ActionSystemInstanceList* createActionSystemInstanceList(CallContext &context);
58
        ExpressionList* createExpressionList(CallContext &context);
59
        IdentifierList* createIdentifierList(CallContext &context);
60
        StatementList* createStatementList(CallContext &context);
61
        Type* createType(CallContext &context, TypeKind t);
62
        Statement* createStatement(CallContext &context, StatementKind t);
63
        Identifier* createIdentifier(CallContext &context, IdentifierKind t);
64
        Expression* createExpression(CallContext &context, ExpressionKind t);
65
66
67
        bool addSymbolToTable(void* symbolTable, void* identifier);
68
        bool addParameterToList(void* parameterList, void* parameterIdentifier);
69
        bool addTypeToList(void* typeList, void* type);
70
        bool addActionSystemInstanceToList(void* objectsList, void* instanceRef);
71
        bool addIdentifierToBlock(void* idBlock, void* idRef);
72
        bool addExpressionToList(void* exprList, void* exprRef);
73
        bool addStatementToList(void* stmtList, void* stmtRef);
74
        bool addIdentifierToList(void* idList, void* idRef);
75
76
77
        /** Initializers.. */
78
        bool initIdentifier(void* id, std::int32_t line, std::int32_t col, const char* text,
79
                void* scopeRef, void* typeRef);
80
        bool initEnumIdentifier(void* enumId, std::int32_t line, std::int32_t col, const char* text,
81
                        void* scopeRef, void* typeRef, bool haveValue, std::int32_t value);
82
        bool initConstIdentifier(void* constId, std::int32_t line, std::int32_t col, const char* text,
83
                void* scopeRef, void* typeRef, void* valueRef);
84
        bool initAttrIdentifier(void* attrId, std::int32_t line, std::int32_t col, const char* text,
85
                void* scopeRef, void* typeRef, void* initRef,bool isStatic, bool isControllable, bool isObservable);
86
        bool initExprVarIdentifier(void* exprVarId, std::int32_t line, std::int32_t col, const char* text,
87
                void* scopeRef, void* typeRef, bool initialized);
88
        bool initTypeIdentifier(void* typeId, std::int32_t line, std::int32_t col, const char* text,
89
                void* scopeRef, void* typeRef, const char* prefix);
90
        bool initMethodIdentifier(void* methodId, std::int32_t line, std::int32_t col, const char* text,
91
                void* scopeRef, void* typeRef, const char* prefix, void* parameterListRef, void* symbolTableRef,
92
                void* bodyRef);
93
        bool initModule(void* moduleId, int line, int col, const char* text, void* scopeRef,
94
                void* typeRef, const char* prefix, void* symTabRef);
95
        bool initMainModule(void* moduleId, int line, int col, const char* text, void* scopeRef,
96
                void* typeRef, const char* prefix, void* symTabRef, void* idListRef);
97
98
        bool initIntType(void* typeId, void* identifierRef, bool anonymousType, std::int32_t low,
99
                std::int32_t high);
100
        bool initBoolType(void* typeId, void* identifierRef, bool anonymousType);
101
        bool initValuedEnumType(void* typeId, void* identifierRef, bool anonymousType, void* symTabRef,
102
                void* intTypeRef);
103
        bool initEnumType(void* typeId,void* identifierRef, bool anonymousType, void* symTabRef);
104
        bool initListType(void* typeId, void* identifierRef, bool anonymousType, void* innerTypeRef,
105
                std::uint32_t maxNumberOfElements);
106
        bool initTupleType(void* typeId, void* identifierRef, bool anonymousType, void* typeListRef);
107
        bool initFunctionType(void* typeId, void* identifierRef, bool anonymousType, void* paramTypeListRef,
108
                void* returnTypeRef, std::int32_t functionKind, bool isPure);
109
        bool initActionSystemInstance(void* instance, void* typeRef, const char* name,
110
                std::int32_t numOfCreatedObjs, void* parentInstanceRef);
111
        bool initActionSystemType(void* typeId, void* identifierRef, bool anonymousType, void* baseTypeRef,
112
                void* parentScopeRef, void* doOdBlockRef, void* symTab, void* objectsListRef,
113
                void* derivedObjectsListRef, bool autoConstruction, bool isInSystemDescription);
114
        bool initNullType(void* typeId, void* identifierRef, bool anonymousType);
115
116
        bool initSkip(void* stmnt, std::int32_t line, std::int32_t col);
117
        bool initBreak(void* stmnt, std::int32_t line, std::int32_t col);
118
        bool initAbort(void* stmnt, std::int32_t line, std::int32_t col);
119
        bool initNondetBlock(void* block, std::int32_t line, std::int32_t col,
120
                        void* symTabRef, void* stmtListRef, void* scopeRef);
121
        bool initSeqBlock(void* block, std::int32_t line, std::int32_t col,
122
                        void* symTabRef, void* stmtListRef, void* scopeRef, void* filterExprRef);
123
        bool initPrioBlock(void* block, std::int32_t line, std::int32_t col,
124
                        void* symTabRef, void* stmtListRef, void* scopeRef);
125
        bool initGuardedCommand(void* stmt,std::int32_t line,std::int32_t pos,
126
                        void* scopeRef,void* guardExprRef,void* bodyRef);
127
        bool initAssignment(void* stmt,std::int32_t line,std::int32_t pos,void* scopeRef,
128
                        void* nonDetExprRef, void* placeExprListRef, void* valueExprListRef, void* symTabRef);
129
        bool initCall(void* stmt,std::int32_t line,std::int32_t pos,void* callExprRef);
130
131
        bool initTypeExpression(void* expr, std::int32_t line, std::int32_t pos,
132
                        void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef);
133
        bool initIdentifierExpression(void* expr, std::int32_t line, std::int32_t pos,
134
                        void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
135
                        void* identifierRef, bool isSelf);
136
        bool initUnaryExpression(void* expr, std::int32_t line, std::int32_t pos,
137
                        void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
138
                        void* child);
139
        bool initBinaryExpression(void* expr, std::int32_t line, std::int32_t pos,
140
                        void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
141
                        void* left, void* right);
142
        bool initTernaryExpression(void* expr, std::int32_t line, std::int32_t pos,
143
                        void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
144
                        void* left, void* mid, void* right, void* defScopeRef);
145
        bool initIntValueExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
146
                        void* callTargetsIdentifierListRef, void* symbTabRef, std::int32_t value);
147
        bool initBoolValueExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
148
                        void* callTargetsIdentifierListRef, void* symbTabRef,bool value);
149
        bool initRefValueExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
150
                        void* callTargetsIdentifierListRef, void* symbTabRef, void* value);
151
        bool initListConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
152
                        void* callTargetsIdentifierListRef, void* symbTabRef,
153
                        void* exprList, void* symTab, void* parentScope,
154
                        void* comprehension, bool hasComprehension);
155
        bool initSetConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
156
                        void* callTargetsIdentifierListRef, void* symbTabRef,
157
                        void* exprList, void* symTab, void* parentScope,
158
                        void* comprehension, bool hasComprehension);
159
        bool initTupleConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
160
                        void* callTargetsIdentifierListRef, void* symbTabRef,
161
                        void* exprList, void* tupleTypeId, bool isMatcher);
162
        bool initAccessExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
163
                        void* callTargetsIdentifierListRef, void* symbTabRef,
164
                        void* left, void* right);
165
        bool initTupleMapAccessExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
166
                        void* callTargetsIdentifierListRef, void* symbTabRef,
167
                        void* child, void* argument);
168
        bool initCallExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
169
                        void* callTargetsIdentifierListRef, void* symbTabRef,
170
                        void* child, void* argumentList, void* scopeRef);
171
        bool initQuantifierExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
172
                        void* callTargetsIdentifierListRef, void* symbTabRef,
173
                        void* child, void* symTabRef, void* scopeRef);
174
        bool initObjectConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
175
                        void* callTargetsIdentifierListRef, void* symbTabRef,
176
                        void* instanceList, std::uint32_t currentInstance, const char* name);
177
178
}
179
}