[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,8 +1428,10 @@ func (n *ExprVariable) Accept(v NodeVisitor) {
|
||||
// ExprYield node
|
||||
type ExprYield struct {
|
||||
Node
|
||||
Key Vertex
|
||||
Value Vertex
|
||||
YieldTkn *token.Token
|
||||
Key Vertex
|
||||
DoubleArrowTkn *token.Token
|
||||
Value Vertex
|
||||
}
|
||||
|
||||
func (n *ExprYield) Accept(v NodeVisitor) {
|
||||
@ -1439,7 +1441,8 @@ func (n *ExprYield) Accept(v NodeVisitor) {
|
||||
// ExprYieldFrom node
|
||||
type ExprYieldFrom struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
YieldFromTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprYieldFrom) Accept(v NodeVisitor) {
|
||||
@ -1449,7 +1452,8 @@ func (n *ExprYieldFrom) Accept(v NodeVisitor) {
|
||||
// ExprCastArray node
|
||||
type ExprCastArray struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastArray) Accept(v NodeVisitor) {
|
||||
@ -1459,7 +1463,8 @@ func (n *ExprCastArray) Accept(v NodeVisitor) {
|
||||
// ExprCastBool node
|
||||
type ExprCastBool struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastBool) Accept(v NodeVisitor) {
|
||||
@ -1469,7 +1474,8 @@ func (n *ExprCastBool) Accept(v NodeVisitor) {
|
||||
// ExprCastDouble node
|
||||
type ExprCastDouble struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastDouble) Accept(v NodeVisitor) {
|
||||
@ -1479,7 +1485,8 @@ func (n *ExprCastDouble) Accept(v NodeVisitor) {
|
||||
// ExprCastInt node
|
||||
type ExprCastInt struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastInt) Accept(v NodeVisitor) {
|
||||
@ -1489,7 +1496,8 @@ func (n *ExprCastInt) Accept(v NodeVisitor) {
|
||||
// ExprCastObject node
|
||||
type ExprCastObject struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastObject) Accept(v NodeVisitor) {
|
||||
@ -1499,7 +1507,8 @@ func (n *ExprCastObject) Accept(v NodeVisitor) {
|
||||
// ExprCastString node
|
||||
type ExprCastString struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastString) Accept(v NodeVisitor) {
|
||||
@ -1509,7 +1518,8 @@ func (n *ExprCastString) Accept(v NodeVisitor) {
|
||||
// ExprCastUnset node
|
||||
type ExprCastUnset struct {
|
||||
Node
|
||||
Expr Vertex
|
||||
CastTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
func (n *ExprCastUnset) Accept(v NodeVisitor) {
|
||||
|
Loading…
Reference in New Issue
Block a user