language-c-0.9.4: Analysis and generation of C code
Copyright(c) 2008 Benedikt Huber
LicenseBSD-style
Maintainerbenedikt.huber@gmail.com
Stabilityexperimental
Portabilityghc
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.C.Parser

Description

Language.C parser

Synopsis

Simple API

parseC :: InputStream -> Position -> Either ParseError CTranslUnit Source #

parseC input initialPos parses the given preprocessed C-source input and returns the AST or a list of parse errors.

Parser Monad

data P a Source #

Instances

Instances details
MonadFail P Source # 
Instance details

Defined in Language.C.Parser.ParserMonad

Methods

fail :: String -> P a #

Applicative P Source # 
Instance details

Defined in Language.C.Parser.ParserMonad

Methods

pure :: a -> P a #

(<*>) :: P (a -> b) -> P a -> P b #

liftA2 :: (a -> b -> c) -> P a -> P b -> P c #

(*>) :: P a -> P b -> P b #

(<*) :: P a -> P b -> P a #

Functor P Source # 
Instance details

Defined in Language.C.Parser.ParserMonad

Methods

fmap :: (a -> b) -> P a -> P b #

(<$) :: a -> P b -> P a #

Monad P Source # 
Instance details

Defined in Language.C.Parser.ParserMonad

Methods

(>>=) :: P a -> (a -> P b) -> P b #

(>>) :: P a -> P b -> P b #

return :: a -> P a #

execParser :: P a -> InputStream -> Position -> [Ident] -> [Name] -> Either ParseError (a, [Name]) Source #

execute the given parser on the supplied input stream. returns ParseError if the parser failed, and a pair of result and remaining name supply otherwise

Synopsis: execParser parser inputStream initialPos predefinedTypedefs uniqNameSupply

execParser_ :: P a -> InputStream -> Position -> Either ParseError a Source #

run the given parser using a new name supply and builtin typedefs see execParser

Synopsis: runParser parser inputStream initialPos

Exposed Parsers

translUnitP :: P CTranslUnit Source #

translUnitP provides a parser for a complete C translation unit, i.e. a list of external declarations.

extDeclP :: P CExtDecl Source #

extDeclP provides a parser for an external (file-scope) declaration

statementP :: P CStat Source #

statementP provides a parser for C statements

expressionP :: P CExpr Source #

expressionP provides a parser for C expressions

Parser Monad

newtype ParseError Source #

Constructors

ParseError ([String], Position) 

Instances

Instances details
Show ParseError Source # 
Instance details

Defined in Language.C.Parser.ParserMonad