-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
The parser doesn't allow parse_error() to return true and continue parsing. #3989
Comments
The documentation is not clear enough: the function must return |
Thanks for clarifying. Is there a bug that tracks "allow the parser to proceed after an error" or "allow parsing non-finite numbers"? |
Not that I am aware of. |
@francislan Is #4522 what you have in mind? |
@nlohmann Yes, exactly! Thanks! |
I am not entirely sure how this can be useful, but maybe I misunderstand your use case. Assume an input like
If we would continue parsing, we would continue with the events:
I think we would need to have a means to "stabilize" the parser - for instance, we could ignore the invalid value @francislan What is your use case? |
Description
The documentation has contradictory information:
Here, it says that parse_error() must return
false
but here, it says that "the return value indicates whether the parsing should continue, so the function should usually returnfalse
."However it seems that the code expects
parse_error()
to returnfalse
and doesn't continue parsing if it returnstrue
. See parser::sax_parse_internal() where it propagates the return value ofparse_error()
instead of only propagatingfalse
values.Example:
Should be
This would allow a SAX handler to deal with non-finite numbers, for example by stringifying them instead of failing parsing altogether. Of course a cleaner way would be for the parser to handle that natively by introducing a new method
virtual bool number_nonfinite(const string_t& s) = 0;
Reproduction steps
Have a SAX handler return
true
for someparse_error()
Expected vs. actual results
Expected: the parser to continue parsing the rest of the input.
Actual: the parser stops.
Minimal code example
No response
Error messages
No response
Compiler and operating system
N/A
Library version
developer branch
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: