Interpolator

name.rayrobdod.stringContextParserCombinator.Interpolator
See theInterpolator companion object
final class Interpolator[-Expr, +A]

Parses an interpolated string expression into some value

Type parameters

A

the type of the parsed result

Expr

the macro-level expression type.

Attributes

Companion
object
Source
Interpolator.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Grouped members

parse

def interpolate(sc: StringContext, args: Seq[Any])(implicit ev: Any <:< Expr): A

Processes an immediate string context and its arguments into a value

Processes an immediate string context and its arguments into a value

Attributes

Example
extension (sc:StringContext)
 def prefix(args:Any*):Result =
   val interpolator:Interpolator[Result] = ???
   interpolator.interpolate(sc, args)
Source
Interpolator.scala
final def interpolate(sc: Expr[StringContext], args: Expr[Seq[Any]])(using q: Quotes, ev: Expr[_] <:< Expr): A

Parses a StringContext and its arguments into a value

Parses a StringContext and its arguments into a value

Attributes

Example
extension (inline sc:StringContext)
 inline def prefix(inline args:Any*):Result =
   ${prefixImpl('sc, 'args)}
def prefixImpl(sc:Expr[StringContext], args:Expr[Seq[Any]])(using Quotes):Expr[Result] =
 val interpolator:Interpolator[Expr[Result]] = ???
 interpolator.interpolate(sc, args)
Inherited from:
VersionSpecificInterpolator (hidden)
Source
VersionSpecificInterpolator.scala

Result Changing Combinators

def map[Z](fn: A => Z): Interpolator[Expr, Z]

Returns a parser which invokes this parser, then modifies a successful result according to fn

Returns a parser which invokes this parser, then modifies a successful result according to fn

Attributes

Source
Interpolator.scala
def mapToExpr[Z >: A, Expr2[_], ToExpr[_], Type[_]](implicit mapping: ToExprMapping[Expr2, ToExpr, Type], toExpr: ToExpr[Z], tpe: Type[Z]): Interpolator[Expr, Expr2[Z]]

Returns a parser which invokes this parser, then maps a successful result by lifting the successful result into an Expr

Returns a parser which invokes this parser, then maps a successful result by lifting the successful result into an Expr

Attributes

Source
Interpolator.scala
def void: Interpolator[Expr, Unit]

Returns an interpolator which invokes this parser, then maps a successful result to the Unit value

Returns an interpolator which invokes this parser, then maps a successful result to the Unit value

Approximately equivalent to this.map({_ => ()})

Attributes

Source
Interpolator.scala

Sequencing Combinators

def <::>[ExprZ <: Expr, B >: A](rhs: Interpolator[ExprZ, List[B]]): Interpolator[ExprZ, List[B]]

Returns a parser which invokes this parser, and upon success invokes the other parser, prepending the result from this parser to the List result from the other parser

Returns a parser which invokes this parser, and upon success invokes the other parser, prepending the result from this parser to the List result from the other parser

Attributes

Since

0.1.1

Source
Interpolator.scala
def <~[ExprZ <: Expr](rhs: Interpolator[ExprZ, Unit]): Interpolator[ExprZ, A]

Returns a parser which invokes this parser, and upon success invokes the other parser, discarding the Unit result from the other parser

Returns a parser which invokes this parser, and upon success invokes the other parser, discarding the Unit result from the other parser

Attributes

Since

0.1.1

Source
Interpolator.scala
def <~>[ExprZ <: Expr, B, Z](rhs: Interpolator[ExprZ, B])(implicit ev: Sequenced[A, B, Z]): Interpolator[ExprZ, Z]

An alias for andThen

An alias for andThen

Attributes

Since

0.1.1

Source
Interpolator.scala
def andThen[ExprZ <: Expr, B, Z](rhs: Interpolator[ExprZ, B])(implicit ev: Sequenced[A, B, Z]): Interpolator[ExprZ, Z]

Returns a parser which invokes this parser, and upon success invokes the other parser.

Returns a parser which invokes this parser, and upon success invokes the other parser.

Type parameters

Z

the result parser's parsed value type

Value parameters

ev

A descriptor of how to combine two values into one value

rhs

the parser to call after this one

Attributes

Source
Interpolator.scala
def flatMap[ExprZ <: Expr, Z](fn: A => Interpolator[ExprZ, Z]): Interpolator[ExprZ, Z]

Returns a parser which invokes this parser, then modifies a successful result according to the parser returned by fn

Returns a parser which invokes this parser, then modifies a successful result according to the parser returned by fn

Attributes

Source
Interpolator.scala
def ~>[ExprZ <: Expr, B](rhs: Interpolator[ExprZ, B])(implicit ev: A <:< Unit): Interpolator[ExprZ, B]

Returns a parser which invokes this parser, and upon success invokes the other parser, discarding the Unit result from this parser

Returns a parser which invokes this parser, and upon success invokes the other parser, discarding the Unit result from this parser

Attributes

Since

0.1.1

Source
Interpolator.scala

Branching Combinators

def <+>[ExprZ <: Expr, B](rhs: Interpolator[ExprZ, B]): Interpolator[ExprZ, Either[A, B]]

Calls orElse using specifically the typeclass.Eithered.discriminatedUnion implicit evidence

Calls orElse using specifically the typeclass.Eithered.discriminatedUnion implicit evidence

Attributes

Since

0.1.1

Source
Interpolator.scala
def </>[B, Z](onFailValue: B)(implicit ev: Eithered[A, B, Z]): Interpolator[Expr, Z]

Returns an interpolator that returns the onFailValue if this parser failed without consuming input

Returns an interpolator that returns the onFailValue if this parser failed without consuming input

Attributes

Since

0.1.1

Source
Interpolator.scala
def <|>[ExprZ <: Expr, B, Z](rhs: Interpolator[ExprZ, B])(implicit ev: Eithered[A, B, Z]): Interpolator[ExprZ, Z]

An alias for orElse

An alias for orElse

Attributes

Since

0.1.1

Source
Interpolator.scala
def orElse[ExprZ <: Expr, B, Z](rhs: Interpolator[ExprZ, B])(implicit ev: Eithered[A, B, Z]): Interpolator[ExprZ, Z]

Returns a parser which invokes this parser, and then:

Returns a parser which invokes this parser, and then:

  • If this parser run succeeded, return this internal's success
  • If this parser failed and consumed input, return this parser's failure
  • If this parser failed but did not consume input, run the other parser and return the other parser's result

Type parameters

Z

the result parser's parsed value type

Value parameters

ev

A descriptor of how to treat either value as one value

rhs

the parser to call after this one

Attributes

Source
Interpolator.scala

Filtering Combinators

def filter(predicate: A => Boolean, description: String): Interpolator[Expr, A]

Returns a parser which invokes this parser, then fails a successful result if it does not pass the predicate

Returns a parser which invokes this parser, then fails a successful result if it does not pass the predicate

Attributes

Source
Interpolator.scala

Repeating Combinators

def optionally[Z](strategy: RepeatStrategy)(implicit ev: Optionally[A, Z]): Interpolator[Expr, Z]

Returns a parser which invokes this parser and provides a value whether this parser succeeded or failed

Returns a parser which invokes this parser and provides a value whether this parser succeeded or failed

Type parameters

Z

the result parser's parsed value type

Value parameters

ev

A descriptor of how to mark present or absent values

strategy

whether the optionally will attempt to match as much or as little as possible, and whether it will backtrack. Default is RepeatStrategy.Possessive

Attributes

Source
Interpolator.scala
def repeat[ExprZ <: Expr, Z](min: Int, max: Int, delimiter: Interpolator[ExprZ, Unit], strategy: RepeatStrategy)(implicit ev: Repeated[A, Z]): Interpolator[ExprZ, Z]

Returns a parser which invokes this parser repeatedly and returns the aggregated result

Returns a parser which invokes this parser repeatedly and returns the aggregated result

Type parameters

Z

the result parser's parsed value type

Value parameters

delimiter

a parser describing separators between each repeat. Defaults to a parser that always succeeds and consumes no input.

ev

A descriptor of how to combine the repeated values into one value

max

the maximum number of repeats to consume

min

the minimum number of repeats to be considered successful

strategy

whether the repeat will attempt to match as much or as little as possible, and whether it will backtrack. Default is RepeatStrategy.Possessive

Attributes

Source
Interpolator.scala

Error Enriching Combinators

def opaque(description: String): Interpolator[Expr, A]

Returns a parser which invokes this parser, but has the given description upon failure

Returns a parser which invokes this parser, but has the given description upon failure

Attributes

Source
Interpolator.scala

Other Combinators

def attempt: Interpolator[Expr, A]

Returns a parser which invokes this parser, but treats the result of a failed parse as if it does not consume input

Returns a parser which invokes this parser, but treats the result of a failed parse as if it does not consume input

Attributes

Source
Interpolator.scala
def extractorAtom[ExprZ[_], TypeZ[_], UnexprA](implicit t: TypeZ[UnexprA], ev: ExprZ[Any] <:< Expr, ev2: A <:< ExprZ[UnexprA]): Parser[ExprZ, TypeZ, ExprZ[UnexprA]]

Creates a parser that will

Creates a parser that will

  • when interpolating, act like this parser
  • when extractoring, invoke this parser and check that the extractor input is equal to the parsed value

The extractor parsing will probably fail if this parser expects to find holes.

Attributes

Source
Interpolator.scala
def hide: Interpolator[Expr, A]

Returns a parser which invokes this parser, but does not show the expected value in failure messages

Returns a parser which invokes this parser, but does not show the expected value in failure messages

Attributes

Source
Interpolator.scala