[refactoring] update ast structure of "StmtPropertyList", "StmtTraitAdaptationList", "StmtTraitMethodRef" and "StmtTraitUseAlias" nodes
This commit is contained in:
parent
5bd63d90ba
commit
43f6fab862
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -237,7 +237,7 @@ import (
|
|||||||
%type <node> trait_use_statement function_call_parameter trait_adaptation_statement trait_precedence trait_alias
|
%type <node> trait_use_statement function_call_parameter trait_adaptation_statement trait_precedence trait_alias
|
||||||
%type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method
|
%type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method
|
||||||
%type <node> static_scalar_value static_operation static_var_list global_var_list
|
%type <node> static_scalar_value static_operation static_var_list global_var_list
|
||||||
%type <node> ctor_arguments function_call_parameter_list echo_expr_list
|
%type <node> ctor_arguments function_call_parameter_list echo_expr_list class_variable_declaration
|
||||||
%type <node> trait_adaptations unset_variables declare_list
|
%type <node> trait_adaptations unset_variables declare_list
|
||||||
%type <node> switch_case_list non_empty_function_call_parameter_list
|
%type <node> switch_case_list non_empty_function_call_parameter_list
|
||||||
%type <node> method_body trait_reference_list
|
%type <node> method_body trait_reference_list
|
||||||
@ -253,7 +253,7 @@ import (
|
|||||||
%type <list> array_pair_list assignment_list lexical_var_list elseif_list new_elseif_list non_empty_for_expr
|
%type <list> array_pair_list assignment_list lexical_var_list elseif_list new_elseif_list non_empty_for_expr
|
||||||
%type <list> for_expr case_list catch_statement additional_catches
|
%type <list> for_expr case_list catch_statement additional_catches
|
||||||
%type <list> non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list
|
%type <list> non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list
|
||||||
%type <list> class_statement_list variable_modifiers method_modifiers class_variable_declaration
|
%type <list> class_statement_list variable_modifiers method_modifiers
|
||||||
%type <list> trait_adaptation_list non_empty_trait_adaptation_list
|
%type <list> trait_adaptation_list non_empty_trait_adaptation_list
|
||||||
%type <list> non_empty_member_modifiers backticks_expr static_array_pair_list non_empty_static_array_pair_list
|
%type <list> non_empty_member_modifiers backticks_expr static_array_pair_list non_empty_static_array_pair_list
|
||||||
|
|
||||||
@ -2456,15 +2456,15 @@ class_statement_list:
|
|||||||
class_statement:
|
class_statement:
|
||||||
variable_modifiers class_variable_declaration ';'
|
variable_modifiers class_variable_declaration ';'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtPropertyList{ast.Node{}, $1, nil, $2}
|
$$ = &ast.StmtPropertyList{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewNodeListTokenPosition($1, $3),
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
},
|
||||||
|
Modifiers: $1,
|
||||||
// save comments
|
Properties: $2.(*ast.ParserSeparatedList).Items,
|
||||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.PropertyList, $3.SkippedTokens)
|
SemiColonTkn: $3,
|
||||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| class_constant_declaration ';'
|
| class_constant_declaration ';'
|
||||||
{
|
{
|
||||||
@ -2548,13 +2548,14 @@ trait_adaptations:
|
|||||||
}
|
}
|
||||||
| '{' trait_adaptation_list '}'
|
| '{' trait_adaptation_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitAdaptationList{ast.Node{}, $2}
|
$$ = &ast.StmtTraitAdaptationList{
|
||||||
|
Node: ast.Node{
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
Position: position.NewTokensPosition($1, $3),
|
||||||
|
},
|
||||||
// save comments
|
OpenParenthesisTkn: $1,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
Adaptations: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.AdaptationList, $3.SkippedTokens)
|
CloseParenthesisTkn: $3,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2633,20 +2634,18 @@ trait_reference_list:
|
|||||||
trait_method_reference:
|
trait_method_reference:
|
||||||
T_STRING
|
T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.Identifier{
|
$$ = &ast.StmtTraitMethodRef{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($1),
|
Position: position.NewTokenPosition($1),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $1,
|
Method: &ast.Identifier{
|
||||||
Value: $1.Value,
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($1),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $1,
|
||||||
|
Value: $1.Value,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitMethodRef{ast.Node{}, nil, name}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| trait_method_reference_fully_qualified
|
| trait_method_reference_fully_qualified
|
||||||
{
|
{
|
||||||
@ -2657,53 +2656,52 @@ trait_method_reference:
|
|||||||
trait_method_reference_fully_qualified:
|
trait_method_reference_fully_qualified:
|
||||||
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
|
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
|
||||||
{
|
{
|
||||||
target := &ast.Identifier{
|
$$ = &ast.StmtTraitMethodRef{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewNodeTokenPosition($1, $3),
|
||||||
|
},
|
||||||
|
Trait: $1,
|
||||||
|
DoubleColonTkn: $2,
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $3,
|
||||||
|
Value: $3.Value,
|
||||||
},
|
},
|
||||||
IdentifierTkn: $3,
|
|
||||||
Value: $3.Value,
|
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitMethodRef{ast.Node{}, $1, target}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $3)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Name, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
trait_alias:
|
trait_alias:
|
||||||
trait_method_reference T_AS trait_modifiers T_STRING
|
trait_method_reference T_AS trait_modifiers T_STRING
|
||||||
{
|
{
|
||||||
alias := &ast.Identifier{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($4),
|
Position: position.NewNodeTokenPosition($1, $4),
|
||||||
|
},
|
||||||
|
Ref: $1,
|
||||||
|
AsTkn: $2,
|
||||||
|
Modifier: $3,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($4),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $4,
|
||||||
|
Value: $4.Value,
|
||||||
},
|
},
|
||||||
IdentifierTkn: $4,
|
|
||||||
Value: $4.Value,
|
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitUseAlias{ast.Node{}, $1, $3, alias}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ref, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| trait_method_reference T_AS member_modifier
|
| trait_method_reference T_AS member_modifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{ast.Node{}, $1, $3, nil}
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewNodesPosition($1, $3),
|
||||||
$$.GetNode().Position = position.NewNodesPosition($1, $3)
|
},
|
||||||
|
Ref: $1,
|
||||||
// save comments
|
AsTkn: $2,
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
Modifier: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ref, $2.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2848,7 +2846,7 @@ member_modifier:
|
|||||||
class_variable_declaration:
|
class_variable_declaration:
|
||||||
class_variable_declaration ',' T_VARIABLE
|
class_variable_declaration ',' T_VARIABLE
|
||||||
{
|
{
|
||||||
$$ = append($1, &ast.StmtProperty{
|
item := &ast.StmtProperty{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewTokenPosition($3),
|
||||||
},
|
},
|
||||||
@ -2864,11 +2862,16 @@ class_variable_declaration:
|
|||||||
Value: $3.Value,
|
Value: $3.Value,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
|
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||||
|
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, item)
|
||||||
|
|
||||||
|
$$ = $1
|
||||||
}
|
}
|
||||||
| class_variable_declaration ',' T_VARIABLE '=' static_scalar
|
| class_variable_declaration ',' T_VARIABLE '=' static_scalar
|
||||||
{
|
{
|
||||||
$$ = append($1, &ast.StmtProperty{
|
item := &ast.StmtProperty{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenNodePosition($3, $5),
|
Position: position.NewTokenNodePosition($3, $5),
|
||||||
},
|
},
|
||||||
@ -2886,52 +2889,61 @@ class_variable_declaration:
|
|||||||
},
|
},
|
||||||
EqualTkn: $4,
|
EqualTkn: $4,
|
||||||
Expr: $5,
|
Expr: $5,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||||
|
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, item)
|
||||||
|
|
||||||
|
$$ = $1
|
||||||
}
|
}
|
||||||
| T_VARIABLE
|
| T_VARIABLE
|
||||||
{
|
{
|
||||||
$$ = []ast.Vertex{
|
$$ = &ast.ParserSeparatedList{
|
||||||
&ast.StmtProperty{
|
Items: []ast.Vertex{
|
||||||
Node: ast.Node{
|
&ast.StmtProperty{
|
||||||
Position: position.NewTokenPosition($1),
|
|
||||||
},
|
|
||||||
Var: &ast.ExprVariable{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($1),
|
Position: position.NewTokenPosition($1),
|
||||||
},
|
},
|
||||||
VarName: &ast.Identifier{
|
Var: &ast.ExprVariable{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($1),
|
Position: position.NewTokenPosition($1),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $1,
|
VarName: &ast.Identifier{
|
||||||
Value: $1.Value,
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($1),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $1,
|
||||||
|
Value: $1.Value,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
Expr: nil,
|
||||||
},
|
},
|
||||||
Expr: nil,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| T_VARIABLE '=' static_scalar
|
| T_VARIABLE '=' static_scalar
|
||||||
{
|
{
|
||||||
$$ = []ast.Vertex{
|
$$ = &ast.ParserSeparatedList{
|
||||||
&ast.StmtProperty{
|
Items: []ast.Vertex{
|
||||||
Node: ast.Node{
|
&ast.StmtProperty{
|
||||||
Position: position.NewTokenNodePosition($1, $3),
|
|
||||||
},
|
|
||||||
Var: &ast.ExprVariable{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($1),
|
Position: position.NewTokenNodePosition($1, $3),
|
||||||
},
|
},
|
||||||
VarName: &ast.Identifier{
|
Var: &ast.ExprVariable{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($1),
|
Position: position.NewTokenPosition($1),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $1,
|
VarName: &ast.Identifier{
|
||||||
Value: $1.Value,
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($1),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $1,
|
||||||
|
Value: $1.Value,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
EqualTkn: $2,
|
||||||
|
Expr: $3,
|
||||||
},
|
},
|
||||||
EqualTkn: $2,
|
|
||||||
Expr: $3,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -247,7 +247,7 @@ import (
|
|||||||
%type <node> variable_class_name dereferencable_scalar constant dereferencable
|
%type <node> variable_class_name dereferencable_scalar constant dereferencable
|
||||||
%type <node> callable_expr callable_variable static_member new_variable
|
%type <node> callable_expr callable_variable static_member new_variable
|
||||||
%type <node> encaps_var encaps_var_offset echo_expr_list catch_name_list name_list
|
%type <node> encaps_var encaps_var_offset echo_expr_list catch_name_list name_list
|
||||||
%type <node> if_stmt const_list non_empty_argument_list
|
%type <node> if_stmt const_list non_empty_argument_list property_list
|
||||||
%type <node> alt_if_stmt
|
%type <node> alt_if_stmt
|
||||||
%type <node> if_stmt_without_else
|
%type <node> if_stmt_without_else
|
||||||
%type <node> class_const_decl
|
%type <node> class_const_decl
|
||||||
@ -274,7 +274,7 @@ import (
|
|||||||
|
|
||||||
%type <list> encaps_list backticks_expr namespace_name catch_list class_const_list
|
%type <list> encaps_list backticks_expr namespace_name catch_list class_const_list
|
||||||
%type <list> for_exprs non_empty_for_exprs
|
%type <list> for_exprs non_empty_for_exprs
|
||||||
%type <list> unprefixed_use_declarations inline_use_declarations property_list
|
%type <list> unprefixed_use_declarations inline_use_declarations
|
||||||
%type <list> case_list trait_adaptation_list
|
%type <list> case_list trait_adaptation_list
|
||||||
%type <list> use_declarations lexical_var_list isset_variables non_empty_array_pair_list
|
%type <list> use_declarations lexical_var_list isset_variables non_empty_array_pair_list
|
||||||
%type <list> array_pair_list top_statement_list
|
%type <list> array_pair_list top_statement_list
|
||||||
@ -2193,15 +2193,16 @@ class_statement_list:
|
|||||||
class_statement:
|
class_statement:
|
||||||
variable_modifiers optional_type property_list ';'
|
variable_modifiers optional_type property_list ';'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtPropertyList{ast.Node{}, $1, $2, $3}
|
$$ = &ast.StmtPropertyList{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewNodeListTokenPosition($1, $4),
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $4)
|
},
|
||||||
|
Modifiers: $1,
|
||||||
// save comments
|
Type: $2,
|
||||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
Properties: $3.(*ast.ParserSeparatedList).Items,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.PropertyList, $4.SkippedTokens)
|
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.SkippedTokens)
|
SemiColonTkn: $4,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| method_modifiers T_CONST class_const_list ';'
|
| method_modifiers T_CONST class_const_list ';'
|
||||||
{
|
{
|
||||||
@ -2286,23 +2287,24 @@ trait_adaptations:
|
|||||||
}
|
}
|
||||||
| '{' '}'
|
| '{' '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitAdaptationList{ast.Node{}, nil}
|
$$ = &ast.StmtTraitAdaptationList{
|
||||||
|
Node: ast.Node{
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $2)
|
Position: position.NewTokensPosition($1, $2),
|
||||||
|
},
|
||||||
// save comments
|
OpenParenthesisTkn: $1,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
CloseParenthesisTkn: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.AdaptationList, $2.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| '{' trait_adaptation_list '}'
|
| '{' trait_adaptation_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitAdaptationList{ast.Node{}, $2}
|
$$ = &ast.StmtTraitAdaptationList{
|
||||||
|
Node: ast.Node{
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
Position: position.NewTokensPosition($1, $3),
|
||||||
|
},
|
||||||
// save comments
|
OpenParenthesisTkn: $1,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
Adaptations: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.AdaptationList, $3.SkippedTokens)
|
CloseParenthesisTkn: $3,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2354,88 +2356,84 @@ trait_precedence:
|
|||||||
trait_alias:
|
trait_alias:
|
||||||
trait_method_reference T_AS T_STRING
|
trait_method_reference T_AS T_STRING
|
||||||
{
|
{
|
||||||
alias := &ast.Identifier{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewNodeTokenPosition($1, $3),
|
||||||
|
},
|
||||||
|
Ref: $1,
|
||||||
|
AsTkn: $2,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $3,
|
||||||
|
Value: $3.Value,
|
||||||
},
|
},
|
||||||
IdentifierTkn: $3,
|
|
||||||
Value: $3.Value,
|
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitUseAlias{ast.Node{}, $1, nil, alias}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $3)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ref, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| trait_method_reference T_AS reserved_non_modifiers
|
| trait_method_reference T_AS reserved_non_modifiers
|
||||||
{
|
{
|
||||||
alias := &ast.Identifier{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewNodeTokenPosition($1, $3),
|
||||||
|
},
|
||||||
|
Ref: $1,
|
||||||
|
AsTkn: $2,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $3,
|
||||||
|
Value: $3.Value,
|
||||||
},
|
},
|
||||||
IdentifierTkn: $3,
|
|
||||||
Value: $3.Value,
|
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitUseAlias{ast.Node{}, $1, nil, alias}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $3)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ref, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| trait_method_reference T_AS member_modifier identifier
|
| trait_method_reference T_AS member_modifier identifier
|
||||||
{
|
{
|
||||||
alias := &ast.Identifier{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($4),
|
Position: position.NewNodeTokenPosition($1, $4),
|
||||||
|
},
|
||||||
|
Ref: $1,
|
||||||
|
AsTkn: $2,
|
||||||
|
Modifier: $3,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($4),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $4,
|
||||||
|
Value: $4.Value,
|
||||||
},
|
},
|
||||||
IdentifierTkn: $4,
|
|
||||||
Value: $4.Value,
|
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitUseAlias{ast.Node{}, $1, $3, alias}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ref, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| trait_method_reference T_AS member_modifier
|
| trait_method_reference T_AS member_modifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{ast.Node{}, $1, $3, nil}
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewNodesPosition($1, $3),
|
||||||
$$.GetNode().Position = position.NewNodesPosition($1, $3)
|
},
|
||||||
|
Ref: $1,
|
||||||
// save comments
|
AsTkn: $2,
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
Modifier: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ref, $2.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
trait_method_reference:
|
trait_method_reference:
|
||||||
identifier
|
identifier
|
||||||
{
|
{
|
||||||
name := &ast.Identifier{
|
$$ = &ast.StmtTraitMethodRef{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($1),
|
Position: position.NewTokenPosition($1),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $1,
|
Method: &ast.Identifier{
|
||||||
Value: $1.Value,
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($1),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $1,
|
||||||
|
Value: $1.Value,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitMethodRef{ast.Node{}, nil, name}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| absolute_trait_method_reference
|
| absolute_trait_method_reference
|
||||||
{
|
{
|
||||||
@ -2446,21 +2444,20 @@ trait_method_reference:
|
|||||||
absolute_trait_method_reference:
|
absolute_trait_method_reference:
|
||||||
name T_PAAMAYIM_NEKUDOTAYIM identifier
|
name T_PAAMAYIM_NEKUDOTAYIM identifier
|
||||||
{
|
{
|
||||||
target := &ast.Identifier{
|
$$ = &ast.StmtTraitMethodRef{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewNodeTokenPosition($1, $3),
|
||||||
|
},
|
||||||
|
Trait: $1,
|
||||||
|
DoubleColonTkn: $2,
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
IdentifierTkn: $3,
|
||||||
|
Value: $3.Value,
|
||||||
},
|
},
|
||||||
IdentifierTkn: $3,
|
|
||||||
Value: $3.Value,
|
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtTraitMethodRef{ast.Node{}, $1, target}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $3)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1, $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Name, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2594,14 +2591,16 @@ member_modifier:
|
|||||||
property_list:
|
property_list:
|
||||||
property_list ',' property
|
property_list ',' property
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
|
||||||
|
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, $3)
|
||||||
|
|
||||||
// save comments
|
$$ = $1
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| property
|
| property
|
||||||
{
|
{
|
||||||
$$ = []ast.Vertex{$1}
|
$$ = &ast.ParserSeparatedList{
|
||||||
|
Items: []ast.Vertex{$1},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -670,9 +670,11 @@ func (n *StmtProperty) Accept(v NodeVisitor) {
|
|||||||
// StmtPropertyList node
|
// StmtPropertyList node
|
||||||
type StmtPropertyList struct {
|
type StmtPropertyList struct {
|
||||||
Node
|
Node
|
||||||
Modifiers []Vertex
|
Modifiers []Vertex
|
||||||
Type Vertex
|
Type Vertex
|
||||||
Properties []Vertex
|
Properties []Vertex
|
||||||
|
SeparatorTkns []*token.Token
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtPropertyList) Accept(v NodeVisitor) {
|
func (n *StmtPropertyList) Accept(v NodeVisitor) {
|
||||||
@ -780,7 +782,9 @@ func (n *StmtTrait) Accept(v NodeVisitor) {
|
|||||||
// StmtTraitAdaptationList node
|
// StmtTraitAdaptationList node
|
||||||
type StmtTraitAdaptationList struct {
|
type StmtTraitAdaptationList struct {
|
||||||
Node
|
Node
|
||||||
Adaptations []Vertex
|
OpenParenthesisTkn *token.Token
|
||||||
|
Adaptations []Vertex
|
||||||
|
CloseParenthesisTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtTraitAdaptationList) Accept(v NodeVisitor) {
|
func (n *StmtTraitAdaptationList) Accept(v NodeVisitor) {
|
||||||
@ -790,8 +794,9 @@ func (n *StmtTraitAdaptationList) Accept(v NodeVisitor) {
|
|||||||
// StmtTraitMethodRef node
|
// StmtTraitMethodRef node
|
||||||
type StmtTraitMethodRef struct {
|
type StmtTraitMethodRef struct {
|
||||||
Node
|
Node
|
||||||
Trait Vertex
|
Trait Vertex
|
||||||
Method Vertex
|
DoubleColonTkn *token.Token
|
||||||
|
Method Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtTraitMethodRef) Accept(v NodeVisitor) {
|
func (n *StmtTraitMethodRef) Accept(v NodeVisitor) {
|
||||||
@ -815,6 +820,7 @@ func (n *StmtTraitUse) Accept(v NodeVisitor) {
|
|||||||
type StmtTraitUseAlias struct {
|
type StmtTraitUseAlias struct {
|
||||||
Node
|
Node
|
||||||
Ref Vertex
|
Ref Vertex
|
||||||
|
AsTkn *token.Token
|
||||||
Modifier Vertex
|
Modifier Vertex
|
||||||
Alias Vertex
|
Alias Vertex
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user