Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tree_node_t), | intent(in) | :: | tree(:) | |||
integer(kind=int32) | :: | root_i |
function print_class_simplify (tree, root_i) result(str) use :: forgex_segment_m, only: SEG_EMPTY use :: forgex_utf8_m implicit none type(tree_node_t), intent(in) :: tree(:) integer(int32) :: root_i character(:), allocatable :: str integer(int32) :: siz, j character(:),allocatable :: buf str = '' if (allocated(tree(root_i)%c)) then siz = size(tree(root_i)%c, dim=1) else return end if if (siz == 0) return if (tree(root_i)%c(1) == SEG_LF) then str = '<LF>' return else if (tree(root_i)%c(1) == SEG_CR) then str = '<CR>' return else if (tree(root_i)%c(1) == SEG_EMPTY) then str ="<EMPTY>" return else if (siz == 1 .and. tree(root_i)%c(1)%min == tree(root_i)%c(1)%max) then str = '"'//char_utf8(tree(root_i)%c(1)%min)//'"' return else if (siz == 1 .and. tree(root_i)%c(1) == SEG_ANY) then str = '<ANY>' return end if buf = '[ ' do j = 1, siz if (tree(root_i)%c(j) == SEG_LF) then buf = buf//'<LF>; ' else if (tree(root_i)%c(j) == SEG_TAB) then buf = buf//'<TAB>; ' else if (tree(root_i)%c(j) == SEG_CR) then buf = buf//'<CR>; ' else if (tree(root_i)%c(j) == SEG_FF) then buf = buf//'<FF>; ' else if (tree(root_i)%c(j) == SEG_SPACE) then buf = buf//'<SPACE>; ' else if (tree(root_i)%c(j) == SEG_ZENKAKU_SPACE) then buf = buf//'<ZENKAKU SPACE>; ' else if (tree(root_i)%c(j)%max == UTF8_CODE_MAX) then buf = buf//'"'//char_utf8(tree(root_i)%c(j)%min)//'"-"'//"<U+1FFFFF>"//'; ' else buf = buf//'"'//char_utf8(tree(root_i)%c(j)%min)//'"-"'//char_utf8(tree(root_i)%c(j)%max)//'"; ' end if end do buf = trim(buf)//']' str = trim(buf) end function print_class_simplify