[refactoring] update "ParserBrackets" nodes

This commit is contained in:
Vadym Slizov 2020-12-04 12:58:56 +02:00
parent ea3c5298e2
commit af968a7c3b
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
2 changed files with 41 additions and 58 deletions

View File

@ -3691,11 +3691,14 @@ expr_without_variable:
} }
| '(' new_expr ')' instance_call | '(' new_expr ')' instance_call
{ {
$$ = $2 $$ = &ast.ParserBrackets{
Node: ast.Node{
// save comments Position: position.NewTokensPosition($1, $3),
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.SkippedTokens, $$.GetNode().Tokens[token.Start]...)) },
yylex.(*Parser).setFreeFloatingTokens($$, token.End, append($$.GetNode().Tokens[token.End], $3.SkippedTokens...)) OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
}
for _, n := range($4) { for _, n := range($4) {
switch nn := n.(type) { switch nn := n.(type) {
@ -4405,8 +4408,7 @@ dynamic_class_name_reference:
{ {
$$ = $1 $$ = $1
// save comments $3[0].(*ast.ExprPropertyFetch).ObjectOperatorTkn = $2
yylex.(*Parser).setFreeFloating($3[0], token.Var, $2.SkippedTokens)
for _, n := range($3) { for _, n := range($3) {
switch nn := n.(type) { switch nn := n.(type) {
@ -4482,10 +4484,6 @@ exit_expr:
OpenBracketTkn: $1, OpenBracketTkn: $1,
CloseBracketTkn: $2, CloseBracketTkn: $2,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $2.SkippedTokens)
} }
| parenthesis_expr | parenthesis_expr
{ {
@ -5141,11 +5139,14 @@ static_operation:
} }
| '(' static_scalar_value ')' | '(' static_scalar_value ')'
{ {
$$ = $2 $$ = &ast.ParserBrackets{
Node: ast.Node{
// save comments Position: position.NewTokensPosition($1, $3),
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.SkippedTokens, $$.GetNode().Tokens[token.Start]...)) },
yylex.(*Parser).setFreeFloatingTokens($$, token.End, append($$.GetNode().Tokens[token.End], $3.SkippedTokens...)) OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
}
} }
; ;
@ -5373,10 +5374,6 @@ parenthesis_expr:
Child: $2, Child: $2,
CloseBracketTkn: $3, CloseBracketTkn: $3,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
} }
| '(' yield_expr ')' | '(' yield_expr ')'
{ {
@ -5388,10 +5385,6 @@ parenthesis_expr:
Child: $2, Child: $2,
CloseBracketTkn: $3, CloseBracketTkn: $3,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
} }
; ;
@ -5872,14 +5865,14 @@ variable_name:
} }
| '{' expr '}' | '{' expr '}'
{ {
$$ = $2 $$ = &ast.ParserBrackets{
Node: ast.Node{
// save position Position: position.NewTokensPosition($1, $3),
$$.GetNode().Position = position.NewTokensPosition($1, $3) },
OpenBracketTkn: $1,
// save comments Child: $2,
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.SkippedTokens, $$.GetNode().Tokens[token.Start]...)) CloseBracketTkn: $3,
yylex.(*Parser).setFreeFloatingTokens($$, token.End, append($$.GetNode().Tokens[token.End], $3.SkippedTokens...)) }
} }
; ;

View File

@ -3371,10 +3371,6 @@ expr_without_variable:
Child: $2, Child: $2,
CloseBracketTkn: $3, CloseBracketTkn: $3,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
} }
| new_expr | new_expr
{ {
@ -3835,10 +3831,6 @@ exit_expr:
Child: $2, Child: $2,
CloseBracketTkn: $3, CloseBracketTkn: $3,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
} }
; ;
@ -4166,10 +4158,6 @@ dereferencable:
Child: $2, Child: $2,
CloseBracketTkn: $3, CloseBracketTkn: $3,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
} }
| dereferencable_scalar | dereferencable_scalar
{ {
@ -4192,10 +4180,6 @@ callable_expr:
Child: $2, Child: $2,
CloseBracketTkn: $3, CloseBracketTkn: $3,
} }
// save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
} }
| dereferencable_scalar | dereferencable_scalar
{ {
@ -4434,11 +4418,14 @@ member_name:
} }
| '{' expr '}' | '{' expr '}'
{ {
$$ = $2; $$ = &ast.ParserBrackets{
Node: ast.Node{
// save comments Position: position.NewTokensPosition($1, $3),
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.SkippedTokens, $$.GetNode().Tokens[token.Start]...)) },
yylex.(*Parser).setFreeFloatingTokens($$, token.End, append($$.GetNode().Tokens[token.End], $3.SkippedTokens...)) OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
}
} }
| simple_variable | simple_variable
{ {
@ -4459,11 +4446,14 @@ property_name:
} }
| '{' expr '}' | '{' expr '}'
{ {
$$ = $2; $$ = &ast.ParserBrackets{
Node: ast.Node{
// save comments Position: position.NewTokensPosition($1, $3),
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.SkippedTokens, $$.GetNode().Tokens[token.Start]...)) },
yylex.(*Parser).setFreeFloatingTokens($$, token.End, append($$.GetNode().Tokens[token.End], $3.SkippedTokens...)) OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
}
} }
| simple_variable | simple_variable
{ {