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-07 (15:47)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Efficient C++ interfacing?
On Mon, 2004-06-07 at 13:04, Eray Ozkural wrote:

> You can skip code blocks, assignment statements, etc., but that means you have 
> to parse them. :) 

Indeed, but it is enough to do stuff like track matching
brackets to do that. The other tokens don't affect the parse
and just get dropped.

> My idea was that you first needed a complete C++ syntax 
> analyzer, and then you can build whatever minimal semantic analyzer you want 
> to. Here, we need just a (possibly) full C++ static type analyzer. I was 
> venturing in that direction and saw it was so much harder than C, naturally. 
> The C++ type system and *syntax* is a mess, especially with templates.

The syntactic problem itself isn't quite so bad. The real difficulty
is that you need to know, as in C, if a name is a type. In both
C and C++, this means keeping track of typenames. The difference
is that in C this is a simple dictionary lookup. In C++, with
overloading and namespaces and templates etc, the lookup rules are
quite nasty .. so the real problem is that you can't parse
without a structured symbol table and complex lookup rules.

>  Are there any decent combinatorial parser packages 
> for ocaml? (Or is ocaml not abstract enough to do that? *grin*)

Good question. Be nice to have some alternative parsers around.

> A parser generator that can cope with C++ adequately is most definitely a 
> great boost. As I said, I lack experience with the new features of SWIG, but 
> you seem to think it is inadequate. Have you tried it out with any real-world 
> C++ libs, does it have serious shortcomings?

The problem with SWIG for me isn't that it can't parse C++:
there are two problems:

(1) it isn't built for automation (wrapping many libraries
all at once).

(2) It can't dynamically load the SWIG felix module
and the developers won't put it in CVS, so it becomes
a nightmare to build.

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: