author | wenzelm |
Tue, 29 Dec 2009 15:33:39 +0100 | |
changeset 34807 | d71ecec53c61 |
parent 34802 | 006331f2b128 |
child 34808 | e462572536e9 |
permissions | -rw-r--r-- |
34407 | 1 |
/* |
34485 | 2 |
* Document as list of commands, consisting of lists of tokens |
34407 | 3 |
* |
4 |
* @author Johannes Hölzl, TU Munich |
|
34532 | 5 |
* @author Fabian Immler, TU Munich |
34485 | 6 |
* @author Makarius |
34407 | 7 |
*/ |
8 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
package isabelle.proofdocument |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
10 |
|
34760 | 11 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
12 |
import java.util.regex.Pattern |
34703 | 13 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
14 |
|
34760 | 15 |
object Proof_Document |
34483 | 16 |
{ |
34582 | 17 |
// Be careful when changing this regex. Not only must it handle the |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
18 |
// spurious end of a token but also: |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
19 |
// Bug ID: 5050507 Pattern.matches throws StackOverflow Error |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
20 |
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507 |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
21 |
|
34483 | 22 |
val token_pattern = |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
23 |
Pattern.compile( |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
24 |
"\\{\\*([^*]|\\*[^}]|\\*\\z)*(\\z|\\*\\})|" + |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
25 |
"\\(\\*([^*]|\\*[^)]|\\*\\z)*(\\z|\\*\\))|" + |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
26 |
"(\\?'?|')[A-Za-z_0-9.]*|" + |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
27 |
"[A-Za-z_0-9.]+|" + |
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 |
"\"([^\\\\\"]?(\\\\(.|\\z))?)*+(\"|\\z)|" + |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
30 |
"`([^\\\\`]?(\\\\(.|\\z))?)*+(`|\\z)|" + |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
31 |
"[()\\[\\]{}:;]", Pattern.MULTILINE) |
34485 | 32 |
|
34778 | 33 |
def empty(id: String): Proof_Document = |
34 |
new Proof_Document(id, Linear_Set(), Map(), Linear_Set(), Map()) |
|
34660 | 35 |
|
36 |
type StructureChange = List[(Option[Command], Option[Command])] |
|
34778 | 37 |
} |
34538
20bfcca24658
Prover as actor managing ProofDocument-versions (removed EventBus structural_changes);
immler@in.tum.de
parents:
34532
diff
changeset
|
38 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
39 |
|
34760 | 40 |
class Proof_Document( |
34582 | 41 |
val id: String, |
34807 | 42 |
val tokens: Linear_Set[Token], // FIXME plain List, inside Command |
43 |
val token_start: Map[Token, Int], // FIXME eliminate |
|
34689 | 44 |
val commands: Linear_Set[Command], |
34778 | 45 |
var states: Map[Command, Command_State]) // FIXME immutable |
34483 | 46 |
{ |
34760 | 47 |
import Proof_Document.StructureChange |
34653 | 48 |
|
34582 | 49 |
def content = Token.string_from_tokens(Nil ++ tokens, token_start) |
34657 | 50 |
|
51 |
||
34693 | 52 |
|
34485 | 53 |
/** token view **/ |
54 |
||
34778 | 55 |
def text_changed(session: Session, change: Change): (Proof_Document, StructureChange) = |
34485 | 56 |
{ |
34760 | 57 |
def edit_doc(doc_chgs: (Proof_Document, StructureChange), edit: Edit) = { |
34660 | 58 |
val (doc, chgs) = doc_chgs |
34778 | 59 |
val (new_doc, chg) = doc.text_edit(session, edit, change.id) |
34660 | 60 |
(new_doc, chgs ++ chg) |
61 |
} |
|
34693 | 62 |
((this, Nil: StructureChange) /: change.edits)(edit_doc) |
34660 | 63 |
} |
64 |
||
34778 | 65 |
def text_edit(session: Session, e: Edit, id: String): (Proof_Document, StructureChange) = |
34660 | 66 |
{ |
67 |
case class TextChange(start: Int, added: String, removed: String) |
|
68 |
val change = e match { |
|
69 |
case Insert(s, a) => TextChange(s, a, "") |
|
70 |
case Remove(s, r) => TextChange(s, "", r) |
|
71 |
} |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
72 |
//indices of tokens |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
73 |
var start: Map[Token, Int] = token_start |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
74 |
def stop(t: Token) = start(t) + t.length |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
75 |
// split old token lists |
34582 | 76 |
val tokens = Nil ++ this.tokens |
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
77 |
val (begin, remaining) = tokens.span(stop(_) < change.start) |
34648 | 78 |
val (removed, end) = remaining.span(token_start(_) <= change.start + change.removed.length) |
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
79 |
// update indices |
34582 | 80 |
start = end.foldLeft(start)((s, t) => |
34648 | 81 |
s + (t -> (s(t) + change.added.length - change.removed.length))) |
34485 | 82 |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
83 |
val split_begin = removed.takeWhile(start(_) < change.start). |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
84 |
map (t => { |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
85 |
val split_tok = new Token(t.content.substring(0, change.start - start(t)), t.kind) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
86 |
start += (split_tok -> start(t)) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
87 |
split_tok |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
88 |
}) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
89 |
|
34648 | 90 |
val split_end = removed.dropWhile(stop(_) < change.start + change.removed.length). |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
91 |
map (t => { |
34582 | 92 |
val split_tok = |
34648 | 93 |
new Token(t.content.substring(change.start + change.removed.length - start(t)), t.kind) |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
94 |
start += (split_tok -> start(t)) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
95 |
split_tok |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
96 |
}) |
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
97 |
// update indices |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
98 |
start = removed.foldLeft (start) ((s, t) => s - t) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
99 |
start = split_end.foldLeft (start) ((s, t) => |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
100 |
s + (t -> (change.start + change.added.length))) |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
101 |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
102 |
val ins = new Token(change.added, Token.Kind.OTHER) |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
103 |
start += (ins -> change.start) |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
104 |
|
34582 | 105 |
var invalid_tokens = split_begin ::: ins :: split_end ::: end |
106 |
var new_tokens: List[Token] = Nil |
|
107 |
var old_suffix: List[Token] = Nil |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
108 |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
109 |
val match_start = invalid_tokens.firstOption.map(start(_)).getOrElse(0) |
34582 | 110 |
val matcher = |
34760 | 111 |
Proof_Document.token_pattern.matcher(Token.string_from_tokens(invalid_tokens, start)) |
34526 | 112 |
|
113 |
while (matcher.find() && invalid_tokens != Nil) { |
|
34485 | 114 |
val kind = |
34802 | 115 |
if (session.syntax().is_command(matcher.group)) |
34485 | 116 |
Token.Kind.COMMAND_START |
34494 | 117 |
else if (matcher.end - matcher.start > 2 && matcher.group.substring(0, 2) == "(*") |
34485 | 118 |
Token.Kind.COMMENT |
119 |
else |
|
120 |
Token.Kind.OTHER |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
121 |
val new_token = new Token(matcher.group, kind) |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34550
diff
changeset
|
122 |
start += (new_token -> (match_start + matcher.start)) |
34526 | 123 |
new_tokens ::= new_token |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
124 |
|
34660 | 125 |
invalid_tokens = invalid_tokens dropWhile (stop(_) < stop(new_token)) |
34526 | 126 |
invalid_tokens match { |
34582 | 127 |
case t :: ts => |
128 |
if (start(t) == start(new_token) && |
|
129 |
start(t) > change.start + change.added.length) { |
|
34597 | 130 |
old_suffix = t :: ts |
34592 | 131 |
new_tokens = new_tokens.tail |
34526 | 132 |
invalid_tokens = Nil |
133 |
} |
|
134 |
case _ => |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
135 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
136 |
} |
34526 | 137 |
val insert = new_tokens.reverse |
34544
56217d219e27
proofdocument-versions get id from changes
immler@in.tum.de
parents:
34541
diff
changeset
|
138 |
val new_token_list = begin ::: insert ::: old_suffix |
34778 | 139 |
token_changed(session, id, begin.lastOption, insert, |
34597 | 140 |
old_suffix.firstOption, new_token_list, start) |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
141 |
} |
34582 | 142 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
143 |
|
34485 | 144 |
/** command view **/ |
145 |
||
34582 | 146 |
private def token_changed( |
34778 | 147 |
session: Session, |
34582 | 148 |
new_id: String, |
149 |
before_change: Option[Token], |
|
150 |
inserted_tokens: List[Token], |
|
151 |
after_change: Option[Token], |
|
34597 | 152 |
new_tokens: List[Token], |
34660 | 153 |
new_token_start: Map[Token, Int]): |
34760 | 154 |
(Proof_Document, StructureChange) = |
34485 | 155 |
{ |
34689 | 156 |
val new_tokenset = Linear_Set[Token]() ++ new_tokens |
34593 | 157 |
val cmd_before_change = before_change match { |
158 |
case None => None |
|
159 |
case Some(bc) => |
|
160 |
val cmd_with_bc = commands.find(_.contains(bc)).get |
|
161 |
if (cmd_with_bc.tokens.last == bc) { |
|
162 |
if (new_tokenset.next(bc).map(_.is_start).getOrElse(true)) |
|
163 |
Some(cmd_with_bc) |
|
164 |
else commands.prev(cmd_with_bc) |
|
165 |
} |
|
166 |
else commands.prev(cmd_with_bc) |
|
167 |
} |
|
34544
56217d219e27
proofdocument-versions get id from changes
immler@in.tum.de
parents:
34541
diff
changeset
|
168 |
|
34593 | 169 |
val cmd_after_change = after_change match { |
170 |
case None => None |
|
171 |
case Some(ac) => |
|
172 |
val cmd_with_ac = commands.find(_.contains(ac)).get |
|
173 |
if (ac.is_start) |
|
174 |
Some(cmd_with_ac) |
|
175 |
else |
|
176 |
commands.next(cmd_with_ac) |
|
177 |
} |
|
34485 | 178 |
|
34593 | 179 |
val removed_commands = commands.dropWhile(Some(_) != cmd_before_change).drop(1). |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
180 |
takeWhile(Some(_) != cmd_after_change) |
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
181 |
|
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
182 |
// calculate inserted commands |
34526 | 183 |
def tokens_to_commands(tokens: List[Token]): List[Command]= { |
184 |
tokens match { |
|
185 |
case Nil => Nil |
|
34582 | 186 |
case t :: ts => |
187 |
val (cmd, rest) = |
|
188 |
ts.span(t => t.kind != Token.Kind.COMMAND_START && t.kind != Token.Kind.COMMENT) |
|
34778 | 189 |
new Command(session.create_id(), t :: cmd, new_token_start) :: tokens_to_commands(rest) |
34485 | 190 |
} |
191 |
} |
|
192 |
||
34593 | 193 |
val split_begin = |
194 |
if (before_change.isDefined) { |
|
195 |
val changed = |
|
196 |
if (cmd_before_change.isDefined) |
|
34595 | 197 |
new_tokens.dropWhile(_ != cmd_before_change.get.tokens.last).drop(1) |
34593 | 198 |
else new_tokenset |
199 |
if (changed.exists(_ == before_change.get)) |
|
34597 | 200 |
changed.takeWhile(_ != before_change.get).toList ::: |
201 |
List(before_change.get) |
|
34593 | 202 |
else Nil |
203 |
} else Nil |
|
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
204 |
|
34593 | 205 |
val split_end = |
34667 | 206 |
if (after_change.isDefined) { |
34595 | 207 |
val unchanged = new_tokens.dropWhile(_ != after_change.get) |
34667 | 208 |
if(cmd_after_change.isDefined) { |
209 |
if (unchanged.exists(_ == cmd_after_change.get.tokens.first)) |
|
210 |
unchanged.takeWhile(_ != cmd_after_change.get.tokens.first).toList |
|
211 |
else Nil |
|
212 |
} else { |
|
213 |
unchanged |
|
214 |
} |
|
34593 | 215 |
} else Nil |
216 |
||
34597 | 217 |
val rescan_begin = |
218 |
split_begin ::: |
|
219 |
before_change.map(bc => new_tokens.dropWhile(_ != bc).drop(1)).getOrElse(new_tokens) |
|
34582 | 220 |
val rescanning_tokens = |
34597 | 221 |
after_change.map(ac => rescan_begin.takeWhile(_ != ac)).getOrElse(rescan_begin) ::: |
222 |
split_end |
|
34593 | 223 |
val inserted_commands = tokens_to_commands(rescanning_tokens.toList) |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
224 |
|
34550
171c8c6e5707
prepared proofdocument for only needed changes
immler@in.tum.de
parents:
34544
diff
changeset
|
225 |
// build new document |
34739 | 226 |
val new_commandset = commands. |
227 |
delete_between(cmd_before_change, cmd_after_change). |
|
228 |
append_after(cmd_before_change, inserted_commands) |
|
229 |
||
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
230 |
|
34544
56217d219e27
proofdocument-versions get id from changes
immler@in.tum.de
parents:
34541
diff
changeset
|
231 |
val doc = |
34760 | 232 |
new Proof_Document(new_id, new_tokenset, new_token_start, new_commandset, |
34778 | 233 |
states -- removed_commands) |
34660 | 234 |
|
235 |
val removes = |
|
236 |
for (cmd <- removed_commands) yield (cmd_before_change -> None) |
|
237 |
val inserts = |
|
238 |
for (cmd <- inserted_commands) yield (doc.commands.prev(cmd) -> Some(cmd)) |
|
239 |
||
240 |
return (doc, removes.toList ++ inserts) |
|
34485 | 241 |
} |
34596 | 242 |
|
243 |
val commands_offsets = { |
|
244 |
var last_stop = 0 |
|
245 |
(for (c <- commands) yield { |
|
246 |
val r = c -> (last_stop,c.stop(this)) |
|
247 |
last_stop = c.stop(this) |
|
248 |
r |
|
249 |
}).toArray |
|
250 |
} |
|
251 |
||
34712
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
252 |
def command_at(pos: Int): Option[Command] = |
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
253 |
find_command(pos, 0, commands_offsets.length) |
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
254 |
|
34596 | 255 |
// use a binary search to find commands for a given offset |
34712
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
256 |
private def find_command(pos: Int, array_start: Int, array_stop: Int): Option[Command] = |
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
257 |
{ |
34596 | 258 |
val middle_index = (array_start + array_stop) / 2 |
34712
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
259 |
if (middle_index >= commands_offsets.length) return None |
34596 | 260 |
val (middle, (start, stop)) = commands_offsets(middle_index) |
261 |
// does middle contain pos? |
|
34712
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
262 |
if (start <= pos && pos < stop) |
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
263 |
Some(middle) |
34596 | 264 |
else if (start > pos) |
34712
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
265 |
find_command(pos, array_start, middle_index) |
34596 | 266 |
else if (stop <= pos) |
34712
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
267 |
find_command(pos, middle_index + 1, array_stop) |
4f0ee5ab0380
replaced find_command_at by command_at -- null-free, proper Option;
wenzelm
parents:
34703
diff
changeset
|
268 |
else error("impossible") |
34596 | 269 |
} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
270 |
} |