List-directed control syntaxを除外した十進実数tokenだけを許可する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | token |
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