Packages

  • package root

    A library for writing custom string interpolation implementations via parser combinators

    A library for writing custom string interpolation implementations via parser combinators

    ## Entry Points

    If the string context should create an object: Create leaf parsers using the methods in the Interpolator companion object, combine and manipulate them with the methods in Interpolator, then interpolate using the final Interpolator's interpolate method.

    If the string context should create an extractor: Create leaf parsers using the methods in the Extractor companion object, combine and manipulate them with the methods in Extractor, then interpolate using the final Extractor's extractor method.

    If the string context should do both: Create leaf parsers using the methods in the Parser companion object, combine and manipulate them with the methods in Parser, then interpolate using the final Parser's interpolate and extractor methods.

    Definition Classes
    root
  • package name
    Definition Classes
    root
  • package rayrobdod
    Definition Classes
    name
  • package stringContextParserCombinator

    A library for implementing custom string interpolation implementations using Parser Combinators

    A library for implementing custom string interpolation implementations using Parser Combinators

    Definition Classes
    rayrobdod
  • package typeclass

    Implicit values used by branch combinators that allow combinations of input types to have more ergonomic return types.

    Implicit values used by branch combinators that allow combinations of input types to have more ergonomic return types.

    Each of the typeclasses defined in this package fit into a matrix, where one dimension is which type of parser the typeclass is used with and the other dimension is the method that uses an instance of the type

    method

    Covariant (Interpolator)

    Contravariant (Extractor)

    Invariant (Parser)

    andThen

    Sequenced

    ContraSequenced

    BiSequenced

    orElse

    Eithered

    ContraEithered

    BiEithered

    repeat

    Repeated

    ContraRepeated

    BiRepeated

    optionally

    Optionally

    ContraOptionally

    BiOptionally

    mapToExpr

    ToExprMapping

    N/A

    N/A

    Thus, if you are only working with interpolators, then you'll only need to work with the unprefixed typeclasses.

    Each of these traits has a companion object that defines a generic instance of the trait, and a few instances for more specific types. For instance, each typeclass includes a instance that will avoid wrapping scala.Unit values in a collection or tuple.

    Defining custom instances of these types is supported. Making custom given instances can significantly reduce the number of explicit map calls required when writing a parser, however the usual advice with given instances applies: keep types specific, or keep the scope of a given instance to the minimum viable to prevent given instances from becoming confusing.

    Definition Classes
    stringContextParserCombinator
  • CodePoint
  • Extractor
  • Interpolator
  • LiftFunction
  • ParseException
  • Parser
  • PartialExprFunction
  • RepeatStrategy
  • Unapply

final class Interpolator[-Expr, +A] extends VersionSpecificInterpolator[Expr, A]

Parses an interpolated string expression into some value

Expr

the macro-level expression type.

A

the type of the parsed result

Linear Supertypes
VersionSpecificInterpolator[Expr, A], AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Interpolator
  2. VersionSpecificInterpolator
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toany2stringadd[Interpolator[Expr, A]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Interpolator[Expr, A], B)
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toArrowAssoc[Interpolator[Expr, A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. 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

    Since

    0.1.1

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

    Since

    0.1.1

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

    Since

    0.1.1

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

    Since

    0.1.1

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

    Since

    0.1.1

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

    Since

    0.1.1

  11. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. 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.

    Z

    the result parser's parsed value type

    rhs

    the parser to call after this one

    ev

    A descriptor of how to combine two values into one value

  13. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  14. 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

  15. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  16. def ensuring(cond: (Interpolator[Expr, A]) => Boolean, msg: => Any): Interpolator[Expr, A]
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toEnsuring[Interpolator[Expr, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: (Interpolator[Expr, A]) => Boolean): Interpolator[Expr, A]
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toEnsuring[Interpolator[Expr, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. def ensuring(cond: Boolean, msg: => Any): Interpolator[Expr, A]
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toEnsuring[Interpolator[Expr, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  19. def ensuring(cond: Boolean): Interpolator[Expr, A]
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toEnsuring[Interpolator[Expr, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  22. 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 * when interpolating, act like this parser * when extractoring, invoke this parser and check that the extractor input is equal to the parsed value

    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.

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

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

  25. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  26. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  27. def hide: Interpolator[Expr, A]

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

  28. val impl: internal.Interpolator[Expr, A]
    Attributes
    protected[stringContextParserCombinator]
    Definition Classes
    Interpolator → VersionSpecificInterpolator
  29. 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

    Example:
    1. extension (sc:StringContext) def prefix(args:Any*):Result = val interpolator:Interpolator[Result] = ??? interpolator.interpolate(sc, args)

  30. final def interpolate(c: Context)(extensionClassName: String)(args: Seq[scala.reflect.macros.blackbox.Context.Expr[Any]])(implicit ev: <:<[scala.reflect.macros.blackbox.Context.Expr[_], Expr]): A

    Parses a StringContext and its arguments into a value

    Parses a StringContext and its arguments into a value

    Definition Classes
    VersionSpecificInterpolator
    Example:
    1. def valueImpl(c:Context)(args:c.Expr[Any]*):c.Expr[Result] = {
        val myParser:Interpolator[Expr[Result]] = ???
        myParser.interpolate(c)("package.ValueStringContext")(args)
      }
      
      implicit final class ValueStringContext(val sc:scala.StringContext) extends AnyVal {
        def value(args:Any*):Result = macro valueImpl
      }
      
      // alternatively
      implicit final class ValueStringContext(val sc:scala.StringContext) {
        object value {
          def apply(args:Any*):Result = macro valueImpl
        }
      }
  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. def map[Z](fn: (A) => Z): Interpolator[Expr, Z]

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

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

  34. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  35. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  36. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  37. def opaque(description: String): Interpolator[Expr, A]

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

  38. def optionally[Z](strategy: RepeatStrategy = RepeatStrategy.Possessive)(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

    Z

    the result parser's parsed value type

    strategy

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

    ev

    A descriptor of how to mark present or absent values

  39. 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: * 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

    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

    Z

    the result parser's parsed value type

    rhs

    the parser to call after this one

    ev

    A descriptor of how to treat either value as one value

  40. def repeat[ExprZ <: Expr, Z](min: Int = 0, max: Int = Integer.MAX_VALUE, delimiter: Interpolator[ExprZ, Unit] = new Interpolator[ExprZ, Unit](new internal.Pass[Id, Id]), strategy: RepeatStrategy = RepeatStrategy.Possessive)(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

    Z

    the result parser's parsed value type

    min

    the minimum number of repeats to be considered successful

    max

    the maximum number of repeats to consume

    delimiter

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

    strategy

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

    ev

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

  41. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  42. def toString(): String
    Definition Classes
    AnyRef → Any
  43. 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({_ => ()})

  44. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  45. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  46. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. 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

    Since

    0.1.1

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

  2. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toStringFormat[Interpolator[Expr, A]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

  3. def [B](y: B): (Interpolator[Expr, A], B)
    Implicit
    This member is added by an implicit conversion from Interpolator[Expr, A] toArrowAssoc[Interpolator[Expr, A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from VersionSpecificInterpolator[Expr, A]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromInterpolator[Expr, A] to any2stringadd[Interpolator[Expr, A]]

Inherited by implicit conversion StringFormat fromInterpolator[Expr, A] to StringFormat[Interpolator[Expr, A]]

Inherited by implicit conversion Ensuring fromInterpolator[Expr, A] to Ensuring[Interpolator[Expr, A]]

Inherited by implicit conversion ArrowAssoc fromInterpolator[Expr, A] to ArrowAssoc[Interpolator[Expr, A]]

parse

Ungrouped

Result Changing Combinators

Sequencing Combinators

Branching Combinators

Filtering Combinators

Repeating Combinators

Error Enriching Combinators

Other Combinators