1
2
3
4
5
6 #ifndef SNGCPP_AST_FUNCTION_INCLUDED
7 #define SNGCPP_AST_FUNCTION_INCLUDED
8 #include <sngcpp/ast/Statement.hpp>
9 #include <sngcpp/ast/Specifier.hpp>
10
11 namespace sngcpp { namespace ast {
12
13 class ParameterNode : public Node
14 {
15 public:
16 ParameterNode();
17 ParameterNode(const Span& span_, Node* typeExpr_, Node* declarator_);
18 void Accept(Visitor& visitor) override;
19 void Write(Writer& writer) override;
20 void Read(Reader& reader) override;
21 Node* TypeExpr() { return typeExpr.get(); }
22 Node* Declarator() { return declarator.get(); }
23 private:
24 std::unique_ptr<Node> typeExpr;
25 std::unique_ptr<Node> declarator;
26 };
27
28 class ParameterSequenceNode : public BinaryNode
29 {
30 public:
31 ParameterSequenceNode();
32 ParameterSequenceNode(const Span& span_, Node* left_, Node* right_);
33 void Accept(Visitor& visitor) override;
34 };
35
36 class FunctionNode : public Node
37 {
38 public:
39 FunctionNode();
40 FunctionNode(const Span& span_, Specifier specifiers_, Node* typeExpr_, Node* declarator_, CompoundStatementNode* body_);
41 void Accept(Visitor& visitor) override;
42 void Write(Writer& writer) override;
43 void Read(Reader& reader) override;
44 Specifier Specifiers() const { return specifiers; }
45 Node* TypeExpr() { return typeExpr.get(); }
46 Node* Declarator() { return declarator.get(); }
47 CompoundStatementNode* Body() { return body.get(); }
48 private:
49 Specifier specifiers;
50 std::unique_ptr<Node> typeExpr;
51 std::unique_ptr<Node> declarator;
52 std::unique_ptr<CompoundStatementNode> body;
53 };
54
55 bool IsFunctionDeclarator(Node* declaratorNode);
56 bool HasPureSpecifier(Specifier specifiers);
57
58 } }
59
60 #endif // SNGCPP_AST_FUNCTION_INCLUDED