[refactoring] update ast structure of "Constant" nodes

This commit is contained in:
Vadym Slizov 2020-08-24 23:28:44 +03:00
parent 0285900fe5
commit c63213630a
19 changed files with 298 additions and 288 deletions

View File

@ -4154,7 +4154,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
EndPos: 27, EndPos: 27,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -4186,7 +4186,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
EndPos: 36, EndPos: 36,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5124,7 +5124,7 @@ func TestStmtConstList(t *testing.T) {
EndPos: 16, EndPos: 16,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5156,7 +5156,7 @@ func TestStmtConstList(t *testing.T) {
EndPos: 25, EndPos: 25,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5451,7 +5451,7 @@ func TestStmtDeclare(t *testing.T) {
EndPos: 18, EndPos: 18,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5530,7 +5530,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
EndPos: 18, EndPos: 18,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5562,7 +5562,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
EndPos: 34, EndPos: 34,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5642,7 +5642,7 @@ func TestStmtDeclare_Alt(t *testing.T) {
EndPos: 18, EndPos: 18,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -447,14 +447,9 @@ top_statement:
} }
| constant_declaration ';' | constant_declaration ';'
{ {
$1.(*ast.StmtConstList).SemiColonTkn = $2
$1.(*ast.StmtConstList).Node.Position = position.NewNodeTokenPosition($1, $2)
$$ = $1 $$ = $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:
constant_declaration ',' T_STRING '=' static_scalar constant_declaration ',' T_STRING '=' static_scalar
{ {
name := &ast.Identifier{ast.Node{}, $3.Value}
constant := &ast.StmtConstant{ast.Node{}, name, $5}
constList := $1.(*ast.StmtConstList) constList := $1.(*ast.StmtConstList)
lastConst := lastNode(constList.Consts) constList.Node.Position = position.NewNodesPosition($1, $5)
constList.Consts = append(constList.Consts, constant) 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 $$ = $1
// save position yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtConstList).Consts).(*ast.StmtConstant).Name, token.Start, $3.SkippedTokens)
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)
} }
| T_CONST T_STRING '=' static_scalar | T_CONST T_STRING '=' static_scalar
{ {
name := &ast.Identifier{ast.Node{}, $2.Value} $$ = &ast.StmtConstList{
constant := &ast.StmtConstant{ast.Node{}, name, $4} Node: ast.Node{
constList := []ast.Vertex{constant} Position: position.NewTokenNodePosition($1, $4),
$$ = &ast.StmtConstList{ast.Node{}, constList} },
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 yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtConstList).Consts).(*ast.StmtConstant).Name, token.Start, $2.SkippedTokens)
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)
} }
; ;
@ -1735,32 +1743,42 @@ declare_statement:
declare_list: declare_list:
T_STRING '=' static_scalar T_STRING '=' static_scalar
{ {
name := &ast.Identifier{ast.Node{}, $1.Value} $$ = []ast.Vertex{
constant := &ast.StmtConstant{ast.Node{}, name, $3} &ast.StmtConstant{
$$ = []ast.Vertex{constant} 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 yylex.(*Parser).setFreeFloating(lastNode($$).(*ast.StmtConstant).Name, token.Start, $1.SkippedTokens)
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)
} }
| declare_list ',' T_STRING '=' static_scalar | declare_list ',' T_STRING '=' static_scalar
{ {
name := &ast.Identifier{ast.Node{}, $3.Value} lastNode($1).(*ast.StmtConstant).CommaTkn = $2
constant := &ast.StmtConstant{ast.Node{}, name, $5} $$ = append($1, &ast.StmtConstant{
$$ = append($1, constant) 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 yylex.(*Parser).setFreeFloating(lastNode($$).(*ast.StmtConstant).Name, token.Start, $3.SkippedTokens)
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)
} }
; ;
@ -2359,14 +2377,9 @@ class_statement:
} }
| class_constant_declaration ';' | class_constant_declaration ';'
{ {
$1.(*ast.StmtClassConstList).SemiColonTkn = $2
$1.(*ast.StmtClassConstList).Node.Position = position.NewNodeTokenPosition($1, $2)
$$ = $1 $$ = $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 | trait_use_statement
{ {
@ -2797,38 +2810,52 @@ class_variable_declaration:
class_constant_declaration: class_constant_declaration:
class_constant_declaration ',' T_STRING '=' static_scalar 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) constList := $1.(*ast.StmtClassConstList)
lastConst := lastNode(constList.Consts) constList.Node.Position = position.NewNodesPosition($1, $5)
constList.Consts = append(constList.Consts, constant) 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 $$ = $1
// save position yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtClassConstList).Consts).(*ast.StmtConstant).Name, token.Start, $3.SkippedTokens)
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)
} }
| T_CONST T_STRING '=' static_scalar | T_CONST T_STRING '=' static_scalar
{ {
name := &ast.Identifier{ast.Node{}, $2.Value} $$ = &ast.StmtClassConstList{
constant := &ast.StmtConstant{ast.Node{}, name, $4} Node: ast.Node{
$$ = &ast.StmtClassConstList{ast.Node{}, nil, []ast.Vertex{constant}} 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 yylex.(*Parser).setFreeFloating(lastNode($$.(*ast.StmtClassConstList).Consts).(*ast.StmtConstant).Name, token.Start, $2.SkippedTokens)
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)
} }
; ;

View File

@ -3134,7 +3134,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1071, EndPos: 1071,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 58, StartLine: 58,
@ -3166,7 +3166,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1080, EndPos: 1080,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 58, StartLine: 58,
@ -3793,7 +3793,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1409, EndPos: 1409,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 67, StartLine: 67,
@ -3825,7 +3825,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1418, EndPos: 1418,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 67, StartLine: 67,
@ -4020,7 +4020,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1512, EndPos: 1512,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 71, StartLine: 71,
@ -4074,7 +4074,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1530, EndPos: 1530,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 72, StartLine: 72,
@ -4106,7 +4106,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1546, EndPos: 1546,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 72, StartLine: 72,
@ -4162,7 +4162,7 @@ func TestPhp5(t *testing.T) {
EndPos: 1566, EndPos: 1566,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 73, StartLine: 73,

View File

@ -4318,7 +4318,7 @@ func TestStmtClassConstList(t *testing.T) {
EndPos: 34, EndPos: 34,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -4350,7 +4350,7 @@ func TestStmtClassConstList(t *testing.T) {
EndPos: 43, EndPos: 43,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -4442,7 +4442,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
EndPos: 27, EndPos: 27,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -4474,7 +4474,7 @@ func TestStmtClassConstList_WithoutModifiers(t *testing.T) {
EndPos: 36, EndPos: 36,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5721,7 +5721,7 @@ func TestStmtConstList(t *testing.T) {
EndPos: 16, EndPos: 16,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -5753,7 +5753,7 @@ func TestStmtConstList(t *testing.T) {
EndPos: 25, EndPos: 25,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -6048,7 +6048,7 @@ func TestStmtDeclare(t *testing.T) {
EndPos: 18, EndPos: 18,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -6127,7 +6127,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
EndPos: 18, EndPos: 18,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -6159,7 +6159,7 @@ func TestStmtDeclare_Stmts(t *testing.T) {
EndPos: 34, EndPos: 34,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -6239,7 +6239,7 @@ func TestStmtDeclare_Alt(t *testing.T) {
EndPos: 18, EndPos: 18,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -536,15 +536,14 @@ top_statement:
} }
| T_CONST const_list ';' | T_CONST const_list ';'
{ {
$$ = &ast.StmtConstList{ast.Node{}, $2} $$ = &ast.StmtConstList{
Node: ast.Node{
// save position Position: position.NewTokensPosition($1, $3),
$$.GetNode().Position = position.NewTokensPosition($1, $3) },
ConstTkn: $1,
// save comments Consts: $2,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) SemiColonTkn: $3,
yylex.(*Parser).setFreeFloating($$, token.Stmts, $3.SkippedTokens) }
yylex.(*Parser).setToken($$, token.SemiColon, $3.SkippedTokens)
} }
; ;
@ -782,10 +781,9 @@ use_declaration:
const_list: const_list:
const_list ',' const_decl const_list ',' const_decl
{ {
$$ = append($1, $3) lastNode($1).(*ast.StmtConstant).CommaTkn = $2
// save comments $$ = append($1, $3)
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
} }
| const_decl | const_decl
{ {
@ -2198,20 +2196,15 @@ class_statement:
} }
| method_modifiers T_CONST class_const_list ';' | method_modifiers T_CONST class_const_list ';'
{ {
$$ = &ast.StmtClassConstList{ast.Node{}, $1, $3} $$ = &ast.StmtClassConstList{
Node: ast.Node{
// save position Position: position.NewOptionalListTokensPosition($1, $2, $4),
$$.GetNode().Position = position.NewOptionalListTokensPosition($1, $2, $4) },
Modifiers: $1,
// save comments ConstTkn: $2,
if len($1) > 0 { Consts: $3,
yylex.(*Parser).MoveFreeFloating($1[0], $$) SemiColonTkn: $4,
yylex.(*Parser).setFreeFloating($$, token.ModifierList, $2.SkippedTokens)
} else {
yylex.(*Parser).setFreeFloating($$, token.Start, $2.SkippedTokens)
} }
yylex.(*Parser).setFreeFloating($$, token.ConstList, $4.SkippedTokens)
yylex.(*Parser).setToken($$, token.SemiColon, $4.SkippedTokens)
} }
| T_USE name_list trait_adaptations | T_USE name_list trait_adaptations
{ {
@ -2616,10 +2609,9 @@ property:
class_const_list: class_const_list:
class_const_list ',' class_const_decl class_const_list ',' class_const_decl
{ {
$$ = append($1, $3) lastNode($1).(*ast.StmtConstant).CommaTkn = $2
// save comments $$ = append($1, $3)
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
} }
| class_const_decl | class_const_decl
{ {
@ -2630,32 +2622,42 @@ class_const_list:
class_const_decl: class_const_decl:
identifier '=' expr backup_doc_comment identifier '=' expr backup_doc_comment
{ {
name := &ast.Identifier{ast.Node{}, $1.Value} $$ = &ast.StmtConstant{
$$ = &ast.StmtConstant{ast.Node{}, name, $3} 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 yylex.(*Parser).setFreeFloating($$.(*ast.StmtConstant).Name, token.Start, $1.SkippedTokens)
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)
} }
; ;
const_decl: const_decl:
T_STRING '=' expr backup_doc_comment T_STRING '=' expr backup_doc_comment
{ {
name := &ast.Identifier{ast.Node{}, $1.Value} $$ = &ast.StmtConstant{
$$ = &ast.StmtConstant{ast.Node{}, name, $3} 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 yylex.(*Parser).setFreeFloating($$.(*ast.StmtConstant).Name, token.Start, $1.SkippedTokens)
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)
} }
; ;

View File

@ -3919,7 +3919,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1322, EndPos: 1322,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 70, StartLine: 70,
@ -3951,7 +3951,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1331, EndPos: 1331,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 70, StartLine: 70,
@ -4018,7 +4018,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1359, EndPos: 1359,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 71, StartLine: 71,
@ -4050,7 +4050,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1368, EndPos: 1368,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 71, StartLine: 71,
@ -4732,7 +4732,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1693, EndPos: 1693,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 81, StartLine: 81,
@ -4764,7 +4764,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1702, EndPos: 1702,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 81, StartLine: 81,
@ -4959,7 +4959,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1796, EndPos: 1796,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 85, StartLine: 85,
@ -5013,7 +5013,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1814, EndPos: 1814,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 86, StartLine: 86,
@ -5069,7 +5069,7 @@ func TestPhp7(t *testing.T) {
EndPos: 1834, EndPos: 1834,
}, },
}, },
ConstantName: &ast.Identifier{ Name: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 87, StartLine: 87,

View File

@ -319,7 +319,9 @@ func (n *StmtClass) Accept(v NodeVisitor) {
type StmtClassConstList struct { type StmtClassConstList struct {
Node Node
Modifiers []Vertex Modifiers []Vertex
ConstTkn *token.Token
Consts []Vertex Consts []Vertex
SemiColonTkn *token.Token
} }
func (n *StmtClassConstList) Accept(v NodeVisitor) { func (n *StmtClassConstList) Accept(v NodeVisitor) {
@ -364,7 +366,9 @@ func (n *StmtClassMethod) Accept(v NodeVisitor) {
// StmtConstList node // StmtConstList node
type StmtConstList struct { type StmtConstList struct {
Node Node
ConstTkn *token.Token
Consts []Vertex Consts []Vertex
SemiColonTkn *token.Token
} }
func (n *StmtConstList) Accept(v NodeVisitor) { func (n *StmtConstList) Accept(v NodeVisitor) {
@ -374,8 +378,10 @@ func (n *StmtConstList) Accept(v NodeVisitor) {
// StmtConstant node // StmtConstant node
type StmtConstant struct { type StmtConstant struct {
Node Node
ConstantName Vertex Name Vertex
EqualTkn *token.Token
Expr Vertex Expr Vertex
CommaTkn *token.Token
} }
func (n *StmtConstant) Accept(v NodeVisitor) { func (n *StmtConstant) Accept(v NodeVisitor) {

View File

@ -487,10 +487,10 @@ func (t *DFS) Traverse(n ast.Vertex) {
if !t.visitor.EnterNode(nn) { if !t.visitor.EnterNode(nn) {
return return
} }
if nn.ConstantName != nil { if nn.Name != nil {
t.visitor.Enter("ConstantName", true) t.visitor.Enter("Name", true)
t.Traverse(nn.ConstantName) t.Traverse(nn.Name)
t.visitor.Leave("ConstantName", true) t.visitor.Leave("Name", true)
} }
if nn.Expr != nil { if nn.Expr != nil {
t.visitor.Enter("Expr", true) t.visitor.Enter("Expr", true)
@ -1334,9 +1334,9 @@ func (t *DFS) Traverse(n ast.Vertex) {
t.visitor.Leave("Class", true) t.visitor.Leave("Class", true)
} }
if nn.ConstantName != nil { if nn.ConstantName != nil {
t.visitor.Enter("ConstantName", true) t.visitor.Enter("Name", true)
t.Traverse(nn.ConstantName) t.Traverse(nn.ConstantName)
t.visitor.Leave("ConstantName", true) t.visitor.Leave("Name", true)
} }
case *ast.ExprClone: case *ast.ExprClone:
if nn == nil { if nn == nil {

View File

@ -67,3 +67,18 @@ func (v *FilterTokens) StmtHaltCompiler(n *ast.StmtHaltCompiler) {
n.CloseParenthesisTkn = nil n.CloseParenthesisTkn = nil
n.SemiColonTkn = nil n.SemiColonTkn = nil
} }
func (v *FilterTokens) StmtConstList(n *ast.StmtConstList) {
n.ConstTkn = nil
n.SemiColonTkn = nil
}
func (v *FilterTokens) StmtClassConstList(n *ast.StmtClassConstList) {
n.ConstTkn = nil
n.SemiColonTkn = nil
}
func (v *FilterTokens) StmtConstant(n *ast.StmtConstant) {
n.EqualTkn = nil
n.CommaTkn = nil
}

View File

@ -141,7 +141,7 @@ func (nsr *NamespaceResolver) StmtPropertyList(n *ast.StmtPropertyList) {
func (nsr *NamespaceResolver) StmtConstList(n *ast.StmtConstList) { func (nsr *NamespaceResolver) StmtConstList(n *ast.StmtConstList) {
for _, constant := range n.Consts { for _, constant := range n.Consts {
nsr.AddNamespacedName(constant, string(constant.(*ast.StmtConstant).ConstantName.(*ast.Identifier).Value)) nsr.AddNamespacedName(constant, string(constant.(*ast.StmtConstant).Name.(*ast.Identifier).Value))
} }
} }

View File

@ -594,11 +594,11 @@ func TestResolveConstantsName(t *testing.T) {
nameAB := &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("A")}, &ast.NameNamePart{Value: []byte("B")}}} nameAB := &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("A")}, &ast.NameNamePart{Value: []byte("B")}}}
constantB := &ast.StmtConstant{ constantB := &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("B")}, Name: &ast.Identifier{Value: []byte("B")},
Expr: &ast.ScalarLnumber{Value: []byte("1")}, Expr: &ast.ScalarLnumber{Value: []byte("1")},
} }
constantC := &ast.StmtConstant{ constantC := &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("C")}, Name: &ast.Identifier{Value: []byte("C")},
Expr: &ast.ScalarLnumber{Value: []byte("1")}, Expr: &ast.ScalarLnumber{Value: []byte("1")},
} }
@ -638,11 +638,11 @@ func TestResolveNamespaces(t *testing.T) {
relativeNameCE := &ast.NameRelative{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("C")}, &ast.NameNamePart{Value: []byte("E")}}} relativeNameCE := &ast.NameRelative{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("C")}, &ast.NameNamePart{Value: []byte("E")}}}
constantB := &ast.StmtConstant{ constantB := &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("B")}, Name: &ast.Identifier{Value: []byte("B")},
Expr: &ast.ScalarLnumber{Value: []byte("1")}, Expr: &ast.ScalarLnumber{Value: []byte("1")},
} }
constantC := &ast.StmtConstant{ constantC := &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("C")}, Name: &ast.Identifier{Value: []byte("C")},
Expr: &ast.ScalarLnumber{Value: []byte("1")}, Expr: &ast.ScalarLnumber{Value: []byte("1")},
} }

View File

@ -1603,7 +1603,7 @@ func (p *PrettyPrinter) printStmtClassConstList(n ast.Vertex) {
func (p *PrettyPrinter) printStmtConstant(n ast.Vertex) { func (p *PrettyPrinter) printStmtConstant(n ast.Vertex) {
nn := n.(*ast.StmtConstant) nn := n.(*ast.StmtConstant)
p.Print(nn.ConstantName) p.Print(nn.Name)
io.WriteString(p.w, " = ") io.WriteString(p.w, " = ")
p.Print(nn.Expr) p.Print(nn.Expr)
} }

View File

@ -2530,7 +2530,7 @@ func TestPrintStmtClass(t *testing.T) {
Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}},
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -2585,7 +2585,7 @@ func TestPrintStmtAnonymousClass(t *testing.T) {
Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}},
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -2616,11 +2616,11 @@ func TestPrintStmtClassConstList(t *testing.T) {
Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}},
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'a'")}, Expr: &ast.ScalarString{Value: []byte("'a'")},
}, },
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("BAR")}, Name: &ast.Identifier{Value: []byte("BAR")},
Expr: &ast.ScalarString{Value: []byte("'b'")}, Expr: &ast.ScalarString{Value: []byte("'b'")},
}, },
}, },
@ -2639,7 +2639,7 @@ func TestPrintStmtConstant(t *testing.T) {
p := printer.NewPrettyPrinter(o, " ") p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtConstant{ p.Print(&ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'BAR'")}, Expr: &ast.ScalarString{Value: []byte("'BAR'")},
}) })
@ -2676,7 +2676,7 @@ func TestPrintStmtDeclareStmts(t *testing.T) {
&ast.StmtDeclare{ &ast.StmtDeclare{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -2710,7 +2710,7 @@ func TestPrintStmtDeclareExpr(t *testing.T) {
&ast.StmtDeclare{ &ast.StmtDeclare{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -2737,7 +2737,7 @@ func TestPrintStmtDeclareNop(t *testing.T) {
p.Print(&ast.StmtDeclare{ p.Print(&ast.StmtDeclare{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },

View File

@ -2421,69 +2421,27 @@ func (p *Printer) printStmtClass(n ast.Vertex) {
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtClassConstList(n ast.Vertex) { func (p *Printer) printStmtClassConstList(n *ast.StmtClassConstList) {
nn := n.(*ast.StmtClassConstList) p.joinPrintRefactored(" ", n.Modifiers)
p.printFreeFloating(nn, token.Start) p.bufStart = " "
p.printToken(n.ConstTkn, "const")
if nn.Modifiers != nil { p.bufStart = " "
for k, m := range nn.Modifiers { p.joinPrintRefactored(",", n.Consts)
if k > 0 && m.GetNode().Tokens.IsEmpty() { p.printToken(n.SemiColonTkn, ";")
io.WriteString(p.w, " ")
}
p.Print(m)
}
if nn.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
}
p.printFreeFloating(nn, token.ModifierList)
io.WriteString(p.w, "const")
if nn.Consts[0].GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
p.joinPrint(",", nn.Consts)
p.printFreeFloating(nn, token.ConstList)
p.printFreeFloating(nn, token.SemiColon)
if nn.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, ";")
}
p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtConstList(n ast.Vertex) { func (p *Printer) printStmtConstList(n *ast.StmtConstList) {
nn := n.(*ast.StmtConstList) p.printToken(n.ConstTkn, "const")
p.printFreeFloating(nn, token.Start) p.bufStart = " "
p.joinPrintRefactored(",", n.Consts)
io.WriteString(p.w, "const") p.printToken(n.SemiColonTkn, ";")
if nn.Consts[0].GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
p.joinPrint(",", nn.Consts)
p.printFreeFloating(nn, token.Stmts)
p.printFreeFloating(nn, token.SemiColon)
if nn.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, ";")
}
p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtConstant(n ast.Vertex) { func (p *Printer) printStmtConstant(n *ast.StmtConstant) {
nn := n.(*ast.StmtConstant) p.Print(n.Name)
p.printFreeFloating(nn, token.Start) p.printToken(n.EqualTkn, "=")
p.Print(n.Expr)
p.Print(nn.ConstantName) p.printToken(n.CommaTkn, "")
p.printFreeFloating(nn, token.Name)
io.WriteString(p.w, "=")
p.Print(nn.Expr)
p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtContinue(n ast.Vertex) { func (p *Printer) printStmtContinue(n ast.Vertex) {
@ -2515,7 +2473,7 @@ func (p *Printer) printStmtDeclare(n ast.Vertex) {
io.WriteString(p.w, "declare") io.WriteString(p.w, "declare")
p.printFreeFloating(nn, token.Declare) p.printFreeFloating(nn, token.Declare)
io.WriteString(p.w, "(") io.WriteString(p.w, "(")
p.joinPrint(",", nn.Consts) p.joinPrintRefactored(",", nn.Consts)
p.printFreeFloating(nn, token.ConstList) p.printFreeFloating(nn, token.ConstList)
io.WriteString(p.w, ")") io.WriteString(p.w, ")")

View File

@ -896,7 +896,8 @@ func TestParseAndPrintPhp5ClassConstList(t *testing.T) {
} }
func TestParseAndPrintPhp5ConstList(t *testing.T) { func TestParseAndPrintPhp5ConstList(t *testing.T) {
src := `<?php // TODO: remove ; after <?php
src := `<?php ;
const FOO = 1 , BAR = 2 ; const FOO = 1 , BAR = 2 ;
` `
@ -924,7 +925,7 @@ func TestParseAndPrintPhp5Continue(t *testing.T) {
func TestParseAndPrintPhp5Declare(t *testing.T) { func TestParseAndPrintPhp5Declare(t *testing.T) {
src := `<?php src := `<?php
declare ( FOO = 'bar' ) ; declare ( FOO = 'bar' , BAR = 'foo' ) ;
declare ( FOO = 'bar' ) $a ; declare ( FOO = 'bar' ) $a ;
declare ( FOO = 'bar' ) { } declare ( FOO = 'bar' ) { }

View File

@ -1012,7 +1012,8 @@ func TestParseAndPrintClassConstList(t *testing.T) {
} }
func TestParseAndPrintConstList(t *testing.T) { func TestParseAndPrintConstList(t *testing.T) {
src := `<?php // TODO: remove ; after <?php
src := `<?php ;
const FOO = 1 , BAR = 2 ; const FOO = 1 , BAR = 2 ;
` `
@ -1040,7 +1041,7 @@ func TestParseAndPrintContinue(t *testing.T) {
func TestParseAndPrintDeclare(t *testing.T) { func TestParseAndPrintDeclare(t *testing.T) {
src := `<?php src := `<?php
declare ( FOO = 'bar' ) ; declare ( FOO = 'bar' , BAR = "foo" ) ;
declare ( FOO = 'bar' ) $a ; declare ( FOO = 'bar' ) $a ;
declare ( FOO = 'bar' ) { } declare ( FOO = 'bar' ) { }

View File

@ -3028,7 +3028,7 @@ func TestPrinterPrintStmtClass(t *testing.T) {
}, },
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -3078,7 +3078,7 @@ func TestPrinterPrintStmtAnonymousClass(t *testing.T) {
Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}},
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -3102,11 +3102,11 @@ func TestPrinterPrintStmtClassConstList(t *testing.T) {
Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}},
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'a'")}, Expr: &ast.ScalarString{Value: []byte("'a'")},
}, },
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("BAR")}, Name: &ast.Identifier{Value: []byte("BAR")},
Expr: &ast.ScalarString{Value: []byte("'b'")}, Expr: &ast.ScalarString{Value: []byte("'b'")},
}, },
}, },
@ -3127,11 +3127,11 @@ func TestPrinterPrintStmtConstList(t *testing.T) {
p.Print(&ast.StmtConstList{ p.Print(&ast.StmtConstList{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'a'")}, Expr: &ast.ScalarString{Value: []byte("'a'")},
}, },
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("BAR")}, Name: &ast.Identifier{Value: []byte("BAR")},
Expr: &ast.ScalarString{Value: []byte("'b'")}, Expr: &ast.ScalarString{Value: []byte("'b'")},
}, },
}, },
@ -3150,7 +3150,7 @@ func TestPrinterPrintStmtConstant(t *testing.T) {
p := printer.NewPrinter(o) p := printer.NewPrinter(o)
p.Print(&ast.StmtConstant{ p.Print(&ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'BAR'")}, Expr: &ast.ScalarString{Value: []byte("'BAR'")},
}) })
@ -3187,7 +3187,7 @@ func TestPrinterPrintStmtDeclareStmts(t *testing.T) {
p.Print(&ast.StmtDeclare{ p.Print(&ast.StmtDeclare{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -3213,7 +3213,7 @@ func TestPrinterPrintStmtDeclareExpr(t *testing.T) {
p.Print(&ast.StmtDeclare{ p.Print(&ast.StmtDeclare{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },
@ -3235,7 +3235,7 @@ func TestPrinterPrintStmtDeclareNop(t *testing.T) {
p.Print(&ast.StmtDeclare{ p.Print(&ast.StmtDeclare{
Consts: []ast.Vertex{ Consts: []ast.Vertex{
&ast.StmtConstant{ &ast.StmtConstant{
ConstantName: &ast.Identifier{Value: []byte("FOO")}, Name: &ast.Identifier{Value: []byte("FOO")},
Expr: &ast.ScalarString{Value: []byte("'bar'")}, Expr: &ast.ScalarString{Value: []byte("'bar'")},
}, },
}, },