Skip to content

An ergonomic "reverse identifier" #178

Answered by renggli
amake asked this question in Q&A
Oct 10, 2024 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Your example with starLazy is what I would have suggested. Only thing I would do is to extract a helper method, to make it more readable, i.e.

Parser reverseId(Parser inner, Parser terminator) => 
    inner.starLazy(terminator & inner.not()) & terminator;

final id = reverseId(letter() | digit(), letter());

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@amake
Comment options

Answer selected by amake
Comment options

You must be logged in to vote
2 replies
@amake
Comment options

@renggli
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants