scala-parser-combinators icon indicating copy to clipboard operation
scala-parser-combinators copied to clipboard

`|||` parser reports error on only one of the explored branches

Open ValentinAebi opened this issue 1 year ago • 1 comments

When both branches of a ||| combinator produce a Failure as a result, the resulting error message is the one coming from the branch that matched the longest chain. This can lead to confusing error messages in situations like this one:

lazy val parser = (intKeyword ~ ...) ||| (doubleKeyword ~ ...)

where the parser outputs an error message like expected 'int'. I think that it would be much less confusing to issue an error message that contains all the possible tokens: expected 'int' or 'double'.

Am I using the API the wrong way, or is there no way of configuring the parser to output such error messages? In the latter case, the addition of such a feature would be much appreciated.

ValentinAebi avatar Oct 11 '24 15:10 ValentinAebi

I think you might need to dig into the source code to answer this (and perhaps improve it) yourself, as I don't think there's anyone left who actually knows the codebase well.

SethTisue avatar Oct 26 '24 19:10 SethTisue