2010-01-30 07:26:05 +03:00
|
|
|
#ifndef EXPRESSION_H_
|
|
|
|
#define EXPRESSION_H_
|
|
|
|
|
2011-09-03 08:10:36 +04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2012-03-28 02:05:00 +04:00
|
|
|
#include "value.h"
|
2013-04-19 02:34:14 +04:00
|
|
|
#include "typedefs.h"
|
2010-01-30 07:26:05 +03:00
|
|
|
|
|
|
|
class Expression
|
|
|
|
{
|
|
|
|
public:
|
2011-09-03 08:10:36 +04:00
|
|
|
std::vector<Expression*> children;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2012-03-28 02:05:00 +04:00
|
|
|
const Value const_value;
|
2011-09-03 08:10:36 +04:00
|
|
|
std::string var_name;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2011-09-03 08:10:36 +04:00
|
|
|
std::string call_funcname;
|
2013-04-19 02:34:14 +04:00
|
|
|
AssignmentList call_arguments;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
|
|
|
// Boolean: ! && ||
|
|
|
|
// Operators: * / % + -
|
|
|
|
// Relations: < <= == != >= >
|
|
|
|
// Vector element: []
|
|
|
|
// Condition operator: ?:
|
|
|
|
// Invert (prefix '-'): I
|
|
|
|
// Constant value: C
|
|
|
|
// Create Range: R
|
|
|
|
// Create Vector: V
|
|
|
|
// Create Matrix: M
|
|
|
|
// Lookup Variable: L
|
|
|
|
// Lookup member per name: N
|
|
|
|
// Function call: F
|
2011-09-03 08:10:36 +04:00
|
|
|
std::string type;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
|
|
|
Expression();
|
2012-03-28 02:05:00 +04:00
|
|
|
Expression(const Value &val);
|
2013-04-27 02:32:19 +04:00
|
|
|
Expression(const std::string &type, Expression *left, Expression *right);
|
|
|
|
Expression(const std::string &type, Expression *expr);
|
2010-01-30 07:26:05 +03:00
|
|
|
~Expression();
|
|
|
|
|
|
|
|
Value evaluate(const class Context *context) const;
|
2010-11-08 00:29:34 +03:00
|
|
|
std::string toString() const;
|
2010-01-30 07:26:05 +03:00
|
|
|
};
|
|
|
|
|
2010-11-08 00:29:34 +03:00
|
|
|
std::ostream &operator<<(std::ostream &stream, const Expression &expr);
|
|
|
|
|
2010-01-30 07:26:05 +03:00
|
|
|
#endif
|