parse_for_chars Subroutine

private subroutine parse_for_chars(unit, str, chars)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string)

character(kind=CK,len=*), intent(in) :: chars

the string to check for.

Description

Core parsing routine.

Calls

proc~~parse_for_chars~~CallsGraph proc~parse_for_chars parse_for_chars proc~pop_char pop_char proc~parse_for_chars->proc~pop_char interface~throw_exception throw_exception proc~parse_for_chars->interface~throw_exception proc~json_throw_exception json_throw_exception interface~throw_exception->proc~json_throw_exception
Help

Called By

proc~~parse_for_chars~~CalledByGraph proc~parse_for_chars parse_for_chars proc~parse_value parse_value proc~parse_value->proc~parse_for_chars proc~parse_object parse_object proc~parse_value->proc~parse_object proc~parse_array parse_array proc~parse_value->proc~parse_array proc~json_parse_string json_parse_string proc~json_parse_string->proc~parse_value proc~json_parse_file json_parse_file proc~json_parse_file->proc~parse_value proc~parse_object->proc~parse_value proc~parse_object->proc~parse_object proc~parse_array->proc~parse_value proc~wrap_json_parse_string wrap_json_parse_string proc~wrap_json_parse_string->proc~json_parse_string interface~json_parse json_parse interface~json_parse->proc~json_parse_string interface~json_parse->proc~json_parse_file proc~test_14 test_14 proc~test_14->interface~json_parse proc~test_8 test_8 proc~test_8->interface~json_parse proc~json_file_load json_file_load proc~json_file_load->interface~json_parse proc~json_file_load_from_string json_file_load_from_string proc~json_file_load_from_string->interface~json_parse program~jf_test_14 jf_test_14 program~jf_test_14->proc~test_14 program~jf_test_8 jf_test_8 program~jf_test_8->proc~test_8 proc~wrap_json_file_load_from_string wrap_json_file_load_from_string proc~wrap_json_file_load_from_string->proc~json_file_load_from_string
Help

Variables

TypeVisibility AttributesNameInitial
integer(kind=IK), public :: i
integer(kind=IK), public :: length
logical(kind=LK), public :: eof
character(kind=CK,len=1), public :: c

Source Code

    subroutine parse_for_chars(unit, str, chars)

    implicit none

    integer(IK),intent(in)              :: unit   !! file unit number (if parsing from a file)
    character(kind=CK,len=*),intent(in) :: str    !! JSON string (if parsing from a string)
    character(kind=CK,len=*),intent(in) :: chars  !! the string to check for.

    integer(IK) :: i, length
    logical(LK) :: eof
    character(kind=CK,len=1) :: c

    if (.not. exception_thrown) then

        length = len_trim(chars)

        do i = 1, length
            c = pop_char(unit, str=str, eof = eof, skip_ws = .true.)
            if (eof) then
                call throw_exception('Error in parse_for_chars:'//&
                                     ' Unexpected end of file while parsing array.')
                return
            else if (c /= chars(i:i)) then
                call throw_exception('Error in parse_for_chars:'//&
                                     ' Unexpected character.: "'//c//'" '//chars(i:i))
                return
            end if
        end do

    end if

    end subroutine parse_for_chars