src/Pure/ML/ml_process.scala
changeset 66782 193c31b79a33
parent 66781 dac4cfbfede8
child 66848 982baed14542
equal deleted inserted replaced
66781:dac4cfbfede8 66782:193c31b79a33
    73           "PolyML.Compiler.prompt2 := \"Poly/ML# \"")
    73           "PolyML.Compiler.prompt2 := \"Poly/ML# \"")
    74       }
    74       }
    75       else
    75       else
    76         List(
    76         List(
    77           "(PolyML.SaveState.loadHierarchy " +
    77           "(PolyML.SaveState.loadHierarchy " +
    78             ML_Syntax.print_list(ML_Syntax.print_string0)(heaps) +
    78             ML_Syntax.print_list(ML_Syntax.print_string_bytes)(heaps) +
    79           "; PolyML.print_depth 0) handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ " +
    79           "; PolyML.print_depth 0) handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ " +
    80           ML_Syntax.print_string0(": " + logic_name + "\n") +
    80           ML_Syntax.print_string_bytes(": " + logic_name + "\n") +
    81           "); OS.Process.exit OS.Process.failure)")
    81           "); OS.Process.exit OS.Process.failure)")
    82 
    82 
    83     val eval_modes =
    83     val eval_modes =
    84       if (modes.isEmpty) Nil
    84       if (modes.isEmpty) Nil
    85       else List("Print_Mode.add_modes " + ML_Syntax.print_list(ML_Syntax.print_string0)(modes))
    85       else List("Print_Mode.add_modes " + ML_Syntax.print_list(ML_Syntax.print_string_bytes)(modes))
    86 
    86 
    87     // options
    87     // options
    88     val isabelle_process_options = Isabelle_System.tmp_file("options")
    88     val isabelle_process_options = Isabelle_System.tmp_file("options")
    89     File.write(isabelle_process_options, YXML.string_of_body(options.encode))
    89     File.write(isabelle_process_options, YXML.string_of_body(options.encode))
    90     val env_options = Map("ISABELLE_PROCESS_OPTIONS" -> File.standard_path(isabelle_process_options))
    90     val env_options = Map("ISABELLE_PROCESS_OPTIONS" -> File.standard_path(isabelle_process_options))
    96         case None => Nil
    96         case None => Nil
    97         case Some(base) =>
    97         case Some(base) =>
    98           def print_table(table: List[(String, String)]): String =
    98           def print_table(table: List[(String, String)]): String =
    99             ML_Syntax.print_list(
    99             ML_Syntax.print_list(
   100               ML_Syntax.print_pair(
   100               ML_Syntax.print_pair(
   101                 ML_Syntax.print_string0, ML_Syntax.print_string0))(table)
   101                 ML_Syntax.print_string_bytes, ML_Syntax.print_string_bytes))(table)
   102           def print_list(list: List[String]): String =
   102           def print_list(list: List[String]): String =
   103             ML_Syntax.print_list(ML_Syntax.print_string0)(list)
   103             ML_Syntax.print_list(ML_Syntax.print_string_bytes)(list)
   104           List("Resources.init_session_base" +
   104           List("Resources.init_session_base" +
   105             " {global_theories = " + print_table(base.global_theories.toList) +
   105             " {global_theories = " + print_table(base.global_theories.toList) +
   106             ", loaded_theories = " + print_list(base.loaded_theories.keys) +
   106             ", loaded_theories = " + print_list(base.loaded_theories.keys) +
   107             ", known_theories = " + print_table(base.dest_known_theories) + "}")
   107             ", known_theories = " + print_table(base.dest_known_theories) + "}")
   108       }
   108       }
   114       else
   114       else
   115         channel match {
   115         channel match {
   116           case None =>
   116           case None =>
   117             List("Isabelle_Process.init_options ()")
   117             List("Isabelle_Process.init_options ()")
   118           case Some(ch) =>
   118           case Some(ch) =>
   119             List("Isabelle_Process.init_protocol " + ML_Syntax.print_string0(ch.server_name))
   119             List("Isabelle_Process.init_protocol " + ML_Syntax.print_string_bytes(ch.server_name))
   120         }
   120         }
   121 
   121 
   122     // ISABELLE_TMP
   122     // ISABELLE_TMP
   123     val isabelle_tmp = Isabelle_System.tmp_dir("process")
   123     val isabelle_tmp = Isabelle_System.tmp_dir("process")
   124     val env_tmp = Map("ISABELLE_TMP" -> File.standard_path(isabelle_tmp))
   124     val env_tmp = Map("ISABELLE_TMP" -> File.standard_path(isabelle_tmp))
   176     -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
   176     -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
   177 
   177 
   178   Run the raw Isabelle ML process in batch mode.
   178   Run the raw Isabelle ML process in batch mode.
   179 """,
   179 """,
   180       "T:" -> (arg =>
   180       "T:" -> (arg =>
   181         eval_args = eval_args ::: List("--eval", "use_thy " + ML_Syntax.print_string0(arg))),
   181         eval_args = eval_args ::: List("--eval", "use_thy " + ML_Syntax.print_string_bytes(arg))),
   182       "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),
   182       "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),
   183       "e:" -> (arg => eval_args = eval_args ::: List("--eval", arg)),
   183       "e:" -> (arg => eval_args = eval_args ::: List("--eval", arg)),
   184       "f:" -> (arg => eval_args = eval_args ::: List("--use", arg)),
   184       "f:" -> (arg => eval_args = eval_args ::: List("--use", arg)),
   185       "l:" -> (arg => logic = arg),
   185       "l:" -> (arg => logic = arg),
   186       "m:" -> (arg => modes = arg :: modes),
   186       "m:" -> (arg => modes = arg :: modes),