From 1db53be4aec68c2ae672db527a5d750e1010d0e8 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Fri, 12 Jan 2018 10:16:09 +0200 Subject: [PATCH] update dumper.go comments --- visitor/dumper.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/visitor/dumper.go b/visitor/dumper.go index 1c81122..ebfbfee 100644 --- a/visitor/dumper.go +++ b/visitor/dumper.go @@ -10,12 +10,15 @@ import ( "github.com/z7zmey/php-parser/node" ) +// Dumper prints ast hierarchy to stdout +// Also prints comments and positions attached to nodes type Dumper struct { Indent string Comments comment.Comments Positions position.Positions } +// EnterNode is invoked at every node in heirerchy func (d Dumper) EnterNode(n node.Node) bool { fmt.Printf("%v%v", d.Indent, reflect.TypeOf(n)) @@ -37,11 +40,13 @@ func (d Dumper) EnterNode(n node.Node) bool { return true } +// GetChildrenVisitor is invoked at every node parameter that contains children nodes func (d Dumper) GetChildrenVisitor(key string) node.Visitor { fmt.Printf("%v%q:\n", d.Indent+" ", key) return Dumper{d.Indent + " ", d.Comments, d.Positions} } +// LeaveNode is invoked after node process func (d Dumper) LeaveNode(n node.Node) { // do nothing }