OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Public Types | Public Member Functions | Private Attributes | List of all members
matheval::detail::eval_ast< real_t > Class Template Reference

Evaluate the Abstract Syntax Tree. More...

#include <matheval.hpp>

Public Types

using result_type = real_t
 Necessary typedef for boost::apply_visitor More...
 
using symbol_table_t = std::map< std::string, result_type >
 Type of the symbol table. More...
 

Public Member Functions

 eval_ast (symbol_table_t sym)
 Constructor. More...
 
result_type operator() (nil) const
 Empty nodes in the tree evaluate to 0. More...
 
result_type operator() (result_type n) const
 Numbers evaluate to themselves. More...
 
result_type operator() (std::string const &c) const
 Variables evaluate to their value in the symbol table. More...
 
result_type operator() (expr_ast< real_t > const &ast) const
 Recursively evaluate the AST. More...
 
result_type operator() (binary_op< real_t > const &tree) const
 Evaluate a binary operator and optionally recurse its operands. More...
 
result_type operator() (unary_op< real_t > const &tree) const
 Evaluate a unary operator and optionally recurse its operand. More...
 

Private Attributes

symbol_table_t st
 

Detailed Description

template<typename real_t>
class matheval::detail::eval_ast< real_t >

Evaluate the Abstract Syntax Tree.

This visits all the variants of the AST and applies the stored operators.

Definition at line 208 of file matheval.hpp.

Member Typedef Documentation

◆ result_type

template<typename real_t >
using matheval::detail::eval_ast< real_t >::result_type = real_t

Necessary typedef for boost::apply_visitor

Definition at line 212 of file matheval.hpp.

◆ symbol_table_t

template<typename real_t >
using matheval::detail::eval_ast< real_t >::symbol_table_t = std::map<std::string, result_type>

Type of the symbol table.

Definition at line 215 of file matheval.hpp.

Constructor & Destructor Documentation

◆ eval_ast()

template<typename real_t >
matheval::detail::eval_ast< real_t >::eval_ast ( symbol_table_t  sym)
inlineexplicit

Constructor.

Saves the symbol table to apply variables.

Definition at line 221 of file matheval.hpp.

Member Function Documentation

◆ operator()() [1/6]

template<typename real_t >
result_type matheval::detail::eval_ast< real_t >::operator() ( binary_op< real_t > const &  tree) const
inline

Evaluate a binary operator and optionally recurse its operands.

Definition at line 246 of file matheval.hpp.

◆ operator()() [2/6]

template<typename real_t >
result_type matheval::detail::eval_ast< real_t >::operator() ( expr_ast< real_t > const &  ast) const
inline

Recursively evaluate the AST.

Definition at line 240 of file matheval.hpp.

References matheval::detail::expr_ast< real_t >::tree.

◆ operator()() [3/6]

template<typename real_t >
result_type matheval::detail::eval_ast< real_t >::operator() ( nil  ) const
inline

Empty nodes in the tree evaluate to 0.

Definition at line 224 of file matheval.hpp.

◆ operator()() [4/6]

template<typename real_t >
result_type matheval::detail::eval_ast< real_t >::operator() ( result_type  n) const
inline

Numbers evaluate to themselves.

Definition at line 227 of file matheval.hpp.

References Hypervolume::n.

◆ operator()() [5/6]

template<typename real_t >
result_type matheval::detail::eval_ast< real_t >::operator() ( std::string const &  c) const
inline

Variables evaluate to their value in the symbol table.

Definition at line 230 of file matheval.hpp.

References Physics::c, and matheval::detail::eval_ast< real_t >::st.

◆ operator()() [6/6]

template<typename real_t >
result_type matheval::detail::eval_ast< real_t >::operator() ( unary_op< real_t > const &  tree) const
inline

Evaluate a unary operator and optionally recurse its operand.

Definition at line 255 of file matheval.hpp.

Member Data Documentation

◆ st

template<typename real_t >
symbol_table_t matheval::detail::eval_ast< real_t >::st
private

Definition at line 263 of file matheval.hpp.

Referenced by matheval::detail::eval_ast< real_t >::operator()().


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