Skip to content

Make choice report full names instead of first letters #525

Answered by zesterer
soywod asked this question in Q&A
Discussion options

You must be logged in to vote

This is a product of the fact that just works on the level of tokens (in your case, chars), even when given a sequence (like "foo"). Chumsky provides a way to 'realias' a parser in error messages: the .labelled(...) combinator (on 1.0, you'll need to enable the label feature). Now you can do this:

just("foo")
    .labelled("foo")

And you'll get something like this in the error message:

found 'b', expected 'foo'

labelled works on all parsers, even much more complex ones. This allows you to realias an entire pattern (such as 'expressions') and have something like found '#', expected expression appear in your error message. For example, the nano_rust example uses this to produce easier to u…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@soywod
Comment options

@zesterer
Comment options

Answer selected by soywod
@soywod
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
3 participants