sealed trait Parser[+Err, -In, +Result] extends AnyRef
A Parser consumes a stream of 'In's and either fails with a ParserError possibly holding a custom error of type
'Err' or succeeds with a result of type Result
Parsers can be combined with Printers to get Syntax, or a Parser and a Printer can be built simultaneously by using the combinators of Syntax.
Recursive parsers can be expressed directly by recursing in one of the zipping or or-else combinators.
By default a parser backtracks automatically. This behavior can be changed with the 'manualBacktracking' operator.
Parsers trees get optimized automatically before running the parser. This optimized tree can be examined by the 'optimized' field. For the full list of transformations performed in the optimization phase check each parser node's 'optimizeNode' method.
- Err
Custom error type
- In
Element type of the input stream of parsing
- Result
The type of the parsed result value
- Self Type
- Parser[Err, In, Result]
- Alphabetic
- By Inheritance
- Parser
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def needsBacktrack: Boolean
- Attributes
- protected
- abstract def optimizeNode(state: OptimizerState): Parser[Err, In, Result]
- Attributes
- protected
- abstract def parseRec(state: ParserState): Result
- Attributes
- protected
- abstract def stripNode(state: OptimizerState): Parser[Err, In, Result]
- Attributes
- protected
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def *: Parser[Err, In, Chunk[Result]]
Symbolic alias for repeat0
- final def +: Parser[Err, In, Chunk[Result]]
Symbolic alias for repeat
- final def <+>[Err2 >: Err, In2 <: In, Result2](that: => Parser[Err2, In2, Result2]): Parser[Err2, In2, Either[Result, Result2]]
Symbolic alias for orElseEither
- final def <>[Err2 >: Err, In2 <: In, Result2 >: Result](that: => Parser[Err2, In2, Result2]): Parser[Err2, In2, Result2]
Symbolic alias for orElse
- final def <~[Err2 >: Err, In2 <: In, Result2](that: => Parser[Err2, In2, Unit]): Parser[Err2, In2, Result]
Symbolic alias for zipLeft
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ?: Parser[Err, In, Option[Result]]
Symbolic alias for optional
- final def ??(name: String): Parser[Err, In, Result]
Symbolic alias for named
- final def as[Result2](result: Result2): Parser[Err, In, Result2]
Ignores the parser's successful result and result in 'result' instead
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def atLeast(min: Int): Parser[Err, In, Chunk[Result]]
Repeats this parser at least 'min' times.
Repeats this parser at least 'min' times.
The result is all the parsed elements until the first failure. The failure that stops the repetition gets swallowed and in case auto-backtracking is on, the parser backtracks to the end of the last successful item.
- final def autoBacktracking: Parser[Err, In, Result]
Enables auto-backtracking for this parser
- final def backtrack: Parser[Err, In, Result]
Parser that resets the parsing position in case it fails.
Parser that resets the parsing position in case it fails.
By default backtracking points are automatically inserted. This behavior can be changed with the autoBacktracking, manualBacktracking and setAutoBacktracking combinators.
- final def between[Err2 >: Err, In2 <: In](left: Parser[Err2, In2, Any], right: Parser[Err2, In2, Any]): Parser[Err2, In2, Result]
Concatenates the parsers 'left', then this, then 'right'.
Concatenates the parsers 'left', then this, then 'right'.
All three must succeed. The result is this parser's result.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- lazy val compiledOpStack: InitialParser
- lazy val defaultImplementation: ParserImplementation
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def filter[Result2, Err2 >: Err](condition: (Result2) => Boolean, failure: Err2)(implicit ev: <:<[Result, Result2]): Parser[Err2, In, Result2]
Checks the result of this parser with the given function.
Checks the result of this parser with the given function. If the 'condition' is false, fails with the given failure 'failure', otherwise results in the this parser's result.
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def flatMap[Err2 >: Err, In2 <: In, Result2](that: (Result) => Parser[Err2, In2, Result2]): Parser[Err2, In2, Result2]
Determines the continuation of the parser by the result of this parser, expressed by the function 'that'
- final def flatten(implicit ev2: <:<[Result, Chunk[String]]): Parser[Err, In, String]
Flattens a result of parsed strings to a single string
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def manualBacktracking: Parser[Err, In, Result]
Turns off auto-backtracking for this parser
- final def map[Result2](to: (Result) => Result2): Parser[Err, In, Result2]
Maps the parser's successful result with the given function 'to'
- final def mapError[Err2](f: (Err) => Err2): Parser[Err2, In, Result]
Maps the error with the given function 'f'
- final def named(name: String): Parser[Err, In, Result]
Associates a name with this parser.
Associates a name with this parser. The chain of named parsers are reported in case of failure to help debugging parser issues.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def not[Err2 >: Err](failure: => Err2): Parser[Err2, In, Unit]
Parser that fails with the given 'failure' if this parser succeeds
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- lazy val optimized: Parser[Err, In, Result]
The optimized parser tree used by the parser implementations
- final def optional: Parser[Err, In, Option[Result]]
Make this parser optional.
Make this parser optional.
Failure of this parser will be ignored. In case auto-backtracking is enabled, backtracking is performed on it.
- final def orElse[Err2 >: Err, In2 <: In, Result2 >: Result](that: => Parser[Err2, In2, Result2]): Parser[Err2, In2, Result2]
Assigns 'that' parser as a fallback of this.
Assigns 'that' parser as a fallback of this. First this parser gets evaluated. In case it succeeds, the result is this parser's result. In case it fails, the result is 'that' parser's result.
If auto-backtracking is on, this parser will backtrack before trying 'that' parser.
- final def orElseEither[Err2 >: Err, In2 <: In, Result2](that: => Parser[Err2, In2, Result2]): Parser[Err2, In2, Either[Result, Result2]]
Assigns 'that' parser as a fallback of this.
Assigns 'that' parser as a fallback of this. First this parser gets evaluated. In case it succeeds, the result is this parser's result wrapped in 'Left'. In case it fails, the result is 'that' parser's result, wrapped in 'Right'.
Compared to orElse, this version allows the two parsers to have different result types.
If auto-backtracking is on, this parser will backtrack before trying 'that' parser.
- final def parseChars(input: Chunk[Char], parserImplementation: ParserImplementation)(implicit ev: <:<[Char, In]): Either[ParserError[Err], Result]
Run this parser on the given 'input' chunk of characters using a specific parser implementation
- final def parseChars(input: Chunk[Char])(implicit ev: <:<[Char, In]): Either[ParserError[Err], Result]
Run this parser on the given 'input' chunk of characters
- final def parseString(input: String, parserImplementation: ParserImplementation)(implicit ev: <:<[Char, In]): Either[ParserError[Err], Result]
Run this parser on the given 'input' string using a specific parser implementation
- final def parseString(input: String)(implicit ev: <:<[Char, In]): Either[ParserError[Err], Result]
Run this parser on the given 'input' string
- final def repeat: Parser[Err, In, Chunk[Result]]
Repeats this parser at least once.
Repeats this parser at least once.
The result is all the parsed elements until the first failure. The failure that stops the repetition gets swallowed and in case auto-backtracking is on, the parser backtracks to the end of the last successful item.
- final def repeat0: Parser[Err, In, Chunk[Result]]
Repeats this parser zero or more times.
Repeats this parser zero or more times.
The result is all the parsed elements until the first failure. The failure that stops the repetition gets swallowed and in case auto-backtracking is on, the parser backtracks to the end of the last successful item.
- final def repeatUntil[Err2 >: Err, In2 <: In](stopCondition: Parser[Err2, In2, Any]): Parser[Err2, In2, Chunk[Result]]
Repeats this parser until the given
stopCondition
parser succeeds. - final def repeatWithSep[Err2 >: Err, In2 <: In](sep: Parser[Err2, In2, Unit]): Parser[Err2, In2, Chunk[Result]]
Repeats this parser at least once and requires that between each element, the 'sep' parser succeeds
- final def repeatWithSep0[Err2 >: Err, In2 <: In](sep: Parser[Err2, In2, Unit]): Parser[Err2, In2, Chunk[Result]]
Repeats this parser zero or more times and requires that between each element, the 'sep' parser succeeds
- def runOptimizeNode(optimizerState: OptimizerState): Parser[Err, In, Result]
- Attributes
- protected
- def runStripNode(stripState: OptimizerState): Parser[Err, In, Result]
- Attributes
- protected
- final def setAutoBacktracking(enabled: Boolean): Parser[Err, In, Result]
Enables or disables auto-backtracking for this parser
- final def string(implicit ev: <:<[Char, In]): Parser[Err, Char, String]
Ignores this parser's result and instead capture the parsed string fragment
- def strip: Parser[Err, In, Result]
Strips all the name information from this parser to improve performance but reduces the failure message's verbosity.
- final def surroundedBy[Err2 >: Err, In2 <: In](other: Parser[Err2, In2, Any]): Parser[Err2, In2, Result]
Surrounds this parser with the 'other' parser.
Surrounds this parser with the 'other' parser. The result is this parser's result.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def transformEither[Err2, Result2](to: (Result) => Either[Err2, Result2]): Parser[Err2, In, Result2]
Maps the parser's successful result with the given function 'to' that either fails or produces a new result value.
- final def transformOption[Result2](to: (Result) => Option[Result2]): Parser[Option[Err], In, Result2]
Maps the parser's successful result with the given function 'to' that either produces a new result value or the failure is indicated in the error channel by the value None.
- final def unit: Parser[Err, In, Unit]
Parser that does not consume any input and produces the unit value
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def zip[Err2 >: Err, In2 <: In, Result2, ZippedResult](that: => Parser[Err2, In2, Result2])(implicit zippable: Out[Result, Result2, ZippedResult]): Parser[Err2, In2, ZippedResult]
Concatenates this parser with 'that' parser.
Concatenates this parser with 'that' parser. In case both parser succeeds, the result is a pair of the results.
- final def zipLeft[Err2 >: Err, In2 <: In, Result2](that: => Parser[Err2, In2, Any]): Parser[Err2, In2, Result]
Concatenates this parser with 'that' parser.
Concatenates this parser with 'that' parser. In case both parser succeeds, the result is the result of this parser. Otherwise the parser fails.
- final def |[Err2 >: Err, In2 <: In, Result2 >: Result](that: => Parser[Err2, In2, Result2]): Parser[Err2, In2, Result2]
Symbolic alias for orElse
- final def ~[Err2 >: Err, In2 <: In, Result2, ZippedResult](that: => Parser[Err2, In2, Result2])(implicit zippable: Out[Result, Result2, ZippedResult]): Parser[Err2, In2, ZippedResult]
Symbolic alias for zip