On Fri, Apr 8, 2011 at 1:44 PM, Javier Pimás <elpochodelagente@gmail.com>wrote:
On Fri, Apr 8, 2011 at 2:05 AM, Ricardo Moran <richi.moran@gmail.com>wrote:
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.
Hi Javier,
That's a great project and I'm highly interested in it. I'm not experienced in PetitParser so I won't be a lot of help, but I'll give it a try.
excelent
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)
Maybe you already thought of this but what if you make your parser build some simple C AST and then you make specific visitors for each kind of FFI?
I didn't think of it because I never did a parser before and have no experience with PP. Is it the clean way to do it? How is that implented? maybe have for each expression in the bnf a class that represents it, and make PP create the instances?
Well, I have no experience with parsers, either. I just played with PP a little (I learned a lot by looking at PetitSmalltalk), and I'm currently using the visitor pattern to translate smalltalk to NXC. You know what they said: "if you have a hammer, then everything looks like a nail" so I'm probably biased towards this pattern :) I don't know if this is the clean way to do it, but I think it's clean enough for me :) I would implement it just as you said: a class for each expression, and make PP create the instances.
Cheers Richo
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