[refactoring] update ast structure of "ArrayDimFetch" and "ArrayItem" nodes
This commit is contained in:
parent
47b974a3a4
commit
4b8d431767
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -3067,27 +3067,31 @@ chaining_method_or_property:
|
||||
chaining_dereference:
|
||||
chaining_dereference '[' dim_offset ']'
|
||||
{
|
||||
fetch := &ast.ExprArrayDimFetch{ast.Node{}, nil, $3}
|
||||
fetch := &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
Var: nil,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
|
||||
$$ = append($1, fetch)
|
||||
|
||||
// save position
|
||||
fetch.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| '[' dim_offset ']'
|
||||
{
|
||||
fetch := &ast.ExprArrayDimFetch{ast.Node{}, nil, $2}
|
||||
fetch := &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
Var: nil,
|
||||
OpenBracketTkn: $1,
|
||||
Dim: $2,
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
|
||||
$$ = []ast.Vertex{fetch}
|
||||
|
||||
// save position
|
||||
fetch.GetNode().Position = position.NewNodePosition($2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Var, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Expr, $3.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -4021,54 +4025,57 @@ yield_expr:
|
||||
combined_scalar_offset:
|
||||
combined_scalar '[' dim_offset ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| combined_scalar_offset '[' dim_offset ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']'
|
||||
{
|
||||
str := &ast.ScalarString{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
Var: &ast.ScalarString{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
StringTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, str, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition(str, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| general_constant '[' dim_offset ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -4782,14 +4789,15 @@ static_scalar_value:
|
||||
static_operation:
|
||||
static_scalar_value '[' static_scalar_value ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| static_scalar_value '+' static_scalar_value
|
||||
{
|
||||
@ -5284,63 +5292,61 @@ possible_comma:
|
||||
non_empty_static_array_pair_list:
|
||||
non_empty_static_array_pair_list ',' static_scalar_value T_DOUBLE_ARROW static_scalar_value
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, $3, $5}
|
||||
arrayItem := &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($3, $5),
|
||||
},
|
||||
Key: $3,
|
||||
DoubleArrowTkn: $4,
|
||||
Val: $5,
|
||||
}
|
||||
|
||||
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, arrayItem)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodesPosition($3, $5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($3, arrayItem)
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| non_empty_static_array_pair_list ',' static_scalar_value
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, nil, $3}
|
||||
arrayItem := &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($3),
|
||||
},
|
||||
Val: $3,
|
||||
}
|
||||
|
||||
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, arrayItem)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($3, arrayItem)
|
||||
}
|
||||
| static_scalar_value T_DOUBLE_ARROW static_scalar_value
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, $1, $3}
|
||||
|
||||
$$ = &ast.ParserSeparatedList{
|
||||
Items: []ast.Vertex{arrayItem},
|
||||
Items: []ast.Vertex{
|
||||
&ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($1, $3),
|
||||
},
|
||||
Key: $1,
|
||||
DoubleArrowTkn: $2,
|
||||
Val: $3,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodesPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, arrayItem)
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Expr, $2.SkippedTokens)
|
||||
}
|
||||
| static_scalar_value
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, nil, $1}
|
||||
|
||||
$$ = &ast.ParserSeparatedList{
|
||||
Items: []ast.Vertex{arrayItem},
|
||||
Items: []ast.Vertex{
|
||||
&ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($1),
|
||||
},
|
||||
Val: $1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodePosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, arrayItem)
|
||||
}
|
||||
;
|
||||
|
||||
@ -5504,27 +5510,31 @@ variable_property:
|
||||
array_method_dereference:
|
||||
array_method_dereference '[' dim_offset ']'
|
||||
{
|
||||
fetch := &ast.ExprArrayDimFetch{ast.Node{}, nil, $3}
|
||||
fetch := &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
Var: nil,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
|
||||
$$ = append($1, fetch)
|
||||
|
||||
// save position
|
||||
fetch.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| method '[' dim_offset ']'
|
||||
{
|
||||
fetch := &ast.ExprArrayDimFetch{ast.Node{}, nil, $3}
|
||||
fetch := &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
Var: nil,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
|
||||
$$ = []ast.Vertex{$1, fetch}
|
||||
|
||||
// save position
|
||||
fetch.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -5605,25 +5615,27 @@ variable_class_name:
|
||||
array_function_dereference:
|
||||
array_function_dereference '[' dim_offset ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| function_call '[' dim_offset ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -5667,25 +5679,27 @@ base_variable:
|
||||
reference_variable:
|
||||
reference_variable '[' dim_offset ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| reference_variable '{' expr '}'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| compound_variable
|
||||
{
|
||||
@ -5756,27 +5770,31 @@ object_property:
|
||||
object_dim_list:
|
||||
object_dim_list '[' dim_offset ']'
|
||||
{
|
||||
fetch := &ast.ExprArrayDimFetch{ast.Node{}, nil, $3}
|
||||
fetch := &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
Var: nil,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
|
||||
$$ = append($1, fetch)
|
||||
|
||||
// save position
|
||||
fetch.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| object_dim_list '{' expr '}'
|
||||
{
|
||||
fetch := &ast.ExprArrayDimFetch{ast.Node{}, nil, $3}
|
||||
fetch := &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
Var: nil,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
|
||||
$$ = append($1, fetch)
|
||||
|
||||
// save position
|
||||
fetch.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(fetch, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| variable_name
|
||||
{
|
||||
@ -5861,13 +5879,12 @@ assignment_list:
|
||||
assignment_list_element:
|
||||
variable
|
||||
{
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, nil, $1}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodePosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($1),
|
||||
},
|
||||
Val: $1,
|
||||
}
|
||||
}
|
||||
| T_LIST '(' assignment_list ')'
|
||||
{
|
||||
@ -5878,7 +5895,11 @@ assignment_list_element:
|
||||
pairList.Items = nil
|
||||
}
|
||||
|
||||
listNode := &ast.ExprList{
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
Val: &ast.ExprList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
@ -5887,21 +5908,12 @@ assignment_list_element:
|
||||
Items: $3.(*ast.ParserSeparatedList).Items,
|
||||
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||
CloseBracketTkn: $4,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, nil, listNode}
|
||||
|
||||
// save position
|
||||
listNode.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
$$.GetNode().Position = position.NewNodePosition(listNode)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(listNode, token.List, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(listNode, token.ArrayPairList, $4.SkippedTokens)
|
||||
}
|
||||
| /* empty */
|
||||
{
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, nil, nil}
|
||||
$$ = &ast.ExprArrayItem{}
|
||||
}
|
||||
;
|
||||
|
||||
@ -5925,133 +5937,139 @@ array_pair_list:
|
||||
non_empty_array_pair_list:
|
||||
non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, $3, $5}
|
||||
arrayItem := &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($3, $5),
|
||||
},
|
||||
Key: $3,
|
||||
DoubleArrowTkn: $4,
|
||||
Val: $5,
|
||||
}
|
||||
|
||||
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, arrayItem)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodesPosition($3, $5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($3, arrayItem)
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| non_empty_array_pair_list ',' expr
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, nil, $3}
|
||||
arrayItem := &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($3),
|
||||
},
|
||||
Val: $3,
|
||||
}
|
||||
|
||||
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, arrayItem)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodePosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($3, arrayItem)
|
||||
}
|
||||
| expr T_DOUBLE_ARROW expr
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, $1, $3}
|
||||
|
||||
$$ = &ast.ParserSeparatedList{
|
||||
Items: []ast.Vertex{arrayItem},
|
||||
Items: []ast.Vertex{
|
||||
&ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($1, $3),
|
||||
},
|
||||
Key: $1,
|
||||
DoubleArrowTkn: $2,
|
||||
Val: $3,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodesPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, arrayItem)
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Expr, $2.SkippedTokens)
|
||||
}
|
||||
| expr
|
||||
{
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, nil, $1}
|
||||
|
||||
$$ = &ast.ParserSeparatedList{
|
||||
Items: []ast.Vertex{arrayItem},
|
||||
Items: []ast.Vertex{
|
||||
&ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($1),
|
||||
},
|
||||
Val: $1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
arrayItem.GetNode().Position = position.NewNodePosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, arrayItem)
|
||||
}
|
||||
| non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_variable
|
||||
{
|
||||
reference := &ast.ExprReference{ast.Node{}, $6}
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, $3, reference}
|
||||
arrayItem := &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($3, $6),
|
||||
},
|
||||
Key: $3,
|
||||
DoubleArrowTkn: $4,
|
||||
Val: &ast.ExprReference{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($5, $6),
|
||||
},
|
||||
Var: $6,
|
||||
},
|
||||
}
|
||||
|
||||
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, arrayItem)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
reference.GetNode().Position = position.NewTokenNodePosition($5, $6)
|
||||
arrayItem.GetNode().Position = position.NewNodesPosition($3, $6)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($3, arrayItem)
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Expr, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(reference, token.Start, $5.SkippedTokens)
|
||||
}
|
||||
| non_empty_array_pair_list ',' '&' w_variable
|
||||
{
|
||||
reference := &ast.ExprReference{ast.Node{}, $4}
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, nil, reference}
|
||||
arrayItem := &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $4),
|
||||
},
|
||||
Val: &ast.ExprReference{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $4),
|
||||
},
|
||||
Var: $4,
|
||||
},
|
||||
}
|
||||
|
||||
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, arrayItem)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
reference.GetNode().Position = position.NewTokenNodePosition($3, $4)
|
||||
arrayItem.GetNode().Position = position.NewTokenNodePosition($3, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
| expr T_DOUBLE_ARROW '&' w_variable
|
||||
{
|
||||
reference := &ast.ExprReference{ast.Node{}, $4}
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, $1, reference}
|
||||
|
||||
$$ = &ast.ParserSeparatedList{
|
||||
Items: []ast.Vertex{arrayItem},
|
||||
Items: []ast.Vertex{
|
||||
&ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($1, $4),
|
||||
},
|
||||
Key: $1,
|
||||
DoubleArrowTkn: $2,
|
||||
Val: &ast.ExprReference{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $4),
|
||||
},
|
||||
Var: $4,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
reference.GetNode().Position = position.NewTokenNodePosition($3, $4)
|
||||
arrayItem.GetNode().Position = position.NewNodesPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, arrayItem)
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Expr, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(reference, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
| '&' w_variable
|
||||
{
|
||||
reference := &ast.ExprReference{ast.Node{}, $2}
|
||||
arrayItem := &ast.ExprArrayItem{ast.Node{}, false, nil, reference}
|
||||
|
||||
$$ = &ast.ParserSeparatedList{
|
||||
Items: []ast.Vertex{arrayItem},
|
||||
Items: []ast.Vertex{
|
||||
&ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
Val: &ast.ExprReference{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
Var: $2,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
reference.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
arrayItem.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(arrayItem, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -6112,23 +6130,26 @@ encaps_var:
|
||||
}
|
||||
| T_VARIABLE '[' encaps_var_offset ']'
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
},
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, variable, $3}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($1)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE T_OBJECT_OPERATOR T_STRING
|
||||
{
|
||||
@ -6191,25 +6212,28 @@ encaps_var:
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $6),
|
||||
},
|
||||
OpenCurlyBracketTkn: $1,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
IdentifierTkn: $2,
|
||||
Value: $2.Value,
|
||||
},
|
||||
},
|
||||
OpenBracketTkn: $3,
|
||||
Dim: $4,
|
||||
CloseBracketTkn: $5,
|
||||
CloseCurlyBracketTkn: $6,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, variable, $4}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($2)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $6)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken(variable, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $5.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $6.SkippedTokens)
|
||||
}
|
||||
| T_CURLY_OPEN variable '}'
|
||||
{
|
||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -4236,36 +4236,39 @@ callable_variable:
|
||||
}
|
||||
| dereferencable '[' optional_expr ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| constant '[' optional_expr ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| dereferencable '{' expr '}'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| dereferencable T_OBJECT_OPERATOR property_name argument_list
|
||||
{
|
||||
@ -4380,25 +4383,27 @@ new_variable:
|
||||
}
|
||||
| new_variable '[' optional_expr ']'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| new_variable '{' expr '}'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $4),
|
||||
},
|
||||
Var: $1,
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| new_variable T_OBJECT_OPERATOR property_name
|
||||
{
|
||||
@ -4529,64 +4534,73 @@ non_empty_array_pair_list:
|
||||
array_pair:
|
||||
expr T_DOUBLE_ARROW expr
|
||||
{
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodesPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($1, $3),
|
||||
},
|
||||
Key: $1,
|
||||
DoubleArrowTkn: $2,
|
||||
Val: $3,
|
||||
}
|
||||
}
|
||||
| expr
|
||||
{
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, nil, $1}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodePosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($1),
|
||||
},
|
||||
Val: $1,
|
||||
}
|
||||
}
|
||||
| expr T_DOUBLE_ARROW '&' variable
|
||||
{
|
||||
reference := &ast.ExprReference{ast.Node{}, $4}
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, $1, reference}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodesPosition($1, $4)
|
||||
reference.GetNode().Position = position.NewTokenNodePosition($3, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(reference, token.Start, $3.SkippedTokens)
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodesPosition($1, $4),
|
||||
},
|
||||
Key: $1,
|
||||
DoubleArrowTkn: $2,
|
||||
Val: &ast.ExprReference{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $4),
|
||||
},
|
||||
Var: $4,
|
||||
},
|
||||
}
|
||||
}
|
||||
| '&' variable
|
||||
{
|
||||
reference := &ast.ExprReference{ast.Node{}, $2}
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, nil, reference}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
reference.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
Val: &ast.ExprReference{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
Var: $2,
|
||||
},
|
||||
}
|
||||
}
|
||||
| T_ELLIPSIS expr
|
||||
{
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, true, nil, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
EllipsisTkn: $1,
|
||||
Val: $2,
|
||||
}
|
||||
}
|
||||
| expr T_DOUBLE_ARROW T_LIST '(' array_pair_list ')'
|
||||
{
|
||||
listNode := &ast.ExprList{
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodeTokenPosition($1, $6),
|
||||
},
|
||||
Key: $1,
|
||||
DoubleArrowTkn: $2,
|
||||
Val: &ast.ExprList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($3, $6),
|
||||
},
|
||||
@ -4595,19 +4609,16 @@ array_pair:
|
||||
Items: $5.(*ast.ParserSeparatedList).Items,
|
||||
SeparatorTkns: $5.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||
CloseBracketTkn: $6,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, $1, listNode}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $6)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
|
||||
}
|
||||
| T_LIST '(' array_pair_list ')'
|
||||
{
|
||||
listNode := &ast.ExprList{
|
||||
$$ = &ast.ExprArrayItem{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
Val: &ast.ExprList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
@ -4616,11 +4627,8 @@ array_pair:
|
||||
Items: $3.(*ast.ParserSeparatedList).Items,
|
||||
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||
CloseBracketTkn: $4,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprArrayItem{ast.Node{}, false, nil, listNode}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
}
|
||||
;
|
||||
|
||||
@ -4681,23 +4689,26 @@ encaps_var:
|
||||
}
|
||||
| T_VARIABLE '[' encaps_var_offset ']'
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
},
|
||||
OpenBracketTkn: $2,
|
||||
Dim: $3,
|
||||
CloseBracketTkn: $4,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, variable, $3}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($1)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE T_OBJECT_OPERATOR T_STRING
|
||||
{
|
||||
@ -4760,25 +4771,28 @@ encaps_var:
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $6),
|
||||
},
|
||||
OpenCurlyBracketTkn: $1,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
IdentifierTkn: $2,
|
||||
Value: $2.Value,
|
||||
},
|
||||
},
|
||||
OpenBracketTkn: $3,
|
||||
Dim: $4,
|
||||
CloseBracketTkn: $5,
|
||||
CloseCurlyBracketTkn: $6,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
$$ = &ast.ExprArrayDimFetch{ast.Node{}, variable, $4}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($2)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $6)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken(variable, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $5.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $6.SkippedTokens)
|
||||
}
|
||||
| T_CURLY_OPEN variable '}'
|
||||
{
|
||||
|
@ -954,7 +954,11 @@ func (n *ExprArray) Accept(v NodeVisitor) {
|
||||
type ExprArrayDimFetch struct {
|
||||
Node
|
||||
Var Vertex
|
||||
OpenCurlyBracketTkn *token.Token
|
||||
OpenBracketTkn *token.Token
|
||||
Dim Vertex
|
||||
CloseBracketTkn *token.Token
|
||||
CloseCurlyBracketTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprArrayDimFetch) Accept(v NodeVisitor) {
|
||||
@ -964,8 +968,9 @@ func (n *ExprArrayDimFetch) Accept(v NodeVisitor) {
|
||||
// ExprArrayItem node
|
||||
type ExprArrayItem struct {
|
||||
Node
|
||||
Unpack bool
|
||||
EllipsisTkn *token.Token
|
||||
Key Vertex
|
||||
DoubleArrowTkn *token.Token
|
||||
Val Vertex
|
||||
}
|
||||
|
||||
|
@ -620,11 +620,6 @@ func (v *Dump) ExprArrayItem(n *ast.ExprArrayItem) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ExprArrayItem{\n")
|
||||
v.printNode(n.GetNode())
|
||||
|
||||
if n.Unpack {
|
||||
v.printIndent(v.indent)
|
||||
v.print("Unpack: true,\n")
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Dump) ExprArrowFunction(n *ast.ExprArrowFunction) {
|
||||
|
@ -1369,7 +1369,7 @@ func (p *Printer) printExprArrayItem(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprArrayItem)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
if nn.Unpack {
|
||||
if nn.EllipsisTkn != nil {
|
||||
p.write([]byte("..."))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user