I’m using NimbleParsec to parse a protocol and I would like to know if there is anyway to force a combinator to use labels.
For example, if I have this integer(min: 1) |> label("protocol"), the library will return an random error and not the protocol one in case I don’t send an integer. I would like to known if there is anyway to encapsulate a logic to guarantee that in case it fails, I can get a label to then pattern match later on the exact part it failed.
Which seems pretty reasonable to me. I do find returning meaningful parsing errors a bit tricky at times - but typically not an issue in this simple kind of case.
Sorry about the noise, I found the problem. I’m building a long chain of combinators, and the error was coming from the next one in the chain. I posted just a small snippet to make it easier to frame the question, but it masked out the problem.
Glad you’re up and running. I typically try to make the grammar as explicit as possible and avoid lookahead unless really necessary. Perhaps thats just my preference. For example: