@@ -37,7 +37,7 @@ struct Node {
3737 Position positionStart;
3838 Position positionEnd;
3939
40- std::string virtual to_string () {
40+ std::string virtual to_string () const {
4141 return " Not implemented! " + nodeType;
4242 };
4343
@@ -55,14 +55,14 @@ struct Node {
5555};
5656
5757struct NumberNode : Node {
58- NumberNode (Token token) {
58+ NumberNode (const Token& token) {
5959 this ->nodeType = nodetypes::Number;
6060 this ->token = token;
6161 this ->positionStart = token.positionStart ;
6262 this ->positionEnd = token.positionEnd ;
6363 }
6464
65- std::string to_string () override {
65+ std::string to_string () const override {
6666 return token.value ;
6767 }
6868
@@ -72,15 +72,15 @@ struct NumberNode : Node {
7272};
7373
7474struct VariableDeclarationNode : Node {
75- VariableDeclarationNode (Token token, spNode valueNode) {
75+ VariableDeclarationNode (const Token& token, const spNode& valueNode) {
7676 this ->nodeType = nodetypes::VariableDeclaration;
7777 this ->token = token;
7878 this ->valueNode = valueNode;
7979 this ->positionStart = token.positionStart ;
8080 this ->positionEnd = valueNode->positionEnd ;
8181 }
8282
83- std::string to_string () override {
83+ std::string to_string () const override {
8484 return " (LET, identifier:\" " + token.value + " \" , EQUAL, " + valueNode->to_string () + " )" ;
8585 }
8686
@@ -90,15 +90,15 @@ struct VariableDeclarationNode : Node {
9090};
9191
9292struct VariableAssignmentNode : Node {
93- VariableAssignmentNode (Token token, spNode valueNode) {
93+ VariableAssignmentNode (const Token& token, const spNode& valueNode) {
9494 this ->nodeType = nodetypes::VariableAssignment;
9595 this ->token = token;
9696 this ->valueNode = valueNode;
9797 this ->positionStart = token.positionStart ;
9898 this ->positionEnd = valueNode->positionEnd ;
9999 }
100100
101- std::string to_string () override {
101+ std::string to_string () const override {
102102 return " (identifier:\" " + token.value + " \" , EQUAL, " + valueNode->to_string () + " )" ;
103103 }
104104
@@ -108,14 +108,14 @@ struct VariableAssignmentNode : Node {
108108};
109109
110110struct VariableRetrievementNode : Node {
111- VariableRetrievementNode (Token token) {
111+ VariableRetrievementNode (const Token& token) {
112112 this ->nodeType = nodetypes::VariableRetrievement;
113113 this ->token = token;
114114 this ->positionStart = token.positionStart ;
115115 this ->positionEnd = token.positionEnd ;
116116 }
117117
118- std::string to_string () override {
118+ std::string to_string () const override {
119119 return token.value ;
120120 }
121121
@@ -125,7 +125,7 @@ struct VariableRetrievementNode : Node {
125125};
126126
127127struct BinaryOperatorNode : Node {
128- BinaryOperatorNode (spNode leftNode, Token token, spNode rightNode) {
128+ BinaryOperatorNode (const spNode& leftNode, const Token& token, const spNode& rightNode) {
129129 this ->nodeType = nodetypes::BinaryOperator;
130130 this ->token = token;
131131 this ->leftNode = leftNode;
@@ -134,7 +134,7 @@ struct BinaryOperatorNode : Node {
134134 this ->positionEnd = rightNode->positionEnd ;
135135 }
136136
137- std::string to_string () override {
137+ std::string to_string () const override {
138138 return " (" + leftNode->to_string () + " , " + token.type + " , " + rightNode->to_string () + " )" ;
139139 }
140140
@@ -144,15 +144,15 @@ struct BinaryOperatorNode : Node {
144144};
145145
146146struct UnaryOperatorNode : Node {
147- UnaryOperatorNode (Token token, spNode rightNode) {
147+ UnaryOperatorNode (const Token& token, const spNode& rightNode) {
148148 this ->nodeType = nodetypes::UnaryOperator;
149149 this ->token = token;
150150 this ->rightNode = rightNode;
151151 this ->positionStart = token.positionStart ;
152152 this ->positionEnd = rightNode->positionEnd ;
153153 }
154154
155- std::string to_string () override {
155+ std::string to_string () const override {
156156 return " (" + token.type + " , " + rightNode->to_string () + " )" ;
157157 }
158158
@@ -162,12 +162,12 @@ struct UnaryOperatorNode : Node {
162162};
163163
164164struct ErrorNode : Node {
165- ErrorNode (Token token) {
165+ ErrorNode (const Token& token) {
166166 this ->nodeType = nodetypes::Error;
167167 this ->token = token;
168168 }
169169
170- std::string to_string () override {
170+ std::string to_string () const override {
171171 return token.value ;
172172 }
173173
0 commit comments