src/Pure/Tools/process_theories.scala
author wenzelm
Sat, 01 Nov 2025 13:56:39 +0100
changeset 83435 0f9bae334ac6
parent 83007 b9715600883c
permissions -rw-r--r--
more uniform Isabelle_System.default_logic, with subtle change of semantics due to getenv_strict;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Tools/process_theories.scala
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     3
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     4
Process theories within an adhoc session context.
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     5
*/
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     6
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     7
package isabelle
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     8
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
     9
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    10
import java.io.{File => JFile}
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    11
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    12
import scala.collection.mutable
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    13
import scala.util.matching.Regex
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    14
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    15
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    16
object Process_Theories {
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    17
  /** process theories **/
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    18
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    19
  def read_files(path: Path): List[Path] =
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    20
    Library.trim_split_lines(File.read(path)).map(Path.explode)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    21
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    22
  def process_theories(
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    23
    options: Options,
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    24
    logic: String,
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    25
    directory: Option[Path] = None,
82980
839d86abfe86 tuned signature: more defaults;
wenzelm
parents: 82977
diff changeset
    26
    theories: List[String] = Nil,
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    27
    files: List[Path] = Nil,
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    28
    dirs: List[Path] = Nil,
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    29
    output_messages: Boolean = false,
82980
839d86abfe86 tuned signature: more defaults;
wenzelm
parents: 82977
diff changeset
    30
    message_head: List[Regex] = Nil,
839d86abfe86 tuned signature: more defaults;
wenzelm
parents: 82977
diff changeset
    31
    message_body: List[Regex] = Nil,
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    32
    margin: Double = Pretty.default_margin,
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    33
    breakgain: Double = Pretty.default_breakgain,
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    34
    metric: Pretty.Metric = Symbol.Metric,
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
    35
    unicode_symbols: Boolean = false,
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
    36
    export_files: List[(String, Int, List[String])] = Nil,
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    37
    progress: Progress = new Progress
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    38
  ): Build.Results = {
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    39
    Isabelle_System.with_tmp_dir("private") { private_dir =>
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    40
      /* options */
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    41
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    42
      val build_engine = Build.Engine(Build.engine_name(options))
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    43
      val build_options = build_engine.build_options(options)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    44
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    45
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    46
      /* session directory and files */
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    47
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    48
      val private_prefix = private_dir.implode + "/"
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    49
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
    50
      val session_name = Sessions.DRAFT
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    51
      val session_dir =
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    52
        directory match {
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    53
          case Some(dir) => dir.absolute
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    54
          case None =>
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    55
            val dir = Isabelle_System.make_directory(private_dir + Path.basic(session_name))
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    56
            var seen = Set.empty[JFile]
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    57
            for (path0 <- files) {
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    58
              val path = path0.canonical
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    59
              val file = path.file
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    60
              if (!seen(file)) {
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    61
                seen += file
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    62
                val target = dir + path.base
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    63
                if (target.is_file) {
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    64
                  error("Duplicate session source file " + path.base + " --- from " + path)
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    65
                }
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    66
                Isabelle_System.copy_file(path, target)
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    67
              }
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    68
            }
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
    69
            dir
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    70
        }
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    71
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    72
      /* session theories */
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    73
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    74
      val more_theories =
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    75
        for (path <- files; name <- Thy_Header.get_thy_name(path.implode))
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    76
          yield name
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    77
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    78
      val session_theories = theories ::: more_theories
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    79
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    80
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    81
      /* session imports */
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    82
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    83
      val sessions_structure = Sessions.load_structure(build_options, dirs = dirs)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    84
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    85
      val session_imports =
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    86
        Set.from(
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    87
          for {
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    88
            name <- session_theories.iterator
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    89
            session = sessions_structure.theory_qualifier(name)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    90
            if session.nonEmpty
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    91
          } yield session).toList
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    92
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    93
82993
cae70aa29054 build logic image in persistent store, without private_dir;
wenzelm
parents: 82992
diff changeset
    94
      /* build session */
cae70aa29054 build logic image in persistent store, without private_dir;
wenzelm
parents: 82992
diff changeset
    95
cae70aa29054 build logic image in persistent store, without private_dir;
wenzelm
parents: 82992
diff changeset
    96
      Build.build_logic(options, logic, dirs = dirs, progress = progress,
cae70aa29054 build logic image in persistent store, without private_dir;
wenzelm
parents: 82992
diff changeset
    97
        build_heap = true, strict = true)
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    98
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
    99
      val session_entry =
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   100
        Sessions.Session_Entry(
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   101
          parent = Some(logic),
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   102
          theories = session_theories.map(a => (Nil, List(((a, Position.none), false)))),
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   103
          imports = session_imports,
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   104
          export_files = export_files
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   105
            .map({ case (a, b, c) => (Path.explode(a).absolute.implode, b, c) }))
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   106
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   107
      val session_info =
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   108
        Sessions.Info.make(session_entry, draft_session = true,
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   109
          dir = session_dir, options = options)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   110
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   111
      def session_setup(setup_session_name: String, session: Session): Unit = {
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   112
        if (output_messages && setup_session_name == session_name) {
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
   113
          def recode(s: String): String = Symbol.output(unicode_symbols, s)
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   114
          session.all_messages += Session.Consumer[Prover.Message]("process_theories") {
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   115
            case output: Prover.Output
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   116
              if Protocol.is_exported(output.message) || Protocol.is_state(output.message) =>
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   117
              output.properties match {
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   118
                case Position.Line_File(line, file0) =>
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   119
                  val file = Library.perhaps_unprefix(private_prefix, file0)
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   120
                  val pos = Position.Line_File(line, file)
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   121
                  if (Build.print_log_check(pos, output.message, message_head, message_body)) {
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   122
                    progress.echo(Protocol.message_text(output.message, heading = true, pos = pos,
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
   123
                      recode = recode, margin = margin, breakgain = breakgain, metric = metric))
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   124
                  }
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   125
                case _ =>
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   126
              }
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   127
            case _ =>
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   128
          }
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   129
        }
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   130
      }
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   131
82992
01b6ba2f121b proper session dirs;
wenzelm
parents: 82991
diff changeset
   132
      Build.build(options, private_dir = Some(private_dir), dirs = dirs, progress = progress,
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   133
        infos = List(session_info), selection = Sessions.Selection.session(session_name),
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   134
        session_setup = session_setup,
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   135
        export_files = export_files.nonEmpty)
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   136
    }
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   137
  }
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   138
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   139
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   140
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   141
  /** Isabelle tool wrapper **/
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   142
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   143
  val isabelle_tool = Isabelle_Tool("process_theories",
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   144
    "process theories within an adhoc session context",
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   145
    Scala_Project.here,
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   146
    { args =>
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
   147
      var directory: Option[Path] = None
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   148
      val export_files = new mutable.ListBuffer[(String, Int, List[String])]
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   149
      val message_head = new mutable.ListBuffer[Regex]
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   150
      val message_body = new mutable.ListBuffer[Regex]
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   151
      var output_messages = false
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
   152
      var unicode_symbols = false
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   153
      val dirs = new mutable.ListBuffer[Path]
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   154
      val files = new mutable.ListBuffer[Path]
83435
0f9bae334ac6 more uniform Isabelle_System.default_logic, with subtle change of semantics due to getenv_strict;
wenzelm
parents: 83007
diff changeset
   155
      var logic = Isabelle_System.default_logic()
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   156
      var margin = Pretty.default_margin
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   157
      var options = Options.init()
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   158
      var verbose = false
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   159
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   160
      val getopts = Getopts("""
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   161
Usage: isabelle process_theories [OPTIONS] [THEORIES...]
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   162
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   163
  Options are:
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
   164
    -D DIR       explicit session directory (default: private)
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   165
    -E EXPORTS   write session export artifacts to file-system
82991
eacbf9361b8d tuned spelling;
wenzelm
parents: 82990
diff changeset
   166
    -F FILE      include additional session files, listed in FILE
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   167
    -H REGEX     filter messages by matching against head
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   168
    -M REGEX     filter messages by matching against body
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   169
    -O           output messages
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
   170
    -U           output Unicode symbols
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   171
    -d DIR       include session directory
82991
eacbf9361b8d tuned spelling;
wenzelm
parents: 82990
diff changeset
   172
    -f FILE      include additional session file
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   173
    -l NAME      logic session name (default ISABELLE_LOGIC=""" + quote(logic) + """)
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   174
    -m MARGIN    margin for pretty printing (default: """ + margin + """)
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   175
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   176
    -v           verbose
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   177
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   178
  Process theories within an adhoc session context.
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   179
""",
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
   180
        "D:" -> (arg => directory = Some(Path.explode(arg))),
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   181
        "E:" -> (arg => export_files += Sessions.parse_exports(arg)),
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   182
        "F:" -> (arg => files ++= read_files(Path.explode(arg))),
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   183
        "H:" -> (arg => message_head += arg.r),
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   184
        "M:" -> (arg => message_body += arg.r),
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   185
        "O" -> (_ => output_messages = true),
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
   186
        "U" -> (_ => unicode_symbols = true),
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   187
        "d:" -> (arg => dirs += Path.explode(arg)),
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   188
        "f:" -> (arg => files += Path.explode(arg)),
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   189
        "l:" -> (arg => logic = arg),
82977
35b0ef2558da support output of prover messages;
wenzelm
parents: 82975
diff changeset
   190
        "m:" -> (arg => margin = Value.Double.parse(arg)),
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   191
        "o:" -> (arg => options = options + arg),
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   192
        "v" -> (_ => verbose = true))
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   193
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   194
      val theories = getopts(args)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   195
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   196
      val progress = new Console_Progress(verbose = verbose)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   197
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   198
      val results =
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   199
        progress.interrupt_handler {
82990
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
   200
          process_theories(options, logic, directory = directory, theories = theories,
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
   201
            files = files.toList, dirs = dirs.toList, output_messages = output_messages,
96010245b731 support for explicit session directory;
wenzelm
parents: 82988
diff changeset
   202
            message_head = message_head.toList, message_body = message_body.toList,
83007
b9715600883c support for "isabelle process_theories -E EXPORTS";
wenzelm
parents: 82993
diff changeset
   203
            margin = margin, unicode_symbols = unicode_symbols, export_files = export_files.toList,
82988
71ffc2c22348 explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents: 82980
diff changeset
   204
            progress = progress)
82975
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   205
        }
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   206
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   207
      sys.exit(results.rc)
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   208
    })
a28d9192d31e Process theories within an adhoc session context.
wenzelm
parents:
diff changeset
   209
}