Handler

io.dylemma.spac.impl.ParserInterruptedBy.Handler
class Handler[In, Out](var main: Handler[In, Out], var interrupter: Handler[In, Any]) extends Handler[In, Out]

Attributes

Graph
Supertypes
trait Handler[In, Out]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def finish(): Out

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.

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.

Attributes

Returns

the final result of this parser

def step(in: In): Either[Out, Handler[In, Out]]

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.

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.

Value parameters

in

A single input event from a data stream

Attributes

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.

Inherited methods

def asTopLevelHandler(caller: SpacTraceElement): Handler[In, Out]

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.

Attributes

Inherited from:
Handler
def stepMany[C[_], In2 <: In](inputs: C[In2])(implicit C: Unconsable[C]): Either[(Out, C[In2]), Handler[In, Out]]

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().

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.

Type parameters

C

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

In2

Subtype of In, or In (to satisfy contravariance)

Value parameters

C

Evidence that the inputs has a head/tail split operation

inputs

A sequence of inputs

Attributes

Returns

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

Inherited from:
Handler