14#ifndef ATTRIBUTE_MAPPER_BUILT_IN_FUNCTIONS_HPP
15#define ATTRIBUTE_MAPPER_BUILT_IN_FUNCTIONS_HPP
19#include <boost/optional.hpp>
34 = std::map<std::string, built_in_function<T>>;
68 result |= boost::apply_visitor(*
this, path_element);
76 result |= boost::apply_visitor(*
this, subscript.
identifier);
77 result |= boost::apply_visitor(*
this, subscript.
index);
83 return boost::apply_visitor(*
this,
operand);
88 return boost::apply_visitor(*
this, x.
operand_);
94 result |= boost::apply_visitor(*
this, x.
cond_value);
95 result |= boost::apply_visitor(*
this, x.
cond_true);
96 result |= boost::apply_visitor(*
this, x.
cond_false);
102 return boost::apply_visitor(*
this, x.
operand_);
107 bool result = boost::apply_visitor(*
this, x.
first);
108 for (
const auto &terms: x.
rest) {
109 result |= (*this)(terms);
117 bool result = (*this)(a.
rhs);
123 const auto &functions = get_built_in_functions<float>();
125 sl_log_error(
"attribute_mapper_built_in_function_name_check",
126 "Unknown function (%s) found in AST tree",
133 if (
true == (*
this)(argument)) {
145 result |= (*this)(a);
153 for (
const auto &ast_element:
ast) {
154 result |= boost::apply_visitor(*
this, ast_element);
Class that evaluates if we have unknown functions in the AST.
Definition: attribute_mapper_built_in_functions.hpp:47
bool operator()(const signed_ &x) const
Definition: attribute_mapper_built_in_functions.hpp:86
bool operator()(const operation &x) const
Definition: attribute_mapper_built_in_functions.hpp:100
bool operator()(const function_invokation &f) const
Definition: attribute_mapper_built_in_functions.hpp:121
bool operator()(const scope &x) const
Definition: attribute_mapper_built_in_functions.hpp:141
bool operator()(const operand &operand) const
Definition: attribute_mapper_built_in_functions.hpp:81
bool operator()(const nil) const
Definition: attribute_mapper_built_in_functions.hpp:49
bool operator()(unsigned int) const
Definition: attribute_mapper_built_in_functions.hpp:54
bool operator()(const assignment &a) const
Definition: attribute_mapper_built_in_functions.hpp:114
bool operator()(const expression &x) const
Definition: attribute_mapper_built_in_functions.hpp:105
bool operator()(const attribute_path_subscript &subscript) const
Definition: attribute_mapper_built_in_functions.hpp:73
bool operator()(const ast_tree &ast) const
Definition: attribute_mapper_built_in_functions.hpp:150
bool operator()(const condition &x) const
Definition: attribute_mapper_built_in_functions.hpp:91
bool operator()(const attribute &a) const
Definition: attribute_mapper_built_in_functions.hpp:64
bool operator()(float) const
Definition: attribute_mapper_built_in_functions.hpp:59
#define sl_log_error(tag, fmtstr,...)
Definition: sl_log.h:145
Definition: attribute_mapper_ast.hpp:39
const mapper_function_map< T > & get_built_in_functions()
Gets the map of built-in functions, containing names and pointers.
Definition: attribute_mapper_built_in_functions.cpp:254
std::function< eval_result_type< T >(std::vector< eval_result_type< T > > &)> built_in_function
Definition: attribute_mapper_built_in_functions.hpp:32
x3::variant< ast::nil, uint32_t, float, x3::forward_ast< attribute >, x3::forward_ast< signed_ >, x3::forward_ast< expression >, x3::forward_ast< condition >, x3::forward_ast< function_invokation > > operand
Operands.
Definition: attribute_mapper_ast.hpp:95
boost::optional< T > eval_result_type
Definition: attribute_mapper_built_in_functions.hpp:30
std::map< std::string, built_in_function< T > > mapper_function_map
Definition: attribute_mapper_built_in_functions.hpp:34
Assignment.
Definition: attribute_mapper_ast.hpp:193
expression rhs
right hand side of the assignment
Definition: attribute_mapper_ast.hpp:200
Definition: attribute_mapper_ast.hpp:53
Attribute path subscript.
Definition: attribute_mapper_ast.hpp:160
operand identifier
Definition: attribute_mapper_ast.hpp:161
operand index
Definition: attribute_mapper_ast.hpp:162
Attribute.
Definition: attribute_mapper_ast.hpp:177
std::vector< attribute_path_element > attribute_path
Definition: attribute_mapper_ast.hpp:179
Condition.
Definition: attribute_mapper_ast.hpp:147
operand cond_true
Truth value.
Definition: attribute_mapper_ast.hpp:149
operand cond_false
False value.
Definition: attribute_mapper_ast.hpp:150
operand cond_value
Selector value.
Definition: attribute_mapper_ast.hpp:148
Expression.
Definition: attribute_mapper_ast.hpp:134
operand first
Definition: attribute_mapper_ast.hpp:135
std::list< operation > rest
Definition: attribute_mapper_ast.hpp:136
Built-in function invokation Example : fn_min_value(r'3, 5, d'5 or 20)
Definition: attribute_mapper_ast.hpp:209
std::vector< expression > arguments
Definition: attribute_mapper_ast.hpp:211
std::string function_name
Definition: attribute_mapper_ast.hpp:210
Definition: attribute_mapper_ast.hpp:42
Operation An operation consists of an operator and an right hand side operand. When operations are ev...
Definition: attribute_mapper_ast.hpp:123
operand operand_
right hand side operand
Definition: attribute_mapper_ast.hpp:125
Scope.
Definition: attribute_mapper_ast.hpp:234
std::vector< assignment > assignments
Definition: attribute_mapper_ast.hpp:237
Uniary signed operand.
Definition: attribute_mapper_ast.hpp:111
operand operand_
Definition: attribute_mapper_ast.hpp:113