parser_obj_ParseLine Subroutine

private pure subroutine parser_obj_ParseLine(this, line)

Parses a line by finding the label-value pair and storing it as a new entry.

Type Bound

parser_obj

Arguments

Type IntentOptional Attributes Name
class(parser_obj), intent(inout) :: this

Parser object

character(len=MAX_LINE_SIZE), intent(inout) :: line

A line from the input file


Calls

proc~~parser_obj_parseline~~CallsGraph proc~parser_obj_parseline parser_obj%parser_obj_ParseLine proc~parser_obj_addentry parser_obj%parser_obj_AddEntry proc~parser_obj_parseline->proc~parser_obj_addentry proc~parser_obj_fetchlabelid parser_obj%parser_obj_FetchLabelID proc~parser_obj_parseline->proc~parser_obj_fetchlabelid proc~parser_obj_reformatline parser_obj%parser_obj_ReformatLine proc~parser_obj_parseline->proc~parser_obj_reformatline

Called by

proc~~parser_obj_parseline~~CalledByGraph proc~parser_obj_parseline parser_obj%parser_obj_ParseLine proc~parser_obj_parsefile parser_obj%parser_obj_ParseFile proc~parser_obj_parsefile->proc~parser_obj_parseline program~main main program~main->proc~parser_obj_parsefile

Source Code

  pure subroutine parser_obj_ParseLine(this,line)
    !> Parses a line by finding the label-value pair and storing it as a new
    ! entry.
    implicit none
    class(parser_obj),        intent(inout) :: this                            !! Parser object
    character(MAX_LINE_SIZE), intent(inout) :: line                            !! A line from the input file
    ! Work variables
    character(MAX_LABEL_SIZE) :: label                                         !! A label
    character(MAX_LINE_SIZE)  :: value                                         !! A value
    integer                   :: separator_index                               !! Left most position of the separator
    integer                   :: entry_id
    type(entry_obj)           :: new_entry

    ! Remove tabs and comments
    call parser_obj_ReformatLine(line)

    ! Get position of separator (normally ":")
    separator_index = index(line,SEPARATOR)

    ! If found a separator, create a new entry
    if (separator_index.ne.0) then

      read(line(1:separator_index-1),'(a)') label
      read(line(separator_index+1:), '(a)') value

      if (len_trim(value).ne.0) then

        entry_id=this%FetchLabelID(label)

        if (entry_id.ne.0) then
          this%entries(entry_id)%value=trim(adjustl(value))
        else
          ! Add a new entry
          new_entry%label=trim(adjustl(label))
          new_entry%value=trim(adjustl(value))
          call this%AddEntry(new_entry)
        end if
      end if
    end if

    return
  end subroutine parser_obj_ParseLine