825 cyclic_modules = false, class_transitive = true, |
825 cyclic_modules = false, class_transitive = true, |
826 class_relation_public = true, empty_data = (), |
826 class_relation_public = true, empty_data = (), |
827 memorize_data = K I, modify_stmts = modify_stmts } |
827 memorize_data = K I, modify_stmts = modify_stmts } |
828 end; |
828 end; |
829 |
829 |
830 fun serialize_ml print_ml_module print_ml_stmt ctxt |
830 fun serialize_ml print_ml_module print_ml_stmt ml_extension ctxt |
831 { module_name, reserved_syms, identifiers, includes, |
831 { module_name, reserved_syms, identifiers, includes, |
832 class_syntax, tyco_syntax, const_syntax } exports program = |
832 class_syntax, tyco_syntax, const_syntax } program exports = |
833 let |
833 let |
834 |
834 |
835 (* build program *) |
835 (* build program *) |
836 val { deresolver, hierarchical_program = ml_program } = |
836 val { deresolver, hierarchical_program = ml_program } = |
837 ml_program_of_program ctxt module_name (Name.make_context reserved_syms) |
837 ml_program_of_program ctxt module_name (Name.make_context reserved_syms) |
853 (* serialization *) |
853 (* serialization *) |
854 val p = Pretty.chunks2 (map snd includes |
854 val p = Pretty.chunks2 (map snd includes |
855 @ map snd (Code_Namespace.print_hierarchical { |
855 @ map snd (Code_Namespace.print_hierarchical { |
856 print_module = print_module, print_stmt = print_stmt, |
856 print_module = print_module, print_stmt = print_stmt, |
857 lift_markup = apsnd } ml_program)); |
857 lift_markup = apsnd } ml_program)); |
858 fun write width NONE = writeln o format [] width |
|
859 | write width (SOME p) = File.write p o format [] width; |
|
860 fun prepare syms width p = ([("", format syms width p)], try (deresolver [])); |
|
861 in |
858 in |
862 Code_Target.serialization write prepare p |
859 (Code_Target.Singleton (ml_extension, p), try (deresolver [])) |
863 end; |
860 end; |
864 |
861 |
865 val serializer_sml : Code_Target.serializer = |
862 val serializer_sml : Code_Target.serializer = |
866 Code_Target.parse_args (Scan.succeed ()) #> K (serialize_ml print_sml_module print_sml_stmt); |
863 Code_Target.parse_args (Scan.succeed ()) #> K (serialize_ml print_sml_module print_sml_stmt "ML"); |
867 |
864 |
868 val serializer_ocaml : Code_Target.serializer = |
865 val serializer_ocaml : Code_Target.serializer = |
869 Code_Target.parse_args (Scan.succeed ()) #> K (serialize_ml print_ocaml_module print_ocaml_stmt); |
866 Code_Target.parse_args (Scan.succeed ()) #> K (serialize_ml print_ocaml_module print_ocaml_stmt "ocaml"); |
870 |
867 |
871 |
868 |
872 (** Isar setup **) |
869 (** Isar setup **) |
873 |
870 |
874 fun fun_syntax print_typ fxy [ty1, ty2] = |
871 fun fun_syntax print_typ fxy [ty1, ty2] = |