@@ -111,7 +111,7 @@ func parseReturnStmt(p *Parser) ast.Statement {
111111 }
112112
113113 return & ast.ReturnStmt {
114- Value : & value ,
114+ Value : value ,
115115 Location : * source .NewLocation (& start , & end ),
116116 }
117117}
@@ -143,11 +143,10 @@ func parseLogicalOr(p *Parser) ast.Expression {
143143 for p .match (lexer .OR_TOKEN ) {
144144 operator := p .advance ()
145145 right := parseLogicalAnd (p )
146- left := expr // Create a copy to avoid circular reference
147146 expr = & ast.BinaryExpr {
148- Left : & left ,
147+ Left : expr ,
149148 Operator : operator ,
150- Right : & right ,
149+ Right : right ,
151150 Location : * source .NewLocation (expr .Loc ().Start , right .Loc ().End ),
152151 }
153152 }
@@ -162,11 +161,10 @@ func parseLogicalAnd(p *Parser) ast.Expression {
162161 for p .match (lexer .AND_TOKEN ) {
163162 operator := p .advance ()
164163 right := parseEquality (p )
165- left := expr // Create a copy to avoid circular reference
166164 expr = & ast.BinaryExpr {
167- Left : & left ,
165+ Left : expr ,
168166 Operator : operator ,
169- Right : & right ,
167+ Right : right ,
170168 Location : * source .NewLocation (expr .Loc ().Start , right .Loc ().End ),
171169 }
172170 }
@@ -181,11 +179,10 @@ func parseEquality(p *Parser) ast.Expression {
181179 for p .match (lexer .DOUBLE_EQUAL_TOKEN , lexer .NOT_EQUAL_TOKEN ) {
182180 operator := p .advance ()
183181 right := parseComparison (p )
184- left := expr // Create a copy to avoid circular reference
185182 expr = & ast.BinaryExpr {
186- Left : & left ,
183+ Left : expr ,
187184 Operator : operator ,
188- Right : & right ,
185+ Right : right ,
189186 Location : * source .NewLocation (expr .Loc ().Start , right .Loc ().End ),
190187 }
191188 }
@@ -200,11 +197,10 @@ func parseComparison(p *Parser) ast.Expression {
200197 for p .match (lexer .LESS_TOKEN , lexer .GREATER_TOKEN , lexer .LESS_EQUAL_TOKEN , lexer .GREATER_EQUAL_TOKEN ) {
201198 operator := p .advance ()
202199 right := parseAdditive (p )
203- left := expr // Create a copy to avoid circular reference
204200 expr = & ast.BinaryExpr {
205- Left : & left ,
201+ Left : expr ,
206202 Operator : operator ,
207- Right : & right ,
203+ Right : right ,
208204 Location : * source .NewLocation (expr .Loc ().Start , right .Loc ().End ),
209205 }
210206 }
@@ -219,11 +215,10 @@ func parseAdditive(p *Parser) ast.Expression {
219215 for p .match (lexer .PLUS_TOKEN , lexer .MINUS_TOKEN ) {
220216 operator := p .advance ()
221217 right := parseMultiplicative (p )
222- left := expr // Create a copy to avoid circular reference
223218 expr = & ast.BinaryExpr {
224- Left : & left ,
219+ Left : expr ,
225220 Operator : operator ,
226- Right : & right ,
221+ Right : right ,
227222 Location : * source .NewLocation (expr .Loc ().Start , right .Loc ().End ),
228223 }
229224 }
@@ -238,11 +233,10 @@ func parseMultiplicative(p *Parser) ast.Expression {
238233 for p .match (lexer .MUL_TOKEN , lexer .DIV_TOKEN , lexer .MOD_TOKEN , lexer .EXP_TOKEN ) {
239234 operator := p .advance ()
240235 right := parseUnary (p )
241- left := expr // Create a copy to avoid circular reference
242236 expr = & ast.BinaryExpr {
243- Left : & left ,
237+ Left : expr ,
244238 Operator : operator ,
245- Right : & right ,
239+ Right : right ,
246240 Location : * source .NewLocation (expr .Loc ().Start , right .Loc ().End ),
247241 }
248242 }
@@ -274,7 +268,7 @@ func handleNotNegative(p *Parser) ast.Expression {
274268 right := parseUnary (p )
275269 return & ast.UnaryExpr {
276270 Operator : operator ,
277- Operand : & right ,
271+ Operand : right ,
278272 Location : * source .NewLocation (& operator .Start , right .Loc ().End ),
279273 }
280274}
@@ -308,7 +302,7 @@ func handlePlusMinus(p *Parser) ast.Expression {
308302
309303 return & ast.PrefixExpr {
310304 Operator : operator ,
311- Operand : & operand ,
305+ Operand : operand ,
312306 Location : * source .NewLocation (& operator .Start , operand .Loc ().End ),
313307 }
314308}
@@ -323,7 +317,7 @@ func handleSpread(p *Parser) ast.Expression {
323317 }
324318
325319 return & ast.SpreadExpr {
326- Expression : & right ,
320+ Expression : right ,
327321 Location : * source .NewLocation (& operator .Start , right .Loc ().End ),
328322 }
329323}
@@ -341,7 +335,7 @@ func parseCast(p *Parser) ast.Expression {
341335 }
342336
343337 return & ast.CastExpr {
344- Value : & expr ,
338+ Value : expr ,
345339 TargetType : targetType ,
346340 Location : * source .NewLocation (expr .Loc ().Start , targetType .Loc ().End ),
347341 }
@@ -364,8 +358,8 @@ func parseIndexing(p *Parser, expr ast.Expression) (ast.Expression, bool) {
364358
365359 end := p .consume (lexer .CLOSE_BRACKET , "expected ']' after index expression" )
366360 return & ast.IndexableExpr {
367- Indexable : & expr ,
368- Index : & index ,
361+ Indexable : expr ,
362+ Index : index ,
369363 Location : * source .NewLocation (start , & end .End ),
370364 }, true
371365}
@@ -382,7 +376,7 @@ func parseIncDec(p *Parser, expr ast.Expression) (ast.Expression, bool) {
382376 return nil , false
383377 }
384378 return & ast.PostfixExpr {
385- Operand : & expr ,
379+ Operand : expr ,
386380 Operator : operator ,
387381 Location : * source .NewLocation (expr .Loc ().Start , & operator .End ),
388382 }, true
@@ -477,7 +471,7 @@ func parseFunctionCall(p *Parser, caller ast.Expression) (ast.Expression, bool)
477471 end := p .consume (lexer .CLOSE_PAREN , "expected ')' after function arguments" )
478472
479473 return & ast.FunctionCallExpr {
480- Caller : & caller ,
474+ Caller : caller ,
481475 Arguments : arguments ,
482476 Location : * source .NewLocation (start , & end .End ),
483477 }, true
0 commit comments