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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 1ABAABBCA for ; Mon, 31 Mar 2008 13:27:33 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEACZn8EfAXQIm/2dsb2JhbACocg X-IronPort-AV: E=Sophos;i="4.25,582,1199660400"; d="scan'208";a="10872720" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 31 Mar 2008 13:27:32 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m2VBRW10023977 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 31 Mar 2008 13:27:32 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjkBABZo8EeDrhCRiGdsb2JhbACRRgEBAQ8mlmw X-IronPort-AV: E=Sophos;i="4.25,582,1199660400"; d="scan'208";a="8998520" Received: from smeltpunt.science.ru.nl ([131.174.16.145]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Mar 2008 13:27:27 +0200 Received: from tandem.cs.ru.nl (tandem.cs.ru.nl [131.174.142.18]) by smeltpunt.science.ru.nl (8.13.7/5.23) with ESMTP id m2VBRRA4010826 for ; Mon, 31 Mar 2008 13:27:27 +0200 (MEST) Received: from tews by tandem.cs.ru.nl with local (Exim 4.63) (envelope-from ) id 1JgIAh-0006Ob-5J for caml-list@inria.fr; Mon, 31 Mar 2008 13:27:27 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18416.51871.133886.196204@tandem.cs.ru.nl> Date: Mon, 31 Mar 2008 13:27:27 +0200 To: caml-list@inria.fr Subject: camlp4: str_item quotations for normal syntax X-Mailer: VM 7.19 under Emacs 21.4.1 From: Hendrik Tews X-Scanned-By: MIMEDefang 2.63 on 131.174.16.145 X-Miltered: at discorde with ID 47F0CAA4.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 syntax:01 hendrik:01 tews:01 tews:01 ocaml:01 syntax:01 compilation:01 struct:01 camlp:01 printf:01 printf:01 decls:01 expander:01 expr:01 Hi, I am trying to use (anti-) quotations for the normal ocaml syntax and run into the following problems: 1. when pattern matching over str_item, what's the antiquotation to use to get the list of all str_item's in a structure or in a compilation unit? One can use Ast.list_of_str_item, for instance | <:str_item@loc< module $uid:mname$ = struct $items$ end >> -> .... (Ast.list_of_str_item items) but what's the antiquotation for directly getting the list? I found str_items in Camlp4OCamlRevisedParser, and tried (match ast with | <:str_items< $list:tops$ >> -> Printf.printf "%s has %d top level decls\n" (opt_string input_file) (List.length tops)); but there is no quotation expander for str_items. Further, str_items appears in module_expr but not in implem or top_phrase. Why not? 2. Ast.list_of_str_item is defined but never used, right? I am guessing that there is a line missing in Camlp4QuotationCommon.ml, similar to the one with Ast.stSem_of_list. Right? 3. The str_item quotations for the ocaml syntax seem to produce always Ast.StSem(...,..., Ast.StNil...), for instance | <:str_item@loc< type $lid:name$ = $lid:oname$ >> -> gives | Ast.StSem (loc, (Ast.StTyp (_, (Ast.TyDcl (_, name, [], (Ast.TyId (_, (Ast.IdLid (_, oname)))), [])))), (Ast.StNil _)) -> What do I have to write in order to get just | Ast.StTyp (loc, (Ast.TyDcl (_, name, [], (Ast.TyId (_, (Ast.IdLid (_, oname)))), []))) -> as I get with the revised qotations? 4. What is the quotation for _just_ getting Ast.StSem(_,_,_) for instance for doing List.iter (function | Ast.StSem(_,_,_) -> assert false | ..... ) (Ast.list_of_str_item ....) 5. What is Register.OCamlPreCastPrinter good for? 6. I would be interested in contributing for a version of http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree for ocaml syntax. Nicolas, Matthieu: What would you prefer as best structure? A separate page with lots of duplication or one page for ocaml and revised syntax, possibly differentiating things with color? I tend to the latter. Bye, Hendrik