save expr.Exit and expr.Die comments
This commit is contained in:
parent
22cca215df
commit
deccf266d9
287
php7/php7.go
287
php7/php7.go
File diff suppressed because it is too large
Load Diff
29
php7/php7.y
29
php7/php7.y
@ -3109,16 +3109,30 @@ expr_without_variable:
|
||||
| T_EXIT exit_expr
|
||||
{
|
||||
if (strings.EqualFold($1.Value, "die")) {
|
||||
$$ = expr.NewDie($2)
|
||||
$$ = expr.NewDie(nil)
|
||||
if $2 != nil {
|
||||
$$.(*expr.Die).Expr = $2.(*expr.Exit).Expr
|
||||
}
|
||||
} else {
|
||||
$$ = expr.NewExit($2)
|
||||
$$ = expr.NewExit(nil)
|
||||
if $2 != nil {
|
||||
$$.(*expr.Exit).Expr = $2.(*expr.Exit).Expr
|
||||
}
|
||||
}
|
||||
|
||||
// save position
|
||||
if $2 == nil {
|
||||
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1))
|
||||
} else {
|
||||
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2))
|
||||
}
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExitToken)
|
||||
|
||||
if $2 != nil {
|
||||
yylex.(*Parser).comments.AddFromChildNode($$, $2)
|
||||
}
|
||||
}
|
||||
| '@' expr
|
||||
{
|
||||
@ -3368,7 +3382,16 @@ exit_expr:
|
||||
/* empty */
|
||||
{ $$ = nil }
|
||||
| '(' optional_expr ')'
|
||||
{ $$ = $2; }
|
||||
{
|
||||
$$ = expr.NewExit($2);
|
||||
|
||||
// save position
|
||||
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken)
|
||||
yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken)
|
||||
}
|
||||
;
|
||||
|
||||
backticks_expr:
|
||||
|
Loading…
Reference in New Issue
Block a user