Formatting a whole source text: the main library entry point.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | FMT_ERR_INTERNAL | = | 1 |
formatting would have changed the code; the text is returned unchanged |
| integer, | public, | parameter | :: | FMT_OK | = | 0 |
formatted |
The code tokens of src as one string that same_code compares when use statements may
be reordered: for each token its kind (operators all alike), whether it is glued to the
previous token, and its text as key gives it. The signatures of use statements in a run
are sorted, and so are those of the items of each only: list.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
How much of a token's text, from its start, Fortran reads ignoring case: all of a name, an operator or a number (exponent letters and kinds), the kind prefix of a string, and none of anything else.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the token's text |
||
| integer, | intent(in) | :: | kind |
its kind ( |
Warnings for input beyond the limits of the Fortran 2023 standard (6.3.2.1): lines longer than 10,000 characters, and statements of more than 1,000,000 characters (counted without comments and line breaks).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
An upper bound of the width of the longest code line of text: the characters of each line
before a comment, without the blanks before it, as long_code_lines counts them.
Preprocessor lines do not count. Strings are followed across continuation lines, so that a
! inside one does not end the code, but the scan does not tokenize, so it may count more
than a token-based count would; never less.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the formatted text |
Width of the longest line of text, in characters (as utf8_width counts them).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
text whose lines end with LF |
text with the statements at changed (byte ranges, in order) laid out again, each on its own
at the column where it starts. text is formatted apart from those statements, and they do
not depend on the lines around them (see stands_alone), so this gives what formatting the
whole text again would, in a fraction of the time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the text, after lines were split |
||
| integer, | intent(in) | :: | changed(:,:) |
byte ranges of the statements to lay out |
||
| type(format_options_t), | intent(in) | :: | opts |
the formatting options |
True if a and b have the same code tokens, in the same order, with the same text and the
same joins across line breaks (blanks, comments and line layout may differ). Names and dot
operators are compared ignoring case, as Fortran does, and the two spellings of a relational
operator (< and .lt.) are the same.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | a |
first source text |
||
| character(len=*), | intent(in) | :: | b |
second source text |
||
| logical, | intent(in), | optional | :: | reordered_use |
allow reordered |
|
| type(token_list_t), | intent(in), | optional | :: | a_tokens |
the tokens of |
True if code token s of sa matches code token t of sb, as their keys in
code_signature would: same kind (operators all alike), same glue, and the same text,
ignoring case where Fortran does (see folded_length), with relational operators in their
symbol spelling.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | sa |
source text of |
||
| type(token_t), | intent(in) | :: | s |
a code token of |
||
| character(len=*), | intent(in) | :: | sb |
source text of |
||
| type(token_t), | intent(in) | :: | t |
a code token of |
True if a code line of text may be longer than limit characters (see longest_code).
A line has no more characters than bytes, so the scan is only needed when a line has more
bytes than that, which finding the line breaks shows quickly.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the formatted text |
||
| integer, | intent(in) | :: | limit |
the line length |
One pass of the formatter: structure, whitespace, case and layout.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(format_options_t), | intent(in) | :: | opts |
formatting options |
||
| character(len=:), | intent(out), | allocatable | :: | out |
the formatted text |
|
| type(diagnostic_t), | intent(out), | allocatable | :: | diags(:) |
problems found in this pass |
|
| type(token_list_t), | intent(out), | optional | :: | src_tokens |
the tokens of |
Format src. On success out is the formatted text and stat is FMT_OK.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text to format |
||
| type(format_options_t), | intent(in) | :: | opts |
formatting options |
||
| character(len=:), | intent(out), | allocatable | :: | out |
the formatted text |
|
| integer, | intent(out) | :: | stat |
|
||
| character(len=:), | intent(out), | allocatable | :: | errmsg |
error message; unallocated if |
|
| type(diagnostic_t), | intent(out), | optional, | allocatable | :: | diags(:) |
problems found while formatting |