rust-bakery / nom

Rust parser combinator framework
MIT License
9.38k stars 806 forks source link

The error message from `convert_error(VerboseError)` doesn't look good for general Nom errors #1620

Open saschanaz opened 1 year ago

saschanaz commented 1 year ago

Prerequisites

Here are a few things you should provide to help me understand the issue:

Description

Per the current implementation, only Char gets proper English sentence and others only get in (ErrorKind): e.g. in Fail from nom::combinator::fail().

https://github.com/rust-bakery/nom/blob/6923bacfd4e7496f56de787071bd221fef86faf4/src/error.rs#L343-L345

That's especially weird when mixed with nom::error::context() as it gets the same format. Thus it becomes:

0: at line 1, in Fail:
callback TotheFuture = void ()
                              ^

1: at line 1, in CallbackDefinition:
callback TotheFuture = void ()
^

I'd rather completely skip , in Fail in this example, or it would be even better if I could add a custom message why it needs to fail there, e.g. "Missing semicolon".

Can the messages get some customization?