2012-12-05 19:32:43 +00:00
|
|
|
/*
|
|
|
|
* BasicExpression.h
|
|
|
|
*
|
|
|
|
* Created on: Dec 5, 2012
|
|
|
|
* Author: attero
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BASICEXPRESSION_H_
|
|
|
|
#define BASICEXPRESSION_H_
|
|
|
|
#include "ASTExpression.h"
|
2012-12-07 15:58:27 +00:00
|
|
|
#include <iostream>
|
2012-12-28 10:01:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* BasicExpression is a very important class in my AST design. It always has
|
|
|
|
* two children, which are actually left and right operands. Basic expression stores
|
|
|
|
* a type of operation it does. It can be "+" or "-" for example.
|
|
|
|
* Type of operator is very important when expression evaluates itself.
|
|
|
|
*
|
|
|
|
*/
|
2012-12-05 19:32:43 +00:00
|
|
|
class BasicExpression : public ASTExpression {
|
|
|
|
public:
|
2012-12-05 22:27:03 +00:00
|
|
|
|
2012-12-05 19:32:43 +00:00
|
|
|
void set_operator(std::string op);
|
|
|
|
void set_left_operand(ASTNode * left);
|
|
|
|
void set_right_operand(ASTNode * right);
|
2012-12-05 20:31:06 +00:00
|
|
|
virtual SenchaObject evaluate();
|
2012-12-07 15:58:27 +00:00
|
|
|
virtual void execute();
|
2012-12-09 11:57:51 +00:00
|
|
|
virtual void execute_quietly();
|
2012-12-21 15:21:49 +00:00
|
|
|
std::string get_operator() { return oper; }
|
2012-12-18 21:41:39 +00:00
|
|
|
virtual void accept(Visitor * visitor);
|
2012-12-05 22:27:03 +00:00
|
|
|
|
2012-12-28 10:01:48 +00:00
|
|
|
BasicExpression();
|
2012-12-05 19:32:43 +00:00
|
|
|
virtual ~BasicExpression();
|
2012-12-21 15:21:49 +00:00
|
|
|
|
|
|
|
private:
|
2012-12-28 10:01:48 +00:00
|
|
|
//Do I use it for anything actually?
|
2012-12-21 15:21:49 +00:00
|
|
|
bool children_set;
|
|
|
|
std::string oper;
|
2012-12-05 19:32:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* BASICEXPRESSION_H_ */
|