Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Language.Haskell.GHC.Parser
Synopsis
- runParser :: DynFlags -> Parser a -> String -> ParseOutput a
- type LineNumber = Int
- type ColumnNumber = Int
- type ErrMsg = String
- data StringLoc = Loc LineNumber ColumnNumber
- data ParseOutput a
- data Parser a
- data Located a = Located {
- line :: LineNumber
- unloc :: a
- parserStatement :: Parser (Maybe (LStmt GhcPs (LHsExpr GhcPs)))
- parserImport :: Parser (LImportDecl GhcPs)
- parserDeclaration :: Parser (OrdList (LHsDecl GhcPs))
- parserTypeSignature :: Parser (Located (OrdList (LHsDecl GhcPs)))
- parserModule :: Parser (Located HsModule)
- parserExpression :: Parser (LHsExpr GhcPs)
- parsePragmasIntoDynFlags :: DynFlags -> FilePath -> String -> IO (Maybe DynFlags)
- removeComments :: String -> String
- layoutChunks :: String -> [Located String]
Documentation
runParser :: DynFlags -> Parser a -> String -> ParseOutput a Source #
Run a GHC parser on a string. Return success or failure with associated information for both.
type LineNumber = Int Source #
A line number in an input string.
type ColumnNumber = Int Source #
A column number in an input string.
A location in an input string.
Constructors
Loc LineNumber ColumnNumber |
data ParseOutput a Source #
Output from running a parser.
Constructors
Failure ErrMsg StringLoc | Parser failed with given error message and location. |
Parsed a | Parser succeeded with an output. |
Partial a (String, String) | Partial parser succeeded with an output. |
Instances
Show a => Show (ParseOutput a) Source # | |
Defined in Language.Haskell.GHC.Parser Methods showsPrec :: Int -> ParseOutput a -> ShowS # show :: ParseOutput a -> String # showList :: [ParseOutput a] -> ShowS # | |
Eq a => Eq (ParseOutput a) Source # | |
Defined in Language.Haskell.GHC.Parser Methods (==) :: ParseOutput a -> ParseOutput a -> Bool # (/=) :: ParseOutput a -> ParseOutput a -> Bool # |
Store locations along with a value.
Constructors
Located | |
Fields
|
removeComments :: String -> String Source #
Drop comments from Haskell source. Simply gets rid of them, does not replace them in any way.
layoutChunks :: String -> [Located String] Source #
Split an input string into chunks based on indentation. A chunk is a line and all lines immediately following that are indented beyond the indentation of the first line. This parses Haskell layout rules properly, and allows using multiline expressions via indentation.
Quasiquotes are allowed via a post-processing step.