CBMC
preprocessor_line.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: ANSI-C Language Conversion
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
11
12
#include "
preprocessor_line.h
"
13
14
#include <cctype>
15
16
#include <
util/string2int.h
>
17
#include <
util/parser.h
>
18
19
#include "
literals/unescape_string.h
"
20
21
void
preprocessor_line
(
22
const
char
*text,
23
parsert
&parser)
24
{
25
const
char
*ptr=text;
26
std::string line_number;
27
28
// skip WS
29
while
(*ptr==
' '
|| *ptr==
'\t'
) ptr++;
30
31
// skip #
32
if
(*ptr!=
'#'
)
33
return
;
34
ptr++;
35
36
// skip WS
37
while
(*ptr==
' '
|| *ptr==
'\t'
) ptr++;
38
39
// skip "line"
40
if
(*ptr==
'l'
)
41
{
42
while
(*ptr!=0 && *ptr!=
' '
&& *ptr!=
'\t'
) ptr++;
43
}
44
45
// skip WS
46
while
(*ptr==
' '
|| *ptr==
'\t'
) ptr++;
47
48
// get line number
49
while
(isdigit(*ptr))
50
{
51
line_number+=*ptr;
52
ptr++;
53
}
54
55
// skip until "
56
while
(*ptr!=
'\n'
&& *ptr!=
'"'
) ptr++;
57
58
parser.
set_line_no
(
unsafe_string2unsigned
(line_number));
59
60
// skip "
61
if
(*ptr!=
'"'
)
62
return
;
63
64
ptr++;
65
66
std::string file_name_tmp;
67
68
// get file name
69
while
(*ptr!=
'\n'
&& *ptr!=
'"'
)
70
{
71
file_name_tmp+=*ptr;
72
ptr++;
73
}
74
75
std::string file_name_tmp2=
unescape_string
(file_name_tmp);
76
parser.
set_file
(file_name_tmp2);
77
}
string2int.h
parsert
Definition:
parser.h:23
preprocessor_line.h
unescape_string.h
parser.h
unsafe_string2unsigned
unsigned unsafe_string2unsigned(const std::string &str, int base)
Definition:
string2int.cpp:35
preprocessor_line
void preprocessor_line(const char *text, parsert &parser)
Definition:
preprocessor_line.cpp:21
unescape_string
std::string unescape_string(const std::string &src)
Definition:
unescape_string.cpp:151
parsert::set_file
void set_file(const irep_idt &file)
Definition:
parser.h:85
parsert::set_line_no
void set_line_no(unsigned _line_no)
Definition:
parser.h:80
src
ansi-c
preprocessor_line.cpp
Generated by
1.8.17