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

Scanner.Next should return an actual error #2

Closed
db47h opened this issue Aug 28, 2018 · 1 comment
Closed

Scanner.Next should return an actual error #2

db47h opened this issue Aug 28, 2018 · 1 comment
Labels
wontfix This will not be worked on

Comments

@db47h
Copy link
Owner

db47h commented Aug 28, 2018

The idea is to distinguish lexing errors from I/O errors.

On the other hand, if an I/O error occurs, s.abort is set to true, so any subsequent calls to next will return an EOF token.

Clients that need to distinguish error types may consider the built-in Error token as fatal and implement their own soft error token in their ragel file.

Something possibly more versatile is to have any returned error token added to a list of errors (with the actual error interface) and add ErrorCount and Errors method to Scanner.

@db47h db47h added the wontfix This will not be worked on label Sep 20, 2018
@db47h
Copy link
Owner Author

db47h commented Sep 20, 2018

After much consideration and extensive use with a couple of parsers, it turns out that an error from the lexer, whether due to incorrect input or I/O, will result in a parsing failure. Adding different error cases only complicates the parser implementation for no benefit.

@db47h db47h closed this as completed Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant