Last byte of a two- or one-character operator at i, or 0 if there is none.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| integer, | intent(in) | :: | i |
byte to look at |
integer function operator_end(src, i) result(j) !! Last byte of a two- or one-character operator at `i`, or 0 if there is none. character(len=*), intent(in) :: src !! source text integer, intent(in) :: i !! byte to look at character(len=*), parameter :: two(*) = ['**', '//', '==', '/=', '<=', '>=', '=>', '::'] character(len=*), parameter :: one = '=+-*/<>()[],:;%?' character(len=2) :: pair integer :: k pair = src(i:min(i + 1, len(src))) do k = 1, size(two) if (pair == two(k)) then j = i + 1 return end if end do j = 0 if (index(one, src(i:i)) > 0) j = i end function operator_end