add idea: improve automation of low-level C bindings generation

This commit is contained in:
micklat 2014-02-14 13:20:49 -08:00
parent efa28fa5c4
commit e4f3011c17
1 changed files with 29 additions and 0 deletions

View File

@ -303,6 +303,35 @@ We also currently lack a website which tracks packages similar to Hackage or npm
**Difficulty:** Medium **Difficulty:** Medium
**Mentor:** dom96 ([@dom96](http://github.com/dom96)) **Mentor:** dom96 ([@dom96](http://github.com/dom96))
___
#### improve the automation of low-level C bindings
**Desirable skills:** Knowledge of C
**Description**:
Nimrod's c2nim tool helps create nimrod bindings for C libraries. However, c2nim does not parse the whole C language, and is not currently supposed to import whole APIs into nimrod mechanically, but rather to serve as a starting point for manual definition of interfaces to C libraries. c2nim is particularly effective in dealing with C's preprocessor macros, but is
not currently capable of parsing many C header files.
Make c2nim accept more C declarations than it currently does, and produce corresponding Nimrod declarations. This can be done either by directly filling-in the missing capabilities, or by interfacing it with a mature tool for parsing C code, such as LLVM's CLang or the GCC-XML tool. If one of these tools is used, then it is expected that it would not suffice by itself, but rather augment the current c2nim parser, since these tools have their own limitations. A possible implementation might pass
the header file once through gcc-xml to parse C declarations, and would use the current c2nim parser on lines that start with '#' to parse preprocessor definitions. c2nim would then process the parsed headers and produce constants, types, macros and proc declarations similar to those that it produces now.
Although c2nim currently converts function implementations (and not only declarations), this functionality is outside the scope of this task.
**Tasks**:
Depending on the chosen implementation technique, the tasks would be either:
* detect individual deficiencies in c2nim support for .h files and fix them
or:
* interface with a feature-complete parser for C, such as that of GCC or CLANG.
* refactor c2nim so that it can generate declarations from the parsed output of the above parser, rather than directly from .h files as it currently does.
* combine the output from the previous task with the declarations that c2nim produces for preprocessor macros.
**Difficulty:** Medium
**Bonus Points:** support, in addition, a few common c++ constructs that c2nim does not currently support.
**Mentor:** Araq ([@Araq](http://github.com/Araq))
___ ___
#### Implement re2nim, a lexer generator for nimrod #### Implement re2nim, a lexer generator for nimrod