php-parser/node/scalar/encapsed.go

35 lines
717 B
Go
Raw Normal View History

2017-12-04 22:02:24 +00:00
package scalar
2017-12-03 21:29:17 +00:00
import (
"fmt"
"github.com/z7zmey/php-parser/token"
2017-12-04 22:02:24 +00:00
"github.com/z7zmey/php-parser/node"
2017-12-03 21:29:17 +00:00
"io"
)
2017-12-04 22:02:24 +00:00
type Encapsed struct {
node.SimpleNode
2017-12-03 21:29:17 +00:00
startToken token.Token
endToken token.Token
2017-12-04 22:02:24 +00:00
parts []node.Node
2017-12-03 21:29:17 +00:00
}
2017-12-04 22:02:24 +00:00
func NewEncapsed(startToken token.Token, parts []node.Node, endToken token.Token) node.Node {
return Encapsed{
node.SimpleNode{Name: "Encapsed", Attributes: make(map[string]string)},
2017-12-03 21:29:17 +00:00
startToken,
endToken,
parts,
}
}
2017-12-04 22:02:24 +00:00
func (n Encapsed) Print(out io.Writer, indent string) {
2017-12-04 21:24:12 +00:00
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.Name, n.startToken.StartLine, n.endToken.EndLine)
2017-12-03 21:29:17 +00:00
fmt.Fprintf(out, "\n%vparts:", indent+" ",)
for _, nn := range n.parts {
nn.Print(out, indent+" ")
}
}