36#include <boost/config/warning_disable.hpp>
37#include <boost/variant/recursive_variant.hpp>
38#include <boost/fusion/include/adapt_struct.hpp>
39#include <boost/fusion/include/io.hpp>
40#include <boost/optional.hpp>
156 typedef boost::variant<
160 , boost::recursive_wrapper<function>
161 , boost::recursive_wrapper<power>
162 , boost::recursive_wrapper<unary>
163 , boost::recursive_wrapper<expression>
249 boost::optional<expression>
rhs;
257 typedef boost::variant<
275 inline std::ostream&
operator<<(std::ostream& out,
nil) { out << std::string(
"nil");
return out; }
286BOOST_FUSION_ADAPT_STRUCT(
292BOOST_FUSION_ADAPT_STRUCT(
298BOOST_FUSION_ADAPT_STRUCT(
301 (std::list<mupp::ast::operation>, rest)
304BOOST_FUSION_ADAPT_STRUCT(
310BOOST_FUSION_ADAPT_STRUCT(
316BOOST_FUSION_ADAPT_STRUCT(
319 (boost::optional<mupp::ast::expression>, rhs)
322BOOST_FUSION_ADAPT_STRUCT(
std::list< statement > statement_list
Type alias for a list of statements forming a program.
optoken
Enumeration of arithmetic and unary operators.
@ op_minus
Subtraction operator (-)
@ op_positive
Unary plus operator (+x)
@ op_divide
Division operator (/)
@ op_plus
Addition operator (+)
@ op_times
Multiplication operator (*)
@ op_negative
Unary minus operator (-x)
boost::variant< variable_declaration, assignment > statement
Variant type representing a single statement.
boost::variant< nil, double, variable, boost::recursive_wrapper< function >, boost::recursive_wrapper< power >, boost::recursive_wrapper< unary >, boost::recursive_wrapper< expression > > operand
Variant type representing any operand in an expression.
funid
Enumeration of supported mathematical functions.
@ fun_sqrt
Square root function.
@ fun_atan
Arctangent function.
@ fun_acos
Arccosine function.
@ fun_exp
Exponential function.
@ fun_min
Minimum value function.
@ fun_cos
Cosine function.
@ fun_cosh
Hyperbolic cosine function.
@ fun_max
Maximum value function.
@ fun_ln
Natural logarithm function.
@ fun_log
Base-10 logarithm function.
@ fun_tanh
Hyperbolic tangent function.
@ fun_asin
Arcsine function.
@ fun_sinh
Hyperbolic sine function.
@ fun_tan
Tangent function.
@ fun_abs
Absolute value function.
std::ostream & operator<<(std::ostream &out, nil)
Stream output operator for nil nodes (debugging support).
Represents an assignment statement.
variable lhs
The left-hand side variable being assigned to.
expression rhs
The right-hand side expression to evaluate.
Represents a complete expression with operator precedence.
operand first
The first operand in the expression.
std::list< operation > rest
Sequence of operations applied left-to-right.
Represents a function call with a single argument.
expression arg
The argument expression.
funid func_id
The function identifier.
Represents an empty/null AST node.
Represents a binary operation with an operator and right operand.
optoken operator_
The binary operator (+, -, *, /)
operand operand_
The right-hand operand.
Represents a power operation.
expression base
The base expression.
expression pow
The exponent expression.
Abstract Syntax Tree (AST) definitions for the variable parser.
int id
ID used as key to map to iterator position in source code (not part of the logical AST structure)
Represents a unary operation applied to an operand.
operand operand_
The operand the operator is applied to.
optoken operator_
The unary operator (positive or negative)
Represents a variable declaration with optional initialization.
variable lhs
The variable being declared.
boost::optional< expression > rhs
Optional initialization expression.
Represents a variable in an expression.
std::string name
Variable name without the '$' prefix.
variable(std::string const &name="")
Constructor for variable node.