[refactoring] update use
ast structure
This commit is contained in:
parent
88dfd32d9e
commit
feebb017c4
File diff suppressed because it is too large
Load Diff
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -428,49 +428,56 @@ top_statement:
|
||||
}
|
||||
| T_USE use_declarations ';'
|
||||
{
|
||||
$$ = &ast.StmtUseList{ast.Node{}, nil, $2}
|
||||
useList := &ast.StmtUseList{ast.Node{}, $2}
|
||||
$$ = &ast.StmtUse{ast.Node{}, useList}
|
||||
|
||||
// save position
|
||||
useList.GetNode().Position = position.NewNodeListPosition($2)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $3.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_USE T_FUNCTION use_function_declarations ';'
|
||||
{
|
||||
useType := &ast.Identifier{ast.Node{}, $2.Value}
|
||||
$$ = &ast.StmtUseList{ast.Node{}, useType, $3}
|
||||
identifier := &ast.Identifier{ast.Node{}, $2.Value}
|
||||
useList := &ast.StmtUseList{ast.Node{}, $3}
|
||||
useType := &ast.StmtUseType{ast.Node{}, identifier, useList}
|
||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
||||
|
||||
// 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)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(identifier, token.Start, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(useType, token.Start, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_USE T_CONST use_const_declarations ';'
|
||||
{
|
||||
useType := &ast.Identifier{ast.Node{}, $2.Value}
|
||||
$$ = &ast.StmtUseList{ast.Node{}, useType, $3}
|
||||
identifier := &ast.Identifier{ast.Node{}, $2.Value}
|
||||
useList := &ast.StmtUseList{ast.Node{}, $3}
|
||||
useType := &ast.StmtUseType{ast.Node{}, identifier, useList}
|
||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
||||
|
||||
// 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)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(identifier, token.Start, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(useType, token.Start, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -511,22 +518,19 @@ use_declaration:
|
||||
namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| namespace_name T_AS T_STRING
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
@ -534,7 +538,6 @@ use_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
|
||||
|
||||
@ -543,16 +546,14 @@ use_declaration:
|
||||
| T_NS_SEPARATOR namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $2}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -560,7 +561,7 @@ use_declaration:
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $2}
|
||||
alias := &ast.Identifier{ast.Node{}, $4.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
@ -568,9 +569,7 @@ use_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($2, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens)
|
||||
|
||||
@ -600,22 +599,19 @@ use_function_declaration:
|
||||
namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| namespace_name T_AS T_STRING
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
@ -623,7 +619,6 @@ use_function_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
|
||||
|
||||
@ -632,16 +627,14 @@ use_function_declaration:
|
||||
| T_NS_SEPARATOR namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $2}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -649,7 +642,7 @@ use_function_declaration:
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $2}
|
||||
alias := &ast.Identifier{ast.Node{}, $4.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
@ -657,9 +650,7 @@ use_function_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($2, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens)
|
||||
|
||||
@ -689,22 +680,19 @@ use_const_declaration:
|
||||
namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| namespace_name T_AS T_STRING
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
@ -712,7 +700,6 @@ use_const_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
|
||||
|
||||
@ -721,16 +708,14 @@ use_const_declaration:
|
||||
| T_NS_SEPARATOR namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $2}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -738,7 +723,7 @@ use_const_declaration:
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $2}
|
||||
alias := &ast.Identifier{ast.Node{}, $4.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
@ -746,9 +731,7 @@ use_const_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($2, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.Tokens)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -528,58 +528,61 @@ top_statement:
|
||||
}
|
||||
| T_USE mixed_group_use_declaration ';'
|
||||
{
|
||||
$$ = $2
|
||||
$$ = &ast.StmtUse{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $3.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_USE use_type group_use_declaration ';'
|
||||
{
|
||||
$3.(*ast.StmtGroupUse).UseType = $2
|
||||
$$ = $3
|
||||
useType := &ast.StmtUseType{ast.Node{}, $2, $3}
|
||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
||||
|
||||
// save position
|
||||
useType.GetNode().Position = position.NewNodesPosition($2, $3)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_USE use_declarations ';'
|
||||
{
|
||||
$$ = &ast.StmtUseList{ast.Node{}, nil, $2}
|
||||
useList := &ast.StmtUseList{ast.Node{}, $2}
|
||||
$$ = &ast.StmtUse{ast.Node{}, useList}
|
||||
|
||||
// save position
|
||||
useList.GetNode().Position = position.NewNodeListPosition($2)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $3.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| 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
|
||||
useList.GetNode().Position = position.NewNodeListPosition($3)
|
||||
useType.GetNode().Position = position.NewNodesPosition($2, useList)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseDeclarationList, $4.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -630,20 +633,20 @@ group_use_declaration:
|
||||
namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
||||
{
|
||||
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
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
useList.GetNode().Position = position.NewNodeListPosition($4)
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $6)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], name)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Slash, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($2.Tokens, $3.Tokens...))
|
||||
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 {
|
||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $6.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(useList, token.End, $6.Tokens)
|
||||
}
|
||||
|
||||
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 '}'
|
||||
{
|
||||
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
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
useList.GetNode().Position = position.NewNodeListPosition($5)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $7)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.UseType, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Slash, $4.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($3.Tokens, $4.Tokens...))
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
@ -676,20 +679,20 @@ mixed_group_use_declaration:
|
||||
namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
||||
{
|
||||
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
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
useList.GetNode().Position = position.NewNodeListPosition($4)
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $6)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], name)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Slash, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($2.Tokens, $3.Tokens...))
|
||||
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 {
|
||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $6.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.End, $6.Tokens)
|
||||
}
|
||||
|
||||
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 '}'
|
||||
{
|
||||
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
|
||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
||||
useList.GetNode().Position = position.NewNodeListPosition($5)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $7)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Use, $1.Tokens)
|
||||
yylex.(*Parser).MoveFreeFloating($2[0], name)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.Slash, $4.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.Start, append($3.Tokens, $4.Tokens...))
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
@ -792,8 +795,10 @@ inline_use_declaration:
|
||||
}
|
||||
| use_type unprefixed_use_declaration
|
||||
{
|
||||
$2.(*ast.StmtUse).UseType = $1
|
||||
$$ = $2
|
||||
$$ = &ast.StmtUseType{ast.Node{}, $1, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewNodesPosition($1, $2)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -803,14 +808,11 @@ unprefixed_use_declaration:
|
||||
namespace_name
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, nil}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], name)
|
||||
$$.GetNode().Position = position.NewNodePosition(name)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@ -818,7 +820,7 @@ unprefixed_use_declaration:
|
||||
{
|
||||
name := &ast.NameName{ast.Node{}, $1}
|
||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
||||
$$ = &ast.StmtUse{ast.Node{}, nil, name, alias}
|
||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
||||
|
||||
// save position
|
||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
||||
@ -826,7 +828,6 @@ unprefixed_use_declaration:
|
||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).MoveFreeFloating($1[0], name)
|
||||
yylex.(*Parser).setFreeFloating(name, token.End, $2.Tokens)
|
||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.Tokens)
|
||||
|
||||
@ -839,9 +840,6 @@ use_declaration:
|
||||
{
|
||||
$$ = $1
|
||||
|
||||
// save coments
|
||||
yylex.(*Parser).MoveFreeFloating($1.(*ast.StmtUse).Use, $$)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_NS_SEPARATOR unprefixed_use_declaration
|
||||
@ -849,8 +847,7 @@ use_declaration:
|
||||
$$ = $2;
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
|
||||
yylex.(*Parser).setToken($$, token.Slash, $1.Tokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,6 @@ type NodeVisitor interface {
|
||||
StmtFunction(n *StmtFunction)
|
||||
StmtGlobal(n *StmtGlobal)
|
||||
StmtGoto(n *StmtGoto)
|
||||
StmtGroupUse(n *StmtGroupUse)
|
||||
StmtHaltCompiler(n *StmtHaltCompiler)
|
||||
StmtIf(n *StmtIf)
|
||||
StmtInlineHtml(n *StmtInlineHtml)
|
||||
@ -85,7 +84,10 @@ type NodeVisitor interface {
|
||||
StmtTry(n *StmtTry)
|
||||
StmtUnset(n *StmtUnset)
|
||||
StmtUse(n *StmtUse)
|
||||
StmtGroupUseList(n *StmtGroupUseList)
|
||||
StmtUseList(n *StmtUseList)
|
||||
StmtUseDeclaration(n *StmtUseDeclaration)
|
||||
StmtUseType(n *StmtUseType)
|
||||
StmtWhile(n *StmtWhile)
|
||||
|
||||
ExprArray(n *ExprArray)
|
||||
|
@ -532,18 +532,6 @@ func (n *StmtGoto) Accept(v NodeVisitor) {
|
||||
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
|
||||
type StmtHaltCompiler struct {
|
||||
Node
|
||||
@ -804,26 +792,56 @@ func (n *StmtUnset) Accept(v NodeVisitor) {
|
||||
// StmtUse node
|
||||
type StmtUse struct {
|
||||
Node
|
||||
UseType Vertex
|
||||
Use Vertex
|
||||
Alias Vertex
|
||||
UseList Vertex
|
||||
}
|
||||
|
||||
func (n *StmtUse) Accept(v NodeVisitor) {
|
||||
v.StmtUse(n)
|
||||
}
|
||||
|
||||
// StmtGroupUseList node
|
||||
type StmtGroupUseList struct {
|
||||
Node
|
||||
Prefix Vertex
|
||||
UseList Vertex
|
||||
}
|
||||
|
||||
func (n *StmtGroupUseList) Accept(v NodeVisitor) {
|
||||
v.StmtGroupUseList(n)
|
||||
}
|
||||
|
||||
// StmtUseList node
|
||||
type StmtUseList struct {
|
||||
Node
|
||||
UseType Vertex
|
||||
Uses []Vertex
|
||||
UseDeclarations []Vertex
|
||||
}
|
||||
|
||||
func (n *StmtUseList) Accept(v NodeVisitor) {
|
||||
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
|
||||
type StmtWhile struct {
|
||||
Node
|
||||
|
@ -745,30 +745,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
||||
t.Traverse(nn.Label)
|
||||
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:
|
||||
if nn == nil {
|
||||
return
|
||||
@ -1174,10 +1150,48 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
||||
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.UseList != nil {
|
||||
t.visitor.Enter("UseList", true)
|
||||
t.Traverse(nn.UseList)
|
||||
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 {
|
||||
t.visitor.Enter("Use", true)
|
||||
@ -1189,24 +1203,22 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
||||
t.Traverse(nn.Alias)
|
||||
t.visitor.Leave("Alias", true)
|
||||
}
|
||||
case *ast.StmtUseList:
|
||||
case *ast.StmtUseType:
|
||||
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.Type != nil {
|
||||
t.visitor.Enter("Type", true)
|
||||
t.Traverse(nn.Type)
|
||||
t.visitor.Leave("Type", true)
|
||||
}
|
||||
if nn.Uses != nil {
|
||||
t.visitor.Enter("Uses", false)
|
||||
for _, c := range nn.Uses {
|
||||
t.Traverse(c)
|
||||
}
|
||||
t.visitor.Leave("Uses", false)
|
||||
if nn.Use != nil {
|
||||
t.visitor.Enter("Use", true)
|
||||
t.Traverse(nn.Use)
|
||||
t.visitor.Leave("Use", true)
|
||||
}
|
||||
case *ast.StmtWhile:
|
||||
if nn == nil {
|
||||
|
@ -437,12 +437,6 @@ func (v *Dump) StmtGoto(n *ast.StmtGoto) {
|
||||
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) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.StmtHaltCompiler{\n")
|
||||
@ -596,12 +590,30 @@ func (v *Dump) StmtUse(n *ast.StmtUse) {
|
||||
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) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.StmtUseList{\n")
|
||||
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) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.StmtWhile{\n")
|
||||
|
@ -13,7 +13,9 @@ type NamespaceResolver struct {
|
||||
Namespace *Namespace
|
||||
ResolvedNames map[ast.Vertex]string
|
||||
|
||||
goDeep bool
|
||||
goDeep bool
|
||||
useType string
|
||||
usePrefix []ast.Vertex
|
||||
}
|
||||
|
||||
// NewNamespaceResolver NamespaceResolver type constructor
|
||||
@ -45,28 +47,28 @@ func (nsr *NamespaceResolver) StmtNamespace(n *ast.StmtNamespace) {
|
||||
}
|
||||
}
|
||||
|
||||
func (nsr *NamespaceResolver) StmtUseList(n *ast.StmtUseList) {
|
||||
useType := ""
|
||||
if n.UseType != nil {
|
||||
useType = string(n.UseType.(*ast.Identifier).Value)
|
||||
func (nsr *NamespaceResolver) StmtUseType(n *ast.StmtUseType) {
|
||||
if n.Type != nil {
|
||||
nsr.useType = string(n.Type.(*ast.Identifier).Value)
|
||||
}
|
||||
|
||||
for _, nn := range n.Uses {
|
||||
nsr.AddAlias(useType, nn, nil)
|
||||
}
|
||||
|
||||
nsr.goDeep = false
|
||||
}
|
||||
|
||||
func (nsr *NamespaceResolver) StmtGroupUse(n *ast.StmtGroupUse) {
|
||||
useType := ""
|
||||
if n.UseType != nil {
|
||||
useType = string(n.UseType.(*ast.Identifier).Value)
|
||||
func (nsr *NamespaceResolver) StmtGroupUseList(n *ast.StmtGroupUseList) {
|
||||
if n.Prefix != nil {
|
||||
nsr.usePrefix = n.Prefix.(*ast.NameName).Parts
|
||||
}
|
||||
}
|
||||
|
||||
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.AddAlias(useType, nn, n.Prefix.(*ast.NameName).Parts)
|
||||
}
|
||||
nsr.Namespace.AddAlias(nsr.useType, concatNameParts(nsr.usePrefix, useNameParts), alias)
|
||||
|
||||
nsr.goDeep = false
|
||||
}
|
||||
@ -213,26 +215,10 @@ func (nsr *NamespaceResolver) LeaveNode(n ast.Vertex) {
|
||||
if nn.Stmts != nil {
|
||||
nsr.Namespace = NewNamespace("")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AddAlias adds a new alias
|
||||
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)
|
||||
case *ast.StmtUseType:
|
||||
nsr.useType = ""
|
||||
case *ast.StmtGroupUseList:
|
||||
nsr.usePrefix = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,12 @@ func TestResolveStaticCall(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -48,10 +50,12 @@ func TestResolveStaticPropertyFetch(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -79,10 +83,12 @@ func TestResolveClassConstFetch(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -110,10 +116,12 @@ func TestResolveNew(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -141,10 +149,12 @@ func TestResolveInstanceOf(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -175,14 +185,15 @@ func TestResolveInstanceCatch(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
},
|
||||
&ast.StmtUse{
|
||||
Use: nameDE,
|
||||
Alias: &ast.Identifier{Value: []byte("F")},
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
}, &ast.StmtUseDeclaration{
|
||||
Use: nameDE,
|
||||
Alias: &ast.Identifier{Value: []byte("F")},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -220,11 +231,15 @@ func TestResolveFunctionCall(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
UseType: &ast.Identifier{Value: []byte("function")},
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseType{
|
||||
Type: &ast.Identifier{Value: []byte("function")},
|
||||
Use: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -252,11 +267,15 @@ func TestResolveConstFetch(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
UseType: &ast.Identifier{Value: []byte("const")},
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseType{
|
||||
Type: &ast.Identifier{Value: []byte("const")},
|
||||
Use: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -286,25 +305,39 @@ func TestResolveGroupUse(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtGroupUse{
|
||||
Prefix: nameAB,
|
||||
UseList: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
UseType: &ast.Identifier{Value: []byte("Function")},
|
||||
Use: nameF,
|
||||
},
|
||||
&ast.StmtUse{
|
||||
UseType: &ast.Identifier{Value: []byte("const")},
|
||||
Use: nameC,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtGroupUseList{
|
||||
Prefix: nameAB,
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseType{
|
||||
Type: &ast.Identifier{Value: []byte("Function")},
|
||||
Use: &ast.StmtUseDeclaration{
|
||||
Use: nameF,
|
||||
},
|
||||
},
|
||||
&ast.StmtUseType{
|
||||
Type: &ast.Identifier{Value: []byte("const")},
|
||||
Use: &ast.StmtUseDeclaration{
|
||||
Use: nameC,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtGroupUse{
|
||||
Prefix: nameBD,
|
||||
UseType: &ast.Identifier{Value: []byte("Function")},
|
||||
UseList: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameE,
|
||||
&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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -347,10 +380,12 @@ func TestResolveTraitUse(t *testing.T) {
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAB,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAB,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -668,10 +703,12 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: namespaceCD,
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUseList{
|
||||
Uses: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
Use: nameAC,
|
||||
&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: nameAC,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -182,10 +182,6 @@ func (v *Null) StmtGoto(_ *ast.StmtGoto) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtGroupUse(_ *ast.StmtGroupUse) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtHaltCompiler(_ *ast.StmtHaltCompiler) {
|
||||
// do nothing
|
||||
}
|
||||
@ -286,10 +282,22 @@ func (v *Null) StmtUse(_ *ast.StmtUse) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtGroupUseList(_ *ast.StmtGroupUseList) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtUseList(_ *ast.StmtUseList) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtUseDeclaration(_ *ast.StmtUseDeclaration) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtUseType(_ *ast.StmtUseType) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtWhile(_ *ast.StmtWhile) {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -353,8 +353,6 @@ func (p *PrettyPrinter) printNode(n ast.Vertex) {
|
||||
p.printStmtGlobal(n)
|
||||
case *ast.StmtGoto:
|
||||
p.printStmtGoto(n)
|
||||
case *ast.StmtGroupUse:
|
||||
p.printStmtGroupUse(n)
|
||||
case *ast.StmtHaltCompiler:
|
||||
p.printStmtHaltCompiler(n)
|
||||
case *ast.StmtIf:
|
||||
@ -399,10 +397,16 @@ func (p *PrettyPrinter) printNode(n ast.Vertex) {
|
||||
p.printStmtTry(n)
|
||||
case *ast.StmtUnset:
|
||||
p.printStmtUnset(n)
|
||||
case *ast.StmtUseList:
|
||||
p.printStmtUseList(n)
|
||||
case *ast.StmtUse:
|
||||
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:
|
||||
p.printStmtWhile(n)
|
||||
}
|
||||
@ -1847,22 +1851,6 @@ func (p *PrettyPrinter) printStmtGoto(n ast.Vertex) {
|
||||
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) {
|
||||
io.WriteString(p.w, "__halt_compiler();")
|
||||
}
|
||||
@ -2146,27 +2134,34 @@ func (p *PrettyPrinter) printStmtUnset(n ast.Vertex) {
|
||||
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) {
|
||||
nn := n.(*ast.StmtUse)
|
||||
|
||||
if nn.UseType != nil {
|
||||
p.Print(nn.UseType)
|
||||
io.WriteString(p.w, " ")
|
||||
}
|
||||
io.WriteString(p.w, "use ")
|
||||
|
||||
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)
|
||||
|
||||
@ -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) {
|
||||
nn := n.(*ast.StmtWhile)
|
||||
|
||||
|
@ -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) {
|
||||
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("")
|
||||
|
||||
p := printer.NewPrettyPrinter(o, " ")
|
||||
p.Print(&ast.StmtUseList{
|
||||
UseType: &ast.Identifier{Value: []byte("function")},
|
||||
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")}}},
|
||||
},
|
||||
},
|
||||
p.Print(&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{},
|
||||
})
|
||||
|
||||
expected := `use function Foo as Bar, Baz;`
|
||||
expected := `use ;`
|
||||
actual := o.String()
|
||||
|
||||
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("")
|
||||
|
||||
p := printer.NewPrettyPrinter(o, " ")
|
||||
p.Print(&ast.StmtUse{
|
||||
UseType: &ast.Identifier{Value: []byte("function")},
|
||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
||||
p.Print(&ast.StmtGroupUseList{
|
||||
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")}}},
|
||||
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`
|
||||
|
@ -16,8 +16,10 @@ const (
|
||||
)
|
||||
|
||||
type Printer struct {
|
||||
w io.Writer
|
||||
s printerState
|
||||
w io.Writer
|
||||
s printerState
|
||||
bufStart string
|
||||
bufEnd string
|
||||
}
|
||||
|
||||
// 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) {
|
||||
if n == nil {
|
||||
return
|
||||
@ -374,8 +391,6 @@ func (p *Printer) printNode(n ast.Vertex) {
|
||||
p.printStmtGlobal(n)
|
||||
case *ast.StmtGoto:
|
||||
p.printStmtGoto(n)
|
||||
case *ast.StmtGroupUse:
|
||||
p.printStmtGroupUse(n)
|
||||
case *ast.StmtHaltCompiler:
|
||||
p.printStmtHaltCompiler(n)
|
||||
case *ast.StmtIf:
|
||||
@ -422,10 +437,16 @@ func (p *Printer) printNode(n ast.Vertex) {
|
||||
p.printStmtTry(n)
|
||||
case *ast.StmtUnset:
|
||||
p.printStmtUnset(n)
|
||||
case *ast.StmtUseList:
|
||||
p.printStmtUseList(n)
|
||||
case *ast.StmtUse:
|
||||
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:
|
||||
p.printStmtWhile(n)
|
||||
}
|
||||
@ -443,8 +464,11 @@ func (p *Printer) printNodeRoot(n ast.Vertex) {
|
||||
|
||||
func (p *Printer) printNodeIdentifier(n ast.Vertex) {
|
||||
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))
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
|
||||
@ -519,7 +543,8 @@ func (p *Printer) printNodeArgument(n ast.Vertex) {
|
||||
|
||||
func (p *Printer) printNameNamePart(n ast.Vertex) {
|
||||
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))
|
||||
|
||||
@ -532,22 +557,26 @@ func (p *Printer) printNameName(n ast.Vertex) {
|
||||
|
||||
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) {
|
||||
nn := n.(*ast.NameFullyQualified)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
|
||||
p.bufStart = ""
|
||||
|
||||
io.WriteString(p.w, "\\")
|
||||
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) {
|
||||
nn := n.(*ast.NameRelative)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
|
||||
p.bufStart = ""
|
||||
|
||||
io.WriteString(p.w, "namespace")
|
||||
p.printFreeFloating(nn, token.Namespace)
|
||||
@ -557,7 +586,8 @@ func (p *Printer) printNameRelative(n ast.Vertex) {
|
||||
p.Print(part)
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
p.printFreeFloatingOrDefault(nn, token.End, p.bufEnd)
|
||||
p.bufEnd = ""
|
||||
}
|
||||
|
||||
// scalar
|
||||
@ -2710,41 +2740,6 @@ func (p *Printer) printStmtGoto(n ast.Vertex) {
|
||||
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) {
|
||||
nn := n.(*ast.StmtHaltCompiler)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
@ -3197,59 +3192,78 @@ func (p *Printer) printStmtUnset(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
|
||||
func (p *Printer) printStmtUseList(n ast.Vertex) {
|
||||
nn := n.(*ast.StmtUseList)
|
||||
func (p *Printer) printStmtUse(n ast.Vertex) {
|
||||
nn := n.(*ast.StmtUse)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "use")
|
||||
|
||||
if nn.UseType != nil {
|
||||
if nn.UseType.GetNode().Tokens.IsEmpty() {
|
||||
io.WriteString(p.w, " ")
|
||||
}
|
||||
p.Print(nn.UseType)
|
||||
p.bufStart = " "
|
||||
p.Print(nn.UseList)
|
||||
|
||||
p.printFreeFloatingOrDefault(nn, token.End, ";")
|
||||
}
|
||||
|
||||
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() {
|
||||
io.WriteString(p.w, " ")
|
||||
}
|
||||
p.joinPrint(",", nn.Uses)
|
||||
p.printFreeFloating(nn, token.UseDeclarationList)
|
||||
p.joinPrint(",", nn.UseDeclarations)
|
||||
|
||||
p.printFreeFloating(nn, token.SemiColon)
|
||||
if nn.GetNode().Tokens.IsEmpty() {
|
||||
io.WriteString(p.w, ";")
|
||||
p.printFreeFloatingOrDefault(nn, token.End, bufEnd)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (p *Printer) printStmtUse(n ast.Vertex) {
|
||||
nn := n.(*ast.StmtUse)
|
||||
func (p *Printer) printStmtUseType(n ast.Vertex) {
|
||||
nn := n.(*ast.StmtUseType)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
if nn.UseType != nil {
|
||||
p.Print(nn.UseType)
|
||||
if nn.UseType.GetNode().Tokens.IsEmpty() {
|
||||
io.WriteString(p.w, " ")
|
||||
}
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.Slash)
|
||||
p.Print(nn.Type)
|
||||
|
||||
p.bufStart = " "
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
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("")
|
||||
|
||||
p := printer.NewPrinter(o)
|
||||
p.Print(&ast.StmtUseList{
|
||||
UseType: &ast.Identifier{Value: []byte("function")},
|
||||
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")}}},
|
||||
p.Print(&ast.StmtUse{
|
||||
UseList: &ast.StmtUseList{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
&ast.StmtUseDeclaration{
|
||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expected := `use function Foo as Bar,Baz;`
|
||||
expected := `use Foo;`
|
||||
actual := o.String()
|
||||
|
||||
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("")
|
||||
|
||||
p := printer.NewPrinter(o)
|
||||
p.Print(&ast.StmtUse{
|
||||
UseType: &ast.Identifier{Value: []byte("function")},
|
||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
||||
p.Print(&ast.StmtGroupUseList{
|
||||
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")}}},
|
||||
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`
|
||||
|
@ -6,7 +6,6 @@ type Position int
|
||||
const (
|
||||
Start Position = iota
|
||||
End
|
||||
Slash
|
||||
Colon
|
||||
SemiColon
|
||||
AltEnd
|
||||
|
@ -10,85 +10,84 @@ func _() {
|
||||
var x [1]struct{}
|
||||
_ = x[Start-0]
|
||||
_ = x[End-1]
|
||||
_ = x[Slash-2]
|
||||
_ = x[Colon-3]
|
||||
_ = x[SemiColon-4]
|
||||
_ = x[AltEnd-5]
|
||||
_ = x[Dollar-6]
|
||||
_ = x[Ampersand-7]
|
||||
_ = x[Name-8]
|
||||
_ = x[Prefix-9]
|
||||
_ = x[Key-10]
|
||||
_ = x[Var-11]
|
||||
_ = x[UseType-12]
|
||||
_ = x[ReturnType-13]
|
||||
_ = x[OptionalType-14]
|
||||
_ = x[CaseSeparator-15]
|
||||
_ = x[LexicalVars-16]
|
||||
_ = x[Params-17]
|
||||
_ = x[Ref-18]
|
||||
_ = x[Cast-19]
|
||||
_ = x[Expr-20]
|
||||
_ = x[InitExpr-21]
|
||||
_ = x[CondExpr-22]
|
||||
_ = x[IncExpr-23]
|
||||
_ = x[True-24]
|
||||
_ = x[Cond-25]
|
||||
_ = x[HaltCompiller-26]
|
||||
_ = x[Namespace-27]
|
||||
_ = x[Static-28]
|
||||
_ = x[Class-29]
|
||||
_ = x[Use-30]
|
||||
_ = x[While-31]
|
||||
_ = x[For-32]
|
||||
_ = x[Switch-33]
|
||||
_ = x[Break-34]
|
||||
_ = x[Foreach-35]
|
||||
_ = x[Declare-36]
|
||||
_ = x[Label-37]
|
||||
_ = x[Finally-38]
|
||||
_ = x[List-39]
|
||||
_ = x[Default-40]
|
||||
_ = x[If-41]
|
||||
_ = x[ElseIf-42]
|
||||
_ = x[Else-43]
|
||||
_ = x[Variadic-44]
|
||||
_ = x[Function-45]
|
||||
_ = x[DoubleArrow-46]
|
||||
_ = x[Alias-47]
|
||||
_ = x[As-48]
|
||||
_ = x[Equal-49]
|
||||
_ = x[Exit-50]
|
||||
_ = x[Array-51]
|
||||
_ = x[Isset-52]
|
||||
_ = x[Empty-53]
|
||||
_ = x[Eval-54]
|
||||
_ = x[Echo-55]
|
||||
_ = x[Try-56]
|
||||
_ = x[Catch-57]
|
||||
_ = x[Unset-58]
|
||||
_ = x[Stmts-59]
|
||||
_ = x[VarList-60]
|
||||
_ = x[ConstList-61]
|
||||
_ = x[NameList-62]
|
||||
_ = x[ParamList-63]
|
||||
_ = x[ModifierList-64]
|
||||
_ = x[ArrayPairList-65]
|
||||
_ = x[CaseListStart-66]
|
||||
_ = x[CaseListEnd-67]
|
||||
_ = x[ArgumentList-68]
|
||||
_ = x[PropertyList-69]
|
||||
_ = x[ParameterList-70]
|
||||
_ = x[AdaptationList-71]
|
||||
_ = x[LexicalVarList-72]
|
||||
_ = x[UseDeclarationList-73]
|
||||
_ = x[OpenParenthesisToken-74]
|
||||
_ = x[CloseParenthesisToken-75]
|
||||
_ = x[Colon-2]
|
||||
_ = x[SemiColon-3]
|
||||
_ = x[AltEnd-4]
|
||||
_ = x[Dollar-5]
|
||||
_ = x[Ampersand-6]
|
||||
_ = x[Name-7]
|
||||
_ = x[Prefix-8]
|
||||
_ = x[Key-9]
|
||||
_ = x[Var-10]
|
||||
_ = x[UseType-11]
|
||||
_ = x[ReturnType-12]
|
||||
_ = x[OptionalType-13]
|
||||
_ = x[CaseSeparator-14]
|
||||
_ = x[LexicalVars-15]
|
||||
_ = x[Params-16]
|
||||
_ = x[Ref-17]
|
||||
_ = x[Cast-18]
|
||||
_ = x[Expr-19]
|
||||
_ = x[InitExpr-20]
|
||||
_ = x[CondExpr-21]
|
||||
_ = x[IncExpr-22]
|
||||
_ = x[True-23]
|
||||
_ = x[Cond-24]
|
||||
_ = x[HaltCompiller-25]
|
||||
_ = x[Namespace-26]
|
||||
_ = x[Static-27]
|
||||
_ = x[Class-28]
|
||||
_ = x[Use-29]
|
||||
_ = x[While-30]
|
||||
_ = x[For-31]
|
||||
_ = x[Switch-32]
|
||||
_ = x[Break-33]
|
||||
_ = x[Foreach-34]
|
||||
_ = x[Declare-35]
|
||||
_ = x[Label-36]
|
||||
_ = x[Finally-37]
|
||||
_ = x[List-38]
|
||||
_ = x[Default-39]
|
||||
_ = x[If-40]
|
||||
_ = x[ElseIf-41]
|
||||
_ = x[Else-42]
|
||||
_ = x[Variadic-43]
|
||||
_ = x[Function-44]
|
||||
_ = x[DoubleArrow-45]
|
||||
_ = x[Alias-46]
|
||||
_ = x[As-47]
|
||||
_ = x[Equal-48]
|
||||
_ = x[Exit-49]
|
||||
_ = x[Array-50]
|
||||
_ = x[Isset-51]
|
||||
_ = x[Empty-52]
|
||||
_ = x[Eval-53]
|
||||
_ = x[Echo-54]
|
||||
_ = x[Try-55]
|
||||
_ = x[Catch-56]
|
||||
_ = x[Unset-57]
|
||||
_ = x[Stmts-58]
|
||||
_ = x[VarList-59]
|
||||
_ = x[ConstList-60]
|
||||
_ = x[NameList-61]
|
||||
_ = x[ParamList-62]
|
||||
_ = x[ModifierList-63]
|
||||
_ = x[ArrayPairList-64]
|
||||
_ = x[CaseListStart-65]
|
||||
_ = x[CaseListEnd-66]
|
||||
_ = x[ArgumentList-67]
|
||||
_ = x[PropertyList-68]
|
||||
_ = x[ParameterList-69]
|
||||
_ = x[AdaptationList-70]
|
||||
_ = x[LexicalVarList-71]
|
||||
_ = x[UseDeclarationList-72]
|
||||
_ = x[OpenParenthesisToken-73]
|
||||
_ = x[CloseParenthesisToken-74]
|
||||
}
|
||||
|
||||
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 {
|
||||
if i < 0 || i >= Position(len(_Position_index)-1) {
|
||||
|
Loading…
Reference in New Issue
Block a user