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

Evaluate the Abstract Syntax Tree. More...

#include <matheval.hpp>

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

Public Types

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

Public Member Functions

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

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 269 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 visitor.

Definition at line 272 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 275 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 281 of file matheval.hpp.

Member Function Documentation

◆ operator()() [1/9]

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 304 of file matheval.hpp.

References matheval::detail::binary_op< real_t >::lhs, matheval::detail::binary_op< real_t >::op, and matheval::detail::binary_op< real_t >::rhs.

◆ operator()() [2/9]

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 299 of file matheval.hpp.

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

◆ operator()() [3/9]

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 284 of file matheval.hpp.

◆ operator()() [4/9]

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

Handle recursive_wrapper for binary_op.

Definition at line 320 of file matheval.hpp.

◆ operator()() [5/9]

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

Handle recursive_wrapper for expr_ast.

Definition at line 315 of file matheval.hpp.

◆ operator()() [6/9]

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

Handle recursive_wrapper for unary_op.

Definition at line 325 of file matheval.hpp.

◆ operator()() [7/9]

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 287 of file matheval.hpp.

◆ operator()() [8/9]

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 290 of file matheval.hpp.

◆ operator()() [9/9]

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 310 of file matheval.hpp.

References matheval::detail::unary_op< real_t >::op, and matheval::detail::unary_op< real_t >::rhs.

Member Data Documentation

◆ st

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

Definition at line 330 of file matheval.hpp.


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