Safe Haskell | None |
---|---|
Language | GHC2021 |
Synopsis
- data StringLexError loc
- = UnexpectedEOF !loc !(ContainsSmartQuote loc)
- | BadCharInitialLex !loc !(ContainsSmartQuote loc)
- | EscapeBadChar !loc
- | EscapeUnexpectedEOF !loc
- | EscapeNumRangeError !loc
- | EscapeSmartQuoteError !Char !loc
- data ContainsSmartQuote loc
- = NoSmartQuote
- | SmartQuote !Char !loc
- data LexStringType
- lexString :: LexStringType -> GetChar loc -> loc -> Either (StringLexError loc) (String, loc)
- isDoubleSmartQuote :: Char -> Bool
- isSingleSmartQuote :: Char -> Bool
- isAnyChar :: Char -> Bool
- resolveEscapeCharacter :: GetChar loc -> loc -> Either (StringLexError loc) (Char, loc)
Documentation
data StringLexError loc Source #
UnexpectedEOF !loc !(ContainsSmartQuote loc) | Unexpectedly hit EOF when lexing string |
BadCharInitialLex !loc !(ContainsSmartQuote loc) | Found invalid character when initially lexing string |
EscapeBadChar !loc | Found invalid character when parsing an escaped character |
EscapeUnexpectedEOF !loc | Unexpectedly hit EOF when parsing an escaped character |
EscapeNumRangeError !loc | Escaped number exceeds range |
EscapeSmartQuoteError !Char !loc | Found escaped smart unicode chars as `’` or `”` |
Instances
Show loc => Show (StringLexError loc) Source # | |
Defined in GHC.Parser.String showsPrec :: Int -> StringLexError loc -> ShowS # show :: StringLexError loc -> String # showList :: [StringLexError loc] -> ShowS # |
data ContainsSmartQuote loc Source #
When initially lexing the string, we want to track if we've seen a smart quote, to show a helpful "you might be accidentally using a smart quote" error.
NoSmartQuote | |
SmartQuote !Char !loc |
Instances
Show loc => Show (ContainsSmartQuote loc) Source # | |
Defined in GHC.Parser.String showsPrec :: Int -> ContainsSmartQuote loc -> ShowS # show :: ContainsSmartQuote loc -> String # showList :: [ContainsSmartQuote loc] -> ShowS # |
lexString :: LexStringType -> GetChar loc -> loc -> Either (StringLexError loc) (String, loc) Source #
Unicode smart quote helpers
isDoubleSmartQuote :: Char -> Bool Source #
isSingleSmartQuote :: Char -> Bool Source #
Other helpers
resolveEscapeCharacter :: GetChar loc -> loc -> Either (StringLexError loc) (Char, loc) Source #
After finding a backslash, parse the rest of the escape character, starting at the given location.