30#ifndef __EXPRESSION_H__
31#define __EXPRESSION_H__
49#include <boost/function.hpp>
50#include <boost/lexical_cast.hpp>
51#include "boost/algorithm/string.hpp"
73 typedef std::map<std::string, Expressions::Expr_t*>
Named_t;
143 if (evaluator(
ast_)) {
144 result = evaluator.
result();
148 return std::make_tuple(result, valid);
167 std::string_view op(
expr_);
169 constexpr std::pair<std::string_view, Expressions::OperatorType_t> op_map[] = {
178 for (
const auto& p : op_map) {
179 if (op.find(p.first) != std::string_view::npos) {
195 bool success = phrase_parse(iter,
end, expression, skipper,
ast_);
197 if (!success || iter !=
end) {
198 std::cout <<
"Parsing failed!" << std::endl;
199 std::string here = (iter !=
end ? std::string(iter,
end):
expr_);
201 "Parsing failed here: " + here +
"!");
206 if (requirements(
ast_)) {
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
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
std::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_
Expressions::OperatorType_t type_
client::ast::expression ast_
std::string::const_iterator iterator_type
const std::set< std::string > & getReqFuncs() const
void determineConstrOperator()
Expressions::OperatorType_t getOpType() const
get operator type present (if expression is constraint)
functionDictionary_t getRegFuncs() const
const std::string & toString() const
Expressions::Result_t evaluate(const variableDictionary_t &vars)
evaluate an expression given a value dictionary of free variables
Expression(std::string expr)
Expression(std::string expr, functionDictionary_t known_expr_funcs)
const 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()