Configuring Subprogram Specification Statement Rules

There are rules which will check indent and formatting of the subprogram specification of a procedure or function:

subprogram_specification ::=
    procedure designator [ ( formal_parameter_list ) ]
    | [ pure | impure ] function designator [ ( formal_parameter_list ) ]
        return type_mark

designator ::= identifier | operator_symbol

formal_parameter_list ::= parameter_interface_list

interface_list ::=
    interface_element { ; interface_element }

interface_element ::= interface_declaration

There are separate rules for the structure of the subprogram specification and the indenting. Both rules are required to ensure proper formatting of subprogram specification statements.

There are several options to the structure rules:

Option

Symbol

Values

Structural Element

Default Value

Description

first_open_paren

green_diamond

add_new_line, remove_new_line, ignore

opening parenthesis

remove_new_line

  • The setting add_new_line enforces a carriage return (alias “new line”) [and, consequently by indentation rules kicking in, also (indirectly) enforces the indentation of the new line]

  • The setting remove_new_line enforces the removal of any potential space and carriage return

  • The setting ignore disables the option and hence no formatting check is done at all: spaces and new lines can be anything

last_close_paren

red_penta_star

add_new_line, remove_new_line, ignore

closing parenthesis

add_new_line

interface_element

orange_triangle

add_new_line, remove_new_line, ignore

interface element

add_new_line

interface_list_semicolon

purple_hexa_star

remove_new_line, ignore

semicolon

remove_new_line

ignore_single_line

N/A

yes, no

N/A

no

  • yes = Ignore single line expressions.

  • no = Apply rules to single line expressions.

The following figure illustrates where the options will be applied in an procedure call.

_images/subprogram_specification_statement_code.png

The following configuration replicates the above code snippet.

rule :
  procedure_013:
     first_open_paren : 'remove_new_line'
     last_close_paren : 'add_new_line'
     interface_element_semicolon : 'remove_new_line'
     interface_element: 'add_new_line'
     ignore_single_line : 'no'

Note

All examples use the above configuration.

Example: first_open_paren set to add_new_line

Setting the first_open_paren option to add_new_line will result in the following formatting:

procedure update_test
(
  test_number : integer;
  test_result : boolean
);

Example: last_close_paren set to remove_new_line

Setting the last_close_paren option to remove_new_line will result in the following formatting:

procedure update_test (
  test_number : integer;
  test_result : boolean);

Example: interface_element set to remove_new_line

Setting the interface_element option to remove_new_line will result in the following formatting:

procedure update_test (test_number : integer;test_result : boolean
);

Rules Enforcing Subprogram Specification Structure