let parse_constant = function
PconstInteger s ->
let n, t = parse_integer s in
CTTconstInteger n, t
| PconstChar s ->
let c =
match unquote_string s with
[c] -> c
| _ -> failwith "parse_const"
in
CTTconstInteger (big_int_of_int (Char.code c)), type_int
| PconstFloat s ->
let length = String.length s in
if s.[length - 1] = 'f' || s.[length - 1] = 'F' then begin
CTTconstFloat (float_of_string (chop_last_char s)), type_float
end
else if s.[length - 1] = 'l' || s.[length - 1] = 'L' then begin
CTTconstFloat (float_of_string (chop_last_char s)), type_long_double
end
else
CTTconstFloat (float_of_string s), type_double
| PconstString l ->
let rec continue = function
[] -> []
| s::l -> (unquote_string s)@(continue l)
in
let l = continue l in
let length = List.length l in
let s = String.create length in
let rec continue i = function
[] -> ()
| c::l ->
s.[i] <- c;
continue (i + 1) l
in
continue 0 l;
CTTconstString s, type_char_array length