From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA15297; Wed, 8 Jan 2003 03:31:37 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA15360 for ; Wed, 8 Jan 2003 03:31:36 +0100 (MET) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h082VZr10745 for ; Wed, 8 Jan 2003 03:31:35 +0100 (MET) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id DAA22934 for caml-list@inria.fr; Wed, 8 Jan 2003 03:31:35 +0100 Date: Wed, 8 Jan 2003 03:31:35 +0100 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] type problem with camlp4 Message-ID: <20030108033135.A22889@verdot.inria.fr> References: <20030107035710.GA15791@anu.edu.au> <20030107133947.B16891@verdot.inria.fr> <20030107223455.GA23238@anu.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030107223455.GA23238@anu.edu.au>; from Pietro.Abate@anu.edu.au on Wed, Jan 08, 2003 at 09:34:55AM +1100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Wed, Jan 08, 2003 at 09:34:55AM +1100, Pietro Abate wrote: > [[ n = STRING -> > let node = magic_function ( parse_string n ) in > let id = gen_id() in > (<:patt<$lid:id$>>,<:expr<$node$>>) > ]]; > > who can I do that ? what is the magic function ? let node = Grammar.Entry.parse Pcaml.expr (Stream.of_string n) in You may need to enclose that with a good "try..with" in case of syntax error in your string, because the error location raised would be relative to it, and would highlight a wrong position. Moreover, the resulting tree should be also re-located in case of semantic error for the same reason. Actually, it should be like the handling of quotations, but with that above function as expander. But the code doing that in Camlp4 is in several parts and may not be so easy to extract if you don't know the internal code of Camlp4. I can do it if you want and possibly add a new function in Camlp4 (module Pcaml) for that kind of usage. -- Daniel de RAUGLAUDRE http://cristal.inria.fr/~ddr/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners