[refactoring] update ast structure of "Constant" nodes
This commit is contained in:
@@ -4154,7 +4154,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
|
||||
EndPos: 27,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -4186,7 +4186,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
|
||||
EndPos: 36,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5124,7 +5124,7 @@ func TestStmtConstList(t *testing.T) {
|
||||
EndPos: 16,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5156,7 +5156,7 @@ func TestStmtConstList(t *testing.T) {
|
||||
EndPos: 25,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5451,7 +5451,7 @@ func TestStmtDeclare(t *testing.T) {
|
||||
EndPos: 18,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5530,7 +5530,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
|
||||
EndPos: 18,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5562,7 +5562,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
|
||||
EndPos: 34,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5642,7 +5642,7 @@ func TestStmtDeclare_Alt(t *testing.T) {
|
||||
EndPos: 18,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
|
||||
1207
internal/php5/php5.go
generated
1207
internal/php5/php5.go
generated
File diff suppressed because it is too large
Load Diff
@@ -447,14 +447,9 @@ top_statement:
|
||||
}
|
||||
| constant_declaration ';'
|
||||
{
|
||||
$1.(*ast.StmtConstList).SemiColonTkn = $2
|
||||
$1.(*ast.StmtConstList).Node.Position = position.NewNodeTokenPosition($1, $2)
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $2.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $2.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@@ -725,39 +720,52 @@ use_const_declaration:
|
||||
constant_declaration:
|
||||
constant_declaration ',' T_STRING '=' static_scalar
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
constant := &ast.StmtConstant{ast.Node{}, name, $5}
|
||||
constList := $1.(*ast.StmtConstList)
|
||||
lastConst := lastNode(constList.Consts)
|
||||
constList.Consts = append(constList.Consts, constant)
|
||||
constList.Node.Position = position.NewNodesPosition($1, $5)
|
||||
lastNode(constList.Consts).(*ast.StmtConstant).CommaTkn = $2
|
||||
constList.Consts = append(constList.Consts, &ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $5),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
Value: $3.Value,
|
||||
},
|
||||
EqualTkn: $4,
|
||||
Expr: $5,
|
||||
})
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($3)
|
||||
constant.GetNode().Position = position.NewTokenNodePosition($3, $5)
|
||||
$$.GetNode().Position = position.NewNodeNodeListPosition($1, constList.Consts)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(lastConst, token.End, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Start, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Name, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtConstList).Consts).(*ast.StmtConstant).Name, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
| T_CONST T_STRING '=' static_scalar
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $2.Value}
|
||||
constant := &ast.StmtConstant{ast.Node{}, name, $4}
|
||||
constList := []ast.Vertex{constant}
|
||||
$$ = &ast.StmtConstList{ast.Node{}, constList}
|
||||
$$ = &ast.StmtConstList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $4),
|
||||
},
|
||||
ConstTkn: $1,
|
||||
Consts: []ast.Vertex{
|
||||
&ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($2, $4),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
Value: $2.Value,
|
||||
},
|
||||
EqualTkn: $3,
|
||||
Expr: $4,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($2)
|
||||
constant.GetNode().Position = position.NewTokenNodePosition($2, $4)
|
||||
$$.GetNode().Position = position.NewTokenNodeListPosition($1, constList)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Start, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Name, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtConstList).Consts).(*ast.StmtConstant).Name, token.Start, $2.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1735,32 +1743,42 @@ declare_statement:
|
||||
declare_list:
|
||||
T_STRING '=' static_scalar
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $1.Value}
|
||||
constant := &ast.StmtConstant{ast.Node{}, name, $3}
|
||||
$$ = []ast.Vertex{constant}
|
||||
$$ = []ast.Vertex{
|
||||
&ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $3),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
Value: $1.Value,
|
||||
},
|
||||
EqualTkn: $2,
|
||||
Expr: $3,
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($1)
|
||||
constant.GetNode().Position = position.NewTokenNodePosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Name, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(lastNode($$).(*ast.StmtConstant).Name, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| declare_list ',' T_STRING '=' static_scalar
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
constant := &ast.StmtConstant{ast.Node{}, name, $5}
|
||||
$$ = append($1, constant)
|
||||
lastNode($1).(*ast.StmtConstant).CommaTkn = $2
|
||||
$$ = append($1, &ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $5),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
Value: $3.Value,
|
||||
},
|
||||
EqualTkn: $4,
|
||||
Expr: $5,
|
||||
})
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($3)
|
||||
constant.GetNode().Position = position.NewTokenNodePosition($3, $5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Start, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Name, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(lastNode($$).(*ast.StmtConstant).Name, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@@ -2359,14 +2377,9 @@ class_statement:
|
||||
}
|
||||
| class_constant_declaration ';'
|
||||
{
|
||||
$1.(*ast.StmtClassConstList).SemiColonTkn = $2
|
||||
$1.(*ast.StmtClassConstList).Node.Position = position.NewNodeTokenPosition($1, $2)
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodeTokenPosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.ConstList, $2.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $2.SkippedTokens)
|
||||
}
|
||||
| trait_use_statement
|
||||
{
|
||||
@@ -2797,38 +2810,52 @@ class_variable_declaration:
|
||||
class_constant_declaration:
|
||||
class_constant_declaration ',' T_STRING '=' static_scalar
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
constant := &ast.StmtConstant{ast.Node{}, name, $5}
|
||||
constList := $1.(*ast.StmtClassConstList)
|
||||
lastConst := lastNode(constList.Consts)
|
||||
constList.Consts = append(constList.Consts, constant)
|
||||
constList.Node.Position = position.NewNodesPosition($1, $5)
|
||||
lastNode($$.(*ast.StmtClassConstList).Consts).(*ast.StmtConstant).CommaTkn = $2
|
||||
constList.Consts = append(constList.Consts, &ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $5),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
Value: $3.Value,
|
||||
},
|
||||
EqualTkn: $4,
|
||||
Expr: $5,
|
||||
})
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($3)
|
||||
constant.GetNode().Position = position.NewTokenNodePosition($3, $5)
|
||||
$1.GetNode().Position = position.NewNodesPosition($1, $5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(lastConst, token.End, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Start, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Name, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtClassConstList).Consts).(*ast.StmtConstant).Name, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
| T_CONST T_STRING '=' static_scalar
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $2.Value}
|
||||
constant := &ast.StmtConstant{ast.Node{}, name, $4}
|
||||
$$ = &ast.StmtClassConstList{ast.Node{}, nil, []ast.Vertex{constant}}
|
||||
$$ = &ast.StmtClassConstList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $4),
|
||||
},
|
||||
ConstTkn: $1,
|
||||
Consts: []ast.Vertex{
|
||||
&ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($2, $4),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
Value: $2.Value,
|
||||
},
|
||||
EqualTkn: $3,
|
||||
Expr: $4,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($2)
|
||||
constant.GetNode().Position = position.NewTokenNodePosition($2, $4)
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Start, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(constant, token.Name, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtClassConstList).Consts).(*ast.StmtConstant).Name, token.Start, $2.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -3134,7 +3134,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1071,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 58,
|
||||
@@ -3166,7 +3166,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1080,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 58,
|
||||
@@ -3793,7 +3793,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1409,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 67,
|
||||
@@ -3825,7 +3825,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1418,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 67,
|
||||
@@ -4020,7 +4020,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1512,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 71,
|
||||
@@ -4074,7 +4074,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1530,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 72,
|
||||
@@ -4106,7 +4106,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1546,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 72,
|
||||
@@ -4162,7 +4162,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 1566,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 73,
|
||||
|
||||
@@ -4318,7 +4318,7 @@ func TestStmtClassConstList(t *testing.T) {
|
||||
EndPos: 34,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -4350,7 +4350,7 @@ func TestStmtClassConstList(t *testing.T) {
|
||||
EndPos: 43,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -4442,7 +4442,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
|
||||
EndPos: 27,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -4474,7 +4474,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
|
||||
EndPos: 36,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5721,7 +5721,7 @@ func TestStmtConstList(t *testing.T) {
|
||||
EndPos: 16,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -5753,7 +5753,7 @@ func TestStmtConstList(t *testing.T) {
|
||||
EndPos: 25,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -6048,7 +6048,7 @@ func TestStmtDeclare(t *testing.T) {
|
||||
EndPos: 18,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -6127,7 +6127,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
|
||||
EndPos: 18,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -6159,7 +6159,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
|
||||
EndPos: 34,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
@@ -6239,7 +6239,7 @@ func TestStmtDeclare_Alt(t *testing.T) {
|
||||
EndPos: 18,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 1,
|
||||
|
||||
1082
internal/php7/php7.go
generated
1082
internal/php7/php7.go
generated
File diff suppressed because it is too large
Load Diff
@@ -536,15 +536,14 @@ top_statement:
|
||||
}
|
||||
| T_CONST const_list ';'
|
||||
{
|
||||
$$ = &ast.StmtConstList{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $3.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.SkippedTokens)
|
||||
$$ = &ast.StmtConstList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
ConstTkn: $1,
|
||||
Consts: $2,
|
||||
SemiColonTkn: $3,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@@ -782,10 +781,9 @@ use_declaration:
|
||||
const_list:
|
||||
const_list ',' const_decl
|
||||
{
|
||||
$$ = append($1, $3)
|
||||
lastNode($1).(*ast.StmtConstant).CommaTkn = $2
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
||||
$$ = append($1, $3)
|
||||
}
|
||||
| const_decl
|
||||
{
|
||||
@@ -2198,20 +2196,15 @@ class_statement:
|
||||
}
|
||||
| method_modifiers T_CONST class_const_list ';'
|
||||
{
|
||||
$$ = &ast.StmtClassConstList{ast.Node{}, $1, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewOptionalListTokensPosition($1, $2, $4)
|
||||
|
||||
// save comments
|
||||
if len($1) > 0 {
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
yylex.(*Parser).setFreeFloating($$, token.ModifierList, $2.SkippedTokens)
|
||||
} else {
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $2.SkippedTokens)
|
||||
$$ = &ast.StmtClassConstList{
|
||||
Node: ast.Node{
|
||||
Position: position.NewOptionalListTokensPosition($1, $2, $4),
|
||||
},
|
||||
Modifiers: $1,
|
||||
ConstTkn: $2,
|
||||
Consts: $3,
|
||||
SemiColonTkn: $4,
|
||||
}
|
||||
yylex.(*Parser).setFreeFloating($$, token.ConstList, $4.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.SkippedTokens)
|
||||
}
|
||||
| T_USE name_list trait_adaptations
|
||||
{
|
||||
@@ -2616,10 +2609,9 @@ property:
|
||||
class_const_list:
|
||||
class_const_list ',' class_const_decl
|
||||
{
|
||||
$$ = append($1, $3)
|
||||
lastNode($1).(*ast.StmtConstant).CommaTkn = $2
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
||||
$$ = append($1, $3)
|
||||
}
|
||||
| class_const_decl
|
||||
{
|
||||
@@ -2630,32 +2622,42 @@ class_const_list:
|
||||
class_const_decl:
|
||||
identifier '=' expr backup_doc_comment
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $1.Value}
|
||||
$$ = &ast.StmtConstant{ast.Node{}, name, $3}
|
||||
$$ = &ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $3),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
Value: $1.Value,
|
||||
},
|
||||
EqualTkn: $2,
|
||||
Expr: $3,
|
||||
}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($1)
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Name, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$.(*ast.StmtConstant).Name, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
const_decl:
|
||||
T_STRING '=' expr backup_doc_comment
|
||||
{
|
||||
name := &ast.Identifier{ast.Node{}, $1.Value}
|
||||
$$ = &ast.StmtConstant{ast.Node{}, name, $3}
|
||||
$$ = &ast.StmtConstant{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $3),
|
||||
},
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
Value: $1.Value,
|
||||
},
|
||||
EqualTkn: $2,
|
||||
Expr: $3,
|
||||
}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewTokenPosition($1)
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Name, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$.(*ast.StmtConstant).Name, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -3919,7 +3919,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1322,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 70,
|
||||
@@ -3951,7 +3951,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1331,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 70,
|
||||
@@ -4018,7 +4018,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1359,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 71,
|
||||
@@ -4050,7 +4050,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1368,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 71,
|
||||
@@ -4732,7 +4732,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1693,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 81,
|
||||
@@ -4764,7 +4764,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1702,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 81,
|
||||
@@ -4959,7 +4959,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1796,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 85,
|
||||
@@ -5013,7 +5013,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1814,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 86,
|
||||
@@ -5069,7 +5069,7 @@ func TestPhp7(t *testing.T) {
|
||||
EndPos: 1834,
|
||||
},
|
||||
},
|
||||
ConstantName: &ast.Identifier{
|
||||
Name: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 87,
|
||||
|
||||
Reference in New Issue
Block a user