Line data Source code
1 : #ifndef AST_BINARY_H
2 : #define AST_BINARY_H
3 :
4 : #include "../../../lexicalAnalysis/token.h"
5 : #include "../ast.h"
6 : #include <memory>
7 :
8 : namespace nicole {
9 :
10 : class AST_BINARY : public AST {
11 : private:
12 : Token op_;
13 : std::shared_ptr<AST> left_;
14 : std::shared_ptr<AST> right_;
15 :
16 : public:
17 : explicit AST_BINARY(const long long unsigned nodeId,
18 : const SourceLocation &srcLoc, const Token &op,
19 : const std::shared_ptr<AST> &left,
20 : const std::shared_ptr<AST> &right) noexcept
21 1 : : AST(nodeId, AST_TYPE::BINARY, srcLoc), op_{op}, left_{left},
22 1 : right_{right} {}
23 :
24 9 : [[nodiscard]] const Token &op() const noexcept { return op_; }
25 :
26 18 : [[nodiscard]] const std::shared_ptr<AST> &left() const noexcept {
27 18 : return left_;
28 18 : }
29 :
30 18 : [[nodiscard]] const std::shared_ptr<AST> &right() const noexcept {
31 18 : return right_;
32 18 : }
33 :
34 : [[nodiscard]] std::expected<std::string, Error>
35 0 : accept(const PrintTree &visitor) const noexcept override {
36 0 : return visitor.visit(this);
37 0 : }
38 :
39 : [[nodiscard]] std::expected<bool, Error>
40 0 : accept(const ValidateTree &visitor) const noexcept override {
41 0 : return visitor.visit(this);
42 0 : }
43 :
44 : [[nodiscard]] std::expected<std::monostate, Error>
45 0 : accept(const FillSemanticInfo &visitor) const noexcept override {
46 0 : return visitor.visit(this);
47 0 : }
48 :
49 : [[nodiscard]] std::expected<std::shared_ptr<Type>, Error>
50 0 : accept(const TypeAnalysis &visitor) const noexcept override {
51 0 : return visitor.visit(this);
52 0 : }
53 :
54 : [[nodiscard]] std::expected<std::monostate, Error>
55 0 : accept(const Monomorphize &visitor) const noexcept override {
56 0 : return visitor.visit(this);
57 0 : }
58 :
59 : [[nodiscard]] std::expected<std::shared_ptr<llvm::Value>, Error>
60 0 : accept(const CodeGeneration &visitor) const noexcept override {
61 0 : return visitor.visit(this);
62 0 : }
63 : };
64 :
65 : } // namespace nicole
66 :
67 : #endif
|