Replies: 1 comment
-
That's a difficult one, because there's not an inherent reason for the parser to report a missing semicolon instead of, say, "expected operator instead of let". One thing you could do is to add the following on to the end of your expression parser: expr.then_ignore(just("let").not())
You can combine it with a |
Beta Was this translation helpful? Give feedback.
-
Imagine you have a Rust-like language that uses semicolons as terminators:
Forgetting a semicolon is an easy mistake to make. I've experimented a bit with Chumsky, but it seems that it will always pinpoint the next token (
let
in this case) as the cause of the error. That's not wrong, because after all that token was supposed to be a semicolon, but I'm wondering if there's a way to get the span of the previous token (i.e.0
in this case) so I can provide a better error message? Ideally I'd like to point at the0
and say I expected a semicolon after it.Thanks a lot for all the work you've put in to Chumsky, by the way. Writing a parser with it felt like a breeze.
Beta Was this translation helpful? Give feedback.
All reactions