[refactoring] update ast structure of "Yield", "YieldFrom" and "Cast" nodes
This commit is contained in:
parent
01d695c416
commit
5a6418e853
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -3799,80 +3799,73 @@ expr_without_variable:
|
||||
}
|
||||
| T_INT_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastInt{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastInt{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_DOUBLE_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastDouble{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastDouble{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_STRING_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastString{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastString{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_ARRAY_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastArray{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastArray{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_OBJECT_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastObject{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastObject{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_BOOL_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastBool{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastBool{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_UNSET_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastUnset{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastUnset{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_EXIT exit_expr
|
||||
{
|
||||
@ -3936,13 +3929,12 @@ expr_without_variable:
|
||||
}
|
||||
| T_YIELD
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, nil, nil}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
}
|
||||
}
|
||||
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||
{
|
||||
@ -3984,45 +3976,47 @@ expr_without_variable:
|
||||
yield_expr:
|
||||
T_YIELD expr_without_variable
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, nil, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
Value: $2,
|
||||
}
|
||||
}
|
||||
| T_YIELD variable
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, nil, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
Value: $2,
|
||||
}
|
||||
}
|
||||
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, $2, $4}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $4),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
Key: $2,
|
||||
DoubleArrowTkn: $3,
|
||||
Value: $4,
|
||||
}
|
||||
}
|
||||
| T_YIELD expr T_DOUBLE_ARROW variable
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, $2, $4}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $4),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
Key: $2,
|
||||
DoubleArrowTkn: $3,
|
||||
Value: $4,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -3455,80 +3455,73 @@ expr_without_variable:
|
||||
}
|
||||
| T_INT_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastInt{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastInt{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_DOUBLE_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastDouble{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastDouble{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_STRING_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastString{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastString{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_ARRAY_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastArray{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastArray{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_OBJECT_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastObject{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastObject{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_BOOL_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastBool{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastBool{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_UNSET_CAST expr
|
||||
{
|
||||
$$ = &ast.ExprCastUnset{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
||||
$$ = &ast.ExprCastUnset{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
CastTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| T_EXIT exit_expr
|
||||
{
|
||||
@ -3584,44 +3577,44 @@ expr_without_variable:
|
||||
}
|
||||
| T_YIELD
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, nil, nil}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
}
|
||||
}
|
||||
| T_YIELD expr
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, nil, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
Value: $2,
|
||||
}
|
||||
}
|
||||
| T_YIELD expr T_DOUBLE_ARROW expr
|
||||
{
|
||||
$$ = &ast.ExprYield{ast.Node{}, $2, $4}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
||||
$$ = &ast.ExprYield{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $4),
|
||||
},
|
||||
YieldTkn: $1,
|
||||
Key: $2,
|
||||
DoubleArrowTkn: $3,
|
||||
Value: $4,
|
||||
}
|
||||
}
|
||||
| T_YIELD_FROM expr
|
||||
{
|
||||
$$ = &ast.ExprYieldFrom{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprYieldFrom{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
YieldFromTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| inline_function
|
||||
{
|
||||
|
@ -1428,7 +1428,9 @@ func (n *ExprVariable) Accept(v NodeVisitor) {
|
||||
// ExprYield node
|
||||
type ExprYield struct {
|
||||
Node
|
||||
YieldTkn *token.Token
|
||||
Key Vertex
|
||||
DoubleArrowTkn *token.Token
|
||||
Value Vertex
|
||||
}
|
||||
|
||||
@ -1439,6 +1441,7 @@ func (n *ExprYield) Accept(v NodeVisitor) {
|
||||
// ExprYieldFrom node
|
||||
type ExprYieldFrom struct {
|
||||
Node
|
||||
YieldFromTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1449,6 +1452,7 @@ func (n *ExprYieldFrom) Accept(v NodeVisitor) {
|
||||
// ExprCastArray node
|
||||
type ExprCastArray struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1459,6 +1463,7 @@ func (n *ExprCastArray) Accept(v NodeVisitor) {
|
||||
// ExprCastBool node
|
||||
type ExprCastBool struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1469,6 +1474,7 @@ func (n *ExprCastBool) Accept(v NodeVisitor) {
|
||||
// ExprCastDouble node
|
||||
type ExprCastDouble struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1479,6 +1485,7 @@ func (n *ExprCastDouble) Accept(v NodeVisitor) {
|
||||
// ExprCastInt node
|
||||
type ExprCastInt struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1489,6 +1496,7 @@ func (n *ExprCastInt) Accept(v NodeVisitor) {
|
||||
// ExprCastObject node
|
||||
type ExprCastObject struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1499,6 +1507,7 @@ func (n *ExprCastObject) Accept(v NodeVisitor) {
|
||||
// ExprCastString node
|
||||
type ExprCastString struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1509,6 +1518,7 @@ func (n *ExprCastString) Accept(v NodeVisitor) {
|
||||
// ExprCastUnset node
|
||||
type ExprCastUnset struct {
|
||||
Node
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user