Parser

enum Parser[A]

A parser that produces a value of type A.

A parser that produces a value of type A.

The context is used to represent the possibility of resuming the parser with additional input and, optionally, already parsed input. There are two context types provided:

  • Complete which is the result type for parsers that cannot be resumed.
  • Resumable, which is the result type for parsers that can be resumed.

There are three cases within Complete:

  • Epsilon, for a parser that failed but did not consume any input;
  • Committed, for a parser that failed after consuming some input; and
  • Success, for a parser that successfully parsed a portion of it's input and produced a value of type A.

Resumable adds an additional cause for a parser that can be resumed.

Parsers can be resumed if they accept their complete input but do not parse it. In other words, a parser that Committed to its entire input. Additionally, the programmer must indicate that a parser can be resumed using the resumable method.

Resumption is quite limited. The original input is not reparsed on resumption. Parsing starts again on the new input and hence a parser cannot carry state across resumption boundaries.

Companion
object
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Type members

Enum entries

case Character(char: Char) extends Parser[Char]
case CharacterWhere(predicate: Char => Boolean) extends Parser[Char]
case CharactersUntilRegexOrEnd(regex: Regex, empty: Boolean, through: Boolean) extends Parser[String]
case CharactersUntilTerminator(terminators: Seq[String], empty: Boolean, through: Boolean) extends Parser[String]
case CharactersUntilTerminatorOrEnd(terminators: Seq[String], empty: Boolean, through: Boolean) extends Parser[String]
case CharactersWhile(predicate: Char => Boolean, empty: Boolean, through: Boolean) extends Parser[String]
case End extends Parser[String]
case Exactly(expected: String) extends Parser[String]
case Map[A, B](source: Parser[A], f: A => B) extends Parser[B]
case OneOf[A](parsers: List[Parser[A]]) extends Parser[A]
case OrElse[A](left: Parser[A], right: Parser[A]) extends Parser[A]
case Product[A, B](left: Parser[A], right: Parser[B]) extends Parser[(A, B)]
case StringIn(strings: Iterable[String]) extends Parser[String]
case Void[A](parser: Parser[A]) extends Parser[Unit]