token_list Subroutine

public subroutine token_list(tokens, out)

Renders a token vocabulary as "a, b, c", for an error message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tokens(:)

the accepted vocabulary.

character(len=:), intent(out), allocatable :: out

comma-separated, in array order.


Source Code

    subroutine token_list(tokens, out)
        character(len=*), intent(in) :: tokens(:) !! the accepted vocabulary.
        character(len=:), allocatable, intent(out) :: out !! comma-separated, in array order.
        integer :: i

        out = ""
        do i = 1, size(tokens)
            if (i > 1) out = out // ", "
            out = out // trim(tokens(i))
        end do
    end subroutine token_list