Packages

o

io.dylemma.spac.impl

ParserDrain

object ParserDrain extends Stateless[Any, Unit]

Source
ParserDrain.scala
Linear Supertypes
Stateless[Any, Unit], Handler[Any, Unit], Parser[Any, Unit], AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. ParserDrain
  2. Stateless
  3. Handler
  4. Parser
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def asTopLevelHandler(caller: SpacTraceElement): Handler[Any, Unit]

    Wraps this handler as a "top level" handler, which will inject a SpacTraceElement (representing the current input or the "EOF" signal) to any exception is thrown by this handler when calling its step or finish methods.

    Wraps this handler as a "top level" handler, which will inject a SpacTraceElement (representing the current input or the "EOF" signal) to any exception is thrown by this handler when calling its step or finish methods.

    Used internally by Parser's parse methods.

    Definition Classes
    Handler
  6. def asTransformer: Transformer[Any, Unit]

    Represent this parser as a Transformer which emits this parser's result

    Represent this parser as a Transformer which emits this parser's result

    Definition Classes
    Parser
  7. def attempt: Parser[Any, Either[Throwable, Unit]]

    Like wrapSafe, but represents exceptions as Left and successful results as Right

    Like wrapSafe, but represents exceptions as Left and successful results as Right

    Definition Classes
    Parser
  8. def beforeContext[I2 <: Any, StackElem](matcher: ContextMatcher[StackElem, Any])(implicit stackable: StackLike[I2, StackElem], pos: CallerPos): Parser[I2, Unit]

    Specialization of interruptedBy for stack-like input types, such that an interruption will occur upon entering a stack context that can be matched by the given matcher.

    Specialization of interruptedBy for stack-like input types, such that an interruption will occur upon entering a stack context that can be matched by the given matcher.

    Example:

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

    Subtype of In, or just In (to satisfy contravariance of Parser's In type)

    StackElem

    Specialization of the In type for when it represents a stack push or pop

    matcher

    A matching function that operates on a context stack

    stackable

    Interprets the inputs as stack push/pop events to accumulate a context stack

    returns

    A parser which will perform an early finish() when a matching context is encountered

    Definition Classes
    Parser
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. def expectInputs[I2 <: Any](expectations: List[(String, (I2) => Boolean)]): Parser[I2, Unit]

    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

    Definition Classes
    Parser
  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  14. def finish(): Unit

    Signal the end of the data stream to this handler, forcing it to generate a result.

    Signal the end of the data stream to this handler, forcing it to generate a result. Handlers may throw exceptions in response to this, such as a handler which wants the first event from an empty stream.

    Further calls to step or finish after the first call to finish will result in undefined behavior. The general assumption is that a handler should be discarded after its finish method is called.

    returns

    the final result of this parser

    Definition Classes
    ParserDrainHandler
  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. def interruptedBy[I2 <: Any](interrupter: Parser[I2, Any]): Parser[I2, Unit]

    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 followUp 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.

    Note that if the interrupter throws an exception, that exception will not be caught. If your interrupter might throw, pass interrupter.wrapSafe instead to swallow the exception.

    I2

    Subtype of In, or just In (to satisfy contravariance of Parser's In type)

    interrupter

    A parser which will be run in parallel with this parser, and whose result will be treated as an early EOF for this parser, forcing an early call to finish().

    returns

    A parser which will perform an early finish() call when the interrupter produces a result.

    Definition Classes
    Parser
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def map[Out2](f: (Unit) => Out2): Parser[Any, Out2]

    Create a copy of this Parser whose result is transformed by the given function f.

    Create a copy of this Parser whose result is transformed by the given function f.

    Out2

    The new parser's result type

    f

    Result transformation function

    Definition Classes
    Parser
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def newHandler: ParserDrain.this.type

    Parser's main abstract method; constructs a new Handler representing this parser's logic.

    Parser's main abstract method; constructs a new Handler representing this parser's logic. Parsers are expected to be immutable, but Handlers may be internally-mutable.

    Definition Classes
    StatelessParser
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def orElse[In2 <: Any, Out2 >: Unit](fallback: Parser[In2, Out2]): Parser[In2, Out2]

    Combine this parser with the fallback such that failures from the underlying parsers will be ignored as long as at least one succeeds.

    Combine this parser with the fallback such that failures from the underlying parsers will be ignored as long as at least one succeeds. The result will be the result of whichever underlying parser succeeds first. If all of the underlying parsers fail, a SpacException.FallbackChainFailure will be thrown by the returned parser's handler.

    In2

    Subtype of In, or just In (to satisfy Parser's contravariance on the In type)

    Out2

    Supertype of Out, or just Out (to satisfy Parser's covariance on the Out type)

    fallback

    another parser of the same(ish) type as this one

    returns

    A new parser that will succeed if either this parser or the fallback succeed

    Definition Classes
    Parser
  25. def parse[S](source: S)(implicit S: Parsable[Id, S, Any], pos: CallerPos): Unit

    Interpret the given source as a data stream of type In, using this parser to produce a result of type Out.

    Interpret the given source as a data stream of type In, using this parser to produce a result of type Out. Exceptions thrown by the underlying parser logic will bubble up and be thrown by this method.

    S

    The source type. Will typically be a File or a List[In].

    source

    The source of a data stream

    S

    Typeclass instance that provides the logic for feeding values from source into this parser

    pos

    Captures the caller filename and line number, used to fill in the 'spac trace' if the parser throws an exception

    Definition Classes
    Parser
    Annotations
    @throws(scala.this.throws.<init>$default$1[io.dylemma.spac.SpacException[_]])
  26. def rethrow[T](implicit ev: <:<[Unit, Either[Throwable, T]]): Parser[Any, T]

    Like unwrapSafe, but rethrows exceptions from Left or returns results from Right.

    Like unwrapSafe, but rethrows exceptions from Left or returns results from Right. This operation is the opposite of attempt.

    Definition Classes
    Parser
  27. def step(in: Any): Right[Nothing, ParserDrain.type]

    Advance the state of this handler by accepting a single input of type In.

    Advance the state of this handler by accepting a single input of type In. If doing so would cause this parser to complete, return a Left containing the output. Otherwise, return a Right containing the next parser state.

    Handlers are assumed to be internally-mutable, so it is acceptable to simply update some internal state and then return Right(this), although in some cases it will be desirable to return a separate handler entirely.

    in

    A single input event from a data stream

    returns

    If the input would finish the parser, return a Left containing the result. Otherwise, return a Right containing a Handler which represents the next parsing state. The handler in a Right may be this handler, or a completely separate one.

    Definition Classes
    ParserDrainHandler
  28. def stepMany[C[_], In2 <: Any](inputs: C[In2])(implicit C: Unconsable[C]): Either[(Unit, C[In2]), Handler[Any, Unit]]

    Convenience function to call step on a sequence of inputs all at once.

    Convenience function to call step on a sequence of inputs all at once. If the step returns a result, this method will return a Left containing that result and the remainder of the inputs that were not consumed. If the inputs run out before the handler returns a result from a step, this method will return a Right containing the latest state of the handler. This method will not call the handler's finish().

    In general, you won't call this method directly. Instead, use one of the Parser trait's parse methods.

    C

    An Unconsable collection, i.e. List or cats.data.Chain

    In2

    Subtype of In, or In (to satisfy contravariance)

    inputs

    A sequence of inputs

    C

    Evidence that the inputs has a head/tail split operation

    returns

    Either the handler's result paired with the remaining inputs, or the new handler state

    Definition Classes
    Handler
  29. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  30. def toPipe[F[_]](implicit pos: CallerPos): Pipe[F, Any, Unit]

    Convert this parser to a FS2 "Pipe".

    Convert this parser to a FS2 "Pipe". The resulting pipe will forward inputs from the upstream into this parser, emitting a single value to the downstream when this parser finishes. Since a Parser may abort early (e.g. with Parser.first), the pipe may not pull the entire input stream.

    Definition Classes
    Parser
  31. def toString(): String
    Definition Classes
    AnyRef → Any
  32. def unwrapSafe[T](implicit ev: <:<[Unit, Try[T]]): Parser[Any, T]

    Creates a copy of this parser which unwraps the resulting Try, throwing an exception if the result was a Failure.

    Creates a copy of this parser which unwraps the resulting Try, throwing an exception if the result was a Failure. This operation is the opposite of wrapSafe.

    Definition Classes
    Parser
  33. def upcast[Out2](implicit ev: <:<[Unit, Out2]): Parser[Any, Out2]

    Returns this parser, with the output type widened to Out2, which is some supertype of Out.

    Returns this parser, with the output type widened to Out2, which is some supertype of Out. Uses asInstanceOf rather than creating a new parser.

    Definition Classes
    Parser
  34. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  35. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  36. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  37. def withName(name: String): Parser[Any, Unit]

    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

    Definition Classes
    Parser
  38. def wrapSafe: Parser[Any, Try[Unit]]

    Create a copy of this Parser whose handler will catch NonFatal exceptions thrown by the underlying logic.

    Create a copy of this Parser whose handler will catch NonFatal exceptions thrown by the underlying logic. Caught exceptions will be yielded as a Failure output. Normal results will be wrapped in Success.

    returns

    A copy of this parser that will return a Failure instead of throwing exceptions

    Definition Classes
    Parser

Inherited from Stateless[Any, Unit]

Inherited from Handler[Any, Unit]

Inherited from Parser[Any, Unit]

Inherited from AnyRef

Inherited from Any

Abstract Members

Consumer Methods

Transformation / Combinator Methods

Ungrouped