ffmt_whitespace Module

Whitespace rules within lines: the blanks wanted between pairs of adjacent tokens.

Each rule has a mode: WS_ADD makes sure there is at least one blank on each side (more are kept, so column alignment survives), WS_REMOVE removes the blanks, and WS_KEEP leaves them as they are. Rules only look at tokens on the same line; blanks are never added or removed next to a line break, a continuation & or a comment.

Statements where operators have other meanings are recognized: unary +/-, * in real*8, print * and (*), / in array constructors, and in data, common, namelist, save and equivalence statements. format statements are left alone.


Uses

  • module~~ffmt_whitespace~~UsesGraph module~ffmt_whitespace ffmt_whitespace module~ffmt_options ffmt_options module~ffmt_whitespace->module~ffmt_options module~ffmt_source ffmt_source module~ffmt_whitespace->module~ffmt_source module~ffmt_statements ffmt_statements module~ffmt_whitespace->module~ffmt_statements module~ffmt_strings ffmt_strings module~ffmt_whitespace->module~ffmt_strings module~ffmt_tokens ffmt_tokens module~ffmt_whitespace->module~ffmt_tokens module~ffmt_source->module~ffmt_statements module~ffmt_source->module~ffmt_tokens module~ffmt_directives ffmt_directives module~ffmt_source->module~ffmt_directives module~ffmt_lexer ffmt_lexer module~ffmt_source->module~ffmt_lexer module~ffmt_statements->module~ffmt_strings module~ffmt_statements->module~ffmt_tokens module~ffmt_tokens->module~ffmt_strings module~ffmt_directives->module~ffmt_statements module~ffmt_directives->module~ffmt_tokens module~ffmt_lexer->module~ffmt_strings module~ffmt_lexer->module~ffmt_tokens

Used by

  • module~~ffmt_whitespace~~UsedByGraph module~ffmt_whitespace ffmt_whitespace module~ffmt_format ffmt_format module~ffmt_format->module~ffmt_whitespace module~ffmt_layout ffmt_layout module~ffmt_format->module~ffmt_layout module~ffmt_layout->module~ffmt_whitespace module~ffmt_cli ffmt_cli module~ffmt_cli->module~ffmt_format

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: GAP_KEEP = -1

as in the input

integer, public, parameter :: GAP_MIN1 = -2

at least one blank


Functions

public function compute_gaps(source, views, ws, comment_spacing) result(gap)

The gap wanted before each token (GAP_KEEP, GAP_MIN1 or a number of blanks).

Arguments

Type IntentOptional Attributes Name
type(source_t), intent(in) :: source

the source

type(statement_view_t), intent(in) :: views(:)

the view of each item (see statement_views)

type(whitespace_options_t), intent(in) :: ws

modes of the whitespace rules

integer, intent(in) :: comment_spacing

blanks before a trailing comment, or -1 to keep them

Return Value integer, allocatable, (:)

private elemental function is_word(kind)

Tokens that would run together with a following word: names, numbers and BOZ literals.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: kind

token kind (TK_*)

Return Value logical


Subroutines

private subroutine comment_gaps(source, spacing, gap)

Ask for spacing blanks before each trailing comment (one after code or a continuation &), unless a trailing comment on the line before or after starts in the same column: comments lined up in a column are left as they are.

Arguments

Type IntentOptional Attributes Name
type(source_t), intent(in) :: source

the source

integer, intent(in) :: spacing

blanks wanted before a trailing comment

integer, intent(inout) :: gap(:)

gap wanted before each token, set for the comments

private subroutine statement_gaps(src, tokens, v, ws, gap)

Set the gaps wanted before the tokens of one code statement.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: src

the source text

type(token_list_t), intent(in) :: tokens

its tokens

type(statement_view_t), intent(in) :: v

the statement

type(whitespace_options_t), intent(in) :: ws

modes of the whitespace rules

integer, intent(inout) :: gap(:)

gap wanted before each token, set where a rule applies