X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_disambiguation%2Ftest_parser.ml;h=a3bba5a5a9b4bf74207a562ab288fdbd976c56bf;hb=7b922ad1f9832c1edb3acea8f0c910fa2c0c20e5;hp=1813fd641457953419cb74324ca1312eda26c082;hpb=7dbfe197294523c1178dc4f3a126602fa48fbb00;p=helm.git diff --git a/helm/ocaml/cic_disambiguation/test_parser.ml b/helm/ocaml/cic_disambiguation/test_parser.ml index 1813fd641..a3bba5a5a 100644 --- a/helm/ocaml/cic_disambiguation/test_parser.ml +++ b/helm/ocaml/cic_disambiguation/test_parser.ml @@ -23,16 +23,33 @@ * http://helm.cs.unibo.it/ *) -try - let ic = - (try - open_in Sys.argv.(1) - with Invalid_argument _ -> stdin) - in - let term = CicTextualParser2.parse_term (Stream.of_channel ic) in - close_in ic; - print_endline (CicTextualParser2Pp.pp_term term) -with Stdpp.Exc_located ((p_start, p_end), exn) -> - prerr_endline (Printf.sprintf "Exception at character %d-%d: %s" - p_start p_end (Printexc.to_string exn)) +let mode = ref `Term + +let _ = + try + match Sys.argv.(1) with + | "alias" -> mode := `Alias + | "term" -> mode := `Term + | _ -> () + with Invalid_argument _ -> () + +let _ = + try + let ic = stdin in + (match !mode with + | `Term -> + let term = CicTextualParser2.parse_term (Stream.of_channel ic) in + close_in ic; + print_endline (CicTextualParser2Pp.pp_term term) + | `Alias -> + while true do + let line = input_line ic in + let env = CicTextualParser2.EnvironmentP3.of_string line in + print_endline (CicTextualParser2.EnvironmentP3.to_string env) + done) + with + | End_of_file -> () + | Stdpp.Exc_located ((p_start, p_end), exn) -> + prerr_endline (Printf.sprintf "Exception at character %d-%d: %s" + p_start p_end (Printexc.to_string exn))