ast: print unknown node type
This commit is contained in:
parent
a995361468
commit
de7241ebe5
@ -1,5 +1,7 @@
|
||||
package ast
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Walk traverses an AST in depth-first order: It starts by calling fn(node);
|
||||
// node must not be nil. If f returns true, Walk invokes f recursively for
|
||||
// each of the non-nil children of node, followed by a call of f(nil).
|
||||
@ -30,6 +32,8 @@ func Walk(node Node, fn func(Node) bool) {
|
||||
for _, l := range n.List.Items {
|
||||
Walk(l, fn)
|
||||
}
|
||||
default:
|
||||
fmt.Printf(" unknown type: %T\n", n)
|
||||
}
|
||||
|
||||
fn(nil)
|
||||
|
Loading…
Reference in New Issue
Block a user