comp.lang.ada
 help / color / mirror / Atom feed
From: lga@sma.ch (Laurent Gasser)
Subject: Re: Ada Code Formatting
Date: 1996/08/14
Date: 1996-08-14T00:00:00+00:00	[thread overview]
Message-ID: <4usgbrINNg8u@maz4.sma.ch> (raw)
In-Reply-To: 839662036.6210.1@assen.demon.co.uk


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 <john@assen.demon.co.uk>
> 

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.






  parent reply	other threads:[~1996-08-14  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-09  0:00 Ada Code Formatting campbell james b0159
1996-08-10  0:00 ` Robert Dewar
1996-08-10  0:00 ` Fergus Henderson
1996-08-10  0:00   ` Robert Dewar
1996-08-13  0:00     ` Keith Thompson
1996-08-13  0:00       ` James D. Veale
1996-08-10  0:00 ` John McCabe
1996-08-10  0:00   ` David Weller
1996-08-14  0:00   ` Laurent Gasser [this message]
1996-08-10  0:00 ` James D. Veale
1996-08-12  0:00 ` Ted Dennison
1996-08-14  0:00 ` Paul Hussein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox