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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A8139BBCA for ; Fri, 21 Mar 2008 16:06:41 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4CAC9s40dQRFuwdGdsb2JhbACRDgGZEQ X-IronPort-AV: E=Sophos;i="4.25,536,1199660400"; d="scan'208";a="9792501" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 21 Mar 2008 16:06:41 +0100 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 m2LF6TZ1022271 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 21 Mar 2008 16:06:41 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4CAC9s40dQRFuwdGdsb2JhbACRDgGZEQ X-IronPort-AV: E=Sophos;i="4.25,536,1199660400"; d="scan'208";a="9792500" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 21 Mar 2008 16:06:41 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1JcipM-0007jK-6B for caml-list@inria.fr; Fri, 21 Mar 2008 15:06:40 +0000 Date: Fri, 21 Mar 2008 15:06:40 +0000 To: caml-list@inria.fr Subject: camlp4 question: Mixing a printer and Ast.fold Message-ID: <20080321150639.GA29482@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 47E3CEF5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 gettext:01 camlp:01 ocaml:01 struct:01 gettext:01 syntax:01 sig:01 syntax:01 sig:01 struct:01 val:01 expr:01 expr:01 interf:01 I'm trying to translate Sylvain Le Gall's gettext module to use camlp4 from ocaml 3.10.0. The module is a printer which folds over the AST looking for certain types of function call by name. A simplified version is shown below. This program is supposed to look for all instances of a function named f applied to a string. I cannot for the life of me work out how to get this to compile. I've tried about a dozen different variations of the module names, 'open', 'include' etc. and got a dozen different errors. ---------------------------------------------------------------------- module Id = struct let name = "pr_gettext" let version = "$Id$" end module Make (Syntax : Camlp4.Sig.Syntax) : Camlp4.Sig.Printer(Syntax.Ast).S = struct module Loc = Syntax.Loc module Ast = Syntax.Ast class visitor = object inherit Ast.fold as super val t = [] method t = t method expr = function | <:expr@loc< f $str:singular$ >> -> let t = str :: t in {< t = t >} | e -> super#expr e end let print_interf ?input_file ?output_file _ = () let print_implem ?input_file ?output_file ast = let visitor = (new visitor)#str_item in let t = (visitor ast)#t in List.iter prerr_endline t end (* Register the new printer. *) module M = Camlp4.Register.Printer(Id)(Make) ---------------------------------------------------------------------- ocamlc -I +camlp4 -I /usr/lib64/ocaml/camlp4/Camlp4Parsers -pp camlp4of.opt camlp4lib.cma test.ml -o test.cmo File "test.ml", line 19, characters 19-19: Unbound constructor Ast.ExApp Please let me know how to compile this before I go mad... Rich. -- Richard Jones Red Hat