X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_disambiguation%2Ftest_parser.ml;h=581b8d3e401c13f9952577d39f1872eb051952f7;hb=d3c72d6856cd185e5b3e9f2e8b928b78c7031ed1;hp=0f6b2d162c07ab05d4fd1b21b21b8e6a26bcad52;hpb=358d1d55044347255aacb8daf03de0dbb18bc668;p=helm.git diff --git a/helm/ocaml/cic_disambiguation/test_parser.ml b/helm/ocaml/cic_disambiguation/test_parser.ml index 0f6b2d162..581b8d3e4 100644 --- a/helm/ocaml/cic_disambiguation/test_parser.ml +++ b/helm/ocaml/cic_disambiguation/test_parser.ml @@ -23,20 +23,33 @@ * http://helm.cs.unibo.it/ *) -try - let ic = - (try - open_in Sys.argv.(1) - with Invalid_argument _ -> stdin) - in - let term = Parser.parse_term (Stream.of_channel ic) in - close_in ic; - print_endline (Pp.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 -(* print_endline (Macro.expand "def") *) +let _ = + try + match Sys.argv.(1) with + | "alias" -> mode := `Alias + | "term" -> mode := `Term + | _ -> () + with Invalid_argument _ -> () -(* Printf.printf "'%s'\n" (Macro.expand Sys.argv.(1)) *) +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 (CicAstPp.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))