Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
for my projects, I felt the need for an in-order callback during tree traversal.
(e.g. https://en.wikipedia.org/wiki/Tree_traversal -> in-order)
This pull request introduces a 'recur' callback beside 'enter' and 'leave'. recur is called with the parent element between the traversal of its children.
Think of this simple graph:
With recur, the overall sequence of traversal will be: Enter Parent, Enter A, Leave A, Recur Parent, Enter B, Leave B, Leave Parent. This, beside other usecases, can be useful to check, wether a node is actually a grandchild or a sibling of another node, which can be hard to detect with enter and leave alone.
Recur here only supports BREAK. Also, within replace, recur does not support replacing or removing, only BREAK.
It is just a little addition, but perhaps you find it useful, too.
Cheers,
Sven