Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Efficient C++ interfacing?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-06-06 (20:42)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Efficient C++ interfacing?
On Mon, 2004-06-07 at 04:44, Eray Ozkural wrote:
> On Sunday 06 June 2004 10:00, skaller wrote:

> >
> > (1) Flxcc can't parse C++ yet
> I had started writing a modern top-down C++ parser using the combinatorial 
> parser library Parsec in Haskell, but I had failed due to lack of time with 
> the project.

> There are freely available parser models [LL(k), not LR(k)] which 
> we can build upon. 

C++ *interfaces* can probably be parsed with LALR
tool like ocamlyacc. At least, I hope so!

The needs of a wrapper generator are considerably weaker
than a compiler. For example given the construction:

int x = expr;

we can parse 'expr' by as a list of tokens followed by semi.
We don't care about the RHS at all, we just need to know 'x'
is an 'int'.

Even if we can't quite parse everything, there are
ways a wrapper generator can handle that (eg just
ignore the declaration, and allow the user to fix
it by hand writing the wrapper for that function).

> > (2) Flxcc can't target Ocaml yet
> This one wouldn't be hard.

I agree, but I haven't tried it.

> So, you do have a rudimentary C++ parser?

I have a sophisticated C parser (frontc/Cil)
which handles GNU and MSVC extensions.

Extending frontc to handle C++ seems easy.
Cil converts the representation to one
more amenable to analysis. Hacking Cil
to accept the new constructors is harder.
For example it checks for redeclarations 
of functions:

void f();
void f() { printf("Hello world"); }

and knows there are the same .. but of course
C++ allows overloading.

> > What's needed is developers.

> Yes. However, doing this wrapper generator is considerably valuable. 

I agree. It would be a great boost for Ocaml I think.
And Ocaml people helping get it to work will also be
helping it to work for Felix .. 

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: