ghc-parser-0.1.3.0: Haskell source parser from GHC.

Safe HaskellNone

Language.Haskell.GHC.Parser

Synopsis

Documentation

runParser :: DynFlags -> Parser a -> String -> ParseOutput aSource

Run a GHC parser on a string. Return success or failure with associated information for both.

type LineNumber = IntSource

A line number in an input string.

type ColumnNumber = IntSource

A column number in an input string.

type ErrMsg = StringSource

An error message string.

data StringLoc Source

A location in an input string.

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

Eq a => Eq (ParseOutput a) 
Show a => Show (ParseOutput a) 

data Parser a Source

data Located a Source

Store locations along with a value.

Constructors

Located 

Fields

line :: LineNumber
 
unloc :: a
 

Instances

Functor Located 
Eq a => Eq (Located a) 
Show a => Show (Located a) 

removeComments :: String -> StringSource

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.