author | wenzelm |
Sat, 13 Feb 2016 20:41:56 +0100 | |
changeset 62296 | b04a5ddd6121 |
parent 60991 | 2fc5a44346b5 |
child 62299 | 9e95a4afb8c3 |
permissions | -rw-r--r-- |
43283 | 1 |
/* Title: Pure/System/isabelle_process.scala |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
3 |
|
57916 | 4 |
Isabelle process wrapper. |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
5 |
*/ |
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
6 |
|
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
8 |
|
55618 | 9 |
|
57917 | 10 |
object Isabelle_Process |
11 |
{ |
|
12 |
def apply( |
|
13 |
receiver: Prover.Message => Unit = Console.println(_), |
|
62296 | 14 |
prover_args: String = ""): Isabelle_Process = |
57917 | 15 |
{ |
16 |
val system_channel = System_Channel() |
|
17 |
val system_process = |
|
57916 | 18 |
try { |
62296 | 19 |
val script = |
20 |
"\"$ISABELLE_PROCESS\" " + system_channel.prover_options + |
|
21 |
(if (prover_args == "") "" else " " + prover_args) |
|
22 |
val process = Bash.process(null, null, false, "-c", script) |
|
57916 | 23 |
process.stdin.close |
24 |
process |
|
25 |
} |
|
60215 | 26 |
catch { case exn @ ERROR(_) => system_channel.accepted(); throw exn } |
57917 | 27 |
|
28 |
new Isabelle_Process(receiver, system_channel, system_process) |
|
29 |
} |
|
57916 | 30 |
} |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
31 |
|
57917 | 32 |
class Isabelle_Process private( |
33 |
receiver: Prover.Message => Unit, |
|
34 |
system_channel: System_Channel, |
|
35 |
system_process: Prover.System_Process) |
|
36 |
extends Prover(receiver, system_channel, system_process) |
|
37 |
{ |
|
38 |
def encode(s: String): String = Symbol.encode(s) |
|
39 |
def decode(s: String): String = Symbol.decode(s) |
|
40 |
} |
|
41 |