@@ -3367,36 +3367,38 @@ expr_without_variable:
3367
3367
}
3368
3368
| function is_reference ' (' parameter_list ' )' lexical_vars ' {' inner_statement_list ' }'
3369
3369
{
3370
- $$ = &ast.ExprClosure{
3371
- Position: yylex.(*Parser).builder.NewTokensPosition($1 , $9 ),
3372
- FunctionTkn: $1 ,
3373
- AmpersandTkn: $2 ,
3374
- OpenParenthesisTkn: $3 ,
3375
- Params: $4 .(*ast.ParserSeparatedList).Items,
3376
- SeparatorTkns: $4 .(*ast.ParserSeparatedList).SeparatorTkns,
3377
- CloseParenthesisTkn: $5 ,
3378
- ClosureUse: $6 ,
3379
- OpenCurlyBracketTkn: $7 ,
3380
- Stmts: $8 ,
3381
- CloseCurlyBracketTkn: $9 ,
3382
- }
3370
+ closure := $6 .(*ast.ExprClosure)
3371
+
3372
+ closure.Position = yylex.(*Parser).builder.NewTokensPosition($1 , $9 )
3373
+ closure.FunctionTkn = $1
3374
+ closure.AmpersandTkn = $2
3375
+ closure.OpenParenthesisTkn = $3
3376
+ closure.Params = $4 .(*ast.ParserSeparatedList).Items
3377
+ closure.SeparatorTkns = $4 .(*ast.ParserSeparatedList).SeparatorTkns
3378
+ closure.CloseParenthesisTkn = $5
3379
+ closure.OpenCurlyBracketTkn = $7
3380
+ closure.Stmts = $8
3381
+ closure.CloseCurlyBracketTkn = $9
3382
+
3383
+ $$ = closure
3383
3384
}
3384
3385
| T_STATIC function is_reference ' (' parameter_list ' )' lexical_vars ' {' inner_statement_list ' }'
3385
3386
{
3386
- $$ = &ast.ExprClosure{
3387
- Position: yylex.(*Parser).builder.NewTokensPosition($1 , $10 ),
3388
- StaticTkn: $1 ,
3389
- FunctionTkn: $2 ,
3390
- AmpersandTkn: $3 ,
3391
- OpenParenthesisTkn: $4 ,
3392
- Params: $5 .(*ast.ParserSeparatedList).Items,
3393
- SeparatorTkns: $5 .(*ast.ParserSeparatedList).SeparatorTkns,
3394
- CloseParenthesisTkn: $6 ,
3395
- ClosureUse: $7 ,
3396
- OpenCurlyBracketTkn: $8 ,
3397
- Stmts: $9 ,
3398
- CloseCurlyBracketTkn: $10 ,
3399
- }
3387
+ closure := $7 .(*ast.ExprClosure)
3388
+
3389
+ closure.Position = yylex.(*Parser).builder.NewTokensPosition($1 , $10 )
3390
+ closure.StaticTkn = $1
3391
+ closure.FunctionTkn = $2
3392
+ closure.AmpersandTkn = $3
3393
+ closure.OpenParenthesisTkn = $4
3394
+ closure.Params = $5 .(*ast.ParserSeparatedList).Items
3395
+ closure.SeparatorTkns = $5 .(*ast.ParserSeparatedList).SeparatorTkns
3396
+ closure.CloseParenthesisTkn = $6
3397
+ closure.OpenCurlyBracketTkn = $8
3398
+ closure.Stmts = $9
3399
+ closure.CloseCurlyBracketTkn = $10
3400
+
3401
+ $$ = closure
3400
3402
}
3401
3403
;
3402
3404
@@ -3520,30 +3522,32 @@ function:
3520
3522
lexical_vars :
3521
3523
/* empty */
3522
3524
{
3523
- $$ = nil
3525
+ $$ = &ast.ExprClosure{}
3524
3526
}
3525
3527
| T_USE ' (' lexical_var_list ' )'
3526
3528
{
3527
- $$ = &ast.ExprClosureUse{
3528
- Position: yylex.(*Parser).builder.NewTokensPosition($1 , $4 ),
3529
- UseTkn: $1 ,
3530
- OpenParenthesisTkn: $2 ,
3531
- Uses: $3 .(*ast.ParserSeparatedList).Items,
3532
- SeparatorTkns: $3 .(*ast.ParserSeparatedList).SeparatorTkns,
3533
- CloseParenthesisTkn: $4 ,
3529
+ $$ = &ast.ExprClosure{
3530
+ UseTkn: $1 ,
3531
+ UseOpenParenthesisTkn: $2 ,
3532
+ Use: $3 .(*ast.ParserSeparatedList).Items,
3533
+ UseSeparatorTkns: $3 .(*ast.ParserSeparatedList).SeparatorTkns,
3534
+ UseCloseParenthesisTkn: $4 ,
3534
3535
}
3535
3536
}
3536
3537
;
3537
3538
3538
3539
lexical_var_list :
3539
3540
lexical_var_list ' ,' T_VARIABLE
3540
3541
{
3541
- variable := &ast.ExprVariable {
3542
+ variable := &ast.ExprClosureUse {
3542
3543
Position: yylex.(*Parser).builder.NewTokenPosition($3 ),
3543
- VarName : &ast.Identifier {
3544
+ Var : &ast.ExprVariable {
3544
3545
Position: yylex.(*Parser).builder.NewTokenPosition($3 ),
3545
- IdentifierTkn: $3 ,
3546
- Value: $3 .Value,
3546
+ VarName: &ast.Identifier{
3547
+ Position: yylex.(*Parser).builder.NewTokenPosition($3 ),
3548
+ IdentifierTkn: $3 ,
3549
+ Value: $3 .Value,
3550
+ },
3547
3551
},
3548
3552
}
3549
3553
@@ -3554,7 +3558,7 @@ lexical_var_list:
3554
3558
}
3555
3559
| lexical_var_list ' ,' ' &' T_VARIABLE
3556
3560
{
3557
- reference := &ast.ExprReference {
3561
+ variable := &ast.ExprClosureUse {
3558
3562
Position: yylex.(*Parser).builder.NewTokensPosition($3 , $4 ),
3559
3563
AmpersandTkn: $3 ,
3560
3564
Var: &ast.ExprVariable{
@@ -3568,43 +3572,46 @@ lexical_var_list:
3568
3572
}
3569
3573
3570
3574
$1 .(*ast.ParserSeparatedList).SeparatorTkns = append($1 .(*ast.ParserSeparatedList).SeparatorTkns, $2 )
3571
- $1 .(*ast.ParserSeparatedList).Items = append($1 .(*ast.ParserSeparatedList).Items, reference )
3575
+ $1 .(*ast.ParserSeparatedList).Items = append($1 .(*ast.ParserSeparatedList).Items, variable )
3572
3576
3573
3577
$$ = $1
3574
3578
}
3575
3579
| T_VARIABLE
3576
3580
{
3577
- $$ = &ast.ParserSeparatedList{
3578
- Items: []ast.Vertex{
3579
- &ast.ExprVariable{
3581
+ variable := &ast.ExprClosureUse{
3582
+ Position: yylex.(*Parser).builder.NewTokenPosition($1 ),
3583
+ Var: &ast.ExprVariable{
3584
+ Position: yylex.(*Parser).builder.NewTokenPosition($1 ),
3585
+ VarName: &ast.Identifier{
3580
3586
Position: yylex.(*Parser).builder.NewTokenPosition($1 ),
3581
- VarName: &ast.Identifier{
3582
- Position: yylex.(*Parser).builder.NewTokenPosition($1 ),
3583
- IdentifierTkn: $1 ,
3584
- Value: $1 .Value,
3585
- },
3587
+ IdentifierTkn: $1 ,
3588
+ Value: $1 .Value,
3586
3589
},
3587
3590
},
3588
3591
}
3592
+
3593
+ $$ = &ast.ParserSeparatedList{
3594
+ Items: []ast.Vertex{ variable },
3595
+ }
3589
3596
}
3590
3597
| ' &' T_VARIABLE
3591
3598
{
3592
- $$ = &ast.ParserSeparatedList{
3593
- Items: []ast.Vertex{
3594
- &ast.ExprReference{
3595
- Position: yylex.(*Parser).builder.NewTokensPosition($1 , $2 ),
3596
- AmpersandTkn: $1 ,
3597
- Var: &ast.ExprVariable{
3598
- Position: yylex.(*Parser).builder.NewTokenPosition($2 ),
3599
- VarName: &ast.Identifier{
3600
- Position: yylex.(*Parser).builder.NewTokenPosition($2 ),
3601
- IdentifierTkn: $2 ,
3602
- Value: $2 .Value,
3603
- },
3604
- },
3599
+ variable := &ast.ExprClosureUse{
3600
+ Position: yylex.(*Parser).builder.NewTokensPosition($1 , $2 ),
3601
+ AmpersandTkn: $1 ,
3602
+ Var: &ast.ExprVariable{
3603
+ Position: yylex.(*Parser).builder.NewTokenPosition($2 ),
3604
+ VarName: &ast.Identifier{
3605
+ Position: yylex.(*Parser).builder.NewTokenPosition($2 ),
3606
+ IdentifierTkn: $2 ,
3607
+ Value: $2 .Value,
3605
3608
},
3606
3609
},
3607
3610
}
3611
+
3612
+ $$ = &ast.ParserSeparatedList{
3613
+ Items: []ast.Vertex{ variable },
3614
+ }
3608
3615
}
3609
3616
;
3610
3617
0 commit comments