You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nom should provide a good verbose error type to replace the one from the verbose-errors feature. I started an example in https://github.com/Geal/nom/blob/5.0/examples/json.rs
The code should be extracted from the example and put into nom.
Some questions on how to handle it:
how can we implement ParseError::or? This is used in alt, to compare or accumulate errors from different branches. I tried the error accumulation and I'm not convinced it's useful (most error branches will be useless). A better solution would be to compare the input position in various errors and keep the error that went the furthest into the input (it has the best chance to be the "correct" error)
I'd like to add a ParseError::from_tag method, to have the ability to write "expected tag 'xyz', found 'abc'". The issue is that we do not have any info on the lifetime of tags. I'm wary of introducing a lifetime in VerboseError. Should we mandate 'static on the tag? Or Clone?
in the same way, I'd like to construct errors from is_a and is_not, and show the expected chars in the errors, and I think it will have the samelifetime issues as tag
I wrote the example assuming the input type &str, which allows constructing a useful error message in convert_error. What would such an error message look like if the input is &[u8]? If it is &[u8] but we expect ASCII or UTF-8 data (but considering we might not have received valid data)
should VerboseError have implementations that work on types that deref to &str or &[u8] instead?
The text was updated successfully, but these errors were encountered:
the error type from the example is now integrated in ea87cdf. VerboseError is now generic over the input type, but now there's an issue with implementing or properly. convert_error can be specialized over the input type. Still no idea how to implement ParseError::from_tag
nom should provide a good verbose error type to replace the one from the
verbose-errors
feature. I started an example in https://github.com/Geal/nom/blob/5.0/examples/json.rsThe code should be extracted from the example and put into nom.
Some questions on how to handle it:
ParseError::or
? This is used inalt
, to compare or accumulate errors from different branches. I tried the error accumulation and I'm not convinced it's useful (most error branches will be useless). A better solution would be to compare the input position in various errors and keep the error that went the furthest into the input (it has the best chance to be the "correct" error)ParseError::from_tag
method, to have the ability to write "expected tag 'xyz', found 'abc'". The issue is that we do not have any info on the lifetime of tags. I'm wary of introducing a lifetime inVerboseError
. Should we mandate'static
on the tag? OrClone
?is_a
andis_not
, and show the expected chars in the errors, and I think it will have the samelifetime issues astag
&str
, which allows constructing a useful error message inconvert_error
. What would such an error message look like if the input is&[u8]
? If it is&[u8]
but we expect ASCII or UTF-8 data (but considering we might not have received valid data)VerboseError
have implementations that work on types that deref to&str
or&[u8]
instead?The text was updated successfully, but these errors were encountered: