License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis, Gigaparsec Maintainers |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
This module contains the relevant functionality for configuring the error messages generated by the parsers provided by the Lexer
.
Since: 0.2.2.0
Synopsis
- data ErrorConfig
- data LabelConfig
- class LabelConfigurable config where
- data ExplainConfig
- class ExplainConfigurable config where
- data LabelWithExplainConfig
- class LabelWithExplainConfigurable config where
- labelAndReason :: Set String -> String -> config
- class NotConfigurable config where
- notConfigured :: config
- labelNumericBreakChar :: ErrorConfig -> LabelWithExplainConfig
- labelIntegerUnsignedDecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerUnsignedHexadecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerUnsignedOctal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerUnsignedBinary :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerUnsignedNumber :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerSignedDecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerSignedHexadecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerSignedOctal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerSignedBinary :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerSignedNumber :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
- labelIntegerDecimalEnd :: ErrorConfig -> LabelConfig
- labelIntegerHexadecimalEnd :: ErrorConfig -> LabelConfig
- labelIntegerOctalEnd :: ErrorConfig -> LabelConfig
- labelIntegerBinaryEnd :: ErrorConfig -> LabelConfig
- labelIntegerNumberEnd :: ErrorConfig -> LabelConfig
- filterIntegerOutOfBounds :: ErrorConfig -> Integer -> Integer -> Int -> FilterConfig Integer
- data Bits
- labelNameIdentifier :: ErrorConfig -> String
- labelNameOperator :: ErrorConfig -> String
- unexpectedNameIllegalIdentifier :: ErrorConfig -> String -> String
- unexpectedNameIllegalOperator :: ErrorConfig -> String -> String
- filterNameIllFormedIdentifier :: ErrorConfig -> FilterConfig String
- filterNameIllFormedOperator :: ErrorConfig -> FilterConfig String
- labelCharAscii :: ErrorConfig -> LabelWithExplainConfig
- labelCharLatin1 :: ErrorConfig -> LabelWithExplainConfig
- labelCharUnicode :: ErrorConfig -> LabelWithExplainConfig
- labelCharAsciiEnd :: ErrorConfig -> LabelConfig
- labelCharLatin1End :: ErrorConfig -> LabelConfig
- labelCharUnicodeEnd :: ErrorConfig -> LabelConfig
- labelStringAscii :: ErrorConfig -> Bool -> Bool -> LabelWithExplainConfig
- labelStringLatin1 :: ErrorConfig -> Bool -> Bool -> LabelWithExplainConfig
- labelStringUnicode :: ErrorConfig -> Bool -> Bool -> LabelWithExplainConfig
- labelStringAsciiEnd :: ErrorConfig -> Bool -> Bool -> LabelConfig
- labelStringLatin1End :: ErrorConfig -> Bool -> Bool -> LabelConfig
- labelStringUnicodeEnd :: ErrorConfig -> Bool -> Bool -> LabelConfig
- labelStringCharacter :: ErrorConfig -> LabelConfig
- labelGraphicCharacter :: ErrorConfig -> LabelWithExplainConfig
- labelEscapeSequence :: ErrorConfig -> LabelWithExplainConfig
- labelEscapeNumeric :: ErrorConfig -> Int -> LabelWithExplainConfig
- labelEscapeNumericEnd :: ErrorConfig -> Char -> Int -> LabelWithExplainConfig
- labelEscapeEnd :: ErrorConfig -> LabelWithExplainConfig
- labelStringEscapeEmpty :: ErrorConfig -> LabelConfig
- labelStringEscapeGap :: ErrorConfig -> LabelConfig
- labelStringEscapeGapEnd :: ErrorConfig -> LabelConfig
- data FilterConfig a
- class BasicFilterConfigurable (config :: Type -> Type) where
- basicFilter :: config a
- data VanillaFilterConfig a
- class VanillaFilterConfigurable (config :: Type -> Type) where
- unexpected :: (a -> String) -> config a
- because :: (a -> String) -> config a
- unexpectedBecause :: (a -> String) -> (a -> String) -> config a
- data SpecializedFilterConfig a
- class SpecializedFilterConfigurable (config :: Type -> Type) where
- specializedFilter :: (a -> NonEmpty String) -> config a
- filterCharNonAscii :: ErrorConfig -> VanillaFilterConfig Char
- filterCharNonLatin1 :: ErrorConfig -> VanillaFilterConfig Char
- filterStringNonAscii :: ErrorConfig -> SpecializedFilterConfig String
- filterStringNonLatin1 :: ErrorConfig -> SpecializedFilterConfig String
- filterEscapeCharRequiresExactDigits :: ErrorConfig -> Int -> NonEmpty Word -> SpecializedFilterConfig Word
- filterEscapeCharNumericSequenceIllegal :: ErrorConfig -> Char -> Int -> SpecializedFilterConfig Integer
- data VerifiedBadChars
- class Unverified config where
- unverified :: config
- badCharsFail :: Map Char (NonEmpty String) -> VerifiedBadChars
- badCharsReason :: Map Char String -> VerifiedBadChars
- verifiedCharBadCharsUsedInLiteral :: ErrorConfig -> VerifiedBadChars
- verifiedStringBadCharsUsedInLiteral :: ErrorConfig -> VerifiedBadChars
- labelSymbol :: ErrorConfig -> Map String LabelWithExplainConfig
- labelSymbolEndOfKeyword :: ErrorConfig -> String -> String
- labelSymbolEndOfOperator :: ErrorConfig -> String -> String
- labelSpaceEndOfLineComment :: ErrorConfig -> LabelWithExplainConfig
- labelSpaceEndOfMultiComment :: ErrorConfig -> LabelWithExplainConfig
- defaultErrorConfig :: ErrorConfig
Error Configuration
This is the main type that defines the configuration for errors from the Lexer.
data ErrorConfig Source #
An ErrorConfig
specifies how errors should be produced by the Lexer
.
The Lexer is set up to produce a variety of different errors via label
-ing, explain
-ing, and filter
-ing,
and some applications of the Verified and Preventative error patterns.
The exact content of those errors can be configured here.
Errors can be suppressed or specified with different levels of detail,
or even switching between vanilla or specialised errors.
A custom ErrorConfig
should be created by extending the defaultErrorConfig
with record updates to override the relevant default fields.
Not configuring something does not mean it will not appear in the message,
but will mean it uses the underlying base errors.
Labelling and Explanation Configuration
Labels and Explanations make parser errors more descriptive, by giving a name to the parser that failed, or providing a reason a particular parser failed. These help make error messages more descriptive than the usual 'unexpected symbol' messages.
LabelConfigurable
types describe errors that can provide labels upon failure,
ExplainConfigurable
types those that can providing reaons for failure,
and LabelWithExplainConfigurable
types those that can provide both.
These configs are used by the ErrorConfig
, whose fields include combinators that configure both labels and/or explains for simple description configurations.
Label Configurations
Labels provide names to a parser to be used upon failure.
A LabelConfig
or LabelConfigurable
type is able to produce these sorts of errors.
data LabelConfig Source #
This type configures errors that make labels.
Instances
LabelConfigurable LabelConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors label :: Set String -> LabelConfig Source # hidden :: LabelConfig Source # | |
NotConfigurable LabelConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors |
class LabelConfigurable config where Source #
A type config
is ExplainConfigurable
when it is able to configure errors that make labels.
This means config
is able to behave like a LabelConfig
The configuration produces the labels in the given set, which should not be empty.
Configure a label by stating it must be hidden.
Instances
LabelConfigurable LabelConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors label :: Set String -> LabelConfig Source # hidden :: LabelConfig Source # | |
LabelConfigurable LabelWithExplainConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors |
Explain Configurations
Explains provide a reason that a parser has failed.
An ExplainConfig
or ExplainConfigurable
type is able to produce these sorts of errors.
data ExplainConfig Source #
This type configures errors that give reasons.
Instances
ExplainConfigurable ExplainConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors reason :: String -> ExplainConfig Source # | |
NotConfigurable ExplainConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors |
class ExplainConfigurable config where Source #
A type config
is ExplainConfigurable
when it is able to configure an error which provides a reason.
This means config
is able to behave like an ExplainConfig
:: String | The reason a parser failed. |
-> config |
The error should be displayed using the given reason.
Instances
Label-with-Explain Configurations
LabelWithExplainConfig
combines LabelConfig
and ExplainConfig
,
describing configs that are able to give labels and/or reasons to errors.
LabelWithExplainConfigurable
types are those able to produce an error providing both labels and a reason.
data LabelWithExplainConfig Source #
This type configures both errors that make labels and those that make reasons.
Instances
class LabelWithExplainConfigurable config where Source #
A type config
is LabelWithExplainConfigurable
when it is able to configure an error which provides both a reason and labels.
The configuration produces the labels in the given set, and provides the given reason.
Instances
No-special-error-generating Configs
Sometimes it is best to defer to the default errors, instead of generating specialised ones.
Configs that allow this are NotConfigurable
.
class NotConfigurable config where Source #
A type config
is NotConfigurable
when it is able to specify that no special error should be generated,
and instead use default errors.
notConfigured :: config Source #
No special error should be generated, and default errors should be used instead.
Instances
Numeric Errors
These control the errors generated with the numeric (NumericDesc
) component of the Lexer
.
labelNumericBreakChar :: ErrorConfig -> LabelWithExplainConfig Source #
How a numeric break character should (like _
) be referred to or explained within an error.
labelIntegerUnsignedDecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How unsigned decimal integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerUnsignedHexadecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How unsigned hexadecimal integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerUnsignedOctal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How unsigned octal integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerUnsignedBinary :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How unsigned binary integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerUnsignedNumber :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How generic unsigned integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerSignedDecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How signed decimal integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerSignedHexadecimal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How signed hexadecimal integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerSignedOctal :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How signed octal integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerSignedBinary :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How signed binary integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerSignedNumber :: ErrorConfig -> Maybe Bits -> LabelWithExplainConfig Source #
How generic signed integers (of a possibly given bit-width) should be referred to or explained within an error.
labelIntegerDecimalEnd :: ErrorConfig -> LabelConfig Source #
How the fact that the end of a decimal integer literal is expected should be referred to within an error.
labelIntegerHexadecimalEnd :: ErrorConfig -> LabelConfig Source #
How the fact that the end of a hexadecimal integer literal is expected should be referred to within an error.
labelIntegerOctalEnd :: ErrorConfig -> LabelConfig Source #
How the fact that the end of an octal integer literal is expected should be referred to within an error.
labelIntegerBinaryEnd :: ErrorConfig -> LabelConfig Source #
How the fact that the end of a binary integer literal is expected should be referred to within an error.
labelIntegerNumberEnd :: ErrorConfig -> LabelConfig Source #
How the fact that the end of a generic integer literal is expected should be referred to within an error.
filterIntegerOutOfBounds :: ErrorConfig -> Integer -> Integer -> Int -> FilterConfig Integer Source #
Describes the content of the error when an integer literal is parsed and it is not within the required bit-width.
In
: filterIntegerOutOfBounds
x y r
x
is the smallest value the integer could have taken,y
is the largest value the integer could have taken, andr
is the radix that the integer was parsed using
Bit-Widths
Some of the numeric errors can take into account the supposed bit-width of the parsed data.
Using Bits
achieves this.
The bit-width of certain data.
This is used to help enforce parsers of bounded precision to only return types that can losslessly accomodate that precision.
Name Errors
labelNameIdentifier :: ErrorConfig -> String Source #
How an identifier should be referred to in an error message.
labelNameOperator :: ErrorConfig -> String Source #
How a user-defined operator should be referred to in an error message.
unexpectedNameIllegalIdentifier :: ErrorConfig -> String -> String Source #
How an illegally parsed hard keyword should be referred to as an unexpected component.
unexpectedNameIllegalOperator :: ErrorConfig -> String -> String Source #
How an illegally parsed hard operator should be referred to as an unexpected component.
filterNameIllFormedIdentifier :: ErrorConfig -> FilterConfig String Source #
When parsing identifiers that are required to have specific start characters, how bad identifiers should be reported.
filterNameIllFormedOperator :: ErrorConfig -> FilterConfig String Source #
When parsing operators that are required to have specific start/end characters, how bad operators should be reported.
Text Errors
labelCharAscii :: ErrorConfig -> LabelWithExplainConfig Source #
How an ASCII character literal should be referred to or explained in error messages.
labelCharLatin1 :: ErrorConfig -> LabelWithExplainConfig Source #
How a Latin1 (extended ASCII) character literal should be referred to or explained in error messages.
labelCharUnicode :: ErrorConfig -> LabelWithExplainConfig Source #
How a UTF-16 character literal should be referred to or explained in error messages.
labelCharAsciiEnd :: ErrorConfig -> LabelConfig Source #
How the closing quote of an ASCII character literal should be referred to in error messages.
labelCharLatin1End :: ErrorConfig -> LabelConfig Source #
How the closing quote of a Latin1 (extended ASCII) character literal should be referred to in error messages.
labelCharUnicodeEnd :: ErrorConfig -> LabelConfig Source #
How the closing quote of a UTF-16 character literal should be referred to in error messages.
labelStringAscii :: ErrorConfig -> Bool -> Bool -> LabelWithExplainConfig Source #
How an ASCII-only string should literal be referred to or explained in error messages.
With the arguments
:labelStringAscii
multi raw
multi
: whether this is for a multi-line stringraw
: whether this is for a raw string
labelStringLatin1 :: ErrorConfig -> Bool -> Bool -> LabelWithExplainConfig Source #
How a Latin1-only string should literal be referred to or explained in error messages.
With the arguments
:labelStringLatin1
multi raw
multi
: whether this is for a multi-line stringraw
: whether this is for a raw string
labelStringUnicode :: ErrorConfig -> Bool -> Bool -> LabelWithExplainConfig Source #
How a UTF-16-only string should literal be referred to or explained in error messages.
With the arguments
:labelStringUnicode
multi raw
multi
: whether this is for a multi-line stringraw
: whether this is for a raw string
labelStringAsciiEnd :: ErrorConfig -> Bool -> Bool -> LabelConfig Source #
How the closing quote(s) of an ASCII string literal should be referred to in error messages.
With the arguments
:labelStringAsciiEnd
multi raw
multi
: whether this is for a multi-line stringraw
: whether this is for a raw string
labelStringLatin1End :: ErrorConfig -> Bool -> Bool -> LabelConfig Source #
How the closing quote(s) of a Latin1 string literal should be referred to in error messages.
With the arguments
:labelStringLatin1End
multi raw
multi
: whether this is for a multi-line stringraw
: whether this is for a raw string
labelStringUnicodeEnd :: ErrorConfig -> Bool -> Bool -> LabelConfig Source #
How the closing quote(s) of a UTF-16 string literal should be referred to in error messages.
With the arguments
:labelStringUnicodeEnd
multi raw
multi
: whether this is for a multi-line stringraw
: whether this is for a raw string
labelStringCharacter :: ErrorConfig -> LabelConfig Source #
How general string characters should be referred to in error messages.
labelGraphicCharacter :: ErrorConfig -> LabelWithExplainConfig Source #
How a graphic character (a regular character in the literal) should be referred to or explained in error messages.
labelEscapeSequence :: ErrorConfig -> LabelWithExplainConfig Source #
How an escape sequence should be referred to or explained in error messages.
labelEscapeNumeric :: ErrorConfig -> Int -> LabelWithExplainConfig Source #
How a numeric escape sequence (after the opening character) should be referred to or explained in error messages.
In
:labelEscapeNumeric
radix
radix
: the radix this specific configuration applies to.
labelEscapeNumericEnd :: ErrorConfig -> Char -> Int -> LabelWithExplainConfig Source #
How the end of a numeric escape sequence (after a prefix) should be referred to or explained in error messages.
In
:labelEscapeNumericEnd
prefix radix
prefix
: the character that started this sequenceradix
: the radix this specific configuration applies to.
labelEscapeEnd :: ErrorConfig -> LabelWithExplainConfig Source #
How the end of an escape sequence (anything past the opening character) should be referred to or explained within an error message.
labelStringEscapeEmpty :: ErrorConfig -> LabelConfig Source #
How zero-width escape characters should be referred to within error messages.
labelStringEscapeGap :: ErrorConfig -> LabelConfig Source #
How string gaps should be referred to within error messages.
labelStringEscapeGapEnd :: ErrorConfig -> LabelConfig Source #
How the end of a string gap (the closing slash) should be referred to within error messages.
Filtering Errors
These configs and combinators describe how to generate the filters to rule out specific parses. They can generate types of vanilla error or specialised errors.
Filtering Configs
data FilterConfig a Source #
Configures how filters should be used within the Lexer
.
Instances
BasicFilterConfigurable FilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors basicFilter :: FilterConfig a Source # | |
SpecializedFilterConfigurable FilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors specializedFilter :: (a -> NonEmpty String) -> FilterConfig a Source # | |
VanillaFilterConfigurable FilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors unexpected :: (a -> String) -> FilterConfig a Source # because :: (a -> String) -> FilterConfig a Source # unexpectedBecause :: (a -> String) -> (a -> String) -> FilterConfig a Source # |
class BasicFilterConfigurable (config :: Type -> Type) where Source #
A type config
is BasicFilterConfigurable
when it is able to provide no error configuration,
and instead defer to a regular filter.
basicFilter :: config a Source #
No error configuration for the filter is specified; a regular filter is used instead.
Instances
data VanillaFilterConfig a Source #
Specifies that only filters generating vanilla errors can be used.
Instances
BasicFilterConfigurable VanillaFilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors | |
VanillaFilterConfigurable VanillaFilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors unexpected :: (a -> String) -> VanillaFilterConfig a Source # because :: (a -> String) -> VanillaFilterConfig a Source # unexpectedBecause :: (a -> String) -> (a -> String) -> VanillaFilterConfig a Source # |
class VanillaFilterConfigurable (config :: Type -> Type) where Source #
A type config
is VanillaFilterConfigurable
when it is able to generate vanilla errors.
This means config
is able to behave like a VanillaFilterConfig
:: (a -> String) | a function producing the unexpected label for the given value. |
-> config a |
Ensure the filter generates a vanilla unexpected item for the given failing parse.
:: (a -> String) | a function producing the reason for the given value. |
-> config a |
Ensure the filter generates a vanilla reason for the given failing parse.
:: (a -> String) |
|
-> (a -> String) |
|
-> config a |
Ensure the filter generates a vanilla unexpected item and a reason for the given failing parse.
Instances
VanillaFilterConfigurable FilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors unexpected :: (a -> String) -> FilterConfig a Source # because :: (a -> String) -> FilterConfig a Source # unexpectedBecause :: (a -> String) -> (a -> String) -> FilterConfig a Source # | |
VanillaFilterConfigurable VanillaFilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors unexpected :: (a -> String) -> VanillaFilterConfig a Source # because :: (a -> String) -> VanillaFilterConfig a Source # unexpectedBecause :: (a -> String) -> (a -> String) -> VanillaFilterConfig a Source # |
data SpecializedFilterConfig a Source #
Specifies that only filters generating specialised errors can be used.
Instances
class SpecializedFilterConfigurable (config :: Type -> Type) where Source #
A type config
is SpecializedFilterConfigurable
when it is able to generate specialised errors.
This means config
is able to behave like a SpecializedFilterConfig
Ensure the filter generates specialised messages for the given failing parse.
Instances
SpecializedFilterConfigurable FilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors specializedFilter :: (a -> NonEmpty String) -> FilterConfig a Source # | |
SpecializedFilterConfigurable SpecializedFilterConfig Source # | |
Defined in Text.Gigaparsec.Token.Errors specializedFilter :: (a -> NonEmpty String) -> SpecializedFilterConfig a Source # |
Filtering Combinators
filterCharNonAscii :: ErrorConfig -> VanillaFilterConfig Char Source #
When a non-ASCII character is found in a ASCII-only character literal, specifies how this should be reported.
filterCharNonLatin1 :: ErrorConfig -> VanillaFilterConfig Char Source #
When a non-Latin1 character is found in a Latin1-only character literal, specifies how this should be reported.
filterStringNonAscii :: ErrorConfig -> SpecializedFilterConfig String Source #
When a non-ASCII character is found in a ASCII-only string literal, specifies how this should be reported.
filterStringNonLatin1 :: ErrorConfig -> SpecializedFilterConfig String Source #
When a non-Latin1 character is found in a Latin1-only string literal, specifies how this should be reported.
filterEscapeCharRequiresExactDigits :: ErrorConfig -> Int -> NonEmpty Word -> SpecializedFilterConfig Word Source #
When a numeric escape sequence requires a specific number of digits but this was not successfully parsed, this describes how to report that error given the number of successfully parsed digits up this point.
In
:filterEscapeCharRequiresExactDigits
radix needed
radix
: the radix used for this numeric escape sequence.needed
: the possible numbers of digits required.
filterEscapeCharNumericSequenceIllegal :: ErrorConfig -> Char -> Int -> SpecializedFilterConfig Integer Source #
When a numeric escape sequence is not legal, this describes how to report that error, given the original illegal character.
In
:filterEscapeCharNumericSequenceIllegal
maxEscape radix
maxEscape
: the largest legal escape character.radix
: the radix used for this numeric escape sequence.
Verifying Bad Characters
These types and combinators help implement the Verified Error™ pattern for illegal string and literal characters.
Configs
These types help configure the Verified Error pattern for illegal string and character literal characters,
used by verifiedCharBadCharsUsedInLiteral
and verifiedStringBadCharsUsedInLiteral
.
data VerifiedBadChars Source #
Configures what error should be generated when illegal characters in a string or character literal are parsable.
Instances
class Unverified config where Source #
A type config
is Unverified
when it can disable the verified error for bad characters:
this may improve parsing performance slightly on the failure case.
unverified :: config Source #
A configuration which disables the verified error for bad characters.
Instances
Combinators
badCharsFail :: Map Char (NonEmpty String) -> VerifiedBadChars Source #
Makes "bad literal chars" generate a bunch of given messages in a specialised error. Requires a map from bad characters to their messages.
badCharsReason :: Map Char String -> VerifiedBadChars Source #
Makes "bad literal chars" generate a reason in a vanilla error. Requires a map from bad characters to their reasons.
verifiedCharBadCharsUsedInLiteral :: ErrorConfig -> VerifiedBadChars Source #
Character literals parse either graphic characters or escape characters.
verifiedStringBadCharsUsedInLiteral :: ErrorConfig -> VerifiedBadChars Source #
String literals parse either graphic characters or escape characters.
Symbol Errors
These control the errors generated with the symbol (SymbolDesc
) component of the Lexer
labelSymbol :: ErrorConfig -> Map String LabelWithExplainConfig Source #
Gives names and/or reasons to symbols.
Symbols that do not appear in the map are assumed to be NotConfigurable
.
labelSymbolEndOfKeyword :: ErrorConfig -> String -> String Source #
How the required end of a given keyword should be specified in an error.
labelSymbolEndOfOperator :: ErrorConfig -> String -> String Source #
How the required end of a given operator should be specified in an error.
Space Errors
labelSpaceEndOfLineComment :: ErrorConfig -> LabelWithExplainConfig Source #
How the end of a single-line comment should be described or explained.
labelSpaceEndOfMultiComment :: ErrorConfig -> LabelWithExplainConfig Source #
How the end of a multi-line comment should be described or explained.
The Default Configuration
defaultErrorConfig :: ErrorConfig Source #
The default configuration. This serves as the base configuration, to be customised using record field updates.