Version française
Home     About     Download     Resources     Contact us    
Browse thread
antiquotations for c#
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jake Donham <jake@d...>
Subject: Re: [Caml-list] antiquotations for c#
On Wed, Apr 15, 2009 at 1:49 AM, Joel Reymont <joelr1@gmail.com> wrote:
> Suppose I have a camlp4 parser for C#.
>
> I want to include bits of C# in my code and end up with the AST.
>
> I want to have "holes" in the above AST to plug in values.
>
> I understand that antiquotations take car of filling the holes in the AST,
> any tips on implementing this, though?

Take a look at the trunk of ocamljs, and in particular the jslib
library, which does what you describe for Javascript:

 http://code.google.com/p/ocamljs/source/browse/#svn/trunk/src/jslib

The main thing to know is that you can use the Camlp4 MetaGenerator
module to lift a Javascript (C#) AST value to an OCaml AST value.
There is some other magic that I don't fully understand but was able
to get working by aping the quotation machinery for regular OCaml.

As an example of the use of this library see:

 http://code.google.com/p/ocamljs/source/browse/trunk/src/jscomp/jsgen.ml

Jake