This typeclass specifies how an error generated by a parser should be
formatted. An instance of this trait is required when calling parse
(or similar). By default, Parsley defines its own instance for
ErrorBuilder[String]
found in the ErrorBuilder companion object.
This typeclass specifies how an error generated by a parser should be
formatted. An instance of this trait is required when calling parse
(or similar). By default, Parsley defines its own instance for
ErrorBuilder[String]
found in the ErrorBuilder companion object.
To implement this trait, you will need to define a number of methods
as well as decide on the representation types for a variety of different
components. The relation between the various methods is closely linked
to the types that they both produce and consume. If you only want to change
the basics of formatting without having to define the entire instance, you
can inherit from DefaultErrorBuilder
, but this will lock in your
implementation types (type aliases cannot be overriden in Scala).
- Type Params
- Err
The final result type of the error message
- Since
3.0.0
- Companion
- object
Type members
Types
The representation type of the main body within the error message
The representation type of the main body within the error message
- Since
3.0.0
The representation of all the different possible tokens that could have prevented an error.
The representation of all the different possible tokens that could have prevented an error.
The representation of the information regarding the solving tokens.
The representation of the information regarding the solving tokens.
- Since
3.0.0
The base type of Raw
, Named
and EndOfInput
that
represents the individual items within the error.
The base type of Raw
, Named
and EndOfInput
that
represents the individual items within the error.
- Since
3.0.0
The representation of the line of input where the error occurred.
The representation of the line of input where the error occurred.
- Since
3.0.0
The representation of a reason or a message generated by the parser.
The representation of a reason or a message generated by the parser.
- Since
3.0.0
The representation of the combined reasons or failure messages from the parser.
The representation of the combined reasons or failure messages from the parser.
This represents "named" tokens, which have been provided with a label.
This represents "named" tokens, which have been provided with a label.
- Since
3.0.0
The representation type of position information within the generated message
The representation type of position information within the generated message
- Since
3.0.0
This represents "raw" tokens, where are those without labels: i.e. they come direct from the input, or the characters that the parser is trying to read.
This represents "raw" tokens, where are those without labels: i.e. they come direct from the input, or the characters that the parser is trying to read.
- Since
3.0.0
The representation of the file information
The representation of the file information
- Since
3.0.0
The representation of the information regarding the problematic token.
The representation of the information regarding the problematic token.
- Since
3.0.0
Value members
Abstract methods
Details how to combine the various expected items into a single representation.
Details how to combine the various expected items into a single representation.
- Value Params
- alts
The possible items that fix the error
- Since
3.0.0
Details how to combine any reasons or messages generated within a
single error. Reasons are used by vanilla
messages and messages
are used by specialised
messages.
Details how to combine any reasons or messages generated within a
single error. Reasons are used by vanilla
messages and messages
are used by specialised
messages.
- Value Params
- alts
The messages to combine (see the
[[message]]
or[[reason]]
methods)
- Since
3.0.0
Describes how to handle the information about the tokens that could have avoided the error.
Describes how to handle the information about the tokens that could have avoided the error.
- Value Params
- alts
The tokens that could have prevented the error (see the
[[combineExpectedItems]]
method)
- Since
3.0.0
This is the top level function, which finally compiles all the formatted
sub-parts into a finished value of type Err
.
This is the top level function, which finally compiles all the formatted
sub-parts into a finished value of type Err
.
- Value Params
- lines
This is the main body of the error message (see
[[vanillaError]]
or[[specialisedError]]
methods)- pos
This is the representation of the position of the error in the input (see the
[[pos]]
method)- source
This is the representation of the filename (if it exists) (see the
[[source]]
method)
- Returns
The final assembled error message
- Since
3.0.0
Describes how to format the information about the line that the error occured on.
Describes how to format the information about the line that the error occured on.
- Value Params
- errorPointsAt
The offset into the line that the error points at
- line
The full line of input that produced this error message
- linesAfter
The lines of input just after the one that produced this message (up to
[[numLinesAfter]]
)- linesBefore
The lines of input just before the one that produced this message (up to
[[numLinesBefore]]
)
- Since
3.1.0
Describes how to represent the messages produced by the
fail
combinator (or any that are implemented using it).
Describes how to represent the messages produced by the
fail
combinator (or any that are implemented using it).
- Value Params
- msg
The message produced by the parser
- Since
3.0.0
Formats a named item generated by a label.
Formats a named item generated by a label.
- Value Params
- item
The name given to the label
- Since
3.0.0
Formats a position into the representation type given by Position
.
Formats a position into the representation type given by Position
.
- Value Params
- col
The column the error occurred at
- line
The line the error occurred at
- Returns
A representation of the position
- Since
3.0.0
Formats a raw item generated by either the input string or a input reading combinator without a label.
Formats a raw item generated by either the input string or a input reading combinator without a label.
- Value Params
- item
The raw, unprocessed input
- Since
3.0.0
Describes how to represent the reasons behind a parser fail.
These reasons originate from the explain
combinator.
Describes how to represent the reasons behind a parser fail.
These reasons originate from the explain
combinator.
- Value Params
- reason
The reason produced by the parser
- Since
3.0.0
Formats the name of the file if it exists into the type give by Source
Formats the name of the file if it exists into the type give by Source
- Value Params
- sourceName
The source name of the file, if any
- Since
3.0.0
Specialised errors are triggered by fail
and any combinators that are
implemented in terms of fail
. These errors take precedence over
the vanilla errors, and contain less, more specialised, information
Specialised errors are triggered by fail
and any combinators that are
implemented in terms of fail
. These errors take precedence over
the vanilla errors, and contain less, more specialised, information
- Value Params
- line
Representation of the line of input that this error occured on (see the
[[lineInfo]]
method)- msgs
Information detailing the error (see the
[[combineMessages]]
method)
- Since
3.0.0
Describes how to handle the (potentially missing) information about what token(s) caused the error.
Describes how to handle the (potentially missing) information about what token(s) caused the error.
- Value Params
- item
The
Item
that caused this error
- Since
3.0.0
Vanilla errors are those produced such that they have information about
both expected
and unexpected
tokens. These are usually the default,
and are not produced by fail
(or any derivative) combinators.
Vanilla errors are those produced such that they have information about
both expected
and unexpected
tokens. These are usually the default,
and are not produced by fail
(or any derivative) combinators.
- Value Params
- expected
Information about which token(s) would have avoided the error (see the
[[expected]]
method)- line
Representation of the line of input that this error occured on (see the
[[lineInfo]]
method)- reasons
Additional information about why the error occured (see the
[[combineMessages]]
method)- unexpected
Information about which token(s) caused the error (see the
[[unexpected]]
method)
- Since
3.0.0
Abstract fields
Value that represents the end of the input in the error message.
Value that represents the end of the input in the error message.
- Since
3.0.0
The number of lines of input to request after an error occured
The number of lines of input to request after an error occured
- Since
3.1.0