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

Cannot iterate over Derivation nodes except (pre)terminals #246

Closed
goodmami opened this issue Aug 14, 2019 · 1 comment
Closed

Cannot iterate over Derivation nodes except (pre)terminals #246

goodmami opened this issue Aug 14, 2019 · 1 comment
Milestone

Comments

@goodmami
Copy link
Member

The UDFNode.terminals() and UDFNode.preterminals() methods recursively descend through the tree and return lists of nodes, but for all other nodes the user must do this descent themselves. In addition to iterating over nonterminals (or non-preterminals), a way to get the root node (if it exists) could be handy. Currently one must test if node.is_root() is True.

Calling everything above preterminals "nonterminals" wouldn't be quite right, as preterminals are nonterminals, too. The wiki uses "internal nodes", so maybe internals()?

Whatever it's called, the desired change in functionality would be something like:

  • Derivation.root() -- return the root node if there is one, otherwise None
  • UDFNode.internals() (or something) -- return all non-root nodes above the preterminals

As for the iteration order, depth-first makes sense as it's the order encountered in the UDF string.

@goodmami goodmami added this to the v1.1.0 milestone Aug 14, 2019
@goodmami
Copy link
Member Author

Let's go with internals() for the node-listing function, and let's drop the idea of the root() method until a real need arises.

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

No branches or pull requests

1 participant