Follow up r77654
[lhc/web/wiklou.git] / math / texvc_test.ml
1 exception LexerException of string
2 let lexer_token_safe lexbuf =
3 try Lexer.token lexbuf
4 with Failure s -> raise (LexerException s)
5
6 let rec foo () =
7 try
8 let line = input_line stdin in
9 (try
10 let tree = Parser.tex_expr lexer_token_safe (Lexing.from_string line) in
11 (match Html.render tree with
12 Some _ -> print_string "$^\n"
13 | None -> print_string "$_\n";
14 )
15 with
16 Texutil.Illegal_tex_function s -> print_string ("$T" ^ s ^ " " ^ line ^ "\n")
17 | LexerException s -> print_string ("$L" ^ line ^ "\n")
18 | _ -> print_string ("$ " ^ line ^ "\n"));
19 flush stdout;
20 foo ();
21 with
22 End_of_file -> ()
23 ;;
24 foo ();;