I've just been using your library for parsing some text and it's been very useful. One feature I missed was being able to handle missing values in my NodeVisitor nicely (e.g. from a ? or * pattern that doesn't match). Being able to do:
if not node:
vals = []
would be a convenient idiom to use when the pattern didn't match. It could also be used to do the right thing if visited_children was used as well.
I think bool(node) would just be:
def __bool__(self):
"""Returns True when one or more characters were matched.
Returns False for ? and * Patterns that fail to match."""
return self.start != self.end
I'm happy to turn this into a (trivial) pull request, posting as an issue in case I'm missing something!
I've just been using your library for parsing some text and it's been very useful. One feature I missed was being able to handle missing values in my
NodeVisitor
nicely (e.g. from a?
or*
pattern that doesn't match). Being able to do:would be a convenient idiom to use when the pattern didn't match. It could also be used to do the right thing if
visited_children
was used as well.I think
bool(node)
would just be:I'm happy to turn this into a (trivial) pull request, posting as an issue in case I'm missing something!