Handler

class Handler[In, Out](pending: Array[(Int, Handler[In, Any])], var numPending: Int, finished: Map[Int, Any], assemble: (Int => Any) => Out, callerPos: CallerPos) extends Handler[In, Out]
trait Handler[In, Out]
class Object
trait Matchable
class Any

Value members

Concrete methods

def finish(): Out
def inspect: IndexedSeq[Either[Any, Handler[In, Any]]]

For debug/testing purposes, this combines the unfinished and finished collections in an array with each entry at its corresponding index, representing unfinished parsers as Rights and finished results as Lefts. Also, since Applicative / product builds things up from right to left, the parsers at the "end" end up having the lowest number indexes, so we reverse the output so each parser/result is located at the index corresponding to that parser's position in the source that constructed this parser.

For debug/testing purposes, this combines the unfinished and finished collections in an array with each entry at its corresponding index, representing unfinished parsers as Rights and finished results as Lefts. Also, since Applicative / product builds things up from right to left, the parsers at the "end" end up having the lowest number indexes, so we reverse the output so each parser/result is located at the index corresponding to that parser's position in the source that constructed this parser.

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

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

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.

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

Returns:

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

Inherited from:
Handler