comp.lang.ada
 help / color / mirror / Atom feed
* Re: Ada95 Pretty-Printers
       [not found] <339C58A6.4D5A@sprintmail.com>
@ 1997-06-10  0:00 ` Anonymous
  1997-06-10  0:00   ` John G. Volan
  1997-06-10  0:00 ` Samuel Mize
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 21+ messages in thread
From: Anonymous @ 1997-06-10  0:00 UTC (permalink / raw)



On Mon, 09 Jun 1997 12:25:26 -0700, "John G. Volan"
<johnvolan@sprintmail.com> wrote:

> Are there any pretty-printers out there for Ada95?  I'm looking for
> something that can serve as an alternative to the pretty-printer built
> into Rational's Apex.  Apex is frustrating because it actively reformats
> almost every syntactic structure in Ada to suit Rational's coding style.
> This style is based on the LRM, but it does certain things that are
> fairly intrusive. For instance, if you've gone to the trouble of
> formatting a parameter list like so:
> 
[examples deleted]

As I recall, Apex has a "switches" file that tells it what to do about a
lot of things. Last time I used it, we had to modify switches to link in
some bindings we used. Some of the switches control reformatting; I
think there's one that turns reformatting on or off completely. So,
perhaps you could RTFM or contact your Rational rep and be able to get
Apex to be less intrusive. Good luck.

Jeff Carter  PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"Now go away, or I shall taunt you a second time."
Monty Python & the Holy Grail

Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/




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

* Re: Ada95 Pretty-Printers
       [not found] <339C58A6.4D5A@sprintmail.com>
  1997-06-10  0:00 ` Ada95 Pretty-Printers Anonymous
@ 1997-06-10  0:00 ` Samuel Mize
  1997-06-10  0:00   ` John G. Volan
                     ` (2 more replies)
  1997-06-11  0:00 ` Rolf Ebert
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 21+ messages in thread
From: Samuel Mize @ 1997-06-10  0:00 UTC (permalink / raw)



John G. Volan wrote:
> Are there any pretty-printers out there for Ada95?

This seems to come up every so often, and the answer so far has
been "not really."

I would suppose that one could be built using the AdaMagic front
end, but that's sheer speculation and I don't know how much it costs.

An Ada mode for emacs could be applied in a batch format, if you
find one that works reliably for what you want.


> ...  Apex is frustrating because it actively
> reformats almost every syntactic structure in Ada to suit Rational's
> coding style.

That's a feature.  Just ask them.

...
> Apex will ignore your line breaks and alignment, and reformat
...
> Apex does a lot of this sort of thing (I don't _even_ want to begin
> on how it mangles long expressions), but it doesn't provide very
> many hooks to control this behavior.

I got in the habit of putting an empty comment where I wanted a
line break.  To use your first example:

   procedure Operation             --
     (This  : in     This_Type;    --
      That  : in     That_Type;    --
      Other :    out Other_Type);

will become something like:

   procedure Operation             --
     (This  : in This_Type;    --
      That  : in That_Type;    --
      Other : out Other_Type);

(Assuming that Apex doesn't maintain the blanks to line up "in"
and "out").

I used this mostly to keep expressions broken up the way I wanted.
I found that, if you could keep the line breaks where you want
them, you can get fairly readable expression formatting with just
adding a few extraneous parentheses to direct the formatter to
indent a sub-expression (I have to do the same thing with emacs). 

I got third-hand, supposedly from someone at Rational, that if you
put two spaces at the end of a line, the reformatter will leave
that line break.  If you don't want trailing comments in your code,
you can try it.  I don't know if it's a feature they promise to
support, or just an artifact of the then-current implementation.

I personally prefer using the comments to maintain line breaks,
because people get used to the formatter output.  Thus, someone
might misread the expression, because they expect the indentation
to be correct.  So, I prefer a visible indication that the
automated indentation has been tampered with.

Sam Mize

--
-- Samuel Mize           (817) 619-8622               "Team Ada"
-- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00 ` Ada95 Pretty-Printers Anonymous
@ 1997-06-10  0:00   ` John G. Volan
  0 siblings, 0 replies; 21+ messages in thread
From: John G. Volan @ 1997-06-10  0:00 UTC (permalink / raw)



Anonymous wrote:
> 
> As I recall, Apex has a "switches" file that tells it what to do about a
> lot of things. Last time I used it, we had to modify switches to link in
> some bindings we used. Some of the switches control reformatting; I
> think there's one that turns reformatting on or off completely. So,
> perhaps you could RTFM or contact your Rational rep and be able to get
> Apex to be less intrusive. Good luck.

We tried that. The switches in Apex are very limited, they do not give
you very much control at all.  For instance, you can set the number of
spaces per indent and the typecase for reserved words and identifiers,
and you can force it to put params on separate lines (but only when they
don't all fit on one line), but you can't make it line up parameters and
reserved words on the left if it doesn't already feel like doing that.

We've talked with our Rational reps and come up dry. The most they've
been able to come up with was a little post-processing script that could
take an acronym list and turn all the embedded acronyms in our
identifiers from initial-caps to all-caps.  But that's just lexical
stuff, not the syntactic layout control we'd like to have.

------------------------------------------------------------------------
Internet.Usenet.Put_Signature 
  (Name       => "John G. Volan",
   Employer   => "Texas Instruments Advanced C3I Systems, San Jose, CA",
   Work_Email => "johnv@ti.com",
   Home_Email => "johnvolan@sprintmail.com",
   Slogan     => "Ada95: World's *FIRST* International-Standard OOPL",
   Disclaimer => "My employer never defined these opinions, so using " & 
                 "them would be totally erroneous...or is that just "  &
                 "nondeterministic behavior now? :-) ");
------------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00 ` Samuel Mize
@ 1997-06-10  0:00   ` John G. Volan
  1997-06-10  0:00     ` Spam Hater
  1997-06-16  0:00     ` Greg Gicca @pulsar
  1997-06-10  0:00   ` John G. Volan
  1997-06-10  0:00   ` stuman
  2 siblings, 2 replies; 21+ messages in thread
From: John G. Volan @ 1997-06-10  0:00 UTC (permalink / raw)



Samuel Mize wrote:
> 
> John G. Volan wrote:
> > Are there any pretty-printers out there for Ada95?
> 
> This seems to come up every so often, and the answer so far has
> been "not really."
> 
> I would suppose that one could be built using the AdaMagic front
> end, but that's sheer speculation and I don't know how much it costs.

I've been toying with the thought of doing it using GNAT's front end ...
or maybe this would be a good application for ASIS ... hmm ... what's
the status of ASIS & GNAT?  Gotta look that up ...

> An Ada mode for emacs could be applied in a batch format, if you
> find one that works reliably for what you want.

Is there more than one version? Where can I find alternate versions of
emacs Ada mode?

> I got in the habit of putting an empty comment where I wanted a
> line break.  To use your first example:
> 
>    procedure Operation             --
>      (This  : in     This_Type;    --
>       That  : in     That_Type;    --
>       Other :    out Other_Type);
> 
> will become something like:
> 
>    procedure Operation             --
>      (This  : in This_Type;    --
>       That  : in That_Type;    --
>       Other : out Other_Type);
> 
> (Assuming that Apex doesn't maintain the blanks to line up "in"
> and "out").

Actually, the PRESERVE_WHITESPACE switch will respect the blanks you
manually put into a param list, but here's what Apex does with the
above:

   procedure Operation             --
               (This  : in     This_Type;    --
                That  : in     That_Type;    --
                Other :    out Other_Type);

Folks, is it okay with you if I say this is just plain dumb, or do I
have to hem and haw about it being all a matter of taste? :-)

> I used this mostly to keep expressions broken up the way I wanted.
> I found that, if you could keep the line breaks where you want
> them, you can get fairly readable expression formatting with just
> adding a few extraneous parentheses to direct the formatter to
> indent a sub-expression (I have to do the same thing with emacs).

Yeah, I do that too. I love Emacs, but I've been using it for years so
I'm used to the interface. Our engineers are only going to go for an
editor that adheres to X and/or Windows standards, and unfortunately
Emacs is not very "desktop friendly."

> I got third-hand, supposedly from someone at Rational, that if you
> put two spaces at the end of a line, the reformatter will leave
> that line break.  If you don't want trailing comments in your code,
> you can try it.  I don't know if it's a feature they promise to
> support, or just an artifact of the then-current implementation.

Hmm, that seems to work, but this is what you get:

   procedure Operation  
               (This  : in     This_Type;  
                That  : in     That_Type;  
                Other :    out Other_Type);

I tried this on some control structures, too. If you start with this:

  if Condition  
  then
    Statement;
  elsif Condition
    then  
    Statement;
  else
    Statement;
  end if;

  case Expression is
  when Choice =>
    Statement;
  when Choice =>
    Statement;
  end case;

  Label:
  while Condition  
  loop
    Statement;
  end loop Label;

  Block_Name:
  begin
    Statement;
  exception
  when Exception_Name =>
    Statement;
  end Block_Name;

you wind up with:

  if Condition  
    then
    Statement;
  elsif Condition
    then  
    Statement;
  else
    Statement;
  end if;

  case Expression is
    when Choice =>
      Statement;
    when Choice =>
      Statement;
  end case;

  Loop_Name:
    while Condition  
      loop
      Statement;
    end loop Loop_Name;

  Block_Name:
    begin
      Statement;
    exception
      when Exception_Name =>
        Statement;
    end Block_Name;

(This is with INDENTATION = BREAK_INDENT = 2.)

In other words: (1) If you force a linebreak before a "then" or a
"loop", Apex treats it as a continuation line and indents it by
BREAK_INDENT, rather than lining it up with the "if" or "while". And (2)
you can't prevent "when" clauses and block/loop names from introducing
an extra indent.

Witness what Apex does to an instantiation. Using the
double-space-before-linebreak trick, you can go from this:

  procedure Deallocate is new Ada.Unchecked_Deallocation  
    (Object => Object_Type'Class,
     Name   => Object_Access_Type);

to this:

  procedure Deallocate is new Ada.Unchecked_Deallocation  
                                (Object => Object_Type'Class,
                                 Name   => Object_Access_Type);

If you try this:

  procedure Deallocate is new  
    Ada.Unchecked_Deallocation  
    (Object => Object_Type'Class,
     Name   => Object_Access_Type);

Here's what you get:

  procedure Deallocate is new  
                             Ada.Unchecked_Deallocation  
                             (Object => Object_Type'Class,
                              Name   => Object_Access_Type);

!!!
------------------------------------------------------------------------
Internet.Usenet.Put_Signature 
  (Name       => "John G. Volan",
   Employer   => "Texas Instruments Advanced C3I Systems, San Jose, CA",
   Work_Email => "johnv@ti.com",
   Home_Email => "johnvolan@sprintmail.com",
   Slogan     => "Ada95: World's *FIRST* International-Standard OOPL",
   Disclaimer => "My employer never defined these opinions, so using " & 
                 "them would be totally erroneous...or is that just "  &
                 "nondeterministic behavior now? :-) ");
------------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00     ` Spam Hater
@ 1997-06-10  0:00       ` Spam Hater
  0 siblings, 0 replies; 21+ messages in thread
From: Spam Hater @ 1997-06-10  0:00 UTC (permalink / raw)



> > > > Are there any pretty-printers out there for Ada95?
> > >
> > > This seems to come up every so often, and the answer so far has
> > > been "not really."

Sorry about that.  _I_ don't remember hitting any Send button!  :-)
Anyway, I used Ada-ASSURED on another job about three years ago,
and though I had minor complaints, I think it's an excellent tool.

----------------------------------------------------------------------
    Wes Groleau, Hughes Defense Communications, Fort Wayne, IN USA
Senior Software Engineer - AFATDS                  Tool-smith Wanna-be

Don't send advertisements to this domain unless asked!  All disk space
on fw.hac.com hosts belongs to either Hughes Defense Communications or 
the United States government.  Using email to store YOUR advertising 
on them is trespassing!
----------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00   ` John G. Volan
@ 1997-06-10  0:00     ` Spam Hater
  1997-06-10  0:00       ` Spam Hater
  1997-06-16  0:00     ` Greg Gicca @pulsar
  1 sibling, 1 reply; 21+ messages in thread
From: Spam Hater @ 1997-06-10  0:00 UTC (permalink / raw)



> > > Are there any pretty-printers out there for Ada95?
> >
> > This seems to come up every so often, and the answer so far has
> > been "not really."

----------------------------------------------------------------------
    Wes Groleau, Hughes Defense Communications, Fort Wayne, IN USA
Senior Software Engineer - AFATDS                  Tool-smith Wanna-be

                 wwgrol  -AT-  pseserv3.fw.hac.com

Don't send advertisements to this domain unless asked!  All disk space
on fw.hac.com hosts belongs to either Hughes Defense Communications or 
the United States government.  Using email to store YOUR advertising 
on them is trespassing!
----------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00 ` Samuel Mize
  1997-06-10  0:00   ` John G. Volan
  1997-06-10  0:00   ` John G. Volan
@ 1997-06-10  0:00   ` stuman
  2 siblings, 0 replies; 21+ messages in thread
From: stuman @ 1997-06-10  0:00 UTC (permalink / raw)



Samuel Mize wrote:
> 
> John G. Volan wrote:
> > Are there any pretty-printers out there for Ada95?
> 
> This seems to come up every so often, and the answer so far has
> been "not really."
> 
> I would suppose that one could be built using the AdaMagic front
> end, but that's sheer speculation and I don't know how much it costs.
> 
> An Ada mode for emacs could be applied in a batch format, if you
> find one that works reliably for what you want.
> 
> > ...  Apex is frustrating because it actively
> > reformats almost every syntactic structure in Ada to suit Rational's
> > coding style.
> 
> That's a feature.  Just ask them.
> 
> ...
> > Apex will ignore your line breaks and alignment, and reformat
> ...
> > Apex does a lot of this sort of thing (I don't _even_ want to begin
> > on how it mangles long expressions), but it doesn't provide very
> > many hooks to control this behavior.
> 
> I got in the habit of putting an empty comment where I wanted a
> line break.  To use your first example:
> 
>    procedure Operation             --
>      (This  : in     This_Type;    --
>       That  : in     That_Type;    --
>       Other :    out Other_Type);
> 
> will become something like:
> 
>    procedure Operation             --
>      (This  : in This_Type;    --
>       That  : in That_Type;    --
>       Other : out Other_Type);
> 
> (Assuming that Apex doesn't maintain the blanks to line up "in"
> and "out").
> 
> I used this mostly to keep expressions broken up the way I wanted.
> I found that, if you could keep the line breaks where you want
> them, you can get fairly readable expression formatting with just
> adding a few extraneous parentheses to direct the formatter to
> indent a sub-expression (I have to do the same thing with emacs).
> 
> I got third-hand, supposedly from someone at Rational, that if you
> put two spaces at the end of a line, the reformatter will leave
> that line break.  If you don't want trailing comments in your code,
> you can try it.  I don't know if it's a feature they promise to
> support, or just an artifact of the then-current implementation.
> 
> I personally prefer using the comments to maintain line breaks,
> because people get used to the formatter output.  Thus, someone
> might misread the expression, because they expect the indentation
> to be correct.  So, I prefer a visible indication that the
> automated indentation has been tampered with.
> 
> Sam Mize
> 
> --
> -- Samuel Mize           (817) 619-8622               "Team Ada"
> -- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005
We are using a version of Apex that has several switches to control
pretty printing. One of these switches causes "whitespace" to be
retained. In addition, there is a switch that has an effect on what Apex
does with a statement that does not fit on a line. I think that the
proper setting of these two switches, and adding a couple of spaces at
the end of a line will allow you to retain your formatting. If not,
then  you can set the manual_pretty_printing switch to true and then you
have complete control -- Apex will not do undo your formating --
although it may not do formatting at all.




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00 ` Samuel Mize
  1997-06-10  0:00   ` John G. Volan
@ 1997-06-10  0:00   ` John G. Volan
  1997-06-11  0:00     ` Samuel Mize
                       ` (2 more replies)
  1997-06-10  0:00   ` stuman
  2 siblings, 3 replies; 21+ messages in thread
From: John G. Volan @ 1997-06-10  0:00 UTC (permalink / raw)



Samuel Mize wrote:
>
> John G. Volan wrote:
> > Are there any pretty-printers out there for Ada95?
>
> This seems to come up every so often, and the answer so far has
> been "not really."
>
> I would suppose that one could be built using the AdaMagic front
> end, but that's sheer speculation and I don't know how much it costs.

I've been toying with the thought of doing it using GNAT's front end ...
or maybe this would be a good application for ASIS ... hmm ... what's
the status of ASIS & GNAT? Gotta look that up ...

> An Ada mode for emacs could be applied in a batch format, if you
> find one that works reliably for what you want.

Is there more than one version? Where can I find alternate versions of
emacs Ada mode?

> I got in the habit of putting an empty comment where I wanted a
> line break. To use your first example:
>
> procedure Operation --
> (This : in This_Type; --
> That : in That_Type; --
> Other : out Other_Type);
>
> will become something like:
>
> procedure Operation --
> (This : in This_Type; --
> That : in That_Type; --
> Other : out Other_Type);
>
> (Assuming that Apex doesn't maintain the blanks to line up "in"
> and "out").

Actually, the PRESERVE_WHITESPACE switch will respect the blanks you
manually put into a param list, but here's what Apex does with the
above:

procedure Operation --
(This : in This_Type; --
That : in That_Type; --
Other : out Other_Type);

Folks, is it okay with you if I say this is just plain dumb, or do I
have to hem and haw about it being all a matter of taste? :-)

> I used this mostly to keep expressions broken up the way I wanted.
> I found that, if you could keep the line breaks where you want
> them, you can get fairly readable expression formatting with just
> adding a few extraneous parentheses to direct the formatter to
> indent a sub-expression (I have to do the same thing with emacs).

Yeah, I do that too. I love Emacs, but I've been using it for years so
I'm used to the interface. Our engineers are only going to go for an
editor that adheres to X and/or Windows standards, and unfortunately
Emacs is not very "desktop friendly."

> I got third-hand, supposedly from someone at Rational, that if you
> put two spaces at the end of a line, the reformatter will leave
> that line break. If you don't want trailing comments in your code,
> you can try it. I don't know if it's a feature they promise to
> support, or just an artifact of the then-current implementation.

Hmm, that seems to work, but this is what you get:

procedure Operation
(This : in This_Type;
That : in That_Type;
Other : out Other_Type);

I tried this on some control structures, too. If you start with this:

if Condition
then
Statement;
elsif Condition
then
Statement;
else
Statement;
end if;

case Expression is
when Choice =>
Statement;
when Choice =>
Statement;
end case;

Label:
while Condition
loop
Statement;
end loop Label;

Block_Name:
begin
Statement;
exception
when Exception_Name =>
Statement;
end Block_Name;

you wind up with:

if Condition
then
Statement;
elsif Condition
then
Statement;
else
Statement;
end if;

case Expression is
when Choice =>
Statement;
when Choice =>
Statement;
end case;

Loop_Name:
while Condition
loop
Statement;
end loop Loop_Name;

Block_Name:
begin
Statement;
exception
when Exception_Name =>
Statement;
end Block_Name;

(This is with INDENTATION = BREAK_INDENT = 2.)

In other words: (1) If you force a linebreak before a "then" or a
"loop", Apex treats it as a continuation line and indents it by
BREAK_INDENT, rather than lining it up with the "if" or "while". And (2)
you can't prevent "when" clauses and block/loop names from introducing
an extra indent.

Witness what Apex does to an instantiation. Using the
double-space-before-linebreak trick, you can go from this:

procedure Deallocate is new Ada.Unchecked_Deallocation
(Object => Object_Type'Class,
Name => Object_Access_Type);

to this:

procedure Deallocate is new Ada.Unchecked_Deallocation
(Object => Object_Type'Class,
Name => Object_Access_Type);

If you try this:

procedure Deallocate is new
Ada.Unchecked_Deallocation
(Object => Object_Type'Class,
Name => Object_Access_Type);

Here's what you get:

procedure Deallocate is new
Ada.Unchecked_Deallocation
(Object => Object_Type'Class,
Name => Object_Access_Type);

!!!
------------------------------------------------------------------------
Internet.Usenet.Put_Signature
(Name => "John G. Volan",
Employer => "Texas Instruments Advanced C3I Systems, San Jose, CA",
Work_Email => "johnv@ti.com",
Home_Email => "johnvolan@sprintmail.com",
Slogan => "Ada95: World's *FIRST* International-Standard OOPL",
Disclaimer => "My employer never defined these opinions, so using " &
"them would be totally erroneous...or is that just " &
"nondeterministic behavior now? :-) ");
------------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
       [not found] <339C58A6.4D5A@sprintmail.com>
  1997-06-10  0:00 ` Ada95 Pretty-Printers Anonymous
  1997-06-10  0:00 ` Samuel Mize
@ 1997-06-11  0:00 ` Rolf Ebert
  1997-06-11  0:00   ` John G. Volan
  1997-06-11  0:00 ` Matthew Heaney
  1997-06-12  0:00 ` Jeff Burns
  4 siblings, 1 reply; 21+ messages in thread
From: Rolf Ebert @ 1997-06-11  0:00 UTC (permalink / raw)



>>>>> "JGV" == John G Volan <johnvolan@sprintmail.com> writes:

JGV> Are there any batch pretty-printers out there (commercial or free)
JGV> that can do syntax-level indenting while still respecting the
JGV> user's line-breaks? Or even better, are there any pretty-printers
JGV> that can actively reformat, but which are customizable, maybe using
JGV> syntax templates? (For instance, if one of our programmers forgets
JGV> to put a "then" on a separate line, we'd rather have a tool that
JGV> could automatically move it for him, rather than beat him up in a
JGV> walkthrough for something as trivial as code format.)

The answer to almost any question is Emacs. Emacs can do everything :-)

Look at the emacs-ada-mode package at cs.ny.edu:/pub/gnat.  In its
contrib directory there is a short file which uses Emacs in batch mode
for reindenting files.  The documentation explains the user options
which control indenting.  The current Emacs-reformatter never changes
newlines, though.  But you have the sources and can of course adapt it
to your needs.  I admit, it is very slow.

Try to do that with vi.


        Rolf
        ebert@waporo.muc.de




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

* Re: Ada95 Pretty-Printers
  1997-06-11  0:00 ` Rolf Ebert
@ 1997-06-11  0:00   ` John G. Volan
  0 siblings, 0 replies; 21+ messages in thread
From: John G. Volan @ 1997-06-11  0:00 UTC (permalink / raw)



Thanks to everyone who suggested running emacs in batch mode. We've got
it doing case adjustment and indentation for us now, and we've been able
to hook it into Apex in place of its pretty-printer.  So what if it
doesn't do reformatting -- what self-respecting engineer would want a
tool to decide where to put the line-breaks anyway? :-)

The only downside is that it's pretty slow. The indentation algorithm is
tailored for interactive editing: It's great at indenting the line
you're currently editing, and you don't notice the time it spends
backtracking to see what the indentation level should be.  But when it's
doing all that backtracking repeatedly on every line in a batch
traversal through a file, that's pretty wasteful.

We're debating whether to mangle up a new lisp script to do a one-pass
indenting traversal, but the original ada-mode source is a bit confusing
-- it's hard to tell what can be ripped out.  It might be more
worthwhile for us to look at using ASIS/GNAT as the basis of a pretty
printer. That way we could actually get active reformatting -- but the
way _we_ want it.  For the curious, ASIS/GNAT can be found at: 

   http://www.acm.org/sigada/WG/asiswg/ASIS_GNAT_9705.html

------------------------------------------------------------------------
Internet.Usenet.Put_Signature 
  (Name       => "John G. Volan",
   Employer   => "Texas Instruments Advanced C3I Systems, San Jose, CA",
   Work_Email => "johnv@ti.com",
   Home_Email => "johnvolan@sprintmail.com",
   Slogan     => "Ada95: World's *FIRST* International-Standard OOPL",
   Disclaimer => "My employer never defined these opinions, so using " & 
                 "them would be totally erroneous...or is that just "  &
                 "nondeterministic behavior now? :-) ");
------------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00   ` John G. Volan
@ 1997-06-11  0:00     ` Samuel Mize
  1997-06-12  0:00     ` John G. Volan
  1997-06-12  0:00     ` Robert Dewar
  2 siblings, 0 replies; 21+ messages in thread
From: Samuel Mize @ 1997-06-11  0:00 UTC (permalink / raw)



In article <resurrect.339DA006.228F@sprintmail.com>,
John G. Volan <johnvolan@sprintmail.com> wrote:
>> An Ada mode for emacs could be applied in a batch format, if you
>> find one that works reliably for what you want.
>
>Is there more than one version? Where can I find alternate versions of
>emacs Ada mode?

I think there's a list of two or three at (surprise!) www.adahome.com.
The one we have installed where I work (by an Ada guru who's since left
the company) isn't reliable, but it's a darn sight better than none.


>Actually, the PRESERVE_WHITESPACE switch will respect the blanks you
>manually put into a param list, but here's what Apex does with the
>above:

I don't know if it's your posting or my news reader, but all your
"before" examples appear identical to your "after" examples -- all
lined up on the left margin.


>...I love Emacs, but I've been using it for years so
>I'm used to the interface. Our engineers are only going to go for an
>editor that adheres to X and/or Windows standards, and unfortunately
>Emacs is not very "desktop friendly."

Mine at work is X friendly.  Do you mean it all has to be Icons-n-Click
driven?  Don't they want you to get any real work done?

Sam Mize

-- 
Samuel Mize -- smize@imagin.net -- Team Ada
(personal net account)




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

* Re: Ada95 Pretty-Printers
       [not found] <339C58A6.4D5A@sprintmail.com>
                   ` (2 preceding siblings ...)
  1997-06-11  0:00 ` Rolf Ebert
@ 1997-06-11  0:00 ` Matthew Heaney
  1997-06-12  0:00 ` Jeff Burns
  4 siblings, 0 replies; 21+ messages in thread
From: Matthew Heaney @ 1997-06-11  0:00 UTC (permalink / raw)



In article <339C58A6.4D5A@sprintmail.com>, johnvolan@sprintmail.com wrote:

>Are there any pretty-printers out there for Ada95?  I'm looking for
>something that can serve as an alternative to the pretty-printer built
>into Rational's Apex.  Apex is frustrating because it actively reformats
>almost every syntactic structure in Ada to suit Rational's coding style.
>This style is based on the LRM, but it does certain things that are
>fairly intrusive. For instance, if you've gone to the trouble of
>formatting a parameter list like so:
>
>  procedure Operation
>    (This  : in     This_Type;
>     That  : in     That_Type;
>     Other :    out Other_Type);
>
>Apex will ignore your line breaks and alignment, and reformat it like
>so:
>
>  procedure Operation (This : in This_Type; That : in That_Type;
>                       Other : out Other_Type);

A simple fix: go into your switches file and turn on manual
pretty-printing.  I agree with you that Rational's pretty-printer only
makes things worse.

But what about emacs?  It facilitates the entry of source text, and you can
teach it to format your code any way you want.

At least on my system (Sun Solaris), the folks at Rational customized emacs
so that it's completely integrated with Apex.  Their tailored version is
called aemacs (it's a script that calls the real emacs).

Yes, you can run the normal GUI APEX and use emacs as the editor, but I've
completely ditched the GUI front end; I just use aemacs now as my front
end.  (Realize that APEX has a command line interface: the GUI just calls
the commands you can type from an APEX shell.)

Do this

% apexinit -emacs -nogui

and emacs runs in your xterm, and acts as the APEX front end.  I do all my
compiles in emacs, and visits, etc.  I lose no APEX functionality by using
emacs.

Of course, you can still run APEX with a GUI, and use emacs as the editor. 
It's still integrated, and you can still do compiles in the editor, etc.

I bring this up because you can make emacs do whatever you want.  If you
don't like what it does, you can change it.  You could even use Rolf
Ebert's ada-mode, available from the NYU ftp site.  And you can even have
emacs call the pretty-printer of your choice.

Emacs, it's not your parent's editor, eh?

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00   ` John G. Volan
  1997-06-11  0:00     ` Samuel Mize
  1997-06-12  0:00     ` John G. Volan
@ 1997-06-12  0:00     ` Robert Dewar
  2 siblings, 0 replies; 21+ messages in thread
From: Robert Dewar @ 1997-06-12  0:00 UTC (permalink / raw)



John Volan says

<<I've been toying with the thought of doing it using GNAT's front end ...
or maybe this would be a good application for ASIS ... hmm ... what's
the status of ASIS & GNAT? Gotta look that up ...>>


GNAT/ASIS is fully operational, and we will be announcing commercial spuport
for ASIS in the near future. Meanwhile, there is already a commercial
product (from Mark V systems) that uses the GNAT/ASIS interface to generate
structure diagrams for GNAT programs.

Yes, GNAT/ASIS could be used to generate a pretty printer. However (says
he a bit mysteriously) I advise against investing much effort in such a
project right now!

Robert Dewar
Ada Core Technologies





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

* Re: Ada95 Pretty-Printers
       [not found] <339C58A6.4D5A@sprintmail.com>
                   ` (3 preceding siblings ...)
  1997-06-11  0:00 ` Matthew Heaney
@ 1997-06-12  0:00 ` Jeff Burns
  4 siblings, 0 replies; 21+ messages in thread
From: Jeff Burns @ 1997-06-12  0:00 UTC (permalink / raw)




Wes, thanks for mentioning Ada-ASSURED.  I'm glad you think so highly of it.

Ada-ASSURED may be a good solution for John Volan:

> Apex is frustrating because it actively reformats
> almost every syntactic structure in Ada to suit Rational's coding style.
> This style is based on the LRM, but it does certain things that are
> fairly intrusive.

Ada-ASSURED also formats every syntactic structure, but the 
formatting is apparently higher quality and easier to customize.  
In both examples that you describe, Ada-ASSURED will print the 
code as desired:

>   procedure Operation
>     (This  : in     This_Type;
>      That  : in     That_Type;
>      Other :    out Other_Type);
> 

This is done automatically by the pretty-printer and can be
customized.

>   if Very_Long_Conditional_Expression
>      Spanning_Multiple_Lines
>   then
>     First_Sequence_Of_Statements;
>     ...
>   elsif Short_One_Line_Conditional

We provide a couple options for the above example: the user can choose to
either align the "then" with the "if", or to leave the "then" on the same
line as the "if".  Once the customization is set, all occurrences of
"if-then" will be formatted according to the choice.

> Apex does a lot of this sort of thing (I don't _even_ want to begin on
> how it mangles long expressions), but it doesn't provide very many hooks
> to control this behavior. 

Ada-ASSURED has a long list of ways to change the pretty-printing according
to a user's requirements. However, there are cases in which the
pretty-printing cannot be easily customized [how meaningful would
standardization really be if everything is customized by end-users?].

> 
> Are there any batch pretty-printers out there (commercial or free) that
> can do syntax-level indenting while still respecting the user's
> line-breaks? Or even better, are there any pretty-printers that can
> actively reformat, but which are customizable, maybe using syntax
> templates? 

GrammaTech has two tools to choose from:  Ada-ASSURED and, soon to be
released, Ada-Utilities.  Both can actively reformat code according to user
settings of the pretty-printing parameters.  Batch processing is an option
with Ada-ASSURED and a standard feature with Ada-Utilities.

Ada-ASSURED is for sites that want an advanced language-sensitive editor for
ensuring coding standards are followed as the code is being written.

Ada-Utilities is for sites working with existing code that don't need or
want a language-sensitive editor. It provides code analysis for identifying
problem areas and a set of tools for correcting those problems, including a
high quality pretty printer and language-sensitive code transformations. 
Ada-Utilities is intended to be used for QA and IV&V.

Here are brief descriptions of both products:

Ada-ASSURED (AA) is similar to the Apex editor, but it can be easily
integrated with other tools and your choice of compilers (and it's much less
expensive).  AA checks for syntax errors, monitors/automates coding style,
provides context-sensitive templates and a browser, and includes the option
of structural editing in addition to conventional textual editing. 

AA formats code automatically or on-demand.  One of its coolest features is
dynamic formatting.  In automatic mode AA formats your code as you're typing
it in.  If you change your window width, the formatting will adjust
automatically so your code is still readable. This way you can have multiple
windows of various sizes open at once and they'll all be easy to read.  Of
course, when you go to print your code Ada-ASSURED will print it at the
standard 80 column width (or whatever you set it at, such as 132 or even
"two up") with or without line number margins.

AA does true syntax coloring, not just lexical coloring like Emacs (there is
a difference). Pretty printing looks best when printed through a standard or
color PostScript printer. 

In August we plan to release a new toolset called Ada-Utilities, which will
include the same batch pretty-printing facilities as Ada-ASSURED.  The other
utilities it will include are:

Ada-Audit: a programmable tool for monitoring compliance with coding
standards. Creates reports viewable on web browsers with HTML links to
coding errors and HTML cross-references to appropriate sections of the SPC
AQ&S and the LRM.

Ada-Grep: a structured find utility with an additional argument to narrow
the search to a particular Ada structure, such as a name, an expression or a
statement.

Ada-Transform:  imagine a language-sensitive version of awk, sed, or perl. 
This tool helps you precisely locate and modify, if you wish, any fragment
of code locally or globally.

Ada 95 and Ada 83 are supported by Ada-ASSURED and Ada-Utilities.  Both
include a Scheme-based scripting language providing access to the structure
of your code and additional customizability.

-----------------------------
Jeff Burns, Director of Marketing
GrammaTech, Inc.
One Hopkins Place
Ithaca, NY  14850
ph: 607-273-7340
fax: 607-273-8752
e-mail:  jeff@grammatech.com
www:  http://www.grammatech.com
Team Ada
==============================
Ada-ASSURED
	LSE
	Style Standards Enforcer
	Browser
	QA Tool
	Code Transformer
"Cure for the Common Code"
==============================





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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00   ` John G. Volan
  1997-06-11  0:00     ` Samuel Mize
@ 1997-06-12  0:00     ` John G. Volan
  1997-06-13  0:00       ` Samuel Mize
  1997-06-12  0:00     ` Robert Dewar
  2 siblings, 1 reply; 21+ messages in thread
From: John G. Volan @ 1997-06-12  0:00 UTC (permalink / raw)



Weird... looks like either my newsreader or Samuel's ate up all the
whitespace in my examples.  Here's what they should have looked like
(I'm going to put the whitespace back in, and hopefully the ">" quote
characters will keep the newsreader's appetite in check. :-)

John G. Volan wrote:
> 
> Samuel Mize wrote:
> >
> > I got in the habit of putting an empty comment where I wanted a
> > line break. To use your first example:
> >
> > procedure Operation --
> >   (This  : in     This_Type; --
> >    That  : in     That_Type; --
> >    Other :    out Other_Type);
> >
> > will become something like:
> >
> > procedure Operation --
> >   (This : in This_Type; --
> >    That : in That_Type; --
> >    Other : out Other_Type);
> >
> > (Assuming that Apex doesn't maintain the blanks to line up "in"
> > and "out").
> 
> Actually, the PRESERVE_WHITESPACE switch will respect the blanks you
> manually put into a param list, but here's what Apex does with the
> above:
> 
> procedure Operation --
>             (This  : in     This_Type; --
>              That  : in     That_Type; --
>              Other :    out Other_Type);

(What you should be seeing here is:
- the parameter names all lined up against the open paren
- the colons (":") all lined up
- the "in" keywords all lined up
- the "out" keyword spaced to the right of the "in" keyword
- the type names all lined up
**BUT**
- the initial open paren indented all the way over to two spaces right
from the "O" in "Operation", *NOT* aligned on the left, indented two
spaces from the "p" in "procedure".)

> Folks, is it okay with you if I say this is just plain dumb, or do I
> have to hem and haw about it being all a matter of taste? :-)
> 
[snip]
> > I got third-hand, supposedly from someone at Rational, that if you
> > put two spaces at the end of a line, the reformatter will leave
> > that line break. If you don't want trailing comments in your code,
> > you can try it. I don't know if it's a feature they promise to
> > support, or just an artifact of the then-current implementation.
> 
> Hmm, that seems to work, but this is what you get:
> 
> procedure Operation
>             (This  : in     This_Type;
>              That  : in     That_Type;
>              Other :    out Other_Type);

(The open parent should still appear two spaces right from the "O" in
"Operation".)

> I tried this on some control structures, too. If you start with this:
> 
> if Condition
> then
>   Statement;
> elsif Condition
> then
>   Statement;
> else
>   Statement;
> end if;
> 
> case Expression is
> when Choice =>
>   Statement;
> when Choice =>
>   Statement;
> end case;
> 
> Label:
> while Condition
> loop
>   Statement;
> end loop Label;
> 
> Block_Name:
> begin
>   Statement;
> exception
> when Exception_Name =>
>   Statement;
> end Block_Name;

(What you should see above is all the reserved words lined up on the
left (including "then", "loop", and "when"), and all the Statements
indented exactly the same, two spaces, no matter which part of the
syntax they're in.)

> you wind up with:
> 
> if Condition
>   then
>   Statement;
> elsif Condition
>   then
>   Statement;
> else
>   Statement;
> end if;

(The "then" keywords are indented two spaces rather than aligned left.)

> case Expression is
>   when Choice =>
>     Statement;
>   when Choice =>
>     Statement;
> end case;

(The "when" clauses add a level of indent we don't want, so two levels
of indent have to be unrolled after the last Statement.)

> Loop_Name:
>   while Condition
>     loop
>     Statement;
>   end loop Loop_Name;

(The Loop_Name introduces an extra level of indent we don't want; and
the "loop" keyword is indented two spaces rather than aligned with the
"while".)


> Block_Name:
>   begin
>     Statement;
>   exception
>     when Exception_Name =>
>       Statement;
>   end Block_Name;

(The "when" clauses add a level of indent we don't want, so two levels
of indent have to be unrolled after the last Statement; and the
Block_Name adds a whole other level of indent.)

> (This is with INDENTATION = BREAK_INDENT = 2.)
> 
> In other words: (1) If you force a linebreak before a "then" or a
> "loop", Apex treats it as a continuation line and indents it by
> BREAK_INDENT, rather than lining it up with the "if" or "while". And (2)
> you can't prevent "when" clauses and block/loop names from introducing
> an extra indent.
> 
> Witness what Apex does to an instantiation. Using the
> double-space-before-linebreak trick, you can go from this:
> 
> procedure Deallocate is new Ada.Unchecked_Deallocation
>   (Object => Object_Type'Class,
>    Name   => Object_Access_Type);

(The open paren should be indented two spaces from the "p" in
"procedure".)

> to this:
> 
> procedure Deallocate is new Ada.Unchecked_Deallocation
>                               (Object => Object_Type'Class,
>                                Name   => Object_Access_Type);

(The open paren should now be shoved all the way over to two spaces
right of the "A" in "Ada.")

> If you try this:
> 
> procedure Deallocate is new
>   Ada.Unchecked_Deallocation
>   (Object => Object_Type'Class,
>    Name   => Object_Access_Type);

("Ada" and "(" indented two spaces from the "p" in "procedure".)

> Here's what you get:
> 
> procedure Deallocate is new
>                            Ada.Unchecked_Deallocation
>                            (Object => Object_Type'Class,
>                             Name   => Object_Access_Type);

("Ada" and "(" shoved all the way over, just to the right of "new"!)

> !!!

!!! You said it, man!  (I mean, _I_ said it, man! :-)

(Bob, Bob, Bobby, Robert and Cecil, move over!  You need to free up some
space at the funny-farm for John, John, John-John, Johnny, Juan, Jean,
Giovanni, Johannes, Ivan, Ian, Yiannis, Ioannes, Yohannan, and George,
who have all been driven batty by Apex! :-)

------------------------------------------------------------------------
Internet.Usenet.Put_Signature 
  (Name       => "John G. Volan",
   Employer   => "Texas Instruments Advanced C3I Systems, San Jose, CA",
   Work_Email => "johnv@ti.com",
   Home_Email => "johnvolan@sprintmail.com",
   Slogan     => "Ada95: World's *FIRST* International-Standard OOPL",
   Disclaimer => "My employer never defined these opinions, so using " & 
                 "them would be totally erroneous...or is that just "  &
                 "nondeterministic behavior now? :-) ");
------------------------------------------------------------------------




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

* Re: Ada95 Pretty-Printers
  1997-06-12  0:00     ` John G. Volan
@ 1997-06-13  0:00       ` Samuel Mize
  1997-06-14  0:00         ` Tom Phinney
  1997-06-14  0:00         ` Robert Dewar
  0 siblings, 2 replies; 21+ messages in thread
From: Samuel Mize @ 1997-06-13  0:00 UTC (permalink / raw)



John G. Volan (quoting himself) wrote that Apex does this:

> > if Condition
> >   then
> >   Statement;
> > elsif Condition
> >   then
> >   Statement;
> > else
> >   Statement;
> > end if;
> 
> (The "then" keywords are indented two spaces rather than aligned left.)
> 
> > case Expression is
> >   when Choice =>
> >     Statement;
> >   when Choice =>
> >     Statement;
> > end case;
> 
> (The "when" clauses add a level of indent we don't want, so two levels
> of indent have to be unrolled after the last Statement.)
> 
> > Loop_Name:
> >   while Condition
> >     loop
> >     Statement;
> >   end loop Loop_Name;
> 
> (The Loop_Name introduces an extra level of indent we don't want; and
> the "loop" keyword is indented two spaces rather than aligned with the
> "while".)
> 
> > Block_Name:
> >   begin
> >     Statement;
> >   exception
> >     when Exception_Name =>
> >       Statement;
> >   end Block_Name;
> 
> (The "when" clauses add a level of indent we don't want, so two levels
> of indent have to be unrolled after the last Statement; and the
> Block_Name adds a whole other level of indent.)


All this is in accordance with the indentation shown in the ARM, but I
personally just hate it.  I don't think a loop or block should be
indented
just because it's named.  I feel that the "when" clauses are a parallel
part of the structure.  It makes no more sense to indent "when" or
"then"
than it does to indent "else."  Obviously, this is all just personal
opinion.  But I'm glad to see a smart guy and a significant company
agreeing with me :-) .

Sam Mize

--
-- Samuel Mize    (817) 619-8622    smize@link.com    "Team Ada"
-- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005




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

* Re: Ada95 Pretty-Printers
  1997-06-14  0:00         ` Robert Dewar
@ 1997-06-14  0:00           ` Samuel Mize
  1997-06-14  0:00             ` Robert Dewar
  0 siblings, 1 reply; 21+ messages in thread
From: Samuel Mize @ 1997-06-14  0:00 UTC (permalink / raw)



In article <dewar.866304251@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
>Only by default, in that the RM has very little to say about indentation,
...
>For recommendations on style at this level, you have to look elsewhere than
>the RM.

This is true.  I believe it's AQ&S that suggests the rule "indent the
way the ARM does," and I've seen a lot of people following that.


>Personally my only real criterion for style is absolute consistency.
>I mistrust
>people who have strong feelings about one style over another, because
>it is such
>people who end up being recalcitrant when they move into a new
>environment with
>differnt established styles.

Well, I have strong feelings, but I go with the defined style of the
project (if any).  But then, you don't have to believe that, you
mistrust me :-).

I agree that the benefits of any given style are far smaller than the
benefits of having a uniform coding style.  I was just glad to see
that there might be somewhere a project I could work on and code
like I like to code.

The original poster was looking for a way to get Apex to behave in
accordance with his project's existing style guidelines, so we
probably all three agree.

Sam Mize

-- 
Samuel Mize -- smize@imagin.net -- Team Ada
(personal net account)




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

* Re: Ada95 Pretty-Printers
  1997-06-14  0:00           ` Samuel Mize
@ 1997-06-14  0:00             ` Robert Dewar
  0 siblings, 0 replies; 21+ messages in thread
From: Robert Dewar @ 1997-06-14  0:00 UTC (permalink / raw)



Sam said

<<Well, I have strong feelings, but I go with the defined style of the
project (if any).  But then, you don't have to believe that, you
mistrust me :-).
 
I agree that the benefits of any given style are far smaller than the
benefits of having a uniform coding style.  I was just glad to see
that there might be somewhere a project I could work on and code
like I like to code.
>>



Actually my experience is that most people, unless they are really inflexible,
quickly pick up and assume another style. Furthermore, after a while they get
used to it and cannot imagine changing.

That's certainly my experience with me. I used to really like the all upper
case identifier style of the RM (and I know all the objective arguments to
support the claim that it is better than mixed case -- stands out in comments,
can be dealt with algorithmically etc).

However, I was outvoted on the GNAT project in favor of mixed case. At first
I really disliked it, and found it hard to read, now I could not THINK of
going back to ALL UPPER CASE STUFF, Ugh! :-)

And Sam, if you are happy to go with whatever style is used by your project,
then no need to mistrust you, but I have seen cases where some competent 
programmer insists on using their own style even when everyone else in the
company follows the standard style. Personally I would fire such a programmer,
but that is an extreme position, which many companies are not will to follow,
and instead they tolerate unnecessary variation.

Of course style operates at various levels. Simple rules that can be
mechanically enforced (e.g. the -gnatg rules in GNAT) are the easiest ones
for which uniformity can be achieved. Higher level style rules that are
much harder to precisely characterize are harder to enforce.

Right now, at ACT, everyone is so used to the style rules, and all the code
is in a very rigorously controlled standard style, that they share the same
set of aesthetics and consequently these higher level style rules are also
followed with remarkable consistency.





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

* Re: Ada95 Pretty-Printers
  1997-06-13  0:00       ` Samuel Mize
@ 1997-06-14  0:00         ` Tom Phinney
  1997-06-14  0:00         ` Robert Dewar
  1 sibling, 0 replies; 21+ messages in thread
From: Tom Phinney @ 1997-06-14  0:00 UTC (permalink / raw)



Samuel Mize <smize@link.com> wrote in article <33A157AA.1F2F3650@link.com>...
> John G. Volan (quoting himself) wrote that Apex does this:

<examples omitted, can be found in many prior posts in this thread>

> All this is in accordance with the indentation shown in the ARM, but I
> personally just hate it.  I don't think a loop or block should be indented
> just because it's named.  I feel that the "when" clauses are a parallel
> part of the structure.  It makes no more sense to indent "when" or "then"
> than it does to indent "else."  Obviously, this is all just personal
> opinion.  But I'm glad to see a smart guy and a significant company
> agreeing with me :-) .
-------
The whole point in the "comb" structure was 

(1) to have a structure with bounds on both ends -- the lesson learned from the
unclosed Pascal constructs like "if" (without an "end if");

(2) to have a series of "tines" between the ends of the comb to separate the
intermediate portions of the construct.

What's the point of putting a second level of indentation on the inner part of
the comb relative to the comb ends?  Why should some tines in some combs be
indented, and others not?  My personal practice is to put the "tine" keywords
either as the last or first lexeme(s) of each line, with the choice made for
readability.  This leads (with blank lines omitted when the constructs are
parallel and visually small) to

 if <Boolean-expression> then
   <sequence-of-statements>

 elsif <boolean-expression> then
   <sequence-of-statements>

 else
   <sequence-of-statements>
 end if;

when the boolean expression is small enough to fit on a single line, but any
one of the if or elsif clauses could change to a multi-line form when the
expression itself requires multiple lines, as in 

 if <very-long-multi-line-
                     boolean-expression> 
 then
   <sequence-of-statements>

 elsif <boolean-expression> then
   <sequence-of-statements>

 else
   <sequence-of-statements>
 end if;

A similar approach applies to loop, case, and the other "comb" structures.  In
fact, I frequently use the same syntax for procedure, etc. definitions, with
the "is" moving to an isolated line when that provides better readability and a
more intelligible comb structure.  This same approach works for VHDL (no
surprise :-), and has been used in a number of projects where readability was a
major issue.

Tom Phinney
Honeywell




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

* Re: Ada95 Pretty-Printers
  1997-06-13  0:00       ` Samuel Mize
  1997-06-14  0:00         ` Tom Phinney
@ 1997-06-14  0:00         ` Robert Dewar
  1997-06-14  0:00           ` Samuel Mize
  1 sibling, 1 reply; 21+ messages in thread
From: Robert Dewar @ 1997-06-14  0:00 UTC (permalink / raw)



Sam says

<<All this is in accordance with the indentation shown in the ARM, but I
personally just hate it.  I don't think a loop or block should be
indented
just because it's named.  I feel that the "when" clauses are a parallel
part of the structure.  It makes no more sense to indent "when" or
"then"
than it does to indent "else."  Obviously, this is all just personal
opinion.  But I'm glad to see a smart guy and a significant company
agreeing with me :-) .
 >>

Only by default, in that the RM has very little to say about indentation,
except at the most gross level. For instance on the subject of indenting
then's that do not fit on one line, the RM is (reasonably) silent.

For recommendations on style at this level, you have to look elsewhere than
the RM.

Personally my only real criterion for style is absolute consistency. I mistrust
people who have strong feelings about one style over another, because it is such
people who end up being recalcitrant when they move into a new environment with
differnt established styles.

The original GNAT style was established by consensus among the original GNAT
group, with simple majority voting where there were disagreements. Every now
and then, someone new starts working with the sources, and rants and raves
because they personally don't like this or that style choice. We never pay
any attention, and in our experience, anyone can get used to anything. I
really think that consistency is the ONLY critical style requirement.





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

* Re: Ada95 Pretty-Printers
  1997-06-10  0:00   ` John G. Volan
  1997-06-10  0:00     ` Spam Hater
@ 1997-06-16  0:00     ` Greg Gicca @pulsar
  1 sibling, 0 replies; 21+ messages in thread
From: Greg Gicca @pulsar @ 1997-06-16  0:00 UTC (permalink / raw)



In <339DA006.228F@sprintmail.com> "John G. Volan" <johnvolan@sprintmail.com> writes:

>Samuel Mize wrote:
>> 
>> John G. Volan wrote:
>> > Are there any pretty-printers out there for Ada95?
>> 
>> This seems to come up every so often, and the answer so far has
>> been "not really."
>> 
>> I would suppose that one could be built using the AdaMagic front
>> end, but that's sheer speculation and I don't know how much it costs.

>I've been toying with the thought of doing it using GNAT's front end ...
>or maybe this would be a good application for ASIS ... hmm ... what's
>the status of ASIS & GNAT?  Gotta look that up ...

Just a note on the use of ASIS here...  ASIS is a great tool for
developing all sorts of software tools that need various information
on Ada source; stub generators, metrics evaluators, test case
generators, etc.

However, some data returned by ASIS is not identical to that which was
originally supplied in the source code.  One example might be named
numbers or constant values.  These may be stored simply as the value
at any point of reference.  Values specified using attributes may be
stored as actual numeric values instead of the original source text,
such as: Integer'First, Char'Pos, etc.

Due to the above, an ASIS based pretty-printer may produce semanticlly
equivelent code, but not the same source text as you might expect.

Having said that I would be interested in any tools that might exist
based on ASIS 2.0.  I have several from ASIS 1.1 and would like to see
what might exist for the new standard.

Greg
gicca@aonix.com




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

end of thread, other threads:[~1997-06-16  0:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <339C58A6.4D5A@sprintmail.com>
1997-06-10  0:00 ` Ada95 Pretty-Printers Anonymous
1997-06-10  0:00   ` John G. Volan
1997-06-10  0:00 ` Samuel Mize
1997-06-10  0:00   ` John G. Volan
1997-06-10  0:00     ` Spam Hater
1997-06-10  0:00       ` Spam Hater
1997-06-16  0:00     ` Greg Gicca @pulsar
1997-06-10  0:00   ` John G. Volan
1997-06-11  0:00     ` Samuel Mize
1997-06-12  0:00     ` John G. Volan
1997-06-13  0:00       ` Samuel Mize
1997-06-14  0:00         ` Tom Phinney
1997-06-14  0:00         ` Robert Dewar
1997-06-14  0:00           ` Samuel Mize
1997-06-14  0:00             ` Robert Dewar
1997-06-12  0:00     ` Robert Dewar
1997-06-10  0:00   ` stuman
1997-06-11  0:00 ` Rolf Ebert
1997-06-11  0:00   ` John G. Volan
1997-06-11  0:00 ` Matthew Heaney
1997-06-12  0:00 ` Jeff Burns

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