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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 7DA0BBC6C for ; Thu, 8 Nov 2007 01:25:07 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACvmMUfAXQImh2dsb2JhbACOewIBCAopgQ8 X-IronPort-AV: E=Sophos;i="4.21,387,1188770400"; d="scan'208";a="4173959" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 08 Nov 2007 01:25:07 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lA80OwnA029817 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 8 Nov 2007 01:25:07 +0100 X-IronPort-AV: E=Sophos;i="4.21,387,1188770400"; d="scan'208";a="5566178" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail3-relais-sop.national.inria.fr with SMTP; 08 Nov 2007 01:25:06 +0100 Received: by ausone.inria.fr (sSMTP sendmail emulation); Thu, _d Nov 2007 01:24:27 +0100 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] Which camlp variant? To: tmp123 References: <47320337.3030102@menta.net> In-Reply-To: <47320337.3030102@menta.net> Date: Thu, 08 Nov 2007 01:24:27 +0100 Message-Id: <1194480274-sup-1600@ausone.local> User-Agent: Sup/0.2 Content-Type: text/plain; charset=UTF-8 X-Miltered: at discorde with ID 4732575A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 val:01 printf:01 printf:01 camlp:01 lexing:01 lexing:01 stderr:01 token:01 token:01 parsing:01 parsing:01 caml-list:01 int:01 int:01 Excerpts from tmp123's message of Wed Nov 07 19:25:59 +0100 2007: > Hello, > > The module "pa_log" proposed by Mr. Conway seems very near to the > objective of my previuos post. > > The objective now is expand a line like: DEBUG 3 "%d\n" 14 > to: if debug.val then logint 3 ( fun () -> Printf.printf "%d\" 14 ) > else (); > > However, it is necessary to migrate the module to new camlpx . > > Please, could someone give any advice about the current options: camlp4 > or camlp5? PreCast? Functorial? I would recommend camlp4+PreCast because it's easier. However camlp4 already have a builtin module very similar (called Camlp4DebugParser). Here is a brief introduction... (* * No debugging code at all: * $ camlp4o -parser Camlp4DebugParser debug_extension.ml * true * Debugging code for lexing: * $ STATIC_CAMLP4_DEBUG='lexing' camlp4o -parser Camlp4DebugParser debug_extension.ml * let () = * if Camlp4.Debug.mode "lexing" * then Debug.printf "lexing" "TOKEN: Int %d" (2 * 21) * else () * in true * * Debugging code for lexing and parsing: * $ STATIC_CAMLP4_DEBUG='lexing:parsing' camlp4o -parser Camlp4DebugParser debug_extension.ml * let () = * if Camlp4.Debug.mode "lexing" * then Debug.printf "lexing" "TOKEN: Int %d" (2 * 21) * else () in * let () = * if Camlp4.Debug.mode "parsing" * then Debug.printf "parsing" "RULE: ..." * else () * in true * * Debugging code for any section: * $ STATIC_CAMLP4_DEBUG='*' camlp4o -parser Camlp4DebugParser debug_extension.ml * ... same output as above ... * * When you program is compiled you can use the CAMLP4_DEBUG variable to * activate some debugging sections. * * CAMLP4_DEBUG_FILE manage where messages goes (default is stderr). *) camlp4_debug lexing "TOKEN: Int %d" (2 * 21) in camlp4_debug parsing "RULE: ..." in true -- Nicolas Pouillard aka Ertai