68 type(
context),
intent(inout) :: ctx
69 character(*),
intent(in) :: token
71 character(:),
allocatable :: temp, num_str, fname
72 integer :: pos, iostat, new_line
73 logical :: has_filename
76 pos = index(lowercase(ctx%content), token) + len(token)
77 temp = trim(adjustl(ctx%content(pos:)))
79 if (len_trim(temp) == 0)
then
81 message=
'Synthax error', &
82 label=
label_type(
'#line directive with no arguments', index(token, lowercase(ctx%content)) + len(token) + 1, 1), &
84 trim(ctx%content), ctx%line))
89 pos = index(temp,
' ')
91 num_str = temp(:pos-1)
92 fname = trim(adjustl(temp(pos:)))
96 has_filename = .false.
100 read(num_str, *, iostat=iostat) new_line
101 if (iostat /= 0 .or. new_line < 1)
then
103 message=
'Synthax error', &
104 label=
label_type(
'Invalid line number in #line directive', index(token, lowercase(ctx%content)) + len(token) + 1, len(num_str)), &
106 trim(ctx%content), ctx%line))
110 ctx%line = new_line - 1
113 if (has_filename)
then
114 if (fname(1:1) ==
'"' .and. len(fname) > 1)
then
115 fname = fname(2:index(fname(2:),
'"'))
117 if (len_trim(fname) > 0)
then
118 ctx%path = trim(fname)
Source location and content snapshot for precise diagnostics Instances of this type are created for e...