author | wenzelm |
Mon, 16 Jun 2008 17:54:50 +0200 | |
changeset 27236 | 80356567e7ad |
parent 25857 | cdbef6152dcc |
permissions | -rw-r--r-- |
25648 | 1 |
/* |
2 |
* $Id$ |
|
3 |
* |
|
4 |
* Simple demo for IsabelleProcess wrapper. |
|
5 |
* |
|
25655 | 6 |
* Example session with Beanshell: |
7 |
* |
|
8 |
* $ cd [ISABELLE_HOME]/lib/classes |
|
9 |
* $ javac isabelle/*.java |
|
25657 | 10 |
* |
25655 | 11 |
* $ bsh |
25657 | 12 |
* or |
13 |
* $ java -Disabelle.home=[ISABELLE_HOME] -jar bsh.jar |
|
25656 | 14 |
* % addClassPath("."); |
25657 | 15 |
* |
25655 | 16 |
* % import isabelle.*; |
17 |
* % isabelle = new IsabelleDemo("HOL"); |
|
18 |
* % isabelle.command("theory Test imports Main begin"); |
|
19 |
* % isabelle.command("lemma \"A --> A\""); |
|
20 |
* % isabelle.command(".."); |
|
21 |
* % isabelle.command("end"); |
|
22 |
* % isabelle.close(); |
|
23 |
* |
|
25648 | 24 |
*/ |
25 |
||
26 |
package isabelle; |
|
27 |
||
28 |
public class IsabelleDemo extends IsabelleProcess { |
|
29 |
public IsabelleDemo(String logic) throws IsabelleProcessException |
|
30 |
{ |
|
31 |
super(logic); |
|
25653 | 32 |
new Thread (new Runnable () { |
33 |
public void run() |
|
34 |
{ |
|
35 |
IsabelleProcess.Result result = null; |
|
25857
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
36 |
do { |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
37 |
try { |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
38 |
result = results.take(); |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
39 |
} catch (NullPointerException ex) { |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
40 |
result = null; |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
41 |
} catch (InterruptedException ex) { |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
42 |
result = null; |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
43 |
} |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
44 |
if (result != null) |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
45 |
System.err.println(result.toString()); |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
46 |
if (result.kind == IsabelleProcess.Result.Kind.EXIT) { |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
47 |
result = null; |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
48 |
} |
cdbef6152dcc
more robust console thread (cf. jedit plugin version);
wenzelm
parents:
25660
diff
changeset
|
49 |
} while (result != null); |
25653 | 50 |
System.err.println("Console thread terminated"); |
51 |
} |
|
52 |
}).start(); |
|
25648 | 53 |
} |
25660 | 54 |
|
55 |
public IsabelleDemo() throws IsabelleProcessException { |
|
56 |
this(null); |
|
57 |
} |
|
25648 | 58 |
} |