error_suppress node
This commit is contained in:
parent
ba71b6e7fa
commit
ae6fe52005
29
node/expr/error_suppress.go
Normal file
29
node/expr/error_suppress.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package expr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ErrorSuppress struct {
|
||||||
|
node.SimpleNode
|
||||||
|
expr node.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrorSuppress(expression node.Node) node.Node {
|
||||||
|
return ErrorSuppress{
|
||||||
|
node.SimpleNode{Name: "ErrorSuppress", Attributes: make(map[string]string)},
|
||||||
|
expression,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n ErrorSuppress) Print(out io.Writer, indent string) {
|
||||||
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||||
|
|
||||||
|
if n.expr != nil {
|
||||||
|
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
|
||||||
|
n.expr.Print(out, indent+" ")
|
||||||
|
}
|
||||||
|
}
|
@ -4195,7 +4195,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line parser/parser.y:888
|
//line parser/parser.y:888
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewSimpleNode("Silence").Append(yyDollar[2].node)
|
yyVAL.node = expr.NewErrorSuppress(yyDollar[2].node)
|
||||||
}
|
}
|
||||||
case 360:
|
case 360:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
|
@ -885,7 +885,7 @@ expr_without_variable:
|
|||||||
| 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 { $$ = 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 { $$ = expr.NewErrorSuppress($2) }
|
||||||
| scalar { $$ = $1; }
|
| scalar { $$ = $1; }
|
||||||
| '`' backticks_expr '`' { $$ = expr.NewShellExec($2) }
|
| '`' backticks_expr '`' { $$ = expr.NewShellExec($2) }
|
||||||
| T_PRINT expr { $$ = expr.NewPrint($2) }
|
| T_PRINT expr { $$ = expr.NewPrint($2) }
|
||||||
|
Loading…
Reference in New Issue
Block a user