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.1 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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D2C41BC69 for ; Tue, 12 Jun 2007 12:00:23 +0200 (CEST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5CA0Ij1008540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 12 Jun 2007 12:00:23 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 8D67653C75 for ; Tue, 12 Jun 2007 20:00:03 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12875-03 for ; Tue, 12 Jun 2007 20:00:03 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 707AF53C64 for ; Tue, 12 Jun 2007 20:00:02 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id D4625A0FFCB; Tue, 12 Jun 2007 20:00:02 +1000 (EST) Date: Tue, 12 Jun 2007 20:00:02 +1000 From: Pietro Abate To: ocaml ml Subject: old camlp4 quatations Message-ID: <20070612100002.GA32094@pulp.rsise.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at concorde with ID 466E6EB2.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 ocaml:01 parsing:01 syntax:01 mlast:01 ocaml:01 mlast:01 blog:98 blog:98 functions:01 grammar:01 printable:01 defined:02 ast:02 Hi all, suppose I want to use camlp4 to parse an ocaml program and output the same program in an other language. For the parsing part, I figured out, I've to copy the grammar that in part of the camlp4 distribution. For the output part I'd like to re-write part of the quotation system of camlp4 to output this new language. It's not exactly clear to me how I can work this out... This is my understanding: If I use the quotation module of camlp4, I can either return a string (ExStr) for expressions or patterns or a syntax tree (ExAst) that is defined in the module mLast. Once I've the AST, I've to pretty print it in the target language. Since the AST that is accepted by the quotation module is the ocaml ast, and assuming I can use the same ast for my language, the only thing to be done is to re-write the pp to output the my language... The printer for the ocaml ast is pr_o and the q_MLast module contains the manipulation functions to transform the ast into a printable form... Is this correct ? Do you know of any similar use of camlp4 that I can look at ? thanks :) p -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html