Zigbee Protocol Controller 1.6.0
|
AST evaluator. More...
#include <attribute_mapper_ast_eval.hpp>
Public Types | |
using | result_type = boost::optional< T > |
Public Member Functions | |
eval (const attribute_store::attribute context=0) | |
Construct a new eval object. More... | |
result_type | operator() (const nil &) const |
the undefined keyword More... | |
result_type | operator() (const uint32_t n) const |
a literal number More... | |
result_type | operator() (const float n) const |
a literal number More... | |
result_type | operator() (const operation &x, result_type lhs) const |
An operation. More... | |
result_type | operator() (const signed_ &x) const |
Unary operation. More... | |
result_type | operator() (const expression &x) const |
Condition. More... | |
result_type | operator() (const condition &x) const |
The normal entry point of the evaluator. More... | |
result_type | operator() (const attribute &a) const |
an attribute read from the attribute store More... | |
result_type | operator() (const function_invokation &f) const |
Evaluates Function invokation. More... | |
Private Attributes | |
attribute_store::attribute | context |
AST evaluator.
This evaluator walks though the AST. Usually the evaluator is use to evaluate a toplevel expression, but this can also be applied to other AST nodes.
The evaluation is done in a context such that all attribute paths will be evaluated relative to the context (a common parent node in the attribute store).
The AST evaluator returns a std::optional, because evaluation is not always possible if the the needed attribute are not found within the context.
If the evaluation context is an invalid attribute all evaluations involving an attribute will return no value.
The AST evaluators are implemented as a functor (a function object). This because this allows us to use the boost::apply_visitor, which is able to evaluate the boost::variant objects using functors, through the operator() overloading. The use of the boost::apply_visitor is boost::apply_visitor( functor, variant ), this will call the appropiate operator() overloading for the data type in the variant. See https://www.boost.org/doc/libs/1_76_0/doc/html/boost/apply_visitor.html for details.
using ast::eval< T >::result_type = boost::optional<T> |
|
inlineexplicit |
Construct a new eval object.
context | Context in which this evaluator should work. |
|
inline |
an attribute read from the attribute store
|
inline |
The normal entry point of the evaluator.
|
inline |
Condition.
for if statements
|
inline |
a literal number
|
inline |
Evaluates Function invokation.
|
inline |
the undefined keyword
|
inline |
An operation.
An operation which should be applied to the current result, can be any operation +,-,*,/,&,| etc.
x | The operation |
lhs | Left hand side of the operation |
|
inline |
Unary operation.
|
inline |
a literal number
|
private |