Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cespare opened this issue Sep 28, 2016 · 1 comment

Comments

@cespare
Copy link
Owner

cespare commented Sep 28, 2016

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.

@dmac
Copy link
Collaborator

dmac commented Mar 30, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants