comp.lang.ada
 help / color / mirror / Atom feed
* Ada Code Formatting
@ 1996-08-09  0:00 campbell james b0159
  1996-08-10  0:00 ` Robert Dewar
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: campbell james b0159 @ 1996-08-09  0:00 UTC (permalink / raw)



Hi.

I'm looking for a product that will re-format ada code written by 
different people so that the "style" is the same.  We have some code
that was re-used from one project to the next, but in the process
was "cleaned up" by the second group; mostly indenting, spacing, etc.
that shouldn't really impact the code's function.

I would like to be able to do a diff on the code, but that's not 
possible the way it is right now.

Any ideas?

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  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 ` John McCabe
  1996-08-10  0:00   ` David Weller
  1996-08-14  0:00   ` Laurent Gasser
  1996-08-10  0:00 ` James D. Veale
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 12+ messages in thread
From: John McCabe @ 1996-08-10  0:00 UTC (permalink / raw)



campbelj@escmail.orl.mmc.com (campbell james b0159) wrote:

>Hi.

>I'm looking for a product that will re-format ada code written by 
>different people so that the "style" is the same.  We have some code
>that was re-used from one project to the next, but in the process
>was "cleaned up" by the second group; mostly indenting, spacing, etc.
>that shouldn't really impact the code's function.

>I would like to be able to do a diff on the code, but that's not 
>possible the way it is right now.

>Any ideas?

>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>





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  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-10  0:00 ` John McCabe
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Fergus Henderson @ 1996-08-10  0:00 UTC (permalink / raw)



campbelj@escmail.orl.mmc.com (campbell james b0159) writes:

>I'm looking for a product that will re-format ada code written by 
>different people so that the "style" is the same.  We have some code
>that was re-used from one project to the next, but in the process
>was "cleaned up" by the second group; mostly indenting, spacing, etc.
>that shouldn't really impact the code's function.
>
>I would like to be able to do a diff on the code, but that's not 
>possible the way it is right now.

I'd suggest getting GNU diff, and using `diff -w',
which ignores whitespace.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-10  0:00 ` John McCabe
@ 1996-08-10  0:00   ` David Weller
  1996-08-14  0:00   ` Laurent Gasser
  1 sibling, 0 replies; 12+ messages in thread
From: David Weller @ 1996-08-10  0:00 UTC (permalink / raw)



In article <839662036.6210.1@assen.demon.co.uk>,
John McCabe <john@assen.demon.co.uk> wrote:
>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.
>

Well, not quite.

There is an ada-reformat-batch.el file now supplied as part of the new
emacs ada-mode (2.21 and up, I believe; the latest is 2.23).  This
program will (obviously) reformat a whole group of files.

As a style comment:  Reformatting lots of (presumably already working)
Ada code is a time waster.  If you want to get a uniform appearance,
just reformat the specs.  The less you touch stable code, the higher
the reliability (ideal being touch count = 0 :-).



-- 
    Visit the Ada 95 Booch Components Homepage: www.ocsystems.com/booch
           This is not your father's Ada -- lglwww.epfl.ch/Ada




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Robert Dewar @ 1996-08-10  0:00 UTC (permalink / raw)



James said

"I'm looking for a product that will re-format ada code written by
different people so that the "style" is the same.  We have some code
that was re-used from one project to the next, but in the process
was "cleaned up" by the second group; mostly indenting, spacing, etc.
that shouldn't really impact the code's function.

I would like to be able to do a diff on the code, but that's not
possible the way it is right now."


Any decent diff program has an option to ignore white space, which will
cure a lot of the bogus differences.

You may still have problems from differences in line splitting, a lot
of diff programs do NOT have the capability of ignoring line feeds.

A diff program that worked only on Ada tokens would be useful





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-09  0:00 Ada Code Formatting campbell james b0159
                   ` (2 preceding siblings ...)
  1996-08-10  0:00 ` John McCabe
@ 1996-08-10  0:00 ` James D. Veale
  1996-08-12  0:00 ` Ted Dennison
  1996-08-14  0:00 ` Paul Hussein
  5 siblings, 0 replies; 12+ messages in thread
From: James D. Veale @ 1996-08-10  0:00 UTC (permalink / raw)



campbelj@escmail.orl.mmc.com (campbell james b0159) writes:
>I would like to be able to do a diff on the code, but that's not 
>possible the way it is right now.

>Any ideas?


From jdveale@world.std.com Sat Aug 10 14:16:16 1996
Date: Sat, 10 Aug 1996 14:14:44 -0400 (EDT)
From: "James D. Veale" <jdveale@world.std.com>
To: campbelj@escmail.orl.mmc.com
Cc: "James D. Veale" <jdveale@world.std.com>
Subject: Re: ada code formatting


> I would like to be able to do a diff on the code, but that's not 
> possible the way it is right now.
> 
> Any ideas?

 Another possibility is to use a smarter diff.  I sell a dos based
 comparison utility,  Complite, for programming language source.

 It performs a word-by-word comparison where words are separated not
 only by blanks,  but by common programming language delimiters.
 It is not only insensitive to changes in white space,  but can be 
 optionally insensitive to changes in text flow between lines.

 It's frequently quite good for the kind of changes you described.
 One exception is where a word formed from a contiguous sequence
 of delimiters such as ")+(" is split into three words separated
 by blanks ") + (" . 

 You may want to check my web page at:  http://world.std.com/~jdveale
 for more information.

     Jim Veale  -  jdveale@world.std.com






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-10  0:00 ` Fergus Henderson
@ 1996-08-10  0:00   ` Robert Dewar
  1996-08-13  0:00     ` Keith Thompson
  0 siblings, 1 reply; 12+ messages in thread
From: Robert Dewar @ 1996-08-10  0:00 UTC (permalink / raw)



Fergus said

"I'd suggest getting GNU diff, and using `diff -w',
which ignores whitespace."

(to compare reformatted sources)

This does not work fully, since, as I mentioned in a previous post, most
diff programs, inclufding GNU diff, do not ignore line feeds, so if the
reformatting involves changing the position of line feeds, as is common,
this will not be sufficient to suppress the effects of reformatting.

Also, if comments have been reformatted, the sequence of non-blank characters
changes, since the -- appears at different places.

A useful utility would be an Ada specific diff, with an option to ignore
white space, ignore line changes, ignore reformatting of comments, or
igore comments completely.

(it could even consider ABC and abc to be the same optionally, or
10 and 2#1010#)

So there's a nice little project for someone in an enthusiastic mood!





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-09  0:00 Ada Code Formatting campbell james b0159
                   ` (3 preceding siblings ...)
  1996-08-10  0:00 ` James D. Veale
@ 1996-08-12  0:00 ` Ted Dennison
  1996-08-14  0:00 ` Paul Hussein
  5 siblings, 0 replies; 12+ messages in thread
From: Ted Dennison @ 1996-08-12  0:00 UTC (permalink / raw)



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.  We have some code
> that was re-used from one project to the next, but in the process
> was "cleaned up" by the second group; mostly indenting, spacing, etc.
> that shouldn't really impact the code's function.
> 

Since these folks are in my building, I walked over and went over this in person.
It turns out that they are using VADS (among other compilers), so the a.pr
command in the VADS system does what they want.

-- 
T.E.D.          
                |  Work - mailto:dennison@escmail.orl.mmc.com  |
                |  Home - mailto:dennison@iag.net              |
                |  URL  - http://www.iag.net/~dennison         |




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-10  0:00   ` Robert Dewar
@ 1996-08-13  0:00     ` Keith Thompson
  1996-08-13  0:00       ` James D. Veale
  0 siblings, 1 reply; 12+ messages in thread
From: Keith Thompson @ 1996-08-13  0:00 UTC (permalink / raw)



In <dewar.839723478@schonberg> dewar@cs.nyu.edu (Robert Dewar) writes:
[...]
> A useful utility would be an Ada specific diff, with an option to ignore
> white space, ignore line changes, ignore reformatting of comments, or
> igore comments completely.
> 
> (it could even consider ABC and abc to be the same optionally, or
> 10 and 2#1010#)
> 
> So there's a nice little project for someone in an enthusiastic mood!

A simpler, and nearly as useful, utility would translate its Ada input
into individual tokens and print them one per line.  So, for example,
this input:

    with Text_IO;
    procedure Hello is -- a comment
    begin
	Text_IO.Put_Line("Hello");
    end Hello;

would yield this output:

    with
    text_io
    ;
    procedure
    hello
    is
    begin
    text_io
    .
    put_line
    (
    "Hello"
    )
    ;
    end
    hello
    ;

You could then run two versions of an Ada source through this relatively
simple filter and compare the outputs.  If they compare equal, there is
no semantically significant difference between the original sources.
If they don't, finding where in the original sources the differences
occur is left as an exercise.

-- 
Keith Thompson (The_Other_Keith) kst@thomsoft.com <*>
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
"As the most participatory form of mass speech yet developed, the Internet
deserves the highest protection from government intrusion." -- ACLU v. Reno




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-13  0:00     ` Keith Thompson
@ 1996-08-13  0:00       ` James D. Veale
  0 siblings, 0 replies; 12+ messages in thread
From: James D. Veale @ 1996-08-13  0:00 UTC (permalink / raw)



kst@thomsoft.com (Keith Thompson) writes:
>A simpler, and nearly as useful, utility would translate its Ada input
>into individual tokens and print them one per line.  So, for example,
>this input:

>    with Text_IO;
>    procedure Hello is -- a comment
>    begin
>	Text_IO.Put_Line("Hello");
>    end Hello;

>would yield this output:

>    with
>    text_io
>    ;
>    procedure
>    hello
>    is
>    begin
>    text_io
>    .
>    put_line
>    (
>    "Hello"
>    )
>    ;
>    end
>    hello
>    ;

>You could then run two versions of an Ada source through this relatively
>simple filter and compare the outputs.  If they compare equal, there is
>no semantically significant difference between the original sources.
>If they don't, finding where in the original sources the differences
>occur is left as an exercise.

That's essentially what Complite does,  and what I mean by a word-by-word
comparison where words are separated by common programming language 
delimiters as well as blanks.  The results of the comparison are then
re-integrated into their original line-oriented form with changed words 
highlighted,  correlated scrolling between the two files etc. 

    Jim Veale





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-09  0:00 Ada Code Formatting campbell james b0159
                   ` (4 preceding siblings ...)
  1996-08-12  0:00 ` Ted Dennison
@ 1996-08-14  0:00 ` Paul Hussein
  5 siblings, 0 replies; 12+ messages in thread
From: Paul Hussein @ 1996-08-14  0:00 UTC (permalink / raw)



campbelj@escmail.orl.mmc.com (campbell james b0159) wrote:

>Hi.

>I'm looking for a product that will re-format ada code written by 
>different people so that the "style" is the same.  We have some code
>that was re-used from one project to the next, but in the process
>was "cleaned up" by the second group; mostly indenting, spacing, etc.
>that shouldn't really impact the code's function.

>I would like to be able to do a diff on the code, but that's not 
>possible the way it is right now.

>Any ideas?

>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

There is an ADA formatter avaialable from the NASA ADA archive.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada Code Formatting
  1996-08-10  0:00 ` John McCabe
  1996-08-10  0:00   ` David Weller
@ 1996-08-14  0:00   ` Laurent Gasser
  1 sibling, 0 replies; 12+ messages in thread
From: Laurent Gasser @ 1996-08-14  0:00 UTC (permalink / raw)



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.






^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1996-08-14  0:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
1996-08-10  0:00 ` James D. Veale
1996-08-12  0:00 ` Ted Dennison
1996-08-14  0:00 ` Paul Hussein

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