cespare / goclj

Clojure parsing in Go
MIT License
37 stars 6 forks source link

Add a new package that makes it easier to do common things with a parse.Tree #47

Open cespare opened 8 years ago

cespare commented 8 years ago

Some common tasks:

It would be nice to have some clever high-level API for searching/matching certain constructs.

dmac commented 2 years ago

Another idea:

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()
}