Thread View: comp.lang.prolog
7 messages
7 total messages
Started by Joern Baier
Fri, 11 Sep 1992 09:14
pretty printer
Author: Joern Baier
Date: Fri, 11 Sep 1992 09:14
Date: Fri, 11 Sep 1992 09:14
15 lines
1002 bytes
1002 bytes
Hi! As the subject says it I'm looking for a pretty printer. It should read a source code and write it down in a nicer format. It should also be able to deal with comments and keep the vaiable names. I have been looking for it in the libraries but I think there is nothing appropriate. Thanx in advance, Joern -- Joern Baier (baier@forwiss.uni-passau.de) Jesuitengasse 9 __o D-W8390 Passau _ \<,_ Tel +49/851/35239 (_)/ (_)
Re: pretty printer
Author: Francois-Michel Lang
Date: Fri, 11 Sep 1992 13:26
Date: Fri, 11 Sep 1992 13:26
21 lines
1473 bytes
1473 bytes
In article <1992Sep11.091413.676@tom.rz.uni-passau.de> baier@forwiss.uni-passau.de (Joern Baier) writes: >As the subject says it I'm looking for a pretty printer. >It should read a source code and write it down in a nicer format. >It should also be able to deal with comments and keep the vaiable >names. I have been looking for it in the libraries but I think there is >nothing appropriate. A couple of years ago, when I was a heavy-duty Quintus Prolog user, Dave Bowen sent me a `C' program ppl.c written by Richard that does exactly what you want. I used it quite a bit, and it did quite well. I still have a copy, but I don't think I should post or e-mail it, because I'm not sure of its copyright status. Dave? Richard? Quintus? Can this program be shared? -- ------------------------------------------------------------------ Francois-Michel Lang (202) 752-6067 FAX: (202) 752-4463 alufml@fnma.com ............. Fannie Mae; Asset/Liability Strategy lang@linc.cis.upenn.edu ..... Dept of Comp & Info Science, U of PA
Re: pretty printer
Author: popx
Date: Fri, 11 Sep 1992 13:40
Date: Fri, 11 Sep 1992 13:40
42 lines
2208 bytes
2208 bytes
In article <1992Sep11.091413.676@tom.rz.uni-passau.de>, baier@forwiss.uni-passau.de (Joern Baier) writes: > Hi! > > As the subject says it I'm looking for a pretty printer. > It should read a source code and write it down in a nicer format. > It should also be able to deal with comments and keep the vaiable > names. I have been looking for it in the libraries but I think there is > nothing appropriate. > > Thanx in advance, > Joern > -- > Joern Baier (baier@forwiss.uni-passau.de) > I don't have a complete pretty-printer. However, the code that comes with my "Logic Programming Tutor" includes some of what you need to build one. There's a set of predicates (SDO.PL and SDO_OUTPUT.PL) which read the grammar of a language in a notation that's like DCGs augmented with formatting commands and generate Prolog predicates from it. Portability note: you'll need to be able to 'write' into lists or other structures. There's also a tokeniser and parser, built from the Richard O'Keefe one that comes with the Dec-10 library. This can read variable names. It ignores comments, but you could make it capture them and return them hooked onto the term in some way. I'm not sure what the best way to represent a term augmented in this way would be. You can FTP the code from packages/prolog-pd-software/tutor.tar.Z at src.doc.ic.ac.uk . It's a compressed TAR file, so fetch it in binary mode, and decompress then untar before using. If you do build a pretty-printer from these predicates, please send me a copy of it. General note: the library contains a lot of other code. See README in the aforenamed directory for a short list, CATALOGUE for a long one. I would like more contributions: the number I've been offered so far is very low compared with the amount of Prolog code that exists. Jocelyn Paine
Re: pretty printer
Author: Paul Singleton
Date: Fri, 11 Sep 1992 13:58
Date: Fri, 11 Sep 1992 13:58
30 lines
2139 bytes
2139 bytes
From article <1992Sep11.091413.676@tom.rz.uni-passau.de>, by baier@forwiss.uni-passau.de (Joern Baier):
> As the subject says it I'm looking for a pretty printer.
> It should read a source code and write it down in a nicer format.
> It should also be able to deal with comments and keep the vaiable
> names. I have been looking for it in the libraries but I think there is
> nothing appropriate.
I want a pretty-printer wherein I can implement my own preferred layout of
source code. I think this requires a full parser which keeps variable
names *and* the whitespace (and comments) which are adjacent to each token.
I'd be thrilled if someone put one in the public domain.
I think I could make Prolog source code more readable by using different
fonts, or font variations (I mean bold, italic etc.), and by using subscripts
for related variables, e.g. p(Cs0, Cs1). In fact I am fed up with using
ASCII for my programs when I can use lotsa goodies (some say too many :-)
to make my other writings more readable. Have you noticed how Pascal text
books often use *bold* for the reserved words, erroneously suggesting that
they are distinct e.g. in the way that Algol 68 keyword symbols were. Tut.
So in future I shall compose my Prolog source files using FrameMaker or
some such. As long as all I/O (including that of the debugger) is user-
-configurable, I should be able to preserve the illusion of a Prolog system
which converses in a script much richer than ASCII. Any takers?
----
__ __ Paul Singleton (Mr) JANET: paul@uk.ac.keele.cs
|__) (__ Computer Science Dept. other: paul@cs.keele.ac.uk
| . __). Keele University, Newcastle, tel: +44 (0)782 621111 x7355
Staffs ST5 5BG, ENGLAND fax: +44 (0)782 713082
Re: pretty printer
Author: Michael A. Covington
Date: Fri, 11 Sep 1992 15:21
Date: Fri, 11 Sep 1992 15:21
20 lines
1151 bytes
1151 bytes
By all means let's work on it!
What we need is, as Paul Singleton says, a parser that parses Prolog and
also preserves white space, or at least comments.
I propose: boldface for functors
roman for variable names
Courier for quoted strings ('this' and "this")
italics for comments
Output formats: LaTeX
Word Perfect without header (simple)
perhaps others
First of all, does someone have the appropriate parser? It should be a
very minor modification of an ordinary Prolog parser.
--
+ Michael Covington - Artificial Intelligence Programs - U of Georgia - USA
+ Unless otherwise noted, these are private opinions, not official statements.
Re: pretty printer
Author: popx
Date: Fri, 11 Sep 1992 16:18
Date: Fri, 11 Sep 1992 16:18
44 lines
2791 bytes
2791 bytes
In article <4053@keele.keele.ac.uk>, csa09@seq1.keele.ac.uk (Paul Singleton) writes: > From article <1992Sep11.091413.676@tom.rz.uni-passau.de>, by baier@forwiss.uni-passau.de (Joern Baier): > >> As the subject says it I'm looking for a pretty printer. >> It should read a source code and write it down in a nicer format. >> It should also be able to deal with comments and keep the vaiable >> names. I have been looking for it in the libraries but I think there is >> nothing appropriate. > > I want a pretty-printer wherein I can implement my own preferred layout of > source code. I think this requires a full parser which keeps variable > names *and* the whitespace (and comments) which are adjacent to each token. > I'd be thrilled if someone put one in the public domain. > See my previous posting (two messages earlier). You will need to do some work on the parser and tokeniser, but I think I'm entitled to allow you to grin a bit, at least. Post me a copy when you've finished. > I think I could make Prolog source code more readable by using different > fonts, or font variations (I mean bold, italic etc.), and by using subscripts > for related variables, e.g. p(Cs0, Cs1). In fact I am fed up with using > ASCII for my programs when I can use lotsa goodies (some say too many :-) > to make my other writings more readable. Have you noticed how Pascal text > books often use *bold* for the reserved words, erroneously suggesting that > they are distinct e.g. in the way that Algol 68 keyword symbols were. Tut. > > So in future I shall compose my Prolog source files using FrameMaker or > some such. As long as all I/O (including that of the debugger) is user- > -configurable, I should be able to preserve the illusion of a Prolog system > which converses in a script much richer than ASCII. Any takers? > ---- > __ __ Paul Singleton (Mr) JANET: paul@uk.ac.keele.cs > About two years ago, someone posted a message about "Literate Prolog". They had written a Prolog equivalent of Web, and offered to put it in a central repository, should anyone provide space. I tried to get in touch with the author, but couldn't (mailer problems?). If, Mr. Literate Prolog, you are reading this, then perhaps you could contact me, and I'll add the code to my library. I think your address was something like steve!kelem!xilinx... Jocelyn Paine
Re: pretty printer
Author: Lindsey Spratt
Date: Fri, 11 Sep 1992 19:51
Date: Fri, 11 Sep 1992 19:51
32 lines
2153 bytes
2153 bytes
In article <1992Sep11.152125.5315@athena.cs.uga.edu> mcovingt@athena.cs.uga.edu (Michael A. Covington) writes: >By all means let's work on it! > >What we need is, as Paul Singleton says, a parser that parses Prolog and >also preserves white space, or at least comments. ... >First of all, does someone have the appropriate parser? It should be a >very minor modification of an ordinary Prolog parser. There was some discussion of this recently in this news group. It is difficult to handle comments "formally" in a parser for Prolog (or most any language), since the comments can appear anywhere whitespace can, yet have some semantic correspondence to the other syntactic element which the parser must maintain. The output formatting of comments can be quite tricky as well. Thus, I found a minor modification of an existing grammar to be inadequate and built a DCTG grammar from scratch. This system allows one to specify the formatting approach desired for handling the various operators (another tricky area), and it (optionally) reformats the comments into "canonical" locations with appropriately indented text. The target of this formatting system was ASCII files, so only ASCII output is handled (the other kinds of output could easily be added). Another issue here is that using a word processing system for final formatting can be a problem if the word processing system is going to choose the places to introduce new lines, and the way to indent the "new" line. Both of these decisions should be made in a syntax-sensitive fashion which the word processing system is unlikely to be able to do (except, perhaps, for the text of comments). -lindsey
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads