OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
matheval::detail::expr_ast< real_t > Struct Template Reference

Abstract Syntax Tree. More...

#include <matheval.hpp>

Collaboration diagram for matheval::detail::expr_ast< real_t >:
Collaboration graph

Public Types

using tree_t = std::variant< nil, real_t, std::string, recursive_wrapper< expr_ast< real_t > >, recursive_wrapper< binary_op< real_t > >, recursive_wrapper< unary_op< real_t > > >
 

Public Member Functions

 expr_ast ()
 Default constructor.
 
template<typename Expr >
 expr_ast (Expr other)
 Copy constructor.
 
expr_astoperator+= (expr_ast const &rhs)
 Add a tree.
 
expr_astoperator-= (expr_ast const &rhs)
 subtract a tree
 
expr_astoperator*= (expr_ast const &rhs)
 Multiply by a tree.
 
expr_astoperator/= (expr_ast const &rhs)
 Divide by a tree.
 

Public Attributes

tree_t tree
 AST storage.
 

Detailed Description

template<typename real_t>
struct matheval::detail::expr_ast< real_t >

Abstract Syntax Tree.

Stores the abstract syntax tree (AST) of the parsed mathematical expression.

Definition at line 132 of file matheval.hpp.

Member Typedef Documentation

◆ tree_t

template<typename real_t >
using matheval::detail::expr_ast< real_t >::tree_t = std::variant< nil , real_t, std::string, recursive_wrapper<expr_ast<real_t> >, recursive_wrapper<binary_op<real_t> >, recursive_wrapper<unary_op<real_t> >>

Definition at line 133 of file matheval.hpp.

Constructor & Destructor Documentation

◆ expr_ast() [1/2]

template<typename real_t >
matheval::detail::expr_ast< real_t >::expr_ast ( )
inline

Default constructor.

Initializes the tree to a nil value to indicate inconsistent state.

Definition at line 154 of file matheval.hpp.

◆ expr_ast() [2/2]

template<typename real_t >
template<typename Expr >
matheval::detail::expr_ast< real_t >::expr_ast ( Expr  other)
inline

Copy constructor.

Deep copies the syntax tree.

Definition at line 161 of file matheval.hpp.

Member Function Documentation

◆ operator*=()

template<typename real_t >
expr_ast< real_t > & matheval::detail::expr_ast< real_t >::operator*= ( expr_ast< real_t > const &  rhs)

Multiply by a tree.

Definition at line 253 of file matheval.hpp.

References matheval::detail::unary_op< real_t >::rhs.

◆ operator+=()

template<typename real_t >
expr_ast< real_t > & matheval::detail::expr_ast< real_t >::operator+= ( expr_ast< real_t > const &  rhs)

Add a tree.

Definition at line 243 of file matheval.hpp.

References matheval::detail::unary_op< real_t >::rhs.

◆ operator-=()

template<typename real_t >
expr_ast< real_t > & matheval::detail::expr_ast< real_t >::operator-= ( expr_ast< real_t > const &  rhs)

subtract a tree

Definition at line 248 of file matheval.hpp.

References matheval::detail::unary_op< real_t >::rhs.

◆ operator/=()

template<typename real_t >
expr_ast< real_t > & matheval::detail::expr_ast< real_t >::operator/= ( expr_ast< real_t > const &  rhs)

Divide by a tree.

Definition at line 258 of file matheval.hpp.

References matheval::detail::unary_op< real_t >::rhs.

Member Data Documentation

◆ tree

template<typename real_t >
tree_t matheval::detail::expr_ast< real_t >::tree

AST storage.

The syntax tree can hold various types. Numbers (real_t), variables (std::string), the recursive tree itself (expr_ast), binary operators (binary_op), and unary operators (unary_op).

Definition at line 147 of file matheval.hpp.

Referenced by matheval::detail::eval_ast< real_t >::operator()(), matheval::detail::ConstantFolder< real_t >::operator()(), and matheval::Parser< real_t >::optimize().


The documentation for this struct was generated from the following file: