70 type(
context),
intent(inout) :: ctx
71 character(*),
intent(in) :: token
73 character(:),
allocatable :: temp, num_str, fname
74 integer :: pos, iostat, new_line
75 logical :: has_filename
78 pos = index(lowercase(ctx%content), token) + len(token)
79 temp = trim(adjustl(ctx%content(pos:)))
81 if (len_trim(temp) == 0)
then
83 message=
'Synthax error', &
84 label=
label_type(
'#line directive with no arguments', index(token, lowercase(ctx%content)) + len(token) + 1, 1), &
86 trim(ctx%content), ctx%line))
91 pos = index(temp,
' ')
93 num_str = temp(:pos-1)
94 fname = trim(adjustl(temp(pos:)))
98 has_filename = .false.
102 read(num_str, *, iostat=iostat) new_line
103 if (iostat /= 0 .or. new_line < 1)
then
105 message=
'Synthax error', &
106 label=
label_type(
'Invalid line number in #line directive', index(token, lowercase(ctx%content)) + len(token) + 1, len(num_str)), &
108 trim(ctx%content), ctx%line))
112 ctx%line = new_line - 1
115 if (has_filename)
then
116 if (fname(1:1) ==
'"' .and. len(fname) > 1)
then
117 fname = fname(2:index(fname(2:),
'"'))
119 if (len_trim(fname) > 0)
then
120 ctx%path = trim(fname)
subroutine, public handle_line(ctx, token)
Handle the standard line directive Supports two standard forms: line <number> line <number> "<filenam...
Source location and content snapshot for precise diagnostics Instances of this type are created for e...