1 |
2
|
krennw
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
#pragma once
|
27 |
|
|
|
28 |
|
|
#include <ast/CompleteAstTraversalVisitor.hpp>
|
29 |
|
|
#include <ast/identifiers/Identifier.hpp>
|
30 |
|
|
#include <ast/TextEmitter.hpp>
|
31 |
|
|
#include <ast/identifiers/IdentifierBlock.hpp>
|
32 |
|
|
#include <ast/statements/Skip.hpp>
|
33 |
|
|
|
34 |
|
|
namespace Ast {
|
35 |
|
|
|
36 |
|
|
class PrintVisitor final:
|
37 |
|
|
public CompleteAstTraversalVisitor
|
38 |
|
|
{
|
39 |
|
|
protected:
|
40 |
|
|
bool m_makeParens = true;
|
41 |
|
|
bool m_writeTypes;
|
42 |
|
|
Identifier* m_currentTypeDef;
|
43 |
|
|
TextEmitter m_output;
|
44 |
|
|
|
45 |
|
|
template<typename T> void printSubElementOrNull(T* anElem);
|
46 |
|
|
template <typename T> void printEnumeration(const T& iarg);
|
47 |
|
|
void printOperator(Expression* expression);
|
48 |
|
|
void printType(Type* atype, const std::function<void()>& anAction);
|
49 |
|
|
|
50 |
|
|
public:
|
51 |
|
|
PrintVisitor(CallContext* context);
|
52 |
|
|
virtual ~PrintVisitor();
|
53 |
|
|
|
54 |
|
|
void visit(MainModule* mainModule) override;
|
55 |
|
|
void visit(TypeIdentifier* typeIdentifier) override;
|
56 |
|
|
void visit(BoolType* boolType) override;
|
57 |
|
|
void visit(IntType* intType) override;
|
58 |
|
|
void visit(EnumIdentifier* enumIdentifier) override;
|
59 |
|
|
void visit(EnumType* enumType) override;
|
60 |
|
|
void visit(ListType* listType) override;
|
61 |
|
|
void visit(TupleType* tupleType) override;
|
62 |
|
|
void visit(ActionSystemType* actionSystemType) override;
|
63 |
|
|
void visit(NullType* nullType) override;
|
64 |
|
|
void visit(AttributeIdentifier* attributeIdentifier) override;
|
65 |
|
|
void visit(BoolValueExpression* valueExpression) override;
|
66 |
|
|
void visit(IntValueExpression* valueExpression) override;
|
67 |
|
|
void visit(RefValueExpression* valueExpression) override;
|
68 |
|
|
|
69 |
|
|
void visit(Assignment* assignment) override;
|
70 |
|
|
void visit(AccessExpression* accessExpression) override;
|
71 |
|
|
void visit(TypeExpression* typeExpression) override;
|
72 |
|
|
void visit(BinaryOperator* binaryOperator) override;
|
73 |
|
|
void visit(UnaryOperator* unaryOperator) override;
|
74 |
|
|
void visit(CallExpression* callExpression) override;
|
75 |
|
|
void visit(TupleMapAccessExpression* tupleMapAccessExpression) override;
|
76 |
|
|
void visit(TupleConstructor* tupleConstructor) override;
|
77 |
|
|
void visit(ListConstructor* listConstructor) override;
|
78 |
|
|
void visit(NondetBlock* nondetBlock) override;
|
79 |
|
|
void visit(PrioBlock* prioBlock) override;
|
80 |
|
|
void visit(SeqBlock* seqBlock) override;
|
81 |
|
|
void visit(Call* call) override;
|
82 |
|
|
void visit(GuardedCommand* guardedCommand) override;
|
83 |
|
|
void visit(IdentifierExpression* identifierExpression) override;
|
84 |
|
|
void visit(NondetIdentifierBlock* nondetIdentifierList) override;
|
85 |
|
|
void visit(PrioIdentifierBlock* prioIdentifierList) override;
|
86 |
|
|
void visit(SeqIdentifierBlock* seqIdentifierList) override;
|
87 |
|
|
void visit(Skip* skipStatement) override;
|
88 |
|
|
void visit(TernaryOperator* ternaryOperator) override;
|
89 |
|
|
void visit(MethodIdentifier* methodIdentifier) override;
|
90 |
|
|
void visit(NamedActionIdentifier* namedActionIdentifier) override;
|
91 |
|
|
void visit(SetConstructor* setConstructor) override;
|
92 |
|
|
void visit(ExpressionVariableIdentifier* expressionVariableIdentifier) override;
|
93 |
|
|
void visit(ObjectConstructor* objectConstructor) override;
|
94 |
|
|
void visit(PointerType* pointerType) override;
|
95 |
|
|
|
96 |
|
|
std::string returnVisitorName() {
|
97 |
|
|
return std::string("Print OOAS");
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
std::string toString()
|
101 |
|
|
{
|
102 |
|
|
return m_output.toString();
|
103 |
|
|
}
|
104 |
|
|
};
|
105 |
|
|
|
106 |
|
|
} |