module T = Translator let process (optional_line : string option) = match optional_line with | None -> () | Some line -> let res = Result.map (fun t-> Sounds.repr (module Repr.Default) t) (T.Reader.process line) in match res with | Ok response -> print_endline response | Error err -> print_endline err let rec repeat channel = (* Attempt to read one line. *) let optional_line, continue = T.Lexer.line channel in process optional_line; if continue then repeat channel let () = repeat (Lexing.from_channel stdin)