1
2
3
4
5
6 #ifndef SNGCM_AST_SOURCE_WRITER_INCLUDED
7 #define SNGCM_AST_SOURCE_WRITER_INCLUDED
8 #include <sngcm/ast/AstApi.hpp>
9 #include <sngcm/ast/Visitor.hpp>
10 #include <soulng/util/CodeFormatter.hpp>
11
12 namespace sngcm { namespace ast {
13
14 class SourceWriter : public Visitor
15 {
16 public:
17 SourceWriter(soulng::util::CodeFormatter& formatter_);
18 void Visit(BoolNode& boolNode) override;
19 void Visit(SByteNode& sbyteNode) override;
20 void Visit(ByteNode& byteNode) override;
21 void Visit(ShortNode& shortNode) override;
22 void Visit(UShortNode& ushortNode) override;
23 void Visit(IntNode& intNode) override;
24 void Visit(UIntNode& uintNode) override;
25 void Visit(LongNode& longNode) override;
26 void Visit(ULongNode& ulongNode) override;
27 void Visit(FloatNode& floatNode) override;
28 void Visit(DoubleNode& doubleNode) override;
29 void Visit(CharNode& charNode) override;
30 void Visit(WCharNode& wcharNode) override;
31 void Visit(UCharNode& ucharNode) override;
32 void Visit(VoidNode& voidNode) override;
33
34 void Visit(BooleanLiteralNode& booleanLiteralNode) override;
35 void Visit(SByteLiteralNode& sbyteLiteralNode) override;
36 void Visit(ByteLiteralNode& byteLiteralNode) override;
37 void Visit(ShortLiteralNode& shortLiteralNode) override;
38 void Visit(UShortLiteralNode& ushortLiteralNode) override;
39 void Visit(IntLiteralNode& intLiteralNode) override;
40 void Visit(UIntLiteralNode& uintLiteralNode) override;
41 void Visit(LongLiteralNode& longLiteralNode) override;
42 void Visit(ULongLiteralNode& ulongLiteralNode) override;
43 void Visit(FloatLiteralNode& floatLiteralNode) override;
44 void Visit(DoubleLiteralNode& doubleLiteralNode) override;
45 void Visit(CharLiteralNode& charLiteralNode) override;
46 void Visit(WCharLiteralNode& wcharLiteralNode) override;
47 void Visit(UCharLiteralNode& ucharLiteralNode) override;
48 void Visit(StringLiteralNode& stringLiteralNode) override;
49 void Visit(WStringLiteralNode& wstringLiteralNode) override;
50 void Visit(UStringLiteralNode& ustringLiteralNode) override;
51 void Visit(NullLiteralNode& nullLiteralNode) override;
52 void Visit(ArrayLiteralNode& arrayLiteralNode) override;
53 void Visit(StructuredLiteralNode& structuredLiteralNode) override;
54 void Visit(UuidLiteralNode& uuidLiteralNode) override;
55
56 void Visit(CompileUnitNode& compileUnitNode) override;
57 void Visit(NamespaceNode& namespaceNode) override;
58 void Visit(AliasNode& aliasNode) override;
59 void Visit(NamespaceImportNode& namespaceImportNode) override;
60 void Visit(IdentifierNode& identifierNode) override;
61 void Visit(CursorIdNode& cursorIdNode) override;
62 void Visit(TemplateIdNode& templateIdNode) override;
63 void Visit(FunctionNode& functionNode) override;
64 void Visit(ClassNode& classNode) override;
65 void Visit(ThisInitializerNode& thisInitializerNode) override;
66 void Visit(BaseInitializerNode& baseInitializerNode) override;
67 void Visit(MemberInitializerNode& memberInitializerNode) override;
68 void Visit(StaticConstructorNode& staticConstructorNode) override;
69 void Visit(ConstructorNode& constructorNode) override;
70 void Visit(DestructorNode& destructorNode) override;
71 void Visit(MemberFunctionNode& memberFunctionNode) override;
72 void Visit(ConversionFunctionNode& conversionFunctionNode) override;
73 void Visit(MemberVariableNode& memberVariableNode) override;
74 void Visit(InterfaceNode& interfaceNode) override;
75 void Visit(DelegateNode& delegateNode) override;
76 void Visit(ClassDelegateNode& classDelegateNode) override;
77
78 void Visit(ParenthesizedConstraintNode& parenthesizedConstraintNode) override;
79 void Visit(DisjunctiveConstraintNode& disjunctiveConstraintNode) override;
80 void Visit(ConjunctiveConstraintNode& conjunctiveConstraintNode) override;
81 void Visit(WhereConstraintNode& whereConstraintNode) override;
82 void Visit(PredicateConstraintNode& predicateConstraintNode) override;
83 void Visit(IsConstraintNode& isConstraintNode) override;
84 void Visit(MultiParamConstraintNode& multiParamConstraintNode) override;
85 void Visit(TypeNameConstraintNode& typeNameConstraintNode) override;
86 void Visit(ConstructorConstraintNode& constructorConstraintNode) override;
87 void Visit(DestructorConstraintNode& destructorConstraintNode) override;
88 void Visit(MemberFunctionConstraintNode& memberFunctionConstraintNode) override;
89 void Visit(FunctionConstraintNode& functionConstraintNode) override;
90 void Visit(AxiomStatementNode& axiomStatementNode) override;
91 void Visit(AxiomNode& axiomNode) override;
92 void Visit(ConceptIdNode& conceptIdNode) override;
93 void Visit(ConceptNode& conceptNode) override;
94
95 void Visit(LabelNode& labelNode) override;
96 void Visit(LabeledStatementNode& labeledStatementNode) override;
97 void Visit(CompoundStatementNode& compoundStatementNode) override;
98 void Visit(ReturnStatementNode& returnStatementNode) override;
99 void Visit(IfStatementNode& ifStatementNode) override;
100 void Visit(WhileStatementNode& whileStatementNode) override;
101 void Visit(DoStatementNode& doStatementNode) override;
102 void Visit(ForStatementNode& forStatementNode) override;
103 void Visit(BreakStatementNode& breakStatementNode) override;
104 void Visit(ContinueStatementNode& continueStatementNode) override;
105 void Visit(GotoStatementNode& gotoStatementNode) override;
106 void Visit(ConstructionStatementNode& constructionStatementNode) override;
107 void Visit(DeleteStatementNode& deleteStatementNode) override;
108 void Visit(DestroyStatementNode& destroyStatementNode) override;
109 void Visit(AssignmentStatementNode& assignmentStatementNode) override;
110 void Visit(ExpressionStatementNode& expressionStatementNode) override;
111 void Visit(EmptyStatementNode& emptyStatementNode) override;
112 void Visit(RangeForStatementNode& rangeForStatementNode) override;
113 void Visit(SwitchStatementNode& switchStatementNode) override;
114 void Visit(CaseStatementNode& caseStatementNode) override;
115 void Visit(DefaultStatementNode& defaultStatementNode) override;
116 void Visit(GotoCaseStatementNode& gotoCaseStatementNode) override;
117 void Visit(GotoDefaultStatementNode& gotoDefaultStatementNode) override;
118 void Visit(ThrowStatementNode& throwStatementNode) override;
119 void Visit(TryStatementNode& tryStatementNode) override;
120 void Visit(CatchNode& catchNode) override;
121 void Visit(AssertStatementNode& assertStatementNode) override;
122 void Visit(ConditionalCompilationPartNode& conditionalCompilationPartNode) override;
123 void Visit(ConditionalCompilationDisjunctionNode& conditionalCompilationDisjunctionNode) override;
124 void Visit(ConditionalCompilationConjunctionNode& conditionalCompilationConjunctionNode) override;
125 void Visit(ConditionalCompilationNotNode& conditionalCompilationNotNode) override;
126 void Visit(ConditionalCompilationPrimaryNode& conditionalCompilationPrimaryNode) override;
127 void Visit(ParenthesizedConditionalCompilationExpressionNode& parenthesizeCondCompExprNode) override;
128 void Visit(ConditionalCompilationStatementNode& conditionalCompilationStatementNode) override;
129
130 void Visit(TypedefNode& typedefNode) override;
131 void Visit(ConstantNode& constantNode) override;
132 void Visit(EnumTypeNode& enumTypeNode) override;
133 void Visit(EnumConstantNode& enumConstantNode) override;
134 void Visit(ParameterNode& parameterNode) override;
135 void Visit(TemplateParameterNode& templateParameterNode) override;
136
137 void Visit(ConstNode& constNode) override;
138 void Visit(LValueRefNode& lvalueRefNode) override;
139 void Visit(RValueRefNode& rvalueRefNode) override;
140 void Visit(PointerNode& pointerNode) override;
141 void Visit(ArrayNode& arrayNode) override;
142
143 void Visit(DotNode& dotNode) override;
144 void Visit(ArrowNode& arrowNode) override;
145 void Visit(EquivalenceNode& equivalenceNode) override;
146 void Visit(ImplicationNode& implicationNode) override;
147 void Visit(DisjunctionNode& disjunctionNode) override;
148 void Visit(ConjunctionNode& conjunctionNode) override;
149 void Visit(BitOrNode& bitOrNode) override;
150 void Visit(BitXorNode& bitXorNode) override;
151 void Visit(BitAndNode& bitAndNode) override;
152 void Visit(EqualNode& equalNode) override;
153 void Visit(NotEqualNode& notEqualNode) override;
154 void Visit(LessNode& lessNode) override;
155 void Visit(GreaterNode& greaterNode) override;
156 void Visit(LessOrEqualNode& lessOrEqualNode) override;
157 void Visit(GreaterOrEqualNode& greaterOrEqualNode) override;
158 void Visit(ShiftLeftNode& shiftLeftNode) override;
159 void Visit(ShiftRightNode& shiftRightNode) override;
160 void Visit(AddNode& addNode) override;
161 void Visit(SubNode& subNode) override;
162 void Visit(MulNode& mulNode) override;
163 void Visit(DivNode& divNode) override;
164 void Visit(RemNode& remNode) override;
165 void Visit(NotNode& notNode) override;
166 void Visit(UnaryPlusNode& unaryPlusNode) override;
167 void Visit(UnaryMinusNode& unaryMinusNode) override;
168 void Visit(PrefixIncrementNode& prefixIncrementNode) override;
169 void Visit(PrefixDecrementNode& prefixDecrementNode) override;
170 void Visit(DerefNode& derefNode) override;
171 void Visit(AddrOfNode& addrOfNode) override;
172 void Visit(ComplementNode& complementNode) override;
173 void Visit(IsNode& isNode) override;
174 void Visit(AsNode& asNode) override;
175 void Visit(IndexingNode& indexingNode) override;
176 void Visit(InvokeNode& invokeNode) override;
177 void Visit(PostfixIncrementNode& postfixIncrementNode) override;
178 void Visit(PostfixDecrementNode& postfixDecrementNode) override;
179 void Visit(SizeOfNode& sizeOfNode) override;
180 void Visit(TypeNameNode& typeNameNode) override;
181 void Visit(TypeIdNode& typeIdNode) override;
182 void Visit(CastNode& castNode) override;
183 void Visit(ConstructNode& constructNode) override;
184 void Visit(NewNode& newNode) override;
185 void Visit(ThisNode& thisNode) override;
186 void Visit(BaseNode& baseNode) override;
187 void Visit(ParenthesizedExpressionNode& parenthesizedExpressionNode) override;
188 void Visit(GlobalVariableNode& globalVariableNode) override;
189 void Visit(Attribute& attribute) override;
190 void Visit(Attributes& attributes) override;
191 void Visit(CommentNode& comment) override;
192 void WriteWarning(const std::string& message);
193 void WriteEmptyLine();
194 private:
195 soulng::util::CodeFormatter& formatter;
196 bool omitNewLine;
197 bool omitSemicolon;
198 bool emptyLine;
199 };
200
201 } }
202
203 #endif // SNGCM_AST_SOURCE_WRITER_INCLUDED