author | wenzelm |
Tue, 20 Jan 2009 22:55:45 +0100 | |
changeset 34495 | 722533c532da |
parent 34491 | 20e9d420dbbb |
child 34497 | 184fda8cce04 |
child 34510 | 6106e71c6ee5 |
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 |
|
34486 | 14 |
import scala.collection.mutable.ListBuffer |
15 |
||
34491 | 16 |
import isabelle.proofdocument.{Text, Token, ProofDocument} |
34451 | 17 |
import isabelle.jedit.{Isabelle, Plugin} |
34476 | 18 |
import isabelle.XML |
34451 | 19 |
|
20 |
import sidekick.{SideKickParsedData, IAsset} |
|
21 |
||
22 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
23 |
object Command { |
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
24 |
object Status extends Enumeration { |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
25 |
val UNPROCESSED = Value("UNPROCESSED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
26 |
val FINISHED = Value("FINISHED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
27 |
val REMOVE = Value("REMOVE") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
28 |
val REMOVED = Value("REMOVED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
29 |
val FAILED = Value("FAILED") |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
30 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
31 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
32 |
|
34451 | 33 |
|
34491 | 34 |
class Command(text: Text, val first: Token, val last: Token) |
34451 | 35 |
{ |
36 |
val id = Isabelle.plugin.id() |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
37 |
|
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
38 |
{ |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
39 |
var t = first |
34451 | 40 |
while (t != null) { |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
41 |
t.command = this |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
42 |
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
|
43 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
44 |
} |
34451 | 45 |
|
34399
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
46 |
|
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
47 |
/* command status */ |
34451 | 48 |
|
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
49 |
private var _status = Command.Status.UNPROCESSED |
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
50 |
def status = _status |
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
51 |
def status_=(st: Command.Status.Value) = { |
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
52 |
if (st == Command.Status.UNPROCESSED) { |
34451 | 53 |
// delete markup |
54 |
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
|
55 |
child.children = Nil |
34399
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
56 |
} |
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
57 |
} |
34458
e2aa32bb73c0
- renamed Command.Phase to Command.Status (cf. src/Pure/Isar/isar.ML);
wenzelm
parents:
34451
diff
changeset
|
58 |
_status = st |
34399
5b8b89b7e597
interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents:
34398
diff
changeset
|
59 |
} |
34451 | 60 |
|
34391 | 61 |
|
34451 | 62 |
/* accumulated results */ |
63 |
||
34486 | 64 |
private val results = new ListBuffer[XML.Tree] |
65 |
def add_result(tree: XML.Tree) { results += tree } |
|
34451 | 66 |
|
34486 | 67 |
def result_document = XML.document( |
68 |
results.toList match { |
|
34410 | 69 |
case Nil => XML.Elem("message", Nil, Nil) |
70 |
case List(elem) => elem |
|
34486 | 71 |
case elems => XML.Elem("messages", Nil, List(elems.first, elems.last)) // FIXME all elems!? |
34410 | 72 |
}, "style") |
34451 | 73 |
|
34393 | 74 |
|
34451 | 75 |
/* content */ |
34391 | 76 |
|
34495 | 77 |
override def toString = name |
78 |
||
79 |
val name = text.content(first.start, first.stop) |
|
34491 | 80 |
val content = text.content(proper_start, proper_stop) |
34396
de809360c51d
command property: offset relative to start of command
immler@in.tum.de
parents:
34394
diff
changeset
|
81 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
82 |
def next = if (last.next != null) last.next.command else null |
34483 | 83 |
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
|
84 |
|
34451 | 85 |
def start = first.start |
86 |
def stop = last.stop |
|
87 |
||
88 |
def proper_start = start |
|
89 |
def proper_stop = { |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
90 |
var i = last |
34484
920ff05ca3f3
eliminated explicit method equals, which is always behind == / != anyway in Scala;
wenzelm
parents:
34483
diff
changeset
|
91 |
while (i != first && i.kind == Token.Kind.COMMENT) |
34483 | 92 |
i = i.prev |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
93 |
i.stop |
34451 | 94 |
} |
95 |
||
96 |
||
97 |
/* markup tree */ |
|
98 |
||
99 |
val root_node = |
|
34491 | 100 |
new MarkupNode(this, 0, stop - start, id, Markup.COMMAND_SPAN, content) |
34451 | 101 |
|
102 |
def node_from(kind: String, begin: Int, end: Int) = { |
|
103 |
val markup_content = /*content.substring(begin, end)*/ "" |
|
104 |
new MarkupNode(this, begin, end, id, kind, markup_content) |
|
105 |
} |
|
106 |
} |