Error messages should report the line number where the error occurs. Currently they may dump a large portion of the input text, which is very much not ideal.
Implementation note: Try to avoid threading line number value throughout the parse process. Instead, use this trick: Keep hold of the complete input string somewhere where the error value is processed (this can be outside the inner machinery of the parser), and return the unparsed remaining input string (assumed to be a suffix of the whole input) as a preliminary value. The line number and column of the error are now the line count and length of last line of the parsed input prefix string you can get by slicing the length of the unparsed input off the end of the full input string. (Look up infer_line_num function in the existing code.)
Look into RON and it's SpannedError type for an example of an established crate similar to IDM and what it does. The scope of this issue is to report something similar the SpannedError structure where it reports the line (and optionally column) of the error along with a descriptive message. The message can just be a human-readable string for now, it doesn't need to be a large enum as in RON.
Error messages should report the line number where the error occurs. Currently they may dump a large portion of the input text, which is very much not ideal.
Implementation note: Try to avoid threading line number value throughout the parse process. Instead, use this trick: Keep hold of the complete input string somewhere where the error value is processed (this can be outside the inner machinery of the parser), and return the unparsed remaining input string (assumed to be a suffix of the whole input) as a preliminary value. The line number and column of the error are now the line count and length of last line of the parsed input prefix string you can get by slicing the length of the unparsed input off the end of the full input string. (Look up
infer_line_numfunction in the existing code.)Look into RON and it's
SpannedErrortype for an example of an established crate similar to IDM and what it does. The scope of this issue is to report something similar theSpannedErrorstructure where it reports the line (and optionally column) of the error along with a descriptive message. The message can just be a human-readable string for now, it doesn't need to be a large enum as in RON.