subroutineread_stringprivate
subroutine read_string(c, s)
Read a string in quotes, undoing its escapes.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| c | type(fypp_t) | inout | the state | |
| s | type(scan_t) | inout | the expression |
Calls
Source
Show the code
subroutine read_string(c, s)
type(fypp_t), intent(inout) :: c !! the state
type(scan_t), intent(inout) :: s !! the expression
type(buffer_t) :: b
character :: quote, ch
quote = s%text(s%pos:s%pos)
s%pos = s%pos + 1
do
if (s%pos > len(s%text)) then
call fail(c, 'a string is not closed: '//s%text)
return
end if
ch = s%text(s%pos:s%pos)
s%pos = s%pos + 1
if (ch == quote) exit
if (ch == '\' .and. s%pos <= len(s%text)) then
ch = s%text(s%pos:s%pos)
s%pos = s%pos + 1
if (ch == 'n') ch = NL
if (ch == 't') ch = TAB
end if
call add(b, ch)
end do
call take(b, s%word)
end subroutine read_string