Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module partially reexports Language.Haskell.Exts.Parser with adaptations.
IMPORTANT: if you require compatiblity with ghc 7.8, you should use the
function listOf
for constructing ListOf
values!
Synopsis
- type ModuleHeadAndImports = ModuleHeadAndImports ()
- type PragmasAndModuleHead = PragmasAndModuleHead ()
- type PragmasAndModuleName = PragmasAndModuleName ()
- type ListOf = ListOf
- pattern ModuleHeadAndImports :: [ModulePragma] -> Maybe ModuleHead -> [ImportDecl] -> ModuleHeadAndImports ()
- pattern PragmasAndModuleHead :: [ModulePragma] -> Maybe ModuleHead -> PragmasAndModuleHead ()
- pattern PragmasAndModuleName :: [ModulePragma] -> Maybe ModuleName -> PragmasAndModuleName
- pattern ListOf :: forall a. [a] -> ListOf a
- listOf :: [a] -> ListOf a
- parse :: (Parseable (ast SrcSpanInfo), Functor ast) => String -> ParseResult (ast ())
- parseWithMode :: (Parseable (ast SrcSpanInfo), Functor ast) => ParseMode -> String -> ParseResult (ast ())
- parseModule :: String -> ParseResult Module
- parseModuleWithMode :: ParseMode -> String -> ParseResult Module
- parseModuleWithComments :: ParseMode -> String -> ParseResult (Module, [Comment])
- parseExp :: String -> ParseResult Exp
- parseExpWithMode :: ParseMode -> String -> ParseResult Exp
- parseExpWithComments :: ParseMode -> String -> ParseResult (Exp, [Comment])
- parsePat :: String -> ParseResult Pat
- parsePatWithMode :: ParseMode -> String -> ParseResult Pat
- parsePatWithComments :: ParseMode -> String -> ParseResult (Pat, [Comment])
- parseDecl :: String -> ParseResult Decl
- parseDeclWithMode :: ParseMode -> String -> ParseResult Decl
- parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl, [Comment])
- parseType :: String -> ParseResult Type
- parseTypeWithMode :: ParseMode -> String -> ParseResult Type
- parseTypeWithComments :: ParseMode -> String -> ParseResult (Type, [Comment])
- parseStmt :: String -> ParseResult Stmt
- parseStmtWithMode :: ParseMode -> String -> ParseResult Stmt
- parseStmtWithComments :: ParseMode -> String -> ParseResult (Stmt, [Comment])
- parseImportDecl :: String -> ParseResult ImportDecl
- parseImportDeclWithMode :: ParseMode -> String -> ParseResult ImportDecl
- parseImportDeclWithComments :: ParseMode -> String -> ParseResult (ImportDecl, [Comment])
- getTopPragmas :: String -> ParseResult [ModulePragma]
- unListOf :: ListOf a -> [a]
- newtype NonGreedy a = NonGreedy {
- unNonGreedy :: a
- defaultParseMode :: ParseMode
- fromParseResult :: ParseResult a -> a
- class Parseable ast
- data ParseResult a
- = ParseOk a
- | ParseFailed SrcLoc String
- data ParseMode = ParseMode {}
Documentation
type ModuleHeadAndImports = ModuleHeadAndImports () Source #
type PragmasAndModuleHead = PragmasAndModuleHead () Source #
type PragmasAndModuleName = PragmasAndModuleName () Source #
pattern ModuleHeadAndImports :: [ModulePragma] -> Maybe ModuleHead -> [ImportDecl] -> ModuleHeadAndImports () Source #
pattern PragmasAndModuleHead :: [ModulePragma] -> Maybe ModuleHead -> PragmasAndModuleHead () Source #
pattern PragmasAndModuleName :: [ModulePragma] -> Maybe ModuleName -> PragmasAndModuleName Source #
parse :: (Parseable (ast SrcSpanInfo), Functor ast) => String -> ParseResult (ast ()) Source #
parseWithMode :: (Parseable (ast SrcSpanInfo), Functor ast) => ParseMode -> String -> ParseResult (ast ()) Source #
parseModule :: String -> ParseResult Module Source #
parseModuleWithMode :: ParseMode -> String -> ParseResult Module Source #
parseModuleWithComments :: ParseMode -> String -> ParseResult (Module, [Comment]) Source #
parseExpWithMode :: ParseMode -> String -> ParseResult Exp Source #
parseExpWithComments :: ParseMode -> String -> ParseResult (Exp, [Comment]) Source #
parsePatWithMode :: ParseMode -> String -> ParseResult Pat Source #
parsePatWithComments :: ParseMode -> String -> ParseResult (Pat, [Comment]) Source #
parseDeclWithMode :: ParseMode -> String -> ParseResult Decl Source #
parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl, [Comment]) Source #
parseTypeWithMode :: ParseMode -> String -> ParseResult Type Source #
parseTypeWithComments :: ParseMode -> String -> ParseResult (Type, [Comment]) Source #
parseStmtWithMode :: ParseMode -> String -> ParseResult Stmt Source #
parseStmtWithComments :: ParseMode -> String -> ParseResult (Stmt, [Comment]) Source #
parseImportDeclWithComments :: ParseMode -> String -> ParseResult (ImportDecl, [Comment]) Source #
getTopPragmas :: String -> ParseResult [ModulePragma] Source #
Instances of Parseable
for NonGreedy a
will only consume the input
until a
is fully parsed. This means that parse errors that come later
in the input will be ignored. It's also more efficient, as it's fully lazy
in the remainder of the input:
>>>
parse (unlines ("module A where" : "main =" : repeat "blah")) :: ParseResult PragmasAndModuleHead
ParseOk (NonGreedy {unNonGreedy = PragmasAndModuleHead [] (ModuleName "A",Nothing,Nothing)})
(this example uses the simplified AST)
NonGreedy | |
|
Instances
defaultParseMode :: ParseMode #
Default parameters for a parse.
The default is an unknown filename,
no extensions (i.e. Haskell 98),
don't ignore LANGUAGE pragmas, do ignore LINE pragmas,
and be aware of fixities from the Prelude
.
fromParseResult :: ParseResult a -> a #
Retrieve the result of a successful parse, throwing an error if the parse is actually not successful.
Class providing function for parsing at many different types.
Note that for convenience of implementation, the default methods have
definitions equivalent to undefined
. The minimal definition is all of
the visible methods.
parser
Instances
data ParseResult a #
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. |
Instances
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 | |
|