This class us used to build Parsley's default error messages.
While it compiles with the ErrorBuilder
typeclass, it should not be considered a stable contract: the formatting can be changed at any time and without notice. The API, however, will remain stable.
Attributes
- Since
-
3.0.0
- Note
-
this class is abstract as it does not implement
unexpectedToken
: when creating an instance mix-in an appropriate token extractor fromparsley.errors.tokenextractors
. - Companion
- object
- Source
- DefaultErrorBuilder.scala
- Graph
-
- Supertypes
Members list
Grouped members
item
Extracts an unexpected token from the remaining input.
Extracts an unexpected token from the remaining input.
When a parser fails, by default an error reports an unexpected token of a specific width. This works well for some parsers, but often it is nice to have the illusion of a dedicated lexing pass: instead of reporting the next few characters as unexpected, an unexpected token can be reported instead. This can take many forms, for instance trimming the token to the next whitespace, only taking one character, or even trying to lex a token out of the stream.
This method can be easily implemented by mixing in an appropriate token extractor from parsley.errors.tokenextractors
into this builder.
Value parameters
- amountOfInputParserWanted
-
the input the parser tried to read when it failed (this is not guaranteed to be smaller than the length of
cs
, but is guaranteed to be greater than 0) - cs
-
the remaining input at point of failure (this is guaranteed to be non-empty)
- lexicalError
-
was this error generated as part of "lexing", or in a wider parser (see
markAsToken
)
Attributes
- Returns
-
a token extracted from
cs
that will be used as part of the unexpected message. - Since
-
4.0.0
- Inherited from:
- ErrorBuilder
- Source
- ErrorBuilder.scala
Type members
Types
Represents the end of the input.
The representation type of the main body within the error message.
The representation type of the main body within the error message.
Attributes
- Source
- DefaultErrorBuilder.scala
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.
Attributes
- Source
- DefaultErrorBuilder.scala
The representation of the information regarding the solving tokens.
The representation of the information regarding the solving tokens.
Attributes
- Source
- DefaultErrorBuilder.scala
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.
Attributes
- Source
- DefaultErrorBuilder.scala
The representation of the line of input where the error occurred.
The representation of the line of input where the error occurred.
Attributes
- Source
- DefaultErrorBuilder.scala
The representation of a reason or a message generated by the parser.
The representation of a reason or a message generated by the parser.
Attributes
- Source
- DefaultErrorBuilder.scala
The representation of the combined reasons or failure messages from the parser.
The representation of the combined reasons or failure messages from the parser.
Attributes
- Source
- DefaultErrorBuilder.scala
This represents "named" tokens, which have been provided with a label.
This represents "named" tokens, which have been provided with a label.
Attributes
- Source
- DefaultErrorBuilder.scala
The representation type of position information within the generated message.
The representation type of position information within the generated message.
Attributes
- Source
- DefaultErrorBuilder.scala
This represents "raw" tokens, where are those without labels: 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: they come direct from the input, or the characters that the parser is trying to read.
Attributes
- Source
- DefaultErrorBuilder.scala
The representation of the file information.
The representation of the information regarding the problematic token.
The representation of the information regarding the problematic token.
Attributes
- Source
- DefaultErrorBuilder.scala
Value members
Concrete methods
This is the top level function, which finally compiles all the built sub-parts into a finished value of type Err
.
This is the top level function, which finally compiles all the built sub-parts into a finished value of type Err
.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Details how to combine the various expected items into a single representation.
Details how to combine the various expected items into a single representation.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Details how to combine any reasons or messages generated within a single error.
Details how to combine any reasons or messages generated within a single error. Reasons are used by vanilla
messages and messages are used by specialized
messages.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
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.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Describes how to represent the information about the line that the error occured on.
Describes how to represent the information about the line that the error occured on.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
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).
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Formats a named item generated by a label.
Formats a named item generated by a label.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Formats a position into the representation type given by Position
.
Formats a position into the representation type given by Position
.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
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.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Describes how to represent the reasons behind a parser fail.
Describes how to represent the reasons behind a parser fail. These reasons originate from the explain
combinator.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
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
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Specialized errors are triggered by fail
and any combinators that are implemented in terms of fail
.
Specialized 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 specialized, information
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
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.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Vanilla errors are those produced such that they have information about both expected
and unexpected
tokens.
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.
Attributes
- Definition Classes
- Source
- DefaultErrorBuilder.scala
Concrete 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.
Attributes
- Source
- DefaultErrorBuilder.scala
The number of lines of input to request after an error occured.
The number of lines of input to request after an error occured.
Attributes
- Source
- DefaultErrorBuilder.scala
The number of lines of input to request before an error occured.
The number of lines of input to request before an error occured.
Attributes
- Source
- DefaultErrorBuilder.scala