author | wenzelm |
Mon, 06 Apr 2020 21:07:38 +0200 | |
changeset 71713 | 928fd852f3e2 |
parent 71632 | c1bc38327bc2 |
child 72570 | 79661d12155e |
permissions | -rw-r--r-- |
65477 | 1 |
/* Title: Pure/ML/ml_console.scala |
62559 | 2 |
Author: Makarius |
3 |
||
62588
cd266473b81b
isabelle_process is superseded by "isabelle process" tool;
wenzelm
parents:
62586
diff
changeset
|
4 |
The raw ML process in interactive mode. |
62559 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
10 |
object ML_Console |
|
11 |
{ |
|
12 |
/* command line entry point */ |
|
13 |
||
14 |
def main(args: Array[String]) |
|
15 |
{ |
|
16 |
Command_Line.tool { |
|
17 |
var dirs: List[Path] = Nil |
|
68541 | 18 |
var include_sessions: List[String] = Nil |
62559 | 19 |
var logic = Isabelle_System.getenv("ISABELLE_LOGIC") |
20 |
var modes: List[String] = Nil |
|
21 |
var no_build = false |
|
22 |
var options = Options.init() |
|
62643 | 23 |
var raw_ml_system = false |
62559 | 24 |
|
25 |
val getopts = Getopts(""" |
|
26 |
Usage: isabelle console [OPTIONS] |
|
27 |
||
28 |
Options are: |
|
29 |
-d DIR include session directory |
|
68541 | 30 |
-i NAME include session in name-space of theories |
62559 | 31 |
-l NAME logic session name (default ISABELLE_LOGIC=""" + quote(logic) + """) |
32 |
-m MODE add print mode for output |
|
33 |
-n no build of session image on startup |
|
34 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
|
62643 | 35 |
-r bootstrap from raw Poly/ML |
62559 | 36 |
|
62588
cd266473b81b
isabelle_process is superseded by "isabelle process" tool;
wenzelm
parents:
62586
diff
changeset
|
37 |
Build a logic session image and run the raw Isabelle ML process |
cd266473b81b
isabelle_process is superseded by "isabelle process" tool;
wenzelm
parents:
62586
diff
changeset
|
38 |
in interactive mode, with line editor ISABELLE_LINE_EDITOR=""" + |
cd266473b81b
isabelle_process is superseded by "isabelle process" tool;
wenzelm
parents:
62586
diff
changeset
|
39 |
quote(Isabelle_System.getenv("ISABELLE_LINE_EDITOR")) + """. |
62559 | 40 |
""", |
41 |
"d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))), |
|
68541 | 42 |
"i:" -> (arg => include_sessions = include_sessions ::: List(arg)), |
62559 | 43 |
"l:" -> (arg => logic = arg), |
44 |
"m:" -> (arg => modes = arg :: modes), |
|
45 |
"n" -> (arg => no_build = true), |
|
46 |
"o:" -> (arg => options = options + arg), |
|
69854
cc0b3e177b49
system option "system_heaps" supersedes various command-line options for "system build mode";
wenzelm
parents:
68541
diff
changeset
|
47 |
"r" -> (_ => raw_ml_system = true)) |
62559 | 48 |
|
49 |
val more_args = getopts(args) |
|
71383 | 50 |
if (more_args.nonEmpty) getopts.usage() |
62559 | 51 |
|
52 |
||
71594 | 53 |
val sessions_structure = Sessions.load_structure(options, dirs = dirs) |
71598 | 54 |
val store = Sessions.store(options) |
71594 | 55 |
|
68305 | 56 |
// build logic |
57 |
if (!no_build && !raw_ml_system) { |
|
64115 | 58 |
val progress = new Console_Progress() |
68305 | 59 |
val rc = |
68331 | 60 |
progress.interrupt_handler { |
69854
cc0b3e177b49
system option "system_heaps" supersedes various command-line options for "system build mode";
wenzelm
parents:
68541
diff
changeset
|
61 |
Build.build_logic(options, logic, build_heap = true, progress = progress, dirs = dirs) |
68331 | 62 |
} |
68305 | 63 |
if (rc != 0) sys.exit(rc) |
62559 | 64 |
} |
65 |
||
66 |
// process loop |
|
67 |
val process = |
|
71598 | 68 |
ML_Process(options, sessions_structure, store, |
69 |
logic = logic, args = List("-i"), redirect = true, |
|
62643 | 70 |
modes = if (raw_ml_system) Nil else modes ::: List("ASCII"), |
68209 | 71 |
raw_ml_system = raw_ml_system, |
65431
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
wenzelm
parents:
64598
diff
changeset
|
72 |
session_base = |
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
wenzelm
parents:
64598
diff
changeset
|
73 |
if (raw_ml_system) None |
68541 | 74 |
else Some(Sessions.base_info( |
75 |
options, logic, dirs = dirs, include_sessions = include_sessions).check_base)) |
|
67802 | 76 |
|
71713 | 77 |
POSIX_Interrupt.handler { process.interrupt } { |
78 |
new TTY_Loop(process.stdin, process.stdout).join |
|
62559 | 79 |
val rc = process.join |
71713 | 80 |
if (rc != 0) sys.exit(rc) |
62559 | 81 |
} |
82 |
} |
|
83 |
} |
|
84 |
} |