Extractor

name.rayrobdod.stringContextParserCombinator.Extractor
See theExtractor companion object
final class Extractor[Expr[_], Type[_], -A]

Parses an interpolated string expression into some extractor

Type parameters

A

the type of the parsed result

Expr

the macro-level expression type

Type

the macro-level type type

Attributes

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

Members list

Grouped members

parse

final def extract(sc: StringContext, scrutinee: 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

Extract subexpressions from the given value according to the given StringContext

Attributes

Source
Extractor.scala
final def extractor[UnexprA](sc: Expr[StringContext])(using Quotes, Type[UnexprA], Expr[UnexprA] <:< A, Expr[Boolean] =:= Expr[Boolean], Type[Boolean] =:= Type[Boolean]): Expr[Unapply[UnexprA]]

Parses a StringContext into an extractor

Parses a StringContext into an extractor

Attributes

Example
def valueImpl(sc:Expr[scala.StringContext])(using Quotes):Expr[Unapply[Result]] = {
 val myParser:Extractor[Expr[Result]] = ???
 myParser.extractor(sc)
}
extension (inline sc:scala.StringContext)
 inline def value:Unapply[Result] =
   ${valueImpl('sc)}
Inherited from:
VersionSpecificExtractor (hidden)
Source
VersionSpecificExtractor.scala

Result Changing Combinators

def contramap[Z](contrafn: Z => A): Extractor[Expr, Type, Z]

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

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

Attributes

Source
Extractor.scala
def void: Extractor[Expr, Type, Unit]

Returns an extractor which runs this parser but ignores the input

Returns an extractor which runs this parser but ignores the input

Approximately equivalent to this.contramap({_ => a}), where a is some value this extractor will accept, except this discards all match groups

Attributes

Source
Extractor.scala
def widenWith[Z](contrafn: PartialExprFunction[Expr, Z, A]): Extractor[Expr, Type, Z]

Returns an extractor which invokes the contrafn, then

Returns an extractor which invokes the contrafn, then

  • If the Expr is true, passes the value to this extractor
  • If the Expr is false, fails the match

Attributes

Source
Extractor.scala

Sequencing Combinators

def andThen[B, Z](rhs: Extractor[Expr, Type, B])(implicit ev: ContraSequenced[A, B, Z]): Extractor[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.

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

Branching Combinators

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

Repeating Combinators

def optionally[Z](strategy: RepeatStrategy)(implicit ev: ContraOptionally[Expr, A, Z]): Extractor[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

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
Extractor.scala
def repeat[Z](min: Int, max: Int, delimiter: Extractor[Expr, Type, Unit], strategy: RepeatStrategy)(implicit ev: ContraRepeated[Expr, A, Z]): Extractor[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

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

Error Enriching Combinators

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

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

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

Attributes

Source
Extractor.scala

Other Combinators

def attempt: Extractor[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

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

Attributes

Source
Extractor.scala
def hide: Extractor[Expr, Type, 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
Extractor.scala