[refactoring] update ast structure of "ClassMethod", "Function", "ArrowFunction" and "Closure" nodes
This commit is contained in:
parent
4c54c56af5
commit
2d6ae3a9a2
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -1378,26 +1378,26 @@ is_variadic:
|
|||||||
unticked_function_declaration_statement:
|
unticked_function_declaration_statement:
|
||||||
function is_reference T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
|
function is_reference T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
|
||||||
{
|
{
|
||||||
name := &ast.Identifier{
|
$$ = &ast.StmtFunction{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokensPosition($1, $9),
|
||||||
|
},
|
||||||
|
FunctionTkn: $1,
|
||||||
|
AmpersandTkn: $2,
|
||||||
|
FunctionName: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewTokenPosition($3),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $3,
|
IdentifierTkn: $3,
|
||||||
Value: $3.Value,
|
Value: $3.Value,
|
||||||
|
},
|
||||||
|
OpenParenthesisTkn: $4,
|
||||||
|
Params: $5,
|
||||||
|
CloseParenthesisTkn: $6,
|
||||||
|
OpenCurlyBracketTkn: $7,
|
||||||
|
Stmts: $8,
|
||||||
|
CloseCurlyBracketTkn: $9,
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtFunction{ast.Node{}, $2 != nil, name, $5, nil, $8}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $9)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
if $2 != nil {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $2.SkippedTokens)
|
|
||||||
}
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParamList, $6.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Params, $7.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $9.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2481,37 +2481,30 @@ class_statement:
|
|||||||
}
|
}
|
||||||
| method_modifiers function is_reference T_STRING '(' parameter_list ')' method_body
|
| method_modifiers function is_reference T_STRING '(' parameter_list ')' method_body
|
||||||
{
|
{
|
||||||
name := &ast.Identifier{
|
pos := position.NewTokenNodePosition($2, $8)
|
||||||
|
if $1 != nil {
|
||||||
|
$$.GetNode().Position = position.NewNodeListNodePosition($1, $8)
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = &ast.StmtClassMethod{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: pos,
|
||||||
|
},
|
||||||
|
Modifiers: $1,
|
||||||
|
FunctionTkn: $2,
|
||||||
|
AmpersandTkn: $3,
|
||||||
|
MethodName: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($4),
|
Position: position.NewTokenPosition($4),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $4,
|
IdentifierTkn: $4,
|
||||||
Value: $4.Value,
|
Value: $4.Value,
|
||||||
|
},
|
||||||
|
OpenParenthesisTkn: $5,
|
||||||
|
Params: $6,
|
||||||
|
CloseParenthesisTkn: $7,
|
||||||
|
Stmt: $8,
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtClassMethod{ast.Node{}, $3 != nil, name, $1, $6, nil, $8}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
if $1 == nil {
|
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($2, $8)
|
|
||||||
} else {
|
|
||||||
$$.GetNode().Position = position.NewNodeListNodePosition($1, $8)
|
|
||||||
}
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
if len($1) > 0 {
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ModifierList, $2.SkippedTokens)
|
|
||||||
} else {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $2.SkippedTokens)
|
|
||||||
}
|
|
||||||
if $3 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $4.SkippedTokens)
|
|
||||||
} else {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $3.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ampersand, $4.SkippedTokens)
|
|
||||||
}
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Name, $5.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParameterList, $7.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -3907,51 +3900,37 @@ expr_without_variable:
|
|||||||
}
|
}
|
||||||
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprClosure{ast.Node{}, $2 != nil, false, $4, $6, nil, $8}
|
$$ = &ast.ExprClosure{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokensPosition($1, $9),
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $9)
|
},
|
||||||
|
FunctionTkn: $1,
|
||||||
// save comments
|
AmpersandTkn: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
OpenParenthesisTkn: $3,
|
||||||
if $2 == nil {
|
Params: $4,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $3.SkippedTokens)
|
CloseParenthesisTkn: $5,
|
||||||
} else {
|
ClosureUse: $6,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $2.SkippedTokens)
|
OpenCurlyBracketTkn: $7,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ampersand, $3.SkippedTokens)
|
Stmts: $8,
|
||||||
}
|
CloseCurlyBracketTkn: $9,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParameterList, $5.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.LexicalVars, $7.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $9.SkippedTokens)
|
|
||||||
|
|
||||||
// normalize
|
|
||||||
if $6 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $$.GetNode().Tokens[token.LexicalVars]); delete($$.GetNode().Tokens, token.LexicalVars)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
| T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprClosure{ast.Node{}, $3 != nil, true, $5, $7, nil, $9}
|
$$ = &ast.ExprClosure{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokensPosition($1, $10),
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $10)
|
},
|
||||||
|
StaticTkn: $1,
|
||||||
// save comments
|
FunctionTkn: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
AmpersandTkn: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Static, $2.SkippedTokens)
|
OpenParenthesisTkn: $4,
|
||||||
if $3 == nil {
|
Params: $5,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $4.SkippedTokens)
|
CloseParenthesisTkn: $6,
|
||||||
} else {
|
ClosureUse: $7,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $3.SkippedTokens)
|
OpenCurlyBracketTkn: $8,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ampersand, $4.SkippedTokens)
|
Stmts: $9,
|
||||||
}
|
CloseCurlyBracketTkn: $10,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParameterList, $6.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.LexicalVars, $8.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $10.SkippedTokens)
|
|
||||||
|
|
||||||
// normalize
|
|
||||||
if $7 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $$.GetNode().Tokens[token.LexicalVars]); delete($$.GetNode().Tokens, token.LexicalVars)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -1214,31 +1214,27 @@ unset_variable:
|
|||||||
function_declaration_statement:
|
function_declaration_statement:
|
||||||
T_FUNCTION returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type '{' inner_statement_list '}'
|
T_FUNCTION returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type '{' inner_statement_list '}'
|
||||||
{
|
{
|
||||||
name := &ast.Identifier{
|
$$ = &ast.StmtFunction{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokensPosition($1, $11),
|
||||||
|
},
|
||||||
|
FunctionTkn: $1,
|
||||||
|
AmpersandTkn: $2,
|
||||||
|
FunctionName: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($3),
|
Position: position.NewTokenPosition($3),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $3,
|
IdentifierTkn: $3,
|
||||||
Value: $3.Value,
|
Value: $3.Value,
|
||||||
}
|
},
|
||||||
$$ = &ast.StmtFunction{ast.Node{}, $2 != nil, name, $6, $8, $10}
|
OpenParenthesisTkn: $5,
|
||||||
|
Params: $6,
|
||||||
// save position
|
CloseParenthesisTkn: $7,
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $11)
|
ColonTkn: $8.(*ast.ReturnType).ColonTkn,
|
||||||
|
ReturnType: $8.(*ast.ReturnType).Type,
|
||||||
|
OpenCurlyBracketTkn: $9,
|
||||||
// save comments
|
Stmts: $10,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
CloseCurlyBracketTkn: $11,
|
||||||
if $2 != nil {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $2.SkippedTokens)
|
|
||||||
}
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParamList, $7.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ReturnType, $9.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $11.SkippedTokens)
|
|
||||||
|
|
||||||
// normalize
|
|
||||||
if $8 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $$.GetNode().Tokens[token.ReturnType]); delete($$.GetNode().Tokens, token.ReturnType)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -2025,10 +2021,10 @@ return_type:
|
|||||||
}
|
}
|
||||||
| ':' type_expr
|
| ':' type_expr
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = &ast.ReturnType{
|
||||||
|
ColonTkn: $1,
|
||||||
// save comments
|
Type: $2,
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.SkippedTokens, $$.GetNode().Tokens[token.Start]...))
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2234,36 +2230,32 @@ class_statement:
|
|||||||
}
|
}
|
||||||
| method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body
|
| method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body
|
||||||
{
|
{
|
||||||
name := &ast.Identifier{
|
pos := position.NewTokenNodePosition($2, $10)
|
||||||
|
if $1 != nil {
|
||||||
|
$$.GetNode().Position = position.NewNodeListNodePosition($1, $10)
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = &ast.StmtClassMethod{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: pos,
|
||||||
|
},
|
||||||
|
Modifiers: $1,
|
||||||
|
FunctionTkn: $2,
|
||||||
|
AmpersandTkn: $3,
|
||||||
|
MethodName: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: position.NewTokenPosition($4),
|
Position: position.NewTokenPosition($4),
|
||||||
},
|
},
|
||||||
IdentifierTkn: $4,
|
IdentifierTkn: $4,
|
||||||
Value: $4.Value,
|
Value: $4.Value,
|
||||||
|
},
|
||||||
|
OpenParenthesisTkn: $6,
|
||||||
|
Params: $7,
|
||||||
|
CloseParenthesisTkn: $8,
|
||||||
|
ColonTkn: $9.(*ast.ReturnType).ColonTkn,
|
||||||
|
ReturnType: $9.(*ast.ReturnType).Type,
|
||||||
|
Stmt: $10,
|
||||||
}
|
}
|
||||||
$$ = &ast.StmtClassMethod{ast.Node{}, $3 != nil, name, $1, $7, $9, $10}
|
|
||||||
|
|
||||||
// save position
|
|
||||||
if $1 == nil {
|
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($2, $10)
|
|
||||||
} else {
|
|
||||||
$$.GetNode().Position = position.NewNodeListNodePosition($1, $10)
|
|
||||||
}
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
if len($1) > 0 {
|
|
||||||
yylex.(*Parser).MoveFreeFloating($1[0], $$)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ModifierList, $2.SkippedTokens)
|
|
||||||
} else {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $2.SkippedTokens)
|
|
||||||
}
|
|
||||||
if $3 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $4.SkippedTokens)
|
|
||||||
} else {
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $3.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ampersand, $4.SkippedTokens)
|
|
||||||
}
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParameterList, $8.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -3624,74 +3616,55 @@ expr_without_variable:
|
|||||||
}
|
}
|
||||||
| T_STATIC inline_function
|
| T_STATIC inline_function
|
||||||
{
|
{
|
||||||
$$ = $2;
|
switch n := $2.(type) {
|
||||||
|
|
||||||
switch n := $$.(type) {
|
|
||||||
case *ast.ExprClosure :
|
case *ast.ExprClosure :
|
||||||
n.Static = true;
|
n.Position = position.NewTokenNodePosition($1, $2)
|
||||||
|
n.StaticTkn = $1;
|
||||||
case *ast.ExprArrowFunction :
|
case *ast.ExprArrowFunction :
|
||||||
n.Static = true;
|
n.Position = position.NewTokenNodePosition($1, $2)
|
||||||
|
n.StaticTkn = $1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// save position
|
$$ = $2
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Static, $$.GetNode().Tokens[token.Start]); delete($$.GetNode().Tokens, token.Start)
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
inline_function:
|
inline_function:
|
||||||
T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}'
|
T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprClosure{ast.Node{}, $2 != nil, false, $5, $7, $8, $10}
|
$$ = &ast.ExprClosure{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokensPosition($1, $11),
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $11)
|
},
|
||||||
|
FunctionTkn: $1,
|
||||||
// save comments
|
AmpersandTkn: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
OpenParenthesisTkn: $4,
|
||||||
if $2 == nil {
|
Params: $5,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $4.SkippedTokens)
|
CloseParenthesisTkn: $6,
|
||||||
} else {
|
ClosureUse: $7,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $2.SkippedTokens)
|
ColonTkn: $8.(*ast.ReturnType).ColonTkn,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ampersand, $4.SkippedTokens)
|
ReturnType: $8.(*ast.ReturnType).Type,
|
||||||
}
|
OpenCurlyBracketTkn: $9,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParameterList, $6.SkippedTokens)
|
Stmts: $10,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ReturnType, $9.SkippedTokens)
|
CloseCurlyBracketTkn: $11,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Stmts, $11.SkippedTokens)
|
|
||||||
|
|
||||||
// normalize
|
|
||||||
if $8 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.LexicalVars, $$.GetNode().Tokens[token.ReturnType]); delete($$.GetNode().Tokens, token.ReturnType)
|
|
||||||
}
|
|
||||||
if $7 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $$.GetNode().Tokens[token.LexicalVarList]); delete($$.GetNode().Tokens, token.LexicalVarList)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| T_FN returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW expr
|
| T_FN returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW expr
|
||||||
{
|
{
|
||||||
$$ = &ast.ExprArrowFunction{ast.Node{}, $2 != nil, false, $4, $6, $9}
|
$$ = &ast.ExprArrowFunction{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenNodePosition($1, $9),
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $9)
|
},
|
||||||
|
FnTkn: $1,
|
||||||
// save comments
|
AmpersandTkn: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
OpenParenthesisTkn: $3,
|
||||||
if $2 == nil {
|
Params: $4,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $3.SkippedTokens)
|
CloseParenthesisTkn: $5,
|
||||||
} else {
|
ColonTkn: $6.(*ast.ReturnType).ColonTkn,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Function, $2.SkippedTokens)
|
ReturnType: $6.(*ast.ReturnType).Type,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Ampersand, $3.SkippedTokens)
|
DoubleArrowTkn: $8,
|
||||||
};
|
Expr: $9,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ParameterList, $5.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setFreeFloating($$, token.ReturnType, $8.SkippedTokens)
|
|
||||||
|
|
||||||
// normalize
|
|
||||||
if $6 == nil {
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $$.GetNode().Tokens[token.ReturnType]); delete($$.GetNode().Tokens, token.ReturnType)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -292,10 +292,14 @@ func (n *StmtClassImplements) Accept(v NodeVisitor) {
|
|||||||
// StmtClassMethod node
|
// StmtClassMethod node
|
||||||
type StmtClassMethod struct {
|
type StmtClassMethod struct {
|
||||||
Node
|
Node
|
||||||
ReturnsRef bool
|
|
||||||
MethodName Vertex
|
|
||||||
Modifiers []Vertex
|
Modifiers []Vertex
|
||||||
|
FunctionTkn *token.Token
|
||||||
|
AmpersandTkn *token.Token
|
||||||
|
MethodName Vertex
|
||||||
|
OpenParenthesisTkn *token.Token
|
||||||
Params []Vertex
|
Params []Vertex
|
||||||
|
CloseParenthesisTkn *token.Token
|
||||||
|
ColonTkn *token.Token
|
||||||
ReturnType Vertex
|
ReturnType Vertex
|
||||||
Stmt Vertex
|
Stmt Vertex
|
||||||
}
|
}
|
||||||
@ -501,11 +505,17 @@ func (n *StmtForeach) Accept(v NodeVisitor) {
|
|||||||
// StmtFunction node
|
// StmtFunction node
|
||||||
type StmtFunction struct {
|
type StmtFunction struct {
|
||||||
Node
|
Node
|
||||||
ReturnsRef bool
|
FunctionTkn *token.Token
|
||||||
|
AmpersandTkn *token.Token
|
||||||
FunctionName Vertex
|
FunctionName Vertex
|
||||||
|
OpenParenthesisTkn *token.Token
|
||||||
Params []Vertex
|
Params []Vertex
|
||||||
|
CloseParenthesisTkn *token.Token
|
||||||
|
ColonTkn *token.Token
|
||||||
ReturnType Vertex
|
ReturnType Vertex
|
||||||
|
OpenCurlyBracketTkn *token.Token
|
||||||
Stmts []Vertex
|
Stmts []Vertex
|
||||||
|
CloseCurlyBracketTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtFunction) Accept(v NodeVisitor) {
|
func (n *StmtFunction) Accept(v NodeVisitor) {
|
||||||
@ -951,10 +961,15 @@ func (n *ExprArrayItem) Accept(v NodeVisitor) {
|
|||||||
// ExprArrowFunction node
|
// ExprArrowFunction node
|
||||||
type ExprArrowFunction struct {
|
type ExprArrowFunction struct {
|
||||||
Node
|
Node
|
||||||
ReturnsRef bool
|
StaticTkn *token.Token
|
||||||
Static bool
|
FnTkn *token.Token
|
||||||
|
AmpersandTkn *token.Token
|
||||||
|
OpenParenthesisTkn *token.Token
|
||||||
Params []Vertex
|
Params []Vertex
|
||||||
|
CloseParenthesisTkn *token.Token
|
||||||
|
ColonTkn *token.Token
|
||||||
ReturnType Vertex
|
ReturnType Vertex
|
||||||
|
DoubleArrowTkn *token.Token
|
||||||
Expr Vertex
|
Expr Vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,12 +1021,18 @@ func (n *ExprClone) Accept(v NodeVisitor) {
|
|||||||
// ExprClosure node
|
// ExprClosure node
|
||||||
type ExprClosure struct {
|
type ExprClosure struct {
|
||||||
Node
|
Node
|
||||||
ReturnsRef bool
|
StaticTkn *token.Token
|
||||||
Static bool
|
FunctionTkn *token.Token
|
||||||
|
AmpersandTkn *token.Token
|
||||||
|
OpenParenthesisTkn *token.Token
|
||||||
Params []Vertex
|
Params []Vertex
|
||||||
|
CloseParenthesisTkn *token.Token
|
||||||
ClosureUse *ExprClosureUse
|
ClosureUse *ExprClosureUse
|
||||||
|
ColonTkn *token.Token
|
||||||
ReturnType Vertex
|
ReturnType Vertex
|
||||||
|
OpenCurlyBracketTkn *token.Token
|
||||||
Stmts []Vertex
|
Stmts []Vertex
|
||||||
|
CloseCurlyBracketTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *ExprClosure) Accept(v NodeVisitor) {
|
func (n *ExprClosure) Accept(v NodeVisitor) {
|
||||||
@ -1947,6 +1968,8 @@ func (n *NameNamePart) Accept(v NodeVisitor) {
|
|||||||
v.NameNamePart(n)
|
v.NameNamePart(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to private section
|
||||||
|
|
||||||
type ParserBrackets struct {
|
type ParserBrackets struct {
|
||||||
Node
|
Node
|
||||||
OpenBracketTkn *token.Token
|
OpenBracketTkn *token.Token
|
||||||
@ -1967,3 +1990,13 @@ type ParserSeparatedList struct {
|
|||||||
func (n *ParserSeparatedList) Accept(v NodeVisitor) {
|
func (n *ParserSeparatedList) Accept(v NodeVisitor) {
|
||||||
v.ParserSeparatedList(n)
|
v.ParserSeparatedList(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReturnType struct {
|
||||||
|
Node
|
||||||
|
ColonTkn *token.Token
|
||||||
|
Type Vertex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *ReturnType) Accept(v NodeVisitor) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
@ -288,11 +288,6 @@ func (v *Dump) StmtClassMethod(n *ast.StmtClassMethod) {
|
|||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.StmtClassMethod{\n")
|
v.print("&ast.StmtClassMethod{\n")
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
|
|
||||||
if n.ReturnsRef {
|
|
||||||
v.printIndent(v.indent)
|
|
||||||
v.print("ReturnsRef: true,\n")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) StmtConstList(n *ast.StmtConstList) {
|
func (v *Dump) StmtConstList(n *ast.StmtConstList) {
|
||||||
@ -397,11 +392,6 @@ func (v *Dump) StmtFunction(n *ast.StmtFunction) {
|
|||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.StmtFunction{\n")
|
v.print("&ast.StmtFunction{\n")
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
|
|
||||||
if n.ReturnsRef {
|
|
||||||
v.printIndent(v.indent)
|
|
||||||
v.print("ReturnsRef: true,\n")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) StmtGlobal(n *ast.StmtGlobal) {
|
func (v *Dump) StmtGlobal(n *ast.StmtGlobal) {
|
||||||
@ -641,16 +631,6 @@ func (v *Dump) ExprArrowFunction(n *ast.ExprArrowFunction) {
|
|||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.ExprArrowFunction{\n")
|
v.print("&ast.ExprArrowFunction{\n")
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
|
|
||||||
if n.ReturnsRef {
|
|
||||||
v.printIndent(v.indent)
|
|
||||||
v.print("ReturnsRef: true,\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
if n.Static {
|
|
||||||
v.printIndent(v.indent)
|
|
||||||
v.print("Static: true,\n")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) ExprBitwiseNot(n *ast.ExprBitwiseNot) {
|
func (v *Dump) ExprBitwiseNot(n *ast.ExprBitwiseNot) {
|
||||||
@ -681,16 +661,6 @@ func (v *Dump) ExprClosure(n *ast.ExprClosure) {
|
|||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.ExprClosure{\n")
|
v.print("&ast.ExprClosure{\n")
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
|
|
||||||
if n.ReturnsRef {
|
|
||||||
v.printIndent(v.indent)
|
|
||||||
v.print("ReturnsRef: true,\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
if n.Static {
|
|
||||||
v.printIndent(v.indent)
|
|
||||||
v.print("Static: true,\n")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) ExprClosureUse(n *ast.ExprClosureUse) {
|
func (v *Dump) ExprClosureUse(n *ast.ExprClosureUse) {
|
||||||
|
@ -1015,13 +1015,13 @@ func (p *PrettyPrinter) printExprClosureUse(n ast.Vertex) {
|
|||||||
func (p *PrettyPrinter) printExprClosure(n ast.Vertex) {
|
func (p *PrettyPrinter) printExprClosure(n ast.Vertex) {
|
||||||
nn := n.(*ast.ExprClosure)
|
nn := n.(*ast.ExprClosure)
|
||||||
|
|
||||||
if nn.Static {
|
if nn.StaticTkn != nil {
|
||||||
io.WriteString(p.w, "static ")
|
io.WriteString(p.w, "static ")
|
||||||
}
|
}
|
||||||
|
|
||||||
io.WriteString(p.w, "function ")
|
io.WriteString(p.w, "function ")
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
io.WriteString(p.w, "&")
|
io.WriteString(p.w, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1432,7 +1432,7 @@ func (p *PrettyPrinter) printStmtClassMethod(n ast.Vertex) {
|
|||||||
}
|
}
|
||||||
io.WriteString(p.w, "function ")
|
io.WriteString(p.w, "function ")
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
io.WriteString(p.w, "&")
|
io.WriteString(p.w, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1785,7 +1785,7 @@ func (p *PrettyPrinter) printStmtFunction(n ast.Vertex) {
|
|||||||
|
|
||||||
io.WriteString(p.w, "function ")
|
io.WriteString(p.w, "function ")
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
io.WriteString(p.w, "&")
|
io.WriteString(p.w, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,18 +1405,18 @@ func (p *Printer) printExprArrowFunction(n ast.Vertex) {
|
|||||||
nn := n.(*ast.ExprArrowFunction)
|
nn := n.(*ast.ExprArrowFunction)
|
||||||
p.printFreeFloating(nn, token.Start)
|
p.printFreeFloating(nn, token.Start)
|
||||||
|
|
||||||
if nn.Static {
|
if nn.StaticTkn != nil {
|
||||||
p.write([]byte("static"))
|
p.write([]byte("static"))
|
||||||
}
|
}
|
||||||
p.printFreeFloating(nn, token.Static)
|
p.printFreeFloating(nn, token.Static)
|
||||||
if nn.Static && n.GetNode().Tokens.IsEmpty() {
|
if nn.StaticTkn != nil && n.GetNode().Tokens.IsEmpty() {
|
||||||
p.write([]byte(" "))
|
p.write([]byte(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
p.write([]byte("fn"))
|
p.write([]byte("fn"))
|
||||||
p.printFreeFloating(nn, token.Function)
|
p.printFreeFloating(nn, token.Function)
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
p.write([]byte("&"))
|
p.write([]byte("&"))
|
||||||
}
|
}
|
||||||
p.printFreeFloating(nn, token.Ampersand)
|
p.printFreeFloating(nn, token.Ampersand)
|
||||||
@ -1496,18 +1496,18 @@ func (p *Printer) printExprClosure(n ast.Vertex) {
|
|||||||
nn := n.(*ast.ExprClosure)
|
nn := n.(*ast.ExprClosure)
|
||||||
p.printFreeFloating(nn, token.Start)
|
p.printFreeFloating(nn, token.Start)
|
||||||
|
|
||||||
if nn.Static {
|
if nn.StaticTkn != nil {
|
||||||
p.write([]byte("static"))
|
p.write([]byte("static"))
|
||||||
}
|
}
|
||||||
p.printFreeFloating(nn, token.Static)
|
p.printFreeFloating(nn, token.Static)
|
||||||
if nn.Static && n.GetNode().Tokens.IsEmpty() {
|
if nn.StaticTkn != nil && n.GetNode().Tokens.IsEmpty() {
|
||||||
p.write([]byte(" "))
|
p.write([]byte(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
p.write([]byte("function"))
|
p.write([]byte("function"))
|
||||||
p.printFreeFloating(nn, token.Function)
|
p.printFreeFloating(nn, token.Function)
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
p.write([]byte("&"))
|
p.write([]byte("&"))
|
||||||
}
|
}
|
||||||
p.printFreeFloating(nn, token.Ampersand)
|
p.printFreeFloating(nn, token.Ampersand)
|
||||||
@ -2040,7 +2040,7 @@ func (p *Printer) printStmtClassMethod(n ast.Vertex) {
|
|||||||
p.write([]byte("function"))
|
p.write([]byte("function"))
|
||||||
p.printFreeFloating(nn, token.Function)
|
p.printFreeFloating(nn, token.Function)
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
if nn.GetNode().Tokens.IsEmpty() {
|
if nn.GetNode().Tokens.IsEmpty() {
|
||||||
p.write([]byte(" "))
|
p.write([]byte(" "))
|
||||||
}
|
}
|
||||||
@ -2384,7 +2384,7 @@ func (p *Printer) printStmtFunction(n ast.Vertex) {
|
|||||||
p.write([]byte("function"))
|
p.write([]byte("function"))
|
||||||
p.printFreeFloating(nn, token.Function)
|
p.printFreeFloating(nn, token.Function)
|
||||||
|
|
||||||
if nn.ReturnsRef {
|
if nn.AmpersandTkn != nil {
|
||||||
if nn.GetNode().Tokens.IsEmpty() {
|
if nn.GetNode().Tokens.IsEmpty() {
|
||||||
p.write([]byte(" "))
|
p.write([]byte(" "))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user