The Binding Generator C->Haskell : Implementation of Haskell Binding Modules : Grammar Rules
Previous: CPP Directives and Inline C Code
Next: The Haskell FFI Marshalling Library

2.13. Grammar Rules

The following grammar rules define the syntax of binding hooks:

hook     -> `{#' inner `#}'
inner    -> `import' ['qualified'] ident
	  | `context' ctxt
          | `type' ident
          | `sizeof' ident
          | `enum' idalias trans [`with' prefix] [deriving]
          | `call' [`pure'] [`unsafe'] idalias
	  | `fun' [`pure'] [`unsafe'] idalias parms
          | `get' apath
          | `set' apath
          | `pointer' ['*'] idalias ptrkind
          | `class' [ident `=>'] ident ident

ctxt     -> [`lib' `=' string] [prefix]
idalias  -> ident [(`as' ident | `^')]
prefix   -> `prefix' `=' string
deriving -> `deriving' `(' ident_1 `,' ... `,' ident_n `)'
parms    -> [verbhs `=>'] `{' parm_1 `,' ... `,' parm_n `}' `->' parm
parm     -> [ident_1 [`*' | `-']] verbhs [`&'] [ident_2 [`*'] [`-']]
apath    -> ident
          | `*' apath
          | apath `.' ident
          | apath `->' ident
trans    -> `{' alias_1 `,' ... `,' alias_n `}'
alias    -> `underscoreToCase' | `upcaseFirstLetter' | `downcaseFirstLetter'
          | ident `as' ident
ptrkind  -> [`foreign' | `stable'] ['newtype' | '->' ident]

Identifier ident follow the lexis of Haskell. They may be enclosed in single quotes to disambiguate them from C->Haskell keywords.


The Binding Generator C->Haskell : Implementation of Haskell Binding Modules : Grammar Rules
Previous: CPP Directives and Inline C Code
Next: The Haskell FFI Marshalling Library