variable node, allow nil finally

This commit is contained in:
vadim
2017-12-06 15:04:44 +02:00
parent c744a6c170
commit 2d168cd2e2
4 changed files with 519 additions and 490 deletions

25
node/expr/variable.go Normal file
View File

@@ -0,0 +1,25 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type Variable struct {
node.SimpleNode
token token.Token
}
func NewVariable(token token.Token) node.Node {
return Variable{
node.SimpleNode{Name: "Variable", Attributes: make(map[string]string)},
token,
}
}
func (n Variable) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -38,6 +38,8 @@ func (n Try) Print(out io.Writer, indent string) {
nn.Print(out, indent+" ")
}
fmt.Fprintf(out, "\n%vfinally:", indent+" ")
n.finally.Print(out, indent+" ")
if n.finally != nil {
fmt.Fprintf(out, "\n%vfinally:", indent+" ")
n.finally.Print(out, indent+" ")
}
}