[refactoring] update ast structure of "ArrayDimFetch", "UnaryMinus", "ExprUnaryPlus" and "Variable" nodes
This commit is contained in:
parent
13436b88a7
commit
01d695c416
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -15,7 +15,6 @@ import (
|
||||
node ast.Vertex
|
||||
token *token.Token
|
||||
list []ast.Vertex
|
||||
simpleIndirectReference simpleIndirectReference
|
||||
|
||||
ClosureUse *ast.ExprClosureUse
|
||||
}
|
||||
@ -260,7 +259,7 @@ import (
|
||||
%type <list> method_or_not array_method_dereference object_property object_dim_list dynamic_class_name_variable_property
|
||||
%type <list> dynamic_class_name_variable_properties variable_properties
|
||||
|
||||
%type <simpleIndirectReference> simple_indirect_reference
|
||||
%type <list> simple_indirect_reference
|
||||
%type <token> is_reference is_variadic
|
||||
|
||||
%%
|
||||
@ -1206,14 +1205,6 @@ catch_statement:
|
||||
}
|
||||
| T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' additional_catches
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
catch := &ast.StmtCatch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $8),
|
||||
@ -1221,19 +1212,24 @@ catch_statement:
|
||||
CatchTkn: $1,
|
||||
OpenParenthesisTkn: $2,
|
||||
Types: []ast.Vertex{$3},
|
||||
Var: variable,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
},
|
||||
},
|
||||
CloseParenthesisTkn: $5,
|
||||
OpenCurlyBracketTkn: $6,
|
||||
Stmts: $7,
|
||||
CloseCurlyBracketTkn: $8,
|
||||
}
|
||||
$$ = append([]ast.Vertex{catch}, $9...)
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -1281,14 +1277,6 @@ non_empty_additional_catches:
|
||||
additional_catch:
|
||||
T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}'
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
$$ = &ast.StmtCatch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $8),
|
||||
@ -1296,18 +1284,23 @@ additional_catch:
|
||||
CatchTkn: $1,
|
||||
OpenParenthesisTkn: $2,
|
||||
Types: []ast.Vertex{$3},
|
||||
Var: variable,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
},
|
||||
},
|
||||
CloseParenthesisTkn: $5,
|
||||
OpenCurlyBracketTkn: $6,
|
||||
Stmts: $7,
|
||||
CloseCurlyBracketTkn: $8,
|
||||
}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -2032,19 +2025,20 @@ non_empty_parameter_list:
|
||||
parameter:
|
||||
optional_class_type is_reference is_variadic T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
},
|
||||
}
|
||||
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
variable.GetNode().Position = position.NewTokenPosition($4)
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
|
||||
|
||||
if $3 != nil {
|
||||
variable = &ast.Variadic{
|
||||
Node: ast.Node{
|
||||
@ -2084,20 +2078,20 @@ parameter:
|
||||
}
|
||||
| optional_class_type is_reference is_variadic T_VARIABLE '=' expr
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
},
|
||||
}
|
||||
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
variable.GetNode().Position = position.NewTokenPosition($4)
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(variable, token.End, $5.SkippedTokens)
|
||||
|
||||
if $3 != nil {
|
||||
variable = &ast.Variadic{
|
||||
Node: ast.Node{
|
||||
@ -2290,42 +2284,45 @@ global_var_list:
|
||||
global_var:
|
||||
T_VARIABLE
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| '$' r_variable
|
||||
{
|
||||
$$ = &ast.ExprVariable{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
DollarTkn: $1,
|
||||
VarName: $2,
|
||||
}
|
||||
}
|
||||
| '$' '{' expr '}'
|
||||
{
|
||||
$$ = &ast.ExprVariable{ast.Node{}, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($3, token.Start, append($2.SkippedTokens, $3.GetNode().Tokens[token.Start]...))
|
||||
yylex.(*Parser).setFreeFloatingTokens($3, token.End, append($3.GetNode().Tokens[token.End], $4.SkippedTokens...))
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
DollarTkn: $1,
|
||||
VarName: &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
OpenBracketTkn: $2,
|
||||
Child: $3,
|
||||
CloseBracketTkn: $4,
|
||||
},
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -2333,117 +2330,101 @@ global_var:
|
||||
static_var_list:
|
||||
static_var_list ',' T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, &ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
IdentifierTkn: $3,
|
||||
Value: $3.Value,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
$1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, &ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
Var: variable,
|
||||
},
|
||||
})
|
||||
$1.(*ast.StmtStatic).SeparatorTkns = append($1.(*ast.StmtStatic).SeparatorTkns, $2)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
| static_var_list ',' T_VARIABLE '=' static_scalar
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, &ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $5),
|
||||
},
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($3),
|
||||
},
|
||||
IdentifierTkn: $3,
|
||||
Value: $3.Value,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
$1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, &ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($3, $5),
|
||||
},
|
||||
Var: variable,
|
||||
},
|
||||
EqualTkn: $4,
|
||||
Expr: $5,
|
||||
})
|
||||
$1.(*ast.StmtStatic).SeparatorTkns = append($1.(*ast.StmtStatic).SeparatorTkns, $2)
|
||||
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $3.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
$$ = &ast.StmtStatic{
|
||||
Vars: []ast.Vertex{
|
||||
&ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
Var: variable,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE '=' static_scalar
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
}
|
||||
| T_VARIABLE '=' static_scalar
|
||||
{
|
||||
$$ = &ast.StmtStatic{
|
||||
Vars: []ast.Vertex{
|
||||
&ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $3),
|
||||
},
|
||||
Var: variable,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
},
|
||||
EqualTkn: $2,
|
||||
Expr: $3,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -3609,23 +3590,23 @@ expr_without_variable:
|
||||
}
|
||||
| '+' expr %prec T_INC
|
||||
{
|
||||
$$ = &ast.ExprUnaryPlus{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprUnaryPlus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
PlusTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| '-' expr %prec T_INC
|
||||
{
|
||||
$$ = &ast.ExprUnaryMinus{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprUnaryMinus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
MinusTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| '!' expr
|
||||
{
|
||||
@ -5184,23 +5165,23 @@ static_operation:
|
||||
}
|
||||
| '+' static_scalar_value
|
||||
{
|
||||
$$ = &ast.ExprUnaryPlus{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprUnaryPlus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
PlusTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| '-' static_scalar_value
|
||||
{
|
||||
$$ = &ast.ExprUnaryMinus{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprUnaryMinus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
MinusTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| '(' static_scalar_value ')'
|
||||
{
|
||||
@ -5267,20 +5248,18 @@ general_constant:
|
||||
scalar:
|
||||
T_STRING_VARNAME
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| general_constant
|
||||
{
|
||||
@ -5676,13 +5655,13 @@ variable_without_objects:
|
||||
}
|
||||
| simple_indirect_reference reference_variable
|
||||
{
|
||||
$1.last.VarName = $2
|
||||
|
||||
for _, n := range($1.all) {
|
||||
n.GetNode().Position = position.NewNodesPosition(n, $2)
|
||||
for i := len($1)-1; i>=0; i-- {
|
||||
$1[i].(*ast.ExprVariable).VarName = $2
|
||||
$1[i].(*ast.ExprVariable).Node.Position = position.NewNodesPosition($1[i], $2)
|
||||
$2 = $1[i]
|
||||
}
|
||||
|
||||
$$ = $1.all[0]
|
||||
$$ = $1[0]
|
||||
}
|
||||
;
|
||||
|
||||
@ -5768,13 +5747,13 @@ base_variable:
|
||||
}
|
||||
| simple_indirect_reference reference_variable
|
||||
{
|
||||
$1.last.VarName = $2
|
||||
|
||||
for _, n := range($1.all) {
|
||||
n.GetNode().Position = position.NewNodesPosition(n, $2)
|
||||
for i := len($1)-1; i>=0; i-- {
|
||||
$1[i].(*ast.ExprVariable).VarName = $2
|
||||
$1[i].(*ast.ExprVariable).Node.Position = position.NewNodesPosition($1[i], $2)
|
||||
$2 = $1[i]
|
||||
}
|
||||
|
||||
$$ = $1.all[0]
|
||||
$$ = $1[0]
|
||||
}
|
||||
| static_member
|
||||
{
|
||||
@ -5817,32 +5796,35 @@ reference_variable:
|
||||
compound_variable:
|
||||
T_VARIABLE
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| '$' '{' expr '}'
|
||||
{
|
||||
$$ = &ast.ExprVariable{ast.Node{}, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($3, token.Start, append($2.SkippedTokens, $3.GetNode().Tokens[token.Start]...))
|
||||
yylex.(*Parser).setFreeFloatingTokens($3, token.End, append($3.GetNode().Tokens[token.End], $4.SkippedTokens...))
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
DollarTkn: $1,
|
||||
VarName: &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
OpenBracketTkn: $2,
|
||||
Child: $3,
|
||||
CloseBracketTkn: $4,
|
||||
},
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -5945,29 +5927,23 @@ variable_name:
|
||||
simple_indirect_reference:
|
||||
'$'
|
||||
{
|
||||
n := &ast.ExprVariable{ast.Node{}, nil}
|
||||
$$ = simpleIndirectReference{[]*ast.ExprVariable{n}, n}
|
||||
|
||||
// save position
|
||||
n.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(n, token.Start, $1.SkippedTokens)
|
||||
$$ = []ast.Vertex{
|
||||
&ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
DollarTkn: $1,
|
||||
},
|
||||
}
|
||||
}
|
||||
| simple_indirect_reference '$'
|
||||
{
|
||||
n := &ast.ExprVariable{ast.Node{}, nil}
|
||||
|
||||
$1.last.VarName = n
|
||||
$1.all = append($1.all, n)
|
||||
$1.last = n
|
||||
$$ = $1
|
||||
|
||||
// save position
|
||||
n.GetNode().Position = position.NewTokenPosition($2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(n, token.Start, $2.SkippedTokens)
|
||||
$$ = append($1, &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
DollarTkn: $2,
|
||||
})
|
||||
}
|
||||
;
|
||||
|
||||
@ -6229,20 +6205,18 @@ encaps_list:
|
||||
encaps_var:
|
||||
T_VARIABLE
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE '[' encaps_var_offset ']'
|
||||
{
|
||||
@ -6297,44 +6271,53 @@ encaps_var:
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES expr '}'
|
||||
{
|
||||
variable := &ast.ExprVariable{ast.Node{}, $2}
|
||||
|
||||
$$ = variable
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenBracketTkn: $1,
|
||||
Child: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($2),
|
||||
},
|
||||
VarName: $2,
|
||||
},
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}'
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenBracketTkn: $1,
|
||||
Child: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
IdentifierTkn: $2,
|
||||
Value: $2.Value,
|
||||
},
|
||||
},
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
$$ = variable
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $6),
|
||||
},
|
||||
OpenCurlyBracketTkn: $1,
|
||||
OpenBracketTkn: $1,
|
||||
Child: &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $5),
|
||||
},
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
@ -6350,16 +6333,20 @@ encaps_var:
|
||||
OpenBracketTkn: $3,
|
||||
Dim: $4,
|
||||
CloseBracketTkn: $5,
|
||||
CloseCurlyBracketTkn: $6,
|
||||
},
|
||||
CloseBracketTkn: $6,
|
||||
}
|
||||
}
|
||||
| T_CURLY_OPEN variable '}'
|
||||
{
|
||||
$$ = $2;
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenBracketTkn: $1,
|
||||
Child: $2,
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -6403,20 +6390,18 @@ encaps_var_offset:
|
||||
}
|
||||
| T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -6617,8 +6602,3 @@ class_name_scalar:
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
type simpleIndirectReference struct {
|
||||
all []*ast.ExprVariable
|
||||
last *ast.ExprVariable
|
||||
}
|
||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -1122,19 +1122,21 @@ catch_list:
|
||||
}
|
||||
| catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}'
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
catch := $4.(*ast.StmtCatch)
|
||||
catch.CatchTkn = $2
|
||||
catch.OpenParenthesisTkn = $3
|
||||
catch.Var = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($5),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($5),
|
||||
},
|
||||
IdentifierTkn: $5,
|
||||
Value: $5.Value,
|
||||
},
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
catch := $4.(*ast.StmtCatch)
|
||||
catch.CatchTkn = $2
|
||||
catch.OpenParenthesisTkn = $3
|
||||
catch.Var = variable
|
||||
catch.CloseParenthesisTkn = $6
|
||||
catch.OpenCurlyBracketTkn = $7
|
||||
catch.Stmts = $8
|
||||
@ -1142,12 +1144,6 @@ catch_list:
|
||||
catch.GetNode().Position = position.NewTokensPosition($2, $9)
|
||||
|
||||
$$ = append($1, catch)
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $5.SkippedTokens)
|
||||
}
|
||||
;
|
||||
catch_name_list:
|
||||
@ -1852,19 +1848,20 @@ non_empty_parameter_list:
|
||||
parameter:
|
||||
optional_type is_reference is_variadic T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
},
|
||||
}
|
||||
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
variable.GetNode().Position = position.NewTokenPosition($4)
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
|
||||
|
||||
if $3 != nil {
|
||||
variable = &ast.Variadic{
|
||||
Node: ast.Node{
|
||||
@ -1904,20 +1901,20 @@ parameter:
|
||||
}
|
||||
| optional_type is_reference is_variadic T_VARIABLE '=' expr
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($4),
|
||||
},
|
||||
IdentifierTkn: $4,
|
||||
Value: $4.Value,
|
||||
},
|
||||
}
|
||||
|
||||
var variable ast.Vertex
|
||||
variable = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
variable.GetNode().Position = position.NewTokenPosition($4)
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(variable, token.End, $5.SkippedTokens)
|
||||
|
||||
if $3 != nil {
|
||||
variable = &ast.Variadic{
|
||||
Node: ast.Node{
|
||||
@ -2131,52 +2128,46 @@ static_var_list:
|
||||
static_var:
|
||||
T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
$$ = &ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
Var: variable,
|
||||
}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE '=' expr
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
},
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, identifier}
|
||||
}
|
||||
| T_VARIABLE '=' expr
|
||||
{
|
||||
$$ = &ast.StmtStaticVar{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $3),
|
||||
},
|
||||
Var: variable,
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
},
|
||||
EqualTkn: $2,
|
||||
Expr: $3,
|
||||
}
|
||||
|
||||
// save position
|
||||
variable.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(variable, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
@ -3254,23 +3245,23 @@ expr_without_variable:
|
||||
}
|
||||
| '+' expr %prec T_INC
|
||||
{
|
||||
$$ = &ast.ExprUnaryPlus{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprUnaryPlus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
PlusTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| '-' expr %prec T_INC
|
||||
{
|
||||
$$ = &ast.ExprUnaryMinus{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprUnaryMinus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
MinusTkn: $1,
|
||||
Expr: $2,
|
||||
}
|
||||
}
|
||||
| '!' expr
|
||||
{
|
||||
@ -3744,20 +3735,18 @@ lexical_var_list:
|
||||
lexical_var:
|
||||
T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| '&' T_VARIABLE
|
||||
{
|
||||
@ -4334,42 +4323,45 @@ variable:
|
||||
simple_variable:
|
||||
T_VARIABLE
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| '$' '{' expr '}'
|
||||
{
|
||||
$$ = &ast.ExprVariable{ast.Node{}, $3}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($3, token.Start, append($2.SkippedTokens, $3.GetNode().Tokens[token.Start]...))
|
||||
yylex.(*Parser).setFreeFloatingTokens($3, token.End, append($3.GetNode().Tokens[token.End], $4.SkippedTokens...))
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
DollarTkn: $1,
|
||||
VarName: &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $4),
|
||||
},
|
||||
OpenBracketTkn: $2,
|
||||
Child: $3,
|
||||
CloseBracketTkn: $4,
|
||||
},
|
||||
}
|
||||
}
|
||||
| '$' simple_variable
|
||||
{
|
||||
$$ = &ast.ExprVariable{ast.Node{}, $2}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodePosition($1, $2),
|
||||
},
|
||||
DollarTkn: $1,
|
||||
VarName: $2,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -4696,20 +4688,18 @@ encaps_list:
|
||||
encaps_var:
|
||||
T_VARIABLE
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| T_VARIABLE '[' encaps_var_offset ']'
|
||||
{
|
||||
@ -4764,44 +4754,53 @@ encaps_var:
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES expr '}'
|
||||
{
|
||||
variable := &ast.ExprVariable{ast.Node{}, $2}
|
||||
|
||||
$$ = variable
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenBracketTkn: $1,
|
||||
Child: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewNodePosition($2),
|
||||
},
|
||||
VarName: $2,
|
||||
},
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}'
|
||||
{
|
||||
name := &ast.Identifier{
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenBracketTkn: $1,
|
||||
Child: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
IdentifierTkn: $2,
|
||||
Value: $2.Value,
|
||||
},
|
||||
},
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
variable := &ast.ExprVariable{ast.Node{}, name}
|
||||
|
||||
$$ = variable
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
||||
}
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
|
||||
{
|
||||
$$ = &ast.ExprArrayDimFetch{
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $6),
|
||||
},
|
||||
OpenCurlyBracketTkn: $1,
|
||||
OpenBracketTkn: $1,
|
||||
Child: &ast.ExprArrayDimFetch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($2, $5),
|
||||
},
|
||||
Var: &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
@ -4817,16 +4816,20 @@ encaps_var:
|
||||
OpenBracketTkn: $3,
|
||||
Dim: $4,
|
||||
CloseBracketTkn: $5,
|
||||
CloseCurlyBracketTkn: $6,
|
||||
},
|
||||
CloseBracketTkn: $6,
|
||||
}
|
||||
}
|
||||
| T_CURLY_OPEN variable '}'
|
||||
{
|
||||
$$ = $2;
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setToken($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
||||
$$ = &ast.ParserBrackets{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenBracketTkn: $1,
|
||||
Child: $2,
|
||||
CloseBracketTkn: $3,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -4868,14 +4871,19 @@ encaps_var_offset:
|
||||
isInt := err == nil
|
||||
|
||||
if isInt {
|
||||
lnumber := &ast.ScalarLnumber{
|
||||
$$ = &ast.ExprUnaryMinus{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $2),
|
||||
},
|
||||
MinusTkn: $1,
|
||||
Expr: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($2),
|
||||
},
|
||||
NumberTkn: $2,
|
||||
Value: $2.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprUnaryMinus{ast.Node{}, lnumber}
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $2)
|
||||
} else {
|
||||
$$ = &ast.ScalarString{
|
||||
@ -4890,20 +4898,18 @@ encaps_var_offset:
|
||||
}
|
||||
| T_VARIABLE
|
||||
{
|
||||
identifier := &ast.Identifier{
|
||||
$$ = &ast.ExprVariable{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
VarName: &ast.Identifier{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
IdentifierTkn: $1,
|
||||
Value: $1.Value,
|
||||
},
|
||||
}
|
||||
$$ = &ast.ExprVariable{ast.Node{}, identifier}
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -954,11 +954,9 @@ func (n *ExprArray) Accept(v NodeVisitor) {
|
||||
type ExprArrayDimFetch struct {
|
||||
Node
|
||||
Var Vertex
|
||||
OpenCurlyBracketTkn *token.Token
|
||||
OpenBracketTkn *token.Token
|
||||
Dim Vertex
|
||||
CloseBracketTkn *token.Token
|
||||
CloseCurlyBracketTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprArrayDimFetch) Accept(v NodeVisitor) {
|
||||
@ -1397,6 +1395,7 @@ func (n *ExprTernary) Accept(v NodeVisitor) {
|
||||
// ExprUnaryMinus node
|
||||
type ExprUnaryMinus struct {
|
||||
Node
|
||||
MinusTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1407,6 +1406,7 @@ func (n *ExprUnaryMinus) Accept(v NodeVisitor) {
|
||||
// ExprUnaryPlus node
|
||||
type ExprUnaryPlus struct {
|
||||
Node
|
||||
PlusTkn *token.Token
|
||||
Expr Vertex
|
||||
}
|
||||
|
||||
@ -1417,6 +1417,7 @@ func (n *ExprUnaryPlus) Accept(v NodeVisitor) {
|
||||
// ExprVariable node
|
||||
type ExprVariable struct {
|
||||
Node
|
||||
DollarTkn *token.Token
|
||||
VarName Vertex
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user