comp.lang.ada
 help / color / mirror / Atom feed
* Pretty-printer?  (Alternatives to "gnatpp")
@ 2016-03-13 18:07 Jacob Sparre Andersen
  2016-03-13 18:49 ` J-P. Rosen
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Jacob Sparre Andersen @ 2016-03-13 18:07 UTC (permalink / raw)


What pretty-printers are available for Ada (83-2012)?

I'm already aware of "gnatpp", but it has two disadvantages:

 1) You have to have set up the environment to compile the source file,
    before you can pretty-print it.

 2) You can't get it to select the casing of identifiers on a
    word-by-word basis (which means that I have to repeat every acronym
    we use in the project once for every identifier it occurs in).

What alternatives are there?

How do they fare compared to "gnatpp"?

Greetings,

Jacob
-- 
Ada - the programming language still ahead of its time.


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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
@ 2016-03-13 18:49 ` J-P. Rosen
  2016-03-13 19:26   ` Jacob Sparre Andersen
  2016-03-13 18:49 ` J-P. Rosen
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: J-P. Rosen @ 2016-03-13 18:49 UTC (permalink / raw)


Le 13/03/2016 19:07, Jacob Sparre Andersen a écrit :
>  2) You can't get it to select the casing of identifiers on a
>     word-by-word basis (which means that I have to repeat every acronym
>     we use in the project once for every identifier it occurs in).
Not a full pretty printer, but you can use Adasubst to replace the
casing of all identifiers with how they were declared (which is
presumably what you want).

Free and downloadable from:
http://www.adalog.fr/en/components.html#adasubst

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
  2016-03-13 18:49 ` J-P. Rosen
@ 2016-03-13 18:49 ` J-P. Rosen
  2016-03-13 19:33 ` Britt
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: J-P. Rosen @ 2016-03-13 18:49 UTC (permalink / raw)


Le 13/03/2016 19:07, Jacob Sparre Andersen a écrit :
>  2) You can't get it to select the casing of identifiers on a
>     word-by-word basis (which means that I have to repeat every acronym
>     we use in the project once for every identifier it occurs in).


-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-13 18:49 ` J-P. Rosen
@ 2016-03-13 19:26   ` Jacob Sparre Andersen
  0 siblings, 0 replies; 14+ messages in thread
From: Jacob Sparre Andersen @ 2016-03-13 19:26 UTC (permalink / raw)


J-P. Rosen wrote:

> Not a full pretty printer, but you can use Adasubst to replace the
> casing of all identifiers with how they were declared (which is
> presumably what you want).

Actually not.  I have too many cases of identifiers declared in a form
which conflicts with the common (Ada 95) casing rules.

But thanks for the suggestion anyway.

Greetings,

Jacob
-- 
"If it's a mess, hide it..." -- J-P. Rosen


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

* Re: Pretty-printer?  (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
  2016-03-13 18:49 ` J-P. Rosen
  2016-03-13 18:49 ` J-P. Rosen
@ 2016-03-13 19:33 ` Britt
  2016-03-13 20:32   ` Jacob Sparre Andersen
  2016-03-13 21:37 ` Georg Bauhaus
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Britt @ 2016-03-13 19:33 UTC (permalink / raw)


On Sunday, March 13, 2016 at 2:07:34 PM UTC-4, Jacob Sparre Andersen wrote:

>  2) You can't get it to select the casing of identifiers on a
>     word-by-word basis (which means that I have to repeat every acronym
>     we use in the project once for every identifier it occurs in).

Perhaps I don't understand your problem but gnatpp uses "as declared" casing by default and then you use can supplement this with dictionary files for global casing exceptions. For example, the following line:

*VxWorks*

in a dictionary file (see gnatpp's -D switch) will case all variations of of "vxworks" between underscores in identifiers to be consistently cased as "VxWorks".

-Britt

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

* Re: Pretty-printer?  (Alternatives to "gnatpp")
  2016-03-13 19:33 ` Britt
@ 2016-03-13 20:32   ` Jacob Sparre Andersen
  0 siblings, 0 replies; 14+ messages in thread
From: Jacob Sparre Andersen @ 2016-03-13 20:32 UTC (permalink / raw)


Britt wrote:

> Perhaps I don't understand your problem but gnatpp uses "as declared"
> casing by default and then you use can supplement this with dictionary
> files for global casing exceptions. For example, the following line:
>
> *VxWorks*
>
> in a dictionary file (see gnatpp's -D switch) will case all variations
> of of "vxworks" between underscores in identifiers to be consistently
> cased as "VxWorks".

Thanks for that explanation.  I'll try it out.  But a tool which doesn't
depend on compiling the source file first would still be nice.

Greetings,

Jacob
-- 
»I like it when the support group complains that they have
 insufficient data on mean time to repair bugs in Ada
 software.«                              -- Robert I. Eachus


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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
                   ` (2 preceding siblings ...)
  2016-03-13 19:33 ` Britt
@ 2016-03-13 21:37 ` Georg Bauhaus
  2016-03-13 21:42 ` Georg Bauhaus
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Georg Bauhaus @ 2016-03-13 21:37 UTC (permalink / raw)


On 13.03.16 19:07, Jacob Sparre Andersen wrote:
> What pretty-printers are available for Ada (83-2012)?
http://www.irvine.com/freebies.html

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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
                   ` (3 preceding siblings ...)
  2016-03-13 21:37 ` Georg Bauhaus
@ 2016-03-13 21:42 ` Georg Bauhaus
  2016-03-14  6:43   ` Bob Butler
  2016-03-14  0:58 ` Shark8
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Georg Bauhaus @ 2016-03-13 21:42 UTC (permalink / raw)


On 13.03.16 19:07, Jacob Sparre Andersen wrote:
>   2) You can't get it to select the casing of identifiers on a
>      word-by-word basis (which means that I have to repeat every acronym
>      we use in the project once for every identifier it occurs in).

The (new) Ada mode for Emacs can be used as a pretty printer,
for all versions of Ada, and it supports automatic letter case.
The user may define a list of exceptions to the casing rules
that he prefers.


-- 
"HOTDOGS ARE NOT BOOKMARKS"
Springfield Elementary teaching staff

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

* Pretty-printer?  (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
                   ` (4 preceding siblings ...)
  2016-03-13 21:42 ` Georg Bauhaus
@ 2016-03-14  0:58 ` Shark8
  2016-03-14 23:47 ` Randy Brukardt
  2016-03-15  0:15 ` Britt
  7 siblings, 0 replies; 14+ messages in thread
From: Shark8 @ 2016-03-14  0:58 UTC (permalink / raw)


Byron is at the lexing stage, it could therefore be used as input to a pretty-printer... or just add a "filter" function that has a local dictionary w/ identifiers of the casing you want and iterate over the token-array with the following conditional:
IF token is identifier THEN
  IF identifier not present THEN add identifier to dictionary
  OTHERWISE replace identifier w/ one of the found casing.
  END IF
END IF

https://github.com/OneWingedShark/Byron


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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-13 21:42 ` Georg Bauhaus
@ 2016-03-14  6:43   ` Bob Butler
  2016-03-14 12:01     ` G.B.
  0 siblings, 1 reply; 14+ messages in thread
From: Bob Butler @ 2016-03-14  6:43 UTC (permalink / raw)


On 2016-03-13, Georg Bauhaus <bauhaus@futureapps.invalid> wrote:
> On 13.03.16 19:07, Jacob Sparre Andersen wrote:
>>   2) You can't get it to select the casing of identifiers on a
>>      word-by-word basis (which means that I have to repeat every acronym
>>      we use in the project once for every identifier it occurs in).
>
> The (new) Ada mode for Emacs can be used as a pretty printer,
> for all versions of Ada, and it supports automatic letter case.
> The user may define a list of exceptions to the casing rules
> that he prefers.

I thought of that too but I don't know if you can print from Emacs. I guess
you probably can, there isn't much Emacs can't do.

Emacs language modes are so good you can often (always?) catch syntax errors
in many programming languages even before you try compiling. When Emacs
screws up the indentation or mangles the code when you're editing there's a
darn good chance you have a syntax error!

Bob


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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-14  6:43   ` Bob Butler
@ 2016-03-14 12:01     ` G.B.
  2016-03-14 13:13       ` Simon Wright
  0 siblings, 1 reply; 14+ messages in thread
From: G.B. @ 2016-03-14 12:01 UTC (permalink / raw)


On 14.03.16 07:43, Bob Butler wrote:
> On 2016-03-13, Georg Bauhaus <bauhaus@futureapps.invalid> wrote:
>> On 13.03.16 19:07, Jacob Sparre Andersen wrote:
>>>    2) You can't get it to select the casing of identifiers on a
>>>       word-by-word basis (which means that I have to repeat every acronym
>>>       we use in the project once for every identifier it occurs in).
>>
>> The (new) Ada mode for Emacs can be used as a pretty printer,
>> for all versions of Ada, and it supports automatic letter case.
>> The user may define a list of exceptions to the casing rules
>> that he prefers.
>
> I thought of that too but I don't know if you can print from Emacs. I guess
> you probably can, there isn't much Emacs can't do.

You can print from Emacs, as the following example shows.
(To "print" as in to "write pretty printed text to output";
there also is colored postscript printing, etc.)

Ada mode does report syntax errors. Still, it is lenient
when all that it should do is letter case. Example input:

procedure Synerr is
begin
    null:
end synErr;

about which file Emacs says, when visiting,

synerr.adb:3:8: syntax error in grammar state 641; unexpected :, 
expecting one of (default SEMICOLON)

And then, indeed, trying to indent will screw up the indentation.
Nevertheless, evaluating the sequence of commands

(ada-case-adjust-buffer)
(write-file "synerr.pretty.adb")

will yield a new file "synerr.pretty.adb" that looks like this:

procedure Synerr is
begin
    null:
end Synerr;

So, the last line now also follows the usual letter case rules,
spelling "Synerr" the same in both places. (The syntax error is
still present.)


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

* Re: Pretty-printer? (Alternatives to "gnatpp")
  2016-03-14 12:01     ` G.B.
@ 2016-03-14 13:13       ` Simon Wright
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Wright @ 2016-03-14 13:13 UTC (permalink / raw)


"G.B." <bauhaus@futureapps.invalid> writes:

> Ada mode does report syntax errors. Still, it is lenient
> when all that it should do is letter case. Example input:
>
> procedure Synerr is
> begin
>    null:
> end synErr;
>
> about which file Emacs says, when visiting,
>
> synerr.adb:3:8: syntax error in grammar state 641; unexpected :,
> expecting one of (default SEMICOLON)

And if you C-c C-f point will be placed on the error.

I have ada-case-strict set to nil, which leaves the last line as

   end SynErr;

because I don't want to have to set up a case exception for every
CamelCased name.


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

* Re: Pretty-printer?  (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
                   ` (5 preceding siblings ...)
  2016-03-14  0:58 ` Shark8
@ 2016-03-14 23:47 ` Randy Brukardt
  2016-03-15  0:15 ` Britt
  7 siblings, 0 replies; 14+ messages in thread
From: Randy Brukardt @ 2016-03-14 23:47 UTC (permalink / raw)


"Jacob Sparre Andersen" <sparre@nbi.dk> wrote in message 
news:87a8m2jlp7.fsf@adaheads.consafe1.org...
> What pretty-printers are available for Ada (83-2012)?
>
> I'm already aware of "gnatpp", but it has two disadvantages:
>
> 1) You have to have set up the environment to compile the source file,
>    before you can pretty-print it.
>
> 2) You can't get it to select the casing of identifiers on a
>    word-by-word basis (which means that I have to repeat every acronym
>    we use in the project once for every identifier it occurs in).
>
> What alternatives are there?

The Janus/Ada syntax checker (comes with the Professional Version of 
Janus/Ada) includes a pretty printer mode.

The only setup it requires is that of the entire Janus/Ada system (and 
really, it just needs to be on the path). It's a separate tool from the days 
when compilations took 5 minutes - waiting that long meant that one tended 
to start a build and then go to lunch or a coffee break - and it was really 
annoying to get back and find out that I'd left out a semicolon in the third 
file.

These days, I use it to check syntax on new ACATS tests ('cause it does the 
entire Ada 2012 grammar, Janus/Ada itself does so little more than that it 
isn't worth setting up a compile). It's alway good to get more than one 
opinion (GNAT is not perfect!).

The casing of identifiers has a number of options, one of which is to leave 
them alone program-wide. (/AS - "Same case"). We never thought of the GNAT 
idea of making everything match the declaration (and of course that would be 
a lot harder to do that as opposed to just using Title capitalization or all 
UPPER case).

I'd be a bit concerned about what it will do on newer syntax; I've tested a 
few things but we don't really have any customers who've reported problems 
in it recently so it gets a lower priority than most things.

> How do they fare compared to "gnatpp"?

Dunno, never used gnatpp (and rarely use "syntax" as a pretty printer, 
either).

                                           Randy.


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

* Re: Pretty-printer?  (Alternatives to "gnatpp")
  2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
                   ` (6 preceding siblings ...)
  2016-03-14 23:47 ` Randy Brukardt
@ 2016-03-15  0:15 ` Britt
  7 siblings, 0 replies; 14+ messages in thread
From: Britt @ 2016-03-15  0:15 UTC (permalink / raw)


On Sunday, March 13, 2016 at 2:07:34 PM UTC-4, Jacob Sparre Andersen wrote:
> What pretty-printers are available for Ada (83-2012)?
> 
> I'm already aware of "gnatpp", but it has two disadvantages:
> 
>  1) You have to have set up the environment to compile the source file,
>     before you can pretty-print it.

Yes, this is a constraint but it also permits gnatpp to make consistent, global changes like "as declared" casing across all the files in a GNAT project tree. gnatpp has some remaining quirks but overall it has gotten better and more flexible over the years.
> 
>  2) ...

> What alternatives are there?

For formatting single files as you edit, I've been happy enough with the formatting capabilities build into GPS and GNATbench. These don't require files to be completely compilable.

-Britt


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

end of thread, other threads:[~2016-03-15  0:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-13 18:07 Pretty-printer? (Alternatives to "gnatpp") Jacob Sparre Andersen
2016-03-13 18:49 ` J-P. Rosen
2016-03-13 19:26   ` Jacob Sparre Andersen
2016-03-13 18:49 ` J-P. Rosen
2016-03-13 19:33 ` Britt
2016-03-13 20:32   ` Jacob Sparre Andersen
2016-03-13 21:37 ` Georg Bauhaus
2016-03-13 21:42 ` Georg Bauhaus
2016-03-14  6:43   ` Bob Butler
2016-03-14 12:01     ` G.B.
2016-03-14 13:13       ` Simon Wright
2016-03-14  0:58 ` Shark8
2016-03-14 23:47 ` Randy Brukardt
2016-03-15  0:15 ` Britt

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