ExpressionMatcher

com.phasmidsoftware.number.expression.expr.ExpressionMatchers.ExpressionMatcher
abstract class ExpressionMatcher[+R] extends Matcher[Expression, R]

Abstract class ExpressionMatcher, which extends Matcher where the input type is always Expression.

Type parameters

R

the underlying type of MatchResults.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Inherited methods

def ![S >: R](s: => S): Matchers.this.Matcher[Expression, S]

Defines a Matcher which reverses the sense of this Matcher.

Defines a Matcher which reverses the sense of this Matcher.

Type parameters

S

the type of both s and the result (a super-type of R).

Value parameters

s

the default result value, only to be used in the even of a Miss.

Attributes

Returns

a Matcher[T, R] that works in the opposite sense to this.

Inherited from:
Matcher
def &[S](m: Matchers.this.Matcher[R, S]): Matchers.this.Matcher[Expression, S]

Method to combine Matchers in the sense that, when this successfully matches a T, resulting in an R, then m is invoked on the result, such that if it is successful, we return an S.

Method to combine Matchers in the sense that, when this successfully matches a T, resulting in an R, then m is invoked on the result, such that if it is successful, we return an S.

Type parameters

S

the underlying type of the resulting Matcher.

Value parameters

m

the alternative Matcher.

Attributes

Returns

a Matcher[T, S] that will match in composition on both this and m.

Inherited from:
Matcher
def <~[P, S](m: Matchers.this.Matcher[P, S]): Matchers.this.Matcher[Expression ~ P, R]

Method to combine Matchers this and m such that the resulting Matcher takes a ~ and returns the result from this. The resulting Matcher is named "<~"

Method to combine Matchers this and m such that the resulting Matcher takes a ~ and returns the result from this. The resulting Matcher is named "<~"

Type parameters

P

the input type of m.

S

the result type of m.

Value parameters

m

a Matcher[P, S]

Attributes

Returns

a Matcher[(T, P), R] that is the result of invoking ~ but stripping the second element of the ~.

Inherited from:
Matcher
def ?: Matchers.this.Matcher[Expression, Option[R]]

Defines a Matcher that optionally matches what this Matcher matches. Essentially a synonym for method opt.

Defines a Matcher that optionally matches what this Matcher matches. Essentially a synonym for method opt.

Attributes

Returns

opt(this)

Inherited from:
Matcher
def ^^[S](f: R => S): Matchers.this.Matcher[Expression, S]

Method to transform a MatchResult with a function f.

Method to transform a MatchResult with a function f.

The matcher p ^^ f: succeeds if p succeeds; The resulting match will be the result of applying function f to the result of invoking p.

Value parameters

f

a function that will be applied to this matcher's result (see method map in MatchResult).

Attributes

Returns

a parser that has the same behavior as the current matcher, but whose result is transformed by f.

Inherited from:
Matcher
def andThen[A](g: ExpressionMatchers.this.MatchResult[R] => A): Expression => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
def chain[Q, U](m: Matchers.this.Matcher[(Q, R), U]): Matchers.this.Matcher[(Q, Expression), U]

CONSIDER maybe doesn't make sense (compare with valve).

CONSIDER maybe doesn't make sense (compare with valve).

Matcher which succeeds or not, depending on an additional Q value (the control).

Type parameters

Q

the type of the control value.

U

the result type of m and the returned Matcher.

Value parameters

m

a Matcher[(Q, R),U].

Attributes

Returns

a Matcher[(Q,T),U].

Inherited from:
Matcher
def compose[A](g: A => Expression): A => ExpressionMatchers.this.MatchResult[R]

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
def flatMap[U <: Expression, S](f: R => Matchers.this.MatchResult[S]): Matchers.this.Matcher[U, S]

Map method that transforms this Matcher[T, R] into a Matcher[U, S].

Map method that transforms this Matcher[T, R] into a Matcher[U, S].

Type parameters

S

the result type for the resulting Matcher.

U

the input type for the resulting Matcher (U is a subtype of T).

Value parameters

f

a function R => S.

Attributes

Returns

a Matcher[T, S].

Inherited from:
Matcher
def map[U <: Expression, S](f: R => S): Matchers.this.Matcher[U, S]

Map method that transforms this Matcher[T, R] into a Matcher[T, S].

Map method that transforms this Matcher[T, R] into a Matcher[T, S].

Type parameters

S

the result type for the resulting Matcher.

U

the input type for the resulting Matcher (U is a subtype of T).

Value parameters

f

a function R => S.

Attributes

Returns

a Matcher[U, S].

Inherited from:
Matcher
def named(n: String): Matchers.this.Matcher[Expression, R]

Method to create a new (equivalent) Matcher to this, but with a different (given) name.

Method to create a new (equivalent) Matcher to this, but with a different (given) name.

Value parameters

n

the name of the resulting Matcher.

Attributes

Returns

a Matcher[T, R] that behaves the same as this, but which is identified by n.

Inherited from:
Matcher
override def toString: String

Returns a string representation of the Matcher instance.

Returns a string representation of the Matcher instance.

Attributes

Returns

the name of the Matcher.

Definition Classes
Matcher -> Function1 -> Any
Inherited from:
Matcher
def trial: Matchers.this.Matcher[Expression, Try[R]]

Matcher which always succeeds (unless this causes an Error) but whose result is based on a Try[R]. CONSIDER there are similarities between this and the valve method, as well as between this and the matchTryFunc method. TESTME more

Matcher which always succeeds (unless this causes an Error) but whose result is based on a Try[R]. CONSIDER there are similarities between this and the valve method, as well as between this and the matchTryFunc method. TESTME more

Attributes

Returns

Matcher[T, Try of R]

Inherited from:
Matcher
def unit[S](s: S): Matchers.this.Matcher[Expression, S]

Unit method that yields a Matcher

Unit method that yields a Matcher

Type parameters

S

the result type for the resulting Matcher.

Value parameters

s

the instance of type S that will be wrapped in Match for the result of the resulting Matcher.

Attributes

Returns

a Matcher[T, S].

Inherited from:
Matcher
def |[U <: Expression, S >: R](m: Matchers.this.Matcher[U, S]): Matchers.this.Matcher[U, S]

Method to combine Matchers in the sense that, if this fails, then we try to match using m. In other words, this defines an alternation matcher.

Method to combine Matchers in the sense that, if this fails, then we try to match using m. In other words, this defines an alternation matcher.

NOTE: changed the logic to avoid using match2Any because it is unnecessarily convoluted.

NOTE: if equals is not properly implemented for type T, it is possible to get into an infinite recursion. This is actually Issue #14.

NOTE: self-referential matchers via | will cause a StackOverflowError; no lightweight fix is known

Value parameters

m

the alternative Matcher.

Attributes

Returns

a Matcher[T, R] that will match either on this or on m.

Inherited from:
Matcher
def ~[P, S](m: Matchers.this.Matcher[P, S]): Matchers.this.Matcher[Expression ~ P, R ~ S]

Method to combine Matchers this and m such that the resulting Matcher takes a ~ and results in a ~. The result is named "~"

Method to combine Matchers this and m such that the resulting Matcher takes a ~ and results in a ~. The result is named "~"

Type parameters

P

the input type of m.

S

the result type of m.

Value parameters

m

a Matcher[P, S]

Attributes

Returns

a Matcher[T ~ P, R ~ S] that is the result of invoking match2All(this, m).

Inherited from:
Matcher
def ~>[P, S](m: Matchers.this.Matcher[P, S]): Matchers.this.Matcher[Expression ~ P, S]

Method to combine Matchers this and m such that the resulting Matcher takes a ~ and returns the result from m. The resulting Matcher is named "~>"

Method to combine Matchers this and m such that the resulting Matcher takes a ~ and returns the result from m. The resulting Matcher is named "~>"

Type parameters

P

the input type of m.

S

the result type of m.

Value parameters

m

a Matcher[P, S]

Attributes

Returns

a Matcher[(T, P), S] that is the result of invoking ~ but stripping the first element of the ~.

Inherited from:
Matcher

Inherited and Abstract methods

Applies the body of this function to the argument.

Applies the body of this function to the argument.

Value parameters

v1

the function argument

Attributes

Returns

the result of function application.

Inherited from:
Function1

Inherited fields

protected val name: String

A protected field representing the name of the Matcher. It provides a string identifier for the specific Matcher instance. This value is immutable and cannot be modified after initialization.

A protected field representing the name of the Matcher. It provides a string identifier for the specific Matcher instance. This value is immutable and cannot be modified after initialization.

Attributes

Inherited from:
Matcher