From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.4 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 6B62ABBC4 for ; Wed, 15 Apr 2009 18:46:01 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgcAACes5UnRVd14oWdsb2JhbACVWz8BAQEBAQEHCQoCBxGsJ5BGAQMBA4N7BoYp X-IronPort-AV: E=Sophos;i="4.40,192,1238968800"; d="scan'208";a="24644831" Received: from mail-qy0-f120.google.com ([209.85.221.120]) by mail2-smtp-roc.national.inria.fr with ESMTP; 15 Apr 2009 18:46:00 +0200 Received: by qyk26 with SMTP id 26so5381834qyk.1 for ; Wed, 15 Apr 2009 09:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to :content-type:content-transfer-encoding; bh=Xb309hDcv2nw5Zi5x1cCLB224+cxOPRrSxmNYA7/GO0=; b=kw1LL+ZCAskrDHquxt4qcaWcH/A0xw+bBalmO7HcnId6MafW7G6G8xQhJspg4TG4+w kUJxX4IiV+5BtnIuIYBDkZbSG7O/eIBwv+k3/idGpk07kmoS63latMEnzwXbtLDFjG54 p6MtO+gUU3dZduatPbDBc25YmoF9j5yEj73AE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=e83MlM4H9NknwsD05KHB6RQQc1g3py4kJSjS7NOQ3B/vsDdUdaWE58luR1LSIlIWex tdsnrZlp2TTgcOMaDR6Cymz4MCsYuTbCsFXza3ebq8dMgAE4ZEOnL5ylxi7MRbn7qxSv qPXv6VoGzRagS6vf8fxQR5XHefXpxsuaBOawU= MIME-Version: 1.0 Sender: jake.donham@gmail.com Received: by 10.224.80.195 with SMTP id u3mr966454qak.352.1239813959314; Wed, 15 Apr 2009 09:45:59 -0700 (PDT) In-Reply-To: <77D9D70A-15A4-400B-9035-D78D4AF85D67@gmail.com> References: <77D9D70A-15A4-400B-9035-D78D4AF85D67@gmail.com> From: Jake Donham Date: Wed, 15 Apr 2009 09:45:44 -0700 X-Google-Sender-Auth: 3d88d9800833d2ed Message-ID: Subject: Re: [Caml-list] antiquotations for c# To: "O'Caml Mailing List" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; camlp:01 parser:01 camlp:01 ocaml:01 ocaml:01 2009:98 javascript:98 javascript:98 wrote:01 caml-list:01 ast:02 ast:02 module:03 library:03 library:03 On Wed, Apr 15, 2009 at 1:49 AM, Joel Reymont 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