src/Tools/Code/code_ml.ML
changeset 52435 6646bb548c6b
parent 52138 e21426f244aa
child 52519 598addf65209
equal deleted inserted replaced
52434:cbb94074682b 52435:6646bb548c6b
   821   >> (fn with_signatures => serialize_ml print_ocaml_module print_ocaml_stmt with_signatures));
   821   >> (fn with_signatures => serialize_ml print_ocaml_module print_ocaml_stmt with_signatures));
   822 
   822 
   823 
   823 
   824 (** Isar setup **)
   824 (** Isar setup **)
   825 
   825 
       
   826 fun fun_syntax print_typ fxy [ty1, ty2] =
       
   827   brackify_infix (1, R) fxy (
       
   828     print_typ (INFX (1, X)) ty1,
       
   829     str "->",
       
   830     print_typ (INFX (1, R)) ty2
       
   831   );
       
   832 
   826 val setup =
   833 val setup =
   827   Code_Target.add_target
   834   Code_Target.add_target
   828     (target_SML, { serializer = serializer_sml, literals = literals_sml,
   835     (target_SML, { serializer = serializer_sml, literals = literals_sml,
   829       check = { env_var = "ISABELLE_PROCESS",
   836       check = { env_var = "ISABELLE_PROCESS",
   830         make_destination = fn p => Path.append p (Path.explode "ROOT.ML"),
   837         make_destination = fn p => Path.append p (Path.explode "ROOT.ML"),
   833   #> Code_Target.add_target
   840   #> Code_Target.add_target
   834     (target_OCaml, { serializer = serializer_ocaml, literals = literals_ocaml,
   841     (target_OCaml, { serializer = serializer_ocaml, literals = literals_ocaml,
   835       check = { env_var = "ISABELLE_OCAML",
   842       check = { env_var = "ISABELLE_OCAML",
   836         make_destination = fn p => Path.append p (Path.explode "ROOT.ocaml"),
   843         make_destination = fn p => Path.append p (Path.explode "ROOT.ocaml"),
   837         make_command = fn _ => "\"$ISABELLE_OCAML\" -w pu nums.cma ROOT.ocaml" } })
   844         make_command = fn _ => "\"$ISABELLE_OCAML\" -w pu nums.cma ROOT.ocaml" } })
   838   #> Code_Target.add_tyco_syntax target_SML "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] =>
   845   #> Code_Target.set_printings (Code_Symbol.Type_Constructor ("fun",
   839       brackify_infix (1, R) fxy (
   846     [(target_SML, SOME (2, fun_syntax)), (target_OCaml, SOME (2, fun_syntax))]))
   840         print_typ (INFX (1, X)) ty1,
       
   841         str "->",
       
   842         print_typ (INFX (1, R)) ty2
       
   843       )))
       
   844   #> Code_Target.add_tyco_syntax target_OCaml "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] =>
       
   845       brackify_infix (1, R) fxy (
       
   846         print_typ (INFX (1, X)) ty1,
       
   847         str "->",
       
   848         print_typ (INFX (1, R)) ty2
       
   849       )))
       
   850   #> fold (Code_Target.add_reserved target_SML) ML_Syntax.reserved_names
   847   #> fold (Code_Target.add_reserved target_SML) ML_Syntax.reserved_names
   851   #> fold (Code_Target.add_reserved target_SML)
   848   #> fold (Code_Target.add_reserved target_SML)
   852       ["ref" (*rebinding is illegal*), "o" (*dictionary projections use it already*),
   849       ["ref" (*rebinding is illegal*), "o" (*dictionary projections use it already*),
   853         "Fail", "div", "mod" (*standard infixes*), "IntInf"]
   850         "Fail", "div", "mod" (*standard infixes*), "IntInf"]
   854   #> fold (Code_Target.add_reserved target_OCaml) [
   851   #> fold (Code_Target.add_reserved target_OCaml) [