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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id B2174BC69 for ; Wed, 30 May 2007 18:37:27 +0200 (CEST) Received: from server2.thinkcrime.de (server2.thinkcrime.de [213.133.110.149]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4UGbR2p005718 for ; Wed, 30 May 2007 18:37: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 3617448800D for ; Wed, 30 May 2007 18:37:27 +0200 (CEST) Received: by hod-sarge-2005-10.lan.m-e-leypold.de (Postfix, from userid 1003) id 24B2037BC9; Wed, 30 May 2007 18:46: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 18:46:35 +0200 In-Reply-To: (Markus E. L.'s message of "Wed, 30 May 2007 17:56:35 +0200") Message-ID: User-Agent: Some cool user agent (SCUG) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at discorde with ID 465DA847.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 suppresses:98 exception:01 caml-list:01 > 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'd probably want to have a different formatter at 'fmt = ...': This formatter just suppresses arror messages which was good enough for my purposes (extending the toplevel by some new directives :-) ). Regards -- Markus