Thursday, September 24, 2015

gnatpp could not align exception declaration properly

I normally use the GNAT Pretty-Printer gnatpp to format my Ada code.  The output of it is not perfect but acceptable and make my code look consistent.

It has a small alignment bug, for exception declaration, it could not handle it properly.  For this specification align_test.ads:
package Align_Test is
    Index: Integer;
    Number_Test : Integer;

    Bad_File : exception;
    Bad_Argument : exception;
end Align_Test;
gnatpp -r align_test.ads will produce:
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   Bad_File : exception;
   Bad_Argument : exception;
end Align_Test;
I have to manually align the declaration and add specific comments to fence it from gnatpp to change my alignment in future. 
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   --!pp off
   Bad_File     : exception;
   Bad_Argument : exception;
   --!pp on
end Align_Test;
It does not look good, but acceptable.  Wish next version of gnatpp could solve this problem.

P.S. Hooray, today (May. 19, 2016) AdaCore fixed the alignment problem. It will properly show up in GNAT GPL 2016.

No comments: