-
Notifications
You must be signed in to change notification settings - Fork 69
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
Comments
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. |
I see, thank you for your help!
Siddharth
…On 6 February 2017 at 05:57, Nozomi Shibano ***@***.***> wrote:
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#72 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKN2PSA127P4c_Tunpe3gwREUOdRERzQks5rZvyugaJpZM4L0dt_>
.
|
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. |
@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. |
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?
The text was updated successfully, but these errors were encountered: