35namespace func_sketch::parser {
48 const math::MathFunctionList& math_function_list,
49 const math::ConstantList& constant_list,
50 expressions::ExpressionMemoryPool& pool);
65 parsed_expression.
value);
81 if (parsed_expression.
name ==
"x") {
84 const auto constant = constant_list.
get(parsed_expression.
name);
89 "Unknown identifier: " + parsed_expression.
name);
112 std::vector<expressions::Expression*> arguments;
113 arguments.reserve(parsed_expression.
arguments.size());
114 for (
const auto& argument : parsed_expression.
arguments) {
116 argument, math_function_list, constant_list, pool));
119 std::move(arguments), std::move(*function));
129 const std::string& operator_str) {
130 if (operator_str ==
"+") {
133 if (operator_str ==
"-") {
155 parsed_expression.
operand, math_function_list, constant_list, pool),
166 const std::string& operator_str) {
167 if (operator_str ==
"+") {
170 if (operator_str ==
"-") {
173 if (operator_str ==
"*") {
176 if (operator_str ==
"/") {
179 if (operator_str ==
"**") {
183 "Unknown binary operator: " + operator_str);
202 constant_list, pool),
204 constant_list, pool),
213 return boost::apply_visitor(
214 [&pool, &math_function_list, &constant_list](
217 concrete_expression, math_function_list, constant_list, pool);
226 auto pool = std::make_unique<expressions::ExpressionMemoryPool>();
228 parsed_expression, math_function_list, constant_list, *pool);
Definition of BinaryExpression structure.
Definition of BinaryOperator class.
Definition of binary operators.
Class of exceptions of invalid expressions.
Class of memory pools for expressions.
Expression * create(Args &&... args)
Create an expression.
Class of pointers to expressions with RAII.
Class of addition operator.
Class of binary operators.
Class of lists of constants.
std::optional< Number > get(const std::string &name) const
Get a constant from the list.
Class of division operator.
Class of lists of mathematical functions.
std::optional< MathFunction > get(const std::string &name) const
Get a mathematical function from the list.
Class of multiplication operator.
Class of subtraction operator.
Class of unary minus operator.
Class of unary operators.
Class of unary plus operator.
Definition of ConstantExpression structure.
math::UnaryOperator get_unary_operator(const std::string &operator_str)
Get a unary operator by name.
math::BinaryOperator get_binary_operator(const std::string &operator_str)
Get a binary operator by name.
Declaration of convert_expression function.
expressions::ExpressionPtr convert_expression(const ParsedExpression &parsed_expression, const math::MathFunctionList &math_function_list, const math::ConstantList &constant_list)
Convert parsed expression.
Definition of exception classes.
Definition of Expression class.
Definition of ExpressionMemoryPool class.
Definition of MathFunctionList class.
Definition of ParameterExpression structure.
Definition of ParsedExpression structure.
boost::variant< ParsedLiteral, ParsedIdentifier, boost::recursive_wrapper< ParsedFunctionCallExpression >, boost::recursive_wrapper< ParsedUnaryExpression >, boost::recursive_wrapper< ParsedBinaryExpression > > ParsedExpression
Variant of parsed expressions.
Struct of binary expressions.
Struct of constant expressions.
Struct of function call expressions.
Struct of parameter expressions.
Struct of unary expressions.
Struct of parsed binary expressions.
ParsedExpression left_operand
Left operand.
std::string operator_str
Operator.
ParsedExpression right_operand
Right operand.
Struct of parsed function call expressions.
ParsedIdentifier function_name
Function name.
std::vector< ParsedExpression > arguments
Arguments.
Struct of parsed identifiers.
Struct of parsed literals.
Struct of parsed unary expressions.
std::string operator_str
Operator.
ParsedExpression operand
Operand.
Definition of UnaryExpression structure.
Definition of unary operators.