StateRules

trait StateRules

A factory for rules that apply to a particular context.

A factory for rules that apply to a particular context.

Authors

Andrew Foggin Inspired by the Scala parser combinator.

class Object
trait Matchable
class Any

Type members

Types

type Rule[+A, +X] = Rule[S, S, A, X]
type S

Value members

Concrete methods

def allOf[A, X](rules: Seq[Rule[A, X]]): S => Result[S, List[A], X]

Create a rule that succeeds if all of the given rules succeed.

Create a rule that succeeds if all of the given rules succeed.

Value Params
rules

the rules to apply in sequence.

def anyOf[A, X](rules: Seq[Rule[A, X]]): Rule[S, S, List[A], X]

Create a rule that succeeds with a list of all the provided rules that succeed.

Create a rule that succeeds with a list of all the provided rules that succeed.

Value Params
rules

the rules to apply in sequence.

def apply[A, X](f: S => Result[S, A, X]): Rule[S, S, A, X]
def cond(f: S => Boolean): Rule[S, S, S, Nothing]

Create a rule that identities if f(in) is true.

Create a rule that identities if f(in) is true.

def get: Rule[S, S, S, Nothing]
def nil: Rule[S, S, Nil, Nothing]
def none: Rule[S, S, None, Nothing]
def read[A](f: S => A): Rule[S, S, A, Nothing]
def repeatUntil[T, X](rule: Rule[T => T, X])(finished: T => Boolean)(initial: T): Rule[S, S, T, X]

Repeatedly apply a rule from initial value until finished condition is met.

Repeatedly apply a rule from initial value until finished condition is met.

def set(s: => S): Rule[S, S, S, Nothing]
def unit[A](a: => A): Rule[S, S, A, Nothing]
def update(f: S => S): Rule[S, S, S, Nothing]

Abstract fields