4.3.1. Migrating from gnatpp switches

This page helps users of gnatpp get the same formatting with GNATformat. Some gnatpp switches have a direct GNATformat counterpart, or match GNATformat’s default behavior. For the others, the following sections give a configuration snippet that makes GNATformat format code the same way, or in a similar way.

4.3.1.1. Using a configuration snippet

Save the snippet to a JSON file and pass that file to the --override-layout switch:

gnatformat -P prj.gpr --override-layout separate_then.json

To make it permanent, use the Override_Layout attribute in the Format package of the project file:

package Format is
   for Override_Layout ("Ada") use ("separate_then.json");
end Format;

To mimic several gnatpp switches, pass several snippets. They are applied in the order they are given:

gnatformat -P prj.gpr --override-layout separate_then.json \
  --override-layout vertical_enum_types.json

Each snippet is designed to be used on its own. Two snippets may change the layout of the same construct, in which case the last one wins. Check the result when you combine snippets, and adapt them to your needs if necessary.

4.3.1.2. Switches covered by a configuration snippet

gnatpp switch

Result

Notes

--alignment

Similar

:= in assignments and parameter modes are not aligned

--call-threshold=1

Same

Only for a threshold of 1

--no-separate-is

Same

--no-separate-loop-then

Same

--par-threshold=1

Same

Only for a threshold of 1

--separate-loop

Same

--separate-then

Same

--split-line-before-record

Same

--vertical-array-types

Similar

Index definitions that do not fit on one line go on separate lines

--vertical-case-alternatives

Same

--vertical-enum-types

Same

--vertical-named-aggregates

Same

4.3.1.3. Switches that need no configuration snippet

The following gnatpp switches have a GNATformat switch (and the corresponding Format project attribute) with the same effect, or match GNATformat’s default behavior:

gnatpp switch

GNATformat equivalent

-Mnnn, --max-line-length=nnn

--width=nnn (Width attribute)

-in, --indentation=n

--indentation=n (Indentation attribute)

-cln, --indent-continuation=n

--indentation-continuation=n (Indentation_Continuation attribute)

--eol=lf, --eol=crlf

--end-of-line=lf, --end-of-line=crlf (End_Of_Line attribute)

-kL, --keyword-lower-case (default); -kU, --keyword-upper-case

--keyword-casing=lower, --keyword-casing=upper (Keyword_Casing attribute). Note that GNATformat keeps the casing of keywords by default.

-nD, --name-case-as-declared (default); -nL, -nU, -nM

--identifier-casing=definition, lower, upper, mixed (Identifier_Casing attribute). Note that GNATformat keeps the casing of identifiers by default.

--ignore=filename

--ignore=filename (Ignore attribute)

--pipe

--pipe

--split-line-before-op

Default behavior. Note that when an expression does not fit on one line, GNATformat puts each operand on its own line.

4.3.1.4. --alignment

By default, gnatpp vertically aligns the constructs below when they are on consecutive lines; a blank line ends the alignment. -A0 (or --no-alignment) turns alignment off.

The gnatpp documentation describes -A1 to -A5 as a way to turn on each alignment separately after -A0. The current gnatpp turns all of them on as soon as one of these switches is given, so in practice alignment is either all on (the default) or all off.

Switch

gnatpp aligns

GNATformat

-A1

: in declarations

Default layout

-A2

:= in initializations in declarations

This configuration snippet

-A3

:= in assignment statements

Not supported

-A4

=> in associations

Default layout

-A5

at in the component clauses of record representation clauses

Default layout

GNATformat equivalent

{
  "node_configs": {
    "ObjectDecl": {
      "node": [
        {
          "kind": "group",
          "document": [
            {
              "kind": "recurse_field",
              "field": "f_ids"
            },
            "whitespace"
          ]
        },
        {
          "kind": "tableSeparator",
          "text": ":"
        },
        {
          "kind": "group",
          "document": [
            {
              "kind": "group",
              "document": [
                {
                  "kind": "continuationLineIndent",
                  "contents": [
                    "line",
                    {
                      "kind": "group",
                      "document": [
                        {
                          "kind": "recurse_field",
                          "field": "f_has_aliased"
                        },
                        {
                          "kind": "if",
                          "condition": {
                            "kind": "is_a",
                            "node": {
                              "kind": "eval_member",
                              "member": "f_has_aliased",
                              "prefix": "this_node"
                            },
                            "pattern": {
                              "kind": "node",
                              "type": "AliasedPresent"
                            }
                          },
                          "then": "whitespace",
                          "else": []
                        },
                        {
                          "kind": "recurse_field",
                          "field": "f_has_constant"
                        },
                        {
                          "kind": "if",
                          "condition": {
                            "kind": "is_a",
                            "node": {
                              "kind": "eval_member",
                              "member": "f_has_constant",
                              "prefix": "this_node"
                            },
                            "pattern": {
                              "kind": "node",
                              "type": "ConstantPresent"
                            }
                          },
                          "then": "whitespace",
                          "else": []
                        },
                        {
                          "kind": "recurse_field",
                          "field": "f_mode"
                        },
                        {
                          "kind": "recurse_field",
                          "field": "f_type_expr"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "id": "object_decl_type"
        },
        {
          "kind": "recurse_field",
          "field": "f_default_expr"
        },
        {
          "kind": "recurse_field",
          "field": "f_renaming_clause"
        },
        {
          "kind": "recurse_field",
          "field": "f_aspects"
        },
        {
          "kind": "text",
          "text": ";"
        }
      ],
      "fields": {
        "f_renaming_clause": [
          "whitespace",
          {
            "kind": "ifBreak",
            "breakContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "continuationLineIndent",
                "contents": "recurse"
              }
            },
            "flatContents": {
              "kind": "continuationLineIndent",
              "contents": "recurse"
            },
            "groupId": "object_decl_type"
          }
        ],
        "f_default_expr": [
          "whitespace",
          {
            "kind": "tableSeparator",
            "text": ":="
          },
          {
            "kind": "ifBreak",
            "breakContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": [
                    "line",
                    "recurse"
                  ]
                }
              }
            },
            "flatContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "group",
                "document": [
                  "line",
                  "recurse"
                ]
              }
            },
            "groupId": "object_decl_type"
          }
        ],
        "f_aspects": [
          "line",
          "recurse"
        ]
      }
    },
    "ComponentDecl": {
      "node": [
        {
          "kind": "group",
          "document": {
            "kind": "recurse_field",
            "field": "f_ids"
          }
        },
        "whitespace",
        {
          "kind": "tableSeparator",
          "text": ":"
        },
        {
          "kind": "group",
          "document": [
            {
              "kind": "continuationLineIndent",
              "contents": [
                "line",
                {
                  "kind": "recurse_field",
                  "field": "f_component_def"
                }
              ]
            }
          ],
          "id": "component_type"
        },
        {
          "kind": "recurse_field",
          "field": "f_default_expr"
        },
        {
          "kind": "recurse_field",
          "field": "f_aspects"
        },
        {
          "kind": "text",
          "text": ";"
        }
      ],
      "fields": {
        "f_default_expr": [
          "whitespace",
          {
            "kind": "tableSeparator",
            "text": ":="
          },
          {
            "kind": "ifBreak",
            "breakContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": [
                    "line",
                    "recurse"
                  ]
                }
              }
            },
            "flatContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "group",
                "document": [
                  "line",
                  "recurse"
                ]
              }
            },
            "groupId": "component_type"
          }
        ]
      }
    },
    "ParamSpec": {
      "node": [
        {
          "kind": "group",
          "document": [
            {
              "kind": "recurse_field",
              "field": "f_ids"
            },
            "whitespace"
          ]
        },
        {
          "kind": "tableSeparator",
          "text": ":"
        },
        {
          "kind": "group",
          "document": [
            {
              "kind": "continuationLineIndent",
              "contents": [
                "line",
                {
                  "kind": "group",
                  "document": [
                    {
                      "kind": "recurse_field",
                      "field": "f_has_aliased"
                    },
                    {
                      "kind": "recurse_field",
                      "field": "f_mode"
                    },
                    {
                      "kind": "tableSeparator",
                      "text": ""
                    },
                    {
                      "kind": "recurse_field",
                      "field": "f_type_expr"
                    }
                  ]
                }
              ]
            }
          ],
          "id": "param_spec_type"
        },
        {
          "kind": "recurse_field",
          "field": "f_default_expr"
        },
        {
          "kind": "recurse_field",
          "field": "f_aspects"
        }
      ],
      "fields": {
        "f_default_expr": [
          "whitespace",
          {
            "kind": "tableSeparator",
            "text": ":="
          },
          {
            "kind": "ifBreak",
            "breakContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": [
                    "line",
                    "recurse"
                  ]
                }
              }
            },
            "flatContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "group",
                "document": [
                  "line",
                  "recurse"
                ]
              }
            },
            "groupId": "param_spec_type"
          }
        ]
      }
    }
  }
}

Example

Input code:

package Alignment is

    type Point is record
       X : Integer := 0;
       Y_Coordinate : Long_Integer := 0;
       Visible : Boolean;
    end record;

    procedure Move (Origin : Point; DX : Integer := 0; DY_Offset : Long_Integer := 0; Scale : Float := 1.0);

    Var_Int : constant Integer := 15;
    Var_Bool : Boolean := True;
    Var_Float : Float := 0.1;

    Var_After_Blank_Line_Sep : Integer := 123;

end Alignment;

GNATformat output with the configuration snippet above:

package Alignment is

   type Point is record
      X            : Integer      := 0;
      Y_Coordinate : Long_Integer := 0;
      Visible      : Boolean;
   end record;

   procedure Move
     (Origin    : Point;
      DX        : Integer      := 0;
      DY_Offset : Long_Integer := 0;
      Scale     : Float        := 1.0);

   Var_Int   : constant Integer := 15;
   Var_Bool  : Boolean          := True;
   Var_Float : Float            := 0.1;

   Var_After_Blank_Line_Sep : Integer := 123;

end Alignment;

Differences with gnatpp

  • := in assignment statements are not aligned. In the unparsing configuration, only blank lines and comments can end an alignment, so consecutive assignments would also be aligned across the other statements between them.

  • gnatpp also aligns the types of parameter specifications after their modes (E :    out Float). GNATformat does not.

  • In record representation clauses, gnatpp also aligns the bounds of the ranges (0 ..  7). GNATformat does not.

4.3.1.5. --call-threshold=1

With --call-threshold=nnn, gnatpp puts each parameter association on its own line when a call or a generic instantiation has more than nnn associations and at least one of them uses named notation.

GNATformat equivalent

{
  "node_configs": {
    "GenericPackageInstantiation": {
      "node": {
        "kind": "group",
        "document": {
          "kind": "continuationLineIndent",
          "contents": [
            {
              "kind": "text",
              "text": "package"
            },
            "whitespace",
            {
              "kind": "recurse_field",
              "field": "f_name"
            },
            "whitespace",
            {
              "kind": "text",
              "text": "is"
            },
            "whitespace",
            {
              "kind": "text",
              "text": "new"
            },
            {
              "kind": "group",
              "id": "generic_name",
              "document": [
                "line",
                {
                  "kind": "recurse_field",
                  "field": "f_generic_pkg_name"
                }
              ]
            },
            {
              "kind": "ifBreak",
              "groupId": "generic_name",
              "breakContents": {
                "kind": "continuationLineIndent",
                "contents": [
                  {
                    "kind": "recurse_field",
                    "field": "f_params"
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_aspects"
                  }
                ]
              },
              "flatContents": [
                {
                  "kind": "recurse_field",
                  "field": "f_params"
                },
                {
                  "kind": "recurse_field",
                  "field": "f_aspects"
                }
              ]
            },
            {
              "kind": "text",
              "text": ";"
            }
          ]
        }
      },
      "fields": {
        "f_params": [
          "line",
          {
            "kind": "align",
            "width": " ",
            "contents": [
              {
                "kind": "text",
                "text": "("
              },
              "recurse",
              {
                "kind": "text",
                "text": ")"
              }
            ]
          }
        ]
      }
    },
    "GenericSubpInstantiation": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": {
              "kind": "continuationLineIndent",
              "contents": [
                {
                  "kind": "recurse_field",
                  "field": "f_kind"
                },
                "whitespace",
                {
                  "kind": "recurse_field",
                  "field": "f_subp_name"
                },
                "whitespace",
                {
                  "kind": "text",
                  "text": "is"
                },
                "whitespace",
                {
                  "kind": "text",
                  "text": "new"
                },
                {
                  "kind": "group",
                  "id": "generic_name",
                  "document": [
                    "line",
                    {
                      "kind": "recurse_field",
                      "field": "f_generic_subp_name"
                    }
                  ]
                },
                {
                  "kind": "ifBreak",
                  "groupId": "generic_name",
                  "breakContents": {
                    "kind": "continuationLineIndent",
                    "contents": [
                      {
                        "kind": "recurse_field",
                        "field": "f_params"
                      },
                      {
                        "kind": "recurse_field",
                        "field": "f_aspects"
                      }
                    ]
                  },
                  "flatContents": [
                    {
                      "kind": "recurse_field",
                      "field": "f_params"
                    },
                    {
                      "kind": "recurse_field",
                      "field": "f_aspects"
                    }
                  ]
                },
                {
                  "kind": "text",
                  "text": ";"
                }
              ]
            }
          }
        ]
      },
      "fields": {
        "f_params": [
          "line",
          {
            "kind": "align",
            "width": " ",
            "contents": [
              {
                "kind": "text",
                "text": "("
              },
              "recurse",
              {
                "kind": "text",
                "text": ")"
              }
            ]
          }
        ]
      }
    },
    "ParamAssoc": {
      "node": [
        {
          "kind": "if",
          "condition": {
            "kind": "is_empty",
            "node": {
              "kind": "eval_member",
              "prefix": "this_node",
              "member": "f_designator"
            }
        },
        "then": [
          {
            "kind": "recurse_field",
            "field": "f_designator"
          },
          {
            "kind": "recurse_field",
            "field": "f_r_expr"
          }
        ],
        "else": [
          {
            "kind": "recurse_field",
            "field": "f_designator"
          },
          {
            "kind": "group",
            "document": {
              "kind": "continuationLineIndent",
              "contents": [
                "line",
                {
                  "kind": "recurse_field",
                  "field": "f_r_expr"
                }
              ]
            }
          }
        ]
        },
        {
          "kind": "match",
          "node": "this_node",
          "matchers": [
            {
              "pattern": {
                "kind": "node",
                "type": "ParamAssoc",
                "members": [
                  {
                    "member": "f_designator",
                    "pattern": {"kind": "not", "pattern": null}
                  },
                  {
                    "member": "parent",
                    "pattern": {
                      "kind": "node",
                      "type": "AssocList",
                      "members": [
                        {
                          "member": "parent",
                          "pattern": {
                            "kind": "or",
                            "patterns": [
                              {"kind": "node", "type": "CallExpr"},
                              {"kind": "node", "type": "GenericInstantiation"}
                            ]
                          }
                        }
                      ]
                    }
                  },
                  {
                    "member": "previous_sibling",
                    "pattern": {"kind": "not", "pattern": null}
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": {
                "kind": "node",
                "type": "ParamAssoc",
                "members": [
                  {
                    "member": "f_designator",
                    "pattern": {"kind": "not", "pattern": null}
                  },
                  {
                    "member": "parent",
                    "pattern": {
                      "kind": "node",
                      "type": "AssocList",
                      "members": [
                        {
                          "member": "parent",
                          "pattern": {
                            "kind": "or",
                            "patterns": [
                              {"kind": "node", "type": "CallExpr"},
                              {"kind": "node", "type": "GenericInstantiation"}
                            ]
                          }
                        }
                      ]
                    }
                  },
                  {
                    "member": "next_sibling",
                    "pattern": {"kind": "not", "pattern": null}
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": "*",
              "document": []
            }
          ]
        }
      ],
      "fields": {
        "f_designator": [
          "recurse",
          "whitespace",
          {
            "kind": "tableSeparator",
            "text": "=>"
          }
        ]
      }
    }
  }
}

Example

Input code:

procedure Calls is
   package My_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Integer);
   function To_Float is new Ada.Unchecked_Conversion (Source => Integer, Target => Float);
begin
   Move (Origin, 1, 2);
   Move (P => Origin, DX => 1, DY => 2);
   Move (Origin, DX => 1, DY => 2);
   Ada.Text_IO.Put_Line (Item => "Hi");
   Total := Add (A => 1, B => 2) + Add (1, 2);
   Outer (Inner (X => 1, Y => 2), 3);
   pragma Assert (Check => Total > 0, Message => "positive");
end Calls;

GNATformat output with the configuration snippet above:

procedure Calls is
   package My_Vectors is new Ada.Containers.Vectors
     (Index_Type   => Positive,
      Element_Type => Integer);
   function To_Float is new Ada.Unchecked_Conversion
     (Source => Integer,
      Target => Float);
begin
   Move (Origin, 1, 2);
   Move
     (P  => Origin,
      DX => 1,
      DY => 2);
   Move
     (Origin,
      DX => 1,
      DY => 2);
   Ada.Text_IO.Put_Line (Item => "Hi");
   Total :=
     Add
       (A => 1,
        B => 2)
     + Add (1, 2);
   Outer
     (Inner
        (X => 1,
         Y => 2),
      3);
   pragma Assert (Check => Total > 0, Message => "positive");
end Calls;

Differences with gnatpp

This configuration snippet only reproduces a threshold of 1.

4.3.1.6. --no-separate-is

With this switch, gnatpp does not place the is keyword of a subprogram body on a separate line when the subprogram specification spans several lines.

GNATformat equivalent

{
  "node_configs": {
    "SubpBody": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": [
              {
                "kind": "recurse_field",
                "field": "f_subp_spec"
              },
              {
                "kind": "recurse_field",
                "field": "f_aspects"
              }
            ],
            "id": "subp_spec"
          },
          {
            "kind": "if",
            "condition": {
              "kind": "is_empty",
              "node": {
                "kind": "eval_member",
                "prefix": "this_node",
                "member": "f_aspects"
              }
            },
            "then": {
              "kind": "group",
              "document": [
                "whitespace",
                {
                  "kind": "text",
                  "text": "is"
                },
                {
                  "kind": "recurse_field",
                  "field": "f_decls"
                }
              ]
            },
            "else": {
              "kind": "ifBreak",
              "groupId": "subp_spec",
              "flatContents": {
                "kind": "group",
                "document": [
                  {
                    "kind": "group",
                    "document": [
                      "line",
                      {
                        "kind": "text",
                        "text": "is"
                      }
                    ]
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_decls"
                  }
                ]
              },
              "breakContents": {
                "kind": "group",
                "document": [
                  "hardline",
                  {
                    "kind": "text",
                    "text": "is"
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_decls"
                  }
                ]
              }
            }
          },
          {
            "kind": "text",
            "text": "begin"
          },
          {
            "kind": "recurse_field",
            "field": "f_stmts"
          },
          "hardline",
          {
            "kind": "text",
            "text": "end"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "line",
          "recurse"
        ],
        "f_decls": [
          {
            "kind": "indent",
            "contents": [
              "recurse"
            ]
          },
          "hardlineWithoutBreakParent"
        ],
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    }
  }
}

Example

Input code:

package body Is_Placement is
   procedure Log (Msg : String) is
   begin
      null;
   end Log;
   procedure Draw (Canvas : in out Canvas_Type; From_Point : Point; To_Point : Point; C : Color) is
      Total : Integer := 0;
   begin
      null;
   end Draw;
   function Is_Valid (P : Point) return Boolean is
   begin
      return True;
   end Is_Valid;
end Is_Placement;

GNATformat output with the configuration snippet above:

package body Is_Placement is
   procedure Log (Msg : String) is
   begin
      null;
   end Log;
   procedure Draw
     (Canvas     : in out Canvas_Type;
      From_Point : Point;
      To_Point   : Point;
      C          : Color) is
      Total : Integer := 0;
   begin
      null;
   end Draw;
   function Is_Valid (P : Point) return Boolean is
   begin
      return True;
   end Is_Valid;
end Is_Placement;

4.3.1.7. --no-separate-loop-then

With this switch, gnatpp does not place the then keyword of IF statements and the loop keyword of FOR and WHILE loop statements on a separate line, even when the condition or the loop specification spans several lines.

GNATformat equivalent

{
  "node_configs": {
    "ElsifStmtPart": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "text",
                "text": "elsif"
              },
              "whitespace",
              {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": {
                    "kind": "recurse_field",
                    "field": "f_cond_expr"
                  }
                }
              },
              "whitespace",
              {
                "kind": "text",
                "text": "then"
              }
            ]
          },
          {
            "kind": "indent",
            "contents": [
              "hardlineWithoutBreakParent",
              {
                "kind": "recurse_field",
                "field": "f_stmts"
              }
            ],
            "bubbleUpTrailingTrivias": true
          }
        ]
      }
    },
    "ForLoopStmt": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "text",
                "text": "for"
              },
              "whitespace",
              {
                "kind": "recurse_field",
                "field": "f_spec"
              },
              "whitespace",
              {
                "kind": "text",
                "text": "loop"
              }
            ]
          },
          {
            "kind": "indent",
            "contents": [
              "hardline",
              {
                "kind": "recurse_field",
                "field": "f_stmts"
              }
            ]
          },
          "hardline",
          {
            "kind": "text",
            "text": "end"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "loop"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    },
    "IfStmt": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": [
                    {
                      "kind": "text",
                      "text": "if"
                    },
                    "whitespace",
                    "flushLineBreaks",
                    {
                      "kind": "recurse_field",
                      "field": "f_cond_expr"
                    }
                  ]
                }
              },
              "whitespace",
              {
                "kind": "text",
                "text": "then"
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_then_stmts"
          },
          {
            "kind": "recurse_field",
            "field": "f_alternatives"
          },
          {
            "kind": "recurse_field",
            "field": "f_else_part"
          },
          "hardlineWithoutBreakParent",
          {
            "kind": "text",
            "text": "end"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "if"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_then_stmts": [
          {
            "kind": "indent",
            "contents": [
              "hardlineWithoutBreakParent",
              "recurse"
            ],
            "bubbleUpTrailingTrivias": true
          }
        ],
        "f_alternatives": {
          "kind": "if",
          "condition": {"kind": "is_empty", "node": "this_field"},
          "then": "recurse",
          "else": [
            "hardlineWithoutBreakParent",
            "recurse"
          ]
        }
      }
    },
    "WhileLoopStmt": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "recurse_field",
                  "field": "f_spec"
                }
              },
              "whitespace",
              {
                "kind": "text",
                "text": "loop"
              }
            ]
          },
          {
            "kind": "indent",
            "contents": [
              "hardline",
              {
                "kind": "recurse_field",
                "field": "f_stmts"
              }
            ]
          },
          "hardline",
          {
            "kind": "text",
            "text": "end"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "loop"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    }
  }
}

Example

Input code:

procedure Loops is
begin
   if Canvas.Width > From_Point.X + To_Point.X and then Canvas.Height > From_Point.Y + To_Point.Y then
      null;
   elsif Canvas.Width > From_Point.X + To_Point.X or else Canvas.Height > From_Point.Y then
      null;
   end if;
   if Short then
      null;
   end if;
   for Index in Canvas.Pixels'First (1) .. Canvas.Pixels'Last (1) - From_Point.X - To_Point.X loop
      null;
   end loop;
   while Total > Canvas.Width * Canvas.Height + From_Point.X * To_Point.Y + 12345 loop
      null;
   end loop;
end Loops;

GNATformat output with the configuration snippet above:

procedure Loops is
begin
   if Canvas.Width > From_Point.X + To_Point.X
     and then Canvas.Height > From_Point.Y + To_Point.Y then
      null;
   elsif Canvas.Width > From_Point.X + To_Point.X
     or else Canvas.Height > From_Point.Y then
      null;
   end if;
   if Short then
      null;
   end if;
   for Index in
     Canvas.Pixels'First (1)
     .. Canvas.Pixels'Last (1) - From_Point.X - To_Point.X loop
      null;
   end loop;
   while Total
     > Canvas.Width * Canvas.Height + From_Point.X * To_Point.Y + 12345 loop
      null;
   end loop;
end Loops;

4.3.1.8. --par-threshold=1

With --par-threshold=nnn, gnatpp puts each parameter specification on its own line when a subprogram has more than nnn of them. With --par-threshold=1, gnatpp also splits functions that have a single parameter, and puts return on its own line. What follows a split specification (is, is null, renames, …) stays on its last line.

GNATformat equivalent

{
  "node_configs": {
    "AbstractFormalSubpDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "recurse_field",
                "field": "f_overriding"
              },
              {
                "kind": "recurse_field",
                "field": "f_subp_spec"
              },
              "whitespace",
              {
                "kind": "text",
                "text": "is"
              },
              {
                "kind": "text",
                "text": "abstract"
              },
              {
                "kind": "recurse_field",
                "field": "f_default_expr"
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "hardline",
          "recurse"
        ]
      }
    },
    "AbstractSubpDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "recurse_field",
            "field": "f_subp_spec"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "is"
          },
          {
            "kind": "text",
            "text": "abstract"
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "hardlineWithoutBreakParent",
          "recurse"
        ]
      }
    },
    "AcceptStmtWithStmts": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "text",
                "text": "accept"
              },
              "whitespace",
              {
                "kind": "recurse_field",
                "field": "f_body_decl"
              },
              {
                "kind": "recurse_field",
                "field": "f_entry_index_expr"
              },
              {
                "kind": "recurse_field",
                "field": "f_params"
              },
              "whitespace",
              {
                "kind": "text",
                "text": "do"
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_stmts"
          },
          "hardlineWithoutBreakParent",
          {
            "kind": "text",
            "text": "end"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    },
    "ConcreteFormalSubpDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": [
              {
                "kind": "recurse_field",
                "field": "f_subp_spec"
              },
              {
                "kind": "recurse_field",
                "field": "f_default_expr"
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "hardline",
          "recurse"
        ],
        "f_default_expr": {
          "kind": "group",
          "document": [
            "whitespace",
            {
              "kind": "text",
              "text": "is"
            },
            "whitespace",
            {
              "kind": "innerRoot",
              "contents": "recurse"
            }
          ]
        }
      }
    },
    "ConcreteTypeDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "group",
                "document": [
                  {
                    "kind": "text",
                    "text": "type"
                  },
                  "whitespace",
                  {
                    "kind": "recurse_field",
                    "field": "f_name"
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_discriminants"
                  },
                  "line",
                  {
                    "kind": "text",
                    "text": "is"
                  }
                ]
              },
              {
                "kind": "if",
                "condition": {
                  "kind": "is_a",
                  "node": {
                    "kind": "eval_member",
                    "prefix": "this_node",
                    "member": "f_type_def"
                  },
                  "pattern": {
                    "kind": "or",
                    "patterns": [
                      {"kind": "node", "type": "DerivedTypeDef"},
                      {"kind": "node", "type": "RecordTypeDef"},
                      {"kind": "node", "type": "AccessToSubpDef"}
                    ]
                  }
                },
                "then": {"kind": "recurse_field", "field": "f_type_def"},
                "else": {
                  "kind": "continuationLineIndent",
                  "contents": [
                    "line",
                    {"kind": "recurse_field","field": "f_type_def"}
                  ]
                }
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_discriminants": [
          {
            "kind": "continuationLineIndent",
            "contents": [
              "line",
              "recurse"
            ]
          }
        ],
        "f_aspects": [
          "line",
          "recurse"
        ]
      }
    },
    "ExprFunction": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": {
              "kind": "recurse_field",
              "field": "f_subp_spec"
            }
          },
          {
            "kind": "group",
            "document": [
              "line",
              {
                "kind": "indent",
                "contents": [
                  {
                    "kind": "text",
                    "text": "is"
                  },
                  "whitespace",
                  "flushLineBreaks",
                  {
                    "kind": "recurse_field",
                    "field": "f_expr"
                  }
                ]
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "hardline",
          "recurse"
        ]
      }
    },
    "FormalTypeDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "group",
                "document": [
                  {
                    "kind": "text",
                    "text": "type"
                  },
                  "whitespace",
                  {
                    "kind": "recurse_field",
                    "field": "f_name"
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_discriminants"
                  },
                  "line",
                  {
                    "kind": "text",
                    "text": "is"
                  }
                ]
              },
              {
                "kind": "if",
                "condition": {
                  "kind": "is_a",
                  "node": {
                    "kind": "eval_member",
                    "prefix": "this_node",
                    "member": "f_type_def"
                  },
                  "pattern": {
                    "kind": "or",
                    "patterns": [
                      {"kind": "node", "type": "DerivedTypeDef"},
                      {"kind": "node", "type": "RecordTypeDef"},
                      {"kind": "node", "type": "AccessToSubpDef"}
                    ]
                  }
                },
                "then": {"kind": "recurse_field", "field": "f_type_def"},
                "else": {
                  "kind": "continuationLineIndent",
                  "contents": [
                    "line",
                    {"kind": "recurse_field", "field": "f_type_def"}
                  ]
                }
              },
              {
                "kind": "recurse_field",
                "field": "f_default_type"
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_discriminants": {
          "kind": "continuationLineIndent",
          "contents": [
            "line",
            "recurse"
          ]
        },
        "f_default_type": {
          "kind": "group",
          "document": [
            "line",
            "recurse"
          ]
        }
      }
    },
    "GenericFormalSubpDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "text",
            "text": "with"
          },
          "whitespace",
          {
            "kind": "recurse_field",
            "field": "f_decl"
          }
        ]
      }
    },
    "NullSubpDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": [
              {
                "kind": "recurse_field",
                "field": "f_subp_spec"
              },
              "whitespace",
              {
                "kind": "text",
                "text": "is"
              },
              {
                "kind": "text",
                "text": "null"
              },
              {
                "kind": "recurse_field",
                "field": "f_aspects"
              },
              {
                "kind": "text",
                "text": ";"
              }
            ]
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "line",
          "recurse"
        ]
      }
    },
    "ParamSpec": {
      "node": [
        {
          "kind": "group",
          "document": [
            {
              "kind": "recurse_field",
              "field": "f_ids"
            },
            "whitespace"
          ]
        },
        {
          "kind": "tableSeparator",
          "text": ":"
        },
        {
          "kind": "group",
          "document": [
            {
              "kind": "group",
              "document": [
                {
                  "kind": "continuationLineIndent",
                  "contents": [
                    "line",
                    {
                      "kind": "group",
                      "document": [
                        {
                          "kind": "recurse_field",
                          "field": "f_has_aliased"
                        },
                        {
                          "kind": "recurse_field",
                          "field": "f_mode"
                        },
                        {
                          "kind": "recurse_field",
                          "field": "f_type_expr"
                        }
                      ]
                    }
                  ]
                }
              ],
              "id": "param_spec_type"
            },
            {
              "kind": "recurse_field",
              "field": "f_default_expr"
            }
          ]
        },
        {
          "kind": "recurse_field",
          "field": "f_aspects"
        },
        {
          "kind": "match",
          "node": "this_node",
          "matchers": [
            {
              "pattern": {
                "kind": "node",
                "type": "ParamSpec",
                "members": [
                  {
                    "member": "previous_sibling",
                    "pattern": {"kind": "node", "type": "ParamSpec"}
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": {
                "kind": "node",
                "type": "ParamSpec",
                "members": [
                  {
                    "member": "next_sibling",
                    "pattern": {"kind": "node", "type": "ParamSpec"}
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": {
                "kind": "node",
                "type": "ParamSpec",
                "members": [
                  {
                    "member": "parent",
                    "pattern": {
                      "kind": "node",
                      "type": "ParamSpecList",
                      "members": [
                        {
                          "member": "parent",
                          "pattern": {
                            "kind": "node",
                            "type": "Params",
                            "members": [
                              {
                                "member": "parent",
                                "pattern": {
                                  "kind": "node",
                                  "type": "SubpSpec",
                                  "members": [
                                    {
                                      "member": "f_subp_kind",
                                      "pattern": {
                                        "kind": "node",
                                        "type": "SubpKindFunction"
                                      }
                                    }
                                  ]
                                }
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": "*",
              "document": []
            }
          ]
        }
      ],
      "fields": {
        "f_default_expr": [
          "whitespace",
          {
            "kind": "text",
            "text": ":="
          },
          {
            "kind": "ifBreak",
            "breakContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": [
                    "line",
                    "recurse"
                  ]
                }
              }
            },
            "flatContents": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "group",
                "document": [
                  "line",
                  "recurse"
                ]
              }
            },
            "groupId": "param_spec_type"
          }
        ]
      }
    },
    "SubpBody": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": [
              {
                "kind": "recurse_field",
                "field": "f_subp_spec"
              },
              {
                "kind": "recurse_field",
                "field": "f_aspects"
              }
            ],
            "id": "subp_spec"
          },
          {
            "kind": "if",
            "condition": {
              "kind": "is_empty",
              "node": {
                "kind": "eval_member",
                "prefix": "this_node",
                "member": "f_aspects"
              }
            },
            "then": {
              "kind": "ifBreak",
              "groupId": "subp_spec",
              "flatContents": {
                "kind": "group",
                "document": [
                  {
                    "kind": "group",
                    "document": [
                      "line",
                      {
                        "kind": "text",
                        "text": "is"
                      }
                    ]
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_decls"
                  }
                ]
              },
              "breakContents": {
                "kind": "group",
                "document": [
                  "hardline",
                  {
                    "kind": "text",
                    "text": "is"
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_decls"
                  }
                ]
              }
            },
            "else": {
              "kind": "ifBreak",
              "groupId": "subp_spec",
              "flatContents": {
                "kind": "group",
                "document": [
                  {
                    "kind": "group",
                    "document": [
                      "line",
                      {
                        "kind": "text",
                        "text": "is"
                      }
                    ]
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_decls"
                  }
                ]
              },
              "breakContents": {
                "kind": "group",
                "document": [
                  "hardline",
                  {
                    "kind": "text",
                    "text": "is"
                  },
                  {
                    "kind": "recurse_field",
                    "field": "f_decls"
                  }
                ]
              }
            }
          },
          {
            "kind": "text",
            "text": "begin"
          },
          {
            "kind": "recurse_field",
            "field": "f_stmts"
          },
          "hardline",
          {
            "kind": "text",
            "text": "end"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "line",
          "recurse"
        ],
        "f_decls": [
          {
            "kind": "indent",
            "contents": [
              "recurse"
            ]
          },
          "hardlineWithoutBreakParent"
        ],
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    },
    "SubpBodyStub": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "recurse_field",
            "field": "f_subp_spec"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "is"
          },
          {
            "kind": "text",
            "text": "separate"
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "hardlineWithoutBreakParent",
          "recurse"
        ]
      }
    },
    "SubpRenamingDecl": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "recurse_field",
            "field": "f_overriding"
          },
          {
            "kind": "group",
            "document": [
              {
                "kind": "recurse_field",
                "field": "f_subp_spec"
              },
              "whitespace",
              {
                "kind": "group",
                "document": [
                  {
                    "kind": "continuationLineIndent",
                    "contents": {
                      "kind": "recurse_field",
                      "field": "f_renames"
                    }
                  }
                ]
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_aspects"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_aspects": [
          "line",
          "recurse"
        ]
      }
    },
    "SubpSpec": {
      "node": {
        "kind": "continuationLineIndent",
        "contents": {
          "kind": "group",
          "document": [
            {
              "kind": "recurse_field",
              "field": "f_subp_kind"
            },
            {
              "kind": "recurse_field",
              "field": "f_subp_name"
            },
            {
              "kind": "group",
              "document": [
                {
                  "kind": "recurse_field",
                  "field": "f_subp_params"
                },
                {
                  "kind": "recurse_field",
                  "field": "f_subp_returns"
                }
              ]
            }
          ]
        }
      },
      "fields": {
        "f_subp_name": [
          "whitespace",
          "recurse"
        ],
        "f_subp_returns": {
          "kind": "align",
          "width": " ",
          "contents": [
            "line",
            {
              "kind": "text",
              "text": "return"
            },
            "whitespace",
            "recurse"
          ]
        },
        "f_subp_params": {
          "kind": "if",
          "condition": {"kind": "is_empty", "node": "this_field"},
          "then": "recurse",
          "else": [
            "line",
            "recurse"
          ]
        }
      }
    }
  }
}

Example

Input code:

package Params is
   procedure Reset;
   procedure Log (Msg : String);
   procedure Move (P : in out Point; DX : Integer; DY : Integer);
   function Get return Integer;
   function Is_Valid (P : Point) return Boolean;
   function Add (A : Integer; B : Integer) return Integer is (A + B);
   type Callback is access procedure (A : Integer; B : Integer);
   type Getter is access function (A : Integer) return Integer;
   task T is
      entry Start (Id : Integer; Name : String);
   end T;
end Params;

GNATformat output with the configuration snippet above:

package Params is
   procedure Reset;
   procedure Log (Msg : String);
   procedure Move
     (P  : in out Point;
      DX : Integer;
      DY : Integer);
   function Get return Integer;
   function Is_Valid
     (P : Point)
      return Boolean;
   function Add
     (A : Integer;
      B : Integer)
      return Integer is (A + B);
   type Callback is access procedure
     (A : Integer;
      B : Integer);
   type Getter is access function
     (A : Integer)
      return Integer;
   task T is
      entry Start
        (Id   : Integer;
         Name : String);
   end T;
end Params;

Differences with gnatpp

This configuration snippet only reproduces a threshold of 1.

4.3.1.9. --separate-loop

With this switch, gnatpp places the loop keyword of FOR and WHILE loop statements on a separate line.

GNATformat equivalent

 {
  "node_configs": {
    "ForLoopStmt": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "text",
                "text": "for"
              },
              "whitespace",
              {
                "kind": "recurse_field",
                "field": "f_spec"
              },
              "hardline",
              {
                "kind": "text",
                "text": "loop"
              }
            ]
          },
          {
            "kind": "indent",
            "contents": [
              "hardline",
              {
                "kind": "recurse_field",
                "field": "f_stmts"
              }
            ]
          },
          "hardline",
          {
            "kind": "text",
            "text": "end"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "loop"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    },
    "WhileLoopStmt": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "recurse_field",
                  "field": "f_spec"
                }
              },
              "hardline",
              {
                "kind": "text",
                "text": "loop"
              }
            ]
          },
          {
            "kind": "indent",
            "contents": [
              "hardline",
              {
                "kind": "recurse_field",
                "field": "f_stmts"
              }
            ]
          },
          "hardline",
          {
            "kind": "text",
            "text": "end"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "loop"
          },
          {
            "kind": "recurse_field",
            "field": "f_end_name"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_end_name": [
          "whitespace",
          "recurse"
        ]
      }
    }
  }
}

Example

Input code:

procedure Separate_Loop is
begin

   while Foo loop
     null;
   end loop;

   for Foo of Bar when Foo.Is_Baz loop
     null;
   end loop;

end Separate_Loop;

GNATformat output with the configuration snippet above:

procedure Separate_Loop is
begin

   while Foo
   loop
      null;
   end loop;

   for Foo of Bar when Foo.Is_Baz
   loop
      null;
   end loop;

end Separate_Loop;

4.3.1.10. --separate-then

With this switch, gnatpp places the then keyword of IF statements on a separate line.

GNATformat equivalent

 {
  "node_configs": {
    "ElsifStmtPart": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "text",
                "text": "elsif"
              },
              "whitespace",
              {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": {
                    "kind": "recurse_field",
                    "field": "f_cond_expr"
                  }
                }
              },
              "hardline",
              {
                "kind": "text",
                "text": "then"
              }
            ]
          },
          {
            "kind": "indent",
            "contents": [
              "hardlineWithoutBreakParent",
              {
                "kind": "recurse_field",
                "field": "f_stmts"
              }
            ],
            "bubbleUpTrailingTrivias": true
          }
        ]
      }
    },
    "IfStmt": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "group",
            "document": [
              {
                "kind": "continuationLineIndent",
                "contents": {
                  "kind": "group",
                  "document": [
                    {
                      "kind": "text",
                      "text": "if"
                    },
                    "whitespace",
                    "flushLineBreaks",
                    {
                      "kind": "recurse_field",
                      "field": "f_cond_expr"
                    }
                  ]
                }
              },
              "hardline",
              {
                "kind": "text",
                "text": "then"
              }
            ]
          },
          {
            "kind": "recurse_field",
            "field": "f_then_stmts"
          },
          {
            "kind": "recurse_field",
            "field": "f_alternatives"
          },
          {
            "kind": "recurse_field",
            "field": "f_else_part"
          },
          "hardlineWithoutBreakParent",
          {
            "kind": "text",
            "text": "end"
          },
          "whitespace",
          {
            "kind": "text",
            "text": "if"
          },
          {
            "kind": "text",
            "text": ";"
          }
        ]
      },
      "fields": {
        "f_then_stmts": [
          {
            "kind": "indent",
            "contents": [
              "hardlineWithoutBreakParent",
              "recurse"
            ],
            "bubbleUpTrailingTrivias": true
          }
        ],
        "f_alternatives": {
          "kind": "if",
          "condition": {"kind": "is_empty", "node": "this_field"},
          "then": "recurse",
          "else": [
            "hardlineWithoutBreakParent",
            "recurse"
          ]
        }
      }
    }
  }
}

Example

Input code:

if Foo then
  null;
elsif Bar then
  null;
elsif Baz then
  null;
else
  null;
end if;

GNATformat output with the configuration snippet above:

if Foo
then
   null;
elsif Bar
then
   null;
elsif Baz
then
   null;
else
   null;
end if;

4.3.1.11. --split-line-before-record

With this switch, gnatpp splits the line just before the record keyword in record type declarations.

GNATformat equivalent

{
  "node_configs": {
    "RecordDef": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "indent",
            "contents": [
              "hardline",
              {
                "kind": "text",
                "text": "record"
              },
              {
                "kind": "indent",
                "contents": {
                  "kind": "recurse_field",
                  "field": "f_components"
                }
              },
              "hardline",
              {
                "kind": "text",
                "text": "end"
              },
              "whitespace",
              {
                "kind": "text",
                "text": "record"
              }
            ]
          }
        ]
      }
    }
  }
}

Example

Input code:

type Date is record
      Day   : Integer range 1 .. 31;
      Month : Month_Enum;
      Year  : Integer range 0 .. 4000;
end record;

GNATformat output with the configuration snippet above:

type Date is
   record
      Day   : Integer range 1 .. 31;
      Month : Month_Enum;
      Year  : Integer range 0 .. 4000;
   end record;

4.3.1.12. --vertical-array-types

With this switch, gnatpp formats array type definitions “vertically”: of and the component type always go on a separate line and, in array type declarations, so does array and the index definitions. The index definitions stay on a single line when they fit there.

GNATformat equivalent

{
  "node_configs": {
    "ArrayTypeDef": {
      "node": {
        "kind": "group",
        "document": [
          {
            "kind": "if",
            "condition": {
              "kind": "is_a",
              "node": {
                "kind": "eval_member",
                "prefix": "this_node",
                "member": "parent"
              },
              "pattern": {
                "kind": "or",
                "patterns": [
                  {
                    "kind": "node",
                    "type": "ConcreteTypeDecl"
                  },
                  {
                    "kind": "node",
                    "type": "FormalTypeDecl"
                  }
                ]
              }
            },
            "then": "breakParent",
            "else": []
          },
          {
            "kind": "text",
            "text": "array"
          },
          "whitespace",
          {
            "kind": "group",
            "document": {
              "kind": "innerRoot",
              "contents": [
                {
                  "kind": "text",
                  "text": "("
                },
                {
                  "kind": "align",
                  "width": " ",
                  "contents": {
                    "kind": "recurse_field",
                    "field": "f_indices"
                  }
                },
                {
                  "kind": "text",
                  "text": ")"
                }
              ]
            }
          },
          "hardlineWithoutBreakParent",
          {
            "kind": "text",
            "text": "of"
          },
          "whitespace",
          {
            "kind": "recurse_field",
            "field": "f_component_type"
          }
        ]
      }
    }
  }
}

Example

Input code:

package ArrayTypeDef is

  type Constrained_Matrix is
    array (Natural range 0 .. L1, Natural range 0 .. L2, Natural range 0 .. L3)
   of Integer;

  type Unconstrained_Matrix is array(Integer  range <>, Integer range <>) of Real;

  type Small_Matrix is array (1 .. 2, 1 .. 3) of Integer;

  Buffer : array (1 .. 10) of Character;

end ArrayTypeDef;

GNATformat output with the configuration snippet above:

package ArrayTypeDef is

   type Constrained_Matrix is
     array (Natural range 0 .. L1,
            Natural range 0 .. L2,
            Natural range 0 .. L3)
     of Integer;

   type Unconstrained_Matrix is
     array (Integer range <>, Integer range <>)
     of Real;

   type Small_Matrix is
     array (1 .. 2, 1 .. 3)
     of Integer;

   Buffer : array (1 .. 10)
     of Character;

end ArrayTypeDef;

Differences with gnatpp

When the index definitions do not fit on a single line, gnatpp puts as many of them as fit on each line, while this configuration snippet puts each of them on its own line.

4.3.1.13. --vertical-case-alternatives

With this switch, gnatpp formats case statements, case expressions and variant parts with additional line breaks, so that each | choice goes on a separate line.

GNATformat equivalent

 {
  "node_configs": {
    "AlternativesList": {
      "sep": [
        "hardline",
        "recurse",
        "whitespace"
      ],
      "table": null
    }
  }
}

Example

Input code:

procedure Vertical_Alternatives is

   --  CaseExpr alternatives
   Status_Str : constant String :=
     (case Current_Status is
        when Idle | Ready | Waiting => "Standby",
        when Running | Processing   => "Active",
        when Fault | Error          => "Failed");

   --  VariantPart alternatives
   type Sensor_Status (Kind : Sensor_Kind) is record
     case Kind is
      when Temperature | Humidity | Pressure =>  Reading : Float;
      when Discrete | Binary => State   : Boolean;
      when others => Raw_Value : Integer;
   end case;
end record;

begin
  --  CaseSmt alternatives
  case Current_State is
     when Idle | Waiting | Suspended => Process_Idle;
     when Active | Running => Process_Active;
     when others => Process_Unknown;
  end case;

end Vertical_Alternatives;

GNATformat output with the configuration snippet above:

procedure Vertical_Alternatives is

   --  CaseExpr alternatives
   Status_Str : constant String :=
     (case Current_Status is
        when Idle
           | Ready
           | Waiting    => "Standby",
        when Running
           | Processing => "Active",
        when Fault
           | Error      => "Failed");

   --  VariantPart alternatives
   type Sensor_Status (Kind : Sensor_Kind) is record
      case Kind is
         when Temperature
            | Humidity
            | Pressure
         =>
            Reading : Float;

         when Discrete
            | Binary
         =>
            State : Boolean;

         when others =>
            Raw_Value : Integer;
      end case;
   end record;

begin
   --  CaseSmt alternatives
   case Current_State is
      when Idle
         | Waiting
         | Suspended =>
         Process_Idle;

      when Active
         | Running =>
         Process_Active;

      when others =>
         Process_Unknown;
   end case;

end Vertical_Alternatives;

4.3.1.14. --vertical-enum-types

With this switch, gnatpp formats enumeration type declarations “vertically”: the list of enumeration literals goes on a separate line, even when it contains a single literal, and each enumeration literal goes on a separate line.

GNATformat equivalent

{
  "node_configs": {
    "EnumTypeDef": {
      "node": {
        "kind": "group",
        "document": [
          "breakParent",
          {
            "kind": "text",
            "text": "("
          },
          {
            "kind": "align",
            "width": " ",
            "contents": {
              "kind": "recurse_field",
              "field": "f_enum_literals"
            }
          },
          {
            "kind": "text",
            "text": ")"
          }
        ]
      }
    }
  }
}

Example

Input code:

package EnumTypeDef is
   type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
   type Single is (Only);
end EnumTypeDef;

GNATformat output with the configuration snippet above:

package EnumTypeDef is
   type Day is
     (Mon,
      Tue,
      Wed,
      Thu,
      Fri,
      Sat,
      Sun);
   type Single is
     (Only);
end EnumTypeDef;

4.3.1.15. --vertical-named-aggregates

With this switch, gnatpp formats aggregates “vertically” when named notation is used for component associations: each component association goes on a separate line. Despite the name of the switch, gnatpp also does this for aggregates that use only positional notation.

GNATformat equivalent

{
  "node_configs": {
    "AggregateAssoc": {
      "node": [
        {
          "field": "f_designators",
          "kind": "recurse_field"
        },
        {
          "kind": "if",
          "condition": {
            "kind": "eval_member",
            "prefix": {
              "kind": "eval_member",
              "prefix": "this_node",
              "member": "f_designators"
            },
            "member": "is_empty_list"
          },
          "then": {
            "kind": "group",
            "document": [
              {
                "field": "f_r_expr",
                "kind": "recurse_field"
              }
            ]
          },
          "else": {
            "kind": "group",
            "document": {
              "kind": "continuationLineIndent",
              "contents": [
                {
                  "kind": "match",
                  "node": "this_node",
                  "matchers": [
                    {
                      "pattern": {
                        "kind": "node",
                        "type": "AggregateAssoc",
                        "members": [
                          {
                            "member": "f_r_expr",
                            "pattern": {
                              "kind": "node",
                              "type": "UnOp",
                              "members": [
                                {
                                  "member": "f_op",
                                  "pattern": {
                                    "kind": "node",
                                    "type": "OpPlus"
                                  }
                                }
                              ]
                            }
                          },
                          {
                            "member": "parent",
                            "pattern": {
                              "kind": "node",
                              "type": "AssocList",
                              "members": [
                                {
                                  "member": "parent",
                                  "pattern": {
                                    "kind": "node",
                                    "type": "Aggregate",
                                    "members": [
                                      {
                                        "member": "parent",
                                        "pattern": {
                                          "kind": "node",
                                          "type": "AspectAssoc",
                                          "members": [
                                            {
                                              "member": "f_id",
                                              "pattern": {
                                                "kind": "node",
                                                "type": "Identifier",
                                                "members": [
                                                  {
                                                    "member": "p_canonical_text",
                                                    "pattern": {
                                                      "kind": "symbol_literal",
                                                      "value": "depends"
                                                    }
                                                  }
                                                ]
                                              }
                                            }
                                          ]
                                        }
                                      }
                                    ]
                                  }
                                }
                              ]
                            }
                          }
                        ]
                      },
                      "document": []
                    },
                    {
                      "pattern": "*",
                      "document": [
                        "line"
                      ]
                    }
                  ]
                },
                "flushLineBreaks",
                {
                  "field": "f_r_expr",
                  "kind": "recurse_field"
                }
              ]
            }
          }
        },
        {
          "kind": "match",
          "node": "this_node",
          "matchers": [
            {
              "pattern": {
                "kind": "or",
                "patterns": [
                  {
                    "kind": "node",
                    "type": "AggregateAssoc",
                    "members": [
                      {
                        "member": "parent",
                        "pattern": {
                          "kind": "node",
                          "type": "AssocList",
                          "members": [
                            {
                              "member": "parent",
                              "pattern": {
                                "kind": "node",
                                "type": "BaseAggregate",
                                "members": [
                                  {
                                    "member": "parent",
                                    "pattern": {
                                      "kind": "node",
                                      "type": "AspectAssoc",
                                      "members": [
                                        {
                                          "member": "f_id",
                                          "pattern": {
                                            "kind": "node",
                                            "type": "Identifier",
                                            "members": [
                                              {
                                                "member": "p_canonical_text",
                                                "pattern": {
                                                  "kind": "symbol_literal",
                                                  "value": "depends"
                                                }
                                              }
                                            ]
                                          }
                                        }
                                      ]
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "kind": "node",
                    "type": "AggregateAssoc",
                    "members": [
                      {
                        "member": "parent",
                        "pattern": {
                          "kind": "node",
                          "type": "AssocList",
                          "members": [
                            {
                              "member": "parent",
                              "pattern": {
                                "kind": "node",
                                "type": "BaseAggregate",
                                "members": [
                                  {
                                    "member": "parent",
                                    "pattern": {
                                      "kind": "node",
                                      "type": "AggregateAssoc",
                                      "members": [
                                        {
                                          "member": "parent",
                                          "pattern": {
                                            "kind": "node",
                                            "type": "AssocList",
                                            "members": [
                                              {
                                                "member": "parent",
                                                "pattern": {
                                                  "kind": "node",
                                                  "type": "BaseAggregate",
                                                  "members": [
                                                    {
                                                      "member": "parent",
                                                      "pattern": {
                                                        "kind": "node",
                                                        "type": "AspectAssoc",
                                                        "members": [
                                                          {
                                                            "member": "f_id",
                                                            "pattern": {
                                                              "kind": "node",
                                                              "type": "Identifier",
                                                              "members": [
                                                                {
                                                                  "member": "p_canonical_text",
                                                                  "pattern": {
                                                                    "kind": "symbol_literal",
                                                                    "value": "depends"
                                                                  }
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        }
                                      ]
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "kind": "node",
                    "type": "AggregateAssoc",
                    "members": [
                      {
                        "member": "parent",
                        "pattern": {
                          "kind": "node",
                          "type": "AssocList",
                          "members": [
                            {
                              "member": "parent",
                              "pattern": {
                                "kind": "node",
                                "type": "BaseAggregate",
                                "members": [
                                  {
                                    "member": "parent",
                                    "pattern": {
                                      "kind": "node",
                                      "type": "UnOp",
                                      "members": [
                                        {
                                          "member": "parent",
                                          "pattern": {
                                            "kind": "node",
                                            "type": "AggregateAssoc",
                                            "members": [
                                              {
                                                "member": "parent",
                                                "pattern": {
                                                  "kind": "node",
                                                  "type": "AssocList",
                                                  "members": [
                                                    {
                                                      "member": "parent",
                                                      "pattern": {
                                                        "kind": "node",
                                                        "type": "BaseAggregate",
                                                        "members": [
                                                          {
                                                            "member": "parent",
                                                            "pattern": {
                                                              "kind": "node",
                                                              "type": "AspectAssoc",
                                                              "members": [
                                                                {
                                                                  "member": "f_id",
                                                                  "pattern": {
                                                                    "kind": "node",
                                                                    "type": "Identifier",
                                                                    "members": [
                                                                      {
                                                                        "member": "p_canonical_text",
                                                                        "pattern": {
                                                                          "kind": "symbol_literal",
                                                                          "value": "depends"
                                                                        }
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        }
                                      ]
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "kind": "node",
                    "type": "AggregateAssoc",
                    "members": [
                      {
                        "member": "parent",
                        "pattern": {
                          "kind": "node",
                          "type": "AssocList",
                          "members": [
                            {
                              "member": "parent",
                              "pattern": {
                                "kind": "node",
                                "type": "BaseAggregate",
                                "members": [
                                  {
                                    "member": "parent",
                                    "pattern": {
                                      "kind": "node",
                                      "type": "AlternativesList",
                                      "members": [
                                        {
                                          "member": "parent",
                                          "pattern": {
                                            "kind": "node",
                                            "type": "AggregateAssoc",
                                            "members": [
                                              {
                                                "member": "parent",
                                                "pattern": {
                                                  "kind": "node",
                                                  "type": "AssocList",
                                                  "members": [
                                                    {
                                                      "member": "parent",
                                                      "pattern": {
                                                        "kind": "node",
                                                        "type": "BaseAggregate",
                                                        "members": [
                                                          {
                                                            "member": "parent",
                                                            "pattern": {
                                                              "kind": "node",
                                                              "type": "AspectAssoc",
                                                              "members": [
                                                                {
                                                                  "member": "f_id",
                                                                  "pattern": {
                                                                    "kind": "node",
                                                                    "type": "Identifier",
                                                                    "members": [
                                                                      {
                                                                        "member": "p_canonical_text",
                                                                        "pattern": {
                                                                          "kind": "symbol_literal",
                                                                          "value": "depends"
                                                                        }
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        }
                                      ]
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    ]
                  }
                ]
              },
              "document": []
            },
            {
              "pattern": {
                "kind": "node",
                "type": "AggregateAssoc",
                "members": [
                  {
                    "member": "parent",
                    "pattern": {
                      "kind": "node",
                      "type": "AssocList",
                      "members": [
                        {
                          "member": "parent",
                          "pattern": {"kind": "node", "type": "BaseAggregate"}
                        }
                      ]
                    }
                  },
                  {
                    "member": "previous_sibling",
                    "pattern": {"kind": "not", "pattern": null}
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": {
                "kind": "node",
                "type": "AggregateAssoc",
                "members": [
                  {
                    "member": "parent",
                    "pattern": {
                      "kind": "node",
                      "type": "AssocList",
                      "members": [
                        {
                          "member": "parent",
                          "pattern": {"kind": "node", "type": "BaseAggregate"}
                        }
                      ]
                    }
                  },
                  {
                    "member": "next_sibling",
                    "pattern": {"kind": "not", "pattern": null}
                  }
                ]
              },
              "document": "breakParent"
            },
            {
              "pattern": "*",
              "document": []
            }
          ]
        }
      ],
      "fields": {
        "f_designators": [
          {
            "kind": "group",
            "document": "recurse"
          },
          {
            "kind": "tableSeparator",
            "text": ""
          },
          {
            "kind": "group",
            "document": {
              "kind": "continuationLineIndent",
              "contents": {
                "kind": "dedent",
                "contents": {
                  "kind": "group",
                  "document": [
                    "line",
                    {
                      "kind": "text",
                      "text": "=>"
                    }
                  ]
                },
                "bubbleUpLeadingTrivias": true,
                "bubbleUpTrailingTrivias": true
              }
            }
          }
        ]
      }
    }
  }
}

Example

Input code:

procedure Main (X : in out Integer; Y : Integer)
  with Depends => (X => (X, Y)), Global => (Input => G1, Output => G2)
is
   A : constant Foo := Bar'(A, B);
   B : constant Foo := Bar'(A=>A, B=>B);
begin

  F1 := (1, 2, B => 3);

  F2 := (B1 => 1, B2 => 2, others => 0);

  F3 := [B => Val_1, Q => 15];

end Main;

GNATformat output with the configuration snippet above:

procedure Main (X : in out Integer; Y : Integer)
with
  Depends => (X => (X, Y)),
  Global  =>
    (Input  => G1,
     Output => G2)
is
   A : constant Foo :=
     Bar'
       (A,
        B);
   B : constant Foo :=
     Bar'
       (A => A,
        B => B);
begin

   F1 :=
     (1,
      2,
      B => 3);

   F2 :=
     (B1     => 1,
      B2     => 2,
      others => 0);

   F3 :=
     [B => Val_1,
      Q => 15];

end Main;

Differences with gnatpp

Aggregates in Depends aspects keep the default GNATformat layout, because gnatpp does not format them consistently.