-
Notifications
You must be signed in to change notification settings - Fork 52
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
Parser error messages #208
Comments
@sgpthomas @tedbauer add issues here as you find them |
So I’ve done some digging up on pest. A common consensus from its users is “the error messages suck.” This seems to be a problem in FuTIL as well. I've raised an issue asking about getting a nifty error for binary numbers without 0 or 1 ( pest-parser/pest#476 ); still waiting on a response. It seems the pest community is pretty dead lately. I also tried looking at an even simpler example similar to one listed here: import statement missing a semicolon. For example let's look at the syntax for
If the user forgets a semicolon here, it will give the following error:
Ideally, we would want to do something along the lines of
There's a few problems I'm running into with this.
However, I'm not sure what this method should do. I'd like it to just consume the semicolon and be done with it. I thought this would be simply as returning
Resulting error:
One hacky solution I was thinking about is simply allowing a binary number to take any digit, and catching the error later down the stack when we actually try to parse the binary number. I'm not exactly sure if this would be possible / how easy this would be, but its something I could try with your guys consent. |
Hey, thanks for looking into this! In general, getting good error messages out of a parser generator is quite hard—even when the parser generator makes good error reporting a priority. If the library doesn't support special features to offer control over error messages, often the only recourse is to just try fiddling around with equivalent ways of writing the same grammar (as you have here) to see if the error messages magically get better. Or to just switch to another parser generator! Anyway, I think it's worth fiddling around here, but I just wanted to put a warning here that it may be infeasible to make errors better without a more drastic step (in which case maybe it's not worth it for now). |
Thanks Adrian. I agree. Part of the next release of pest ( I am happy to hear other solutions though, since I'm still quite new to Rust and pest. Or, if switching to another parse generator is something of interest, I could look into that as well. |
yeah, it might be worthwhile to switch to a different parser. as much of a pain as that would be. A parser combinator library may be the way to go for this because they are generally better for error messages. I'm familiar with nom and I like it but it may be worthwhile to look into some other options. A thing that I would like to retain is being able to continue carrying span information around with identifiers so that we can have location specific error messages further along in the compiler pipeline. I should add that you shouldn't feel obligated to rewrite the parser. It's a rather tedious task, although it might give you some more rust experience. |
Ok we can bring this up in the next meeting. I wouldn't be opposed to the idea. Like you've mentioned, it would be a good entryway into learning Rust. |
@cgyurgyik Thanks for all the discussion! While better parsing error message are going to be great, it seems like switching out the parser will require some planning. In the meantime, if you want to jump into the deep end and quickly learn Rust and our pass infrastructure, I instead recommend writing a pass. For example, #177 would be good, self-contained pass that's worth implementing. |
Ok yeah I wasn't sure where it was on the list of priorities, and I'm sure its a pretty big undertaking. I'll look into #177. |
The general strategy to fixing these issues was adding additional parse rules that parse the bad case and then throw an informative error message. |
Awesome. |
The parser gives bad error messages when:
while
bodies don't haveseq
inside them.32'b4
The text was updated successfully, but these errors were encountered: