VerifiedErrors

parsley.errors.patterns$.VerifiedErrors
final implicit class VerifiedErrors[P, A](p: P)(implicit con: P => Parsley[A])

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.

Type parameters

P

the type of base value that this class is used on (the conversion to Parsley) is summoned automatically.

Value parameters

con

a conversion that allows values convertible to parsers to be used.

p

the value that this class is enabling methods on.

Attributes

Constructor

This constructor should not be called manually, it is designed to be used via Scala's implicit resolution.

Since

4.2.0

Source
patterns.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

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.

Value parameters

msggen

the function that generates the error messages from the parsed value.

Attributes

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).

Source
patterns.scala
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.

Value parameters

msg0

the first message in the error message.

msgs

the remaining messages that will make up the error message.

Attributes

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).

Source
patterns.scala
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.

Attributes

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).

Source
patterns.scala
def verifiedUnexpected(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.

Value parameters

reason

the reason that this parser is illegal.

Attributes

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).

Source
patterns.scala
def verifiedUnexpected(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.

Value parameters

reason

a function that produces a reason for the error given the parsed result.

Attributes

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).

Source
patterns.scala
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.

Value parameters

err

the generator that produces the error message.

Attributes

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).

Source
patterns.scala