goclj
goclj copied to clipboard
Add a new package that makes it easier to do common things with a parse.Tree
Some common tasks:
- Checking whether a node is a symbol (or keyword, etc) and if it is, pulling out Val
- Walking through the whole tree recursively
It would be nice to have some clever high-level API for searching/matching certain constructs.
Another idea:
- Expose the key/value pairs of a map
There may be non-semantic nodes present, so a caller can't just iterate through every pair of m.Children().
Maybe this is implemented as:
type KeyVal struct {
Key Node
Val Node
}
func (m *MapNode) KeyVals() []*KeyVal
Or you could have an iterator, which might be more efficient if you're only looking for one key, say:
kv := m.KeyVals()
for kv.Next() {
key, val := kv.KeyVal()
}