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.3 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 1A111BC69 for ; Wed, 30 May 2007 17:47:28 +0200 (CEST) Received: from server2.thinkcrime.de (server2.thinkcrime.de [213.133.110.149]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4UFlRkB009237 for ; Wed, 30 May 2007 17:47:27 +0200 Received: from hod-sarge-2005-10.lan.m-e-leypold.de (dslb-088-072-247-191.pools.arcor-ip.net [88.72.247.191]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server2.thinkcrime.de (Postfix) with ESMTP id D97D648800D for ; Wed, 30 May 2007 17:47:28 +0200 (CEST) Received: by hod-sarge-2005-10.lan.m-e-leypold.de (Postfix, from userid 1003) id D3F8E37BC9; Wed, 30 May 2007 17:56:35 +0200 (CEST) To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] scripting the toplevel References: <7D7BAFC8-9689-4985-B6AE-E83AB95398C4@research.att.com> Organization: Leypold, Software-Dienstleistungen und -Beratung From: "Markus E.L." Date: Wed, 30 May 2007 17:56:35 +0200 In-Reply-To: <7D7BAFC8-9689-4985-B6AE-E83AB95398C4@research.att.com> (Yitzhak Mandelbaum's message of "Wed, 30 May 2007 11:27:17 -0400") Message-ID: User-Agent: Some cool user agent (SCUG) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 465D9C8F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; toplevel:01 markus:01 gerd:01 stolpmann's:01 findlib:01 toplevel:01 lexing:01 toploop:01 fmt:01 toploop:01 fmt:01 markus:01 exception:01 caml-list:01 parse:02 I picked the following trick from Gerd Stolpmann's findlib; exception Toplevel_error of string;; let toplevel_exec s = let l = Lexing.from_string s in let ph = !Toploop.parse_toplevel_phrase l in let fmt = Format.make_formatter (fun _ _ _ -> ()) (fun _ -> ()) in if not (Toploop.execute_phrase false fmt ph) then raise (Toplevel_error s) ;; You can now do toplevel_exec "#load " ^ (String.escaped user_module) ^ ";;" Regards -- Markus