10#include "../tokens/tokens.h"
11#include "../tokenNode/tokenNode.h"
12#include "../tokenNode/NumberNode/NumberNode.h"
13#include "../tokenNode/OperatorNode/OperatorNode.h"
14#include "../tokenNode/StringNode/StringNode.h"
15#include "../tokenNode/VariableNode/VariableNode.h"
16#include "../tokenNode/builtinNode/builtinNode.h"
17#include "../tokenNode/ifNode/ifNode.h"
18#include "../tokenNode/whileNode/whileNode.h"
19#include "../tokenNode/forNode/forNode.h"
65 Interpreter(
const std::string& filepath,
const int& linenumber);
73 void run__CODE(std::shared_ptr<tokenNode>& TKNode,
const std::string& datatype);
97 void visit_controlflow(std::shared_ptr<tokenNode>& TKNode,
const std::string& datatype);
113 bool checkCondition(std::shared_ptr<tokenNode>& TKNode,
const std::string& datatype);
121 void visit_Variables(std::shared_ptr<tokenNode>& TKNode,
const std::string& datatype);
143 std::string
visit__StringAppendNode(std::shared_ptr<VariableNode>& nodeToAppendTo,
const std::string& passedvalue);
DATATYPES
Definition Interpreter.h:21
double value
Definition Interpreter.h:31
bool result
Definition Interpreter.h:30
bool isbooleanstatement
Definition Interpreter.h:29
returns a struct containing number values from calculations
Definition Interpreter.h:28
bool result
Definition Interpreter.h:39
bool isbooleanstatement
Definition Interpreter.h:38
std::string value
Definition Interpreter.h:40
returns a struct containing string values from calculations
Definition Interpreter.h:37
double numberval
Definition Interpreter.h:51
bool booleanval
Definition Interpreter.h:48
bool isbooleanval
Definition Interpreter.h:47
bool isnumberval
Definition Interpreter.h:49
bool iswordval
Definition Interpreter.h:50
std::string wordval
Definition Interpreter.h:52
specifies the type of the return value and carries the return value
Definition Interpreter.h:46
void run__CODE(std::shared_ptr< tokenNode > &TKNode, const std::string &datatype)
runs the interpreter
Definition Interpreter.cpp:9
std::string visit__StringNode(std::shared_ptr< StringNode > &TKNode)
visits a string and extracts it's value eg "value"
Definition Interpreter.cpp:323
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
Definition Interpreter.cpp:616
std::string filePath
name of the file currently being processed
Definition Interpreter.h:79
double visit__unaryNumberNode(std::shared_ptr< NumberNode > &TKNode)
extracts the number value from this node which is of type unary, eg -5 or +5
Definition Interpreter.cpp:327
void visit_controlflow(std::shared_ptr< tokenNode > &TKNode, const std::string &datatype)
visits control flow on the syntax tree
Definition Interpreter.cpp:13
void visit_built_in_func(std::shared_ptr< tokenNode > &TKNode, const std::string &datatype)
visits built in function
Definition Interpreter.cpp:105
returnStringValues visitWORDS(std::shared_ptr< tokenNode > &TKNode)
attempts to figure out if the passed in argument is a StringNode, OperatorNode or VariableNode
Definition Interpreter.cpp:239
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,...
Definition Interpreter.cpp:336
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,...
Definition Interpreter.cpp:593
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
Definition Interpreter.cpp:533
returnNumberValues visit__numberOPNODE(std::shared_ptr< OperatorNode > &TKNode)
attempts to figure out which operator is being used between two number nodes
Definition Interpreter.cpp:345
double visit__NumberNode(std::shared_ptr< NumberNode > &TKNode)
extracts the number value from this node , eg 5
Definition Interpreter.cpp:325
std::string visit__StringAppendNode(std::shared_ptr< VariableNode > &nodeToAppendTo, const std::string &passedvalue)
appends a value to the end of a variable
Definition Interpreter.cpp:575
returnStringValues visit__stringOPNODE(std::shared_ptr< OperatorNode > &TKNode)
attempts to figure out which operator is being used between two word nodes
Definition Interpreter.cpp:457
bool isInLoop
specifies whether or not what is currently being processed is a loop or not
Definition Interpreter.h:89
int lnNum
the line number in the file which is currently being processed
Definition Interpreter.h:84
void visit_Variables(std::shared_ptr< tokenNode > &TKNode, const std::string &datatype)
visits variable nodes and extracts their values
Definition Interpreter.cpp:157
returnNumberValues visitNUMBERS(std::shared_ptr< tokenNode > &TKNode)
attempts to figure out if the passed in argument is a NumberNode, OperatorNode or VariableNode
Definition Interpreter.cpp:277
Interprets and executes code from the abstract syntax tree.
Definition Interpreter.h:58