Project

General

Profile

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


/*
* AstFactory.hpp
*
* Created on: Dec 22, 2013
* Author: willibald
*/


#pragma once

#include <string>
#include <CallContext.hpp>
#include <ast/identifiers/Identifier.hpp>
#include <ast/types/Type.hpp>
#include <ast/expressions/Expression.hpp>
#include <ast/statements/Statement.hpp>
#include <cstdint>
#include <ast/Containers.hpp>

/**
* The Ast::Factory namespace defines all functions the can be used to
* create new AST objects.
*/

namespace Ast{
namespace Factory {

/** Creates an object and registers it with the context. */
ActionSystemInstance* createActionSystemInstance(CallContext &context);
SymbolTable* createSymbolTable(CallContext &context);
ParameterList* createParameterList(CallContext &context);
TypeList* createTypeList(CallContext &context);
ActionSystemInstanceList* createActionSystemInstanceList(CallContext &context);
ExpressionList* createExpressionList(CallContext &context);
IdentifierList* createIdentifierList(CallContext &context);
StatementList* createStatementList(CallContext &context);
Type* createType(CallContext &context, TypeKind t);
Statement* createStatement(CallContext &context, StatementKind t);
Identifier* createIdentifier(CallContext &context, IdentifierKind t);
Expression* createExpression(CallContext &context, ExpressionKind t);


bool addSymbolToTable(void* symbolTable, void* identifier);
bool addParameterToList(void* parameterList, void* parameterIdentifier);
bool addTypeToList(void* typeList, void* type);
bool addActionSystemInstanceToList(void* objectsList, void* instanceRef);
bool addIdentifierToBlock(void* idBlock, void* idRef);
bool addExpressionToList(void* exprList, void* exprRef);
bool addStatementToList(void* stmtList, void* stmtRef);
bool addIdentifierToList(void* idList, void* idRef);


/** Initializers.. */
bool initIdentifier(void* id, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef);
bool initEnumIdentifier(void* enumId, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef, bool haveValue, std::int32_t value);
bool initConstIdentifier(void* constId, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef, void* valueRef);
bool initAttrIdentifier(void* attrId, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef, void* initRef,bool isStatic, bool isControllable, bool isObservable);
bool initExprVarIdentifier(void* exprVarId, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef, bool initialized);
bool initTypeIdentifier(void* typeId, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef, const char* prefix);
bool initMethodIdentifier(void* methodId, std::int32_t line, std::int32_t col, const char* text,
void* scopeRef, void* typeRef, const char* prefix, void* parameterListRef, void* symbolTableRef,
void* bodyRef);
bool initModule(void* moduleId, int line, int col, const char* text, void* scopeRef,
void* typeRef, const char* prefix, void* symTabRef);
bool initMainModule(void* moduleId, int line, int col, const char* text, void* scopeRef,
void* typeRef, const char* prefix, void* symTabRef, void* idListRef);

bool initIntType(void* typeId, void* identifierRef, bool anonymousType, std::int32_t low,
std::int32_t high);
bool initBoolType(void* typeId, void* identifierRef, bool anonymousType);
bool initValuedEnumType(void* typeId, void* identifierRef, bool anonymousType, void* symTabRef,
void* intTypeRef);
bool initEnumType(void* typeId,void* identifierRef, bool anonymousType, void* symTabRef);
bool initListType(void* typeId, void* identifierRef, bool anonymousType, void* innerTypeRef,
std::uint32_t maxNumberOfElements);
bool initTupleType(void* typeId, void* identifierRef, bool anonymousType, void* typeListRef);
bool initFunctionType(void* typeId, void* identifierRef, bool anonymousType, void* paramTypeListRef,
void* returnTypeRef, std::int32_t functionKind, bool isPure);
bool initActionSystemInstance(void* instance, void* typeRef, const char* name,
std::int32_t numOfCreatedObjs, void* parentInstanceRef);
bool initActionSystemType(void* typeId, void* identifierRef, bool anonymousType, void* baseTypeRef,
void* parentScopeRef, void* doOdBlockRef, void* symTab, void* objectsListRef,
void* derivedObjectsListRef, bool autoConstruction, bool isInSystemDescription);
bool initNullType(void* typeId, void* identifierRef, bool anonymousType);

bool initSkip(void* stmnt, std::int32_t line, std::int32_t col);
bool initBreak(void* stmnt, std::int32_t line, std::int32_t col);
bool initAbort(void* stmnt, std::int32_t line, std::int32_t col);
bool initNondetBlock(void* block, std::int32_t line, std::int32_t col,
void* symTabRef, void* stmtListRef, void* scopeRef);
bool initSeqBlock(void* block, std::int32_t line, std::int32_t col,
void* symTabRef, void* stmtListRef, void* scopeRef, void* filterExprRef);
bool initPrioBlock(void* block, std::int32_t line, std::int32_t col,
void* symTabRef, void* stmtListRef, void* scopeRef);
bool initGuardedCommand(void* stmt,std::int32_t line,std::int32_t pos,
void* scopeRef,void* guardExprRef,void* bodyRef);
bool initAssignment(void* stmt,std::int32_t line,std::int32_t pos,void* scopeRef,
void* nonDetExprRef, void* placeExprListRef, void* valueExprListRef, void* symTabRef);
bool initCall(void* stmt,std::int32_t line,std::int32_t pos,void* callExprRef);

bool initTypeExpression(void* expr, std::int32_t line, std::int32_t pos,
void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef);
bool initIdentifierExpression(void* expr, std::int32_t line, std::int32_t pos,
void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
void* identifierRef, bool isSelf);
bool initUnaryExpression(void* expr, std::int32_t line, std::int32_t pos,
void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
void* child);
bool initBinaryExpression(void* expr, std::int32_t line, std::int32_t pos,
void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
void* left, void* right);
bool initTernaryExpression(void* expr, std::int32_t line, std::int32_t pos,
void* typeRef, void* callTargetsIdentifierListRef, void* symbTabRef,
void* left, void* mid, void* right, void* defScopeRef);
bool initIntValueExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef, std::int32_t value);
bool initBoolValueExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,bool value);
bool initRefValueExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef, void* value);
bool initListConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* exprList, void* symTab, void* parentScope,
void* comprehension, bool hasComprehension);
bool initSetConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* exprList, void* symTab, void* parentScope,
void* comprehension, bool hasComprehension);
bool initTupleConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* exprList, void* tupleTypeId, bool isMatcher);
bool initAccessExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* left, void* right);
bool initTupleMapAccessExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* child, void* argument);
bool initCallExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* child, void* argumentList, void* scopeRef);
bool initQuantifierExpression(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* child, void* symTabRef, void* scopeRef);
bool initObjectConstructor(void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
void* callTargetsIdentifierListRef, void* symbTabRef,
void* instanceList, std::uint32_t currentInstance, const char* name);

}
}