2018-02-20 18:05:04 +00:00
|
|
|
package walker // Node walking behavior
|
2018-01-17 16:58:45 +00:00
|
|
|
|
2018-02-20 17:52:07 +00:00
|
|
|
// Walkable interface
|
2018-02-20 18:05:04 +00:00
|
|
|
//
|
|
|
|
// Every node must implement this interface
|
2018-02-20 17:52:07 +00:00
|
|
|
type Walkable interface {
|
2018-01-17 16:58:45 +00:00
|
|
|
Walk(v Visitor)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Visitor interface
|
|
|
|
type Visitor interface {
|
2018-02-20 18:05:04 +00:00
|
|
|
EnterNode(w Walkable) bool // EnterNode is invoked for each node encountered by Walk.
|
|
|
|
GetChildrenVisitor(Key string) Visitor // GetChildrenVisitor is invoked at every node parameter that contains children nodes
|
|
|
|
LeaveNode(w Walkable) // LeaveNode is invoked after process node
|
2018-01-17 16:58:45 +00:00
|
|
|
}
|