inline-c-0.5.3.0: Write Haskell source files including C code inline. No FFI required.

Safe HaskellNone
LanguageHaskell2010

Language.C.Types

Contents

Description

Views of C datatypes. While Language.C.Types.Parse defines datatypes for representing the concrete syntax tree of C types, this module provides friendlier views of C types, by turning them into a data type matching more closely how we read and think about types, both in Haskell and in C. To appreciate the difference, look at the difference between ParameterDeclaration and ParameterDeclaration.

As a bonus, routines are provided for describing types in natural language (English) -- see describeParameterDeclaration and describeType.

Synopsis

Types

data Sign Source

Constructors

Signed 
Unsigned 

Instances

Parsing

type IsTypeName = Identifier -> Bool Source

Function used to determine whether an Id is a type name.

type CParser m = (Monad m, Functor m, Applicative m, MonadPlus m, Parsing m, CharParsing m, TokenParsing m, LookAheadParsing m, MonadReader IsTypeName m) Source

All the parsing is done using the type classes provided by the parsers package. You can use the parsing routines with any of the parsers that implement the classes, such as parsec or trifecta.

The MonadReader with IsTypeName is required for parsing C, see http://en.wikipedia.org/wiki/The_lexer_hack.

runCParser Source

Arguments

:: Stream s Identity Char 
=> IsTypeName

Function determining if an identifier is a type name.

-> String

Source name.

-> s

String to parse.

-> ReaderT IsTypeName (Parsec s ()) a

Parser. Anything with type forall m. CParser m => m a is a valid argument.

-> Either ParseError a 

Runs a CParser using parsec.

quickCParser Source

Arguments

:: IsTypeName

Function determining if an identifier is a type name.

-> String

String to parse.

-> ReaderT IsTypeName (Parsec String ()) a

Parser. Anything with type forall m. CParser m => m a is a valid argument.

-> a 

Useful for quick testing. Uses "quickCParser" as source name, and throws an error if parsing fails.

quickCParser_ Source

Arguments

:: String

String to parse.

-> ReaderT IsTypeName (Parsec String ()) a

Parser. Anything with type forall m. CParser m => m a is a valid argument.

-> a 

Like quickCParser, but uses const False as IsTypeName.

Convert to and from high-level views

To english