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 ->
Kernel.error
~source:lb.lex_curr_p
"unexpected token '%s'" (Lexing.lexeme lb);
Logic_utils.exit_kw_c_mode ();
raise Parsing.Parse_error
| Error (_, m) ->
Kernel.error ~source:lb.lex_curr_p "%s" m;
Logic_utils.exit_kw_c_mode ();
raise Parsing.Parse_error
| Logic_utils.Not_well_formed (loc, m) ->
Kernel.error ~source:(fst loc) "%s" m;
Logic_utils.exit_kw_c_mode ();
raise Parsing.Parse_error