1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-27 04:24:41 +01:00

Give node visitor callback type a name and docs

This commit is contained in:
Vytautas Šaltenis 2016-04-05 10:08:50 +03:00
parent 76062d428d
commit e7d45749ff

View File

@ -230,7 +230,12 @@ func (n *Node) canContain(t NodeType) bool {
return false return false
} }
func (root *Node) Walk(visitor func(node *Node, entering bool)) { // NodeVisitor is a callback to be called when traversing the syntax tree.
// Called twice for every node: once with entering=true when the branch is
// first visited, then with entering=false after all the children are done.
type NodeVisitor func(node *Node, entering bool)
func (root *Node) Walk(visitor NodeVisitor) {
walker := NewNodeWalker(root) walker := NewNodeWalker(root)
node, entering := walker.next() node, entering := walker.next()
for node != nil { for node != nil {