comp.lang.ada
 help / color / mirror / Atom feed
* How to check code indentation?
@ 2017-09-25 21:08 Victor Porton
  2017-09-25 22:35 ` gautier_niouzes
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Victor Porton @ 2017-09-25 21:08 UTC (permalink / raw)


I have a source code where some declarations or statements are indented 
wrongly. An example:

   function raptor_namespaces_find_namespace (Stack: Namespace_Stack_Handle;
                                                Prefix: chars_ptr;
                                                Len: int)
                                                return Namespace_Handle
     with Import, Convention=>C;

("Prefix" is not below "Stack" but two spaces are extraneous.)

I use -gnaty3 but weirdly GNAT 7.2.0 does not detect this error.

Is there any free tool to check (or even better automatically correct) Ada 
(preferably Ada2012) indentation?

-- 
Victor Porton - http://portonvictor.org


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

* Re: How to check code indentation?
  2017-09-25 21:08 How to check code indentation? Victor Porton
@ 2017-09-25 22:35 ` gautier_niouzes
  2017-09-25 23:08   ` Victor Porton
  2017-09-25 23:10 ` Victor Porton
  2017-09-27  4:07 ` Per Sandberg
  2 siblings, 1 reply; 9+ messages in thread
From: gautier_niouzes @ 2017-09-25 22:35 UTC (permalink / raw)


> Is there any free tool to check (or even better automatically correct) Ada 
> (preferably Ada2012) indentation?

There are reformatters, like:
  - ICCFMT: http://www.irvine.com/freebies.html
  - the reformatter tool in AdaGIDE: https://sf.net/projects/adagide
...and probably others.
If you want to check the before vs. after states to be sure nothing got lost on the way, the Normalize tool can be helpful:
    http://adalog.fr/en/components.html#Normalize

HTH
Gautier
_____________________________________________________________
A free online game in Ada: http://pasta.phyrama.com/game.html
New: High Scores lists!


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

* Re: How to check code indentation?
  2017-09-25 22:35 ` gautier_niouzes
@ 2017-09-25 23:08   ` Victor Porton
  2017-09-27  3:23     ` Stephen Leake
  0 siblings, 1 reply; 9+ messages in thread
From: Victor Porton @ 2017-09-25 23:08 UTC (permalink / raw)


gautier_niouzes@hotmail.com wrote:

>> Is there any free tool to check (or even better automatically correct)
>> Ada (preferably Ada2012) indentation?
> 
> There are reformatters, like:
>   - ICCFMT: http://www.irvine.com/freebies.html

I need Ada2012 support. It does not.

>   - the reformatter tool in AdaGIDE: https://sf.net/projects/adagide

It is for Windows. I am a Linux user.

> ...and probably others.
> If you want to check the before vs. after states to be sure nothing got
> lost on the way, the Normalize tool can be helpful:
>     http://adalog.fr/en/components.html#Normalize

It doesn't help in my task.

-- 
Victor Porton - http://portonvictor.org

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

* Re: How to check code indentation?
  2017-09-25 21:08 How to check code indentation? Victor Porton
  2017-09-25 22:35 ` gautier_niouzes
@ 2017-09-25 23:10 ` Victor Porton
  2017-09-25 23:43   ` Anh Vo
  2017-09-27  4:07 ` Per Sandberg
  2 siblings, 1 reply; 9+ messages in thread
From: Victor Porton @ 2017-09-25 23:10 UTC (permalink / raw)


Victor Porton wrote:

> I have a source code where some declarations or statements are indented
> wrongly. An example:
> 
>    function raptor_namespaces_find_namespace (Stack:
>    Namespace_Stack_Handle;
>                                                 Prefix: chars_ptr;
>                                                 Len: int)
>                                                 return Namespace_Handle
>      with Import, Convention=>C;
> 
> ("Prefix" is not below "Stack" but two spaces are extraneous.)
> 
> I use -gnaty3 but weirdly GNAT 7.2.0 does not detect this error.
> 
> Is there any free tool to check (or even better automatically correct) Ada
> (preferably Ada2012) indentation?

Hm, GNAT GPS does (however sometimes wrong) Ada code reformatting when 
pressing Tab key.

Can it be scripted in some way to do Ada reformatting automatically for a 
set of source files?

-- 
Victor Porton - http://portonvictor.org


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

* Re: How to check code indentation?
  2017-09-25 23:10 ` Victor Porton
@ 2017-09-25 23:43   ` Anh Vo
  2017-09-25 23:59     ` Victor Porton
  0 siblings, 1 reply; 9+ messages in thread
From: Anh Vo @ 2017-09-25 23:43 UTC (permalink / raw)


On Monday, September 25, 2017 at 4:10:33 PM UTC-7, Victor Porton wrote:
> Victor Porton wrote:
> 
> > I have a source code where some declarations or statements are indented
> > wrongly. An example:
> > 
> >    function raptor_namespaces_find_namespace (Stack:
> >    Namespace_Stack_Handle;
> >                                                 Prefix: chars_ptr;
> >                                                 Len: int)
> >                                                 return Namespace_Handle
> >      with Import, Convention=>C;
> > 
> > ("Prefix" is not below "Stack" but two spaces are extraneous.)
> > 
> > I use -gnaty3 but weirdly GNAT 7.2.0 does not detect this error.
> > 
> > Is there any free tool to check (or even better automatically correct) Ada
> > (preferably Ada2012) indentation?
> 
> Hm, GNAT GPS does (however sometimes wrong) Ada code reformatting when 
> pressing Tab key.
> 
> Can it be scripted in some way to do Ada reformatting automatically for a 
> set of source files?

Have you looked at gnatpp command? 

Anh Vo

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

* Re: How to check code indentation?
  2017-09-25 23:43   ` Anh Vo
@ 2017-09-25 23:59     ` Victor Porton
  2017-09-26  0:00       ` Victor Porton
  0 siblings, 1 reply; 9+ messages in thread
From: Victor Porton @ 2017-09-25 23:59 UTC (permalink / raw)


Anh Vo wrote:

> On Monday, September 25, 2017 at 4:10:33 PM UTC-7, Victor Porton wrote:
>> Victor Porton wrote:
>> 
>> > I have a source code where some declarations or statements are indented
>> > wrongly. An example:
>> > 
>> >    function raptor_namespaces_find_namespace (Stack:
>> >    Namespace_Stack_Handle;
>> >                                                 Prefix: chars_ptr;
>> >                                                 Len: int)
>> >                                                 return Namespace_Handle
>> >      with Import, Convention=>C;
>> > 
>> > ("Prefix" is not below "Stack" but two spaces are extraneous.)
>> > 
>> > I use -gnaty3 but weirdly GNAT 7.2.0 does not detect this error.
>> > 
>> > Is there any free tool to check (or even better automatically correct)
>> > Ada (preferably Ada2012) indentation?
>> 
>> Hm, GNAT GPS does (however sometimes wrong) Ada code reformatting when
>> pressing Tab key.
>> 
>> Can it be scripted in some way to do Ada reformatting automatically for a
>> set of source files?
> 
> Have you looked at gnatpp command?

Thanks, I am now checking it.

But it seems not to work :-(

Consider this short file test.ads:

  package test is
    end test;

I run /usr/local/stow/gnat-gpl-2017-x86_64-linux-bin/bin/gnatpp -i3 test.ads

There is no output and the file is not changed, it's wrong alignment 
remains.

What is wrong?

-- 
Victor Porton - http://portonvictor.org

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

* Re: How to check code indentation?
  2017-09-25 23:59     ` Victor Porton
@ 2017-09-26  0:00       ` Victor Porton
  0 siblings, 0 replies; 9+ messages in thread
From: Victor Porton @ 2017-09-26  0:00 UTC (permalink / raw)


Victor Porton wrote:

> Anh Vo wrote:
> 
>> On Monday, September 25, 2017 at 4:10:33 PM UTC-7, Victor Porton wrote:
>>> Victor Porton wrote:
>>> 
>>> > I have a source code where some declarations or statements are
>>> > indented wrongly. An example:
>>> > 
>>> >    function raptor_namespaces_find_namespace (Stack:
>>> >    Namespace_Stack_Handle;
>>> >                                                 Prefix: chars_ptr;
>>> >                                                 Len: int)
>>> >                                                 return
>>> >                                                 Namespace_Handle
>>> >      with Import, Convention=>C;
>>> > 
>>> > ("Prefix" is not below "Stack" but two spaces are extraneous.)
>>> > 
>>> > I use -gnaty3 but weirdly GNAT 7.2.0 does not detect this error.
>>> > 
>>> > Is there any free tool to check (or even better automatically correct)
>>> > Ada (preferably Ada2012) indentation?
>>> 
>>> Hm, GNAT GPS does (however sometimes wrong) Ada code reformatting when
>>> pressing Tab key.
>>> 
>>> Can it be scripted in some way to do Ada reformatting automatically for
>>> a set of source files?
>> 
>> Have you looked at gnatpp command?
> 
> Thanks, I am now checking it.
> 
> But it seems not to work :-(
> 
> Consider this short file test.ads:
> 
>   package test is
>     end test;
> 
> I run /usr/local/stow/gnat-gpl-2017-x86_64-linux-bin/bin/gnatpp -i3
> test.ads
> 
> There is no output and the file is not changed, it's wrong alignment
> remains.
> 
> What is wrong?

Oh, I see it works if I add -r option.

-- 
Victor Porton - http://portonvictor.org


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

* Re: How to check code indentation?
  2017-09-25 23:08   ` Victor Porton
@ 2017-09-27  3:23     ` Stephen Leake
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Leake @ 2017-09-27  3:23 UTC (permalink / raw)


On Monday, September 25, 2017 at 6:09:05 PM UTC-5, Victor Porton wrote:
> gautier_niouzes@hotmail.com wrote:
> 
> >> Is there any free tool to check (or even better automatically correct)
> >> Ada (preferably Ada2012) indentation?
> > 
> > There are reformatters, like:
> >   - ICCFMT: http://www.irvine.com/freebies.html
> 
> I need Ada2012 support. It does not.
> 
> >   - the reformatter tool in AdaGIDE: https://sf.net/projects/adagide
> 
> It is for Windows. I am a Linux user.
> 
> > ...and probably others.
> > If you want to check the before vs. after states to be sure nothing got
> > lost on the way, the Normalize tool can be helpful:
> >     http://adalog.fr/en/components.html#Normalize
> 
> It doesn't help in my task.
> 
> -- 
> Victor Porton - http://portonvictor.org

Emacs Ada mode does indentation, with full Ada 2012 support.

With a little elisp programming, you can use it for both test and fix.

The simplest way to test is to save the file to a different name, indent, and diff.


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

* Re: How to check code indentation?
  2017-09-25 21:08 How to check code indentation? Victor Porton
  2017-09-25 22:35 ` gautier_niouzes
  2017-09-25 23:10 ` Victor Porton
@ 2017-09-27  4:07 ` Per Sandberg
  2 siblings, 0 replies; 9+ messages in thread
From: Per Sandberg @ 2017-09-27  4:07 UTC (permalink / raw)


Use GPS with the plugin Autoformat enable then the file will be 
formatted every time its saved to disk.
/P


Den 2017-09-25 kl. 23:08, skrev Victor Porton:
> I have a source code where some declarations or statements are indented
> wrongly. An example:
> 
>     function raptor_namespaces_find_namespace (Stack: Namespace_Stack_Handle;
>                                                  Prefix: chars_ptr;
>                                                  Len: int)
>                                                  return Namespace_Handle
>       with Import, Convention=>C;
> 
> ("Prefix" is not below "Stack" but two spaces are extraneous.)
> 
> I use -gnaty3 but weirdly GNAT 7.2.0 does not detect this error.
> 
> Is there any free tool to check (or even better automatically correct) Ada
> (preferably Ada2012) indentation?
> 

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

end of thread, other threads:[~2017-09-27  4:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 21:08 How to check code indentation? Victor Porton
2017-09-25 22:35 ` gautier_niouzes
2017-09-25 23:08   ` Victor Porton
2017-09-27  3:23     ` Stephen Leake
2017-09-25 23:10 ` Victor Porton
2017-09-25 23:43   ` Anh Vo
2017-09-25 23:59     ` Victor Porton
2017-09-26  0:00       ` Victor Porton
2017-09-27  4:07 ` Per Sandberg

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