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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC,T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,19b6efa2ecebaed0 X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Ada95 Pretty-Printers Date: 1997/06/10 Message-ID: <339DA006.228F@sprintmail.com> X-Deja-AN: 247514226 References: <339C58A6.4D5A@sprintmail.com> <339D677D.2FAC886C@link.com> Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-06-10T00:00:00+00:00 List-Id: 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? :-) "); ------------------------------------------------------------------------