Parse a string into tokens. This subroutine implements the tokenize
intrinsic procedure as defined in
the Fortran 2023 language standard (Section 16.9.210).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
integer, | intent(out), | allocatable | :: | first(:) | ||
integer, | intent(out), | allocatable | :: | last(:) |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private | :: | l | ||||
integer, | private | :: | n | ||||
integer, | private | :: | pos | ||||
integer, | private | :: | pos_end(len(string)+1) | ||||
integer, | private | :: | pos_start(len(string)+1) |
pure subroutine tokenize_into_first_last(string, set, first, last) character(*), intent(in) :: string, set integer, allocatable, intent(out) :: first(:), last(:) integer :: pos_start(len(string) + 1), pos_end(len(string) + 1) integer :: l, n, pos l = len(string) n = 0 pos = 0 do while (pos < l + 1) n = n + 1 pos_start(n) = pos + 1 call split(string, set, pos) pos_end(n) = pos - 1 end do allocate(first(n), last(n)) first(:) = pos_start(1:n) last(:) = pos_end(1:n) end subroutine tokenize_into_first_last