fdoc

subroutineparse_declarator

subroutine parse_declarator(text, name, dimension, initial, points)

Read one name of a declaration, such as x(3) = 1.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the text

namecharacter(len=:)outallocatable

the name

dimensioncharacter(len=:)outallocatable

the dimensions, if any

initialcharacter(len=:)outallocatable

the initial value, if any

pointslogicalout

true if initialized with =>

Calls

Source

Show the code
subroutine parse_declarator(text, name, dimension, initial, points)
    character(len=*), intent(in) :: text                    !! the text
    character(len=:), allocatable, intent(out) :: name      !! the name
    character(len=:), allocatable, intent(out) :: dimension !! the dimensions, if any
    character(len=:), allocatable, intent(out) :: initial   !! the initial value, if any
    logical, intent(out) :: points                          !! true if initialized with `=>`
    character(len=:), allocatable :: dec
    integer :: at, stop_at

    dec = remove_blanks(text)
    points = .false.
    at = top_index(dec, '=')
    if (at > 0) then
        points = dec(at + 1:min(at + 1, len(dec))) == '>'
        initial = dec(at + merge(2, 1, points):)
        dec = dec(:at - 1)
    end if
    stop_at = scan(dec, '([*')
    if (stop_at > 1) then
        dimension = dec(stop_at:)
        name = dec(:stop_at - 1)
    else
        name = dec
    end if
end subroutine parse_declarator

Graphs

Calls

Called by