[refactoring] update ast structure of "Assign" and "Binary" nodes

This commit is contained in:
Vadym Slizov 2020-12-04 10:40:48 +02:00
parent 5a6418e853
commit d19b3f609e
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
5 changed files with 972 additions and 944 deletions

BIN
internal/php5/php5.go generated

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -2804,65 +2804,65 @@ new_expr:
expr_without_variable:
T_LIST '(' array_pair_list ')' '=' expr
{
listNode := &ast.ExprList{
$$ = &ast.ExprAssign{
Node: ast.Node{
Position: position.NewTokensPosition($1, $4),
Position: position.NewTokenNodePosition($1, $6),
},
ListTkn: $1,
OpenBracketTkn: $2,
Items: $3.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
CloseBracketTkn: $4,
Var: &ast.ExprList{
Node: ast.Node{
Position: position.NewTokensPosition($1, $4),
},
ListTkn: $1,
OpenBracketTkn: $2,
Items: $3.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
CloseBracketTkn: $4,
},
EqualTkn: $5,
Expr: $6,
}
$$ = &ast.ExprAssign{ast.Node{}, listNode, $6}
// save position
$$.GetNode().Position = position.NewTokenNodePosition($1, $6)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Var, $5.SkippedTokens)
}
| '[' array_pair_list ']' '=' expr
{
listNode := &ast.ExprList{
$$ = &ast.ExprAssign{
Node: ast.Node{
Position: position.NewTokensPosition($1, $3),
Position: position.NewTokenNodePosition($1, $5),
},
OpenBracketTkn: $1,
Items: $2.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
CloseBracketTkn: $3,
Var: &ast.ExprList{
Node: ast.Node{
Position: position.NewTokensPosition($1, $3),
},
OpenBracketTkn: $1,
Items: $2.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
CloseBracketTkn: $3,
},
EqualTkn: $4,
Expr: $5,
}
$$ = &ast.ExprAssign{ast.Node{}, listNode, $5}
// save position
$$.GetNode().Position = position.NewTokenNodePosition($1, $5)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Var, $4.SkippedTokens)
}
| variable '=' expr
{
$$ = &ast.ExprAssign{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssign{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable '=' '&' expr
{
$$ = &ast.ExprAssignReference{ast.Node{}, $1, $4}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $4)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
yylex.(*Parser).setFreeFloating($$, token.Equal, $3.SkippedTokens)
$$ = &ast.ExprAssignReference{
Node: ast.Node{
Position: position.NewNodesPosition($1, $4),
},
Var: $1,
EqualTkn: $2,
AmpersandTkn: $3,
Expr: $4,
}
}
| T_CLONE expr
{
@ -2876,146 +2876,146 @@ expr_without_variable:
}
| variable T_PLUS_EQUAL expr
{
$$ = &ast.ExprAssignPlus{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignPlus{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_MINUS_EQUAL expr
{
$$ = &ast.ExprAssignMinus{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignMinus{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_MUL_EQUAL expr
{
$$ = &ast.ExprAssignMul{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignMul{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_POW_EQUAL expr
{
$$ = &ast.ExprAssignPow{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignPow{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_DIV_EQUAL expr
{
$$ = &ast.ExprAssignDiv{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignDiv{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_CONCAT_EQUAL expr
{
$$ = &ast.ExprAssignConcat{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignConcat{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_MOD_EQUAL expr
{
$$ = &ast.ExprAssignMod{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignMod{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_AND_EQUAL expr
{
$$ = &ast.ExprAssignBitwiseAnd{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignBitwiseAnd{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_OR_EQUAL expr
{
$$ = &ast.ExprAssignBitwiseOr{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignBitwiseOr{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_XOR_EQUAL expr
{
$$ = &ast.ExprAssignBitwiseXor{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignBitwiseXor{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_SL_EQUAL expr
{
$$ = &ast.ExprAssignShiftLeft{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignShiftLeft{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_SR_EQUAL expr
{
$$ = &ast.ExprAssignShiftRight{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignShiftRight{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_COALESCE_EQUAL expr
{
$$ = &ast.ExprAssignCoalesce{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens)
$$ = &ast.ExprAssignCoalesce{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Var: $1,
EqualTkn: $2,
Expr: $3,
}
}
| variable T_INC
{
@ -3059,189 +3059,190 @@ expr_without_variable:
}
| expr T_BOOLEAN_OR expr
{
$$ = &ast.ExprBinaryBooleanOr{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryBooleanOr{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_BOOLEAN_AND expr
{
$$ = &ast.ExprBinaryBooleanAnd{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryBooleanAnd{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_LOGICAL_OR expr
{
$$ = &ast.ExprBinaryLogicalOr{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryLogicalOr{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_LOGICAL_AND expr
{
$$ = &ast.ExprBinaryLogicalAnd{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryLogicalAnd{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_LOGICAL_XOR expr
{
$$ = &ast.ExprBinaryLogicalXor{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryLogicalXor{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '|' expr
{
$$ = &ast.ExprBinaryBitwiseOr{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryBitwiseOr{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '&' expr
{
$$ = &ast.ExprBinaryBitwiseAnd{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryBitwiseAnd{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '^' expr
{
$$ = &ast.ExprBinaryBitwiseXor{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryBitwiseXor{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '.' expr
{
$$ = &ast.ExprBinaryConcat{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryConcat{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '+' expr
{
$$ = &ast.ExprBinaryPlus{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryPlus{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '-' expr
{
$$ = &ast.ExprBinaryMinus{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryMinus{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '*' expr
{
$$ = &ast.ExprBinaryMul{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryMul{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_POW expr
{
$$ = &ast.ExprBinaryPow{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryPow{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '/' expr
{
$$ = &ast.ExprBinaryDiv{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryDiv{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '%' expr
{
$$ = &ast.ExprBinaryMod{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryMod{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_SL expr
{
$$ = &ast.ExprBinaryShiftLeft{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryShiftLeft{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_SR expr
{
$$ = &ast.ExprBinaryShiftRight{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryShiftRight{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| '+' expr %prec T_INC
{
@ -3285,103 +3286,102 @@ expr_without_variable:
}
| expr T_IS_IDENTICAL expr
{
$$ = &ast.ExprBinaryIdentical{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryIdentical{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_IS_NOT_IDENTICAL expr
{
$$ = &ast.ExprBinaryNotIdentical{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryNotIdentical{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_IS_EQUAL expr
{
$$ = &ast.ExprBinaryEqual{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryEqual{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_IS_NOT_EQUAL expr
{
$$ = &ast.ExprBinaryNotEqual{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
yylex.(*Parser).setToken($$, token.Equal, $2.SkippedTokens)
$$ = &ast.ExprBinaryNotEqual{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '<' expr
{
$$ = &ast.ExprBinarySmaller{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinarySmaller{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_IS_SMALLER_OR_EQUAL expr
{
$$ = &ast.ExprBinarySmallerOrEqual{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinarySmallerOrEqual{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr '>' expr
{
$$ = &ast.ExprBinaryGreater{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryGreater{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_IS_GREATER_OR_EQUAL expr
{
$$ = &ast.ExprBinaryGreaterOrEqual{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryGreaterOrEqual{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_SPACESHIP expr
{
$$ = &ast.ExprBinarySpaceship{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinarySpaceship{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| expr T_INSTANCEOF class_name_reference
{
@ -3440,14 +3440,14 @@ expr_without_variable:
}
| expr T_COALESCE expr
{
$$ = &ast.ExprBinaryCoalesce{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprBinaryCoalesce{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Left: $1,
OpTkn: $2,
Right: $3,
}
}
| internal_functions_in_yacc
{

View File

@ -1529,8 +1529,9 @@ func (n *ExprCastUnset) Accept(v NodeVisitor) {
// ExprAssign node
type ExprAssign struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssign) Accept(v NodeVisitor) {
@ -1540,8 +1541,10 @@ func (n *ExprAssign) Accept(v NodeVisitor) {
// ExprAssignReference node
type ExprAssignReference struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
AmpersandTkn *token.Token
Expr Vertex
}
func (n *ExprAssignReference) Accept(v NodeVisitor) {
@ -1551,8 +1554,9 @@ func (n *ExprAssignReference) Accept(v NodeVisitor) {
// ExprAssignBitwiseAnd node
type ExprAssignBitwiseAnd struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignBitwiseAnd) Accept(v NodeVisitor) {
@ -1562,8 +1566,9 @@ func (n *ExprAssignBitwiseAnd) Accept(v NodeVisitor) {
// ExprAssignBitwiseOr node
type ExprAssignBitwiseOr struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignBitwiseOr) Accept(v NodeVisitor) {
@ -1573,8 +1578,9 @@ func (n *ExprAssignBitwiseOr) Accept(v NodeVisitor) {
// ExprAssignBitwiseXor node
type ExprAssignBitwiseXor struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignBitwiseXor) Accept(v NodeVisitor) {
@ -1584,8 +1590,9 @@ func (n *ExprAssignBitwiseXor) Accept(v NodeVisitor) {
// ExprAssignCoalesce node
type ExprAssignCoalesce struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignCoalesce) Accept(v NodeVisitor) {
@ -1595,8 +1602,9 @@ func (n *ExprAssignCoalesce) Accept(v NodeVisitor) {
// ExprAssignConcat node
type ExprAssignConcat struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignConcat) Accept(v NodeVisitor) {
@ -1606,8 +1614,9 @@ func (n *ExprAssignConcat) Accept(v NodeVisitor) {
// ExprAssignDiv node
type ExprAssignDiv struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignDiv) Accept(v NodeVisitor) {
@ -1617,8 +1626,9 @@ func (n *ExprAssignDiv) Accept(v NodeVisitor) {
// ExprAssignMinus node
type ExprAssignMinus struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignMinus) Accept(v NodeVisitor) {
@ -1628,8 +1638,9 @@ func (n *ExprAssignMinus) Accept(v NodeVisitor) {
// ExprAssignMod node
type ExprAssignMod struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignMod) Accept(v NodeVisitor) {
@ -1639,8 +1650,9 @@ func (n *ExprAssignMod) Accept(v NodeVisitor) {
// ExprAssignMul node
type ExprAssignMul struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignMul) Accept(v NodeVisitor) {
@ -1650,8 +1662,9 @@ func (n *ExprAssignMul) Accept(v NodeVisitor) {
// ExprAssignPlus node
type ExprAssignPlus struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignPlus) Accept(v NodeVisitor) {
@ -1661,8 +1674,9 @@ func (n *ExprAssignPlus) Accept(v NodeVisitor) {
// ExprAssignPow node
type ExprAssignPow struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignPow) Accept(v NodeVisitor) {
@ -1672,8 +1686,9 @@ func (n *ExprAssignPow) Accept(v NodeVisitor) {
// ExprAssignShiftLeft node
type ExprAssignShiftLeft struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignShiftLeft) Accept(v NodeVisitor) {
@ -1683,8 +1698,9 @@ func (n *ExprAssignShiftLeft) Accept(v NodeVisitor) {
// ExprAssignShiftRight node
type ExprAssignShiftRight struct {
Node
Var Vertex
Expr Vertex
Var Vertex
EqualTkn *token.Token
Expr Vertex
}
func (n *ExprAssignShiftRight) Accept(v NodeVisitor) {
@ -1695,6 +1711,7 @@ func (n *ExprAssignShiftRight) Accept(v NodeVisitor) {
type ExprBinaryBitwiseAnd struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1706,6 +1723,7 @@ func (n *ExprBinaryBitwiseAnd) Accept(v NodeVisitor) {
type ExprBinaryBitwiseOr struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1717,6 +1735,7 @@ func (n *ExprBinaryBitwiseOr) Accept(v NodeVisitor) {
type ExprBinaryBitwiseXor struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1728,6 +1747,7 @@ func (n *ExprBinaryBitwiseXor) Accept(v NodeVisitor) {
type ExprBinaryBooleanAnd struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1739,6 +1759,7 @@ func (n *ExprBinaryBooleanAnd) Accept(v NodeVisitor) {
type ExprBinaryBooleanOr struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1750,6 +1771,7 @@ func (n *ExprBinaryBooleanOr) Accept(v NodeVisitor) {
type ExprBinaryCoalesce struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1761,6 +1783,7 @@ func (n *ExprBinaryCoalesce) Accept(v NodeVisitor) {
type ExprBinaryConcat struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1772,6 +1795,7 @@ func (n *ExprBinaryConcat) Accept(v NodeVisitor) {
type ExprBinaryDiv struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1783,6 +1807,7 @@ func (n *ExprBinaryDiv) Accept(v NodeVisitor) {
type ExprBinaryEqual struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1794,6 +1819,7 @@ func (n *ExprBinaryEqual) Accept(v NodeVisitor) {
type ExprBinaryGreater struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1805,6 +1831,7 @@ func (n *ExprBinaryGreater) Accept(v NodeVisitor) {
type ExprBinaryGreaterOrEqual struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1816,6 +1843,7 @@ func (n *ExprBinaryGreaterOrEqual) Accept(v NodeVisitor) {
type ExprBinaryIdentical struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1827,6 +1855,7 @@ func (n *ExprBinaryIdentical) Accept(v NodeVisitor) {
type ExprBinaryLogicalAnd struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1838,6 +1867,7 @@ func (n *ExprBinaryLogicalAnd) Accept(v NodeVisitor) {
type ExprBinaryLogicalOr struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1849,6 +1879,7 @@ func (n *ExprBinaryLogicalOr) Accept(v NodeVisitor) {
type ExprBinaryLogicalXor struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1860,6 +1891,7 @@ func (n *ExprBinaryLogicalXor) Accept(v NodeVisitor) {
type ExprBinaryMinus struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1871,6 +1903,7 @@ func (n *ExprBinaryMinus) Accept(v NodeVisitor) {
type ExprBinaryMod struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1882,6 +1915,7 @@ func (n *ExprBinaryMod) Accept(v NodeVisitor) {
type ExprBinaryMul struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1893,6 +1927,7 @@ func (n *ExprBinaryMul) Accept(v NodeVisitor) {
type ExprBinaryNotEqual struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1904,6 +1939,7 @@ func (n *ExprBinaryNotEqual) Accept(v NodeVisitor) {
type ExprBinaryNotIdentical struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1915,6 +1951,7 @@ func (n *ExprBinaryNotIdentical) Accept(v NodeVisitor) {
type ExprBinaryPlus struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1926,6 +1963,7 @@ func (n *ExprBinaryPlus) Accept(v NodeVisitor) {
type ExprBinaryPow struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1937,6 +1975,7 @@ func (n *ExprBinaryPow) Accept(v NodeVisitor) {
type ExprBinaryShiftLeft struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1948,6 +1987,7 @@ func (n *ExprBinaryShiftLeft) Accept(v NodeVisitor) {
type ExprBinaryShiftRight struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1959,6 +1999,7 @@ func (n *ExprBinaryShiftRight) Accept(v NodeVisitor) {
type ExprBinarySmaller struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1970,6 +2011,7 @@ func (n *ExprBinarySmaller) Accept(v NodeVisitor) {
type ExprBinarySmallerOrEqual struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}
@ -1981,6 +2023,7 @@ func (n *ExprBinarySmallerOrEqual) Accept(v NodeVisitor) {
type ExprBinarySpaceship struct {
Node
Left Vertex
OpTkn *token.Token
Right Vertex
}