-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case-insensitive literal matches throw off error position #361
Comments
Hmm, there's no obvious way to fix Interestingly, I strongly suspect that support for Thank you for any thoughts or suggestions! And thank you for a great parser. |
See kevinmehall/rust-peg#361. I have fixed the positions but lost the reporting of actual tokens/keywords.
If you want something that works on the current version, you could trick the infinite loop detection with This would also be a good use case for #284 once added. |
Thank you for the suggestions! The
|
Oops, try |
a85e71b allows |
Thank you, this is excellent! This will allow me to give much better errors in certain parsers. As always, |
First, I want to thank you for my absolute favorite Rust parser library. I've written so many little
peg
parsers for all kinds of things in so many open source tools.peg
is an amazing tool.I'm trying to write a parser that records token locations and whitespace, and I've run into a weird problem that throws off error positions. I'm trying to use the basic trick in #216, and it winds up looking like this:
However,
$([_]*<{kw.len()}>)
will match all the way to end ofkw.len()
. In a language that has some long keywords, this means that errors may be reported far to the right of where they actually occur.This version is better:
...but it can only ever report
expected keyword
, notexpected SELECT, DROP, or CREATE
.I tried replacing
/ expected!("keyword")
with/ {? Err(keyword) }
. Unfortunately, this triggers an infinite loop in the grammar, becausepeg
can't see the guaranteed failure and thinks it's an empty rule.Then I started to try weird things, like positive lookahead:
This does other weird things, like fail with
expected <unreported>
, because apparently positive look-ahead is silent on failure?Anyway, I'll try a few more things and see how it goes. Maybe
want(..)
should match twice, once as positive lookahead and a second time for real?The text was updated successfully, but these errors were encountered: