let rec prf_raw_of_string ?(print_trace = false) ?(print_tokens = false) (s : string) : t_prf_raw =
try
let prf_seq : PRF_sequencer.t_prf_seq = PRF_sequencer.prf_seq_of_string ~print_trace:print_trace s in
prf_raw_of_prf_seq ~print_tokens:print_tokens prf_seq
with
|PRF_sequencer.Error "empty string" -> raise (Error "Empty file")
|PRF_sequencer.Automaton_error (PRF_sequencer.State n) ->
match print_trace with
|false ->
let _ = IO.print_to_stderr_red "PRF_sequencer failed; went through the following states:" in
prf_raw_of_string ~print_trace:true ~print_tokens:print_tokens s
|true ->
let _ : unit = IO.print_to_stderr_red ("PRF_sequencer failed in state " ^ (string_of_int n)) in
raise (Parse_error s)