A continuation line whose first non-blank token is f, with its code starting at the column
aligned, or at indented or its original column if that would make the line too long.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(writer_t), | intent(inout) | :: | w |
the output and the alignment state |
||
| character(len=*), | intent(in) | :: | src |
the source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
its tokens |
||
| integer, | intent(in) | :: | f |
first non-blank token of the line |
||
| integer, | intent(in) | :: | lend |
last token of the line, its line break if it has one |
||
| integer, | intent(in) | :: | aligned |
preferred column for the code (see continuation_target) |
||
| integer, | intent(in) | :: | indented |
column for the code with a fixed continuation indent |
subroutine emit_continuation(w, src, tokens, f, lend, aligned, indented) !! A continuation line whose first non-blank token is `f`, with its code starting at the column !! `aligned`, or at `indented` or its original column if that would make the line too long. type(writer_t), intent(inout) :: w !! the output and the alignment state character(len=*), intent(in) :: src !! the source text type(token_list_t), intent(in) :: tokens !! its tokens integer, intent(in) :: f !! first non-blank token of the line integer, intent(in) :: lend !! last token of the line, its line break if it has one integer, intent(in) :: aligned !! preferred column for the code (see [[continuation_target]]) integer, intent(in) :: indented !! column for the code with a fixed continuation indent integer :: g, target, orig if (tokens%tok(f)%kind /= TK_CONT) then target = fitting_column(w, src, tokens, f, lend, [aligned, indented, input_column(src, tokens%tok(f))]) call put(w, repeat(' ', target)) call emit_body(w, src, tokens, f, lend) return end if ! a leading `&`, placed so that the code after it starts at the target column orig = input_column(src, tokens%tok(f)) g = f + 1 if (g <= lend) then if (is_code_kind(tokens%tok(g)%kind)) then ! `&code`: keep them together target = fitting_column(w, src, tokens, f, lend, [aligned - 1, indented - 1, orig], g, 1) call put(w, repeat(' ', target)//'&') call emit_body(w, src, tokens, g, lend) return end if end if g = first_non_blank(tokens, g, lend) target = fitting_column(w, src, tokens, f, lend, [aligned - 2, indented - 2, orig], g, 2) call put(w, repeat(' ', target)//'&') if (g <= lend) then if (tokens%tok(g)%kind /= TK_NEWLINE) call put(w, ' ') end if call emit_body(w, src, tokens, g, lend) end subroutine emit_continuation