c-dsl-0.1.0.0: A higher level DSL on top of language-c

Safe HaskellNone

Language.C.DSL.Exp

Description

This module contians the DSL for writing CExprs. It doesn't export the orphan instance for IsString CExpr which can be found in Language.C.DSL.StringLike.

Synopsis

Documentation

str :: String -> CExprSource

Lift a Haskell string into a literal C string.

(==:) :: CExpr -> CExpr -> CExprSource

Comparison operators, normal haskell operators with : at the end.

(>=:) :: CExpr -> CExpr -> CExprSource

Comparison operators, normal haskell operators with : at the end.

(<=:) :: CExpr -> CExpr -> CExprSource

Comparison operators, normal haskell operators with : at the end.

(>:) :: CExpr -> CExpr -> CExprSource

Comparison operators, normal haskell operators with : at the end.

(<:) :: CExpr -> CExpr -> CExprSource

Comparison operators, normal haskell operators with : at the end.

(/=:) :: CExpr -> CExpr -> CExprSource

Comparison operators, normal haskell operators with : at the end.

ternary :: CExpr -> CExpr -> CExpr -> CExprSource

The ternary operator in C. ternary a b c will turn into a ? b : c.

var :: Ident -> CExprSource

A function mapping identifier in C to be used as variables. Normally this can be avoided since Language.C.DSL.StringLike provides an IsString instance.

(#) :: CExpr -> [CExpr] -> CExprSource

Function calls, f#[a, b, c] will become f(a, b, c). Note that f is also an expression.

(<--) :: CExpr -> CExpr -> CExprSource

The assignment operator. var <-- value will become var = value; in C.

assign :: CAssignOp -> CExpr -> CExpr -> CExprSource

This is the more generalized version of '(<--)'. It allows any CAssignOp to be passed in to facilitate writing a += b and similar.

data UnOp Source

A simplified unary operator type. It can be converted to Cs version using toCUnaryOp.

Constructors

PlusPlus 
MinusMinus 
Minus 
Plus 
Not 
Addr

The address of operator &.

Ind

The dereferencing operator in C *.

Instances

toCUnaryOp :: UnOp -> CUnaryOpSource

Convert a UnOp to the corresponding CUnaryOp.

pre :: UnOp -> CExpr -> CExprSource

Apply a unary operator prefix, op pre exp will transform into something like op exp in C. This only matters for PlusPlus and MinusMinus.

post :: CExpr -> UnOp -> CExprSource

The postfix equivalent of pre.

star :: CExpr -> CExprSource

A quick wrapper of pre Ind exp since it's so common.

comma :: [CExpr] -> CExprSource

The C comma operator, comma [a, b, c] is equivalent to a, b, c in C.

castTo :: CExpr -> CDecl -> CExprSource

Implements C style casts for expressions.

sizeOfDecl :: CDecl -> CExprSource

size of for types.

sizeOf :: CExpr -> CExprSource

size of for expressions. Carefully note that sizeOf someType will incorrectly treat someType as a variable, not a type.

(&) :: CExpr -> String -> CExprSource

Access a field of a struct, this C's . operator.

(&*) :: CExpr -> String -> CExprSource

The automatic dereferencing -> in C.

(!) :: CExpr -> CExpr -> CExprSource

This is the indexing operator in C, a ! i is a[i].