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.0 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 0F8F1BC6C for ; Fri, 27 Jul 2007 15:52:45 +0200 (CEST) Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.180]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6RDqhm6009923 for ; Fri, 27 Jul 2007 15:52:44 +0200 Received: by ik-out-1112.google.com with SMTP id b35so782203ika for ; Fri, 27 Jul 2007 06:52:43 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=mXDDE9wlhFNr99WRh16UQcRe3LHmakgbx7LR/qZIFkUA8LwK2tdah2cY1o7WHue2B+Iwk508LH4YdENKRaDGg6su9pyqq/+WCN3P2S57YooiuARjFveqy+EBeRQeph9tSNf9JjZTn5r5DuNojxdaEZxqerK1zYLJIyS7lWeeTLE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=c6zej+oxKCtasb1I0JHPSa/wNwufnWU4lfXTqjVG5LByIOpe5kV3+wFBCM4KbRfKSp5kFmrrMoKtc7/pcbs6y1ySuQwggVRuR4MN2JfYodhmEVVx0S1vqy8PBO2plNM/o4iGzA0KtQRxKryAF2eYux2lbRZ28vUQ36Mskwe9l1k= Received: by 10.78.150.7 with SMTP id x7mr753192hud.1185544363344; Fri, 27 Jul 2007 06:52:43 -0700 (PDT) Received: by 10.78.192.4 with HTTP; Fri, 27 Jul 2007 06:52:43 -0700 (PDT) Message-ID: <9b415f950707270652v61ce2302nd62ee5a2025cd09c@mail.gmail.com> Date: Fri, 27 Jul 2007 15:52:43 +0200 From: "Benedikt Grundmann" Sender: benedikt.grundmann@googlemail.com To: "Nicolas Pouillard" Subject: Re: [Caml-list] Question on camlp4 3.10 Cc: Caml-list In-Reply-To: <1185458485-sup-4306@ausone.inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9b415f950707260646v2dd6be3ds71a6d6ff3cd12fd8@mail.gmail.com> <1185457805-sup-9231@ausone.inria.fr> <9b415f950707260657v6f2f92c6s84e2334f8c34e137@mail.gmail.com> <1185458485-sup-4306@ausone.inria.fr> X-Google-Sender-Auth: 9b7b2143cf36a8b9 X-Miltered: at discorde with ID 46A9F8AB.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; grundmann:01 camlp:01 camlp:01 toplevel:01 ocaml:01 lib:01 toplevel:01 syntax:01 syntax:01 ocaml:01 rewriting:01 parser:01 parser:01 node:01 ctyp:01 Where can I find more documentation on camlp4 filter? I assumed that I should be able to use Camlp4FoldGenerator, but I already failed at importing it into the toplevel, to interactively explore it: bene@discworld:trunk$ rlwrap ocaml Objective Caml version 3.10.0 # #load "camlp4orf.cma";; Camlp4 Parsing version 3.10.0 # #load "camlp4lib.cma";; # open Camlp4.PreCast;; # class fold = Camlp4Filters.GenerateFold.generated;; [tons of #load camlp4*.cma which all didn't get me Camlp4Filters into the toplevel] And another question, how should one handle errors in a syntax extension? One of my syntax extension handles only part of the full ocaml type language, but instead of rewriting the type parser, I use the original parser and apply a function on the Camlp4.Ast, so sometimes I encounter a node in the ast that I cannot handle, what should I do then? Currently I do: match t with | <:ctyp< ... > -> ... | _ -> let _loc = Ast.loc_of_ctyp t in Printf.eprintf "pa_message: Don't know how to handle the type at %s\n%!" (Loc.to_string _loc); exit 1 But I'm sure that there is a better builtin way?! (For example it would be nice if I could include a textual representation of t in the error message) Thanks in advance, Bene 2007/7/26, Nicolas Pouillard : > Ah, sorry I didn't read the second part. It's a lot harder to have it correct > unless you completely ignore "open". You should do that with a Camlp4 filter, > that store the module path while traversing module declaration in a topdown > way. > > > > > 2007/7/26, Nicolas Pouillard : > > > Look at the Camlp4MacroParser extension, there is __FILE__. > > > > > > Excerpts from Benedikt Grundmann's message of Thu Jul 26 15:46:26 +0200 2007: > > > > How can I get the name of the module where my syntax extension is > > > > applied? For simplicity assume that I would like to write a MODULE > > > > macro similar to __FILE__ in c. > > > > > > > > shell> cat > test.ml > > > > let _ = print_endline MODULE > > > > > > > > shell> ./test > > > > Test > > > > shell> cat > test2.ml > > > > module M = > > > > struct > > > > let _ = print_endline MODULE > > > > end > > > > > > > > shell> ./test2 > > > > Test.M > > > > > > > > > > > > Cheers, > > > > > > > > Bene > > > > > > > > > > -- > > > Nicolas Pouillard aka Ertai > > > > > > > -- > Nicolas Pouillard aka Ertai > -- Calvin: I try to make everyone's day a little more surreal. (From Calvin & Hobbes)