30 #ifndef __EXPRESSION_H__
31 #define __EXPRESSION_H__
46 #include <boost/function.hpp>
47 #include <boost/lexical_cast.hpp>
48 #include <boost/variant/get.hpp>
49 #include <boost/variant/variant.hpp>
50 #include "boost/smart_ptr.hpp"
51 #include "boost/tuple/tuple.hpp"
52 #include "boost/algorithm/string.hpp"
60 namespace Expressions {
74 typedef std::map<std::string, Expressions::Expr_t*>
Named_t;
144 if (evaluator(
ast_)) {
145 result = evaluator.
result();
149 return boost::make_tuple(result, valid);
168 std::string op =
expr_;
170 if(boost::find_first(op,
"=="))
172 else if(boost::find_first(op,
"!="))
174 else if(boost::find_first(op,
"<="))
176 else if(boost::find_first(op,
"<"))
178 else if(boost::find_first(op,
">="))
180 else if(boost::find_first(op,
">"))
196 bool success = phrase_parse(iter, end, expression, skipper,
ast_);
198 if (!success || iter != end) {
199 std::cout <<
"Parsing failed!" <<
std::endl;
200 std::string here = (iter != end ? std::string(iter, end):
expr_);
202 "Parsing failed here: " + here +
"!");
207 if (requirements(
ast_)) {
Expression Expr_t
type of an expression
Expression(std::string expr, functionDictionary_t known_expr_funcs)
Expression(std::string expr)
Expressions::Result_t evaluate(variableDictionary_t vars)
evaluate an expression given a value dictionary of free variables
std::set< std::string > functions()
std::set< std::string > vars_
std::set< std::string > funcs_
client::ast::expression ast_
std::map< std::string, double > variableDictionary_t
Inform & endl(Inform &inf)
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
std::string toString() const
std::set< std::string > getReqVars() const
void determineConstrOperator()
functionDictionary_t known_expr_funcs_
void registerFunctions(std::map< std::string, client::function::type > functions)
std::map< std::string, client::function::type > functionDictionary_t
void registerVariables(std::map< std::string, double > variableDictionary)
OperatorType_t
distinguish different constraints
functionDictionary_t getRegFuncs() const
Expressions::OperatorType_t getOpType() const
get operator type present (if expression is constraint)
std::set< std::string > variables()
std::string::const_iterator iterator_type
std::set< std::string > getReqFuncs() const
boost::tuple< double, bool > Result_t
std::pair< std::string, Expressions::Expr_t * > SingleNamed_t
Expressions::OperatorType_t type_