/** * @file mix_cc/matheval/ast.hpp * @brief 抽象语法树 * @author Cat (null.null.null@qq.com) * @version 0.1 * @date 2021-09-17 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #ifndef MATHEVAL_IMPLEMENTATION #error "Do not include ast.hpp directly!" #endif #pragma once #include #include #include #include namespace mix_cc { namespace matheval { namespace x3 = boost::spirit::x3; namespace ast { struct nil {}; struct unary_op; struct binary_op; struct expression; // clang-format off struct operand : x3::variant< nil , double , std::string , x3::forward_ast , x3::forward_ast , x3::forward_ast > { using base_type::base_type; using base_type::operator=; }; // clang-format on struct unary_op { double (*op)(double); operand rhs; }; struct binary_op { double (*op)(double, double); operand lhs; operand rhs; }; struct operation { double (*op)(double, double); operand rhs; }; struct expression { operand lhs; std::list rhs; }; } // namespace ast } // namespace matheval } // namespace mix_cc