Skip to content
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

How can I count/enumerate all syntax errors that occur while parsing? #72

Closed
siddharth-krishna opened this issue Feb 1, 2017 · 4 comments

Comments

@siddharth-krishna
Copy link

Sorry this is more a question than an issue. I know I can try-catch parse errors and get line number information from the lex buffer, but is it possible to count the number of syntax errors or get line numbers for all errors encountered? Or does this raise an exception on the first seen error?

@nshibano
Copy link

nshibano commented Feb 6, 2017

Hi,

First of all I am not expert in this area. This is just my opinions.

I think your understanding is correct. It throws exception. When parser encounters error, it can not recognize further tokens.

If you want to count number of errors, you can restart parsing from next token of the point first error was occur, or next semicolon, newline or something.

@siddharth-krishna
Copy link
Author

siddharth-krishna commented Feb 7, 2017 via email

@ihavenonickname
Copy link

Rich error reporting/recovery (which is what you're asking for) is probably the most common reason for writing your own, custom parser. Parser generators usually don't provide rich error reporting and error recovery.

Note: I've never used this specific parser generator so what I just said is a general advice.

@cartermp
Copy link
Contributor

cartermp commented Apr 9, 2020

@siddharth-krishna as others have mentioned here, a bespoke parser is the best approach if you want good error recovery. F# uses a generated parser but also has a layer that sits atop it that provides a lot of these kinds of things, in addition to a tooling host that can introspect things at different points when compared to a batch compilation process. It's not really a goal of this project to offer more intricate error recovery, so I'll close this one out.

@cartermp cartermp closed this as completed Apr 9, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants