[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Guile Summer of Code project
Guile Summer of Code project
Thu, 20 Mar 2008 06:12:56 -0400
Thunderbird 188.8.131.52 (X11/20080305)
Hello everyone , how are you?
Considering that the GNU project is participating on the google summer
of code of this year, I am wondering if we could probably get a nice
Guile/Scheme project onto it.
Here I send a brief and general proposal about my project, a Guile C
Parser. A parser written on Scheme hooked up into Guile for parsing C files.
As I said, it is a very brief proposal, so, many implementations details
would still need to be figured out or might change on the road, but I
think it is detailed enough as to show what I am after with it.
Please let me know if you are interested on further information,
Thanks and Regards,
-- Title: Guile C Parser (GCP)
-- What is GCP?
GCP as its name stands, it is a parser for ANSI C code written on Scheme
to be included into Guile.
The main idea is to represent in a structured and modular way all the components
of a C source file into Guile.
This tool would allow to easily parser C headers files and generate
automatically Guile interfaces for their libraries among other things.
-- Design and Development
My initial idea is to give an object representation of a C source code file
from Guile, and implement from there on, functions and data types , probably
using GOOPS for many of this representation for easy handling of the C code
from Guile itself.
Briefly and general explained the project will consist initially of
the following Scheme modules:
This module contains the main Scheme procedures for parsing C code.
It should be an easy interface from the user point of view, though
very powerful in the other hand, because it will implement the core
For example, we can have a main entry function for the whole parser
(define (parser-c <string>)
This function would take a single string value containing a proper C
program or file and will be the responsible of building the complete
for the code returning either a:
a - GCP data structure. Something like an abstract syntax tree
wrapped around data structures to ease handle (we could
probably use GOOPS here).
b - An error message or structure spepcifying failure of
We could also include in this module handy things like for
example, different parsing modes for a C standard or language extension.
This module could be included in certain extent into c-parser.scm ,
nevertheless , considering the nature of the project and given the
representation I want to give to each components , I will probably have
to implement a lexer offering some kind of object representation
for tokens, so it probably make it worthy to have it in a different
It will contain also a main entry function like:
(define (lexer-c <string>)
Taking a string of proper C code, and returning lexems probably
wrapped in somekind of data types. It could also return a lexical error.
This function and module could be also used standalone , but practically
will be invoked from c-parser.scm through parse-c.
This module will contain the whole ANSI C code abstract syntax described
and represented in terms of Scheme structures. For example,
we can have here defined objects for the different C statements
(if, while ..) , the different structures (struct , enum ...).
It will also be the module containing a representation of all the
available standard ANSI types.
In general, this module will offer the mapping between the C
syntax and its Scheme equivalent, among the necessary data structures
(abstract data types/objects) to be handled by the rest of the modules.
This module will contain the fuctions to 'pretty print' output
of the parser and lexer. It might also contain functions for proper
visulation of the data structures of the syntax representation on
It will contain extra functions and objects. For example, we can
add here routines to extend the parser, like parser-c that instead
of taking a string value would take a whole file or C program directory,
it can also containg Guile-specific extensions.
Considering the previous brief and general description of this project,
I will take a schedule similar to the following:
- I would start designing the c-syntax.scm module, this could
take big part of the time , probably around 3 weeks, and it should
be in my opinion the first module, since it will contain the main
design desicions affecting the rest of the modules operations.
All the data structures handled by the rest of the program will
be described and implemented here.
- In 2 weeks could be greatly implemented the whole lexer.
- The parser will be the more complex and time consuming task.
I expect that its development takes at least 1 month and a half.
- The modules c-pretty and c-misc , depending of the needs could
take longer than expected, but something basic and usable
accomplishing their main functions could be done in around 3 weeks.
After this time, we should be able to have a very usable parser and framework,
that we can hook into Guile and start using very straight-forward.
-- Technical details:
I would fully implement this code using latest 1.8 Guile version
(by the time of this writing 1.8.4).
-- Community benefits.
Scheme is a small programming language , with a very loyal community
who has been able to deploy Scheme through many fields.
Guile is a particular Scheme project intended to make available such a
language as an embeddable library into other applications, mainly
coded on C.
Therefore, being able to parse and access C code from Scheme/Guile itself,
and handling such a code like any other Scheme object would clearly
benefit the community opening many new possibilities.
For example, creating Guile bindings through a foreign function generator
using the parser on headers for popular C libraries and applications
would be plain easy.
This project can also greatly help with the internals, analyzing and
checking proper C code using Guile.
- Guile Summer of Code project,
Luis Araujo <=