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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 860D2BC69 for ; Thu, 29 Mar 2007 11:48:56 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2T9mu4I019687 for ; Thu, 29 Mar 2007 11:48:56 +0200 Received: by ug-out-1314.google.com with SMTP id k3so524435ugf for ; Thu, 29 Mar 2007 02:48:55 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rOxUenQ54tVgD2k0gEWzw6Bkh/nMNQSlndVQSRuRukAoywObTyrr9zYYhoEIMoMmu71CTIwZUgJawuUxZhNcYLZf7CJJzhXuxewGWkSnF0vft03qahAf1IypvZuBPuVo06U5J1RBszgm1H4P0DJfhzJjuU1dIwGPnVM7t5dUq5c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=p9/PqorpBVrrnNqCDvQaGTW+U//0bC8JLrUmEQ9b9JB1KKZSlCYWuTJikoBUgzlD2V4K9k0ShY8L01ijxIkAkakAGvtdRERyPSC2vSnAeAqSz5Rc7SCHr34EptJy4dxgSAZmLDmRBKz1AUpLGCB1HLYuJPvGCCot+QL02JWWJPk= Received: by 10.114.176.1 with SMTP id y1mr165678wae.1175161734491; Thu, 29 Mar 2007 02:48:54 -0700 (PDT) Received: by 10.114.183.4 with HTTP; Thu, 29 Mar 2007 02:48:54 -0700 (PDT) Message-ID: Date: Thu, 29 Mar 2007 11:48:54 +0200 From: "Nicolas Pouillard" To: "Hendrik Tews" Subject: Re: [Caml-list] camlp4 3.10 questions Cc: caml-list@inria.fr In-Reply-To: <17930.60913.933794.204656@tandem.cs.ru.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <17930.60913.933794.204656@tandem.cs.ru.nl> X-j-chkmail-Score: MSGID : 460B8B88.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 460B8B88.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 hendrik:01 tews:01 tews:01 camlp:01 sig:01 syntax:01 sig:01 syntax:01 expr:01 expr:01 functors:01 howto:01 functor:01 lexer:01 On 3/29/07, Hendrik Tews wrote: > Hi, > > while doing my little camlp4 printer exercise I had the following > questions: > > 1. What is the difference between Register.Printer and > Register.OCamlPrinter? I guess it boils down to the difference > between Sig.Syntax and Sig.Camlp4Syntax? Yes it's mainly a difference about what your printer really needs. If you use the camlp4 AST then you need a Sig.Camlp4Syntax as argument, if it's not needed then you can use Sig.Syntax. The main point is about make thing re-usable. > 2. There are various maps and folds on asts in Sig.Camlp4Ast. How > can I use them? There two things: 1/ The generic classes map and fold for the camlp4 AST. You have to subclass it and override some cases to use it. Here is a filter that reduces 0 + x to x and x + 0 to x. open Camlp4.PreCast let f = object (self) inherit Ast.map as super method expr = function | <:expr< $x$ + 0 >> | <:expr< 0 + $x$ >> -> self#expr x | e -> super#expr e end in AstFilters.register_str_item f#str_item 2/ There is a lot of shortcuts to made the use of them easier when one just want to hook up only one thing (expressions for instance). The same example. open Camlp4.PreCast let f = Ast.map_expr begin function | <:expr< $x$ + 0 >> | <:expr< 0 + $x$ >> -> x | e -> e end in AstFilters.register_str_item f#str_item There is some interesting examples in camlp4/examples > 3. Register.declare_dyn_module puts all modules in a queue > together with a function that contains some delayed side > effects. Where are these function called? Camlp4Bin.ml > 4. I have the impression that the users Make functors (such as in > the printer HOWTO) are always applied to the same argument, > namely PreCast.Syntax. Why do I have to give a functor then? To make it re-usable. Imagine that you want a camlp4 with a different lexer, token type, or locations... By making some new modules binding them in a new MyCamlp4PreCast and then use printers, parsers syntax extensions, that just require a Sig.Syntax... > 5. I saw Camlp4OCamlOriginalQuotationExpander, presumably this is > a quotation expander for quotations in original syntax. Is > this already complete? Complete, not really but usable yes. > 6. There are various camlp4's: camlp4 camlp4o camlp4of camlp4oof > camlp4orf camlp4r camlp4rf camlp4boot camlp4prof. Could > somebody explain the nameing convention? f is for full, this means that many camlp4 extensions are already loaded (grammars, quotations, parsers, list comprehension...). > camlp4boot is the one used for bootstrapping or compiling the > camlp4 sources? Both. > What is camlp4prof? A profiling toy. > 7. Is there an equivalent to the old pa_o_fast.cmx? Nop :( > 8. How can I process multiple files with the same camlp4 process? As always ? -- Nicolas Pouillard