shell_exec node
This commit is contained in:
parent
40a27c6131
commit
f0e3206c18
31
node/expr/shell_exec.go
Normal file
31
node/expr/shell_exec.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package expr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ShellExec struct {
|
||||||
|
node.SimpleNode
|
||||||
|
parts []node.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewShellExec(parts []node.Node) node.Node {
|
||||||
|
return ShellExec{
|
||||||
|
node.SimpleNode{Name: "ShellExec", Attributes: make(map[string]string)},
|
||||||
|
parts,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n ShellExec) Print(out io.Writer, indent string) {
|
||||||
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||||
|
|
||||||
|
if n.parts != nil {
|
||||||
|
fmt.Fprintf(out, "\n%vparts:", indent+" ")
|
||||||
|
for _, nn := range n.parts {
|
||||||
|
nn.Print(out, indent+" ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4209,7 +4209,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line parser/parser.y:892
|
//line parser/parser.y:892
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewNodeExprShellExec(yyDollar[1].token, yyDollar[2].list, yyDollar[3].token)
|
yyVAL.node = expr.NewShellExec(yyDollar[2].list)
|
||||||
}
|
}
|
||||||
case 362:
|
case 362:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
|
@ -889,7 +889,7 @@ expr_without_variable:
|
|||||||
| T_EXIT exit_expr { $$ = expr.NewExit($2, strings.EqualFold($1.Value, "die")) }
|
| T_EXIT exit_expr { $$ = expr.NewExit($2, strings.EqualFold($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 '`' { $$ = expr.NewShellExec($2) }
|
||||||
| T_PRINT expr { $$ = expr.NewPrint($2) }
|
| T_PRINT expr { $$ = expr.NewPrint($2) }
|
||||||
| T_YIELD { $$ = node.NewSimpleNode("Yield"); }
|
| T_YIELD { $$ = node.NewSimpleNode("Yield"); }
|
||||||
| T_YIELD expr { $$ = node.NewSimpleNode("Yield").Append($2); }
|
| T_YIELD expr { $$ = node.NewSimpleNode("Yield").Append($2); }
|
||||||
|
Loading…
Reference in New Issue
Block a user