Documentation
¶
Overview ¶
Copyright 2009 The Go Authors. All rights reserved. Copyright 2015 Benoit Sigoure. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Rewrite ¶
func Rewrite(v Rewriter, node Node) (rewritten Node)
Rewrite traverses an AST in depth-first order: It starts by calling v.Rewrite(node); node must not be nil. If the visitor w returned by v.Rewrite(node) is not nil, Rewrite is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Rewrite(nil).
Types ¶
type Rewriter ¶
type Rewriter interface {
Rewrite(node Node) (rewritten Node, w Rewriter)
}
A Rewriter's Rewrite method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Rewrite(nil).