writer_t Derived Type

type, private :: writer_t

Output being built, and the alignment state of the current statement.


Inherits

type~~writer_t~~InheritsGraph type~writer_t writer_t type~case_marks_t case_marks_t type~writer_t->type~case_marks_t cases type~string_builder_t string_builder_t type~writer_t->type~string_builder_t buf

Components

Type Visibility Attributes Name Initial
integer, public :: anchor_col(3) = -1

column of the first item after an assignment = / =>, a use statement's only: and a declaration's ::, or -1

integer, public, allocatable :: bracket_first(:)

column of the first item after each open bracket, or -1; only bracket_first(1:nbrackets) is in use

type(string_builder_t), public :: buf

the output text

type(case_marks_t), public :: cases

letter case wanted for each token (see compute_case)

integer, public :: col = 0

output column: characters since the last line break

integer, public :: comment_in = -1

input column of the comment on the previous line, or -1

integer, public :: comment_out = -1

output column of that comment

logical, public :: declaration = .false.

a top-level :: has been seen in the current statement

integer, public, allocatable :: gap(:)

blanks wanted before each token (see compute_gaps)

logical, public :: generic = .false.

the current statement is a generic binding

logical, public :: keep_original = .true.

fall back to a code line's original indentation when the new one would make it too long (when lines are not split)

logical, public :: line_comment = .false.

a comment has been written on the current line

integer, public :: line_length = 0

maximum line length, or 0

integer, public, allocatable :: long_lines(:)

input lines that kept their indentation to stay within the line length

integer, public :: nbrackets = 0

open brackets in the current statement

integer, public :: pending_anchor = 0

the next code token is the first item after this anchor

logical, public :: pending_bracket = .false.

the next code token is the first item after a bracket

integer, public :: prev = 0

the previous code token of the statement (index into the token list), or 0

logical, public :: separated = .false.

a top-level , or : has been seen in the statement

integer, public :: stmt_in = -1

input column of the last statement, while comment lines directly follow it, or -1

integer, public :: stmt_out = -1

output column of that statement


Source Code

type :: writer_t
    !! Output being built, and the alignment state of the current statement.
    type(string_builder_t) :: buf               !! the output text
    integer :: col = 0                          !! output column: characters since the last line break
    integer :: nbrackets = 0                    !! open brackets in the current statement
    integer, allocatable :: bracket_first(:)    !! column of the first item after each open bracket, or -1;
                                                !! only `bracket_first(1:nbrackets)` is in use
    integer :: anchor_col(3) = -1               !! column of the first item after an assignment `=` / `=>`,
                                                !! a `use` statement's `only:` and a declaration's `::`, or -1
    integer :: pending_anchor = 0               !! the next code token is the first item after this anchor
    logical :: pending_bracket = .false.        !! the next code token is the first item after a bracket
    logical :: separated = .false.              !! a top-level `,` or `:` has been seen in the statement
    integer :: prev = 0                         !! the previous code token of the statement (index into the
                                                !! token list), or 0
    integer :: comment_in = -1                  !! input column of the comment on the previous line, or -1
    integer :: comment_out = -1                 !! output column of that comment
    logical :: line_comment = .false.           !! a comment has been written on the current line
    integer :: stmt_in = -1                     !! input column of the last statement, while comment lines
                                                !! directly follow it, or -1
    integer :: stmt_out = -1                    !! output column of that statement
    logical :: generic = .false.                !! the current statement is a `generic` binding
    logical :: declaration = .false.            !! a top-level `::` has been seen in the current statement
    integer :: line_length = 0                  !! maximum line length, or 0
    logical :: keep_original = .true.           !! fall back to a code line's original indentation when the
                                                !! new one would make it too long (when lines are not split)
    integer, allocatable :: long_lines(:)       !! input lines that kept their indentation to stay within the line length
    integer, allocatable :: gap(:)              !! blanks wanted before each token (see [[compute_gaps]])
    type(case_marks_t) :: cases                 !! letter case wanted for each token (see [[compute_case]])
end type writer_t