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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 75B0ABC6B for ; Tue, 23 Oct 2007 11:40:15 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABJeHUfAXQImh2dsb2JhbACOVgIBCAop X-IronPort-AV: E=Sophos;i="4.21,316,1188770400"; d="scan'208";a="18504193" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 23 Oct 2007 11:40:17 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9N9eEUh025222 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 23 Oct 2007 11:40:14 +0200 X-IronPort-AV: E=Sophos;i="4.21,316,1188770400"; d="scan'208";a="3527079" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with SMTP; 23 Oct 2007 11:40:14 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Tue, _d Oct 2007 11:39:39 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] Camlp4 as a universal pre-processor ? To: David Teller References: <1193118873.7228.10.camel@Blefuscu> In-Reply-To: <1193118873.7228.10.camel@Blefuscu> Date: Tue, 23 Oct 2007 11:39:39 +0200 Message-Id: <1193131952-sup-5002@ausone.inria.fr> User-Agent: Sup/0.1 Content-Type: text/plain; charset=UTF-8 X-j-chkmail-Score: MSGID : 471DC17E.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 471DC17E.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 syntax:01 ocpp:01 non-ocaml:01 parser:01 cpp:01 trivial:01 syntax:01 ocaml:01 dependencies:01 ocaml's:01 lexer:01 wiki:01 untyped:01 Excerpts from David Teller's message of Tue Oct 23 07:54:33 +0200 2007: > Hello list, > I'm currently playing with camlp4 3.10. I've succeeded in making a > syntax extension to help me generate annotated trees, which is a good > start. > > Now, I understand that, by invoking ocpp, camlp4 may be used as a > pre-processor for non-OCaml language, which sounds interesting, for I > have need of pre-processing some parser generator input (at the moment, > menhir, but there are good chances I'll switch to Dypgen to get around > some limitations) to maintain consistency between the implementation and > the specifications. There are very good chances that I could do that > with cpp, as it's essentially trivial pre-processing, but I'd rather use > camlp4, if only to learn more about it. > > So, my question is: how do I write a pre-processor that doesn't depend > on the syntax of OCaml ? I'm hoping I can get away with one or two > quotations and one anti-quotation, but I have no clue how to register > these without adding dependencies to either OCaml's Original or Revised > syntax. Does anyone have any examples handy ? A way to start this is to just keep the lexer and provide a new grammar including quotations [2] and antiquotations. On the wiki [1] there is also a small but complete example of a grammar for the untyped lambda calculus with antiquotations [3], and also a tutorial of making a full parser with Camlp4 [4]. [1]: http://brion.inria.fr/gallium/index.php/Camlp4 [2]: http://brion.inria.fr/gallium/index.php/Quotation [3]: http://brion.inria.fr/gallium/index.php/Lambda_calculus_quotations [4]: http://brion.inria.fr/gallium/index.php/Full_parser_tutorial -- Nicolas Pouillard aka Ertai