Parser

sbt.internal.util.complete.Parser
See theParser companion trait
object Parser extends ParserMain

Contains Parser implementation helper methods not typically needed for using parsers.

Attributes

Companion
trait
Graph
Supertypes
trait ParserMain
class Object
trait Matchable
class Any
Self type
Parser.type

Members list

Type members

Classlikes

final class Failure extends Result[Nothing]

Attributes

Supertypes
class Result[Nothing]
class Object
trait Matchable
class Any
sealed abstract class Result[+T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Failure
class Value[T]
final case class Value[+T](value: T) extends Result[T]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Result[T]
class Object
trait Matchable
class Any
Show all

Inherited classlikes

object ~

See unapply.

See unapply.

Attributes

Inherited from:
ParserMain
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def and[T](a: Parser[T], b: Parser[_]): Parser[T]
def bindParser[A, B](a: Parser[A], f: A => Parser[B]): Parser[B]
def choiceParser[A, B](a: Parser[A], b: Parser[B]): Parser[Either[A, B]]
def filterParser[T](a: Parser[T], f: T => Boolean, seen: String, msg: String => String): Parser[T]
def mapParser[A, B](a: Parser[A], f: A => B): Parser[B]
def mkFailure(error: => String, definitive: Boolean): Failure
def mkFailures(errors: => Seq[String], definitive: Boolean): Failure
def onFailure[T](delegate: Parser[T], msg: String): Parser[T]
def oneOrMore[T](p: Parser[T]): Parser[Seq[T]]
def opt[T](a: Parser[T]): Parser[Option[T]]
def repeat[T](p: Parser[T], min: Int, max: UpperBound): Parser[Seq[T]]
def seqParser[A, B](a: Parser[A], b: Parser[B]): Parser[(A, B)]
def trapAndFail[T](delegate: Parser[T]): Parser[T]
def tuple[A, B](a: Option[A], b: Option[B]): Option[(A, B)]
def zeroOrMore[T](p: Parser[T]): Parser[Seq[T]]

Inherited methods

def apply[T](p: Parser[T])(s: String): Parser[T]

Applies parser p to input s.

Applies parser p to input s.

Attributes

Inherited from:
ParserMain
def charClass(f: Char => Boolean, label: String): Parser[Char]

Defines a Parser that parses a single character only if the predicate f returns true for that character. If this parser fails, label is used as the failure message.

Defines a Parser that parses a single character only if the predicate f returns true for that character. If this parser fails, label is used as the failure message.

Attributes

Inherited from:
ParserMain
def chars(legal: String): Parser[Char]

Defines a Parser that parses a single character only if it is contained in legal.

Defines a Parser that parses a single character only if it is contained in legal.

Attributes

Inherited from:
ParserMain
def completions(p: Parser[_], s: String, level: Int): Completions

Applies parser p to input s and returns the completions at verbosity level. The interpretation of level is up to parser definitions, but 0 is the default by convention, with increasing positive numbers corresponding to increasing verbosity. Typically no more than a few levels are defined.

Applies parser p to input s and returns the completions at verbosity level. The interpretation of level is up to parser definitions, but 0 is the default by convention, with increasing positive numbers corresponding to increasing verbosity. Typically no more than a few levels are defined.

Attributes

Inherited from:
ParserMain
def derive1[T](p: Parser[T], c: Char): Parser[T]

Applies parser p to a single character of input.

Applies parser p to a single character of input.

Attributes

Inherited from:
ParserMain
def examples[A](a: Parser[A], completions: ExampleSource, maxNumberOfExamples: Int, removeInvalidExamples: Boolean): Parser[A]

Type parameters

A

the type of values that are returned by the parser.

Value parameters

a

the parser to decorate with a source of examples. All validation and parsing is delegated to this parser, only Parser.completions is modified.

completions

the source of examples when displaying completions to the user.

maxNumberOfExamples

limits the number of examples that the source of examples should return. This can prevent lengthy pauses and avoids bad interactive user experience.

removeInvalidExamples

indicates whether completion examples should be checked for validity (against the given parser). An exception is thrown if the example source contains no valid completion suggestions.

Attributes

Inherited from:
ParserMain
def examples[A](a: Parser[A], completions: Set[String], check: Boolean): Parser[A]

Attributes

Inherited from:
ParserMain
def failure(msg: => String, definitive: Boolean): Parser[Nothing]

Defines a parser that always fails on any input with message msg. If definitive is true, any failures by later alternatives are discarded.

Defines a parser that always fails on any input with message msg. If definitive is true, any failures by later alternatives are discarded.

Attributes

Inherited from:
ParserMain
def homParser[A](a: Parser[A], b: Parser[A]): Parser[A]

Attributes

Inherited from:
ParserMain
def invalid(msgs: => Seq[String], definitive: Boolean): Parser[Nothing]

Defines a parser that always fails on any input with messages msgs. If definitive is true, any failures by later alternatives are discarded.

Defines a parser that always fails on any input with messages msgs. If definitive is true, any failures by later alternatives are discarded.

Attributes

Inherited from:
ParserMain
def matched(t: Parser[_], seen: Vector[Char], partial: Boolean): Parser[String]

Attributes

Inherited from:
ParserMain
def not(p: Parser[_], failMessage: String): Parser[Unit]

Attributes

Inherited from:
ParserMain
def oneOf[T](p: Seq[Parser[T]]): Parser[T]

Attributes

Inherited from:
ParserMain
def parse[T](str: String, parser: Parser[T]): Either[String, T]

Parses input str using parser. If successful, the result is provided wrapped in Right. If unsuccessful, an error message is provided in Left.

Parses input str using parser. If successful, the result is provided wrapped in Right. If unsuccessful, an error message is provided in Left.

Attributes

Inherited from:
ParserMain
def range(r: NumericRange[Char], label: String): Parser[Char]

Presents a Char range as a Parser. A single Char is parsed only if it is in the given range.

Presents a Char range as a Parser. A single Char is parsed only if it is in the given range.

Attributes

Inherited from:
ParserMain
def result[T](p: Parser[T], s: String): Either[() => (Seq[String], Int), T]

Attributes

Inherited from:
ParserMain
def sample(str: String, parser: Parser[_], completions: Boolean): Unit

Convenience method to use when developing a parser. parser is applied to the input str. If completions is true, the available completions for the input are displayed. Otherwise, the result of parsing is printed using the result's toString method. If parsing fails, the error message is displayed.

Convenience method to use when developing a parser. parser is applied to the input str. If completions is true, the available completions for the input are displayed. Otherwise, the result of parsing is printed using the result's toString method. If parsing fails, the error message is displayed.

See also sampleParse and sampleCompletions.

Attributes

Inherited from:
ParserMain
def sampleCompletions(str: String, parser: Parser[_], level: Int): Unit

Convenience method to use when developing a parser. parser is applied to the input str and the available completions are displayed on separate lines. If parsing fails, the error message is displayed.

Convenience method to use when developing a parser. parser is applied to the input str and the available completions are displayed on separate lines. If parsing fails, the error message is displayed.

Attributes

Inherited from:
ParserMain
def sampleParse(str: String, parser: Parser[_]): Unit

Convenience method to use when developing a parser. parser is applied to the input str and the result of parsing is printed using the result's toString method. If parsing fails, the error message is displayed.

Convenience method to use when developing a parser. parser is applied to the input str and the result of parsing is printed using the result's toString method. If parsing fails, the error message is displayed.

Attributes

Inherited from:
ParserMain
def seq[T](p: Seq[Parser[T]]): Parser[Seq[T]]

Attributes

Inherited from:
ParserMain
def seq0[T](p: Seq[Parser[T]], errors: => Seq[String]): Parser[Seq[T]]

Attributes

Inherited from:
ParserMain
def stringLiteral(s: String, start: Int): Parser[String]

Attributes

Inherited from:
ParserMain
def success[T](value: T): Parser[T]

Defines a parser that always succeeds on empty input with the result value.

Defines a parser that always succeeds on empty input with the result value.

Attributes

Inherited from:
ParserMain
def token[T](t: Parser[T], complete: TokenCompletions): Parser[T]

Attributes

Inherited from:
ParserMain
def token[T](t: Parser[T], description: String): Parser[T]

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, description is displayed for suggestions and no completions are ever performed.

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, description is displayed for suggestions and no completions are ever performed.

Attributes

Inherited from:
ParserMain
def token[T](t: Parser[T], hide: Int => Boolean): Parser[T]

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, no completions are returned if hide returns true for the current tab completion level. Otherwise, the completions provided by the delegate t or a later derivative are appended to the prefix String already seen by this parser.

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, no completions are returned if hide returns true for the current tab completion level. Otherwise, the completions provided by the delegate t or a later derivative are appended to the prefix String already seen by this parser.

Attributes

Inherited from:
ParserMain
def token[T](t: Parser[T]): Parser[T]

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, the completions provided by the delegate t or a later derivative are appended to the prefix String already seen by this parser.

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, the completions provided by the delegate t or a later derivative are appended to the prefix String already seen by this parser.

Attributes

Inherited from:
ParserMain
def tokenDisplay[T](t: Parser[T], display: String): Parser[T]

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, display is used as the printed suggestion, but the completions from the delegate parser t are used to complete if unambiguous.

Establishes delegate parser t as a single token of tab completion. When tab completion of part of this token is requested, display is used as the printed suggestion, but the completions from the delegate parser t are used to complete if unambiguous.

Attributes

Inherited from:
ParserMain

Extensions

Inherited extensions

extension (s: String)
def *(n: Int): String

Attributes

Inherited from:
ParserMain

Implicits

Inherited implicits

implicit def literal(s: String): Parser[String]

Presents a literal String s as a Parser that only parses that exact text and provides it as the result.

Presents a literal String s as a Parser that only parses that exact text and provides it as the result.

Attributes

Inherited from:
ParserMain
implicit def literal(ch: Char): Parser[Char]

Presents a single Char ch as a Parser that only parses that exact character.

Presents a single Char ch as a Parser that only parses that exact character.

Attributes

Inherited from:
ParserMain
implicit def literalRichCharParser(c: Char): RichParser[Char]

Attributes

Inherited from:
ParserMain
implicit def literalRichStringParser(s: String): RichParser[String]

Attributes

Inherited from:
ParserMain
implicit def range(r: NumericRange[Char]): Parser[Char]

Presents a Char range as a Parser. A single Char is parsed only if it is in the given range.

Presents a Char range as a Parser. A single Char is parsed only if it is in the given range.

Attributes

Inherited from:
ParserMain
implicit def richParser[A](a: Parser[A]): RichParser[A]

Provides combinators for Parsers.

Provides combinators for Parsers.

Attributes

Inherited from:
ParserMain