shell_exec node

This commit is contained in:
z7zmey 2017-12-18 20:00:19 +02:00
parent 40a27c6131
commit f0e3206c18
3 changed files with 33 additions and 2 deletions

31
node/expr/shell_exec.go Normal file
View 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+" ")
}
}
}

View File

@ -4209,7 +4209,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
//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:
yyDollar = yyS[yypt-2 : yypt+1]

View File

@ -889,7 +889,7 @@ expr_without_variable:
| T_EXIT exit_expr { $$ = expr.NewExit($2, strings.EqualFold($1.Value, "die")) }
| '@' expr { $$ = node.NewSimpleNode("Silence").Append($2); }
| scalar { $$ = $1; }
| '`' backticks_expr '`' { $$ = node.NewNodeExprShellExec($1, $2, $3) }
| '`' backticks_expr '`' { $$ = expr.NewShellExec($2) }
| T_PRINT expr { $$ = expr.NewPrint($2) }
| T_YIELD { $$ = node.NewSimpleNode("Yield"); }
| T_YIELD expr { $$ = node.NewSimpleNode("Yield").Append($2); }