ghc-exactprint-0.4.0.0: ExactPrint for GHC

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.GHC.ExactPrint.Parsers

Contents

Description

This module rexposes wrapped parsers from the GHC API. Along with returning the parse result, the corresponding annotations are also returned such that it is then easy to modify the annotations and print the result.

Synopsis

Utility

withDynFlags :: (DynFlags -> a) -> IO a Source

Provides a safe way to consume a properly initialised set of DynFlags.

myParser fname expr = withDynFlags (\d -> parseExpr d fname expr)

data CppOptions Source

Constructors

CppOptions 

Fields

cppDefine :: [String]

CPP #define macros

cppInclude :: [FilePath]

CPP Includes directory

cppFile :: [FilePath]

CPP pre-include file

Module Parsers

parseModule :: FilePath -> IO (Either (SrcSpan, String) (Anns, Located (HsModule RdrName))) Source

This entry point will also work out which language extensions are required and perform CPP processing if necessary.

parseModule = parseModuleWithCpp defaultCppOptions

Note: ParsedSource is a synonym for Located (HsModule RdrName)

parseModuleWithCpp :: CppOptions -> FilePath -> IO (Either (SrcSpan, String) (Anns, Located (HsModule RdrName))) Source

Parse a module with specific instructions for the C pre-processor.

Basic Parsers

parseWith :: Annotate w => DynFlags -> FilePath -> P (Located w) -> String -> Either (SrcSpan, String) (Anns, Located w) Source

Wrapper function which returns Annotations along with the parsed element.