On Fri, Apr 8, 2011 at 1:57 PM, Javier Pimás <elpochodelagente@gmail.com>wrote:
On Fri, Apr 8, 2011 at 1:08 PM, Alexandre Bergel <alexandre.bergel@me.com>wrote:
What is tricky with analyzing C are macros and preprocessors directive. srcML does a satisfactory job. But indeed, having a solution based on PetitParser is indeed promising.
Yes, and I don't know what to do, and would like to know if you or someone else have any idea of how to solve it. I will think some approach, but if you have some idea to share it would be better so I go directly to a good solution. I'm thinking that to feed the parser I'll have to preprocess the string with another parser, and make a string to string conversion by having a set of defines and paths so that #includes and #ifdefs work. But probably I'll need a cache because the generated string will be huge.
What do you think?
Can't macros and preprocessor directives be represented as just another nodes in the AST?
Regards, Javier.
Cheers, Alexandre
On 7 Apr 2011, at 23:53, Javier Pimás wrote:
by the way, the grammar is based on
http://www.quut.com/c/ANSI-C-grammar-l-1998.html
and
http://www.quut.com/c/ANSI-C-grammar-y.html
I'd be very grateful if you contribute to cover the full extent of it!
On Fri, Apr 8, 2011 at 12:37 AM, Javier Pimás < elpochodelagente@gmail.com> wrote: Hi, I took some time to start developing a C parser with PetitParser. I used the slides of the smalltalk school, they were pretty useful, and after some hours I have a very basic tokens scanner. The idea of this work is to be able to feed the parser with C headers and automagically get the C bindings done in smalltalk.
Now I have to actually start doing something with the scanned code. How should I do that, all in the same class? What if I want to generate bindings for different kinds of FFIs? Other question, how should I handle preprocessing? (now there isn't any kind of preprocessing)
You can see the code, download it and commit improvements to the repo at www.squeaksource.com/Bindings
Anybody who is interested is welcomed to help in the development!
Regards, Javier.
-- Javier Pimás Ciudad de Buenos Aires
-- Javier Pimás Ciudad de Buenos Aires
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- Javier Pimás Ciudad de Buenos Aires