Class/Object

laika.parse

Parser

Related Docs: object Parser | package parse

Permalink

abstract class Parser[+T] extends AnyRef

The abstract base for all parser implementations.

Contains the main parse function as well as various combinator function to create a new parser based on this one.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Parser
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Parser()

    Permalink

Abstract Value Members

  1. abstract def parse(in: ParserContext): Parsed[T]

    Permalink

    Parses the string content in the specified context and returns the result.

    Parses the string content in the specified context and returns the result.

    This is the only abstract method in Parser that concrete implementations need to implement.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def *: Repeat[T]

    Permalink

    Returns a parser that repeatedly applies this parser.

    Returns a parser that repeatedly applies this parser. It will always succeed, potentially with an empty list as the result.

  4. def +: Repeat[T]

    Permalink

    Returns a parser that repeatedly applies this parser (at least once).

  5. def <~[U](p: Parser[U]): Parser[T]

    Permalink

    Applies the specified parser to the input left over by this parser, but only keeps the left result.

    Applies the specified parser to the input left over by this parser, but only keeps the left result.

    a <~ b only succeeds if both parsers succeed.

  6. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  7. def >>[U](fq: (T) ⇒ Parser[U]): Parser[U]

    Permalink

    Operator synonym for flatMap.

  8. def ?: Parser[Option[T]]

    Permalink

    Returns a parser that optionally parses what this parser parses.

  9. def ^?[U](f: PartialFunction[T, U], error: (T) ⇒ String = ...): Parser[U]

    Permalink

    Returns a parser that applies a partial function to the result of this parser.

    Returns a parser that applies a partial function to the result of this parser.

    p ^? f succeeds if p succeeds and f is defined at the result of p, In that case it returns f applied to the result of p.

    f

    a partial function that will be applied to this parser's result.

    error

    an optional function that takes the same argument as f and produces an error message.

  10. def ^^[U](f: (T) ⇒ U): Parser[U]

    Permalink

    A synonym for map, allowing the grammar to be declared in a concise way.

  11. def ^^?[U](f: (T) ⇒ Either[String, U]): Parser[U]

    Permalink

    Returns a parser that applies a function to the result of this parser producing an Either where Left is interpreted as failure.

    Returns a parser that applies a function to the result of this parser producing an Either where Left is interpreted as failure. It is an alternative to ^? for scenarios where the conditional check cannot be easily performed in a pattern match.

    p ^^? f succeeds if p succeeds and f returns a Right when applied to the result of p.

  12. def ^^^[U](v: ⇒ U): Parser[U]

    Permalink

    Returns a parser that ignores the result of this parser (if it succeeds) and returns the specified result instead.

    Returns a parser that ignores the result of this parser (if it succeeds) and returns the specified result instead.

    Subclasses may override this method to avoid any expensive result processing.

  13. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  14. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def flatMap[U](f: (T) ⇒ Parser[U]): Parser[U]

    Permalink

    Builds a new parser by applying the specified function to the result of this parser and subsequently applying the parser returned by that function to the input left over by this parser.

  19. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  20. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  21. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  22. def map[U](f: (T) ⇒ U): Parser[U]

    Permalink

    Builds a new parser by applying the specified function to the result of this parser.

  23. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  24. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  26. def orElse[U >: T](p0: ⇒ Parser[U]): Parser[U]

    Permalink

    Applies the specified parser when this parser fails.

    Applies the specified parser when this parser fails.

    a orElse b succeeds if either of the parsers succeeds.

    Implementation note: The parameter is by-name to allow the definition of recursive parsers. In contrast to the former SDK parser combinators this is the only place where a parser with a by-name parameter is used whereas in all other places the additional cost is avoided.

  27. def parse(in: String): Parsed[T]

    Permalink

    Parses the specified string and returns the result.

  28. def rep: Repeat[T]

    Permalink

    Returns a parser that repeatedly applies this parser.

    Returns a parser that repeatedly applies this parser. The returned parser offers an API to specify further constraints like min or max.

  29. def repWith[U >: T](next: (U) ⇒ Parser[U]): Parser[List[U]]

    Permalink

    Returns a parser that invokes the specified function repeatedly, passing the result of this parser if it succeeds, to produce new parsers that get applied until one of them fails.

    Returns a parser that invokes the specified function repeatedly, passing the result of this parser if it succeeds, to produce new parsers that get applied until one of them fails.

    The result of the returned parser is a list containing the result of this parser (if it succeeds) plus the results of successful invocations of the parsers returned by the specified function.

  30. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  31. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  32. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. def withFailureMessage(msg: String): Parser[T]

    Permalink

    Changes the failure message produced by a parser.

  36. def |[U >: T](p: ⇒ Parser[U]): Parser[U]

    Permalink

    Applies the specified parser when this parser fails.

    Applies the specified parser when this parser fails.

    a | b succeeds if either of the parsers succeeds.

    Implementation note: The parameter is by-name to allow the definition of recursive parsers. In contrast to the former SDK parser combinators this is the only place where a parser with a by-name parameter is used whereas in all other places the additional cost is avoided.

  37. def ~[U](p: Parser[U]): Parser[~[T, U]]

    Permalink

    Applies the specified parser to the input left over by this parser and combines the two results.

    Applies the specified parser to the input left over by this parser and combines the two results.

    a ~ b only succeeds if both parsers succeed, with the results in a wrapper class named ~ for convenient pattern matching:

    a ~ b ~ c ^^ {
      case a ~ b ~ c => processResult(a, b, c)
    }
  38. def ~>[U](p: Parser[U]): Parser[U]

    Permalink

    Applies the specified parser to the input left over by this parser, but only keeps the right result.

    Applies the specified parser to the input left over by this parser, but only keeps the right result.

    a ~> b only succeeds if both parsers succeed.

Inherited from AnyRef

Inherited from Any

Ungrouped