7#include "skeleton_node.hpp"
14 bool has_else =
false;
15 statement_vector children;
16 statement_vector else_children;
25 append_child(else_children,
std::move(x));
41 void post_process(formula_post_process_context &context)
override {
42 if (std::ssize(children) > 0) {
43 children.back()->left_align();
45 if (std::ssize(else_children) > 0) {
46 else_children.back()->left_align();
49 post_process_expression(context, *name_expression, location);
50 post_process_expression(context, *list_expression, location);
52 for (ttlet &child: children) {
53 child->post_process(context);
55 for (ttlet &child: else_children) {
56 child->post_process(context);
61 auto list_data = evaluate_formula_without_output(context, *list_expression, location);
63 if (!list_data.is_vector()) {
64 tt_error_info().set<
"parse_location">(location);
65 throw operation_error(
"Expecting expression returns a vector, got {}", list_data);
69 if (list_data.size() > 0) {
70 ttlet loop_size = std::ssize(list_data);
72 for (
auto i = list_data.vector_begin(); i != list_data.vector_end(); ++i) {
75 name_expression->assign_without_output(context, item);
78 auto error_location = location;
79 if (ttlet expression_location = error_info::peek<parse_location, "parse_location">()) {
80 error_location += *expression_location;
86 context.loop_push(loop_count++, loop_size);
87 auto tmp = evaluate_children(context, children);
92 }
else if (tmp.is_continue()) {
94 }
else if (!tmp.is_undefined()) {
101 auto tmp = evaluate_children(context, else_children);
102 if (tmp.is_break() || tmp.is_continue()) {
104 }
else if (!tmp.is_undefined()) {
114 s += to_string(*name_expression);
116 s += to_string(*list_expression);
Error information passed alongside an error code or exception.
Definition error_info.hpp:81
error_info & set(Arg &&value) noexcept
Set an information for a given tag.
Definition error_info.hpp:144
Exception thrown during execution of a dynamic operation.
Definition exception.hpp:37
Definition formula_evaluation_context.hpp:16
void set_output_size(ssize_t new_size) noexcept
Set the size of the output.
Definition formula_evaluation_context.hpp:67
ssize_t output_size() const noexcept
Get the size of the output.
Definition formula_evaluation_context.hpp:60
Definition parse_location.hpp:16
Definition skeleton_for_node.hpp:11
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_for_node.hpp:23
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_for_node.hpp:60
Definition skeleton_node.hpp:16