C++ parser
Jacob Carlborg
doob at me.com
Wed May 22 11:41:14 PDT 2013
On 2013-05-22 20:31, Jacob Carlborg wrote:
I accidentally sent the message too soon.
> On 2013-05-22 16:55, IgorStepanov wrote:
>
>> Seems pretty. What I need to do first to start work over C++ to D
>> handle? As I think, I'll need to generate to one C++ header one .cpp
>> glue file (with some hacking over header) and one .di file.
>
> I'm not sure on how to best bind C++ code to D. D can handle some parts
> of the C++ ABI, like classes and virtual functions. dlang.org contains
> some information:
>
> http://dlang.org/cpp_interface.html
There was a talk on the recent D conference about binding C++ code:
Reddit:
http://www.reddit.com/r/programming/comments/1eiku4/dconf_2013_day_1_talk_5_using_d_alongside_a_game/
Youtube:
http://www.youtube.com/watch?v=FKceA691Wcg
>> First goal
>> is a parse and syntax analyse of this header. Do libclang provide me
>> this functional?
Yes, libclang will lex, parse and do semantic analysis. You can then
walk the AST and do want you want with it. You need to indicate it's C++
you want to parse using the -x flag. You need to add C++ in the
"setupArguments" and "handleLanguage" functions. You can see that the
"handleLanguage" function already contains a "case" for C++. After that
you can put the C++ specific code in a new package: translator/cpp.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list