From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9f7c0fce90769654 X-Google-Attributes: gid103376,public From: lga@sma.ch (Laurent Gasser) Subject: Re: Ada Code Formatting Date: 1996/08/14 Message-ID: <4usgbrINNg8u@maz4.sma.ch>#1/1 X-Deja-AN: 174119606 distribution: world references: <839662036.6210.1@assen.demon.co.uk> organization: Swiss Meterological Institute keywords: formatter, nicer, Ada 83 reply-to: lga@sma.ch newsgroups: comp.lang.ada Date: 1996-08-14T00:00:00+00:00 List-Id: In article <839662036.6210.1@assen.demon.co.uk>, john@assen.demon.co.uk (John McCabe) writes: > campbelj@escmail.orl.mmc.com (campbell james b0159) wrote: > >I'm looking for a product that will re-format ada code written by > >different people so that the "style" is the same. > >Jim > > >James E. Campbell, Staff Systems Engineer > >Lockheed Martin Corporation, Information Systems, Orlando, FL > >407.306.7498 (voice) / 407.306.2303 (fax) > >mailto:campbelj@escmail.orl.mmc.com > > Try using emacs with ada-mode. It'll take some work as you have to go > through each file by hand, but it is reasonably configurable and works > quite well. > > If you want something more automatic there isn't a lot of choice but > nicer113 by Laurent Gasser available free from > > ftp://masg1.epfl.ch/pub/nicer113 > > Is one person's (fairly reasonable) attempt at this although you > probably need to compile it. > > Good luck > > > Best Regards > John McCabe > I must say it is not the only attempt at Ada 83 code formatting. Beside the compiler vendor tools (VADS as I read elsewhere) and Ada mode for Emacs, there are 5 others attempts in the Ada CD-ROM from Walnut Creek (Edition feruary 96, first disc, in folder "Ada/Asr/Prettyp/". I dont know for sure if the code I tried (descending.ada from Steven E. Nameroff) was taken from there. It is a top-down parser for Ada 83, dated July 15, 1983. It requires a legal source code to work and contains all the rules on which the formatter was built. I also tried to compile a version by Intermetrics. At browsing the code, it seems to have benefited from their experience at compiler writing. But the code was not self-sufficient (it required libraries I didn't bother to search or supply an equivalent). A third one called "Ada Pretty Printing Program" was written by Marlow Henne and Larry Neal in Pascal (dated July 2, 1985). I didn't try to compile it. My attempt, nicer113, is based upon a finite state machine with stack. The implementation is the only documentation of the formatting rules. It also tries to be a "weak" formatter. The same code with two different initial layouts may end in different layout. Essentially, it only expands the source when it judges that the layout is too compact. Sometimes, only a human programmer can decide which layout reads best. In comparision with descending.ada, nicer113 surprisingly runs around 5 times faster, and is more robust (accept code which is not legal Ada). So nicer is useful for early stages of the code writing (when things got cluttered but the code is not yet complete) and for person discovering Ada (it helps them to acquire a fairly readable style). But for comparision or archive purpose, a formatter like descending.ada seems more adequate. All in all, this should have been a "hot" topic around the time the language was defined (around '83-'85, I guess). The new standard Ada 95 could revive the topic. -- Laurent Gasser (lga@sma.ch) Computers do not solve problems, they execute solutions.