ghc-9.11: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.Parser.String

Synopsis

Documentation

data StringLexError loc Source #

Constructors

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

Instances details
Show loc => Show (StringLexError loc) Source # 
Instance details

Defined in GHC.Parser.String

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.

Constructors

NoSmartQuote 
SmartQuote !Char !loc 

Instances

Instances details
Show loc => Show (ContainsSmartQuote loc) Source # 
Instance details

Defined in GHC.Parser.String

lexString :: LexStringType -> GetChar loc -> loc -> Either (StringLexError loc) (String, loc) Source #

Unicode smart quote helpers

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.