Interprets and executes code from the abstract syntax tree. More...
#include <Interpreter.h>
Public Member Functions | |
| Interpreter (const std::string &filepath, const int &linenumber) | |
| Interpreter constructor. | |
| void | run__CODE (std::shared_ptr< tokenNode > &TKNode, const std::string &datatype) |
| runs the interpreter | |
Private Member Functions | |
| void | visit_controlflow (std::shared_ptr< tokenNode > &TKNode, const std::string &datatype) |
| visits control flow on the syntax tree | |
| void | visit_built_in_func (std::shared_ptr< tokenNode > &TKNode, const std::string &datatype) |
| visits built in function | |
| bool | checkCondition (std::shared_ptr< tokenNode > &TKNode, const std::string &datatype) |
| checks if the condition of a control flow is true from visit_controlflow() on for-loop, while-loop, if,else if statements | |
| void | visit_Variables (std::shared_ptr< tokenNode > &TKNode, const std::string &datatype) |
| visits variable nodes and extracts their values | |
| returnStringValues | visitWORDS (std::shared_ptr< tokenNode > &TKNode) |
| attempts to figure out if the passed in argument is a StringNode, OperatorNode or VariableNode | |
| std::string | visit__StringNode (std::shared_ptr< StringNode > &TKNode) |
| visits a string and extracts it's value eg "value" | |
| std::string | visit__StringAppendNode (std::shared_ptr< VariableNode > &nodeToAppendTo, const std::string &passedvalue) |
| appends a value to the end of a variable | |
| returnNumberValues | visitNUMBERS (std::shared_ptr< tokenNode > &TKNode) |
| attempts to figure out if the passed in argument is a NumberNode, OperatorNode or VariableNode | |
| double | visit__unaryNumberNode (std::shared_ptr< NumberNode > &TKNode) |
| extracts the number value from this node which is of type unary, eg -5 or +5 | |
| double | visit__unaryNumberNodeExpr (std::shared_ptr< NumberNode > &TKNode) |
| visits a number node contained within an expression such as and multiplies it by it's unary, eg -(5 + 5) | |
| double | visit__NumberNode (std::shared_ptr< NumberNode > &TKNode) |
| extracts the number value from this node , eg 5 | |
| double | visit__NumberAppendNode (std::shared_ptr< VariableNode > &nodeToAppendTo, const double &passedvalue) |
| appends/adds or any other operator, a value to the end of a variable | |
| returnNumberValues | visit__numberOPNODE (std::shared_ptr< OperatorNode > &TKNode) |
| attempts to figure out which operator is being used between two number nodes | |
| returnStringValues | visit__stringOPNODE (std::shared_ptr< OperatorNode > &TKNode) |
| attempts to figure out which operator is being used between two word nodes | |
| void | resetVariableValue (std::shared_ptr< forNode > &forobj) |
| reset a variable in a for loop back to it's original value after the for loop has finished executing | |
Private Attributes | |
| std::string | filePath |
| name of the file currently being processed | |
| int | lnNum |
| the line number in the file which is currently being processed | |
| bool | isInLoop |
| specifies whether or not what is currently being processed is a loop or not | |
Interprets and executes code from the abstract syntax tree.