Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!im4u!ut-sally!utah-cs!shebs From: shebs@utah-cs.UUCP Newsgroups: comp.lang.misc Subject: Re: Programmable pretty-printers? Message-ID: <4299@utah-cs.UUCP> Date: Mon, 16-Feb-87 11:14:10 EST Article-I.D.: utah-cs.4299 Posted: Mon Feb 16 11:14:10 1987 Date-Received: Tue, 17-Feb-87 05:47:04 EST References: <1704@enea.UUCP> Reply-To: shebs@utah-cs.UUCP (Stanley Shebs) Organization: University of Utah CS Dept Lines: 25 In article <1704@enea.UUCP> sommar@enea.UUCP(Erland Sommarskog) writes: >A programmable pretty-printer (PPP) is an idea that's been in my head for a >while and I have been thinking that I should write one if I ever get the >time. This isn't a reference to a particular program, but Dick Waters' paper "User Format Control in a LISP Prettyprinter" in the Oct 1983 TOPLAS (vol. 5, no. 4) is about how to do it in a Lisp context (although the idea could be applied to other languages). The main idea is to decouple formatting from printing and run each as a sort of coroutine. The interface is a stream of tokens, some of which represent literal objects, others mark required line breaks, while still others mark optional breaks. Then you have a user control that specifies how a given language construct is to be broken into these tokens. The specification syntax is a little ugly, but you probably wouldn't want to use it directly anyway... In any case, the hard part of prettyprinting is counting columns and fitting stuff, and this is handled by a module that doesn't need to know very much besides what to do with tokens. >Erland Sommarskog sommar@enea.UUCP >ENEA DATA, Stockholm stan shebs (shebs@cs.utah.edu)