[refactoring] update ast structure of "BitwiseNot", "BooleanNot", "ClassConstFetch" and "Clone" nodes

This commit is contained in:
Vadym Slizov 2020-12-01 09:51:47 +02:00
parent 4b8d431767
commit b90400d993
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
5 changed files with 142 additions and 145 deletions

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -3220,13 +3220,13 @@ expr_without_variable:
} }
| T_CLONE expr | T_CLONE expr
{ {
$$ = &ast.ExprClone{ast.Node{}, $2} $$ = &ast.ExprClone{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
CloneTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| variable T_PLUS_EQUAL expr | variable T_PLUS_EQUAL expr
{ {
@ -3609,23 +3609,23 @@ expr_without_variable:
} }
| '!' expr | '!' expr
{ {
$$ = &ast.ExprBooleanNot{ast.Node{}, $2} $$ = &ast.ExprBooleanNot{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
ExclamationTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| '~' expr | '~' expr
{ {
$$ = &ast.ExprBitwiseNot{ast.Node{}, $2} $$ = &ast.ExprBitwiseNot{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
TildaTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| expr T_IS_IDENTICAL expr | expr T_IS_IDENTICAL expr
{ {
@ -4665,21 +4665,20 @@ common_scalar:
static_class_constant: static_class_constant:
class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
; ;
@ -4867,23 +4866,23 @@ static_operation:
} }
| '!' static_scalar_value | '!' static_scalar_value
{ {
$$ = &ast.ExprBooleanNot{ast.Node{}, $2} $$ = &ast.ExprBooleanNot{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
ExclamationTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| '~' static_scalar_value | '~' static_scalar_value
{ {
$$ = &ast.ExprBitwiseNot{ast.Node{}, $2} $$ = &ast.ExprBitwiseNot{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
TildaTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| static_scalar_value '|' static_scalar_value | static_scalar_value '|' static_scalar_value
{ {
@ -6445,81 +6444,77 @@ isset_variable:
class_constant: class_constant:
class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
; ;
static_class_name_scalar: static_class_name_scalar:
class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
; ;
class_name_scalar: class_name_scalar:
class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
; ;

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -2866,13 +2866,13 @@ expr_without_variable:
} }
| T_CLONE expr | T_CLONE expr
{ {
$$ = &ast.ExprClone{ast.Node{}, $2} $$ = &ast.ExprClone{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
CloneTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| variable T_PLUS_EQUAL expr | variable T_PLUS_EQUAL expr
{ {
@ -3267,23 +3267,23 @@ expr_without_variable:
} }
| '!' expr | '!' expr
{ {
$$ = &ast.ExprBooleanNot{ast.Node{}, $2} $$ = &ast.ExprBooleanNot{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
ExclamationTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| '~' expr | '~' expr
{ {
$$ = &ast.ExprBitwiseNot{ast.Node{}, $2} $$ = &ast.ExprBitwiseNot{
Node: ast.Node{
// save position Position: position.NewTokenNodePosition($1, $2),
$$.GetNode().Position = position.NewTokenNodePosition($1, $2) },
TildaTkn: $1,
// save comments Expr: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| expr T_IS_IDENTICAL expr | expr T_IS_IDENTICAL expr
{ {
@ -4112,39 +4112,37 @@ constant:
} }
| class_name T_PAAMAYIM_NEKUDOTAYIM identifier | class_name T_PAAMAYIM_NEKUDOTAYIM identifier
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier | variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier
{ {
target := &ast.Identifier{ $$ = &ast.ExprClassConstFetch{
Node: ast.Node{
Position: position.NewNodeTokenPosition($1, $3),
},
Class: $1,
DoubleColonTkn: $2,
ConstantName: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: position.NewTokenPosition($3), Position: position.NewTokenPosition($3),
}, },
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
},
} }
$$ = &ast.ExprClassConstFetch{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)
} }
; ;

View File

@ -1000,6 +1000,7 @@ func (n *ExprArrowFunction) Accept(v NodeVisitor) {
// ExprBitwiseNot node // ExprBitwiseNot node
type ExprBitwiseNot struct { type ExprBitwiseNot struct {
Node Node
TildaTkn *token.Token
Expr Vertex Expr Vertex
} }
@ -1010,6 +1011,7 @@ func (n *ExprBitwiseNot) Accept(v NodeVisitor) {
// ExprBooleanNot node // ExprBooleanNot node
type ExprBooleanNot struct { type ExprBooleanNot struct {
Node Node
ExclamationTkn *token.Token
Expr Vertex Expr Vertex
} }
@ -1021,6 +1023,7 @@ func (n *ExprBooleanNot) Accept(v NodeVisitor) {
type ExprClassConstFetch struct { type ExprClassConstFetch struct {
Node Node
Class Vertex Class Vertex
DoubleColonTkn *token.Token
ConstantName Vertex ConstantName Vertex
} }
@ -1031,6 +1034,7 @@ func (n *ExprClassConstFetch) Accept(v NodeVisitor) {
// ExprClone node // ExprClone node
type ExprClone struct { type ExprClone struct {
Node Node
CloneTkn *token.Token
Expr Vertex Expr Vertex
} }