Result

sealed trait Result[Token, +A]

Result of a parsing operation.

This is essentially a very specialised version of Either (and can, in fact, be turned into one through toEither).

A result keeps track of whether or not any data has been consumed when producing it. This is used to decide whether or not to try alternative parsers in a Parser.| call.

Results also store an error message even if they're successful. This might seem a little odd, but is necessary to be able to provide good error messages for combinators such as Parser.filter where we might turn a success into a failure after the fact.

Companion:
object
class Object
trait Matchable
class Any
class Error[Token]
class Ok[Token, A]

Value members

Abstract methods

def consumed: Boolean

Concrete methods

def consume: Result[Token, A]

Marks this result as consuming.

Marks this result as consuming.

def empty: Result[Token, A]

Marks this result as non-consuming.

Marks this result as non-consuming.

def label(label: String): Result[Token, A]
def map[B](f: A => B): Result[Token, B]
def mapMessage(f: Message => Message): Result[Token, A]
def recoverWith[AA >: A](f: Error[Token] => Result[Token, AA]): Result[Token, AA]
def setStart(pos: Position): Result[Token, A]
def toEither: Either[Message, A]