5

I'm trying to find a 70s or very early 80s source code of a Pascal pretty-printing program which is more advanced than the version mentioned on the Prettyprint wiki page which is undated and somewhat COBOL-like with procedures having definitions like

PROCEDURE GETCHAR( (* FROM *)      VAR INPUTFILE : TEXT;
                   (* UPDATING *)  VAR NEXTCHAR  : CHARINFO;
                   (* RETURNING *) VAR CURRCHAR  : CHARINFO );

For some reason I cannot compile it with online Free Pascal - apart form some unclear issue with the IN operator, the contemporary language does not support the intrinsic function GET (other Pascal compilers available online use Free Pascal as well, failing in similar ways).

With a few modifications, however, that pretty-printer compiles and works on the BESM-6 emulator, but the results are unsatisfactory, e.g. it sometimes inserts spaces between periods in array declarations, seemingly haphazardly:

type alfa = packed array [1..6] of char;x=array[1..2] of integer;
alfa2 = packed array [1..12] of char;
alfa22 = packed array [1..2] of alfa2;

becomes

TYPE ALFA = PACKED ARRAY [ 1 . . 6 ]  OF  CHAR ;
     X = ARRAY[1..2] OF INTEGER;
     ALFA2 = PACKED ARRAY [ 1 . . 12 ]  OF  CHAR ;
     ALFA22  = PACKED  ARRAY [  1 .  . 2  ]  OF   ALFA2 ;

Is there the source code of a better legacy Pascal pretty-printer?

Rationale:

I've decompiled the BESM-6 Pascal pretty-printer which performs some syntax checking and parses a few pseudo-comments, including one which is not understood by the BESM-6 Pascal compiler proper: specifically, Jx where x is a character which is taken literally to be the (optional) meta-character for the language keywords from now on.

Apart from recognizing the keywords and calling procedures handling the corresponding statements, most of the logic is not understood, and the variable names and procedures are non-mnemonic.

(Caveat lector: for reading convenience, begin/end are represented with { }, and the comments are bounded with (* and *); also, the code contains machine-specific details pertaining to the output file format with word-aligned lines of fixed width and compressed spaces.)

To facilitate restoring the source code closer to its original form, it would be nice to find a prototype of this program (which likely exists as there was no point adding support for non-existent pseudo-comment characters if the pretty-printer was written from scratch).

The programming manual mentions that the program was transferred to the Computing Center of the USSR Academy of Sciences by scientists from the GDR. That makes it even more likely that the program had a Western prototype.

7
  • 2
    I wrote pretty printing program for Turbo Pascal 5.0 around 1995 and I still have the source. It does formal compilation from pascal to nice pascal code (that is using grammar in external file) and I used it for long years regularry. There are some ASM sections to draw progress bars ovet TP screen, but they could be simply throw away. Are you interested in such source (source grammar included)?
    – gilhad
    Commented May 4, 2021 at 11:51
  • 1
    @gilhad Thank you, but not as much, because it is unlikely that it could help me to bring the decompiled source of the 1970s pretty printing program to readability. But you're welcome to put a link to it in the comments for completeness if it is already available on a public resource.
    – Leo B.
    Commented May 4, 2021 at 15:23
  • Sorry, I have it only in my local archives and I do not have permanent enought public place :(
    – gilhad
    Commented May 4, 2021 at 18:55
  • 1
    @gilhad No github? I highly recommend it.
    – Leo B.
    Commented May 4, 2021 at 18:59
  • 2
    Here is the file (AS IS) download.gilhad.cz/pretty.arj and will be there few weeks. I am sorry, it uses czech laguage mainly, and I did not touched it for many years. Should work anyway. There is more phases, where it makes PASCAL.LL1 from PASCAL.PAS where the grammar is defined - arrows right/left make indent/unindent, semicolon (;) to make new line and maybe some others formating helps. Also I found that it is for TP7.0 probabelly, enabling richer grammar. Cannot find older version :( License: Free/GPL/or anything, or as you feel it
    – gilhad
    Commented May 5, 2021 at 3:11

1 Answer 1

7

A few pretty-printers were published in the 13th Pascal Newsletter in 1978. The machine-readable text of a version of the one by Hueras and Ledgard is available on the SAILDART archive. (Also on SAILDART is an unrelated formatter named PFORM, although it might be fairly specific to the weird variety of PDP-10 Pascal used at Stanford.) The source code of a version of Condict's formatter can be found in this archive; search for “condict” to find it.

6
  • 1
    Thanks! The one mentioned on the wiki page I refer to is an older version by Hueras and Ledgard. I should try and see if it is better. It will take quite a while to convert that PFORM.PSC to conventional Pascal to experiment with it (the concept of "initprocedure" is particularly unusual) but at a cursory glance, its internal mechanisms are way different from the decompiled version. By the way, the compiler I'm experimenting with is the released version of the one mentioned on page 94 of the PDF.
    – Leo B.
    Commented May 4, 2021 at 1:25
  • 1
    @LeoB. Documentation for the the Pascal is available here.
    – texdr.aft
    Commented May 4, 2021 at 1:33
  • 1
    It looks like what I have decompiled is stylistically quite close to PASCAL PROGRAM FORMATTER by Michael Condict, starting on page 49 of the PDF. I wish there was a machine-readable text of it.
    – Leo B.
    Commented May 4, 2021 at 2:28
  • 1
    @LeoB. There seems to be a listing in this archive of source code, but there are many differences between it and the published version.
    – texdr.aft
    Commented May 4, 2021 at 3:57
  • 1
    Thank you; I now believe that this is indeed the prototype of the program I've decompiled: in addition to the overall similarity of the algorithm, there is similarity of the order of the procedures. Please add the link in your comment to the answer.
    – Leo B.
    Commented May 4, 2021 at 4:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .