io.dylemma.spac

Parser

trait Parser[-In, +Out] extends HandlerFactory[In, Out]

An immutable object that can be used to create Handlers.

Self Type
Parser[In, Out]
Source
Parser.scala
Linear Supertypes
HandlerFactory[In, Out], (Any) ⇒ HandlerFactory[In, Out], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Parser
  2. HandlerFactory
  3. Function1
  4. AnyRef
  5. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def makeHandler(): Handler[In, Out]

    Definition Classes
    HandlerFactory

Concrete Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (Parser[In, Out], B)

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to ArrowAssoc[Parser[In, Out]] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def and[O2](other: Parser[In, O2]): Combined2[Out, O2]

    [use case]

    [use case]
    O2

    The output type of the other Parser

    other

    Another Parser to combine with

    returns

    An intermediate oject with as and asTuple methods that finish the combination

    Full Signature

    def and[I2 <: In, O2](other: Parser[I2, O2]): Combined2[Out, O2]

  9. def andThen[A](g: (HandlerFactory[In, Out]) ⇒ A): (Any) ⇒ A

    Definition Classes
    Function1
    Annotations
    @unspecialized()
  10. def apply(v1: Any): HandlerFactory[In, Out]

    Always returns this, so that this can be passed to Splitter#through

    Always returns this, so that this can be passed to Splitter#through

    Definition Classes
    HandlerFactory → Function1
  11. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  12. def beforeContext[I2 <: In, StackElem](matcher: ContextMatcher[StackElem, Any])(implicit stackable: Aux[I2, StackElem]): Parser[I2, Out]

    Create a copy of this parser that will observe an early EOF upon entering a context matched by the given matcher.

    Create a copy of this parser that will observe an early EOF upon entering a context matched by the given matcher. This is especially useful for creating followedBy chains involving optional elements.

    Normally, a parser for an optional item in some context will not finish until that context ends, or until the item is encountered. So if the item is not present, followedBy logic won't work since the following parser/transformer will not see any events.

    To make sure the leading parser can "fail fast", you can force it to end early if it encounters a specific context, i.e. the context used by the parser/transformer being passed to .follwedBy.

    Example:

    val preludeContext = * \ "prelude"
    val dataContext = * \ "data"
    
    for {
      prelude <- Splitter(preludeContext).firstOption[Prelude].beforeContext(dataContext).followedByStream
      data <- Splitter(dataContext).as[Data]
    } yield data
    matcher
    returns

  13. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. def compose[A](g: (A) ⇒ Any): (A) ⇒ HandlerFactory[In, Out]

    Definition Classes
    Function1
    Annotations
    @unspecialized()
  15. def ensuring(cond: (Parser[In, Out]) ⇒ Boolean, msg: ⇒ Any): Parser[In, Out]

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to Ensuring[Parser[In, Out]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: (Parser[In, Out]) ⇒ Boolean): Parser[In, Out]

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to Ensuring[Parser[In, Out]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: Boolean, msg: ⇒ Any): Parser[In, Out]

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to Ensuring[Parser[In, Out]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. def ensuring(cond: Boolean): Parser[In, Out]

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to Ensuring[Parser[In, Out]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  19. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  21. def expectInputs[I2 <: In](expectations: List[(String, (I2) ⇒ Boolean)]): Parser[I2, Out]

    Impose expectations on the sequence of inputs to be received by handlers created by this parser.

    Impose expectations on the sequence of inputs to be received by handlers created by this parser. As this parser's handler receives an input, the input will be tested against the head of the expectations list. If the test returns false, the expectation is failed and the handler will throw an exception. If the test returns true, the expectation is satisfied, and the handler will advance to the next expectation. If there are no more expectations left in the list (i.e. N inputs have satisfied the corresponding N expectations), then all expectations have been met and inputs will be treated as normal by the handler. If the handler receives an EOF before all expectations are met, it will throw an exception.

    expectations

    A sequence of label -> test expectations imposed on inputs to this parser

    returns

    A copy of this parser with expectations imposed on its inputs

  22. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. def followedBy: FollowedBy[In, Out, Parser]

    Intermediate object for creating a sequence parser in which the result of this parser will be used to initialize a second parser as soon as it is available.

    Intermediate object for creating a sequence parser in which the result of this parser will be used to initialize a second parser as soon as it is available.

    In other words, the source (series of In values) will be fed into this Parser until this parser's handler returns a result of type Out. At that point, the second parser (as specified by using the apply or flatMap methods on the FollowedBy returned by this method) will be instantiated. Any relevent "stack events" (see Stackable) will be replayed so the second parser has the right context, and from that point on, all In values will be sent to the second parser. When that second parser returns a result, that result becomes the output of the combined parser created by this.followedBy(out => makeSecondParser(out))

    Examples:

    val p1: Parser[A] = /* ... */	  *    def getP2(p1Result: A): Parser[B] = /* ... */	  *    val combined: Parser[B] = p1.followedBy(getP2)
    
    // alternative `flatMap` syntax
    val combined: Parser[B] = for {
      p1Result <- p1.followedBy
      p2Result <- getP2(p1Result)
    } yield p2Result

    See interruptedBy, which is useful when a transformer.parseFirstOption must be followedBy some other parser.

  24. def followedByStream: FollowedBy[In, Out, Transformer]

    Intermediate object creating a transformer that depends on this parser.

    Intermediate object creating a transformer that depends on this parser. Particularly useful in cases where one or more specific "info" elements precede a stream of other elements which require that "info" to be parsed.

    Examples:

    val p1: Parser[In, A] = /* ... */	  *    def getP2Stream(p1Result: A): Transformer[In, B] = /* ... */	  *    val combined: Transformer[In, B] = p1.andThenStream(getP2Stream)
    
    // alternative `flatMap` syntax
    val combined: Transformer[In, B] = for {
      p1Result <- p1.andThenStream
      p2Result <- getP2Stream(p1Result)
    } yield p2Result

    See followedBy for a general explanation of how the combination works.

    See also, interruptedBy, which is useful when a transformer.parseFirstOption must be followedBy some other transformer.

  25. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  26. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  28. def interruptedBy[I2 <: In](interrupter: Parser[I2, Any]): Parser[I2, Out]

    Create a copy of this parser that will treat a result from the interrupter as an early EOF.

    Create a copy of this parser that will treat a result from the interrupter as an early EOF. This is especially useful for creating followedBy chains involving optional elements.

    Normally, a parser for an optional item in some context will not finish until that context ends, or until the item is encountered. So if the item is not present, followedBy logic won't work since the following parser/transformer will not see any events.

    To make sure the leading parser can "fail fast", you can "interrupt" it, typically by creating a parser that immediately returns a result upon entering a particular context, i.e. the context in which the "following" parser will start. Parser#beforeContext provides a convenience for doing so.

    interrupter
    returns

  29. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  30. def map[U](f: (Out) ⇒ U): Parser[In, U]

    Transform this Parser's results using a transformation function.

    Transform this Parser's results using a transformation function.

    f

    The transformation function

    returns

    A new Parser instance which computes its results by applying f to the results computed by this Parser

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

    Definition Classes
    AnyRef
  32. final def notify(): Unit

    Definition Classes
    AnyRef
  33. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  34. def orElse[I2 <: In, B >: Out](fallback: Parser[I2, B]): Parser[I2, B]

    Combine this parser with the fallback such that if either one fails but the other succeeds, the result will be taken from the one that succeeds.

    Combine this parser with the fallback such that if either one fails but the other succeeds, the result will be taken from the one that succeeds.

    Note: if you want to have a chain of fallbacks, it will be more efficient to do Parser.oneOf(p1, p2, p3, ...) than doing p1 orElse p2 orElse p3 orElse ....

    B
    fallback
    returns

  35. def parse[S](source: S)(implicit consume: ConsumableLike[S, In]): Out

    Parse the given source object by spawning a handler and feeding events from the source into that handler until it yields a result.

    Parse the given source object by spawning a handler and feeding events from the source into that handler until it yields a result.

    S

    The source object type

    source

    An object that can be treated as a stream of In events

    consume

    Typeclass instance allowing instances of Src to be treated as a stream of In events

    returns

    The parse result

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

    Definition Classes
    AnyRef
  37. def toString(): String

    Definition Classes
    Function1 → AnyRef → Any
  38. def unwrapSafe[T](implicit ev: <:<[Out, Try[T]]): Parser[In, T]

    Given a parser whose output type is a Try[T], return a new parser which will unwrap the Try, returning either the underlying T for Success, or throwing the caught exception for Failure.

    Given a parser whose output type is a Try[T], return a new parser which will unwrap the Try, returning either the underlying T for Success, or throwing the caught exception for Failure. This operation is the opposite of wrapSafe.

    T

    The unwrapped type

    ev

    Evidence that this parser's output type is a Try[T] for some type T

    returns

    A parser that unwraps the Try returned by this parser

  39. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. def withName(name: String): Parser[In, Out]

    Creates a copy of this parser, but with a different toString

    Creates a copy of this parser, but with a different toString

    name

    The new "name" (i.e. toString) for this parser

    returns

    A copy of this parser whose toString returns the given name

  43. def wrapSafe: Parser[In, Try[Out]]

    Create a new parser to wrap this one, such that any exception thrown during parsing will be caught and returned as a Failure.

    Create a new parser to wrap this one, such that any exception thrown during parsing will be caught and returned as a Failure.

    returns

    A parser that will return a Failure instead of throwing an exception

  44. def ~[O2](other: Parser[In, O2]): Combined2[Out, O2]

    [use case]

    [use case]
    O2

    other

    returns

    Full Signature

    def ~[I2 <: In, O2](other: Parser[I2, O2]): Combined2[Out, O2]

  45. def [B](y: B): (Parser[In, Out], B)

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to ArrowAssoc[Parser[In, Out]] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (parser: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (parser: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: Parser[In, Out]

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to ArrowAssoc[Parser[In, Out]] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (parser: ArrowAssoc[Parser[In, Out]]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: Parser[In, Out]

    Implicit information
    This member is added by an implicit conversion from Parser[In, Out] to Ensuring[Parser[In, Out]] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (parser: Ensuring[Parser[In, Out]]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from HandlerFactory[In, Out]

Inherited from (Any) ⇒ HandlerFactory[In, Out]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Parser[In, Out] to StringAdd

Inherited by implicit conversion any2stringfmt from Parser[In, Out] to StringFormat

Inherited by implicit conversion any2ArrowAssoc from Parser[In, Out] to ArrowAssoc[Parser[In, Out]]

Inherited by implicit conversion any2Ensuring from Parser[In, Out] to Ensuring[Parser[In, Out]]

Ungrouped