[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
|
| T_INT_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastInt{ast.Node{}, $2}
|
$$ = &ast.ExprCastInt{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_DOUBLE_CAST expr
|
| T_DOUBLE_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastDouble{ast.Node{}, $2}
|
$$ = &ast.ExprCastDouble{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_STRING_CAST expr
|
| T_STRING_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastString{ast.Node{}, $2}
|
$$ = &ast.ExprCastString{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_ARRAY_CAST expr
|
| T_ARRAY_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastArray{ast.Node{}, $2}
|
$$ = &ast.ExprCastArray{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_OBJECT_CAST expr
|
| T_OBJECT_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastObject{ast.Node{}, $2}
|
$$ = &ast.ExprCastObject{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_BOOL_CAST expr
|
| T_BOOL_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastBool{ast.Node{}, $2}
|
$$ = &ast.ExprCastBool{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_UNSET_CAST expr
|
| T_UNSET_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastUnset{ast.Node{}, $2}
|
$$ = &ast.ExprCastUnset{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_EXIT exit_expr
|
| T_EXIT exit_expr
|
||||||
{
|
{
|
||||||
@ -3936,13 +3929,12 @@ expr_without_variable:
|
|||||||
}
|
}
|
||||||
| T_YIELD
|
| T_YIELD
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, nil, nil}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenPosition($1),
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
}
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||||
{
|
{
|
||||||
@ -3984,45 +3976,47 @@ expr_without_variable:
|
|||||||
yield_expr:
|
yield_expr:
|
||||||
T_YIELD expr_without_variable
|
T_YIELD expr_without_variable
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, nil, $2}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
Value: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_YIELD variable
|
| T_YIELD variable
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, nil, $2}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
Value: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable
|
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, $2, $4}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $4),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
Key: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
DoubleArrowTkn: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
Value: $4,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_YIELD expr T_DOUBLE_ARROW variable
|
| T_YIELD expr T_DOUBLE_ARROW variable
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, $2, $4}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $4),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
Key: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
DoubleArrowTkn: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
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
|
| T_INT_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastInt{ast.Node{}, $2}
|
$$ = &ast.ExprCastInt{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_DOUBLE_CAST expr
|
| T_DOUBLE_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastDouble{ast.Node{}, $2}
|
$$ = &ast.ExprCastDouble{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_STRING_CAST expr
|
| T_STRING_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastString{ast.Node{}, $2}
|
$$ = &ast.ExprCastString{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_ARRAY_CAST expr
|
| T_ARRAY_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastArray{ast.Node{}, $2}
|
$$ = &ast.ExprCastArray{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_OBJECT_CAST expr
|
| T_OBJECT_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastObject{ast.Node{}, $2}
|
$$ = &ast.ExprCastObject{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_BOOL_CAST expr
|
| T_BOOL_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastBool{ast.Node{}, $2}
|
$$ = &ast.ExprCastBool{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_UNSET_CAST expr
|
| T_UNSET_CAST expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprCastUnset{ast.Node{}, $2}
|
$$ = &ast.ExprCastUnset{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
CastTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.Cast, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_EXIT exit_expr
|
| T_EXIT exit_expr
|
||||||
{
|
{
|
||||||
@ -3584,44 +3577,44 @@ expr_without_variable:
|
|||||||
}
|
}
|
||||||
| T_YIELD
|
| T_YIELD
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, nil, nil}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenPosition($1),
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
}
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_YIELD expr
|
| T_YIELD expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, nil, $2}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
Value: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_YIELD expr T_DOUBLE_ARROW expr
|
| T_YIELD expr T_DOUBLE_ARROW expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYield{ast.Node{}, $2, $4}
|
$$ = &ast.ExprYield{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $4),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
},
|
||||||
|
YieldTkn: $1,
|
||||||
// save comments
|
Key: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
DoubleArrowTkn: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
Value: $4,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_YIELD_FROM expr
|
| T_YIELD_FROM expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprYieldFrom{ast.Node{}, $2}
|
$$ = &ast.ExprYieldFrom{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $2),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
},
|
||||||
|
YieldFromTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| inline_function
|
| inline_function
|
||||||
{
|
{
|
||||||
|
@ -1428,7 +1428,9 @@ func (n *ExprVariable) Accept(v NodeVisitor) {
|
|||||||
// ExprYield node
|
// ExprYield node
|
||||||
type ExprYield struct {
|
type ExprYield struct {
|
||||||
Node
|
Node
|
||||||
|
YieldTkn *token.Token
|
||||||
Key Vertex
|
Key Vertex
|
||||||
|
DoubleArrowTkn *token.Token
|
||||||
Value Vertex
|
Value Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1439,6 +1441,7 @@ func (n *ExprYield) Accept(v NodeVisitor) {
|
|||||||
// ExprYieldFrom node
|
// ExprYieldFrom node
|
||||||
type ExprYieldFrom struct {
|
type ExprYieldFrom struct {
|
||||||
Node
|
Node
|
||||||
|
YieldFromTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1449,6 +1452,7 @@ func (n *ExprYieldFrom) Accept(v NodeVisitor) {
|
|||||||
// ExprCastArray node
|
// ExprCastArray node
|
||||||
type ExprCastArray struct {
|
type ExprCastArray struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1459,6 +1463,7 @@ func (n *ExprCastArray) Accept(v NodeVisitor) {
|
|||||||
// ExprCastBool node
|
// ExprCastBool node
|
||||||
type ExprCastBool struct {
|
type ExprCastBool struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,6 +1474,7 @@ func (n *ExprCastBool) Accept(v NodeVisitor) {
|
|||||||
// ExprCastDouble node
|
// ExprCastDouble node
|
||||||
type ExprCastDouble struct {
|
type ExprCastDouble struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1479,6 +1485,7 @@ func (n *ExprCastDouble) Accept(v NodeVisitor) {
|
|||||||
// ExprCastInt node
|
// ExprCastInt node
|
||||||
type ExprCastInt struct {
|
type ExprCastInt struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,6 +1496,7 @@ func (n *ExprCastInt) Accept(v NodeVisitor) {
|
|||||||
// ExprCastObject node
|
// ExprCastObject node
|
||||||
type ExprCastObject struct {
|
type ExprCastObject struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1499,6 +1507,7 @@ func (n *ExprCastObject) Accept(v NodeVisitor) {
|
|||||||
// ExprCastString node
|
// ExprCastString node
|
||||||
type ExprCastString struct {
|
type ExprCastString struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1509,6 +1518,7 @@ func (n *ExprCastString) Accept(v NodeVisitor) {
|
|||||||
// ExprCastUnset node
|
// ExprCastUnset node
|
||||||
type ExprCastUnset struct {
|
type ExprCastUnset struct {
|
||||||
Node
|
Node
|
||||||
|
CastTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user