merged
authorwenzelm
Mon, 11 Jan 2010 10:55:43 +0100
changeset 34310 a3d66403f9c9
parent 34309 d91c3fce478e (current diff)
parent 34304 b32c68328d24 (diff)
child 34311 f0a6f02ad705
child 34872 6ca970cfa873
merged
--- a/src/Pure/General/linear_set.scala	Sun Jan 10 18:14:29 2010 +0100
+++ b/src/Pure/General/linear_set.scala	Mon Jan 11 10:55:43 2010 +0100
@@ -118,18 +118,26 @@
   override def isEmpty: Boolean = !rep.first.isDefined
   def size: Int = if (isEmpty) 0 else rep.nexts.size + 1
 
-  def elements = new Iterator[A] {
-    private var next_elem = rep.first
+  def contains(elem: A): Boolean =
+    !isEmpty && (rep.last.get == elem || rep.nexts.isDefinedAt(elem))
+
+  private def elements_from(start: Option[A]): Iterator[A] = new Iterator[A] {
+    private var next_elem = start
     def hasNext = next_elem.isDefined
-    def next = {
-      val elem = next_elem.get
-      next_elem = rep.nexts.get(elem)
-      elem
-    }
+    def next =
+      next_elem match {
+        case Some(elem) =>
+          next_elem = rep.nexts.get(elem)
+          elem
+        case None => throw new NoSuchElementException("next on empty iterator")
+      }
   }
 
-  def contains(elem: A): Boolean =
-    !isEmpty && (rep.last.get == elem || rep.nexts.isDefinedAt(elem))
+  def elements: Iterator[A] = elements_from(rep.first)
+
+  def elements(elem: A): Iterator[A] =
+    if (contains(elem)) elements_from(Some(elem))
+    else throw new Linear_Set.Undefined(elem.toString)
 
   def + (elem: A): Linear_Set[A] = insert_after(rep.last, elem)
 
--- a/src/Pure/General/scan.scala	Sun Jan 10 18:14:29 2010 +0100
+++ b/src/Pure/General/scan.scala	Mon Jan 11 10:55:43 2010 +0100
@@ -108,6 +108,7 @@
     def ++ (elems: Iterator[String]): Lexicon = (this /: elems) ((s, elem) => s + elem)
 
 
+
     /** RegexParsers methods **/
 
     override val whiteSpace = "".r
--- a/src/Pure/Thy/text_edit.scala	Sun Jan 10 18:14:29 2010 +0100
+++ b/src/Pure/Thy/text_edit.scala	Mon Jan 11 10:55:43 2010 +0100
@@ -11,8 +11,10 @@
 sealed abstract class Text_Edit
 {
   val start: Int
+  def text: String
   def after(offset: Int): Int
   def before(offset: Int): Int
+  def can_edit(string_length: Int, shift: Int): Boolean
   def edit(string: String, shift: Int): (Option[Text_Edit], String)
 }
 
--- a/src/Pure/Thy/thy_syntax.scala	Sun Jan 10 18:14:29 2010 +0100
+++ b/src/Pure/Thy/thy_syntax.scala	Mon Jan 11 10:55:43 2010 +0100
@@ -7,7 +7,7 @@
 package isabelle
 
 
-class Thy_Syntax
+object Thy_Syntax
 {
   private val parser = new Outer_Parse.Parser
   {