Interpreter prototype alpha
c++ interpreter for make believe language
 
Loading...
Searching...
No Matches
VariableNode.h
Go to the documentation of this file.
1
8#ifndef VARIABLENODE_H
9#define VARIABLENODE_H
10#include "../tokenNode.h"
11
15class VariableNode : public tokenNode{
16public:
20 std::shared_ptr<tokenNode> assignedData = nullptr;
21
25 std::shared_ptr<tokenNode> appendData = nullptr;
26
30 std::string appendType = "null";
31
35 std::string varName = "";
36
42
48 std::string __represent__();
49
50 //static variables
54 static std::vector<std::shared_ptr<VariableNode>> stackNUMBERvector;
55
59 static std::vector<std::shared_ptr<VariableNode>> stackWORDvector;
60
61 //static functions
68 static void pushIntoVector(std::shared_ptr<VariableNode> token, const std::string& stacktype);
69
76 static bool alreadyExistingVariable(const std::string& toCheck, const std::string& stacktype);
77
84 static std::shared_ptr<VariableNode> getThisVariableobject(const std::string& variablename, const std::string& stacktype);
85
94 static bool reassignExistingVariable(std::shared_ptr<tokenNode> token, const std::string& variablename, const std::string& stacktype, const std::string& appendtype);
95
96};
97
98#endif
node used for creating abstract syntax tree
Definition tokenNode.h:15
static std::shared_ptr< VariableNode > getThisVariableobject(const std::string &variablename, const std::string &stacktype)
returns a pointer to the variable with the name of the variablename in the correct stacktype whether ...
Definition VariableNode.cpp:41
std::shared_ptr< tokenNode > appendData
the value to add to this variable's assigned data
Definition VariableNode.h:25
static bool reassignExistingVariable(std::shared_ptr< tokenNode > token, const std::string &variablename, const std::string &stacktype, const std::string &appendtype)
reassigns new data to a variable in the stack
Definition VariableNode.cpp:57
static bool alreadyExistingVariable(const std::string &toCheck, const std::string &stacktype)
checks if the variable name in toCheck is an exisitng variable
Definition VariableNode.cpp:25
static std::vector< std::shared_ptr< VariableNode > > stackWORDvector
stack vector of all word variables
Definition VariableNode.h:59
std::shared_ptr< tokenNode > assignedData
pointer to this variables assigned data
Definition VariableNode.h:20
std::string __represent__()
(virtual) returns a string representing the current state of this whilenode and it's syntax tree stru...
Definition VariableNode.cpp:8
std::string appendType
append type of append data eg, '+=', '-=', '*=' etc
Definition VariableNode.h:30
static std::vector< std::shared_ptr< VariableNode > > stackNUMBERvector
stack vector of all number variables
Definition VariableNode.h:54
std::string varName
the name of the variable
Definition VariableNode.h:35
static void pushIntoVector(std::shared_ptr< VariableNode > token, const std::string &stacktype)
pushes a new variable onto the stack depending on the stack to put it in
Definition VariableNode.cpp:20
VariableNode()
constructor
Definition VariableNode.cpp:6
creates a node in the syntax tree of type variable
Definition VariableNode.h:15
creates an object with the mapping of a token that was assigned to it from the 'tokens' class
Definition tokens.h:200