Class/Object

molecule.parsing

Parser

Related Docs: object Parser | package parsing

Permalink

abstract class Parser[A, +B] extends AnyRef

Incremental parser

A

the type of the input messages accepted by a parser B the type of the result

Self Type
Parser[A, B]
Linear Supertypes
AnyRef, Any
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 apply(seg: Seg[A]): ParseResult[B, A]

    Permalink

    Apply this parser to the next segment.

    Apply this parser to the next segment.

    seg

    the segment to parse for the next message

    returns

    a parse result

  2. abstract def name: String

    Permalink

    The name of this parser (used for debugging)

    The name of this parser (used for debugging)

    returns

    name of this parser

  3. abstract def result(signal: Signal): Option[Either[Fail, Done[B, A]]]

    Permalink

    Request result because there is no more data

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 *(implicit parsers: Parsers[A]): Parser[A, Seg[B]]

    Permalink

    Returns a parser that repeatedly parses what this parser parses

    Returns a parser that repeatedly parses what this parser parses

    returns

    rep(this)

  4. def +(implicit parsers: Parsers[A]): Parser[A, Seg[B]]

    Permalink

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

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

    returns

    rep1(this)

  5. def <~[U](p: ⇒ Parser[A, U]): Parser[A, B]

    Permalink

    A parser combinator for sequential composition which keeps only the left result

    A parser combinator for sequential composition which keeps only the left result

    p <~ q' succeeds if p' succeeds and q' succeeds on the input left over by p'.

    Note: <~ has lower operator precedence than ~ or ~>.

    returns

    a Parser' that -- on success -- returns the result of p'.

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

    Permalink
    Definition Classes
    AnyRef → Any
  7. def ?(implicit parsers: Parsers[A]): Parser[A, Option[B]]

    Permalink

    Returns a parser that optionally parses what this parser parses.

    Returns a parser that optionally parses what this parser parses.

    returns

    opt(this)

  8. def ^^[U](f: (B) ⇒ U): Parser[A, U]

    Permalink

    A parser combinator for function application

    A parser combinator for function application

    p ^^ f' succeeds if p' succeeds; it returns f' applied to the result of p'.

    f

    a function that will be applied to this parser's result (see map' in ParseResult').

    returns

    a parser that has the same behaviour as the current parser, but whose result is transformed by f'.

  9. def ^^^[U](r: U): Parser[A, U]

    Permalink

    A parser combinator for substituting a result with another

    A parser combinator for substituting a result with another

    p ^^^ r' succeeds if p' succeeds; it returns r'

    r

    the substitution result

    returns

    a parser that has the same behaviour as the current parser, but whose result is replaced by r'.

  10. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def collect[C](f: PartialFunction[B, C]): Parser[A, C]

    Permalink
  13. def contraMap[Z](g: (Z) ⇒ A, consume: (Z, A) ⇒ Z): Parser[Z, B]

    Permalink

    transforms this of type Parser[A,B] into a parser of type Parser[Z,B].

    transforms this of type Parser[A,B] into a parser of type Parser[Z,B].

    g

    function that maps a message of type Z into a message of type A. Given an input stream ichan: IChan[Z] and a parser: Parser[A,B], the stream transformation ichan.parse(parser.contraMap(g,h)) is equivalent to ichan.map(g).parse(parser). The reason for contraMap is to be able to apply g until a first parsed result on a input:Input[Z]; input.read(parser.contraMap(g,h)) will leave, after reading the first parsed result, the stream untouched and of type Z, so one map want to apply another parser of type Parser[Z,C] afterwards.

    consume

    function to generate a partially consumed message type Z in case the inverse function of g does not exists. A parser may partially consume a message of an input stream. So if this leaves a partially consumed message of type A on the stream, an equally consumed message of type Z will generated with function consume. In the function consume(z:A,a:A):Z, z is the message to be partially consumed, a is the partially consume value of g(z); the return value must be the partially consume z such that g( consume(z,a) ) == a and when g(z) == a than consume(z,a) == z If consume is not correctly specified, the contraMapped parser may give unexpected results in case of partially consumed messages.

    returns

    a contraMapped parser

  14. def contraMapReversible[Z](g: (Z) ⇒ A, h: (A) ⇒ Z): Parser[Z, B]

    Permalink

    transforms this of type Parser[A,B] into a parser of type Parser[Z,B].

    transforms this of type Parser[A,B] into a parser of type Parser[Z,B].

    g

    function that maps a message of type Z into a message of type A. Given an input stream ichan: IChan[Z] and a parser: Parser[A,B], the stream transformation ichan.parse(parser.contraMap(g,h)) is equivalent to ichan.map(g).parse(parser). The reason for contraMap is to be able to apply g until a first parsed result on a input:Input[Z]; input.read(parser.contraMap(g,h)) will leave, after reading the first parsed result, the stream untouched and of type Z, so one map want to apply another parser of type Parser[Z,C] afterwards.

    h

    inverse function of g. A parser may partially consume a message of an input stream. So if this leaves a partially consumed message of type A on the stream, that message will be reverse mapped to Z with function h. If h(g(a)) is not equal to a, the contraMapped parser may give unexpected results in case of partially consumed messages. In case the function h is not defined, one must use contraMap[Z](g: Z => A, consume:(Z,A) => Z): Parser[Z, B].

    returns

    a contraMapped parser

  15. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def filter(p: (B) ⇒ Boolean): Parser[A, B]

    Permalink

    Filter results of this parser.

    Filter results of this parser.

    p

    predicate that returns true for results accepted by this parser

    returns

    a filtered parser

  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def flatMap[C](f: (B) ⇒ Parser[A, C]): Parser[A, C]

    Permalink

    Sequence with a second parsers only after this one produced a result.

    Sequence with a second parsers only after this one produced a result.

    returns

    the resulting parser

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

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

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

    Permalink
    Definition Classes
    Any
  23. final def map[C](f: (B) ⇒ C): Parser[A, C]

    Permalink

    Map the result of this parser to another result C

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

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

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

    Permalink
    Definition Classes
    AnyRef
  27. final def result(seg: Seg[A], signal: Signal): Option[Either[Fail, Done[B, A]]]

    Permalink

    Apply this parser to the last segment.

    Apply this parser to the last segment.

    seg

    the segment to parse for a new message

    signal

    the signal accompanying the last segment

    returns

    Nothing if there is no new message left. Some Fail or Done depending on if the last parse failed or succeeded.

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. def |[U >: B](alternative: ⇒ Parser[A, U]): Parser[A, U]

    Permalink

    A parser combinator for alternative composition

    A parser combinator for alternative composition

    p | q' succeeds if p' succeeds or q' succeeds Note that q' is only tried if p's failure is non-fatal (i.e., back-tracking is allowed).

    returns

    a Parser' that returns the result of the first parser to succeed (out of p' and q') The resulting parser succeeds if (and only if)

    • p' succeeds, or
    • if p' fails allowing back-tracking and q' succeeds.
  34. def ~[U](p: ⇒ Parser[A, U]): Parser[A, ~[B, U]]

    Permalink

    A parser combinator for sequential composition

    A parser combinator for sequential composition

    p ~ q' succeeds if p' succeeds and q' succeeds on the input left over by p'.

    returns

    a Parser' that -- on success -- returns a ~' (like a Pair, but easier to pattern match on) that contains the result of p' and that of q'. The resulting parser fails if either p' or q' fails.

  35. def ~>[U](p: ⇒ Parser[A, U]): Parser[A, U]

    Permalink

    A parser combinator for sequential composition which keeps only the right result

    A parser combinator for sequential composition which keeps only the right result

    p ~> q' succeeds if p' succeeds and q' succeeds on the input left over by p'.

    returns

    a Parser' that -- on success -- returns the result of q'.

Inherited from AnyRef

Inherited from Any

Ungrouped