- (fun env loc ->
- prerr_endline "ENV";
- prerr_endline (CicNotationPp.pp_env env);
- CicNotationEnv.instantiate env l2)))
-(* CicNotationParser.print_l2_pattern ()) *)
- | 1 -> ignore (CicNotationParser.parse_syntax_pattern istream)
- | 2 ->
- let ast = CicNotationParser.parse_ast_pattern istream in
- if ast = P.Sort `Prop then
- prerr_endline "eureka"
- else
- prerr_endline ":-("
- | 3 -> ignore (CicNotationParser.parse_interpretation istream)
- | _ -> Arg.usage arg_spec usage; exit 1);
- with CicNotationParser.Parse_error (floc, msg) ->
- let (x, y) = P.loc_of_floc floc in
- let before = String.sub line 0 x in
- let error = String.sub line x (y - x) in
- let after = String.sub line y (String.length line - y) in
- eprintf "%s\e[01;31m%s\e[00m%s\n" before error after;
- prerr_endline (sprintf "at character %d-%d: %s" x y msg)
- done
- with End_of_file ->
- close_in ic
+ (fun env loc -> CicNotationFwd.instantiate_level2 env l2));
+(* last_rule_id := Some rule_id; *)
+ if dir <> Some `LeftToRight then
+ ignore (CicNotationRew.add_pretty_printer
+ ?precedence ?associativity l2 l1)
+ | G.Executable (_, G.Command (_, G.Interpretation (_, id, l2, l3))) ->
+ prerr_endline "interpretation";
+ prerr_endline (sprintf "dsc: %s" id);
+ ignore (CicNotationRew.add_interpretation id l2 l3);
+ flush stdout
+ | G.Executable (_, G.Command (_, G.Dump _)) ->
+ CicNotationParser.print_l2_pattern (); print_newline ()
+ | G.Executable (_, G.Command (_, G.Render (_, uri))) ->
+ let obj, _ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
+ let annobj, _, _, id_to_sort, _, _, _ =
+ Cic2acic.acic_object_of_cic_object obj
+ in
+ let annterm =
+ match annobj with
+ | Cic.AConstant (_, _, _, _, ty, _, _)
+ | Cic.AVariable (_, _, _, ty, _, _) -> ty
+ | _ -> assert false
+ in
+ let t, id_to_uri =
+ CicNotationRew.ast_of_acic id_to_sort annterm
+ in
+ prerr_endline "Raw AST";
+ prerr_endline (CicNotationPp.pp_term t);
+ let t' = CicNotationRew.pp_ast t in
+ prerr_endline "Rendered AST";
+ prerr_endline (CicNotationPp.pp_term t');
+ dump_xml t' id_to_uri "out.xml"
+ | _ -> prerr_endline "Unsupported statement"
+ with
+ | End_of_file -> raise End_of_file
+ | CicNotationParser.Parse_error (floc, msg) ->
+ let (x, y) = P.loc_of_floc floc in
+(* let before = String.sub line 0 x in
+ let error = String.sub line x (y - x) in
+ let after = String.sub line y (String.length line - y) in
+ eprintf "%s\e[01;31m%s\e[00m%s\n" before error after;
+ prerr_endline (sprintf "at character %d-%d: %s" x y msg) *)
+ prerr_endline (sprintf "Parse error at character %d-%d: %s"
+ (!char_count + x) (!char_count + y) msg)
+ | exn ->
+ prerr_endline
+ (sprintf "Uncaught exception: %s" (Printexc.to_string exn))
+ done
+ with End_of_file -> ()
+
+let _ =
+ let arg_spec = [ ] in
+ let usage = "" in
+ Arg.parse arg_spec (fun _ -> raise (Arg.Bad usage)) usage;
+ print_endline "Loading builtin notation ...";
+ CicNotation.load_notation (Helm_registry.get "notation.core_file");
+ print_endline "done.";
+ flush stdout;
+ process_stream (Stream.of_channel stdin)