From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by pauillac.inria.fr; Tue, 22 Mar 94 17:18:33 +0100 Received: from concorde.inria.fr by pauillac.inria.fr; Tue, 22 Mar 94 15:56:44 +0100 Received: from swan.cl.cam.ac.uk (pp@swan.cl.cam.ac.uk [128.232.0.56]) by concorde.inria.fr (8.6.8/8.6.6) with ESMTP id PAA09340 for ; Tue, 22 Mar 1994 15:56:31 +0100 Received: from auk.cl.cam.ac.uk (user jrh (rfc931)) by swan.cl.cam.ac.uk with SMTP (PP-6.5) to cl; Tue, 22 Mar 1994 14:56:04 +0000 To: caml-list@pauillac.inria.fr Cc: John.Harrison@cl.cam.ac.uk Subject: Installing parsers and printers Date: Tue, 22 Mar 94 14:55:52 +0000 From: John Harrison Message-Id: <"swan.cl.cam.:265930:940322145613"@cl.cam.ac.uk> Sender: weis@pauillac.inria.fr My interest in CAML is as a metalanguage for an embedded logic (which was of course ML's original application, hence the name). An important part of this is the provision of a nice interface to the user who still uses the toplevel loop, so I have two wishes: o I'd like to be able to install a custom printer to display objects of a nominated type (in the toplevel loop). I have a logic encoded as a recursive type. Of course this is unreadable in its raw form, and it's very tedious to have to call a prettyprinter explicitly. Ideally I'd like to be able to do something like: #install_printer "term" "term_printer";; (where `term_printer' is an ML function I have defined), and then have all objects of type `term' displayed using that printer. If something this clean is not possible I'm willing to dive into C if somebody can advise me on how to interface to the system. o I'd like to be able to set up some special quotation syntax to parse down to a nominated type automatically. I envisage something like: #install_parser "<<" ">>" "term_parser";; (where `term_parser' is an ML function I have defined). Thereafter if I type <<....>>, the system would call the parser on the string "...." and that would be the result of evaluation. If this is not possible, then I can survive by invoking a parser explicitly on a string. However I would really like to suppress recognition of escapes like "\n" in this string. Is there a clean way of forcing this, or does it necessitate patching the lexer? It is interesting to note that SML/NJ originally had no such facilities, but they have been added by Konrad Slind -- see his paper in the Second ML Workshop: "Object Language Embedding in Standard ML of New Jersey". I'd be grateful for any help, John.