-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAstNode.cpp
47 lines (42 loc) · 924 Bytes
/
AstNode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "AstNode.h"
/*
* This c'tor used to build every Node of the Ast.
* input:
* data - the value of the Node.
* type - the type of the Node in the Ast: Operator \ Operand \ Token.
*/
AstNode::AstNode(string data, int type) {
_Data = data;
_type = type;
}
/*
* This function return the value of the Node.
* Output: the Node value.
*/
string AstNode::getData() {
return this->_Data;
}
/*
* This function return all the branches of that Ast Node.
* Output: Vector of pointers to all the branches of the Ast Node.
*/
vector<AstNode*> AstNode::getBranches() {
return this->_branches;
}
/*
* This function add new node to the Node branches.
* Input:
* node - new node to push into the Node branches.
* output: NULL
*/
void AstNode::add(AstNode* node) {
this->_branches.push_back(node);
}
/*
* This function return the type of that Node.
* Output: The type of the Node.
*/
int AstNode::getType()
{
return _type;
}