69 type(
context),
intent(inout) :: ctx
70 character(*),
intent(in) :: token
72 character(:),
allocatable :: temp, num_str, fname
73 integer :: pos, iostat, new_line
74 logical :: has_filename
77 pos = index(lowercase(ctx%content), token) + len(token)
78 temp = trim(adjustl(ctx%content(pos:)))
80 if (len_trim(temp) == 0)
then
82 message=
'Syntax error', &
83 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=
'Syntax error', &
106 label=
label_type(
'Invalid line number in #line directive', index(token, lowercase(ctx%content)) + len(token) + &
109 trim(ctx%content), ctx%line))
113 ctx%line = new_line - 1
116 if (has_filename)
then
117 if (fname(1:1) ==
'"' .and. len(fname) > 1)
then
118 fname = fname(2:index(fname(2:),
'"'))
120 if (len_trim(fname) > 0)
then
121 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...