exit node
This commit is contained in:
parent
c6729a06e2
commit
0609575139
32
node/expr/exit.go
Normal file
32
node/expr/exit.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package expr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Exit struct {
|
||||||
|
node.SimpleNode
|
||||||
|
expr node.Node
|
||||||
|
isDie bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewExit(expr node.Node, isDie bool) node.Node {
|
||||||
|
return Exit{
|
||||||
|
node.SimpleNode{Name: "Exit", Attributes: make(map[string]string)},
|
||||||
|
expr,
|
||||||
|
isDie,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n Exit) Print(out io.Writer, indent string) {
|
||||||
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||||
|
fmt.Fprintf(out, "\n%vis die: %t", indent+" ", n.isDie)
|
||||||
|
|
||||||
|
if n.expr != nil {
|
||||||
|
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
|
||||||
|
n.expr.Print(out, indent+" ")
|
||||||
|
}
|
||||||
|
}
|
@ -4188,7 +4188,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line parser/parser.y:879
|
//line parser/parser.y:879
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewSimpleNode("Exit").Append(yyDollar[2].node)
|
yyVAL.node = expr.NewExit(yyDollar[2].node, yyDollar[1].token.Value == "die")
|
||||||
}
|
}
|
||||||
case 359:
|
case 359:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
|
@ -876,7 +876,7 @@ expr_without_variable:
|
|||||||
| T_OBJECT_CAST expr { $$ = cast.NewCastObject($2) }
|
| T_OBJECT_CAST expr { $$ = cast.NewCastObject($2) }
|
||||||
| T_BOOL_CAST expr { $$ = cast.NewCastBool($2) }
|
| T_BOOL_CAST expr { $$ = cast.NewCastBool($2) }
|
||||||
| T_UNSET_CAST expr { $$ = cast.NewCastUnset($2) }
|
| T_UNSET_CAST expr { $$ = cast.NewCastUnset($2) }
|
||||||
| T_EXIT exit_expr { $$ = node.NewSimpleNode("Exit").Append($2); }
|
| T_EXIT exit_expr { $$ = expr.NewExit($2, $1.Value == "die") }
|
||||||
| '@' expr { $$ = node.NewSimpleNode("Silence").Append($2); }
|
| '@' expr { $$ = node.NewSimpleNode("Silence").Append($2); }
|
||||||
| scalar { $$ = $1; }
|
| scalar { $$ = $1; }
|
||||||
| '`' backticks_expr '`' { $$ = node.NewNodeExprShellExec($1, $2, $3) }
|
| '`' backticks_expr '`' { $$ = node.NewNodeExprShellExec($1, $2, $3) }
|
||||||
|
Loading…
Reference in New Issue
Block a user