This subroutine converts escaped character of the argument chara
into segment seg_list
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | chara | |||
type(segment_t), | intent(inout), | allocatable | :: | seg_list(:) |
pure subroutine convert_escaped_character_into_segments(chara, seg_list) !, hexcode) use :: forgex_utf8_m, only: ichar_utf8 implicit none character(*), intent(in) :: chara type(segment_t), allocatable, intent(inout) :: seg_list(:) integer :: unused if (allocated(seg_list)) deallocate(seg_list) select case (trim(chara)) case (ESCAPE_T) allocate(seg_list(1)) seg_list(1) = SEG_TAB case (ESCAPE_N) allocate(seg_list(2)) seg_list(1) = SEG_LF seg_list(2) = SEG_CR case (ESCAPE_R) allocate(seg_list(1)) seg_list(1) = SEG_CR case (ESCAPE_D) allocate(seg_list(1)) seg_list(1) = SEG_DIGIT case (ESCAPE_D_CAPITAL) allocate(seg_list(1)) seg_list(1) = SEG_DIGIT call invert_segment_list(seg_list) case (ESCAPE_W) allocate(seg_list(4)) seg_list(1) = SEG_LOWERCASE seg_list(2) = SEG_UPPERCASE seg_list(3) = SEG_DIGIT seg_list(4) = SEG_UNDERSCORE case (ESCAPE_W_CAPITAL) allocate(seg_list(4)) seg_list(1) = SEG_LOWERCASE seg_list(2) = SEG_UPPERCASE seg_list(3) = SEG_DIGIT seg_list(4) = SEG_UNDERSCORE call invert_segment_list(seg_list) case (ESCAPE_S) allocate(seg_list(6)) seg_list(1) = SEG_SPACE seg_list(2) = SEG_TAB seg_list(3) = SEG_CR seg_list(4) = SEG_LF seg_list(5) = SEG_FF seg_list(6) = SEG_ZENKAKU_SPACE case (ESCAPE_S_CAPITAL) allocate(seg_list(6)) seg_list(1) = SEG_SPACE seg_list(2) = SEG_TAB seg_list(3) = SEG_CR seg_list(4) = SEG_LF seg_list(5) = SEG_FF seg_list(6) = SEG_ZENKAKU_SPACE call invert_segment_list(seg_list) case (ESCAPE_X) allocate(seg_list(1)) call hex2seg(chara, seg_list(1), unused) case (ESCAPE_P) allocate(seg_list(1)) seg_list(1) = SEG_ERROR continue case (SYMBOL_BSLH) allocate(seg_list(1)) seg_list(1)%min = ichar_utf8(SYMBOL_BSLH) seg_list(1)%max = ichar_utf8(SYMBOL_BSLH) case (SYMBOL_LCRB) allocate(seg_list(1)) seg_list(1)%min = ichar_utf8(SYMBOL_LCRB) seg_list(1)%max = ichar_utf8(SYMBOL_LCRB) case (SYMBOL_RCRB) allocate(seg_list(1)) seg_list(1)%min = ichar_utf8(SYMBOL_RCRB) seg_list(1)%max = ichar_utf8(SYMBOL_RCRB) case (SYMBOL_LSBK) allocate(seg_list(1)) seg_list(1)%min = ichar_utf8(SYMBOL_LSBK) seg_list(1)%max = ichar_utf8(SYMBOL_LSBK) case (SYMBOL_RSBK) allocate(seg_list(1)) seg_list(1)%min = ichar_utf8(SYMBOL_RSBK) seg_list(1)%max = ichar_utf8(SYMBOL_RSBK) case default allocate(seg_list(1)) seg_list(1) = SEG_ERROR end select end subroutine convert_escaped_character_into_segments