parse_from_lines Subroutine

private subroutine parse_from_lines(this, lines, n_lines, label, errors, n_err)

Walk an in-memory namelist (already split into lines): strip comments, scan for &group headers, dispatch keys. label names the source in error messages — a file path for parse_file, a sentinel (e.g. ““) for buffer parses.

Arguments

Type IntentOptional Attributes Name
type(nml_schema_t), intent(inout) :: this
character(len=*), intent(in) :: lines(:)
integer, intent(in) :: n_lines
character(len=*), intent(in) :: label
character(len=:), intent(inout), allocatable :: errors(:)
integer, intent(inout) :: n_err

Calls

proc~~parse_from_lines~~CallsGraph proc~parse_from_lines parse_from_lines proc~add_err add_err proc~parse_from_lines->proc~add_err proc~dispatch_group dispatch_group proc~parse_from_lines->proc~dispatch_group proc~make_prefix make_prefix proc~parse_from_lines->proc~make_prefix proc~next_amp next_amp proc~parse_from_lines->proc~next_amp proc~read_group_name read_group_name proc~parse_from_lines->proc~read_group_name proc~skip_to_slash skip_to_slash proc~parse_from_lines->proc~skip_to_slash proc~dispatch_group->proc~add_err proc~dispatch_group->proc~skip_to_slash names names proc~dispatch_group->names proc~group_name_list group_name_list proc~dispatch_group->proc~group_name_list proc~parse_group_body parse_group_body proc~dispatch_group->proc~parse_group_body proc~schema_find_group nml_schema_t%schema_find_group proc~dispatch_group->proc~schema_find_group proc~schema_is_external nml_schema_t%schema_is_external proc~dispatch_group->proc~schema_is_external proc~strip_nml strip_nml proc~dispatch_group->proc~strip_nml proc~suggest suggest proc~dispatch_group->proc~suggest proc~fmt_int fmt_int proc~make_prefix->proc~fmt_int proc~strip_comment strip_comment proc~next_amp->proc~strip_comment proc~is_ident_char is_ident_char proc~read_group_name->proc~is_ident_char proc~read_group_name->proc~strip_comment proc~skip_to_slash->proc~strip_comment proc~apply_one_pair apply_one_pair proc~parse_group_body->proc~apply_one_pair proc~collect_tokens collect_tokens proc~parse_group_body->proc~collect_tokens proc~schema_find_group->proc~strip_nml proc~lower lower proc~schema_find_group->proc~lower proc~schema_is_external->proc~strip_nml proc~schema_is_external->proc~lower proc~strip_nml->proc~lower proc~levenshtein levenshtein proc~suggest->proc~levenshtein proc~suggest->proc~lower proc~apply_one_pair->proc~add_err proc~apply_one_pair->proc~make_prefix proc~apply_one_pair->names proc~apply_one_pair->proc~suggest parse_tokens parse_tokens proc~apply_one_pair->parse_tokens proc~append_val append_val proc~apply_one_pair->proc~append_val proc~group_find_key nml_group_t%group_find_key proc~apply_one_pair->proc~group_find_key proc~group_key_list group_key_list proc~apply_one_pair->proc~group_key_list proc~collect_tokens->proc~add_err proc~collect_tokens->proc~make_prefix proc~collect_tokens->proc~strip_comment proc~check_unsupported check_unsupported proc~collect_tokens->proc~check_unsupported proc~push_tok push_tok proc~collect_tokens->proc~push_tok proc~check_unsupported->proc~add_err proc~check_unsupported->proc~make_prefix proc~is_repeat_count is_repeat_count proc~check_unsupported->proc~is_repeat_count proc~group_find_key->proc~lower

Called by

proc~~parse_from_lines~~CalledByGraph proc~parse_from_lines parse_from_lines proc~parse_file parse_file proc~parse_file->proc~parse_from_lines proc~schema_parse_lines nml_schema_t%schema_parse_lines proc~schema_parse_lines->proc~parse_from_lines proc~read_config_from_string_impl read_config_from_string_impl proc~read_config_from_string_impl->proc~schema_parse_lines proc~schema_parse nml_schema_t%schema_parse proc~schema_parse->proc~parse_file proc~read_config_from_string read_config_from_string proc~read_config_from_string->proc~read_config_from_string_impl proc~read_config_impl read_config_impl proc~read_config_impl->proc~schema_parse proc~build_pending_handle build_pending_handle proc~build_pending_handle->proc~read_config_from_string proc~read_config read_config proc~read_config->proc~read_config_impl proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~build_pending_handle proc~rdb_ocean_create_pending rdb_ocean_create_pending proc~rdb_ocean_create_pending->proc~build_pending_handle

Variables

Type Visibility Attributes Name Initial
integer, private :: col
integer, private :: gline
character(len=:), private, allocatable :: gname
logical, private, allocatable :: group_seen(:)
integer, private :: li
character(len=:), private, allocatable :: prefix

Source Code

   subroutine parse_from_lines(this, lines, n_lines, label, errors, n_err)
      !! Walk an in-memory namelist (already split into `lines`): strip
      !! comments, scan for `&group` headers, dispatch keys.  `label`
      !! names the source in error messages — a file path for parse_file,
      !! a sentinel (e.g. "<config-string>") for buffer parses.
      type(nml_schema_t), intent(inout) :: this
      character(len=*), intent(in) :: lines(:)
      integer, intent(in) :: n_lines
      character(len=*), intent(in) :: label
      character(len=:), allocatable, intent(inout) :: errors(:)
      integer, intent(inout) :: n_err

      integer :: li, col, gline
      character(len=:), allocatable :: gname, prefix
      logical, allocatable :: group_seen(:)

      if (allocated(this%groups)) then
         allocate (group_seen(size(this%groups)))
         group_seen = .false.
      else
         allocate (group_seen(0))
      end if

      li = 1
      col = 1
      do
         ! Scan for the next '&' that opens a group.
         call next_amp(lines, n_lines, li, col)
         if (li > n_lines) exit
         gline = li
         call read_group_name(lines, n_lines, li, col, gname)
         prefix = make_prefix(label, gline)
         if (len_trim(gname) == 0) then
            call add_err(errors, n_err, prefix//"malformed group header (expected name after '&')")
            ! Skip to next '/' to recover.
            call skip_to_slash(lines, n_lines, li, col)
            cycle
         end if
         call dispatch_group(this, lines, n_lines, li, col, gname, prefix, &
                             group_seen, errors, n_err, label)
      end do
   end subroutine parse_from_lines