comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <condicma@bogon.pwfl.com>
Subject: Re: Gnat pretty printing
Date: 1998/12/11
Date: 1998-12-11T00:00:00+00:00	[thread overview]
Message-ID: <36714049.2C5CE298@pwfl.com> (raw)
In-Reply-To: 74on70$m9o$1@cnn.Princeton.EDU

> 
> As it turns out, I have an independent study project slated for next semester
> to reimplement the reformatting tool in AdaGIDE.  It is also available as
> a standalone tool, and will generate colorized RTF output.  Suggestions for
> requirements are welcome, although I don't promise to have the same
> preferences you do :-).  Send these to mcc@cs.usafa.af.mil
> 
> AdaGIDE is distributed with GNAT on Windows, beginning with version 3.10p,
> but the latest AdaGIDE is found at
> http://www.usafa.af.mil/dfcs/bios/mcc_html/adagide.html
> 
> The reformatter standalone is at:
> http://www.usafa.af.mil/dfcs/bios/mcc_html/ada_stuff.html
> 
> Of course, the best way to implement such a tool would be with ASIS rather
> than modifying the sources of GNAT.  We will NOT take this approach, however,
> because it is essential in our environment to be able to reformat code that
> will not compile, on a "as you go" basis during editing.
> 
For the record, the thing I typically dislike about pretty-printers is
that I like to span certain things across lines and want them to line up
in a predictable way. Formal parameter lists on procedure declarations
and named associations on procedure calls are the two most common areas
where I'd like spanned lines and tabs to make things line up. I don't
think I could write a formal requirements document for you in just a
couple of minutes, but here's an example of some code as I manually
format it:

    procedure Pop (
        Item            :    out Element_Ptr_Type ;
        List            : in out List_Type) is
        --
        Temp            : Link_Type         := null ;
    begin
        pragma Debug (
            Ada.Text_IO.Put_Line (
                File    => Ada.Text_IO.Current_Error,
                Item    => "UTIL.Tagged_Lists.Pop: ")) ;
        if (List.Length <= 0) then
            raise Underflow ;
        end if ;
        Temp            := List.First ;
        --
        List.First      := List.First.Next ;
        List.Current    := List.First ;
        List.Length     := List.Length - 1 ;
        List.Memory     := List.Memory -
            ((Temp.all'Size / System.Storage_Unit) +
                (Temp.Value.all'Size / System.Storage_Unit)) ;
        if (List.First = null) then
            --
            --  Empty list.
            --
            List.Last       := null ;
        end if ;
        --
        Item    := Temp.Value ;
        Dispose (
            X	=> Temp) ;
    exception
        when Storage_Error =>
            pragma Debug (
                Ada.Text_IO.Put_Line (
                    File    => Ada.Text_IO.Current_Error,
                    Item    => "UTIL.Tagged_Lists.Pop: Storage_Error."))
;
            raise Underflow ;
        when Constraint_Error =>
            pragma Debug (
                Ada.Text_IO.Put_Line (
                    File    => Ada.Text_IO.Current_Error,
                    Item    => "UTIL.Tagged_Lists.Pop:
Constraint_Error.")) ;
            raise Underflow ;
    end Pop ;


Notice specifically how the formal parameter list in/out, etc line up
with each parameter on a separate line. Also the procedure calls with
named association and the assignment statements with the := lining up. I
am not too terribly concerned about the capitalization/lower-case issues
since this is usually a toggleable option and you have to modify the
capitalization anyway for abbreviations. The main thing about my
formatting style is that it is extremely regular & predictable with a
visually pleasing alignment of related objects. I'm not sure it is
possible to codify all of the style into a program that would produce
the desired result in all cases, but even if it just got me close, I'd
be willing to patch it up manually when I considered the jobe done.

I hope this might give you a few good ideas. If you want to talk over
any ideas I'd be glad to help if I can.

MDC
-- 
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
Ph: 561.796.8997         Fx: 561.796.4669
***To reply, remove "bogon" from the domain name.***

"Transported to a surreal landscape, a young girl kills the first woman
she meets and then teams up with three complete strangers to kill
again."

        -- TV listing for the Wizard of Oz




  reply	other threads:[~1998-12-11  0:00 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-09  0:00 Gnat pretty printing Matt Tyler
1998-12-09  0:00 ` David C. Hoos
1998-12-09  0:00 ` Tom Moran
1998-12-09  0:00   ` dennison
1998-12-09  0:00     ` Tom Moran
1998-12-09  0:00 ` Marin David Condic
1998-12-09  0:00   ` David C. Hoos
1998-12-10  0:00   ` Martin C. Carlisle
1998-12-11  0:00     ` Marin David Condic [this message]
1998-12-12  0:00       ` Simon Wright
1998-12-14  0:00         ` dennison
1998-12-15  0:00         ` Marin David Condic
1998-12-15  0:00           ` dennison
1998-12-15  0:00             ` Marin David Condic
1998-12-16  0:00               ` Matthew Heaney
1998-12-16  0:00               ` dennison
1998-12-16  0:00                 ` Matthew Heaney
1998-12-16  0:00                 ` Chris Morgan
1998-12-18  0:00                   ` dewar
1998-12-17  0:00                 ` Dale Stanbrough
1998-12-15  0:00           ` Matthew Heaney
1998-12-15  0:00             ` Marin David Condic
1998-12-19  0:00               ` Lieven Marchand
1998-12-12  0:00       ` Robert A Duff
1998-12-13  0:00         ` Ehud Lamm
1998-12-15  0:00         ` Marin David Condic
1998-12-11  0:00     ` Michael F Brenner
1998-12-11  0:00       ` Bob Collins
1998-12-11  0:00       ` dewarr
1998-12-11  0:00       ` Stephane Barbey
1998-12-11  0:00       ` Bryce Bardin
1998-12-14  0:00     ` Robert I. Eachus
1998-12-21  0:00     ` BARDIN Marc
1998-12-09  0:00 ` dennison
1998-12-09  0:00 ` Steve O'Neill
1998-12-10  0:00   ` okellogg
1998-12-11  0:00     ` dewarr
replies disabled

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