diff --git a/inc/AST/BinOp.h b/inc/AST/BinOp.h new file mode 100644 index 0000000..1283898 --- /dev/null +++ b/inc/AST/BinOp.h @@ -0,0 +1,26 @@ +#ifndef BINOP_H +#define BINOP_H + +#include +#include "AST/Expression.h" + +class BinOp : public Expression { +public: + BinOp(Expression* leftExp ,std::string op, Expression* rightExp); + virtual ~BinOp(); + + std::string getOp(); + Expression* getLeftExp(); + Expression* getRightExp(); + virtual void accept(ASTVisitor* visitor); + + + +private: + std::string op_; + Expression* leftExp_; + Expression* rightExp_; + +}; + +#endif // BINOP_H diff --git a/src/AST/BinOp.cpp b/src/AST/BinOp.cpp new file mode 100644 index 0000000..3b3a905 --- /dev/null +++ b/src/AST/BinOp.cpp @@ -0,0 +1,26 @@ +#include "AST/BinOp.h" +#include "AST/ASTVisitor.h" + +BinOp::BinOp(Expression *leftExp, std::string op, Expression *rightExp) : + leftExp_(leftExp), op_(op), rightExp_(rightExp) { +} + +BinOp::~BinOp() { + // +} + +std::string BinOp::getOp() { + return op_; +} + +Expression* BinOp::getLeftExp() { + return leftExp_; +} + +Expression* BinOp::getRightExp() { + return rightExp_; +} + +void BinOp::accept(ASTVisitor* visitor) { + visitor->visit(this); +}