author | immler@in.tum.de |
Mon, 27 Apr 2009 17:33:49 +0200 | |
changeset 34556 | 09a5984250a2 |
parent 34555 | 7c001369956a |
child 34557 | 647a2430d1cd |
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 |
|
34497 | 14 |
import scala.collection.mutable |
34486 | 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 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 |
|
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
32 |
class Command(val tokens: List[Token], val starts: Map[Token, Int]) |
34451 | 33 |
{ |
34 |
val id = Isabelle.plugin.id() |
|
34500
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
35 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
36 |
/* content */ |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
37 |
|
34495 | 38 |
override def toString = name |
39 |
||
34526 | 40 |
val name = tokens.head.content |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
41 |
val content:String = Token.string_from_tokens(tokens.takeWhile(_.kind != Token.Kind.COMMENT), starts) |
34451 | 42 |
|
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
43 |
def start(doc: ProofDocument) = doc.token_start(tokens.first) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
44 |
def stop(doc: ProofDocument) = doc.token_start(tokens.last) + tokens.last.length |
34451 | 45 |
|
34500
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
46 |
/* command status */ |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
47 |
|
34508 | 48 |
var state_id: IsarDocument.State_ID = null |
49 |
||
34500
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
50 |
private var _status = Command.Status.UNPROCESSED |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
51 |
def status = _status |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
52 |
def status_=(st: Command.Status.Value) { |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
53 |
if (st == Command.Status.UNPROCESSED) { |
34533
35308320713a
preliminary/failed attempt to use the new IsarDocument access model to the prover;
wenzelm
parents:
34508
diff
changeset
|
54 |
state_results.clear |
34500
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
55 |
// delete markup |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
56 |
for (child <- root_node.children) { |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
57 |
child.children = Nil |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
58 |
} |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
59 |
} |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
60 |
_status = st |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
61 |
} |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
62 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
63 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
64 |
/* results */ |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
65 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
66 |
private val results = new mutable.ListBuffer[XML.Tree] |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
67 |
private val state_results = new mutable.ListBuffer[XML.Tree] |
34533
35308320713a
preliminary/failed attempt to use the new IsarDocument access model to the prover;
wenzelm
parents:
34508
diff
changeset
|
68 |
def add_result(running: Boolean, tree: XML.Tree) = synchronized { |
34508 | 69 |
(if (running) state_results else results) += tree |
70 |
} |
|
34500
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
71 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
72 |
def result_document = XML.document( |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
73 |
results.toList ::: state_results.toList match { |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
74 |
case Nil => XML.Elem("message", Nil, Nil) |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
75 |
case List(elem) => elem |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
76 |
case elems => XML.Elem("messages", Nil, elems) |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
77 |
}, "style") |
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
78 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
79 |
|
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
80 |
/* markup */ |
34451 | 81 |
|
82 |
val root_node = |
|
34556 | 83 |
new MarkupNode(this, 0, starts(tokens.last) - starts(tokens.first) + tokens.last.length, id, content, Markup.COMMAND_SPAN) |
34451 | 84 |
|
34555
7c001369956a
included information on ML status messages in Sidekick's status-window
immler@in.tum.de
parents:
34554
diff
changeset
|
85 |
def add_markup(desc: String, begin: Int, end: Int) = { |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
86 |
val markup_content = if (end <= content.length) content.substring(begin, end) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
87 |
else { |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
88 |
System.err.println (root_node.stop, content, content.length, end) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
89 |
"wrong indices?" |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34539
diff
changeset
|
90 |
} |
34555
7c001369956a
included information on ML status messages in Sidekick's status-window
immler@in.tum.de
parents:
34554
diff
changeset
|
91 |
root_node insert new MarkupNode(this, begin, end, id, markup_content, desc) |
34451 | 92 |
} |
34556 | 93 |
|
94 |
// syntax highlighting |
|
95 |
val highlight_node = |
|
96 |
new MarkupNode(this, 0, starts(tokens.last) - starts(tokens.first) + tokens.last.length, id, content, Markup.COMMAND_SPAN) |
|
97 |
||
98 |
def add_highlight(kind: String, begin: Int, end: Int) = |
|
99 |
highlight_node insert new MarkupNode(this, begin, end, id, "", kind) |
|
100 |
||
34451 | 101 |
} |