From a67e369e007a74ff1ac2160d6574b2026e19ea88 Mon Sep 17 00:00:00 2001 From: Peter Dahlberg Date: Sat, 1 Jun 2013 01:22:04 +0200 Subject: [PATCH] binOp --- inc/AST/BinOp.h | 26 ++++++++++++++++++++++++++ src/AST/BinOp.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 inc/AST/BinOp.h create mode 100644 src/AST/BinOp.cpp 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); +}