Rule

trait Rule[-In, +Out, +A, +X] extends In => Result[Out, A, X]

A Rule is a function from some input to a Result. The result may be:

A Rule is a function from some input to a Result. The result may be:

  • Success, with a value of some type and an output that may serve as the input to subsequent rules.

  • Failure. A failure may result in some alternative rule being applied.

  • Error. No further rules should be attempted.

Authors

Andrew Foggin Inspired by the Scala parser combinator.

trait In => Result[Out, A, X]
class Object
trait Matchable
class Any
trait Choice[In, Out, A, X]
class DefaultRule[In, Out, A, X]

Value members

Concrete methods

def !^[Y](fx2y: X => Y): Rule[In, Out, A, Y]

Maps an Error

Maps an Error

def -[In2 <: In](exclude: => Rule[In2, Any, Any, Any]): Rule[In2, Out, A, X]
def -^[B](b: B): Rule[In, Out, B, X]
def -~[Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]): Rule[In, Out2, B, X2]
def -~![Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]): Rule[In, Out2, B, Any]
def <~:[InPrev, B, X2 >: X](prev: => Rule[InPrev, In, A => B, X2]): Rule[InPrev, Out, B, X2]

Apply the result of this rule to the function returned by the previous rule

Apply the result of this rule to the function returned by the previous rule

def >->[Out2, B, X2 >: X](fa2resultb: A => Result[Out2, B, X2]): Rule[In, Out2, B, X2]
def >>[Out2, B, X2 >: X](fa2ruleb: A => Out => Result[Out2, B, X2]): Rule[In, Out2, B, X2]
def >>&[B, X2 >: X](fa2ruleb: A => Out => Result[Any, B, X2]): Rule[In, Out, B, X2]
def >>?[Out2, B, X2 >: X](pf: PartialFunction[A, Rule[Out, Out2, B, X2]]): Rule[In, Out2, B, X2]
def >~>[Out2, B1, B2, B >: A, C, X2 >: X](f: (B1, B2) => Out => Result[Out2, C, X2])(A: A => B1 ~ B2): Rule[In, Out2, C, X2]

~>(f) is equivalent to >> { case b1 ~ b2 => f(b1, b2) }

def ??(pf: PartialFunction[A, Any]): Rule[In, Out, A, X]
def ^-^[B1, B2 >: A, C](f: (B1, B2) => C): Rule[In, Out, B1 => C, X]

^-^(f) is equivalent to ^^ { b2 => b1 => f(b1, b2) }

^-^(f) is equivalent to ^^ { b2 => b1 => f(b1, b2) }

def ^^[B](fa2b: A => B): Rule[In, Out, B, X]
def ^^?[B](pf: PartialFunction[A, B]): Rule[In, Out, B, X]
def ^~>~^[B1, B2, B3, B >: A, C](f: (B1, B2, B3) => C)(A: A => B2 ~ B3): Rule[In, Out, B1 => C, X]

^~>~^(f) is equivalent to ^^ { case b2 ~ b3 => b1 => f(b1, b2, b3) }

^~>~^(f) is equivalent to ^^ { case b2 ~ b3 => b1 => f(b1, b2, b3) }

def ^~^[B1, B2, B >: A, C](f: (B1, B2) => C)(A: A => B1 ~ B2): Rule[In, Out, C, X]

^~^(f) is equivalent to ^^ { case b1 ~ b2 => f(b1, b2) }

^~^(f) is equivalent to ^^ { case b1 ~ b2 => f(b1, b2) }

def ^~~^[B1, B2, B3, B >: A, C](f: (B1, B2, B3) => C)(A: A => B1 ~ B2 ~ B3): Rule[In, Out, C, X]

^~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 => f(b1, b2, b3) }

^~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 => f(b1, b2, b3) }

def ^~~~^[B1, B2, B3, B4, B >: A, C](f: (B1, B2, B3, B4) => C)(A: A => B1 ~ B2 ~ B3 ~ B4): Rule[In, Out, C, X]

^~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 => f(b1, b2, b3, b4) }

^~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 => f(b1, b2, b3, b4) }

def ^~~~~^[B1, B2, B3, B4, B5, B >: A, C](f: (B1, B2, B3, B4, B5) => C)(A: A => B1 ~ B2 ~ B3 ~ B4 ~ B5): Rule[In, Out, C, X]

^~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 => f(b1, b2, b3, b4, b5) }

^~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 => f(b1, b2, b3, b4, b5) }

def ^~~~~~^[B1, B2, B3, B4, B5, B6, B >: A, C](f: (B1, B2, B3, B4, B5, B6) => C)(A: A => B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6): Rule[In, Out, C, X]

^~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) }

^~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) }

def ^~~~~~~^[B1, B2, B3, B4, B5, B6, B7, B >: A, C](f: (B1, B2, B3, B4, B5, B6, B7) => C)(A: A => B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6 ~ B7): Rule[In, Out, C, X]

^~~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) }

^~~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) }

def as(name: String): Rule[In, Out, A, X] & Name
def filter(f: A => Boolean): Rule[In, Out, A, X]
def flatMap[Out2, B, X2 >: X](fa2ruleb: A => Out => Result[Out2, B, X2]): Rule[In, Out2, B, X2]
def map[B](fa2b: A => B): Rule[In, Out, B, X]
def mapResult[Out2, B, Y](f: Result[Out, A, X] => Result[Out2, B, Y]): Rule[In, Out2, B, Y]
def orElse[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other: => Rule[In2, Out2, A2, X2]): Rule[In2, Out2, A2, X2]
def orError[In2 <: In]: Rule[In, Out, A, Any]
def |[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other: => Rule[In2, Out2, A2, X2]): Rule[In2, Out2, A2, X2]
def ~[Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]): Rule[In, Out2, A ~ B, X2]
def ~![Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]): Rule[In, Out2, A ~ B, Any]
def ~++[Out2, B >: A, X2 >: X](next: => Rule[Out, Out2, Seq[B], X2]): Rule[In, Out2, List[B], X2]
def ~-[Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]): Rule[In, Out2, A, X2]
def ~-![Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]): Rule[In, Out2, A, Any]
def ~>[Out2, B, X2 >: X](next: => Rule[Out, Out2, A => B, X2]): Rule[In, Out2, B, X2]

Apply the result of this rule to the function returned by the next rule

Apply the result of this rule to the function returned by the next rule

Inherited methods

@unspecialized
def andThen[A](g: Result[Out, A, X] => A): In => A
Inherited from
Function1
def apply(v1: In): Result[Out, A, X]
Inherited from
Function1
@unspecialized
def compose[A](g: A => In): A => Result[Out, A, X]
Inherited from
Function1
override def toString(): String
Definition Classes
Function1 -> Any
Inherited from
Function1

Abstract fields