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 |
subroutine format_pass(src, opts, out, diags, src_tokens) !! One pass of the formatter: structure, whitespace, case and layout. character(len=*), intent(in) :: src !! source text type(format_options_t), intent(in) :: opts !! formatting options character(len=:), allocatable, intent(out) :: out !! the formatted text type(diagnostic_t), allocatable, intent(out) :: diags(:) !! problems found in this pass type(token_list_t), intent(out), optional :: src_tokens !! the tokens of `src` type(source_t) :: source type(statement_view_t), allocatable :: views(:) type(structure_t) :: st integer, allocatable :: long_lines(:) integer :: k call parse_source(src, source) call set_views(source, views) call analyze_structure(source, views, st, diags) out = layout(source, st, compute_gaps(source, views, opts%spaces, opts%comment_spacing), & compute_case(source, views, opts%letter_case), opts, long_lines) do k = 1, size(long_lines) diags = [diags, diagnostic_t(long_lines(k), 'indentation kept: the line would be longer than '// & to_s(opts%line_length)//' characters')] end do if (present(src_tokens)) then call move_alloc(source%tokens%tok, src_tokens%tok) src_tokens%n = source%tokens%n end if end subroutine format_pass