let rec doc_of_nmm_string (print_tokens:bool) (s:string):Doc_types.tr_doc= let _ : unit = set_refs () in let sedlexbuf : Sedlexing.lexbuf = Sedlexing.Utf8.from_string s in let dummy_lexbuf : Lexing.lexbuf = Lexing.from_string "" in let lexer (lexbuf : Lexing.lexbuf) : Nmm_parser.token = match sedlexer print_tokens sedlexbuf with |token, start_pos, end_pos -> let _ : unit = dummy_lexbuf.Lexing.lex_start_p <- start_pos in let _ : unit = dummy_lexbuf.Lexing.lex_curr_p <- end_pos in token in try let doc = Nmm_parser.main lexer dummy_lexbuf in doc with | _ -> match print_tokens with |false -> let _ : unit = IO.print_to_stderr ( String.concat "\n" [ "Read the the following tokens from \'" ^ s ^ "\':"; ] ) in doc_of_nmm_string true s |true -> raise (Error "Parsing failed")