Zigbee Protocol Controller 1.6.0
ast::reducer Class Reference

AST reducer. More...

#include <attribute_mapper_ast_reducer.hpp>

Public Member Functions

 reducer ()
 
operand operator() (const nil &x) const
 
operand operator() (uint32_t n) const
 
operand operator() (float n) const
 
operand operator() (const attribute &a) const
 
operand operator() (const signed_ &x) const
 
operand operator() (const condition &x) const
 
operand operator() (const function_invokation &f) const
 
operand operator() (const expression &x) const
 
operation reduce_operation (const operation &x) const
 This function reduces an operation. More...
 
expression reduce_expression (const expression &x) const
 Reduce an expression. More...
 
assignment operator() (const assignment &x) const
 
scope operator() (const scope &x) const
 
ast_tree operator() (const ast_tree &ast) const
 

Private Attributes

eval< result_type_tevaluator
 

Detailed Description

AST reducer.

This class is an ast evaluator which outputs a copy of the ast in reduced form.

The ast reducer works by going though the ast and try evaluate operands with a normal value evaluator which has an undefined context. This means that the evaluator will only succeed if the operand is a constant, ie does not depend on an attribute.

As the other evaluators this evaluator operates on a functor which uses pattern matchin to evaluate the boost::variant ast components using the boost::apply_visitor.

Constructor & Destructor Documentation

◆ reducer()

ast::reducer::reducer ( )
inline

Member Function Documentation

◆ operator()() [1/11]

assignment ast::reducer::operator() ( const assignment x) const
inline

◆ operator()() [2/11]

ast_tree ast::reducer::operator() ( const ast_tree ast) const
inline

◆ operator()() [3/11]

operand ast::reducer::operator() ( const attribute a) const
inline

◆ operator()() [4/11]

operand ast::reducer::operator() ( const condition x) const
inline

◆ operator()() [5/11]

operand ast::reducer::operator() ( const expression x) const
inline

◆ operator()() [6/11]

operand ast::reducer::operator() ( const function_invokation f) const
inline

◆ operator()() [7/11]

operand ast::reducer::operator() ( const nil x) const
inline

◆ operator()() [8/11]

scope ast::reducer::operator() ( const scope x) const
inline

◆ operator()() [9/11]

operand ast::reducer::operator() ( const signed_ x) const
inline

◆ operator()() [10/11]

operand ast::reducer::operator() ( float  n) const
inline

◆ operator()() [11/11]

operand ast::reducer::operator() ( uint32_t  n) const
inline

◆ reduce_expression()

expression ast::reducer::reduce_expression ( const expression x) const
inline

Reduce an expression.

This is the main entrypoint of reducer. An expession is also a operand though the pattern "( <expression> )". So this reducer is accessed though the operator()(const expression &x).

Parameters
xinput expression
Returns
reduced expression

◆ reduce_operation()

operation ast::reducer::reduce_operation ( const operation x) const
inline

This function reduces an operation.

this is not one of the boost::variant operators since the operation data type is not an operand

Parameters
xinput operation
Returns
reduced operation

Member Data Documentation

◆ evaluator

eval<result_type_t> ast::reducer::evaluator
private

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