Parser choice combines two alternative parsers into one parser that succeeds when either alternative succeeds. Its infix form, |, keeps alternatives readable. section 9.1
The alternatives can parse the same result type. Trying string("abra") | string("cadabra") accepts either input and returns the matching string. section 9.1
Choosing between strings
val p = string("abra").or(string("cadabra")) p.run("abra") == Right("abra") p.run("cadabra") == Right("cadabra") section 9.1
extension [A](p: Parser[A]) def or(p2: Parser[A]): Parser[A]
Browse the generic or combinator signature for combining parsers with the same result type. section 9.1
string("abra").or(string("cadabra")).run("abra") == Right("abra")
string("abra").or(string("cadabra")).run("cadabra") == Right("cadabra")
Browse executable alternatives showing successful results for each branch. section 9.1
