24#include <fmt/format.h>
25#include <fmt/ranges.h>
30auto fmt::formatter<func_sketch::parser::ParsedLiteral>::format(
32 format_context& context)
const -> format_context::iterator {
34 [&context](
const auto& actual_value) {
35 using ValueType = std::decay_t<
decltype(actual_value)>;
36 if constexpr (std::is_same_v<ValueType, func_sketch::Complex>) {
37 return fmt::format_to(context.out(),
"Literal({} + {}i)",
38 actual_value.real(), actual_value.imag());
39 }
else if constexpr (std::is_same_v<ValueType, func_sketch::Real>) {
42 return fmt::format_to(
43 context.out(),
"Literal({:e})", actual_value);
45 return fmt::format_to(
46 context.out(),
"Literal({})", actual_value);
53auto fmt::formatter<func_sketch::parser::ParsedIdentifier>::format(
55 format_context& context)
const -> format_context::iterator {
56 return fmt::format_to(context.out(),
"Identifier({})", value.name);
60auto fmt::formatter<func_sketch::parser::ParsedExpression>::format(
62 format_context& context)
const -> format_context::iterator {
63 return boost::apply_visitor(
64 [&context](
const auto& concrete_value) {
65 return fmt::format_to(context.out(),
"{}", concrete_value);
71auto fmt::formatter<func_sketch::parser::ParsedFunctionCallExpression>::format(
73 format_context& context)
const -> format_context::iterator {
74 return fmt::format_to(context.out(),
"FunctionCall({}, {})",
75 value.function_name, fmt::join(value.arguments,
", "));
79auto fmt::formatter<func_sketch::parser::ParsedUnaryExpression>::format(
81 format_context& context)
const -> format_context::iterator {
82 return fmt::format_to(
83 context.out(),
"Unary({}, {})", value.operator_str, value.operand);
87auto fmt::formatter<func_sketch::parser::ParsedBinaryExpression>::format(
89 format_context& context)
const -> format_context::iterator {
90 return fmt::format_to(context.out(),
"Binary({}, {}, {})",
91 value.operator_str, value.left_operand, value.right_operand);
Definitions of common types.
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 parsed binary expressions.
Struct of parsed function call expressions.
Struct of parsed identifiers.
Struct of parsed literals.
Struct of parsed unary expressions.