equal
deleted
inserted
replaced
3 |
3 |
4 Protocol message formats for interactive proof documents. |
4 Protocol message formats for interactive proof documents. |
5 */ |
5 */ |
6 |
6 |
7 package isabelle |
7 package isabelle |
|
8 |
|
9 import scala.collection.mutable |
|
10 import scala.annotation.tailrec |
8 |
11 |
9 |
12 |
10 object Protocol { |
13 object Protocol { |
11 /* markers for inlined messages */ |
14 /* markers for inlined messages */ |
12 |
15 |
249 } |
252 } |
250 |
253 |
251 |
254 |
252 /* sendback snippets */ |
255 /* sendback snippets */ |
253 |
256 |
254 def senback_snippets(body: XML.Body): List[(String, Properties.T)] = { |
257 def senback_snippets(xml: XML.Body): List[(String, Properties.T)] = { |
255 body match { |
258 var seen = Set.empty[(String, Properties.T)] |
256 case XML.Elem(Markup(Markup.SENDBACK, props), b) :: rest => |
259 val result = new mutable.ListBuffer[(String, Properties.T)] |
257 (XML.content(b), props) :: senback_snippets(rest) |
260 |
258 case XML.Elem(_, b) :: rest => senback_snippets(b ::: rest) |
261 @tailrec def traverse(body: XML.Body): Unit = |
259 case _ :: rest => senback_snippets(rest) |
262 body match { |
260 case Nil => Nil |
263 case XML.Elem(Markup(Markup.SENDBACK, props), body1) :: body2 => |
261 } |
264 val entry = (XML.content(body1), props) |
|
265 if (!seen(entry)) { |
|
266 seen += entry |
|
267 result += entry |
|
268 } |
|
269 traverse(body2) |
|
270 case XML.Wrapped_Elem(_, _, body1) :: body2 => traverse(body1 ::: body2) |
|
271 case XML.Elem(_, body1) :: body2 => traverse(body1 ::: body2) |
|
272 case XML.Text(_) :: body2 => traverse(body2) |
|
273 case Nil => |
|
274 } |
|
275 |
|
276 traverse(xml) |
|
277 result.toList |
262 } |
278 } |
263 |
279 |
264 |
280 |
265 /* breakpoints */ |
281 /* breakpoints */ |
266 |
282 |