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"
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_)) {
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
Inform & endl(Inform &inf)
std::map< std::string, client::function::type > functionDictionary_t
std::map< std::string, double > variableDictionary_t
Representation objects and parsers for attribute expressions.
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
Expression Expr_t
type of an expression
OperatorType_t
distinguish different constraints
boost::tuple< double, bool > Result_t
std::pair< std::string, Expressions::Expr_t * > SingleNamed_t
std::set< std::string > vars_
std::set< std::string > funcs_
functionDictionary_t known_expr_funcs_
std::string toString() const
Expressions::OperatorType_t type_
client::ast::expression ast_
std::string::const_iterator iterator_type
void determineConstrOperator()
Expressions::OperatorType_t getOpType() const
get operator type present (if expression is constraint)
std::set< std::string > getReqFuncs() const
functionDictionary_t getRegFuncs() const
Expression(std::string expr)
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 > getReqVars() const
void registerVariables(std::map< std::string, double > variableDictionary)
void registerFunctions(std::map< std::string, client::function::type > functions)
std::set< std::string > variables()
std::set< std::string > functions()