/** * * 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) * */ #pragma once #include #include #include #include #include namespace Ast { class PrintVisitor final: public CompleteAstTraversalVisitor { protected: bool m_makeParens = true; bool m_writeTypes; Identifier* m_currentTypeDef; TextEmitter m_output; template void printSubElementOrNull(T* anElem); template void printEnumeration(const T& iarg); void printOperator(Expression* expression); void printType(Type* atype, const std::function& anAction); public: PrintVisitor(CallContext* context); virtual ~PrintVisitor(); void visit(MainModule* mainModule) override; void visit(TypeIdentifier* typeIdentifier) override; void visit(BoolType* boolType) override; void visit(IntType* intType) override; void visit(EnumIdentifier* enumIdentifier) override; void visit(EnumType* enumType) override; void visit(ListType* listType) override; void visit(TupleType* tupleType) override; void visit(ActionSystemType* actionSystemType) override; void visit(NullType* nullType) override; void visit(AttributeIdentifier* attributeIdentifier) override; void visit(BoolValueExpression* valueExpression) override; void visit(IntValueExpression* valueExpression) override; void visit(RefValueExpression* valueExpression) override; // void visit(AbortStatement* abortStatement) override; void visit(Assignment* assignment) override; void visit(AccessExpression* accessExpression) override; void visit(TypeExpression* typeExpression) override; void visit(BinaryOperator* binaryOperator) override; void visit(UnaryOperator* unaryOperator) override; void visit(CallExpression* callExpression) override; void visit(TupleMapAccessExpression* tupleMapAccessExpression) override; void visit(TupleConstructor* tupleConstructor) override; void visit(ListConstructor* listConstructor) override; void visit(NondetBlock* nondetBlock) override; void visit(PrioBlock* prioBlock) override; void visit(SeqBlock* seqBlock) override; void visit(Call* call) override; void visit(GuardedCommand* guardedCommand) override; void visit(IdentifierExpression* identifierExpression) override; void visit(NondetIdentifierBlock* nondetIdentifierList) override; void visit(PrioIdentifierBlock* prioIdentifierList) override; void visit(SeqIdentifierBlock* seqIdentifierList) override; void visit(Skip* skipStatement) override; void visit(TernaryOperator* ternaryOperator) override; void visit(MethodIdentifier* methodIdentifier) override; void visit(NamedActionIdentifier* namedActionIdentifier) override; void visit(SetConstructor* setConstructor) override; void visit(ExpressionVariableIdentifier* expressionVariableIdentifier) override; void visit(ObjectConstructor* objectConstructor) override; void visit(PointerType* pointerType) override; std::string returnVisitorName() { return std::string("Print OOAS"); } std::string toString() { return m_output.toString(); } }; } /* namespace Ast */