ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Parser.Lexer

Synopsis

- data Token
  - = ITas
  - | ITcase
  - | ITclass
  - | ITdata
  - | ITdefault
  - | ITderiving
  - | ITdo (Maybe FastString)
  - | ITelse
  - | IThiding
  - | ITforeign
  - | ITif
  - | ITimport
  - | ITin
  - | ITinfix
  - | ITinfixl
  - | ITinfixr
  - | ITinstance
  - | ITlet
  - | ITmodule
  - | ITnewtype
  - | ITof
  - | ITqualified
  - | ITthen
  - | ITtype
  - | ITwhere
  - | ITforall IsUnicodeSyntax
  - | ITexport
  - | ITlabel
  - | ITdynamic
  - | ITsafe
  - | ITinterruptible
  - | ITunsafe
  - | ITstdcallconv
  - | ITccallconv
  - | ITcapiconv
  - | ITprimcallconv
  - | ITjavascriptcallconv
  - | ITmdo (Maybe FastString)
  - | ITfamily
  - | ITrole
  - | ITgroup
  - | ITby
  - | ITusing
  - | ITpattern
  - | ITstatic
  - | ITstock
  - | ITanyclass
  - | ITvia
  - | ITunit
  - | ITsignature
  - | ITdependency
  - | ITrequires
  - | ITinline_prag SourceText InlineSpec RuleMatchInfo
  - | ITopaque_prag SourceText
  - | ITspec_prag SourceText
  - | ITspec_inline_prag SourceText Bool
  - | ITsource_prag SourceText
  - | ITrules_prag SourceText
  - | ITwarning_prag SourceText
  - | ITdeprecated_prag SourceText
  - | ITline_prag SourceText
  - | ITcolumn_prag SourceText
  - | ITscc_prag SourceText
  - | ITunpack_prag SourceText
  - | ITnounpack_prag SourceText
  - | ITann_prag SourceText
  - | ITcomplete_prag SourceText
  - | ITclose_prag
  - | IToptions_prag String
  - | ITinclude_prag String
  - | ITlanguage_prag
  - | ITminimal_prag SourceText
  - | IToverlappable_prag SourceText
  - | IToverlapping_prag SourceText
  - | IToverlaps_prag SourceText
  - | ITincoherent_prag SourceText
  - | ITctype SourceText
  - | ITcomment_line_prag
  - | ITdotdot
  - | ITcolon
  - | ITdcolon IsUnicodeSyntax
  - | ITequal
  - | ITlam
  - | ITlcase
  - | ITlcases
  - | ITvbar
  - | ITlarrow IsUnicodeSyntax
  - | ITrarrow IsUnicodeSyntax
  - | ITdarrow IsUnicodeSyntax
  - | ITlolly
  - | ITminus
  - | ITprefixminus
  - | ITbang
  - | ITtilde
  - | ITat
  - | ITtypeApp
  - | ITpercent
  - | ITstar IsUnicodeSyntax
  - | ITdot
  - | ITproj Bool
  - | ITbiglam
  - | ITocurly
  - | ITccurly
  - | ITvocurly
  - | ITvccurly
  - | ITobrack
  - | ITopabrack
  - | ITcpabrack
  - | ITcbrack
  - | IToparen
  - | ITcparen
  - | IToubxparen
  - | ITcubxparen
  - | ITsemi
  - | ITcomma
  - | ITunderscore
  - | ITbackquote
  - | ITsimpleQuote
  - | ITvarid FastString
  - | ITconid FastString
  - | ITvarsym FastString
  - | ITconsym FastString
  - | ITqvarid (FastString, FastString)
  - | ITqconid (FastString, FastString)
  - | ITqvarsym (FastString, FastString)
  - | ITqconsym (FastString, FastString)
  - | ITdupipvarid FastString
  - | ITlabelvarid SourceText FastString
  - | ITchar SourceText Char
  - | ITstring SourceText FastString
  - | ITstringMulti SourceText FastString
  - | ITinteger IntegralLit
  - | ITrational FractionalLit
  - | ITprimchar SourceText Char
  - | ITprimstring SourceText ByteString
  - | ITprimint SourceText Integer
  - | ITprimword SourceText Integer
  - | ITprimint8 SourceText Integer
  - | ITprimint16 SourceText Integer
  - | ITprimint32 SourceText Integer
  - | ITprimint64 SourceText Integer
  - | ITprimword8 SourceText Integer
  - | ITprimword16 SourceText Integer
  - | ITprimword32 SourceText Integer
  - | ITprimword64 SourceText Integer
  - | ITprimfloat FractionalLit
  - | ITprimdouble FractionalLit
  - | ITopenExpQuote HasE IsUnicodeSyntax
  - | ITopenPatQuote
  - | ITopenDecQuote
  - | ITopenTypQuote
  - | ITcloseQuote IsUnicodeSyntax
  - | ITopenTExpQuote HasE
  - | ITcloseTExpQuote
  - | ITdollar
  - | ITdollardollar
  - | ITtyQuote
  - | ITquasiQuote (FastString, PsSpan, FastString, PsSpan)
  - | ITqQuasiQuote (FastString, FastString, PsSpan, FastString, PsSpan)
  - | ITsplice
  - | ITquote
  - | ITproc
  - | ITrec
  - | IToparenbar IsUnicodeSyntax
  - | ITcparenbar IsUnicodeSyntax
  - | ITlarrowtail IsUnicodeSyntax
  - | ITrarrowtail IsUnicodeSyntax
  - | ITLarrowtail IsUnicodeSyntax
  - | ITRarrowtail IsUnicodeSyntax
  - | ITunknown String
  - | ITeof
  - | ITdocComment HsDocString PsSpan
  - | ITdocOptions String PsSpan
  - | ITlineComment String PsSpan
  - | ITblockComment String PsSpan
- lexer :: Bool -> (Located Token -> P a) -> P a
- lexerDbg :: Bool -> (Located Token -> P a) -> P a
- data ParserOpts = ParserOpts {
  - pExtsBitmap :: !ExtsBitmap
  - pDiagOpts :: !DiagOpts
  }
- mkParserOpts :: EnumSet Extension -> DiagOpts -> Bool -> Bool -> Bool -> Bool -> ParserOpts
- data PState = PState {
  - buffer :: StringBuffer
  - options :: ParserOpts
  - warnings :: Messages PsMessage
  - errors :: Messages PsMessage
  - tab_first :: Maybe RealSrcSpan
  - tab_count :: !Word
  - last_tk :: Maybe (PsLocated Token)
  - prev_loc :: PsSpan
  - last_loc :: PsSpan
  - last_len :: !Int
  - loc :: PsLoc
  - context :: [LayoutContext]
  - lex_state :: [Int]
  - srcfiles :: [FastString]
  - alr_pending_implicit_tokens :: [PsLocated Token]
  - alr_next_token :: Maybe (PsLocated Token)
  - alr_last_loc :: PsSpan
  - alr_context :: [ALRContext]
  - alr_expecting_ocurly :: Maybe ALRLayout
  - alr_justClosedExplicitLetBlock :: Bool
  - eof_pos :: Maybe (Pair RealSrcSpan RealSrcSpan)
  - header_comments :: Maybe [LEpaComment]
  - comment_q :: [LEpaComment]
  - hdk_comments :: OrdList (PsLocated HdkComment)
  }
- initParserState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState
- initPragState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState
- newtype P a = P {
  - unP :: PState -> ParseResult a
  }
- data ParseResult a :: TYPE ('SumRep '['TupleRep '[LiftedRep, LiftedRep], LiftedRep]) where
  - pattern POk :: PState -> a -> ParseResult a
  - pattern PFailed :: PState -> ParseResult a
- allocateComments :: RealSrcSpan -> [LEpaComment] -> ([LEpaComment], [LEpaComment])
- allocatePriorComments :: RealSrcSpan -> [LEpaComment] -> Maybe [LEpaComment] -> (Maybe [LEpaComment], [LEpaComment], [LEpaComment])
- allocateFinalComments :: RealSrcSpan -> [LEpaComment] -> Maybe [LEpaComment] -> (Maybe [LEpaComment], [LEpaComment], [LEpaComment])
- class Monad m => MonadP (m :: Type -> Type) where
  - addError :: MsgEnvelope PsMessage -> m ()
  - addWarning :: MsgEnvelope PsMessage -> m ()
  - addFatalError :: MsgEnvelope PsMessage -> m a
  - getParserOpts :: m ParserOpts
  - allocateCommentsP :: RealSrcSpan -> m EpAnnComments
  - allocatePriorCommentsP :: RealSrcSpan -> m EpAnnComments
  - allocateFinalCommentsP :: RealSrcSpan -> m EpAnnComments
- getBit :: MonadP m => ExtBits -> m Bool
- getRealSrcLoc :: P RealSrcLoc
- getPState :: P PState
- failMsgP :: (SrcSpan -> MsgEnvelope PsMessage) -> P a
- failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> MsgEnvelope PsMessage) -> P a
- srcParseFail :: P a
- getPsErrorMessages :: PState -> Messages PsMessage
- getPsMessages :: PState -> (Messages PsMessage, Messages PsMessage)
- popContext :: P ()
- pushModuleContext :: P ()
- setLastToken :: PsSpan -> Int -> P ()
- setSrcLoc :: RealSrcLoc -> P ()
- activeContext :: P Bool
- nextIsEOF :: P Bool
- getLexState :: P Int
- popLexState :: P Int
- pushLexState :: Int -> P ()
- data ExtBits
  - = FfiBit
  - | InterruptibleFfiBit
  - | CApiFfiBit
  - | ArrowsBit
  - | ThBit
  - | ThQuotesBit
  - | IpBit
  - | OverloadedLabelsBit
  - | ExplicitForallBit
  - | BangPatBit
  - | PatternSynonymsBit
  - | HaddockBit
  - | MagicHashBit
  - | RecursiveDoBit
  - | QualifiedDoBit
  - | UnicodeSyntaxBit
  - | UnboxedParensBit
  - | DatatypeContextsBit
  - | MonadComprehensionsBit
  - | TransformComprehensionsBit
  - | QqBit
  - | RawTokenStreamBit
  - | AlternativeLayoutRuleBit
  - | ALRTransitionalBit
  - | RelaxedLayoutBit
  - | NondecreasingIndentationBit
  - | SafeHaskellBit
  - | TraditionalRecordSyntaxBit
  - | ExplicitNamespacesBit
  - | LambdaCaseBit
  - | BinaryLiteralsBit
  - | NegativeLiteralsBit
  - | HexFloatLiteralsBit
  - | StaticPointersBit
  - | NumericUnderscoresBit
  - | StarIsTypeBit
  - | BlockArgumentsBit
  - | NPlusKPatternsBit
  - | DoAndIfThenElseBit
  - | MultiWayIfBit
  - | GadtSyntaxBit
  - | ImportQualifiedPostBit
  - | LinearTypesBit
  - | NoLexicalNegationBit
  - | OverloadedRecordDotBit
  - | OverloadedRecordUpdateBit
  - | OrPatternsBit
  - | ExtendedLiteralsBit
  - | ListTuplePunsBit
  - | ViewPatternsBit
  - | RequiredTypeArgumentsBit
  - | MultilineStringsBit
  - | LevelImportsBit
  - | InRulePragBit
  - | InNestedCommentBit
  - | UsePosPragsBit
- xtest :: ExtBits -> ExtsBitmap -> Bool
- xunset :: ExtBits -> ExtsBitmap -> ExtsBitmap
- xset :: ExtBits -> ExtsBitmap -> ExtsBitmap
- disableHaddock :: ParserOpts -> ParserOpts
- lexTokenStream :: ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult [Located Token]
- mkParensEpToks :: RealSrcSpan -> (EpToken "(", EpToken ")")
- mkParensLocs :: RealSrcSpan -> (EpaLocation, EpaLocation)
- getCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments
- getPriorCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments
- getFinalCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments
- getEofPos :: P (Maybe (Pair RealSrcSpan RealSrcSpan))
- commentToAnnotation :: RealLocated Token -> LEpaComment
- data HdkComment
  - = HdkCommentNext HsDocString
  - | HdkCommentPrev HsDocString
  - | HdkCommentNamed String HsDocString
  - | HdkCommentSection Int HsDocString
- warnopt :: WarningFlag -> ParserOpts -> Bool
- addPsMessage :: MonadP m => SrcSpan -> PsMessage -> m ()

# Documentation

data Token #

Constructors

ITas |
ITcase |
ITclass |
ITdata |
ITdefault |
ITderiving |
ITdo (Maybe FastString) |
ITelse |
IThiding |
ITforeign |
ITif |
ITimport |
ITin |
ITinfix |
ITinfixl |
ITinfixr |
ITinstance |
ITlet |
ITmodule |
ITnewtype |
ITof |
ITqualified |
ITthen |
ITtype |
ITwhere |
ITforall IsUnicodeSyntax |
ITexport |
ITlabel |
ITdynamic |
ITsafe |
ITinterruptible |
ITunsafe |
ITstdcallconv |
ITccallconv |
ITcapiconv |
ITprimcallconv |
ITjavascriptcallconv |
ITmdo (Maybe FastString) |
ITfamily |
ITrole |
ITgroup |
ITby |
ITusing |
ITpattern |
ITstatic |
ITstock |
ITanyclass |
ITvia |
ITunit |
ITsignature |
ITdependency |
ITrequires |
ITinline_prag SourceText InlineSpec RuleMatchInfo |
ITopaque_prag SourceText |
ITspec_prag SourceText |
ITspec_inline_prag SourceText Bool |
ITsource_prag SourceText |
ITrules_prag SourceText |
ITwarning_prag SourceText |
ITdeprecated_prag SourceText |
ITline_prag SourceText |
ITcolumn_prag SourceText |
ITscc_prag SourceText |
ITunpack_prag SourceText |
ITnounpack_prag SourceText |
ITann_prag SourceText |
ITcomplete_prag SourceText |
ITclose_prag |
IToptions_prag String |
ITinclude_prag String |
ITlanguage_prag |
ITminimal_prag SourceText |
IToverlappable_prag SourceText |
IToverlapping_prag SourceText |
IToverlaps_prag SourceText |
ITincoherent_prag SourceText |
ITctype SourceText |
ITcomment_line_prag |
ITdotdot |
ITcolon |
ITdcolon IsUnicodeSyntax |
ITequal |
ITlam |
ITlcase |
ITlcases |
ITvbar |
ITlarrow IsUnicodeSyntax |
ITrarrow IsUnicodeSyntax |
ITdarrow IsUnicodeSyntax |
ITlolly |
ITminus |
ITprefixminus |
ITbang |
ITtilde |
ITat |
ITtypeApp |
ITpercent |
ITstar IsUnicodeSyntax |
ITdot |
ITproj Bool |
ITbiglam |
ITocurly |
ITccurly |
ITvocurly |
ITvccurly |
ITobrack |
ITopabrack |
ITcpabrack |
ITcbrack |
IToparen |
ITcparen |
IToubxparen |
ITcubxparen |
ITsemi |
ITcomma |
ITunderscore |
ITbackquote |
ITsimpleQuote |
ITvarid FastString |
ITconid FastString |
ITvarsym FastString |
ITconsym FastString |
ITqvarid (FastString, FastString) |
ITqconid (FastString, FastString) |
ITqvarsym (FastString, FastString) |
ITqconsym (FastString, FastString) |
ITdupipvarid FastString |
ITlabelvarid SourceText FastString |
ITchar SourceText Char |
ITstring SourceText FastString |
ITstringMulti SourceText FastString |
ITinteger IntegralLit |
ITrational FractionalLit |
ITprimchar SourceText Char |
ITprimstring SourceText ByteString |
ITprimint SourceText Integer |
ITprimword SourceText Integer |
ITprimint8 SourceText Integer |
ITprimint16 SourceText Integer |
ITprimint32 SourceText Integer |
ITprimint64 SourceText Integer |
ITprimword8 SourceText Integer |
ITprimword16 SourceText Integer |
ITprimword32 SourceText Integer |
ITprimword64 SourceText Integer |
ITprimfloat FractionalLit |
ITprimdouble FractionalLit |
ITopenExpQuote HasE IsUnicodeSyntax |
ITopenPatQuote |
ITopenDecQuote |
ITopenTypQuote |
ITcloseQuote IsUnicodeSyntax |
ITopenTExpQuote HasE |
ITcloseTExpQuote |
ITdollar |
ITdollardollar |
ITtyQuote |
ITquasiQuote (FastString, PsSpan, FastString, PsSpan) |
ITqQuasiQuote (FastString, FastString, PsSpan, FastString, PsSpan) |
ITsplice |
ITquote |
ITproc |
ITrec |
IToparenbar IsUnicodeSyntax |
    (|
ITcparenbar IsUnicodeSyntax |
    |)
ITlarrowtail IsUnicodeSyntax |
    -<
ITrarrowtail IsUnicodeSyntax |
    >-
ITLarrowtail IsUnicodeSyntax |
    -<<
ITRarrowtail IsUnicodeSyntax |
    >>-
ITunknown String | Used when the lexer can't make sense of it
ITeof | end of file token
ITdocComment HsDocString PsSpan | The HsDocString contains more details about what this is and how to pretty print it
ITdocOptions String PsSpan | doc options (prune, ignore-exports, etc)
ITlineComment String PsSpan | comment starting by "--"
ITblockComment String PsSpan | comment in {- -}

#### Instances

Instances details

Show Token # |
Instance details Defined in GHC.Parser.Lexer Methods showsPrec :: Int -> Token -> ShowS # show :: Token -> String # showList :: [Token] -> ShowS #
Outputable Token # |
Instance details Defined in GHC.Parser.Lexer Methods ppr :: Token -> SDoc #

lexer :: Bool -> (Located Token -> P a) -> P a #

lexerDbg :: Bool -> (Located Token -> P a) -> P a #

data ParserOpts #

Parser options.

See `mkParserOpts` to construct this.

Constructors

ParserOpts |
Fields pExtsBitmap :: !ExtsBitmap bitmap of permitted extensions pDiagOpts :: !DiagOpts Options to construct diagnostic messages.

mkParserOpts #

Arguments

:: EnumSet Extension | permitted language extensions enabled
-> DiagOpts | diagnostic options
-> Bool | are safe imports on?
-> Bool | keeping Haddock comment tokens
-> Bool | keep regular comment tokens
-> Bool | If this is enabled, '{-# LINE ... -#}' and '{-# COLUMN ... #-}' update the internal position kept by the parser. Otherwise, those pragmas are lexed as `ITline_prag` and `ITcolumn_prag` tokens.
-> ParserOpts |

Given exactly the information needed, set up the `ParserOpts`

data PState #

Constructors

PState |
Fields buffer :: StringBuffer options :: ParserOpts warnings :: Messages PsMessage errors :: Messages PsMessage tab_first :: Maybe RealSrcSpan tab_count :: !Word last_tk :: Maybe (PsLocated Token) prev_loc :: PsSpan last_loc :: PsSpan last_len :: !Int loc :: PsLoc context :: [LayoutContext] lex_state :: [Int] srcfiles :: [FastString] alr_pending_implicit_tokens :: [PsLocated Token] alr_next_token :: Maybe (PsLocated Token) alr_last_loc :: PsSpan alr_context :: [ALRContext] alr_expecting_ocurly :: Maybe ALRLayout alr_justClosedExplicitLetBlock :: Bool eof_pos :: Maybe (Pair RealSrcSpan RealSrcSpan) header_comments :: Maybe [LEpaComment] comment_q :: [LEpaComment] hdk_comments :: OrdList (PsLocated HdkComment)

initParserState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState #

Creates a parse state from a `ParserOpts` value

initPragState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState #

Set parser options for parsing OPTIONS pragmas

newtype P a #

The parsing monad, isomorphic to `StateT PState Maybe`.

Constructors

P |
Fields unP :: PState -> ParseResult a

#### Instances

Instances details

Applicative P # |
Instance details Defined in GHC.Parser.Lexer Methods pure :: a -> P a # (<*>) :: P (a -> b) -> P a -> P b # liftA2 :: (a -> b -> c) -> P a -> P b -> P c # (*>) :: P a -> P b -> P b # (<*) :: P a -> P b -> P a #
Functor P # |
Instance details Defined in GHC.Parser.Lexer Methods fmap :: (a -> b) -> P a -> P b # (<$) :: a -> P b -> P a #
Monad P # |
Instance details Defined in GHC.Parser.Lexer Methods (>>=) :: P a -> (a -> P b) -> P b # (>>) :: P a -> P b -> P b # return :: a -> P a #
MonadP P # |
Instance details Defined in GHC.Parser.Lexer Methods addError :: MsgEnvelope PsMessage -> P () # addWarning :: MsgEnvelope PsMessage -> P () # addFatalError :: MsgEnvelope PsMessage -> P a # getParserOpts :: P ParserOpts # allocateCommentsP :: RealSrcSpan -> P EpAnnComments # allocatePriorCommentsP :: RealSrcSpan -> P EpAnnComments # allocateFinalCommentsP :: RealSrcSpan -> P EpAnnComments #

data ParseResult a :: TYPE ('SumRep '['TupleRep '[LiftedRep, LiftedRep], LiftedRep]) where #

The result of running a parser.

Bundled Patterns

pattern POk :: PState -> a -> ParseResult a | The parser has consumed a (possibly empty) prefix of the input and produced a result. Use `getPsMessages` to check for accumulated warnings and non-fatal errors. The carried parsing state can be used to resume parsing.
pattern PFailed :: PState -> ParseResult a | The parser has consumed a (possibly empty) prefix of the input and failed. The carried parsing state can be used to resume parsing. It is the state right before failure, including the fatal parse error. `getPsMessages` and `getPsErrorMessages` must return a non-empty bag of errors.

allocateComments :: RealSrcSpan -> [LEpaComment] -> ([LEpaComment], [LEpaComment]) #

allocatePriorComments :: RealSrcSpan -> [LEpaComment] -> Maybe [LEpaComment] -> (Maybe [LEpaComment], [LEpaComment], [LEpaComment]) #

allocateFinalComments :: RealSrcSpan -> [LEpaComment] -> Maybe [LEpaComment] -> (Maybe [LEpaComment], [LEpaComment], [LEpaComment]) #

class Monad m => MonadP (m :: Type -> Type) where #

An mtl-style class for monads that support parsing-related operations. For example, sometimes we make a second pass over the parsing results to validate, disambiguate, or rearrange them, and we do so in the PV monad which cannot consume input but can report parsing errors, check for extension bits, and accumulate parsing annotations. Both P and PV are instances of MonadP.

MonadP grants us convenient overloading. The other option is to have separate operations for each monad: addErrorP vs addErrorPV, getBitP vs getBitPV, and so on.

Methods

addError :: MsgEnvelope PsMessage -> m () #

Add a non-fatal error. Use this when the parser can produce a result despite the error.

For example, when GHC encounters a `forall` in a type, but `-XExplicitForAll` is disabled, the parser constructs `ForAllTy` as if `-XExplicitForAll` was enabled, adding a non-fatal error to the accumulator.

Control flow wise, non-fatal errors act like warnings: they are added to the accumulator and parsing continues. This allows GHC to report more than one parse error per file.

addWarning :: MsgEnvelope PsMessage -> m () #

Add a warning to the accumulator. Use `getPsMessages` to get the accumulated warnings.

addFatalError :: MsgEnvelope PsMessage -> m a #

Add a fatal error. This will be the last error reported by the parser, and the parser will not produce any result, ending in a `PFailed` state.

getParserOpts :: m ParserOpts #

Get parser options

allocateCommentsP :: RealSrcSpan -> m EpAnnComments #

Go through the `comment_q` in `PState` and remove all comments that belong within the given span

allocatePriorCommentsP :: RealSrcSpan -> m EpAnnComments #

Go through the `comment_q` in `PState` and remove all comments that come before or within the given span

allocateFinalCommentsP :: RealSrcSpan -> m EpAnnComments #

Go through the `comment_q` in `PState` and remove all comments that come after the given span

#### Instances

Instances details

MonadP P # |
Instance details Defined in GHC.Parser.Lexer Methods addError :: MsgEnvelope PsMessage -> P () # addWarning :: MsgEnvelope PsMessage -> P () # addFatalError :: MsgEnvelope PsMessage -> P a # getParserOpts :: P ParserOpts # allocateCommentsP :: RealSrcSpan -> P EpAnnComments # allocatePriorCommentsP :: RealSrcSpan -> P EpAnnComments # allocateFinalCommentsP :: RealSrcSpan -> P EpAnnComments #
MonadP PV # |
Instance details Defined in GHC.Parser.PostProcess Methods addError :: MsgEnvelope PsMessage -> PV () # addWarning :: MsgEnvelope PsMessage -> PV () # addFatalError :: MsgEnvelope PsMessage -> PV a # getParserOpts :: PV ParserOpts # allocateCommentsP :: RealSrcSpan -> PV EpAnnComments # allocatePriorCommentsP :: RealSrcSpan -> PV EpAnnComments # allocateFinalCommentsP :: RealSrcSpan -> PV EpAnnComments #

getBit :: MonadP m => ExtBits -> m Bool #

Check if a given flag is currently set in the bitmap.

getRealSrcLoc :: P RealSrcLoc #

getPState :: P PState #

failMsgP :: (SrcSpan -> MsgEnvelope PsMessage) -> P a #

failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> MsgEnvelope PsMessage) -> P a #

srcParseFail :: P a #

getPsErrorMessages :: PState -> Messages PsMessage #

Get a bag of the errors that have been accumulated so far. Does not take -Werror into account.

getPsMessages :: PState -> (Messages PsMessage, Messages PsMessage) #

Get the warnings and errors accumulated so far. Does not take -Werror into account.

popContext :: P () #

pushModuleContext :: P () #

setLastToken :: PsSpan -> Int -> P () #

setSrcLoc :: RealSrcLoc -> P () #

activeContext :: P Bool #

nextIsEOF :: P Bool #

getLexState :: P Int #

popLexState :: P Int #

pushLexState :: Int -> P () #

data ExtBits #

Various boolean flags, mostly language extensions, that impact lexing and parsing. Note that a handful of these can change during lexing/parsing.

Constructors

FfiBit |
InterruptibleFfiBit |
CApiFfiBit |
ArrowsBit |
ThBit |
ThQuotesBit |
IpBit |
OverloadedLabelsBit |
ExplicitForallBit |
BangPatBit |
PatternSynonymsBit |
HaddockBit |
MagicHashBit |
RecursiveDoBit |
QualifiedDoBit |
UnicodeSyntaxBit |
UnboxedParensBit |
DatatypeContextsBit |
MonadComprehensionsBit |
TransformComprehensionsBit |
QqBit |
RawTokenStreamBit |
AlternativeLayoutRuleBit |
ALRTransitionalBit |
RelaxedLayoutBit |
NondecreasingIndentationBit |
SafeHaskellBit |
TraditionalRecordSyntaxBit |
ExplicitNamespacesBit |
LambdaCaseBit |
BinaryLiteralsBit |
NegativeLiteralsBit |
HexFloatLiteralsBit |
StaticPointersBit |
NumericUnderscoresBit |
StarIsTypeBit |
BlockArgumentsBit |
NPlusKPatternsBit |
DoAndIfThenElseBit |
MultiWayIfBit |
GadtSyntaxBit |
ImportQualifiedPostBit |
LinearTypesBit |
NoLexicalNegationBit |
OverloadedRecordDotBit |
OverloadedRecordUpdateBit |
OrPatternsBit |
ExtendedLiteralsBit |
ListTuplePunsBit |
ViewPatternsBit |
RequiredTypeArgumentsBit |
MultilineStringsBit |
LevelImportsBit |
InRulePragBit |
InNestedCommentBit |
UsePosPragsBit | If this is enabled, '{-# LINE ... -#}' and '{-# COLUMN ... #-}' update the internal position. Otherwise, those pragmas are lexed as tokens of their own.

#### Instances

Instances details

Enum ExtBits # |
Instance details Defined in GHC.Parser.Lexer Methods succ :: ExtBits -> ExtBits # pred :: ExtBits -> ExtBits # toEnum :: Int -> ExtBits # fromEnum :: ExtBits -> Int # enumFrom :: ExtBits -> [ExtBits] # enumFromThen :: ExtBits -> ExtBits -> [ExtBits] # enumFromTo :: ExtBits -> ExtBits -> [ExtBits] # enumFromThenTo :: ExtBits -> ExtBits -> ExtBits -> [ExtBits] #

xtest :: ExtBits -> ExtsBitmap -> Bool #

xunset :: ExtBits -> ExtsBitmap -> ExtsBitmap #

xset :: ExtBits -> ExtsBitmap -> ExtsBitmap #

disableHaddock :: ParserOpts -> ParserOpts #

lexTokenStream :: ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult [Located Token] #

mkParensEpToks :: RealSrcSpan -> (EpToken "(", EpToken ")") #

Given a `RealSrcSpan` that surrounds a `HsPar` or `HsParTy`, generate `EpToken` values for the opening and closing bordering on the start and end of the span

mkParensLocs :: RealSrcSpan -> (EpaLocation, EpaLocation) #

Given a `RealSrcSpan` that surrounds a `HsPar` or `HsParTy`, generate `EpaLocation` values for the opening and closing bordering on the start and end of the span

getCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments #

getPriorCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments #

getFinalCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments #

getEofPos :: P (Maybe (Pair RealSrcSpan RealSrcSpan)) #

commentToAnnotation :: RealLocated Token -> LEpaComment #

data HdkComment #

Haddock comment as produced by the lexer. These are accumulated in `PState` and then processed in GHC.Parser.PostProcess.Haddock. The location of the `HsDocString`s spans over the contents of the docstring - i.e. it does not include the decorator ("-- |", "{-|" etc.)

Constructors

HdkCommentNext HsDocString |
HdkCommentPrev HsDocString |
HdkCommentNamed String HsDocString |
HdkCommentSection Int HsDocString |

#### Instances

Instances details

Show HdkComment # |
Instance details Defined in GHC.Parser.Lexer Methods showsPrec :: Int -> HdkComment -> ShowS # show :: HdkComment -> String # showList :: [HdkComment] -> ShowS #

warnopt :: WarningFlag -> ParserOpts -> Bool #

Test whether a `WarningFlag` is set

addPsMessage :: MonadP m => SrcSpan -> PsMessage -> m () #