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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 64147BC0A for ; Tue, 17 Apr 2007 00:49:05 +0200 (CEST) Received: from hub.hrl.com (hub.hrl.com [208.179.241.200]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3GMn4Ji010094 for ; Tue, 17 Apr 2007 00:49:05 +0200 Received: from [192.27.172.110] (dangle.hrl.com [192.27.172.110]) by hpux03.hrl.com (iPlanet Messaging Server 5.2 HotFix 2.10 (built Dec 26 2005)) with ESMTP id <0JGM00LVQ4PR76@hpux03.hrl.com> for caml-list@inria.fr; Mon, 16 Apr 2007 15:49:03 -0700 (PDT) Date: Mon, 16 Apr 2007 15:49:03 -0700 From: Aleksey Nogin Subject: 3.10.0+beta: pa_macro vs Camlp4MacroParser [Was: "Not_found" from a custom camlp4 executable] In-reply-to: To: Caml List Cc: Nicolas Pouillard Reply-To: Caml List , Aleksey Nogin Message-id: <4623FD5F.30006@metaprl.org> Organization: MetaPRL/Mojave Research Group MIME-version: 1.0 Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7BIT User-Agent: Thunderbird 1.5.0.10 (X11/20070301) References: <4623DA8C.1000702@metaprl.org> X-Miltered: at concorde with ID 4623FD60.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 ocamlc:01 -thread:01 -custom:01 threads:01 lib:01 cmo:01 parsers:01 cmo:01 -linkall:01 syntax:01 syntax:01 parser:01 ifdef:01 On 16.04.2007 13:26, Nicolas Pouillard wrote: >> % ocamlc -g -thread -I -custom -o macroprint unix.cma threads.cma >> camlp4/camlp4lib.cma camlp4/Camlp4Printers/Camlp4OCamlPrinter.cmo >> camlp4/Camlp4Parsers/Camlp4OCamlParser.cmo Camlp4MacroParser.cmo >> camlp4/Camlp4Filters/Camlp4TrashRemover.cmo camlp4/Camlp4Bin.cmo -linkall > > You should add the revised grammar before the original one since the > original is a syntax extension of the revised. Thanks a lot for your lightning-fast response! Yes, this is what I was missing - and once I've added the revisied syntax parser to the list of odules to compile, things started working (sort of). Now that I can build it, I see that the "refactoring" of pa_macro into Camlp4MacroParser is, unfortunately, very broken in one important respect. In the pa_macro, the macro definitions inside an IFDEF were only collected while the body of IFDEF is parsed and were not executed until after the IFDEF is parsed and the condition is evaluated. In the "refactored" Camlp4MacroParser all the "DEFINE" directives are executed right away! So, what this means is that DEFINE TRUE;; IFDEF TRUE THEN DEFINE XYZ = 1 ELSE DEFINE XYZ = 2 ENDIF;; let xyz = XYZ;; would correctly result in "let xyz = 1" in pa_macro, but with Camlp4MacroParser, I get "let xyz = 2"! Also note that the item_or_def type that was responsible for collecting the "delayed" definitions in the pa_macro is no longer used in Camlp4MacroParser. Aleksey