Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.
/cppppPublic archive

The C Preprocessor Preprocessor. Like quasi-quotation in C / Objective-C.

License

Notifications You must be signed in to change notification settings

mxswd/cpppp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

CPPPP

Experimental - Proof of concept

Description

Cpppp introduces "Quoted Initialisers" to C. Quoted initialisers are C initialisers that are executed before C compilation and the results substituted (similar to macros). For example:

intx=4; inty=2; intz= @|c_hs|"(+) %d %d"|x, y|;

Here we use the c_hs transformer to call Haskell's (+) function to add two C integers. Cpppp expands this initialiser out into a C foreign function interface call and a Haskell foreign function export.

This is not limited to FFI code generation, you can add your own code transformers! Simply implement the following data type:

dataTransform=foralla.Transform{_init::IOa , _trns::a->String-> [Id] ->SrcLoc->IO (a, Initializer) , _fin::a->IO()}

Using this, we can type check and perform code generate for SQL expressions, regex expressions, Auto Layout strings, etc. in C. Anything you might of used quasi-quotation for in Haskell.

Status

language-c-quote can not ingest macros yet, so it will not work for anything serious yet.

Dependencies

The following repos and branches are required to be cabal install-ed:

  • git@github.com:maxpow4h/language-c-quote.git branch: quoted-init

About

The C Preprocessor Preprocessor. Like quasi-quotation in C / Objective-C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published