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

    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 Parser[Expr[_], Type[_], A] extends VersionSpecificParser[Expr, Type, A]

Parses an interpolated string expression into some value

Expr

the macro-level expression type

Type

the macro-level type type

A

the type of the parsed result

Linear Supertypes
VersionSpecificParser[Expr, Type, A], AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Parser
  2. VersionSpecificParser
  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 Parser[Expr, Type, A] toany2stringadd[Parser[Expr, Type, A]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Parser[Expr, Type, A], B)
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toArrowAssoc[Parser[Expr, Type, A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def andThen[B, Z](rhs: Parser[Expr, Type, B])(implicit ev: BiSequenced[A, B, Z]): Parser[Expr, Type, 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

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def attempt: Parser[Expr, Type, A]

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

  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. def contramap[Z](contrafn: (Z) => A): Extractor[Expr, Type, Z]

    Returns an extractor which invokes this extractor after mapping the input value using contrafn

  11. def ensuring(cond: (Parser[Expr, Type, A]) => Boolean, msg: => Any): Parser[Expr, Type, A]
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toEnsuring[Parser[Expr, Type, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: (Parser[Expr, Type, A]) => Boolean): Parser[Expr, Type, A]
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toEnsuring[Parser[Expr, Type, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean, msg: => Any): Parser[Expr, Type, A]
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toEnsuring[Parser[Expr, Type, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean): Parser[Expr, Type, A]
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toEnsuring[Parser[Expr, Type, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. def extract(sc: StringContext, value: A)(implicit ev: =:=[Id[Any], Expr[Any]], ev2: =:=[ClassTag[Any], Type[Any]]): Option[Seq[Any]]

    Extract subexpressions from the given value according to the given StringContext

  18. final def extractor[UnexprA](c: Context)(extensionClassName: String)(value: scala.reflect.macros.blackbox.Context.Expr[UnexprA])(implicit ev: <:<[scala.reflect.macros.blackbox.Context.Expr[UnexprA], A], ev2: =:=[scala.reflect.macros.blackbox.Context.Expr[_], Expr[_]], ev3: =:=[scala.reflect.macros.blackbox.Context.TypeTag[_], Type[_]], ttUnexprA: scala.reflect.macros.blackbox.Context.TypeTag[UnexprA]): scala.reflect.macros.blackbox.Context.Expr[Any]

    Build an extractor that will extract values from a value of type A based on the provided StringContext

    Build an extractor that will extract values from a value of type A based on the provided StringContext

    Definition Classes
    VersionSpecificParser
  19. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  20. def flatMap[ExprZ <: Expr[Any], Z](cofn: (A) => Interpolator[ExprZ, Z]): Interpolator[ExprZ, Z]

  21. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  22. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. def hide: Parser[Expr, Type, A]

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

  24. def imap[Z](cofn: (A) => Z, contrafn: (Z) => A): Parser[Expr, Type, Z]

  25. val impl: internal.Parser[Expr, Type, A]
    Attributes
    protected[stringContextParserCombinator]
    Definition Classes
    Parser → VersionSpecificParser
  26. def interpolate(sc: StringContext, args: List[Any])(implicit ev: <:<[Any, Expr[Any]]): A

    Processes an immediate string context and its arguments into a value

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

    Parses a StringContext and its arguments into a value

    Parses a StringContext and its arguments into a value

    Definition Classes
    VersionSpecificParser
    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
        }
      }
  28. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  29. def map[Z](cofn: (A) => Z): Interpolator[Expr[Any], Z]

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

  30. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  31. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  32. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. def opaque(description: String): Parser[Expr, Type, A]

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

  34. def optionally[Z](strategy: RepeatStrategy = RepeatStrategy.Possessive)(implicit ev: BiOptionally[Expr, A, Z]): Parser[Expr, Type, 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

  35. def orElse[B, Z](rhs: Parser[Expr, Type, B])(implicit ev: BiEithered[Expr, A, B, Z]): Parser[Expr, Type, 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

  36. def repeat[Z](min: Int = 0, max: Int = Integer.MAX_VALUE, delimiter: Parser[Expr, Type, Unit] = new Parser[Expr, Type, Unit](new internal.Pass), strategy: RepeatStrategy = RepeatStrategy.Possessive)(implicit ev: BiRepeated[Expr, A, Z]): Parser[Expr, Type, 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

  37. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  38. def toExtractor: Extractor[Expr, Type, A]

    Returns an Extractor that builds an extractor like this parser would

  39. def toInterpolator: Interpolator[Expr[Any], A]

    Returns an Interpolator that interpolates like this parser would

  40. def toString(): String
    Definition Classes
    AnyRef → Any
  41. def void: Parser[Expr, Type, Unit]

    Returns a parser which discards its result while interpolating and ignores its input value while extracting

  42. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  43. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  44. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  45. def widenWith[Z](cofn: (A) => Z, contrafn: PartialExprFunction[Expr, Z, A]): Parser[Expr, Type, Z]

    Returns an parser which is the pair of an Interpolator#map and an Extractor#widenWith

Deprecated Value Members

  1. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toStringFormat[Parser[Expr, Type, 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.

  2. def [B](y: B): (Parser[Expr, Type, A], B)
    Implicit
    This member is added by an implicit conversion from Parser[Expr, Type, A] toArrowAssoc[Parser[Expr, Type, 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 VersionSpecificParser[Expr, Type, A]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromParser[Expr, Type, A] to any2stringadd[Parser[Expr, Type, A]]

Inherited by implicit conversion StringFormat fromParser[Expr, Type, A] to StringFormat[Parser[Expr, Type, A]]

Inherited by implicit conversion Ensuring fromParser[Expr, Type, A] to Ensuring[Parser[Expr, Type, A]]

Inherited by implicit conversion ArrowAssoc fromParser[Expr, Type, A] to ArrowAssoc[Parser[Expr, Type, A]]

parse

Ungrouped

Result Changing Combinators

Sequencing Combinators

Branching Combinators

Repeating Combinators

Error Enriching Combinators

Other Combinators

convert