author | wenzelm |
Mon, 19 Jan 2009 23:29:44 +0100 | |
changeset 34485 | 6475bfb4ff99 |
parent 34484 | 920ff05ca3f3 |
child 34486 | 7985efd78aa1 |
permissions | -rw-r--r-- |
34407 | 1 |
/* |
2 |
* Prover commands with semantic state |
|
3 |
* |
|
4 |
* @author Johannes Hölzl, TU Munich |
|
5 |
* @author Fabian Immler, TU Munich |
|
6 |
*/ |
|
7 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle.prover |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
|
34451 | 10 |
|
34393 | 11 |
import javax.swing.text.Position |
12 |
import javax.swing.tree.DefaultMutableTreeNode |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
13 |
|
34485 | 14 |
import isabelle.proofdocument.{Token, ProofDocument} |
34451 | 15 |
import isabelle.jedit.{Isabelle, Plugin} |
34476 | 16 |
import isabelle.XML |
34451 | 17 |
|
18 |
import sidekick.{SideKickParsedData, IAsset} |
|
19 |
||
20 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
21 |
object Command { |
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
22 |
object Status extends Enumeration { |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
23 |
val UNPROCESSED = Value("UNPROCESSED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
24 |
val FINISHED = Value("FINISHED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
25 |
val REMOVE = Value("REMOVE") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
26 |
val REMOVED = Value("REMOVED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
27 |
val FAILED = Value("FAILED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
28 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
29 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
30 |
|
34451 | 31 |
|
34485 | 32 |
class Command(val document: ProofDocument, val first: Token, val last: Token) |
34451 | 33 |
{ |
34 |
val id = Isabelle.plugin.id() |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
35 |
|
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
36 |
{ |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
37 |
var t = first |
34451 | 38 |
while (t != null) { |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
39 |
t.command = this |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
40 |
t = if (t == last) null else t.next |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
41 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
42 |
} |
34451 | 43 |
|
34399
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
44 |
|
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
45 |
/* command status */ |
34451 | 46 |
|
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
47 |
private var _status = Command.Status.UNPROCESSED |
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
48 |
def status = _status |
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
49 |
def status_=(st: Command.Status.Value) = { |
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
50 |
if (st == Command.Status.UNPROCESSED) { |
34451 | 51 |
// delete markup |
52 |
for (child <- root_node.children) { |
|
34401
44241a37b74a
structure of markup-tree in scala, keep track of swing-nodes in background
immler@in.tum.de
parents:
34400
diff
changeset
|
53 |
child.children = Nil |
34399
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
54 |
} |
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
55 |
} |
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
56 |
_status = st |
34399
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
57 |
} |
34451 | 58 |
|
34391 | 59 |
|
34451 | 60 |
/* accumulated results */ |
61 |
||
62 |
var results: List[XML.Tree] = Nil |
|
63 |
||
34410 | 64 |
def results_xml = XML.document( |
65 |
results match { |
|
66 |
case Nil => XML.Elem("message", Nil, Nil) |
|
67 |
case List(elem) => elem |
|
34451 | 68 |
case _ => XML.Elem("messages", Nil, List(results.first, results.last)) |
34410 | 69 |
}, "style") |
34451 | 70 |
def add_result(tree: XML.Tree) { |
34410 | 71 |
results = results ::: List(tree) // FIXME canonical reverse order |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
72 |
} |
34451 | 73 |
|
34393 | 74 |
|
34451 | 75 |
/* content */ |
34391 | 76 |
|
34451 | 77 |
def content(): String = document.getContent(this) |
34396
de809360c51d
command property: offset relative to start of command
immler@in.tum.de
parents:
34394
diff
changeset
|
78 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
79 |
def next = if (last.next != null) last.next.command else null |
34483 | 80 |
def prev = if (first.prev != null) first.prev.command else null |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
81 |
|
34451 | 82 |
def start = first.start |
83 |
def stop = last.stop |
|
84 |
||
85 |
def proper_start = start |
|
86 |
def proper_stop = { |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
87 |
var i = last |
34484
920ff05ca3f3
eliminated explicit method equals, which is always behind == / != anyway in Scala;
wenzelm
parents:
34483
diff
changeset
|
88 |
while (i != first && i.kind == Token.Kind.COMMENT) |
34483 | 89 |
i = i.prev |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
90 |
i.stop |
34451 | 91 |
} |
92 |
||
93 |
||
94 |
/* markup tree */ |
|
95 |
||
96 |
val root_node = |
|
97 |
new MarkupNode(this, 0, stop - start, id, Markup.COMMAND_SPAN, content()) |
|
98 |
||
99 |
def node_from(kind: String, begin: Int, end: Int) = { |
|
100 |
val markup_content = /*content.substring(begin, end)*/ "" |
|
101 |
new MarkupNode(this, begin, end, id, kind, markup_content) |
|
102 |
} |
|
103 |
} |