Splitting code lines that are longer than the line length.
A line is split at a token boundary, preferring (in this order) after a comma, after an operator,
= or ::, after an opening bracket, and anywhere between two tokens. Within the best kind of
break that fits, the rightmost is used. The first part ends with & and the rest goes on a new
line; the layout pass then aligns it. Only the code counts: a trailing comment may extend past
the limit and moves with the last part. Lines are not split inside tokens (strings in particular),
in protected code, in comment or preprocessor lines, or when a token spans lines.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | MAX_CONTINUATIONS | = | 255 |
continuation lines a statement may have before Fortran 2023 (F2018 6.3.2.1); splitting stops there |
The token after which to split tokens a:lend of a line that starts at token a in column
start_col, or 0 if the code fits or cannot be split.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(token_list_t), | intent(in) | :: | tokens |
the tokens of |
||
| character(len=*), | intent(in) | :: | src |
the source text |
||
| integer, | intent(in) | :: | a |
first token of the line |
||
| integer, | intent(in) | :: | lend |
last token of the line, its line break if it has one |
||
| integer, | intent(in) | :: | start_col |
column of token |
||
| integer, | intent(in) | :: | line_length |
maximum line width, in characters |
Line numbers of code lines whose code (without a trailing comment) is longer than line_length,
outside protected code.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
the source text |
||
| integer, | intent(in) | :: | line_length |
maximum line width, in characters; 0 or less for no limit |
How good a place the end of a token with this text is for a line break (1 is best).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
lowercase text of the token |
||
| integer, | intent(in) | :: | kind |
token kind ( |
src with each code line longer than line_length split once. The new continuation lines are indented
by indent more than the line they come from if it is the first line of a statement, and like
it if it is a continuation line, which the layout pass will usually leave in place. nsplit
returns the number of splits.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
the source text |
||
| integer, | intent(in) | :: | line_length |
maximum line width, in characters |
||
| integer, | intent(in) | :: | indent |
indentation step, in blanks |
||
| integer, | intent(out) | :: | nsplit |
number of lines split |
||
| integer, | intent(out), | optional, | allocatable | :: | changed(:,:) |
where the statements that were split
are in |
True if statement k of source, a code statement, can be laid out again on its own after
one of its lines is split, giving what laying out the whole text would: it takes up whole
lines (no ; before or after it on its lines, no byte order mark), has no statement label
(which stays at the start of the line), and is not followed by a comment line that may be
lined up with a comment at the end of its last line.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(source_t), | intent(in) | :: | source |
the source |
||
| integer, | intent(in) | :: | k |
index into |