implicit final class VerifiedErrors[P, A] extends AnyRef
This class exposes combinators related to the Verified Errors parser design pattern.
This extension class operates on values that are convertible to parsers. The combinators it enables allow for the parsing of known illegal values, providing richer error messages in case they succeed.
- P
the type of base value that this class is used on (the conversion to
Parsley
) is summoned automatically.
- Source
- patterns.scala
- Since
4.2.0
- Alphabetic
- By Inheritance
- VerifiedErrors
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new VerifiedErrors(p: P)(implicit con: (P) => Parsley[A])
This constructor should not be called manually, it is designed to be used via Scala's implicit resolution.
This constructor should not be called manually, it is designed to be used via Scala's implicit resolution.
- p
the value that this class is enabling methods on.
- con
a conversion that allows values convertible to parsers to be used.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- 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 ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def verifiedExplain(reason: (A) => String): Parsley[Nothing]
Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a reason generated from this parser's result.
Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a reason generated from this parser's result.
If this parser succeeds, input is consumed and this combinator will fail, producing an unexpected message the same width as the parse along with a reason generated from the successful parse. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.
- reason
a function that produces a reason for the error given the parsed result.
- Since
4.5.0
- Note
when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if
,amend
had been used) and the caret will span the entire successful parse of this parser.when this parser is not to be considered as a terminal error, use
atomic
around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).
- def verifiedExplain(reason: String): Parsley[Nothing]
Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a given reason.
Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a given reason.
If this parser succeeds, input is consumed and this combinator will fail, producing an unexpected message the same width as the parse along with the given reason. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.
- reason
the reason that this parser is illegal.
- Since
4.5.0
- Note
when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if
,amend
had been used) and the caret will span the entire successful parse of this parser.when this parser is not to be considered as a terminal error, use
atomic
around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).
- def verifiedFail(msg0: String, msgs: String*): Parsley[Nothing]
Ensures this parser does not succeed, failing with a specialised error if it does.
Ensures this parser does not succeed, failing with a specialised error if it does.
If this parser succeeds, input is consumed and this combinator will fail, producing an error message based on the given messages. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.
- msg0
the first message in the error message.
- msgs
the remaining messages that will make up the error message.
- Since
4.2.0
- Note
when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if
,amend
had been used) and the caret will span the entire successful parse of this parser.when this parser is not to be considered as a terminal error, use
atomic
around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).
- def verifiedFail(msggen: (A) => Seq[String]): Parsley[Nothing]
Ensures this parser does not succeed, failing with a specialised error based on this parsers result if it does.
Ensures this parser does not succeed, failing with a specialised error based on this parsers result if it does.
If this parser succeeds, input is consumed and this combinator will fail, producing an error message based on the parsed result. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.
- msggen
the function that generates the error messages from the parsed value.
- Since
4.2.0
- Note
when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if
,amend
had been used) and the caret will span the entire successful parse of this parser.when this parser is not to be considered as a terminal error, use
atomic
around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).
- def verifiedUnexpected: Parsley[Nothing]
Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse.
Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse.
If this parser succeeds, input is consumed and this combinator will fail, producing an unexpected message the same width as the parse. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.
- Since
4.2.0
- Note
when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if
,amend
had been used) and the caret will span the entire successful parse of this parser.when this parser is not to be considered as a terminal error, use
atomic
around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).
- def verifiedWith(err: ErrorGen[A]): Parsley[Nothing]
Ensures this parser does not succeed, failing with an error as described by the given
ErrorGen
object.Ensures this parser does not succeed, failing with an error as described by the given
ErrorGen
object.If this parser succeeds, input is consumed and this combinator will fail, producing an error message using the given
errGen
with width the same as the parsed data. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.- err
the generator that produces the error message.
- Since
4.4.0
- Note
when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if
,amend
had been used) and the caret will span the entire successful parse of this parser.when this parser is not to be considered as a terminal error, use
atomic
around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).
- 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()
This is the documentation for Parsley.
Package structure
The parsley package contains the
Parsley
class, as well as theResult
,Success
, andFailure
types. In addition to these, it also contains the following packages and "modules" (a module is defined as being an object which mocks a package):parsley.Parsley
contains the bulk of the core "function-style" combinators.parsley.combinator
contains many helpful combinators that simplify some common parser patterns.parsley.character
contains the combinators needed to read characters and strings, as well as combinators to match specific sub-sets of characters.parsley.debug
contains debugging combinators, helpful for identifying faults in parsers.parsley.expr
contains the following sub modules:parsley.expr.chain
contains combinators used in expression parsingparsley.expr.precedence
is a builder for expression parsers built on a precedence table.parsley.expr.infix
contains combinators used in expression parsing, but with more permissive types than their equivalents inchain
.parsley.expr.mixed
contains combinators that can be used for expression parsing, but where different fixities may be mixed on the same level: this is rare in practice.parsley.syntax
contains several implicits to add syntactic sugar to the combinators. These are sub-categorised into the following sub modules:parsley.syntax.character
contains implicits to allow you to use character and string literals as parsers.parsley.syntax.lift
enables postfix application of the lift combinator onto a function (or value).parsley.syntax.zipped
enables boths a reversed form of lift where the function appears on the right and is applied on a tuple (useful when type inference has failed) as well as a.zipped
method for building tuples out of several combinators.parsley.syntax.extension
contains syntactic sugar combinators exposed as implicit classes.parsley.errors
contains modules to deal with error messages, their refinement and generation.parsley.errors.combinator
provides combinators that can be used to either produce more detailed errors as well as refine existing errors.parsley.errors.tokenextractors
provides mixins for common token extraction strategies during error message generation: these can be used to avoid implementingunexpectedToken
in theErrorBuilder
.parsley.lift
contains functions which lift functions that work on regular types to those which now combine the results of parsers returning those same types. these are ubiquitous.parsley.ap
contains functions which allow for the application of a parser returning a function to several parsers returning each of the argument types.parsley.state
contains combinators that interact with the context-sensitive functionality in the form of state.parsley.token
contains theLexer
class that provides a host of helpful lexing combinators when provided with the description of a language.parsley.position
contains parsers for extracting position information.parsley.generic
contains some basic implementations of the Parser Bridge pattern (see Design Patterns for Parser Combinators in Scala, or the parsley wiki): these can be used before more specialised generic bridge traits can be constructed.