parse_string Function

private function parse_string(unit) result(string)

Arguments

Type IntentOptional AttributesName
integer, intent(inout) :: unit

Return Value type(fson_string), pointer


Contents

Source Code


Source Code

  function parse_string(unit) result(string)
    use fson_string_m, only: fson_string, fson_string_create, fson_string_append
    implicit none

    integer, intent(inout) :: unit
    type(fson_string), pointer :: string

    logical :: eof
    character :: c, last

    string => fson_string_create()

    do
       c = pop_char(unit, eof=eof, skip_ws=.false.)
       if (eof) then
          print *, "Expecting end of string"
          call exit(1)!
       else if ('"' == c .and. last /= '\') then  !'
          exit
       else
          last = c
          call fson_string_append(string, c)
       end if
    end do
  end function parse_string