26 unsigned width_suffix=0;
29 for(
unsigned i=0; i<src.size(); i++)
33 if(ch==
'u' || ch==
'U')
35 else if(ch==
'l' || ch==
'L')
37 else if(ch==
'i' || ch==
'I')
42 if((i+1)<src.size() &&
isdigit(src[i+1]))
47 else if(ch==
'j' || ch==
'J')
53 if(src.size()>=2 && src[0]==
'0' &&
tolower(src[1])==
'x')
57 std::string without_prefix(src, 2, std::string::npos);
60 else if(src.size()>=2 && src[0]==
'0' &&
tolower(src[1])==
'b')
65 std::string without_prefix(src, 2, std::string::npos);
68 else if(src.size()>=2 && src[0]==
'0' &&
isdigit(src[1]))
85 if(width_suffix<=
config.ansi_c.int_width)
87 else if(width_suffix<=
config.ansi_c.long_int_width)
88 c_type=
is_unsigned?ID_unsigned_long_int:ID_signed_long_int;
90 c_type=
is_unsigned?ID_unsigned_long_long_int:ID_signed_long_long_int;
93 is_unsigned ? ID_unsignedbv : ID_signedbv, width_suffix);
94 type.
set(ID_C_c_type, c_type);
106 bool is_hex_or_oct_or_bin=(base==8) || (base==16) || (base==2);
108 #define FITS(width, signed) \
109 ((signed?!is_unsigned:(is_unsigned || is_hex_or_oct_or_bin)) && \
110 (power(2, signed?width-1:width)>value_abs))
116 if(
FITS(
config.ansi_c.int_width,
true) && long_cnt==0)
118 width=
config.ansi_c.int_width;
120 c_type=ID_signed_int;
122 else if(
FITS(
config.ansi_c.int_width,
false) && long_cnt==0)
124 width=
config.ansi_c.int_width;
126 c_type=ID_unsigned_int;
128 else if(
FITS(
config.ansi_c.long_int_width,
true) && long_cnt!=2)
130 width=
config.ansi_c.long_int_width;
132 c_type=ID_signed_long_int;
135 else if(
FITS(
config.ansi_c.long_int_width,
false) && long_cnt!=2)
137 width=
config.ansi_c.long_int_width;
139 c_type=ID_unsigned_long_int;
141 else if(
FITS(
config.ansi_c.long_long_int_width,
true))
143 width=
config.ansi_c.long_long_int_width;
145 c_type=ID_signed_long_long_int;
148 else if(
FITS(
config.ansi_c.long_long_int_width,
false))
150 width=
config.ansi_c.long_long_int_width;
152 c_type=ID_unsigned_long_long_int;
157 width=
config.ansi_c.long_long_int_width;
162 c_type=ID_unsigned_long_long_int;
165 c_type=ID_signed_long_long_int;
169 type.
set(ID_C_c_type, c_type);
181 result.
set(ID_C_base, base);