If I have simple parser defs like this:
def term: Parser[String] = """[a-zA-Z"']+""".r ^^ { _.toString }
def intWhole: Parser[String] = wholeNumber ^^ { w => w }
def simpleTerm: Parser[String] = term >> {
case t:String => failure("Oops!")
}
If I parse against simpleTerm (with any string) it fails as expected with my "Oops!" message.
Now if I add this:
def repTerm: Parser[Unit] = rep(simpleTerm | intWhole) ^^ { _ => Unit }
If I now parse against repTerm, again with just a non-numeric character string, what I'd hope to happen is have it fail with the same "Oops!" message--basically an aborted parse. What happens instead is that I get no error at all; just the returned Unit.
Is there a way to make parsing stop once it hits a failure, and return that failure, during a rep() clause?