comment_column Function

private function comment_column(w, src, tokens, j, default) result(col)

Output column for the comment-only line with comment token j: lined up with the comment on the line above if it was lined up with it in the input, otherwise default. Records the comment for the next line.

Arguments

Type IntentOptional 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) :: j

the comment token

integer, intent(in) :: default

column to use if it is not lined up with the comment above

Return Value integer


Calls

proc~~comment_column~~CallsGraph proc~comment_column comment_column proc~fitting_column fitting_column proc~comment_column->proc~fitting_column proc~input_column input_column proc~comment_column->proc~input_column proc~first_piece_width first_piece_width proc~fitting_column->proc~first_piece_width proc~line_width line_width proc~fitting_column->proc~line_width proc~utf8_width utf8_width proc~input_column->proc~utf8_width proc~first_piece_width->proc~utf8_width proc~line_pieces line_pieces proc~first_piece_width->proc~line_pieces proc~line_width->proc~utf8_width proc~line_width->proc~line_pieces

Called by

proc~~comment_column~~CalledByGraph proc~comment_column comment_column proc~emit_comment_line emit_comment_line proc~emit_comment_line->proc~comment_column proc~emit_statement emit_statement proc~emit_statement->proc~comment_column proc~layout layout proc~layout->proc~emit_comment_line proc~layout->proc~emit_statement proc~format_pass format_pass proc~format_pass->proc~layout proc~format_text format_text proc~format_text->proc~format_pass proc~relayout relayout proc~format_text->proc~relayout proc~relayout->proc~format_pass proc~process_text process_text proc~process_text->proc~format_text proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

integer function comment_column(w, src, tokens, j, default) result(col)
    !! Output column for the comment-only line with comment token `j`: lined up with the comment on
    !! the line above if it was lined up with it in the input, otherwise `default`. Records the
    !! comment for the next line.
    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) :: j                   !! the comment token
    integer, intent(in) :: default             !! column to use if it is not lined up with the comment above
    integer :: in_col
    in_col = input_column(src, tokens%tok(j))
    col = default
    if (w%comment_in >= 0 .and. in_col == w%comment_in) col = w%comment_out
    col = fitting_column(w, src, tokens, j, j, [col, default, in_col], always_original=.true.)
    w%comment_in = in_col
    w%comment_out = col
end function comment_column