Skip to content

Reporting parsing erros #185

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

You must be logged in to vote

Thank you for the one-click reproducible example. This is really appreciated!

As you observed, the issue is that the star() operator is happy to end before a failing definition, which then causes the end-of-input parser to fail with a not so helpful error message.

You can avoid the problem after the repeating star() operator by checking that you either

  • reached the end-of-input (which is good), OR
  • you retry the definition to pass up a nice error message.
Parser start() => ref0(file);
Parser file() => ref0(definition).star() & (endOfInput().trim() | ref0(definition));
...

Replies: 3 comments

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 #184 on December 04, 2024 22:16.