is_decimal_real_token Function

public pure function is_decimal_real_token(token) result(valid)

List-directed control syntaxを除外した十進実数tokenだけを許可する。

Arguments

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

Return Value logical


Called by

proc~~is_decimal_real_token~~CalledByGraph proc~is_decimal_real_token is_decimal_real_token proc~read_matching_summary_real read_matching_summary_real proc~read_matching_summary_real->proc~is_decimal_real_token proc~read_matching_plane_summary_key read_matching_plane_summary_key proc~read_matching_plane_summary_key->proc~read_matching_summary_real

Source Code

  pure logical function is_decimal_real_token(token) result(valid)
    character(len=*), intent(in) :: token
    integer :: position, token_length
    logical :: has_mantissa_digit, has_exponent_digit

    valid = .false.
    token_length = len_trim(token)
    if (token_length <= 0) return
    position = 1
    if (token(position:position) == '+' .or. token(position:position) == '-') position = position + 1
    if (position > token_length) return

    has_mantissa_digit = .false.
    do while (position <= token_length)
      if (.not. is_decimal_digit(token(position:position))) exit
      has_mantissa_digit = .true.
      position = position + 1
    end do
    if (position <= token_length) then
      if (token(position:position) == '.') then
        position = position + 1
        do while (position <= token_length)
          if (.not. is_decimal_digit(token(position:position))) exit
          has_mantissa_digit = .true.
          position = position + 1
        end do
      end if
    end if
    if (.not. has_mantissa_digit) return

    if (position <= token_length) then
      if (index('eEdD', token(position:position)) > 0) then
        position = position + 1
        if (position <= token_length) then
          if (token(position:position) == '+' .or. token(position:position) == '-') position = position + 1
        end if
        has_exponent_digit = .false.
        do while (position <= token_length)
          if (.not. is_decimal_digit(token(position:position))) exit
          has_exponent_digit = .true.
          position = position + 1
        end do
        if (.not. has_exponent_digit) return
      end if
    end if
    valid = position > token_length
  end function is_decimal_real_token