push_tok Subroutine

private subroutine push_tok(tokens, tok_line, n_tok, val, line)

Append a token, growing the buffer as needed.

Arguments

Type IntentOptional Attributes Name
character(len=256), intent(inout), allocatable :: tokens(:)
integer, intent(inout), allocatable :: tok_line(:)
integer, intent(inout) :: n_tok
character(len=*), intent(in) :: val
integer, intent(in) :: line

Called by

proc~~push_tok~~CalledByGraph proc~push_tok push_tok proc~collect_tokens collect_tokens proc~collect_tokens->proc~push_tok proc~parse_group_body parse_group_body proc~parse_group_body->proc~collect_tokens proc~dispatch_group dispatch_group proc~dispatch_group->proc~parse_group_body proc~parse_from_lines parse_from_lines proc~parse_from_lines->proc~dispatch_group 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

Variables

Type Visibility Attributes Name Initial
integer, private :: cap
integer, private :: i
character(len=256), private, allocatable :: tmp(:)
integer, private, allocatable :: tmpl(:)

Source Code

   subroutine push_tok(tokens, tok_line, n_tok, val, line)
      !! Append a token, growing the buffer as needed.
      character(len=256), allocatable, intent(inout) :: tokens(:)
      integer, allocatable, intent(inout) :: tok_line(:)
      integer, intent(inout) :: n_tok
      character(len=*), intent(in) :: val
      integer, intent(in) :: line
      character(len=256), allocatable :: tmp(:)
      integer, allocatable :: tmpl(:)
      integer :: cap, i

      cap = size(tokens)
      if (n_tok >= cap) then
         allocate (tmp(2*cap), tmpl(2*cap))
         do i = 1, n_tok
            tmp(i) = tokens(i)
            tmpl(i) = tok_line(i)
         end do
         call move_alloc(tmp, tokens)
         call move_alloc(tmpl, tok_line)
      end if
      n_tok = n_tok + 1
      tokens(n_tok) = val
      tok_line(n_tok) = line
   end subroutine push_tok