#ifndef PARSEREXPRESSION_BUILDER_HPP #define PARSEREXPRESSION_BUILDER_HPP #include #include #include "Interpreter/BinaryExpressionNode.hpp" #include "Interpreter/ExpressionNode.hpp" #include "Interpreter/IdentifierExpressionNode.hpp" #include "Interpreter/LiteralExpressionNode.hpp" #include "Interpreter/UnaryExpressionNode.hpp" // <-- új include #include "Parser/ParsedExpression.hpp" namespace Parser { static std::unique_ptr buildExpressionFromParsed( const Parser::ParsedExpressionPtr & expr) { using Kind = Parser::ParsedExpression::Kind; switch (expr->kind) { case Kind::Literal: return std::make_unique(expr->value); case Kind::Variable: return std::make_unique(expr->name); case Kind::Binary: { auto lhs = buildExpressionFromParsed(expr->lhs); auto rhs = buildExpressionFromParsed(expr->rhs); return std::make_unique(std::move(lhs), expr->op, std::move(rhs)); } case Kind::Unary: { auto operand = buildExpressionFromParsed(expr->rhs); // rhs az operandus return std::make_unique(expr->op, std::move(operand)); } } throw std::runtime_error("Unknown ParsedExpression kind"); } } // namespace Parser #endif // PARSEREXPRESSION_BUILDER_HPP