[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 ';'
|
| 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)
|
||||||
|
|
||||||
|
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 ';'
|
| 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)
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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)
|
||||||
|
@ -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
|
||||||
|
@ -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 {
|
||||||
|
@ -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")
|
||||||
|
@ -13,7 +13,9 @@ type NamespaceResolver struct {
|
|||||||
Namespace *Namespace
|
Namespace *Namespace
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,12 @@ func TestResolveStaticCall(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -48,10 +50,12 @@ func TestResolveStaticPropertyFetch(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -79,10 +83,12 @@ func TestResolveClassConstFetch(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -110,10 +116,12 @@ func TestResolveNew(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -141,10 +149,12 @@ func TestResolveInstanceOf(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -175,14 +185,15 @@ func TestResolveInstanceCatch(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
},
|
Use: nameAB,
|
||||||
&ast.StmtUse{
|
}, &ast.StmtUseDeclaration{
|
||||||
Use: nameDE,
|
Use: nameDE,
|
||||||
Alias: &ast.Identifier{Value: []byte("F")},
|
Alias: &ast.Identifier{Value: []byte("F")},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -220,11 +231,15 @@ func TestResolveFunctionCall(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
UseType: &ast.Identifier{Value: []byte("function")},
|
UseList: &ast.StmtUseType{
|
||||||
Uses: []ast.Vertex{
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
&ast.StmtUse{
|
Use: &ast.StmtUseList{
|
||||||
Use: nameAB,
|
UseDeclarations: []ast.Vertex{
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -252,11 +267,15 @@ func TestResolveConstFetch(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
UseType: &ast.Identifier{Value: []byte("const")},
|
UseList: &ast.StmtUseType{
|
||||||
Uses: []ast.Vertex{
|
Type: &ast.Identifier{Value: []byte("const")},
|
||||||
&ast.StmtUse{
|
Use: &ast.StmtUseList{
|
||||||
Use: nameAB,
|
UseDeclarations: []ast.Vertex{
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -286,25 +305,39 @@ func TestResolveGroupUse(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtGroupUse{
|
&ast.StmtUse{
|
||||||
Prefix: nameAB,
|
UseList: &ast.StmtGroupUseList{
|
||||||
UseList: []ast.Vertex{
|
Prefix: nameAB,
|
||||||
&ast.StmtUse{
|
UseList: &ast.StmtUseList{
|
||||||
UseType: &ast.Identifier{Value: []byte("Function")},
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameF,
|
&ast.StmtUseType{
|
||||||
},
|
Type: &ast.Identifier{Value: []byte("Function")},
|
||||||
&ast.StmtUse{
|
Use: &ast.StmtUseDeclaration{
|
||||||
UseType: &ast.Identifier{Value: []byte("const")},
|
Use: nameF,
|
||||||
Use: nameC,
|
},
|
||||||
|
},
|
||||||
|
&ast.StmtUseType{
|
||||||
|
Type: &ast.Identifier{Value: []byte("const")},
|
||||||
|
Use: &ast.StmtUseDeclaration{
|
||||||
|
Use: nameC,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&ast.StmtGroupUse{
|
&ast.StmtUse{
|
||||||
Prefix: nameBD,
|
UseList: &ast.StmtUseType{
|
||||||
UseType: &ast.Identifier{Value: []byte("Function")},
|
Type: &ast.Identifier{Value: []byte("Function")},
|
||||||
UseList: []ast.Vertex{
|
Use: &ast.StmtGroupUseList{
|
||||||
&ast.StmtUse{
|
Prefix: nameBD,
|
||||||
Use: nameE,
|
UseList: &ast.StmtUseList{
|
||||||
|
UseDeclarations: []ast.Vertex{
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -347,10 +380,12 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAB,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -668,10 +703,12 @@ func TestResolveNamespaces(t *testing.T) {
|
|||||||
&ast.StmtNamespace{
|
&ast.StmtNamespace{
|
||||||
NamespaceName: namespaceCD,
|
NamespaceName: namespaceCD,
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUseList{
|
&ast.StmtUse{
|
||||||
Uses: []ast.Vertex{
|
UseList: &ast.StmtUseList{
|
||||||
&ast.StmtUse{
|
UseDeclarations: []ast.Vertex{
|
||||||
Use: nameAC,
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: nameAC,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
@ -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")}}},
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
UseList: &ast.StmtUseList{},
|
||||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
})
|
||||||
|
|
||||||
|
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`
|
expected := `function Foo as Bar`
|
||||||
|
@ -16,8 +16,10 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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")}}},
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
UseList: &ast.StmtUseList{},
|
||||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
})
|
||||||
|
|
||||||
|
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`
|
expected := `function Foo as Bar`
|
||||||
|
@ -6,7 +6,6 @@ type Position int
|
|||||||
const (
|
const (
|
||||||
Start Position = iota
|
Start Position = iota
|
||||||
End
|
End
|
||||||
Slash
|
|
||||||
Colon
|
Colon
|
||||||
SemiColon
|
SemiColon
|
||||||
AltEnd
|
AltEnd
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user