I've tried fastparse, parboiled2 and scala-combinators. They all have this problem when defining a LEXER:
LET_KEYWORD ::= "let"
IDENTIFIER ::= "[a-zA-Z]+".r
When I run them against input "leto"
they produce [LET_KEYWORD,IDENTIFIER(o)]
.
I'd expect some of those libraries to give me a behaviour like this:
if the input is "let"
then it resolves the ambiguity by choosing the first defined rule because it's the more relevant.
if the input is "leto"
then there no ambiguity and produces only IDENTIFIER(leto)
.
That's the behaviour described here, in the ANTLR