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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 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 225C5BC69 for ; Mon, 24 Dec 2007 20:37:51 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.24,204,1196636400"; d="scan'208";a="5498015" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail2-relais-roc.national.inria.fr with SMTP; 24 Dec 2007 20:37:50 +0100 Received: by ausone.inria.fr (sSMTP sendmail emulation); Mon, _d Dec 2007 20:36:54 +0100 From: "Nicolas Pouillard" Content-Type: text/plain; charset=UTF-8 Cc: Arnaud Spiwack , caml-list Subject: Re: [Caml-list] OCamlduce + camlp4 To: Alain Frisch References: <476FBA62.9080600@lix.polytechnique.fr> <476FD855.9010800@frisch.fr> In-Reply-To: <476FD855.9010800@frisch.fr> Date: Mon, 24 Dec 2007 20:36:54 +0100 Message-Id: <1198524555-sup-6327@ausone.local> User-Agent: Sup/0.3 X-Spam: no; 0.00; ocamlduce:01 camlp:01 camlp:01 syntax:01 ocamlduce:01 syntax:01 parser:01 ocaml:01 ocaml:01 parsetree:01 parsetree:01 parser:01 lexers:01 cduce:01 lexing:01 Excerpts from Alain Frisch's message of Mon Dec 24 17:03:33 +0100 2007: > Arnaud Spiwack wrote: > > There I discovered that I couldn't find a camlp4 syntax file for > > OCamlduce (to be able to extend OCamlduce's syntax). In my case, I'd > > like an equivalent to camlp4orf (original syntax, but revised-syntax > > quotations) that handles OCamlduce syntax (though, original-syntax > > quotation would require little to change, thus would be all right). > > > > Does anybody know whether it already exists ? (maybe Alain or Nicolas ;) ). > > > > If it does not, I shall consider making one myself, but I will have to > > know better of the insides of OCamlduce. > > I'm not aware of a Camlp4 parser for OCamlduce (which probably means > that such a thing does not exist). It should not be difficult (only > quite boring) to write one. Of course, before writing the grammar, > you'll have to extend Camlp4's OCaml syntax tree with new constructions > and its translation to the real OCaml AST (Parsetree). Another way would be to treat {{...}} as some kind of quotation, and then by only using OCaml pretty printer (instead of the parsetree marshaller) where these quotation are printed as is. However this solution also have a cost, you will lose locations by not using marshalled parsetrees, so I won't really recommend this direction. > The OCamlDuce parser uses different lexers for the OCaml and CDuce > parts. This is done by switching lexing mode on a few tokens ( {{, {:, > :}, }}). It is possible to reproduce that with Camlp4 (you can plug an > arbitrary lexer). > > Let me know if you need more assistance on the OCamlDuce side... Let me know if you need more assistance on the Camlp4 side... > Good luck! You will need some. -- Nicolas Pouillard aka Ertai