1 #ifndef __EXPRESSION_H__
2 #define __EXPRESSION_H__
17 #include <boost/function.hpp>
18 #include <boost/lexical_cast.hpp>
19 #include <boost/variant/get.hpp>
20 #include <boost/variant/variant.hpp>
21 #include "boost/smart_ptr.hpp"
22 #include "boost/tuple/tuple.hpp"
23 #include "boost/algorithm/string.hpp"
31 namespace Expressions {
45 typedef std::map<std::string, Expressions::Expr_t*>
Named_t;
125 if (evaluator(
ast_)) {
126 result = evaluator.
result();
130 return boost::make_tuple(result, valid);
149 std::string op =
expr_;
151 if(boost::find_first(op,
"=="))
153 else if(boost::find_first(op,
"!="))
155 else if(boost::find_first(op,
"<="))
157 else if(boost::find_first(op,
"<"))
159 else if(boost::find_first(op,
">="))
161 else if(boost::find_first(op,
">"))
177 bool success = phrase_parse(iter, end, expression, skipper,
ast_);
179 if (!success || iter != end) {
180 std::cout <<
"Parsing failed!" <<
std::endl;
181 std::string here = (iter != end ? std::string(iter, end):
expr_);
183 "Parsing failed here: " + here +
"!");
188 if (requirements(
ast_)) {
std::set< std::string > getReqFuncs() const
std::pair< std::string, Expressions::Expr_t * > SingleNamed_t
std::string::const_iterator iterator_type
std::string toString() const
Expression(std::string expr)
std::set< std::string > functions()
Expression to be evaluated in the framework.
std::set< std::string > vars_
void determineConstrOperator()
functionDictionary_t known_expr_funcs_
boost::tuple< double, bool > Result_t
void registerFunctions(std::map< std::string, client::function::type > functions)
std::set< std::string > getReqVars() const
Expression Expr_t
type of an expression
Expressions::OperatorType_t type_
Expressions::OperatorType_t getOpType() const
get operator type present (if expression is constraint)
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
OperatorType_t
distinguish different constraints
Expressions::Result_t evaluate(variableDictionary_t vars)
evaluate an expression given a value dictionary of free variables
Expression(std::string expr, functionDictionary_t known_expr_funcs)
std::set< std::string > variables()
client::ast::expression ast_
functionDictionary_t getRegFuncs() const
std::set< std::string > funcs_
void registerVariables(std::map< std::string, double > variableDictionary)
std::map< std::string, double > variableDictionary_t
std::map< std::string, client::function::type > functionDictionary_t
Inform & endl(Inform &inf)