[refactoring] update use ast structure

This commit is contained in:
Vadym Slizov 2020-08-03 21:22:53 +02:00
parent 88dfd32d9e
commit feebb017c4
21 changed files with 3610 additions and 2681 deletions

View File

@ -11442,7 +11442,7 @@ func TestStmtUse(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11451,8 +11451,17 @@ func TestStmtUse(t *testing.T) {
EndPos: 11, EndPos: 11,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 10,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11488,6 +11497,7 @@ func TestStmtUse(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -11510,7 +11520,7 @@ func TestStmtUse_FullyQualified(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11519,8 +11529,17 @@ func TestStmtUse_FullyQualified(t *testing.T) {
EndPos: 12, EndPos: 12,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 11,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11556,6 +11575,7 @@ func TestStmtUse_FullyQualified(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -11578,7 +11598,7 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11587,8 +11607,17 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
EndPos: 19, EndPos: 19,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 18,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11635,6 +11664,7 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -11657,7 +11687,7 @@ func TestStmtUse_List(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11666,8 +11696,17 @@ func TestStmtUse_List(t *testing.T) {
EndPos: 16, EndPos: 16,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 15,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11700,7 +11739,7 @@ func TestStmtUse_List(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11736,6 +11775,7 @@ func TestStmtUse_List(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -11758,7 +11798,7 @@ func TestStmtUse_ListAlias(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11767,8 +11807,17 @@ func TestStmtUse_ListAlias(t *testing.T) {
EndPos: 23, EndPos: 23,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 22,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11801,7 +11850,7 @@ func TestStmtUse_ListAlias(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11848,6 +11897,7 @@ func TestStmtUse_ListAlias(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -11870,7 +11920,7 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11879,7 +11929,16 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
EndPos: 26, EndPos: 26,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 25,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11890,8 +11949,17 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 16,
EndPos: 25,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11924,7 +11992,7 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11960,6 +12028,8 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -11982,7 +12052,7 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -11991,7 +12061,16 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
EndPos: 40, EndPos: 40,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 39,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12002,8 +12081,17 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 16,
EndPos: 39,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12047,7 +12135,7 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12094,6 +12182,8 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -12116,7 +12206,7 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12125,7 +12215,17 @@ func TestStmtUse_ListConstType(t *testing.T) {
EndPos: 23, EndPos: 23,
}, },
}, },
UseType: &ast.Identifier{
UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 22,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12136,8 +12236,17 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 13,
EndPos: 22,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12170,7 +12279,7 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12206,6 +12315,8 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)
@ -12228,7 +12339,7 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12237,7 +12348,16 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
EndPos: 37, EndPos: 37,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 36,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12248,8 +12368,17 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 13,
EndPos: 36,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12293,7 +12422,7 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12340,6 +12469,8 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", false, nil) lexer := scanner.NewLexer([]byte(src), "5.6", false, nil)

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -428,49 +428,56 @@ top_statement:
} }
| T_USE use_declarations ';' | T_USE use_declarations ';'
{ {
$$ = &ast.StmtUseList{ast.Node{}, nil, $2} useList := &ast.StmtUseList{ast.Node{}, $2}
$$ = &ast.StmtUse{ast.Node{}, useList}
// save position // save position
useList.GetNode().Position = position.NewNodeListPosition($2)
$$.GetNode().Position = position.NewTokensPosition($1, $3) $$.GetNode().Position = position.NewTokensPosition($1, $3)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_USE T_FUNCTION use_function_declarations ';' | T_USE T_FUNCTION use_function_declarations ';'
{ {
useType := &ast.Identifier{ast.Node{}, $2.Value} identifier := &ast.Identifier{ast.Node{}, $2.Value}
$$ = &ast.StmtUseList{ast.Node{}, useType, $3} useList := &ast.StmtUseList{ast.Node{}, $3}
useType := &ast.StmtUseType{ast.Node{}, identifier, useList}
$$ = &ast.StmtUse{ast.Node{}, useType}
// save position // save position
useType.GetNode().Position = position.NewTokenPosition($2) identifier.GetNode().Position = position.NewTokenPosition($2)
useList.GetNode().Position = position.NewNodeListPosition($3)
useType.GetNode().Position = position.NewTokenNodePosition($2, useList)
$$.GetNode().Position = position.NewTokensPosition($1, $4) $$.GetNode().Position = position.NewTokensPosition($1, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating(identifier, token.Start, $2.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating(useType, token.Start, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_USE T_CONST use_const_declarations ';' | T_USE T_CONST use_const_declarations ';'
{ {
useType := &ast.Identifier{ast.Node{}, $2.Value} identifier := &ast.Identifier{ast.Node{}, $2.Value}
$$ = &ast.StmtUseList{ast.Node{}, useType, $3} useList := &ast.StmtUseList{ast.Node{}, $3}
useType := &ast.StmtUseType{ast.Node{}, identifier, useList}
$$ = &ast.StmtUse{ast.Node{}, useType}
// save position // save position
useType.GetNode().Position = position.NewTokenPosition($2) identifier.GetNode().Position = position.NewTokenPosition($2)
useList.GetNode().Position = position.NewNodeListPosition($3)
useType.GetNode().Position = position.NewTokenNodePosition($2, useList)
$$.GetNode().Position = position.NewTokensPosition($1, $4) $$.GetNode().Position = position.NewTokensPosition($1, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating(identifier, token.Start, $2.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating(useType, token.Start, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -511,22 +518,19 @@ use_declaration:
namespace_name namespace_name
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodeListPosition($1)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| namespace_name T_AS T_STRING | namespace_name T_AS T_STRING
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
alias := &ast.Identifier{ast.Node{}, $3.Value} alias := &ast.Identifier{ast.Node{}, $3.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
@ -534,7 +538,6 @@ use_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3) $$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
@ -543,16 +546,14 @@ use_declaration:
| T_NS_SEPARATOR namespace_name | T_NS_SEPARATOR namespace_name
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
$$.GetNode().Position = position.NewNodeListPosition($2) $$.GetNode().Position = position.NewNodeListPosition($2)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -560,7 +561,7 @@ use_declaration:
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
alias := &ast.Identifier{ast.Node{}, $4.Value} alias := &ast.Identifier{ast.Node{}, $4.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
@ -568,9 +569,7 @@ use_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($2, $4) $$.GetNode().Position = position.NewNodeListTokenPosition($2, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens)
@ -600,22 +599,19 @@ use_function_declaration:
namespace_name namespace_name
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodeListPosition($1)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| namespace_name T_AS T_STRING | namespace_name T_AS T_STRING
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
alias := &ast.Identifier{ast.Node{}, $3.Value} alias := &ast.Identifier{ast.Node{}, $3.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
@ -623,7 +619,6 @@ use_function_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3) $$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
@ -632,16 +627,14 @@ use_function_declaration:
| T_NS_SEPARATOR namespace_name | T_NS_SEPARATOR namespace_name
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
$$.GetNode().Position = position.NewNodeListPosition($2) $$.GetNode().Position = position.NewNodeListPosition($2)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -649,7 +642,7 @@ use_function_declaration:
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
alias := &ast.Identifier{ast.Node{}, $4.Value} alias := &ast.Identifier{ast.Node{}, $4.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
@ -657,9 +650,7 @@ use_function_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($2, $4) $$.GetNode().Position = position.NewNodeListTokenPosition($2, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens)
@ -689,22 +680,19 @@ use_const_declaration:
namespace_name namespace_name
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodeListPosition($1)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| namespace_name T_AS T_STRING | namespace_name T_AS T_STRING
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
alias := &ast.Identifier{ast.Node{}, $3.Value} alias := &ast.Identifier{ast.Node{}, $3.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
@ -712,7 +700,6 @@ use_const_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3) $$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
@ -721,16 +708,14 @@ use_const_declaration:
| T_NS_SEPARATOR namespace_name | T_NS_SEPARATOR namespace_name
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
$$.GetNode().Position = position.NewNodeListPosition($2) $$.GetNode().Position = position.NewNodeListPosition($2)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -738,7 +723,7 @@ use_const_declaration:
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
alias := &ast.Identifier{ast.Node{}, $4.Value} alias := &ast.Identifier{ast.Node{}, $4.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
@ -746,9 +731,7 @@ use_const_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($2, $4) $$.GetNode().Position = position.NewNodeListTokenPosition($2, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens)

View File

@ -8525,7 +8525,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 154, StartLine: 154,
@ -8534,8 +8534,17 @@ func TestPhp5(t *testing.T) {
EndPos: 3289, EndPos: 3289,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 154,
EndLine: 154,
StartPos: 3285,
EndPos: 3288,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 154, StartLine: 154,
@ -8570,7 +8579,8 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 155, StartLine: 155,
@ -8579,8 +8589,17 @@ func TestPhp5(t *testing.T) {
EndPos: 3299, EndPos: 3299,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 155,
EndLine: 155,
StartPos: 3295,
EndPos: 3298,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 155, StartLine: 155,
@ -8615,7 +8634,8 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 156, StartLine: 156,
@ -8624,8 +8644,17 @@ func TestPhp5(t *testing.T) {
EndPos: 3316, EndPos: 3316,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 156,
EndLine: 156,
StartPos: 3305,
EndPos: 3315,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 156, StartLine: 156,
@ -8671,7 +8700,8 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 157, StartLine: 157,
@ -8680,8 +8710,17 @@ func TestPhp5(t *testing.T) {
EndPos: 3330, EndPos: 3330,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 157,
EndLine: 157,
StartPos: 3321,
EndPos: 3329,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 157, StartLine: 157,
@ -8714,7 +8753,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 157, StartLine: 157,
@ -8749,7 +8788,8 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 158, StartLine: 158,
@ -8758,8 +8798,17 @@ func TestPhp5(t *testing.T) {
EndPos: 3351, EndPos: 3351,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 158,
EndLine: 158,
StartPos: 3335,
EndPos: 3350,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 158, StartLine: 158,
@ -8792,7 +8841,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 158, StartLine: 158,
@ -8838,7 +8887,8 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 159, StartLine: 159,
@ -8847,7 +8897,16 @@ func TestPhp5(t *testing.T) {
EndPos: 3375, EndPos: 3375,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 159,
EndLine: 159,
StartPos: 3356,
EndPos: 3374,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 159, StartLine: 159,
@ -8858,8 +8917,17 @@ func TestPhp5(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 159,
EndLine: 159,
StartPos: 3365,
EndPos: 3374,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 159, StartLine: 159,
@ -8892,7 +8960,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 159, StartLine: 159,
@ -8927,7 +8995,9 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 160, StartLine: 160,
@ -8936,7 +9006,16 @@ func TestPhp5(t *testing.T) {
EndPos: 3413, EndPos: 3413,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 160,
EndLine: 160,
StartPos: 3380,
EndPos: 3412,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 160, StartLine: 160,
@ -8947,8 +9026,17 @@ func TestPhp5(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 160,
EndLine: 160,
StartPos: 3389,
EndPos: 3412,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 160, StartLine: 160,
@ -8992,7 +9080,7 @@ func TestPhp5(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 160, StartLine: 160,
@ -9038,7 +9126,9 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 161, StartLine: 161,
@ -9047,7 +9137,16 @@ func TestPhp5(t *testing.T) {
EndPos: 3434, EndPos: 3434,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 161,
EndLine: 161,
StartPos: 3418,
EndPos: 3433,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 161, StartLine: 161,
@ -9058,8 +9157,17 @@ func TestPhp5(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 161,
EndLine: 161,
StartPos: 3424,
EndPos: 3433,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 161, StartLine: 161,
@ -9092,7 +9200,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 161, StartLine: 161,
@ -9127,7 +9235,9 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 162, StartLine: 162,
@ -9136,7 +9246,16 @@ func TestPhp5(t *testing.T) {
EndPos: 3469, EndPos: 3469,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 162,
EndLine: 162,
StartPos: 3439,
EndPos: 3468,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 162, StartLine: 162,
@ -9147,8 +9266,17 @@ func TestPhp5(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 162,
EndLine: 162,
StartPos: 3445,
EndPos: 3468,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 162, StartLine: 162,
@ -9192,7 +9320,7 @@ func TestPhp5(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 162, StartLine: 162,
@ -9238,6 +9366,8 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
},
},
&ast.StmtExpression{ &ast.StmtExpression{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{

View File

@ -12422,7 +12422,7 @@ func TestStmtUse(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12431,8 +12431,17 @@ func TestStmtUse(t *testing.T) {
EndPos: 11, EndPos: 11,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 10,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12468,6 +12477,7 @@ func TestStmtUse(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -12490,7 +12500,7 @@ func TestStmtUse_FullyQualified(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12499,8 +12509,17 @@ func TestStmtUse_FullyQualified(t *testing.T) {
EndPos: 12, EndPos: 12,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 11,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12536,6 +12555,7 @@ func TestStmtUse_FullyQualified(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -12558,7 +12578,7 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12567,8 +12587,17 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
EndPos: 19, EndPos: 19,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 18,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12615,6 +12644,7 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -12637,7 +12667,7 @@ func TestStmtUse_List(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12646,8 +12676,17 @@ func TestStmtUse_List(t *testing.T) {
EndPos: 16, EndPos: 16,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 15,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12680,7 +12719,7 @@ func TestStmtUse_List(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12716,6 +12755,7 @@ func TestStmtUse_List(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -12738,7 +12778,7 @@ func TestStmtUse_ListAlias(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12747,8 +12787,17 @@ func TestStmtUse_ListAlias(t *testing.T) {
EndPos: 23, EndPos: 23,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 22,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12781,7 +12830,7 @@ func TestStmtUse_ListAlias(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12828,6 +12877,7 @@ func TestStmtUse_ListAlias(t *testing.T) {
}, },
}, },
}, },
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -12850,7 +12900,7 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12859,7 +12909,16 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
EndPos: 26, EndPos: 26,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 25,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12870,8 +12929,17 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 16,
EndPos: 25,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12904,7 +12972,7 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12940,6 +13008,8 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -12962,7 +13032,7 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12971,7 +13041,16 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
EndPos: 40, EndPos: 40,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 39,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -12982,8 +13061,17 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 16,
EndPos: 39,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13027,7 +13115,7 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13074,6 +13162,8 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13096,7 +13186,7 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13105,7 +13195,17 @@ func TestStmtUse_ListConstType(t *testing.T) {
EndPos: 23, EndPos: 23,
}, },
}, },
UseType: &ast.Identifier{
UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 22,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13116,8 +13216,17 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 13,
EndPos: 22,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13150,7 +13259,7 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13186,6 +13295,8 @@ func TestStmtUse_ListConstType(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13208,7 +13319,7 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13217,7 +13328,16 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
EndPos: 37, EndPos: 37,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 36,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13228,8 +13348,17 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 13,
EndPos: 36,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13273,7 +13402,7 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13320,6 +13449,8 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13342,7 +13473,7 @@ func TestStmtUse_GroupUse(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtGroupUse{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13351,6 +13482,15 @@ func TestStmtUse_GroupUse(t *testing.T) {
EndPos: 22, EndPos: 22,
}, },
}, },
UseList: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 21,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13374,8 +13514,17 @@ func TestStmtUse_GroupUse(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 12,
EndPos: 20,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13408,7 +13557,7 @@ func TestStmtUse_GroupUse(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13444,6 +13593,8 @@ func TestStmtUse_GroupUse(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13466,7 +13617,7 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtGroupUse{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13475,6 +13626,15 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
EndPos: 30, EndPos: 30,
}, },
}, },
UseList: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 29,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13498,8 +13658,17 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 12,
EndPos: 28,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13532,7 +13701,7 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13579,6 +13748,8 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
}, },
}, },
}, },
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13601,7 +13772,7 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtGroupUse{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13610,7 +13781,16 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
EndPos: 31, EndPos: 31,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 30,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13621,6 +13801,15 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Use: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 16,
EndPos: 30,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13644,8 +13833,17 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 21,
EndPos: 29,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13678,7 +13876,7 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13714,6 +13912,9 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
}, },
}, },
}, },
},
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13736,7 +13937,7 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtGroupUse{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13745,7 +13946,16 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
EndPos: 28, EndPos: 28,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 27,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13756,6 +13966,15 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Use: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 13,
EndPos: 27,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13779,8 +13998,17 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 18,
EndPos: 26,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13813,7 +14041,7 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13849,6 +14077,9 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
}, },
}, },
}, },
},
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)
@ -13871,7 +14102,7 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
}, },
}, },
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtGroupUse{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13880,6 +14111,15 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
EndPos: 37, EndPos: 37,
}, },
}, },
UseList: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 36,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13903,17 +14143,26 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
StartPos: 18, StartPos: 12,
EndPos: 35,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 12,
EndPos: 21, EndPos: 21,
}, },
}, },
UseType: &ast.Identifier{ Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13924,6 +14173,15 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Use: &ast.StmtUseDeclaration{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 18,
EndPos: 21,
},
},
Use: &ast.NameName{ Use: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13948,16 +14206,17 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ },
&ast.StmtUseType{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
StartPos: 32, StartPos: 23,
EndPos: 35, EndPos: 35,
}, },
}, },
UseType: &ast.Identifier{ Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
@ -13968,6 +14227,15 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Use: &ast.StmtUseDeclaration{
Node: ast.Node{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 35,
},
},
Use: &ast.NameName{ Use: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -13995,6 +14263,9 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
}, },
}, },
}, },
},
},
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", false, nil) lexer := scanner.NewLexer([]byte(src), "7.4", false, nil)

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -528,58 +528,61 @@ top_statement:
} }
| T_USE mixed_group_use_declaration ';' | T_USE mixed_group_use_declaration ';'
{ {
$$ = $2 $$ = &ast.StmtUse{ast.Node{}, $2}
// save position // save position
$$.GetNode().Position = position.NewTokensPosition($1, $3) $$.GetNode().Position = position.NewTokensPosition($1, $3)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_USE use_type group_use_declaration ';' | T_USE use_type group_use_declaration ';'
{ {
$3.(*ast.StmtGroupUse).UseType = $2 useType := &ast.StmtUseType{ast.Node{}, $2, $3}
$$ = $3 $$ = &ast.StmtUse{ast.Node{}, useType}
// save position // save position
useType.GetNode().Position = position.NewNodesPosition($2, $3)
$$.GetNode().Position = position.NewTokensPosition($1, $4) $$.GetNode().Position = position.NewTokensPosition($1, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_USE use_declarations ';' | T_USE use_declarations ';'
{ {
$$ = &ast.StmtUseList{ast.Node{}, nil, $2} useList := &ast.StmtUseList{ast.Node{}, $2}
$$ = &ast.StmtUse{ast.Node{}, useList}
// save position // save position
useList.GetNode().Position = position.NewNodeListPosition($2)
$$.GetNode().Position = position.NewTokensPosition($1, $3) $$.GetNode().Position = position.NewTokensPosition($1, $3)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_USE use_type use_declarations ';' | T_USE use_type use_declarations ';'
{ {
$$ = &ast.StmtUseList{ast.Node{}, $2, $3} useList := &ast.StmtUseList{ast.Node{}, $3}
useType := &ast.StmtUseType{ast.Node{}, $2, useList}
$$ = &ast.StmtUse{ast.Node{}, useType}
// save position // save position
useList.GetNode().Position = position.NewNodeListPosition($3)
useType.GetNode().Position = position.NewNodesPosition($2, useList)
$$.GetNode().Position = position.NewTokensPosition($1, $4) $$.GetNode().Position = position.NewTokensPosition($1, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -630,20 +633,20 @@ group_use_declaration:
namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
$$ = &ast.StmtGroupUse{ast.Node{}, nil, name, $4} useList := &ast.StmtUseList{ast.Node{}, $4}
$$ = &ast.StmtGroupUseList{ast.Node{}, name, useList}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
useList.GetNode().Position = position.NewNodeListPosition($4)
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $6) $$.GetNode().Position = position.NewNodeListTokenPosition($1, $6)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1[0], name) yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($2.Tokens, $3.Tokens...))
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Slash, $3.Tokens)
if $5 != nil { if $5 != nil {
yylex.(*Parser).setFreeFloating($$, token.Stmts, append($5.Tokens, $6.Tokens...)) yylex.(*Parser).setFreeFloatingTokens(useList, token.End, append($5.Tokens, $6.Tokens...))
} else { } else {
yylex.(*Parser).setFreeFloating($$, token.Stmts, $6.Tokens) yylex.(*Parser).setFreeFloating(useList, token.End, $6.Tokens)
} }
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
@ -651,22 +654,22 @@ group_use_declaration:
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
$$ = &ast.StmtGroupUse{ast.Node{}, nil, name, $5} useList := &ast.StmtUseList{ast.Node{}, $5}
$$ = &ast.StmtGroupUseList{ast.Node{}, name, useList}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
useList.GetNode().Position = position.NewNodeListPosition($5)
$$.GetNode().Position = position.NewTokensPosition($1, $7) $$.GetNode().Position = position.NewTokensPosition($1, $7)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.UseType, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($3.Tokens, $4.Tokens...))
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Slash, $4.Tokens)
if $6 != nil { if $6 != nil {
yylex.(*Parser).setFreeFloating($$, token.Stmts, append($6.Tokens, $7.Tokens...)) yylex.(*Parser).setFreeFloatingTokens(useList, token.End, append($6.Tokens, $7.Tokens...))
} else { } else {
yylex.(*Parser).setFreeFloating($$, token.Stmts, $7.Tokens) yylex.(*Parser).setFreeFloating(useList, token.End, $7.Tokens)
} }
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -676,20 +679,20 @@ mixed_group_use_declaration:
namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
$$ = &ast.StmtGroupUse{ast.Node{}, nil, name, $4} useList := &ast.StmtUseList{ast.Node{}, $4}
$$ = &ast.StmtGroupUseList{ast.Node{}, name, useList}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
useList.GetNode().Position = position.NewNodeListPosition($4)
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $6) $$.GetNode().Position = position.NewNodeListTokenPosition($1, $6)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1[0], name) yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($2.Tokens, $3.Tokens...))
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Slash, $3.Tokens)
if $5 != nil { if $5 != nil {
yylex.(*Parser).setFreeFloating($$, token.Stmts, append($5.Tokens, $6.Tokens...)) yylex.(*Parser).setFreeFloatingTokens(useList, token.End, append($5.Tokens, $6.Tokens...))
} else { } else {
yylex.(*Parser).setFreeFloating($$, token.Stmts, $6.Tokens) yylex.(*Parser).setFreeFloatingTokens(useList, token.End, $6.Tokens)
} }
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
@ -697,22 +700,22 @@ mixed_group_use_declaration:
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
{ {
name := &ast.NameName{ast.Node{}, $2} name := &ast.NameName{ast.Node{}, $2}
$$ = &ast.StmtGroupUse{ast.Node{}, nil, name, $5} useList := &ast.StmtUseList{ast.Node{}, $5}
$$ = &ast.StmtGroupUseList{ast.Node{}, name, useList}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($2) name.GetNode().Position = position.NewNodeListPosition($2)
useList.GetNode().Position = position.NewNodeListPosition($5)
$$.GetNode().Position = position.NewTokensPosition($1, $7) $$.GetNode().Position = position.NewTokensPosition($1, $7)
// save comments // save comments
yylex.(*Parser).setFreeFloatingTokens($$, token.Use, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($3.Tokens, $4.Tokens...))
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Slash, $4.Tokens)
if $6 != nil { if $6 != nil {
yylex.(*Parser).setFreeFloating($$, token.Stmts, append($6.Tokens, $7.Tokens...)) yylex.(*Parser).setFreeFloatingTokens(useList, token.End, append($6.Tokens, $7.Tokens...))
} else { } else {
yylex.(*Parser).setFreeFloating($$, token.Stmts, $7.Tokens) yylex.(*Parser).setFreeFloating(useList, token.End, $7.Tokens)
} }
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -792,8 +795,10 @@ inline_use_declaration:
} }
| use_type unprefixed_use_declaration | use_type unprefixed_use_declaration
{ {
$2.(*ast.StmtUse).UseType = $1 $$ = &ast.StmtUseType{ast.Node{}, $1, $2}
$$ = $2
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $2)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -803,14 +808,11 @@ unprefixed_use_declaration:
namespace_name namespace_name
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodePosition(name)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], name)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -818,7 +820,7 @@ unprefixed_use_declaration:
{ {
name := &ast.NameName{ast.Node{}, $1} name := &ast.NameName{ast.Node{}, $1}
alias := &ast.Identifier{ast.Node{}, $3.Value} alias := &ast.Identifier{ast.Node{}, $3.Value}
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias} $$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
// save position // save position
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
@ -826,7 +828,6 @@ unprefixed_use_declaration:
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3) $$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens) yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
@ -839,9 +840,6 @@ use_declaration:
{ {
$$ = $1 $$ = $1
// save coments
yylex.(*Parser).MoveFreeFloating($1.(*ast.StmtUse).Use, $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NS_SEPARATOR unprefixed_use_declaration | T_NS_SEPARATOR unprefixed_use_declaration
@ -849,8 +847,7 @@ use_declaration:
$$ = $2; $$ = $2;
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }

View File

@ -9013,7 +9013,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ &ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 161, StartLine: 161,
@ -9022,8 +9022,17 @@ func TestPhp7(t *testing.T) {
EndPos: 3370, EndPos: 3370,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 161,
EndLine: 161,
StartPos: 3366,
EndPos: 3369,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 161, StartLine: 161,
@ -9058,7 +9067,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 162, StartLine: 162,
@ -9067,8 +9077,17 @@ func TestPhp7(t *testing.T) {
EndPos: 3380, EndPos: 3380,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 162,
EndLine: 162,
StartPos: 3376,
EndPos: 3379,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 162, StartLine: 162,
@ -9103,7 +9122,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 163, StartLine: 163,
@ -9112,8 +9132,17 @@ func TestPhp7(t *testing.T) {
EndPos: 3397, EndPos: 3397,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 163,
EndLine: 163,
StartPos: 3386,
EndPos: 3396,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 163, StartLine: 163,
@ -9159,7 +9188,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 164, StartLine: 164,
@ -9168,8 +9198,17 @@ func TestPhp7(t *testing.T) {
EndPos: 3411, EndPos: 3411,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 164,
EndLine: 164,
StartPos: 3402,
EndPos: 3410,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 164, StartLine: 164,
@ -9202,7 +9241,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 164, StartLine: 164,
@ -9237,7 +9276,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 165, StartLine: 165,
@ -9246,8 +9286,17 @@ func TestPhp7(t *testing.T) {
EndPos: 3432, EndPos: 3432,
}, },
}, },
Uses: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 165,
EndLine: 165,
StartPos: 3416,
EndPos: 3431,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 165, StartLine: 165,
@ -9280,7 +9329,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 165, StartLine: 165,
@ -9326,7 +9375,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 166, StartLine: 166,
@ -9335,7 +9385,16 @@ func TestPhp7(t *testing.T) {
EndPos: 3456, EndPos: 3456,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 166,
EndLine: 166,
StartPos: 3437,
EndPos: 3455,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 166, StartLine: 166,
@ -9346,8 +9405,17 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 166,
EndLine: 166,
StartPos: 3446,
EndPos: 3455,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 166, StartLine: 166,
@ -9380,7 +9448,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 166, StartLine: 166,
@ -9415,7 +9483,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 167, StartLine: 167,
@ -9424,7 +9494,16 @@ func TestPhp7(t *testing.T) {
EndPos: 3494, EndPos: 3494,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 167,
EndLine: 167,
StartPos: 3461,
EndPos: 3493,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 167, StartLine: 167,
@ -9435,8 +9514,17 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 167,
EndLine: 167,
StartPos: 3470,
EndPos: 3493,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 167, StartLine: 167,
@ -9480,7 +9568,7 @@ func TestPhp7(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 167, StartLine: 167,
@ -9526,7 +9614,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 168, StartLine: 168,
@ -9535,7 +9625,16 @@ func TestPhp7(t *testing.T) {
EndPos: 3515, EndPos: 3515,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 168,
EndLine: 168,
StartPos: 3499,
EndPos: 3514,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 168, StartLine: 168,
@ -9546,8 +9645,17 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 168,
EndLine: 168,
StartPos: 3505,
EndPos: 3514,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 168, StartLine: 168,
@ -9580,7 +9688,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 168, StartLine: 168,
@ -9615,7 +9723,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUseList{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 169, StartLine: 169,
@ -9624,7 +9734,16 @@ func TestPhp7(t *testing.T) {
EndPos: 3550, EndPos: 3550,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 169,
EndLine: 169,
StartPos: 3520,
EndPos: 3549,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 169, StartLine: 169,
@ -9635,8 +9754,17 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Uses: []ast.Vertex{ Use: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 169,
EndLine: 169,
StartPos: 3526,
EndPos: 3549,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 169, StartLine: 169,
@ -9680,7 +9808,7 @@ func TestPhp7(t *testing.T) {
Value: []byte("foo"), Value: []byte("foo"),
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 169, StartLine: 169,
@ -9726,7 +9854,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtGroupUse{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 171, StartLine: 171,
@ -9735,6 +9865,15 @@ func TestPhp7(t *testing.T) {
EndPos: 3572, EndPos: 3572,
}, },
}, },
UseList: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 171,
EndLine: 171,
StartPos: 3556,
EndPos: 3571,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -9758,8 +9897,17 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 171,
EndLine: 171,
StartPos: 3562,
EndPos: 3570,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 171, StartLine: 171,
@ -9792,7 +9940,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 171, StartLine: 171,
@ -9827,7 +9975,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtGroupUse{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 172, StartLine: 172,
@ -9836,6 +9986,15 @@ func TestPhp7(t *testing.T) {
EndPos: 3600, EndPos: 3600,
}, },
}, },
UseList: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 172,
EndLine: 172,
StartPos: 3577,
EndPos: 3599,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -9859,8 +10018,17 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 172,
EndLine: 172,
StartPos: 3582,
EndPos: 3598,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 172, StartLine: 172,
@ -9893,7 +10061,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 172, StartLine: 172,
@ -9939,7 +10107,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtGroupUse{ },
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 173, StartLine: 173,
@ -9948,7 +10118,16 @@ func TestPhp7(t *testing.T) {
EndPos: 3629, EndPos: 3629,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 173,
EndLine: 173,
StartPos: 3605,
EndPos: 3628,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 173, StartLine: 173,
@ -9959,6 +10138,15 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Use: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 173,
EndLine: 173,
StartPos: 3614,
EndPos: 3628,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -9982,8 +10170,17 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 173,
EndLine: 173,
StartPos: 3619,
EndPos: 3627,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 173, StartLine: 173,
@ -10016,7 +10213,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 173, StartLine: 173,
@ -10051,7 +10248,10 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtGroupUse{ },
},
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 174, StartLine: 174,
@ -10060,7 +10260,16 @@ func TestPhp7(t *testing.T) {
EndPos: 3656, EndPos: 3656,
}, },
}, },
UseType: &ast.Identifier{ UseList: &ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 174,
EndLine: 174,
StartPos: 3634,
EndPos: 3655,
},
},
Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 174, StartLine: 174,
@ -10071,6 +10280,15 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Use: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 174,
EndLine: 174,
StartPos: 3640,
EndPos: 3655,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -10094,8 +10312,17 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{ Node: ast.Node{
Position: &position.Position{
StartLine: 174,
EndLine: 174,
StartPos: 3646,
EndPos: 3654,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 174, StartLine: 174,
@ -10128,7 +10355,7 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ &ast.StmtUseDeclaration{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 174, StartLine: 174,
@ -10163,7 +10390,10 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtGroupUse{ },
},
},
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 175, StartLine: 175,
@ -10172,6 +10402,15 @@ func TestPhp7(t *testing.T) {
EndPos: 3691, EndPos: 3691,
}, },
}, },
UseList: &ast.StmtGroupUseList{
Node: ast.Node{
Position: &position.Position{
StartLine: 175,
EndLine: 175,
StartPos: 3661,
EndPos: 3690,
},
},
Prefix: &ast.NameName{ Prefix: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -10195,17 +10434,26 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
UseList: []ast.Vertex{ UseList: &ast.StmtUseList{
&ast.StmtUse{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 175, StartLine: 175,
EndLine: 175, EndLine: 175,
StartPos: 3672, StartPos: 3666,
EndPos: 3689,
},
},
UseDeclarations: []ast.Vertex{
&ast.StmtUseType{
Node: ast.Node{
Position: &position.Position{
StartLine: 175,
EndLine: 175,
StartPos: 3666,
EndPos: 3675, EndPos: 3675,
}, },
}, },
UseType: &ast.Identifier{ Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 175, StartLine: 175,
@ -10216,6 +10464,15 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("const"), Value: []byte("const"),
}, },
Use: &ast.StmtUseDeclaration{
Node: ast.Node{
Position: &position.Position{
StartLine: 175,
EndLine: 175,
StartPos: 3672,
EndPos: 3675,
},
},
Use: &ast.NameName{ Use: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -10240,16 +10497,17 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
&ast.StmtUse{ },
&ast.StmtUseType{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 175, StartLine: 175,
EndLine: 175, EndLine: 175,
StartPos: 3686, StartPos: 3677,
EndPos: 3689, EndPos: 3689,
}, },
}, },
UseType: &ast.Identifier{ Type: &ast.Identifier{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
StartLine: 175, StartLine: 175,
@ -10260,6 +10518,15 @@ func TestPhp7(t *testing.T) {
}, },
Value: []byte("function"), Value: []byte("function"),
}, },
Use: &ast.StmtUseDeclaration{
Node: ast.Node{
Position: &position.Position{
StartLine: 175,
EndLine: 175,
StartPos: 3686,
EndPos: 3689,
},
},
Use: &ast.NameName{ Use: &ast.NameName{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{
@ -10286,6 +10553,9 @@ func TestPhp7(t *testing.T) {
}, },
}, },
}, },
},
},
},
&ast.StmtExpression{ &ast.StmtExpression{
Node: ast.Node{ Node: ast.Node{
Position: &position.Position{ Position: &position.Position{

View File

@ -59,7 +59,6 @@ type NodeVisitor interface {
StmtFunction(n *StmtFunction) StmtFunction(n *StmtFunction)
StmtGlobal(n *StmtGlobal) StmtGlobal(n *StmtGlobal)
StmtGoto(n *StmtGoto) StmtGoto(n *StmtGoto)
StmtGroupUse(n *StmtGroupUse)
StmtHaltCompiler(n *StmtHaltCompiler) StmtHaltCompiler(n *StmtHaltCompiler)
StmtIf(n *StmtIf) StmtIf(n *StmtIf)
StmtInlineHtml(n *StmtInlineHtml) StmtInlineHtml(n *StmtInlineHtml)
@ -85,7 +84,10 @@ type NodeVisitor interface {
StmtTry(n *StmtTry) StmtTry(n *StmtTry)
StmtUnset(n *StmtUnset) StmtUnset(n *StmtUnset)
StmtUse(n *StmtUse) StmtUse(n *StmtUse)
StmtGroupUseList(n *StmtGroupUseList)
StmtUseList(n *StmtUseList) StmtUseList(n *StmtUseList)
StmtUseDeclaration(n *StmtUseDeclaration)
StmtUseType(n *StmtUseType)
StmtWhile(n *StmtWhile) StmtWhile(n *StmtWhile)
ExprArray(n *ExprArray) ExprArray(n *ExprArray)

View File

@ -532,18 +532,6 @@ func (n *StmtGoto) Accept(v NodeVisitor) {
v.StmtGoto(n) v.StmtGoto(n)
} }
// StmtGroupUse node
type StmtGroupUse struct {
Node
UseType Vertex
Prefix Vertex
UseList []Vertex
}
func (n *StmtGroupUse) Accept(v NodeVisitor) {
v.StmtGroupUse(n)
}
// StmtHaltCompiler node // StmtHaltCompiler node
type StmtHaltCompiler struct { type StmtHaltCompiler struct {
Node Node
@ -804,26 +792,56 @@ func (n *StmtUnset) Accept(v NodeVisitor) {
// StmtUse node // StmtUse node
type StmtUse struct { type StmtUse struct {
Node Node
UseType Vertex UseList Vertex
Use Vertex
Alias Vertex
} }
func (n *StmtUse) Accept(v NodeVisitor) { func (n *StmtUse) Accept(v NodeVisitor) {
v.StmtUse(n) v.StmtUse(n)
} }
// StmtGroupUseList node
type StmtGroupUseList struct {
Node
Prefix Vertex
UseList Vertex
}
func (n *StmtGroupUseList) Accept(v NodeVisitor) {
v.StmtGroupUseList(n)
}
// StmtUseList node // StmtUseList node
type StmtUseList struct { type StmtUseList struct {
Node Node
UseType Vertex UseDeclarations []Vertex
Uses []Vertex
} }
func (n *StmtUseList) Accept(v NodeVisitor) { func (n *StmtUseList) Accept(v NodeVisitor) {
v.StmtUseList(n) v.StmtUseList(n)
} }
// StmtUseDeclaration node
type StmtUseDeclaration struct {
Node
Use Vertex
Alias Vertex
}
func (n *StmtUseDeclaration) Accept(v NodeVisitor) {
v.StmtUseDeclaration(n)
}
// StmtUseType node
type StmtUseType struct {
Node
Type Vertex
Use Vertex
}
func (n *StmtUseType) Accept(v NodeVisitor) {
v.StmtUseType(n)
}
// StmtWhile node // StmtWhile node
type StmtWhile struct { type StmtWhile struct {
Node Node

View File

@ -745,30 +745,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
t.Traverse(nn.Label) t.Traverse(nn.Label)
t.visitor.Leave("Label", true) t.visitor.Leave("Label", true)
} }
case *ast.StmtGroupUse:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.UseType != nil {
t.visitor.Enter("UseType", true)
t.Traverse(nn.UseType)
t.visitor.Leave("UseType", true)
}
if nn.Prefix != nil {
t.visitor.Enter("Prefix", true)
t.Traverse(nn.Prefix)
t.visitor.Leave("Prefix", true)
}
if nn.UseList != nil {
t.visitor.Enter("UseList", false)
for _, c := range nn.UseList {
t.Traverse(c)
}
t.visitor.Leave("UseList", false)
}
case *ast.StmtHaltCompiler: case *ast.StmtHaltCompiler:
if nn == nil { if nn == nil {
return return
@ -1174,10 +1150,48 @@ func (t *DFS) Traverse(n ast.Vertex) {
if !t.visitor.EnterNode(nn) { if !t.visitor.EnterNode(nn) {
return return
} }
if nn.UseType != nil { if nn.UseList != nil {
t.visitor.Enter("UseType", true) t.visitor.Enter("UseList", true)
t.Traverse(nn.UseType) t.Traverse(nn.UseList)
t.visitor.Leave("UseType", true) t.visitor.Leave("UseList", true)
}
case *ast.StmtGroupUseList:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.Prefix != nil {
t.visitor.Enter("Prefix", true)
t.Traverse(nn.Prefix)
t.visitor.Leave("Prefix", true)
}
if nn.UseList != nil {
t.visitor.Enter("UseList", true)
t.Traverse(nn.UseList)
t.visitor.Leave("UseList", true)
}
case *ast.StmtUseList:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.UseDeclarations != nil {
t.visitor.Enter("UseDeclarations", false)
for _, c := range nn.UseDeclarations {
t.Traverse(c)
}
t.visitor.Leave("UseDeclarations", false)
}
case *ast.StmtUseDeclaration:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
} }
if nn.Use != nil { if nn.Use != nil {
t.visitor.Enter("Use", true) t.visitor.Enter("Use", true)
@ -1189,24 +1203,22 @@ func (t *DFS) Traverse(n ast.Vertex) {
t.Traverse(nn.Alias) t.Traverse(nn.Alias)
t.visitor.Leave("Alias", true) t.visitor.Leave("Alias", true)
} }
case *ast.StmtUseList: case *ast.StmtUseType:
if nn == nil { if nn == nil {
return return
} }
if !t.visitor.EnterNode(nn) { if !t.visitor.EnterNode(nn) {
return return
} }
if nn.UseType != nil { if nn.Type != nil {
t.visitor.Enter("UseType", true) t.visitor.Enter("Type", true)
t.Traverse(nn.UseType) t.Traverse(nn.Type)
t.visitor.Leave("UseType", true) t.visitor.Leave("Type", true)
} }
if nn.Uses != nil { if nn.Use != nil {
t.visitor.Enter("Uses", false) t.visitor.Enter("Use", true)
for _, c := range nn.Uses { t.Traverse(nn.Use)
t.Traverse(c) t.visitor.Leave("Use", true)
}
t.visitor.Leave("Uses", false)
} }
case *ast.StmtWhile: case *ast.StmtWhile:
if nn == nil { if nn == nil {

View File

@ -437,12 +437,6 @@ func (v *Dump) StmtGoto(n *ast.StmtGoto) {
v.printNode(n.GetNode()) v.printNode(n.GetNode())
} }
func (v *Dump) StmtGroupUse(n *ast.StmtGroupUse) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtGroupUse{\n")
v.printNode(n.GetNode())
}
func (v *Dump) StmtHaltCompiler(n *ast.StmtHaltCompiler) { func (v *Dump) StmtHaltCompiler(n *ast.StmtHaltCompiler) {
v.printIndentIfNotSingle(v.indent - 1) v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtHaltCompiler{\n") v.print("&ast.StmtHaltCompiler{\n")
@ -596,12 +590,30 @@ func (v *Dump) StmtUse(n *ast.StmtUse) {
v.printNode(n.GetNode()) v.printNode(n.GetNode())
} }
func (v *Dump) StmtGroupUseList(n *ast.StmtGroupUseList) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtGroupUseList{\n")
v.printNode(n.GetNode())
}
func (v *Dump) StmtUseList(n *ast.StmtUseList) { func (v *Dump) StmtUseList(n *ast.StmtUseList) {
v.printIndentIfNotSingle(v.indent - 1) v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtUseList{\n") v.print("&ast.StmtUseList{\n")
v.printNode(n.GetNode()) v.printNode(n.GetNode())
} }
func (v *Dump) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtUseDeclaration{\n")
v.printNode(n.GetNode())
}
func (v *Dump) StmtUseType(n *ast.StmtUseType) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtUseType{\n")
v.printNode(n.GetNode())
}
func (v *Dump) StmtWhile(n *ast.StmtWhile) { func (v *Dump) StmtWhile(n *ast.StmtWhile) {
v.printIndentIfNotSingle(v.indent - 1) v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtWhile{\n") v.print("&ast.StmtWhile{\n")

View File

@ -14,6 +14,8 @@ type NamespaceResolver struct {
ResolvedNames map[ast.Vertex]string ResolvedNames map[ast.Vertex]string
goDeep bool goDeep bool
useType string
usePrefix []ast.Vertex
} }
// NewNamespaceResolver NamespaceResolver type constructor // NewNamespaceResolver NamespaceResolver type constructor
@ -45,28 +47,28 @@ func (nsr *NamespaceResolver) StmtNamespace(n *ast.StmtNamespace) {
} }
} }
func (nsr *NamespaceResolver) StmtUseList(n *ast.StmtUseList) { func (nsr *NamespaceResolver) StmtUseType(n *ast.StmtUseType) {
useType := "" if n.Type != nil {
if n.UseType != nil { nsr.useType = string(n.Type.(*ast.Identifier).Value)
useType = string(n.UseType.(*ast.Identifier).Value)
} }
for _, nn := range n.Uses {
nsr.AddAlias(useType, nn, nil)
}
nsr.goDeep = false
} }
func (nsr *NamespaceResolver) StmtGroupUse(n *ast.StmtGroupUse) { func (nsr *NamespaceResolver) StmtGroupUseList(n *ast.StmtGroupUseList) {
useType := "" if n.Prefix != nil {
if n.UseType != nil { nsr.usePrefix = n.Prefix.(*ast.NameName).Parts
useType = string(n.UseType.(*ast.Identifier).Value) }
}
func (nsr *NamespaceResolver) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
useNameParts := n.Use.(*ast.NameName).Parts
var alias string
if n.Alias == nil {
alias = string(useNameParts[len(useNameParts)-1].(*ast.NameNamePart).Value)
} else {
alias = string(n.Alias.(*ast.Identifier).Value)
} }
for _, nn := range n.UseList { nsr.Namespace.AddAlias(nsr.useType, concatNameParts(nsr.usePrefix, useNameParts), alias)
nsr.AddAlias(useType, nn, n.Prefix.(*ast.NameName).Parts)
}
nsr.goDeep = false nsr.goDeep = false
} }
@ -213,26 +215,10 @@ func (nsr *NamespaceResolver) LeaveNode(n ast.Vertex) {
if nn.Stmts != nil { if nn.Stmts != nil {
nsr.Namespace = NewNamespace("") nsr.Namespace = NewNamespace("")
} }
} case *ast.StmtUseType:
} nsr.useType = ""
case *ast.StmtGroupUseList:
// AddAlias adds a new alias nsr.usePrefix = nil
func (nsr *NamespaceResolver) AddAlias(useType string, nn ast.Vertex, prefix []ast.Vertex) {
switch use := nn.(type) {
case *ast.StmtUse:
if use.UseType != nil {
useType = string(use.UseType.(*ast.Identifier).Value)
}
useNameParts := use.Use.(*ast.NameName).Parts
var alias string
if use.Alias == nil {
alias = string(useNameParts[len(useNameParts)-1].(*ast.NameNamePart).Value)
} else {
alias = string(use.Alias.(*ast.Identifier).Value)
}
nsr.Namespace.AddAlias(useType, concatNameParts(prefix, useNameParts), alias)
} }
} }

View File

@ -16,13 +16,15 @@ func TestResolveStaticCall(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
&ast.ExprStaticCall{ &ast.ExprStaticCall{
Class: nameBC, Class: nameBC,
Call: &ast.Identifier{Value: []byte("foo")}, Call: &ast.Identifier{Value: []byte("foo")},
@ -48,13 +50,15 @@ func TestResolveStaticPropertyFetch(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
&ast.ExprStaticPropertyFetch{ &ast.ExprStaticPropertyFetch{
Class: nameBC, Class: nameBC,
Property: &ast.Identifier{Value: []byte("foo")}, Property: &ast.Identifier{Value: []byte("foo")},
@ -79,13 +83,15 @@ func TestResolveClassConstFetch(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
&ast.ExprClassConstFetch{ &ast.ExprClassConstFetch{
Class: nameBC, Class: nameBC,
ConstantName: &ast.Identifier{Value: []byte("FOO")}, ConstantName: &ast.Identifier{Value: []byte("FOO")},
@ -110,13 +116,15 @@ func TestResolveNew(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
&ast.ExprNew{ &ast.ExprNew{
Class: nameBC, Class: nameBC,
ArgumentList: &ast.ArgumentList{}, ArgumentList: &ast.ArgumentList{},
@ -141,13 +149,15 @@ func TestResolveInstanceOf(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
&ast.ExprInstanceOf{ &ast.ExprInstanceOf{
Expr: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}}, Expr: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
Class: nameBC, Class: nameBC,
@ -175,17 +185,18 @@ func TestResolveInstanceCatch(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, }, &ast.StmtUseDeclaration{
&ast.StmtUse{
Use: nameDE, Use: nameDE,
Alias: &ast.Identifier{Value: []byte("F")}, Alias: &ast.Identifier{Value: []byte("F")},
}, },
}, },
}, },
},
&ast.StmtTry{ &ast.StmtTry{
Stmts: []ast.Vertex{}, Stmts: []ast.Vertex{},
Catches: []ast.Vertex{ Catches: []ast.Vertex{
@ -220,14 +231,18 @@ func TestResolveFunctionCall(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
UseType: &ast.Identifier{Value: []byte("function")},
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("function")},
Use: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
},
&ast.ExprFunctionCall{ &ast.ExprFunctionCall{
Function: nameB, Function: nameB,
ArgumentList: &ast.ArgumentList{}, ArgumentList: &ast.ArgumentList{},
@ -252,14 +267,18 @@ func TestResolveConstFetch(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
UseType: &ast.Identifier{Value: []byte("const")},
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("const")},
Use: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
},
&ast.ExprConstFetch{ &ast.ExprConstFetch{
Const: nameB, Const: nameB,
}, },
@ -286,28 +305,42 @@ func TestResolveGroupUse(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtGroupUse{
Prefix: nameAB,
UseList: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseType: &ast.Identifier{Value: []byte("Function")}, UseList: &ast.StmtGroupUseList{
Prefix: nameAB,
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("Function")},
Use: &ast.StmtUseDeclaration{
Use: nameF, Use: nameF,
}, },
&ast.StmtUse{ },
UseType: &ast.Identifier{Value: []byte("const")}, &ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("const")},
Use: &ast.StmtUseDeclaration{
Use: nameC, Use: nameC,
}, },
}, },
}, },
&ast.StmtGroupUse{ },
Prefix: nameBD, },
UseType: &ast.Identifier{Value: []byte("Function")}, },
UseList: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("Function")},
Use: &ast.StmtGroupUseList{
Prefix: nameBD,
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameE, Use: nameE,
}, },
}, },
}, },
},
},
},
&ast.ExprConstFetch{ &ast.ExprConstFetch{
Const: nameC, Const: nameC,
}, },
@ -347,13 +380,15 @@ func TestResolveTraitUse(t *testing.T) {
stxTree := &ast.StmtStmtList{ stxTree := &ast.StmtStmtList{
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAB, Use: nameAB,
}, },
}, },
}, },
},
&ast.StmtTraitUse{ &ast.StmtTraitUse{
Traits: []ast.Vertex{ Traits: []ast.Vertex{
nameB, nameB,
@ -668,13 +703,15 @@ func TestResolveNamespaces(t *testing.T) {
&ast.StmtNamespace{ &ast.StmtNamespace{
NamespaceName: namespaceCD, NamespaceName: namespaceCD,
Stmts: []ast.Vertex{ Stmts: []ast.Vertex{
&ast.StmtUseList{
Uses: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUse{
UseList: &ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: nameAC, Use: nameAC,
}, },
}, },
}, },
},
&ast.ExprStaticCall{ &ast.ExprStaticCall{
Class: relativeNameCE, Class: relativeNameCE,
Call: &ast.Identifier{Value: []byte("foo")}, Call: &ast.Identifier{Value: []byte("foo")},

View File

@ -182,10 +182,6 @@ func (v *Null) StmtGoto(_ *ast.StmtGoto) {
// do nothing // do nothing
} }
func (v *Null) StmtGroupUse(_ *ast.StmtGroupUse) {
// do nothing
}
func (v *Null) StmtHaltCompiler(_ *ast.StmtHaltCompiler) { func (v *Null) StmtHaltCompiler(_ *ast.StmtHaltCompiler) {
// do nothing // do nothing
} }
@ -286,10 +282,22 @@ func (v *Null) StmtUse(_ *ast.StmtUse) {
// do nothing // do nothing
} }
func (v *Null) StmtGroupUseList(_ *ast.StmtGroupUseList) {
// do nothing
}
func (v *Null) StmtUseList(_ *ast.StmtUseList) { func (v *Null) StmtUseList(_ *ast.StmtUseList) {
// do nothing // do nothing
} }
func (v *Null) StmtUseDeclaration(_ *ast.StmtUseDeclaration) {
// do nothing
}
func (v *Null) StmtUseType(_ *ast.StmtUseType) {
// do nothing
}
func (v *Null) StmtWhile(_ *ast.StmtWhile) { func (v *Null) StmtWhile(_ *ast.StmtWhile) {
// do nothing // do nothing
} }

View File

@ -353,8 +353,6 @@ func (p *PrettyPrinter) printNode(n ast.Vertex) {
p.printStmtGlobal(n) p.printStmtGlobal(n)
case *ast.StmtGoto: case *ast.StmtGoto:
p.printStmtGoto(n) p.printStmtGoto(n)
case *ast.StmtGroupUse:
p.printStmtGroupUse(n)
case *ast.StmtHaltCompiler: case *ast.StmtHaltCompiler:
p.printStmtHaltCompiler(n) p.printStmtHaltCompiler(n)
case *ast.StmtIf: case *ast.StmtIf:
@ -399,10 +397,16 @@ func (p *PrettyPrinter) printNode(n ast.Vertex) {
p.printStmtTry(n) p.printStmtTry(n)
case *ast.StmtUnset: case *ast.StmtUnset:
p.printStmtUnset(n) p.printStmtUnset(n)
case *ast.StmtUseList:
p.printStmtUseList(n)
case *ast.StmtUse: case *ast.StmtUse:
p.printStmtUse(n) p.printStmtUse(n)
case *ast.StmtGroupUseList:
p.printStmtGroupUseList(n)
case *ast.StmtUseList:
p.printStmtUseList(n)
case *ast.StmtUseDeclaration:
p.printStmtUseDeclaration(n)
case *ast.StmtUseType:
p.printStmtUseType(n)
case *ast.StmtWhile: case *ast.StmtWhile:
p.printStmtWhile(n) p.printStmtWhile(n)
} }
@ -1847,22 +1851,6 @@ func (p *PrettyPrinter) printStmtGoto(n ast.Vertex) {
io.WriteString(p.w, ";") io.WriteString(p.w, ";")
} }
func (p *PrettyPrinter) printStmtGroupUse(n ast.Vertex) {
nn := n.(*ast.StmtGroupUse)
io.WriteString(p.w, "use ")
if nn.UseType != nil {
p.Print(nn.UseType)
io.WriteString(p.w, " ")
}
p.Print(nn.Prefix)
io.WriteString(p.w, "\\{")
p.joinPrint(", ", nn.UseList)
io.WriteString(p.w, "};")
}
func (p *PrettyPrinter) printStmtHaltCompiler(n ast.Vertex) { func (p *PrettyPrinter) printStmtHaltCompiler(n ast.Vertex) {
io.WriteString(p.w, "__halt_compiler();") io.WriteString(p.w, "__halt_compiler();")
} }
@ -2146,27 +2134,34 @@ func (p *PrettyPrinter) printStmtUnset(n ast.Vertex) {
io.WriteString(p.w, ");") io.WriteString(p.w, ");")
} }
func (p *PrettyPrinter) printStmtUseList(n ast.Vertex) {
nn := n.(*ast.StmtUseList)
io.WriteString(p.w, "use ")
if nn.UseType != nil {
p.Print(nn.UseType)
io.WriteString(p.w, " ")
}
p.joinPrint(", ", nn.Uses)
io.WriteString(p.w, ";")
}
func (p *PrettyPrinter) printStmtUse(n ast.Vertex) { func (p *PrettyPrinter) printStmtUse(n ast.Vertex) {
nn := n.(*ast.StmtUse) nn := n.(*ast.StmtUse)
if nn.UseType != nil { io.WriteString(p.w, "use ")
p.Print(nn.UseType)
io.WriteString(p.w, " ") p.Print(nn.UseList)
}
io.WriteString(p.w, ";")
}
func (p *PrettyPrinter) printStmtGroupUseList(n ast.Vertex) {
nn := n.(*ast.StmtGroupUseList)
p.Print(nn.Prefix)
io.WriteString(p.w, "\\{")
p.Print(nn.UseList)
io.WriteString(p.w, "}")
}
func (p *PrettyPrinter) printStmtUseList(n ast.Vertex) {
nn := n.(*ast.StmtUseList)
p.joinPrint(", ", nn.UseDeclarations)
}
func (p *PrettyPrinter) printStmtUseDeclaration(n ast.Vertex) {
nn := n.(*ast.StmtUseDeclaration)
p.Print(nn.Use) p.Print(nn.Use)
@ -2176,6 +2171,15 @@ func (p *PrettyPrinter) printStmtUse(n ast.Vertex) {
} }
} }
func (p *PrettyPrinter) printStmtUseType(n ast.Vertex) {
nn := n.(*ast.StmtUseType)
p.Print(nn.Type)
io.WriteString(p.w, " ")
p.Print(nn.Use)
}
func (p *PrettyPrinter) printStmtWhile(n ast.Vertex) { func (p *PrettyPrinter) printStmtWhile(n ast.Vertex) {
nn := n.(*ast.StmtWhile) nn := n.(*ast.StmtWhile)

View File

@ -3256,32 +3256,6 @@ func TestPrintStmtGoto(t *testing.T) {
} }
} }
func TestPrintStmtGroupUse(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtGroupUse{
UseType: &ast.Identifier{Value: []byte("function")},
Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
UseList: []ast.Vertex{
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
Alias: &ast.Identifier{Value: []byte("Baz")},
},
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Quuz")}}},
},
},
})
expected := `use function Foo\{Bar as Baz, Quuz};`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrintHaltCompiler(t *testing.T) { func TestPrintHaltCompiler(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
@ -3975,24 +3949,15 @@ func TestPrintStmtUset(t *testing.T) {
} }
} }
func TestPrintStmtUseList(t *testing.T) { func TestPrintUse(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
p := printer.NewPrettyPrinter(o, " ") p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtUseList{ p.Print(&ast.StmtUse{
UseType: &ast.Identifier{Value: []byte("function")}, UseList: &ast.StmtUseList{},
Uses: []ast.Vertex{
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")},
},
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
},
},
}) })
expected := `use function Foo as Bar, Baz;` expected := `use ;`
actual := o.String() actual := o.String()
if expected != actual { if expected != actual {
@ -4000,14 +3965,74 @@ func TestPrintStmtUseList(t *testing.T) {
} }
} }
func TestPrintUse(t *testing.T) { func TestPrintStmtGroupUseList(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
p := printer.NewPrettyPrinter(o, " ") p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtUse{ p.Print(&ast.StmtGroupUseList{
UseType: &ast.Identifier{Value: []byte("function")}, Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
UseList: &ast.StmtUseList{},
})
expected := `Foo\{}`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrintStmtUseList(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}}, Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")}, Alias: &ast.Identifier{Value: []byte("Bar")},
},
&ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
},
},
})
expected := `Foo as Bar, Baz`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrintUseDeclaration(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")},
})
expected := `Foo as Bar`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrintUseType(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrettyPrinter(o, " ")
p.Print(&ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("function")},
Use: &ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")},
},
}) })
expected := `function Foo as Bar` expected := `function Foo as Bar`

View File

@ -18,6 +18,8 @@ const (
type Printer struct { type Printer struct {
w io.Writer w io.Writer
s printerState s printerState
bufStart string
bufEnd string
} }
// NewPrinter - Constructor for Printer // NewPrinter - Constructor for Printer
@ -60,6 +62,21 @@ func (p *Printer) printNodes(nn []ast.Vertex) {
} }
} }
func (p *Printer) printFreeFloatingOrDefault(n ast.Vertex, pos token.Position, def string) {
if n == nil {
return
}
if len(n.GetNode().Tokens[pos]) == 0 {
io.WriteString(p.w, def)
return
}
for _, m := range n.GetNode().Tokens[pos] {
io.WriteString(p.w, string(m.Value))
}
}
func (p *Printer) printFreeFloating(n ast.Vertex, pos token.Position) { func (p *Printer) printFreeFloating(n ast.Vertex, pos token.Position) {
if n == nil { if n == nil {
return return
@ -374,8 +391,6 @@ func (p *Printer) printNode(n ast.Vertex) {
p.printStmtGlobal(n) p.printStmtGlobal(n)
case *ast.StmtGoto: case *ast.StmtGoto:
p.printStmtGoto(n) p.printStmtGoto(n)
case *ast.StmtGroupUse:
p.printStmtGroupUse(n)
case *ast.StmtHaltCompiler: case *ast.StmtHaltCompiler:
p.printStmtHaltCompiler(n) p.printStmtHaltCompiler(n)
case *ast.StmtIf: case *ast.StmtIf:
@ -422,10 +437,16 @@ func (p *Printer) printNode(n ast.Vertex) {
p.printStmtTry(n) p.printStmtTry(n)
case *ast.StmtUnset: case *ast.StmtUnset:
p.printStmtUnset(n) p.printStmtUnset(n)
case *ast.StmtUseList:
p.printStmtUseList(n)
case *ast.StmtUse: case *ast.StmtUse:
p.printStmtUse(n) p.printStmtUse(n)
case *ast.StmtGroupUseList:
p.printStmtGroupUseList(n)
case *ast.StmtUseList:
p.printStmtUseList(n)
case *ast.StmtUseDeclaration:
p.printStmtUseDeclaration(n)
case *ast.StmtUseType:
p.printStmtUseType(n)
case *ast.StmtWhile: case *ast.StmtWhile:
p.printStmtWhile(n) p.printStmtWhile(n)
} }
@ -443,8 +464,11 @@ func (p *Printer) printNodeRoot(n ast.Vertex) {
func (p *Printer) printNodeIdentifier(n ast.Vertex) { func (p *Printer) printNodeIdentifier(n ast.Vertex) {
nn := n.(*ast.Identifier) nn := n.(*ast.Identifier)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
@ -519,7 +543,8 @@ func (p *Printer) printNodeArgument(n ast.Vertex) {
func (p *Printer) printNameNamePart(n ast.Vertex) { func (p *Printer) printNameNamePart(n ast.Vertex) {
nn := n.(*ast.NameNamePart) nn := n.(*ast.NameNamePart)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
@ -532,22 +557,26 @@ func (p *Printer) printNameName(n ast.Vertex) {
p.joinPrint("\\", nn.Parts) p.joinPrint("\\", nn.Parts)
p.printFreeFloating(nn, token.End) p.printFreeFloatingOrDefault(nn, token.End, p.bufEnd)
p.bufEnd = ""
} }
func (p *Printer) printNameFullyQualified(n ast.Vertex) { func (p *Printer) printNameFullyQualified(n ast.Vertex) {
nn := n.(*ast.NameFullyQualified) nn := n.(*ast.NameFullyQualified)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, "\\") io.WriteString(p.w, "\\")
p.joinPrint("\\", nn.Parts) p.joinPrint("\\", nn.Parts)
p.printFreeFloating(nn, token.End) p.printFreeFloatingOrDefault(nn, token.End, p.bufEnd)
p.bufEnd = ""
} }
func (p *Printer) printNameRelative(n ast.Vertex) { func (p *Printer) printNameRelative(n ast.Vertex) {
nn := n.(*ast.NameRelative) nn := n.(*ast.NameRelative)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, "namespace") io.WriteString(p.w, "namespace")
p.printFreeFloating(nn, token.Namespace) p.printFreeFloating(nn, token.Namespace)
@ -557,7 +586,8 @@ func (p *Printer) printNameRelative(n ast.Vertex) {
p.Print(part) p.Print(part)
} }
p.printFreeFloating(nn, token.End) p.printFreeFloatingOrDefault(nn, token.End, p.bufEnd)
p.bufEnd = ""
} }
// scalar // scalar
@ -2710,41 +2740,6 @@ func (p *Printer) printStmtGoto(n ast.Vertex) {
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtGroupUse(n ast.Vertex) {
nn := n.(*ast.StmtGroupUse)
p.printFreeFloating(nn, token.Start)
io.WriteString(p.w, "use")
p.printFreeFloating(nn, token.Use)
if nn.UseType != nil {
if nn.UseType.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
p.Print(nn.UseType)
}
if nn.Prefix.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
p.Print(nn.Prefix)
io.WriteString(p.w, "\\")
p.printFreeFloating(nn, token.Slash)
io.WriteString(p.w, "{")
p.joinPrint(",", nn.UseList)
p.printFreeFloating(nn, token.Stmts)
io.WriteString(p.w, "}")
p.printFreeFloating(nn, token.UseDeclarationList)
p.printFreeFloating(nn, token.SemiColon)
if nn.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, ";")
}
p.printFreeFloating(nn, token.End)
}
func (p *Printer) printStmtHaltCompiler(n ast.Vertex) { func (p *Printer) printStmtHaltCompiler(n ast.Vertex) {
nn := n.(*ast.StmtHaltCompiler) nn := n.(*ast.StmtHaltCompiler)
p.printFreeFloating(nn, token.Start) p.printFreeFloating(nn, token.Start)
@ -3197,59 +3192,78 @@ func (p *Printer) printStmtUnset(n ast.Vertex) {
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtUseList(n ast.Vertex) { func (p *Printer) printStmtUse(n ast.Vertex) {
nn := n.(*ast.StmtUseList) nn := n.(*ast.StmtUse)
p.printFreeFloating(nn, token.Start) p.printFreeFloating(nn, token.Start)
io.WriteString(p.w, "use") io.WriteString(p.w, "use")
if nn.UseType != nil { p.bufStart = " "
if nn.UseType.GetNode().Tokens.IsEmpty() { p.Print(nn.UseList)
io.WriteString(p.w, " ")
} p.printFreeFloatingOrDefault(nn, token.End, ";")
p.Print(nn.UseType) }
func (p *Printer) printStmtGroupUseList(n ast.Vertex) {
nn := n.(*ast.StmtGroupUseList)
p.printFreeFloating(nn, token.Start)
p.Print(nn.Prefix)
p.bufStart = "\\{"
p.bufEnd = "}"
p.Print(nn.UseList)
p.printFreeFloating(nn, token.End)
}
func (p *Printer) printStmtUseList(n ast.Vertex) {
nn := n.(*ast.StmtUseList)
bufEnd := p.bufEnd
p.bufEnd = ""
if p.bufStart == "\\{" {
p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
} else {
p.printFreeFloating(nn, token.Start)
} }
if nn.Uses[0].GetNode().Tokens.IsEmpty() { p.joinPrint(",", nn.UseDeclarations)
io.WriteString(p.w, " ")
}
p.joinPrint(",", nn.Uses)
p.printFreeFloating(nn, token.UseDeclarationList)
p.printFreeFloating(nn, token.SemiColon) p.printFreeFloatingOrDefault(nn, token.End, bufEnd)
if nn.GetNode().Tokens.IsEmpty() { }
io.WriteString(p.w, ";")
func (p *Printer) printStmtUseDeclaration(n ast.Vertex) {
nn := n.(*ast.StmtUseDeclaration)
p.printFreeFloating(nn, token.Start)
if nn.Alias != nil {
p.bufEnd = " "
}
p.Print(nn.Use)
if nn.Alias != nil {
io.WriteString(p.w, "as")
p.bufStart = " "
p.Print(nn.Alias)
} }
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtUse(n ast.Vertex) { func (p *Printer) printStmtUseType(n ast.Vertex) {
nn := n.(*ast.StmtUse) nn := n.(*ast.StmtUseType)
p.printFreeFloating(nn, token.Start) p.printFreeFloating(nn, token.Start)
if nn.UseType != nil { p.Print(nn.Type)
p.Print(nn.UseType)
if nn.UseType.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
}
p.printFreeFloating(nn, token.Slash)
p.bufStart = " "
p.Print(nn.Use) p.Print(nn.Use)
if nn.Alias != nil {
if nn.Alias.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
io.WriteString(p.w, "as")
if nn.Alias.GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ")
}
p.Print(nn.Alias)
}
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }

View File

@ -3673,32 +3673,6 @@ func TestPrinterPrintStmtGoto(t *testing.T) {
} }
} }
func TestPrinterPrintStmtGroupUse(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o)
p.Print(&ast.StmtGroupUse{
UseType: &ast.Identifier{Value: []byte("function")},
Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
UseList: []ast.Vertex{
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
Alias: &ast.Identifier{Value: []byte("Baz")},
},
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Quuz")}}},
},
},
})
expected := `use function Foo\{Bar as Baz,Quuz};`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrinterPrintHaltCompiler(t *testing.T) { func TestPrinterPrintHaltCompiler(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
@ -4412,24 +4386,21 @@ func TestPrinterPrintStmtUnset(t *testing.T) {
} }
} }
func TestPrinterPrintStmtUseList(t *testing.T) { func TestPrinterPrintUse(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
p := printer.NewPrinter(o) p := printer.NewPrinter(o)
p.Print(&ast.StmtUseList{ p.Print(&ast.StmtUse{
UseType: &ast.Identifier{Value: []byte("function")}, UseList: &ast.StmtUseList{
Uses: []ast.Vertex{ UseDeclarations: []ast.Vertex{
&ast.StmtUse{ &ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}}, Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")},
}, },
&ast.StmtUse{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
}, },
}, },
}) })
expected := `use function Foo as Bar,Baz;` expected := `use Foo;`
actual := o.String() actual := o.String()
if expected != actual { if expected != actual {
@ -4437,14 +4408,74 @@ func TestPrinterPrintStmtUseList(t *testing.T) {
} }
} }
func TestPrinterPrintUse(t *testing.T) { func TestPrinterPrintStmtGroupUseList(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
p := printer.NewPrinter(o) p := printer.NewPrinter(o)
p.Print(&ast.StmtUse{ p.Print(&ast.StmtGroupUseList{
UseType: &ast.Identifier{Value: []byte("function")}, Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
UseList: &ast.StmtUseList{},
})
expected := `Foo\{}`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrinterPrintStmtUseList(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o)
p.Print(&ast.StmtUseList{
UseDeclarations: []ast.Vertex{
&ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}}, Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")}, Alias: &ast.Identifier{Value: []byte("Bar")},
},
&ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
},
},
})
expected := `Foo as Bar,Baz`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrinterPrintUseDeclaration(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o)
p.Print(&ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")},
})
expected := `Foo as Bar`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrinterPrintUseType(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o)
p.Print(&ast.StmtUseType{
Type: &ast.Identifier{Value: []byte("function")},
Use: &ast.StmtUseDeclaration{
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
Alias: &ast.Identifier{Value: []byte("Bar")},
},
}) })
expected := `function Foo as Bar` expected := `function Foo as Bar`

View File

@ -6,7 +6,6 @@ type Position int
const ( const (
Start Position = iota Start Position = iota
End End
Slash
Colon Colon
SemiColon SemiColon
AltEnd AltEnd

View File

@ -10,85 +10,84 @@ func _() {
var x [1]struct{} var x [1]struct{}
_ = x[Start-0] _ = x[Start-0]
_ = x[End-1] _ = x[End-1]
_ = x[Slash-2] _ = x[Colon-2]
_ = x[Colon-3] _ = x[SemiColon-3]
_ = x[SemiColon-4] _ = x[AltEnd-4]
_ = x[AltEnd-5] _ = x[Dollar-5]
_ = x[Dollar-6] _ = x[Ampersand-6]
_ = x[Ampersand-7] _ = x[Name-7]
_ = x[Name-8] _ = x[Prefix-8]
_ = x[Prefix-9] _ = x[Key-9]
_ = x[Key-10] _ = x[Var-10]
_ = x[Var-11] _ = x[UseType-11]
_ = x[UseType-12] _ = x[ReturnType-12]
_ = x[ReturnType-13] _ = x[OptionalType-13]
_ = x[OptionalType-14] _ = x[CaseSeparator-14]
_ = x[CaseSeparator-15] _ = x[LexicalVars-15]
_ = x[LexicalVars-16] _ = x[Params-16]
_ = x[Params-17] _ = x[Ref-17]
_ = x[Ref-18] _ = x[Cast-18]
_ = x[Cast-19] _ = x[Expr-19]
_ = x[Expr-20] _ = x[InitExpr-20]
_ = x[InitExpr-21] _ = x[CondExpr-21]
_ = x[CondExpr-22] _ = x[IncExpr-22]
_ = x[IncExpr-23] _ = x[True-23]
_ = x[True-24] _ = x[Cond-24]
_ = x[Cond-25] _ = x[HaltCompiller-25]
_ = x[HaltCompiller-26] _ = x[Namespace-26]
_ = x[Namespace-27] _ = x[Static-27]
_ = x[Static-28] _ = x[Class-28]
_ = x[Class-29] _ = x[Use-29]
_ = x[Use-30] _ = x[While-30]
_ = x[While-31] _ = x[For-31]
_ = x[For-32] _ = x[Switch-32]
_ = x[Switch-33] _ = x[Break-33]
_ = x[Break-34] _ = x[Foreach-34]
_ = x[Foreach-35] _ = x[Declare-35]
_ = x[Declare-36] _ = x[Label-36]
_ = x[Label-37] _ = x[Finally-37]
_ = x[Finally-38] _ = x[List-38]
_ = x[List-39] _ = x[Default-39]
_ = x[Default-40] _ = x[If-40]
_ = x[If-41] _ = x[ElseIf-41]
_ = x[ElseIf-42] _ = x[Else-42]
_ = x[Else-43] _ = x[Variadic-43]
_ = x[Variadic-44] _ = x[Function-44]
_ = x[Function-45] _ = x[DoubleArrow-45]
_ = x[DoubleArrow-46] _ = x[Alias-46]
_ = x[Alias-47] _ = x[As-47]
_ = x[As-48] _ = x[Equal-48]
_ = x[Equal-49] _ = x[Exit-49]
_ = x[Exit-50] _ = x[Array-50]
_ = x[Array-51] _ = x[Isset-51]
_ = x[Isset-52] _ = x[Empty-52]
_ = x[Empty-53] _ = x[Eval-53]
_ = x[Eval-54] _ = x[Echo-54]
_ = x[Echo-55] _ = x[Try-55]
_ = x[Try-56] _ = x[Catch-56]
_ = x[Catch-57] _ = x[Unset-57]
_ = x[Unset-58] _ = x[Stmts-58]
_ = x[Stmts-59] _ = x[VarList-59]
_ = x[VarList-60] _ = x[ConstList-60]
_ = x[ConstList-61] _ = x[NameList-61]
_ = x[NameList-62] _ = x[ParamList-62]
_ = x[ParamList-63] _ = x[ModifierList-63]
_ = x[ModifierList-64] _ = x[ArrayPairList-64]
_ = x[ArrayPairList-65] _ = x[CaseListStart-65]
_ = x[CaseListStart-66] _ = x[CaseListEnd-66]
_ = x[CaseListEnd-67] _ = x[ArgumentList-67]
_ = x[ArgumentList-68] _ = x[PropertyList-68]
_ = x[PropertyList-69] _ = x[ParameterList-69]
_ = x[ParameterList-70] _ = x[AdaptationList-70]
_ = x[AdaptationList-71] _ = x[LexicalVarList-71]
_ = x[LexicalVarList-72] _ = x[UseDeclarationList-72]
_ = x[UseDeclarationList-73] _ = x[OpenParenthesisToken-73]
_ = x[OpenParenthesisToken-74] _ = x[CloseParenthesisToken-74]
_ = x[CloseParenthesisToken-75]
} }
const _Position_name = "StartEndSlashColonSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionDoubleArrowAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken" const _Position_name = "StartEndColonSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionDoubleArrowAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken"
var _Position_index = [...]uint16{0, 5, 8, 13, 18, 27, 33, 39, 48, 52, 58, 61, 64, 71, 81, 93, 106, 117, 123, 126, 130, 134, 142, 150, 157, 161, 165, 178, 187, 193, 198, 201, 206, 209, 215, 220, 227, 234, 239, 246, 250, 257, 259, 265, 269, 277, 285, 296, 301, 303, 308, 312, 317, 322, 327, 331, 335, 338, 343, 348, 353, 360, 369, 377, 386, 398, 411, 424, 435, 447, 459, 472, 486, 500, 518, 538, 559} var _Position_index = [...]uint16{0, 5, 8, 13, 22, 28, 34, 43, 47, 53, 56, 59, 66, 76, 88, 101, 112, 118, 121, 125, 129, 137, 145, 152, 156, 160, 173, 182, 188, 193, 196, 201, 204, 210, 215, 222, 229, 234, 241, 245, 252, 254, 260, 264, 272, 280, 291, 296, 298, 303, 307, 312, 317, 322, 326, 330, 333, 338, 343, 348, 355, 364, 372, 381, 393, 406, 419, 430, 442, 454, 467, 481, 495, 513, 533, 554}
func (i Position) String() string { func (i Position) String() string {
if i < 0 || i >= Position(len(_Position_index)-1) { if i < 0 || i >= Position(len(_Position_index)-1) {