Portability | portable |
---|---|
Stability | stable |
Maintainer | Niklas Broberg, d00nibro@chalmers.se |
- class Parseable ast where
- parse :: String -> ParseResult ast
- parseWithMode :: ParseMode -> String -> ParseResult ast
- parseWithComments :: ParseMode -> String -> ParseResult (ast, [Comment])
- data ParseMode = ParseMode {
- parseFilename :: String
- extensions :: [Extension]
- ignoreLanguagePragmas :: Bool
- fixities :: [Fixity]
- defaultParseMode :: ParseMode
- data ParseResult a
- = ParseOk a
- | ParseFailed SrcLoc String
- fromParseResult :: ParseResult a -> a
- parseModule :: String -> ParseResult (Module L)
- parseModuleWithMode :: ParseMode -> String -> ParseResult (Module L)
- parseModuleWithComments :: ParseMode -> String -> ParseResult (Module L, [Comment])
- parseExp :: String -> ParseResult (Exp L)
- parseExpWithMode :: ParseMode -> String -> ParseResult (Exp L)
- parseExpWithComments :: ParseMode -> String -> ParseResult (Exp L, [Comment])
- parsePat :: String -> ParseResult (Pat L)
- parsePatWithMode :: ParseMode -> String -> ParseResult (Pat L)
- parsePatWithComments :: ParseMode -> String -> ParseResult (Pat L, [Comment])
- parseDecl :: String -> ParseResult (Decl L)
- parseDeclWithMode :: ParseMode -> String -> ParseResult (Decl L)
- parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl L, [Comment])
- parseType :: String -> ParseResult (Type L)
- parseTypeWithMode :: ParseMode -> String -> ParseResult (Type L)
- parseTypeWithComments :: ParseMode -> String -> ParseResult (Type L, [Comment])
- getTopPragmas :: String -> ParseResult [OptionPragma L]
General parsing
class Parseable ast whereSource
Class to reuse the parse function at many different types.
parse :: String -> ParseResult astSource
Parse a string with default mode.
parseWithMode :: ParseMode -> String -> ParseResult astSource
Parse a string with an explicit mode.
parseWithComments :: ParseMode -> String -> ParseResult (ast, [Comment])Source
Parse a string with an explicit mode, returning all comments along the AST
Static parameters governing a parse.
Note that the various parse functions in Language.Haskell.Exts.Parser
never look at LANGUAGE pragmas, regardless of
what the ignoreLanguagePragmas
flag is set to.
Only the various parseFile
functions in Language.Haskell.Exts will
act on it, when set to False
.
ParseMode | |
|
defaultParseMode :: ParseModeSource
Default parameters for a parse.
The default is an unknown filename,
no extensions (i.e. Haskell 98),
don't ignore LANGUAGE pragmas,
and be aware of fixities from the Prelude
.
data ParseResult a Source
The result of a parse.
ParseOk a | The parse succeeded, yielding a value. |
ParseFailed SrcLoc String | The parse failed at the specified source location, with an error message. |
Monad ParseResult | |
Functor ParseResult | |
Applicative ParseResult | |
Show a => Show (ParseResult a) | |
Monoid m => Monoid (ParseResult m) |
fromParseResult :: ParseResult a -> aSource
Retrieve the result of a successful parse, throwing an error if the parse is actually not successful.
Parsing of specific AST elements
Modules
parseModule :: String -> ParseResult (Module L)Source
Parse of a string, which should contain a complete Haskell module.
parseModuleWithMode :: ParseMode -> String -> ParseResult (Module L)Source
Parse of a string containing a complete Haskell module, using an explicit mode.
parseModuleWithComments :: ParseMode -> String -> ParseResult (Module L, [Comment])Source
Parse of a string containing a complete Haskell module, using an explicit mode, retaining comments.
Expressions
parseExp :: String -> ParseResult (Exp L)Source
Parse of a string containing a Haskell expression.
parseExpWithMode :: ParseMode -> String -> ParseResult (Exp L)Source
Parse of a string containing a Haskell expression, using an explicit mode.
parseExpWithComments :: ParseMode -> String -> ParseResult (Exp L, [Comment])Source
Parse of a string containing a complete Haskell module, using an explicit mode, retaining comments.
Patterns
parsePat :: String -> ParseResult (Pat L)Source
Parse of a string containing a Haskell pattern.
parsePatWithMode :: ParseMode -> String -> ParseResult (Pat L)Source
Parse of a string containing a Haskell pattern, using an explicit mode.
parsePatWithComments :: ParseMode -> String -> ParseResult (Pat L, [Comment])Source
Parse of a string containing a complete Haskell module, using an explicit mode, retaining comments.
Declarations
parseDecl :: String -> ParseResult (Decl L)Source
Parse of a string containing a Haskell top-level declaration.
parseDeclWithMode :: ParseMode -> String -> ParseResult (Decl L)Source
Parse of a string containing a Haskell top-level declaration, using an explicit mode.
parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl L, [Comment])Source
Parse of a string containing a complete Haskell module, using an explicit mode, retaining comments.
Types
parseType :: String -> ParseResult (Type L)Source
Parse of a string containing a Haskell type.
parseTypeWithMode :: ParseMode -> String -> ParseResult (Type L)Source
Parse of a string containing a Haskell type, using an explicit mode.
parseTypeWithComments :: ParseMode -> String -> ParseResult (Type L, [Comment])Source
Parse of a string containing a complete Haskell module, using an explicit mode, retaining comments.
Option pragmas
getTopPragmas :: String -> ParseResult [OptionPragma L]Source
Partial parse of a string starting with a series of top-level option pragmas.