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
Re: [Caml-list] Calling Ocaml from Python
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Max Powers <max_powers280@h...>
Subject: Re: [Caml-list] Calling Ocaml from Python
>On Thu, 2004-04-29 at 13:49, skaller wrote:
>There is an Ocaml module in SWIG which may be useful to you.

Hmmm, forgive me if I'm totally off base with this, but I thought that SWIG 
was used to interface a C library to other languages. I.e. I can use SWIG to 
generate an interface to a c library so I can use that from Ocaml, rather 
than generating an interface to expose Ocaml functions to a C (or other) 
program. That reveals another option that I'd missed, I can write the parser 
in C (using the normal lex/yacc or even ANTLR!) and then provide both a 
python and Ocaml interface to that library.

>It sounds like you basically only need to call a single
>Ocaml parser function from Python to do the parsing which
>should be trivial.

Yeah, I think you're right (i.e. I think I can write the parser in Ocaml if 
required and it will be fairly simple). What I'm having trouble 
understanding is how to call the Ocaml function from python (i.e. how do I 
call any ocaml library function from python?).

>More difficult will be interpreting the parser output:
>that will be some Ocaml data structure like a parse tree
>you'll need to walk somehow from Python.
>On way to do that might be to get the Ocaml parse to
>build a parse tree made out of PyObjects.

Hmmm, very good point. Haven't thought about that yet... (I've got the 
feeling/hope that the output from the parser won't be too complex - should 
just be a few structs - after all, it's only a configuration file!).

Thanks for the help so far,

SEEK: Now with over 50,000 dream jobs! Click here:

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