let parse_from_location f (loc, s : Lexing.position * string) =
let lb = from_string s in
copy_lexbuf lb loc;
try
f token lb
with
| Parsing.Parse_error as _e ->
Cil.error_loc (
lb.lex_curr_p.Lexing.pos_fname,
lb.lex_curr_p.Lexing.pos_lnum)
"unexpected token '%s'@." (Lexing.lexeme lb);
Logic_utils.exit_kw_c_mode ();
raise Parsing.Parse_error
| Error (_, m) ->
Cil.error_loc (
lb.lex_curr_p.Lexing.pos_fname,
lb.lex_curr_p.Lexing.pos_lnum)
"%s@." m;
Logic_utils.exit_kw_c_mode ();
raise Parsing.Parse_error
| Logic_utils.Not_well_formed (loc, m) ->
Cil.error_loc
((fst loc).Lexing.pos_fname,(fst loc).Lexing.pos_lnum)
"%s@." m;
Logic_utils.exit_kw_c_mode ();
raise Parsing.Parse_error