| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
GHC.Parser
Description
This module provides the generated Happy parser for Haskell. It exports a number of parsers which may be used in any library that uses the GHC API. A common usage pattern is to initialize the parser state with a given string and then parse that string:
runParser :: DynFlags -> String -> P a -> ParseResult a
runParser flags str parser = unP parser parseState
where
filename = "<interactive>"
location = mkRealSrcLoc (mkFastString filename) 1 1
buffer = stringToStringBuffer str
parseState = mkPState flags buffer location
Synopsis
- parseModule :: P (Located HsModule)
- parseSignature :: P (Located HsModule)
- parseImport :: P (LImportDecl GhcPs)
- parseStatement :: P (LStmt GhcPs (LHsExpr GhcPs))
- parseBackpack :: P [LHsUnit PackageName]
- parseDeclaration :: P (LHsDecl GhcPs)
- parseExpression :: P ECP
- parsePattern :: P (Located (Pat (GhcPass 'Parsed)))
- parseTypeSignature :: P (LHsDecl GhcPs)
- parseStmt :: P (Maybe (LStmt GhcPs (LHsExpr GhcPs)))
- parseIdentifier :: P (Located RdrName)
- parseType :: P (LHsType GhcPs)
- parseHeader :: P (Located HsModule)
- parseModuleNoHaddock :: P (Located HsModule)
Documentation
parseModule :: P (Located HsModule) #
Parse a Haskell module with Haddock comments. This is done in two steps:
parseModuleNoHaddockto build the ASTaddHaddockToModuleto insert Haddock comments into it
This is the only parser entry point that deals with Haddock comments.
The other entry points (parseDeclaration, parseExpression, etc) do
not insert them into the AST.
parseSignature :: P (Located HsModule) #
parseImport :: P (LImportDecl GhcPs) #
parseBackpack :: P [LHsUnit PackageName] #
parseDeclaration :: P (LHsDecl GhcPs) #
parseExpression :: P ECP #
parseTypeSignature :: P (LHsDecl GhcPs) #
parseIdentifier :: P (Located RdrName) #
parseHeader :: P (Located HsModule) #