1
2
3
4
5
6 #ifndef SNGCPP_AST_DECLARATION_INCLUDED
7 #define SNGCPP_AST_DECLARATION_INCLUDED
8 #include <sngcpp/ast/Declarator.hpp>
9 #include <sngcpp/ast/Specifier.hpp>
10 #include <sngcpp/ast/Literal.hpp>
11
12 namespace sngcpp { namespace ast {
13
14 class SimpleDeclarationNode : public Node
15 {
16 public:
17 SimpleDeclarationNode();
18 SimpleDeclarationNode(const Span& span_, Specifier specifiers_, Node* typeExpr_, Node* declarator_);
19 void Accept(Visitor& visitor) override;
20 void Write(Writer& writer) override;
21 void Read(Reader& reader) override;
22 Specifier Specifiers() const { return specifiers; }
23 Node* TypeExpr() { return typeExpr.get(); }
24 Node* Declarator() { return declarator.get(); }
25 private:
26 Specifier specifiers;
27 std::unique_ptr<Node> typeExpr;
28 std::unique_ptr<Node> declarator;
29 };
30
31 class AliasDeclarationNode : public Node
32 {
33 public:
34 AliasDeclarationNode();
35 AliasDeclarationNode(const Span& span_, const std::u32string& id_, Node* typeExpr_);
36 void Accept(Visitor& visitor) override;
37 void Write(Writer& writer) override;
38 void Read(Reader& reader) override;
39 const std::u32string& Id() const { return id; }
40 Node* TypeExpr() { return typeExpr.get(); }
41 private:
42 std::u32string id;
43 std::unique_ptr<Node> typeExpr;
44 };
45
46 class UsingDirectiveNode : public Node
47 {
48 public:
49 UsingDirectiveNode();
50 UsingDirectiveNode(const Span& span_, Node* namespaceName_);
51 void Accept(Visitor& visitor) override;
52 void Write(Writer& writer) override;
53 void Read(Reader& reader) override;
54 Node* NamespaceName() { return namespaceName.get(); }
55 private:
56 std::unique_ptr<Node> namespaceName;
57 };
58
59 class UsingDeclarationNode : public Node
60 {
61 public:
62 UsingDeclarationNode();
63 UsingDeclarationNode(const Span& span_, Node* qualifiedId_);
64 void Accept(Visitor& visitor) override;
65 void Write(Writer& writer) override;
66 void Read(Reader& reader) override;
67 Node* QualifiedId() { return qualifiedId.get(); }
68 private:
69 std::unique_ptr<Node> qualifiedId;
70 };
71
72 class TypedefNode : public Node
73 {
74 public:
75 TypedefNode();
76 TypedefNode(const Span& span_, Node* typeExpr_, Node* declarator_);
77 void Accept(Visitor& visitor) override;
78 void Write(Writer& writer) override;
79 void Read(Reader& reader) override;
80 Node* TypeExpr() { return typeExpr.get(); }
81 Node* Declarator() { return declarator.get(); }
82 private:
83 std::unique_ptr<Node> typeExpr;
84 std::unique_ptr<Node> declarator;
85 };
86
87 class DeclarationSequenceNode : public BinaryNode
88 {
89 public:
90 DeclarationSequenceNode();
91 DeclarationSequenceNode(const Span& span_, Node* left_, Node* right_);
92 void Accept(Visitor& visitor) override;
93 };
94
95 class LinkageSpecificationNode : public Node
96 {
97 public:
98 LinkageSpecificationNode();
99 LinkageSpecificationNode(const Span& span_, StringLiteralNode* language_);
100 void Accept(Visitor& visitor) override;
101 void Write(Writer& writer) override;
102 void Read(Reader& reader) override;
103 StringLiteralNode* Language() { return language.get(); }
104 Node* Declarations() { return declarations.get(); }
105 void AddDeclaration(const Span& span_, Node* declaration);
106 private:
107 std::unique_ptr<StringLiteralNode> language;
108 std::unique_ptr<Node> declarations;
109 };
110
111 } }
112
113 #endif // SNGCPP_AST_DECLARATION_INCLUDED