CBMC
Loading...
Searching...
No Matches
preprocessor_line.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: ANSI-C Language Conversion
4
5Author: 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
20
22 const char *text,
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
76 parser.set_file(file_name_tmp2);
77}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
int isdigit(int c)
Definition ctype.c:24
Parser utilities.
void preprocessor_line(const char *text, parsert &parser)
ANSI-C Language Conversion.
unsigned unsafe_string2unsigned(const std::string &str, int base)
std::string unescape_string(const std::string &src)
ANSI-C Language Conversion.