1 #ifndef STAN_LANG_AST_NODE_EXPRESSION_HPP 2 #define STAN_LANG_AST_NODE_EXPRESSION_HPP 3 4 #include <boost/variant/recursive_variant.hpp> 5 #include <ostream> 6 #include <string> 7 #include <vector> 8 #include <cstddef> 9 10 namespace stan { 11 namespace lang { 12 13 struct bare_expr_type; 14 struct nil; 15 struct int_literal; 16 struct double_literal; 17 struct array_expr; 18 struct matrix_expr; 19 struct row_vector_expr; 20 struct variable; 21 struct fun; 22 struct integrate_1d; 23 struct integrate_ode; 24 struct integrate_ode_control; 25 struct algebra_solver; 26 struct algebra_solver_control; 27 struct map_rect; 28 struct index_op; 29 struct index_op_sliced; 30 struct conditional_op; 31 struct binary_op; 32 struct unary_op; 33 34 struct expression { 35 typedef boost::variant<boost::recursive_wrapper<nil>, 36 boost::recursive_wrapper<int_literal>, 37 boost::recursive_wrapper<double_literal>, 38 boost::recursive_wrapper<array_expr>, 39 boost::recursive_wrapper<matrix_expr>, 40 boost::recursive_wrapper<row_vector_expr>, 41 boost::recursive_wrapper<variable>, 42 boost::recursive_wrapper<fun>, 43 boost::recursive_wrapper<integrate_1d>, 44 boost::recursive_wrapper<integrate_ode>, 45 boost::recursive_wrapper<integrate_ode_control>, 46 boost::recursive_wrapper<algebra_solver>, 47 boost::recursive_wrapper<algebra_solver_control>, 48 boost::recursive_wrapper<map_rect>, 49 boost::recursive_wrapper<index_op>, 50 boost::recursive_wrapper<index_op_sliced>, 51 boost::recursive_wrapper<conditional_op>, 52 boost::recursive_wrapper<binary_op>, 53 boost::recursive_wrapper<unary_op> > 54 expression_t; 55 56 expression(); 57 expression(const expression& e); 58 59 expression(const nil& expr); // NOLINT(runtime/explicit) 60 expression(const int_literal& expr); // NOLINT(runtime/explicit) 61 expression(const double_literal& expr); // NOLINT(runtime/explicit) 62 expression(const array_expr& expr); // NOLINT(runtime/explicit) 63 expression(const matrix_expr& expr); // NOLINT(runtime/explicit) 64 expression(const row_vector_expr& expr); // NOLINT(runtime/explicit) 65 expression(const variable& expr); // NOLINT(runtime/explicit) 66 expression(const fun& expr); // NOLINT(runtime/explicit) 67 expression(const integrate_1d& expr); // NOLINT(runtime/explicit) 68 expression(const integrate_ode& expr); // NOLINT(runtime/explicit) 69 expression(const integrate_ode_control& expr); // NOLINT 70 expression(const algebra_solver& expr); // NOLINT(runtime/explicit) 71 expression(const algebra_solver_control& expr); // NOLINT 72 expression(const map_rect& expr); // NOLINT 73 expression(const index_op& expr); // NOLINT(runtime/explicit) 74 expression(const index_op_sliced& expr); // NOLINT(runtime/explicit) 75 expression(const conditional_op& expr); // NOLINT(runtime/explicit) 76 expression(const binary_op& expr); // NOLINT(runtime/explicit) 77 expression(const unary_op& expr); // NOLINT(runtime/explicit) 78 expression(const expression_t& expr_); // NOLINT(runtime/explicit) 79 80 bare_expr_type bare_type() const; 81 int total_dims() const; 82 std::string to_string() const; 83 84 expression& operator+=(const expression& rhs); 85 expression& operator-=(const expression& rhs); 86 expression& operator*=(const expression& rhs); 87 expression& operator/=(const expression& rhs); 88 89 expression_t expr_; 90 }; 91 92 } 93 } 94 #endif 95