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

View File

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