-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExpressionNode.hpp
49 lines (36 loc) · 1.13 KB
/
ExpressionNode.hpp
1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "ISymbol.hpp"
#include "IdentifierNode.hpp"
#include "LiteralNode.hpp"
class ExpressionNode : public SyntaxNode {
public:
virtual ~ExpressionNode() = default;
const ISymbolType *type_of_expression;
protected:
ExpressionNode() = default;
};
class IdentifierExpressionNode : public ExpressionNode {
public:
explicit IdentifierExpressionNode(std::unique_ptr<IdentifierNode> &&identifier) : identifier_(std::move(identifier)) {}
void Visit(ISyntaxTreeVisitor *visitor) const override {
visitor->PostVisit(this);
}
const IdentifierNode *GetIdentifier() const {
return identifier_.get();
}
ISymbol *symbol;
private:
std::unique_ptr<IdentifierNode> identifier_;
};
class LiteralExpressionNode : public ExpressionNode {
public:
explicit LiteralExpressionNode(std::unique_ptr<LiteralNode> &&literal) : literal_(std::move(literal)) {}
void Visit(ISyntaxTreeVisitor *visitor) const override {
visitor->PostVisit(this);
}
const LiteralNode *GetLiteral() const {
return literal_.get();
}
private:
std::unique_ptr<LiteralNode> literal_;
};