php-parser/dumper.go

31 lines
530 B
Go
Raw Normal View History

2017-12-27 23:23:32 +00:00
package main
import (
"fmt"
"github.com/z7zmey/php-parser/node"
)
type dumper struct {
indent string
}
2017-12-28 11:36:27 +00:00
func (d dumper) EnterNode(n node.Node) bool {
2017-12-27 23:23:32 +00:00
fmt.Printf("%v[%v]:\n", d.indent, n.Name())
return true
}
2017-12-28 11:36:27 +00:00
func (d dumper) GetChildrenVisitor(key string) node.Visitor {
2017-12-27 23:23:32 +00:00
fmt.Printf("%v%v:\n", d.indent+". ", key)
return dumper{d.indent + ". . "}
}
func (d dumper) Scalar(key string, value interface{}) {
fmt.Printf("%v%v: %v\n", d.indent+". ", key, value)
}
2017-12-28 11:36:27 +00:00
func (d dumper) LeaveNode(n node.Node) {
// do nothing
}