let lex_string str =
try
let (__strm : _ Stream.t) = lexer str
in
match Stream.peek __strm with
| Some ((tok, _)) ->
(Stream.junk __strm;
(match Stream.peek __strm with
| Some ((EOI, _)) -> (Stream.junk __strm; tok)
| _ -> raise (Stream.Error "")))
| _ -> raise Stream.Failure
with
| Stream.Failure | Stream.Error _ ->
failwith
(sprintf
"Cannot print %S this string contains more than one token"
str)
| Lexer.Error.E exn ->
failwith
(sprintf
"Cannot print %S this identifier does not respect OCaml lexing rules (%s)"
str (Lexer.Error.to_string exn))