Skip to content

Pattern that doesn't consume a set of terminal characters #83

Answered by renggli
venkatd asked this question in Q&A
Discussion options

You must be logged in to vote

I see.

The clean way would be to rewrite the URL grammar so that it does not consume the separator characters at the end. There are various ways of doing that (separatedBy, and, not), but none of them is particularly simple. Also you wrote you don't want to change the existing grammar, so I assume this is not a solution.

Another approach is to use what I originally proposed, but do the transformation in the continuation parser (callCC) and resume the parsing one character earlier. Something along the lines of:

return (...)
  .token() // get token with start and stop position in input
  .callCC((continuation, context) {
    final result = continuation(context);
    if (result.isFailure) re…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by renggli
Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #83 on December 08, 2020 19:53.