Calculator
Step 6
|
#include <node_impl.hpp>
Public Member Functions | |
node_impl () | |
virtual | ~node_impl () |
node_impl (node_impl &&)=default | |
node_impl & | operator= (node_impl &&)=default |
void | print (std::ostream &stream, int indent) const |
number | evaluate () const |
std::string | to_string () const |
identifier_list const & | get_parameters () const |
void | save (std::ostream &stream) const |
Static Public Member Functions | |
static std::shared_ptr< node_impl > | read_node (std::istream &stream) |
Private Member Functions | |
node_impl (node_impl const &)=delete | |
node_impl & | operator= (node_impl const &)=delete |
virtual void | print_node (std::ostream &stream, int indent) const =0 |
virtual number | evaluate_node () const =0 |
virtual std::string | evaluate_string () const |
virtual identifier_list const & | evaluate_parameters () const |
virtual void | save_node (std::ostream &stream) const =0 |
Base class for all parse tree nodes. The node classes all derive from node_impl. Each derived class overrides print_node(), for debugging and evalute_node() to evaluate the node. A few classes also override evaluate_string(), but most classes can inherit the node_impl::evaluate_string implementation, which prints the result of calling evaluate().
This class primarily manages the reference count.
Definition at line 20 of file node_impl.hpp.
node_impl::node_impl | ( | ) |
Definition at line 12 of file node_impl.cpp.
|
virtual |
Definition at line 15 of file node_impl.cpp.
|
default |
|
privatedelete |
number node_impl::evaluate | ( | ) | const |
Definition at line 24 of file node_impl.cpp.
References evaluate_node().
Referenced by evaluate_string().
|
privatepure virtual |
Implemented in node_divide, node_multiply, node_subtract, node_add, node_negate, node_binary, node_unary, node_function_call, node_function, node_identifier, node_number, and node_void.
Referenced by evaluate().
|
privatevirtual |
Reimplemented in node_function.
Definition at line 50 of file node_impl.cpp.
Referenced by get_parameters().
|
privatevirtual |
Reimplemented in node_identifier, and node_void.
Definition at line 42 of file node_impl.cpp.
References evaluate().
Referenced by to_string().
identifier_list const & node_impl::get_parameters | ( | ) | const |
Definition at line 36 of file node_impl.cpp.
References evaluate_parameters().
void node_impl::print | ( | std::ostream & | stream, |
int | indent | ||
) | const |
Definition at line 18 of file node_impl.cpp.
References print_node().
|
privatepure virtual |
Implemented in node_divide, node_multiply, node_subtract, node_add, node_negate, node_binary, node_unary, node_function_call, node_function, node_identifier, node_number, and node_void.
Referenced by print().
|
static |
Read the node type from a library file, then create the proper kind of node.
Definition at line 64 of file node_impl.cpp.
Referenced by node::node().
void node_impl::save | ( | std::ostream & | stream | ) | const |
Definition at line 57 of file node_impl.cpp.
References save_node().
|
privatepure virtual |
Implemented in node_divide, node_multiply, node_subtract, node_add, node_negate, node_binary, node_unary, node_function_call, node_function, node_identifier, node_number, and node_void.
Referenced by save().
std::string node_impl::to_string | ( | ) | const |