diff options
Diffstat (limited to 'src')
37 files changed, 501 insertions, 480 deletions
diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala index 8aa10b44c4..0df92ec0ec 100644 --- a/src/library/scala/BigInt.scala +++ b/src/library/scala/BigInt.scala @@ -50,12 +50,12 @@ object BigInt { /** Translates a byte array containing the two's-complement binary * representation of a BigInt into a BigInt. */ - def apply(x: Array[byte]): BigInt = + def apply(x: Array[Byte]): BigInt = new BigInt(new BigInteger(x)) /** Translates the sign-magnitude representation of a BigInt into a BigInt. */ - def apply(signum: Int, magnitude: Array[byte]): BigInt = + def apply(signum: Int, magnitude: Array[Byte]): BigInt = new BigInt(new BigInteger(signum, magnitude)) /** Constructs a randomly generated positive BigInt that is probably prime, @@ -106,7 +106,7 @@ object BigInt { */ implicit def bigInt2ordered(x: BigInt): Ordered[BigInt] = new Ordered[BigInt] with Proxy { def self: Any = x; - def compare (y: BigInt): int = x.bigInteger.compareTo(y.bigInteger) + def compare (y: BigInt): Int = x.bigInteger.compareTo(y.bigInteger) } } @@ -122,7 +122,7 @@ class BigInt(val bigInteger: BigInteger) extends java.lang.Number { /** Compares this BigInt with the specified value for equality. */ - override def equals (that: Any): boolean = that match { + override def equals (that: Any): Boolean = that match { case that: BigInt => this equals that case that: java.lang.Double => this.bigInteger.doubleValue == that.doubleValue case that: java.lang.Float => this.bigInteger.floatValue == that.floatValue @@ -133,28 +133,28 @@ class BigInt(val bigInteger: BigInteger) extends java.lang.Number { /** Compares this BigInt with the specified BigInt for equality. */ - def equals (that: BigInt): boolean = + def equals (that: BigInt): Boolean = this.bigInteger.compareTo(that.bigInteger) == 0 /** Compares this BigInt with the specified BigInt */ - def compare (that: BigInt): int = this.bigInteger.compareTo(that.bigInteger) + def compare (that: BigInt): Int = this.bigInteger.compareTo(that.bigInteger) /** Less-than-or-equals comparison of BigInts */ - def <= (that: BigInt): boolean = this.bigInteger.compareTo(that.bigInteger) <= 0 + def <= (that: BigInt): Boolean = this.bigInteger.compareTo(that.bigInteger) <= 0 /** Greater-than-or-equals comparison of BigInts */ - def >= (that: BigInt): boolean = this.bigInteger.compareTo(that.bigInteger) >= 0 + def >= (that: BigInt): Boolean = this.bigInteger.compareTo(that.bigInteger) >= 0 /** Less-than of BigInts */ - def < (that: BigInt): boolean = this.bigInteger.compareTo(that.bigInteger) < 0 + def < (that: BigInt): Boolean = this.bigInteger.compareTo(that.bigInteger) < 0 /** Greater-than comparison of BigInts */ - def > (that: BigInt): boolean = this.bigInteger.compareTo(that.bigInteger) > 0 + def > (that: BigInt): Boolean = this.bigInteger.compareTo(that.bigInteger) > 0 /** Addition of BigInts */ @@ -276,17 +276,17 @@ class BigInt(val bigInteger: BigInteger) extends java.lang.Number { /** Returns the index of the rightmost (lowest-order) one bit in this BigInt * (the number of zero bits to the right of the rightmost one bit). */ - def lowestSetBit: int = this.bigInteger.getLowestSetBit() + def lowestSetBit: Int = this.bigInteger.getLowestSetBit() /** Returns the number of bits in the minimal two's-complement representation of this BigInt, * excluding a sign bit. */ - def bitLength: int = this.bigInteger.bitLength() + def bitLength: Int = this.bigInteger.bitLength() /** Returns the number of bits in the two's complement representation of this BigInt * that differ from its sign bit. */ - def bitCount: int = this.bigInteger.bitCount() + def bitCount: Int = this.bigInteger.bitCount() /** Returns true if this BigInt is probably prime, false if it's definitely composite. * @param certainty a measure of the uncertainty that the caller is willing to tolerate: diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala index 70f0b9516b..35c356f428 100644 --- a/src/library/scala/Iterator.scala +++ b/src/library/scala/Iterator.scala @@ -346,7 +346,7 @@ trait Iterator[+A] { * {a<sub>1</sub>,1}...</code> where <code>a<sub>i</sub></code> * are the elements from this iterator. */ - def zipWithIndex = new Iterator[(A, int)] { + def zipWithIndex = new Iterator[(A, Int)] { var idx = 0 def hasNext = Iterator.this.hasNext def next = { @@ -361,7 +361,7 @@ trait Iterator[+A] { * * @param f a function that is applied to every element. */ - def foreach(f: A => Unit): Unit = while (hasNext) f(next) + def foreach(f: A => Unit) { while (hasNext) f(next) } /** Apply a predicate <code>p</code> to all elements of this * iterable object and return <code>true</code> iff the predicate yields diff --git a/src/library/scala/PartiallyOrdered.scala b/src/library/scala/PartiallyOrdered.scala index b4c86fedd8..8531a8de00 100644 --- a/src/library/scala/PartiallyOrdered.scala +++ b/src/library/scala/PartiallyOrdered.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -16,7 +16,7 @@ package scala * @author Martin Odersky * @version 1.0, 23/04/2004 */ -trait PartiallyOrdered[+a] { +trait PartiallyOrdered[+A] { /** Result of comparing <code>this</code> with operand <code>that</code>. * Returns <code>None</code> if operands are not comparable. @@ -25,24 +25,24 @@ trait PartiallyOrdered[+a] { * <code>x == 0</code> iff <code>this == that</code> * <code>x > 0</code> iff <code>this > that</code> */ - def tryCompareTo [b >: a <% PartiallyOrdered[b]](that: b): Option[int] + def tryCompareTo [B >: A <% PartiallyOrdered[B]](that: B): Option[Int] - def < [b >: a <% PartiallyOrdered[b]](that: b): boolean = + def < [B >: A <% PartiallyOrdered[B]](that: B): Boolean = (this tryCompareTo that) match { case Some(x) if x < 0 => true case _ => false } - def > [b >: a <% PartiallyOrdered[b]](that: b): boolean = + def > [B >: A <% PartiallyOrdered[B]](that: B): Boolean = (this tryCompareTo that) match { case Some(x) if x > 0 => true case _ => false } - def <= [b >: a <% PartiallyOrdered[b]](that: b): boolean = + def <= [B >: A <% PartiallyOrdered[B]](that: B): Boolean = (this tryCompareTo that) match { case Some(x) if x <= 0 => true case _ => false } - def >= [b >: a <% PartiallyOrdered[b]](that: b): boolean = + def >= [B >: A <% PartiallyOrdered[B]](that: B): Boolean = (this tryCompareTo that) match { case Some(x) if x >= 0 => true case _ => false diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala index da9e215ed3..9aade29aa1 100644 --- a/src/library/scala/Responder.scala +++ b/src/library/scala/Responder.scala @@ -16,7 +16,6 @@ package scala * @version 1.0 * * @see class Responder - * @since revision 6897 (will be 2.1.1) */ object Responder { @@ -26,8 +25,8 @@ object Responder { * @param x ... * @return ... */ - def constant[a](x: a) = new Responder[a] { - def respond(k: a => unit) = k(x) + def constant[A](x: A) = new Responder[A] { + def respond(k: A => Unit) = k(x) } /** Executes <code>x</code> and returns <code>true</code>, useful @@ -36,20 +35,20 @@ object Responder { * @param x ... * @return ... */ - def exec[a](x: => unit): boolean = { x; true } + def exec[A](x: => Unit): Boolean = { x; true } /** runs a responder, returning an optional result */ - def run[a](r: Responder[a]): Option[a] = { - var result: Option[a] = None + def run[A](r: Responder[A]): Option[A] = { + var result: Option[A] = None r.foreach(x => result = Some(x)) result } - def loop[a](r: Responder[unit]): Responder[Nothing] = + def loop[A](r: Responder[Unit]): Responder[Nothing] = for (_ <- r; val y <- loop(r)) yield y - def loopWhile[a](cond: => boolean)(r: Responder[unit]): Responder[unit] = + def loopWhile[A](cond: => Boolean)(r: Responder[Unit]): Responder[Unit] = if (cond) for (_ <- r; val y <- loopWhile(cond)(r)) yield y else constant(()) @@ -63,28 +62,29 @@ object Responder { * * @author Burak Emir * @version 1.0 - * - * @since revision 6897 (will be 2.1.1) */ -abstract class Responder[+a] { +abstract class Responder[+A] { - def respond(k: a => unit): unit + def respond(k: A => Unit): Unit - def foreach(k: a => unit): unit = respond(k) + def foreach(k: A => Unit) { respond(k) } - def map[b](f: a => b) = new Responder[b] { - def respond(k: b => unit): unit = + def map[B](f: A => B) = new Responder[B] { + def respond(k: B => Unit) { Responder.this.respond(x => k(f(x))) + } } - def flatMap[b](f: a => Responder[b]) = new Responder[b] { - def respond(k: b => unit): unit = + def flatMap[B](f: A => Responder[B]) = new Responder[B] { + def respond(k: B => Unit) { Responder.this.respond(x => f(x).respond(k)) + } } - def filter(p: a => boolean) = new Responder[a] { - def respond(k: a => unit): unit = + def filter(p: A => Boolean) = new Responder[A] { + def respond(k: A => Unit) { Responder.this.respond(x => if (p(x)) k(x) else ()) + } } } diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 35aa93d579..c91f0c7a43 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -40,7 +40,7 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] { protected var later: HashMap[A, B] = null protected var oldKey: A = _ protected var oldValue: Option[B] = _ - protected var deltaSize: int = _ + protected var deltaSize: Int = _ def empty[C]: Map[A, C] = new EmptyMap[A, C] @@ -49,7 +49,7 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] { var cnt = 0 while (m.later != null) { if (key == m.oldKey) return m.oldValue - cnt = cnt + 1 + cnt += 1 m = m.later } if (cnt > logLimit) makeCopy(m) @@ -82,13 +82,13 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] { } } - override def size: int = synchronized { + override def size: Int = synchronized { var m = this var cnt = 0 var s = tableSize while (m.later != null) { s = s - m.deltaSize - cnt = cnt + 1 + cnt += 1 m = m.later } if (cnt > logLimit) makeCopy(m) @@ -103,9 +103,9 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] { private def getValue(e: Entry) = e.value.asInstanceOf[B] - private def logLimit: int = Math.sqrt(table.length.toDouble).toInt + private def logLimit: Int = Math.sqrt(table.length.toDouble).toInt - private def markUpdated(key: A, ov: Option[B], delta: int) { + private def markUpdated(key: A, ov: Option[B], delta: Int) { val lv = loadFactor later = new HashMap[A, B] { override def initialSize = 0 @@ -142,7 +142,7 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] { var i = 0 while (i < s) { table(i) = copy(ltable(i)) - i = i + 1 + i += 1 } tableSize = last.tableSize threshold = last.threshold diff --git a/src/library/scala/collection/immutable/RedBlack.scala b/src/library/scala/collection/immutable/RedBlack.scala index 6940aa32d9..d075aafe0c 100644 --- a/src/library/scala/collection/immutable/RedBlack.scala +++ b/src/library/scala/collection/immutable/RedBlack.scala @@ -12,19 +12,19 @@ package scala.collection.immutable @serializable abstract class RedBlack[A] { - def isSmaller(x: A, y: A): boolean + def isSmaller(x: A, y: A): Boolean private def blacken[B](t: Tree[B]): Tree[B] = t match { case RedTree(k, v, l, r) => BlackTree(k, v, l, r) case t => t } - private def mkTree[B](isBlack: boolean, k: A, v: B, l: Tree[B], r: Tree[B]) = + private def mkTree[B](isBlack: Boolean, k: A, v: B, l: Tree[B], r: Tree[B]) = if (isBlack) BlackTree(k, v, l, r) else RedTree(k, v, l, r) @serializable abstract class Tree[+B] { - def isEmpty: boolean - def isBlack: boolean + def isEmpty: Boolean + def isBlack: Boolean def lookup(x: A): Tree[B] def update[B1 >: B](k: A, v: B1): Tree[B1] = blacken(upd(k, v)) def delete(k: A): Tree[B] = del(k) @@ -52,7 +52,7 @@ abstract class RedBlack[A] { else if (isSmaller(key, k)) right.lookup(k) else this def upd[B1 >: B](k: A, v: B1): Tree[B1] = { - def balanceLeft(isBlack: boolean, z: A, zv: B, l: Tree[B1], d: Tree[B1]) = l match { + def balanceLeft(isBlack: Boolean, z: A, zv: B, l: Tree[B1], d: Tree[B1]) = l match { case RedTree(y, yv, RedTree(x, xv, a, b), c) => RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) case RedTree(x, xv, a, RedTree(y, yv, b, c)) => @@ -60,7 +60,7 @@ abstract class RedBlack[A] { case _ => mkTree(isBlack, z, zv, l, d) } - def balanceRight(isBlack: boolean, x: A, xv: B, a: Tree[B1], r: Tree[B1]) = r match { + def balanceRight(isBlack: Boolean, x: A, xv: B, a: Tree[B1], r: Tree[B1]) = r match { case RedTree(z, zv, RedTree(y, yv, b, c), d) => RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) case RedTree(y, yv, b, RedTree(z, zv, c, d)) => diff --git a/src/library/scala/collection/immutable/Tree.scala b/src/library/scala/collection/immutable/Tree.scala index d4b63b4e4f..1bf0c21d69 100644 --- a/src/library/scala/collection/immutable/Tree.scala +++ b/src/library/scala/collection/immutable/Tree.scala @@ -227,8 +227,8 @@ private case class ITree[A <% Ordered[A],B](t: GBTree[A,B]) * <a href="Tree.html" target="contentFrame"><code>Tree</code></a>. */ private case class INode[A <% Ordered[A],B](t1: GBTree[A,B], - height: int, - size: int) + height: Int, + size: Int) extends InsertTree[A,B] { def insertLeft(key: A, value: B, bigger: GBTree[A,B]) = balance_p(GBNode(key, value, t1, bigger), bigger); @@ -271,7 +271,7 @@ protected abstract class GBTree[A <% Ordered[A],B] extends AnyRef { def delete(key: A): aNode def merge(t: aNode): aNode def takeSmallest: (A,B,aNode) - def balance(s: int): GBTree[A,B] + def balance(s: Int): GBTree[A,B] } private case class GBLeaf[A <% Ordered[A],B]() extends GBTree[A,B] { @@ -292,7 +292,7 @@ private case class GBLeaf[A <% Ordered[A],B]() extends GBTree[A,B] { def takeSmallest: (A,B, GBTree[A,B]) = throw new NoSuchElementException("takeSmallest on empty tree") def delete(_key: A) = throw new NoSuchElementException("Delete on empty tree.") - def balance(s: int) = this + def balance(s: Int) = this override def hashCode() = 0 } @@ -334,7 +334,7 @@ private case class GBNode[A <% Ordered[A],B](key: A, else GBNode(newKey, newValue, smaller, bigger) - def insert(newKey: A, newValue: B, s: int): anInsertTree = { + def insert(newKey: A, newValue: B, s: Int): anInsertTree = { if (newKey < key) smaller.insert(newKey, newValue, s / 2).insertLeft(key, value, bigger) else if (newKey > key) @@ -378,10 +378,10 @@ private case class GBNode[A <% Ordered[A],B](key: A, * @param s ... * @return ... */ - def balance(s: int): GBTree[A,B] = + def balance(s: Int): GBTree[A,B] = balance_list(toList(scala.Nil), s) - protected def balance_list(list: List[(A,B)], s: int): GBTree[A,B] = { + protected def balance_list(list: List[(A,B)], s: Int): GBTree[A,B] = { val empty = GBLeaf[A,B](); def bal(list: List[(A,B)], s: Int): (aNode, List[(A,B)]) = { if (s > 1) { diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala index 0b0bb6a9a4..be9e57c5b9 100644 --- a/src/library/scala/collection/immutable/TreeMap.scala +++ b/src/library/scala/collection/immutable/TreeMap.scala @@ -37,7 +37,7 @@ object TreeMap { * @version 1.1, 03/05/2004 */ @serializable -class TreeMap[A <% Ordered[A], +B](val size: int, t: RedBlack[A]#Tree[B]) +class TreeMap[A <% Ordered[A], +B](val size: Int, t: RedBlack[A]#Tree[B]) extends RedBlack[A] with SortedMap[A, B] { def isSmaller(x: A, y: A) = x < y @@ -57,7 +57,7 @@ extends RedBlack[A] with SortedMap[A, B] { - private def newMap[B](s: int, t: RedBlack[A]#Tree[B]) = new TreeMap[A, B](s, t) + private def newMap[B](s: Int, t: RedBlack[A]#Tree[B]) = new TreeMap[A, B](s, t) /** A factory to create empty maps of the same type of keys. */ diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala index 4873426f38..8236a06bfd 100644 --- a/src/library/scala/collection/immutable/TreeSet.scala +++ b/src/library/scala/collection/immutable/TreeSet.scala @@ -37,7 +37,7 @@ object TreeSet { */ @serializable -class TreeSet[A <% Ordered[A]](val size: int, t: RedBlack[A]#Tree[Unit]) +class TreeSet[A <% Ordered[A]](val size: Int, t: RedBlack[A]#Tree[Unit]) extends RedBlack[A] with SortedSet[A] { def isSmaller(x: A, y: A) = x < y @@ -46,7 +46,7 @@ class TreeSet[A <% Ordered[A]](val size: int, t: RedBlack[A]#Tree[Unit]) protected val tree: RedBlack[A]#Tree[Unit] = if (size == 0) Empty else t - private def newSet(s: int, t: RedBlack[A]#Tree[Unit]) = new TreeSet[A](s, t) + private def newSet(s: Int, t: RedBlack[A]#Tree[Unit]) = new TreeSet[A](s, t) /** A factory to create empty maps of the same type of keys. */ @@ -87,22 +87,25 @@ class TreeSet[A <% Ordered[A]](val size: int, t: RedBlack[A]#Tree[Unit]) def elementsSlow = tree.elementsSlow map (_._1) - override def foreach(f : A => Unit) : Unit = - tree.visit[Unit](())((unit0,y,unit1) => Tuple2(true, f(y))) - override def forall(f : A => Boolean) : Boolean = - tree.visit[Boolean](true)((input,a,unit) => f(a) match { - case ret if input => Tuple2(ret,ret) + override def foreach(f: A => Unit) { + tree.visit[Unit](())((unit0, y, unit1) => Tuple2(true, f(y))) + } + + override def forall(f: A => Boolean): Boolean = + tree.visit[Boolean](true)((input, a, unit) => f(a) match { + case ret if input => Tuple2(ret, ret) })._2 - override def exists(f : A => Boolean) : Boolean = - tree.visit[Boolean](false)((input,a,unit) => f(a) match { - case ret if !input => Tuple2(!ret,ret) + + override def exists(f: A => Boolean): Boolean = + tree.visit[Boolean](false)((input, a, unit) => f(a) match { + case ret if !input => Tuple2(!ret, ret) })._2 - override def rangeImpl(from: Option[A], until: Option[A]) : TreeSet[A] = { - val tree = this.tree.range(from,until) + override def rangeImpl(from: Option[A], until: Option[A]): TreeSet[A] = { + val tree = this.tree.range(from, until) newSet(tree.count, tree) } override def firstKey = tree.first override def lastKey = tree.last - override def compare(a0 : A, a1 : A) = a0.compare(a1) + override def compare(a0: A, a1: A) = a0.compare(a1) } diff --git a/src/library/scala/collection/immutable/UnbalancedTreeMap.scala b/src/library/scala/collection/immutable/UnbalancedTreeMap.scala index 433ff899c0..40a3b7f535 100644 --- a/src/library/scala/collection/immutable/UnbalancedTreeMap.scala +++ b/src/library/scala/collection/immutable/UnbalancedTreeMap.scala @@ -38,7 +38,7 @@ class UnbalancedTreeMap[A <% Ordered[A], +B] extends Map[A, B] { def size: Int = 0 - override def isEmpty: boolean = true + override def isEmpty: Boolean = true protected def add [B1 >: B](key: A, value: B1) = new Node(key, value, this, this) protected def findValue (key: A): UnbalancedTreeMap[A, B] = this @@ -55,12 +55,12 @@ class UnbalancedTreeMap[A <% Ordered[A], +B] extends Map[A, B] { * @param value ... * @return ... */ - def update [B1 >: B](key: A, value: B1) = add(key, value) + def update[B1 >: B](key: A, value: B1) = add(key, value) /** A new TreeMap with the entry added is returned, * assuming that key is <em>not</em> in the TreeMap. */ - def insert [B1 >: B](key: A, value: B1) = add(key, value) + def insert[B1 >: B](key: A, value: B1) = add(key, value) def - (key:A): UnbalancedTreeMap[A, B] = this diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala index 0b6077492f..7a7a765e86 100644 --- a/src/library/scala/collection/mutable/ArrayBuffer.scala +++ b/src/library/scala/collection/mutable/ArrayBuffer.scala @@ -27,10 +27,10 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { * * @param elem the element to append. */ - def +=(elem: A): Unit = { - ensureSize(size0+1) + def +=(elem: A) { + ensureSize(size0 + 1) array(size0) = elem - size0 = size0 + 1 + size0 += 1 } /** Appends a number of elements provided by an iterable object @@ -40,7 +40,7 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { * @param iter the iterable object. * @return the updated buffer. */ - override def ++=(iter: Iterable[A]): Unit = iter copyToBuffer this + override def ++=(iter: Iterable[A]) { iter copyToBuffer this } /** Appends a number of elements in an array * @@ -48,10 +48,10 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { * @param start the first element to append * @param len the number of elements to append */ - override def ++=(src: Array[A], start: int, len: int): Unit = { + override def ++=(src: Array[A], start: Int, len: Int) { ensureSize(size0 + len) Array.copy(src, start, array, size0, len) - size0 = size0 + len + size0 += len } /** Prepends a single element to this buffer and return @@ -61,10 +61,10 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { * @return the updated buffer. */ def +:(elem: A): Buffer[A] = { - ensureSize(size0+1) + ensureSize(size0 + 1) copy(0, 1, size0) array(0) = elem - size0 = size0 + 1 + size0 += 1 this } @@ -98,15 +98,15 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { * @param iter the iterable object providing all elements to insert. * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds. */ - def insertAll(n: Int, iter: Iterable[A]): Unit = { + def insertAll(n: Int, iter: Iterable[A]) { if ((n < 0) || (n > size0)) throw new IndexOutOfBoundsException("cannot insert element at " + n); val xs = iter.elements.toList val len = xs.length - ensureSize(size0+len) + ensureSize(size0 + len) copy(n, n + len, size0 - n) xs.copyToArray(array, n) - size0 = size0 + len + size0 += len } /** Replace element at index <code>n</code> with the new element @@ -116,9 +116,9 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { * @param newelem the new element. * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds. */ - def update(n: Int, newelem: A): Unit = { + def update(n: Int, newelem: A) { if ((n < 0) || (n >= size0)) - throw new IndexOutOfBoundsException("cannot update element at " + n); + throw new IndexOutOfBoundsException("cannot update element at " + n) else { val res = array(n) array(n) = newelem @@ -135,15 +135,15 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { def remove(n: Int): A = { if ((n < 0) || (n >= size0)) throw new IndexOutOfBoundsException("cannot remove element at " + n); - val res = array(n); - copy(n + 1, n, size0 - n - 1); - size0 = size0 - 1; + val res = array(n) + copy(n + 1, n, size0 - n - 1) + size0 -= 1 res } /** Clears the buffer contents. */ - def clear(): Unit = { + def clear() { size0 = 0 } diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala index af64e7783c..ee7091ff20 100644 --- a/src/library/scala/collection/mutable/Buffer.scala +++ b/src/library/scala/collection/mutable/Buffer.scala @@ -52,14 +52,14 @@ trait Buffer[A] extends AnyRef * * @param iter the iterator. */ - def ++=(iter: Iterator[A]): Unit = iter foreach += + def ++=(iter: Iterator[A]) { iter foreach += } /** Appends a number of elements provided by an iterable object * via its <code>elements</code> method. * * @param iter the iterable object. */ - def ++=(iter: Iterable[A]): Unit = ++=(iter.elements) + def ++=(iter: Iterable[A]) { ++=(iter.elements) } /** Appends a number of elements in an array * @@ -67,12 +67,12 @@ trait Buffer[A] extends AnyRef * @param start the first element to append * @param len the number of elements to append */ - def ++=(src: Array[A], start: int, len: int): Unit = { + def ++=(src: Array[A], start: Int, len: Int) { var i = start val end = i + len while (i < end) { this += src(i) - i = i + 1 + i += 1 } } @@ -110,7 +110,7 @@ trait Buffer[A] extends AnyRef * * @param x the element to remove. */ - def -= (x: A): Unit = { + def -= (x: A) { val i = indexOf(x) if(i != -1) remove(i) } @@ -119,20 +119,20 @@ trait Buffer[A] extends AnyRef * * @param elems the elements to append. */ - def append(elems: A*): Unit = this ++= elems + def append(elems: A*) { this ++= elems } /** Appends a number of elements provided by an iterable object * via its <code>elements</code> method. * * @param iter the iterable object. */ - def appendAll(iter: Iterable[A]): Unit = this ++= iter + def appendAll(iter: Iterable[A]) { this ++= iter } /** Prepend an element to this list. * * @param elem the element to prepend. */ - def prepend(elems: A*): Unit = elems ++: this + def prepend(elems: A*) { elems ++: this } /** Prepends a number of elements provided by an iterable object * via its <code>elements</code> method. The identity of the @@ -140,7 +140,7 @@ trait Buffer[A] extends AnyRef * * @param iter the iterable object. */ - def prependAll(iter: Iterable[A]): Unit = iter ++: this + def prependAll(iter: Iterable[A]) { iter ++: this } /** Inserts new elements at the index <code>n</code>. Opposed to method * <code>update</code>, this method will not replace an element with a @@ -149,7 +149,7 @@ trait Buffer[A] extends AnyRef * @param n the index where a new element will be inserted. * @param elems the new elements to insert. */ - def insert(n: Int, elems: A*): Unit = insertAll(n, elems) + def insert(n: Int, elems: A*) { insertAll(n, elems) } /** Inserts new elements at the index <code>n</code>. Opposed to method * <code>update</code>, this method will not replace an element with a @@ -179,9 +179,9 @@ trait Buffer[A] extends AnyRef * @param n the number of elements to remove from the beginning * of this buffer. */ - def trimStart(n: Int): Unit = { + def trimStart(n: Int) { var i = n - while (i > 0) { remove(0); i = i - 1 } + while (i > 0) { remove(0); i -= 1 } } /** Removes the last <code>n</code> elements. @@ -189,9 +189,9 @@ trait Buffer[A] extends AnyRef * @param n the number of elements to remove from the end * of this buffer. */ - def trimEnd(n: Int): Unit = { + def trimEnd(n: Int) { var i = n - while (i > 0) { remove(length - 1); i = i - 1 } + while (i > 0) { remove(length - 1); i -= 1 } } /** Clears the buffer contents. @@ -202,28 +202,30 @@ trait Buffer[A] extends AnyRef * * @param cmd the message to send. */ - def <<(cmd: Message[(Location, A)]): Unit = cmd match { - case Include((l, elem)) => l match { - case Start => prepend(elem) - case End => append(elem) - case Index(n) => insert(n, elem) + def <<(cmd: Message[(Location, A)]) { + cmd match { + case Include((l, elem)) => l match { + case Start => prepend(elem) + case End => append(elem) + case Index(n) => insert(n, elem) + case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") + } + case Update((l, elem)) => l match { + case Start => update(0, elem) + case End => update(length - 1, elem) + case Index(n) => update(n, elem) + case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") + } + case Remove((l, _)) => l match { + case Start => remove(0) + case End => remove(length - 1) + case Index(n) => remove(n) + case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") + } + case Reset() => clear + case s: Script[_] => s.elements foreach << case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") } - case Update((l, elem)) => l match { - case Start => update(0, elem) - case End => update(length - 1, elem) - case Index(n) => update(n, elem) - case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") - } - case Remove((l, _)) => l match { - case Start => remove(0) - case End => remove(length - 1) - case Index(n) => remove(n) - case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") - } - case Reset() => clear - case s: Script[_] => s.elements foreach << - case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") } /** Return a clone of this buffer. diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 4cf1e8f5aa..80150e6e47 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -1,8 +1,12 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL - * @author Martin Odersky - */ -// $Id: HashSet.scala 9235 2006-11-13 14:59:18 +0000 (Mon, 13 Nov 2006) mihaylov $ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ package scala.collection.mutable @@ -72,7 +76,7 @@ trait FlatHashTable[A] { def removeEntry(elem: A) { if (tableDebug) checkConsistent() - def precedes(i: int, j: int) = { + def precedes(i: Int, j: Int) = { val d = table.length >> 1 if (i <= j) j - i < d else i - j > d @@ -106,11 +110,11 @@ trait FlatHashTable[A] { def elements = new Iterator[A] { private var i = 0 def hasNext: Boolean = { - while (i < table.length && (null == table(i))) i = i + 1; + while (i < table.length && (null == table(i))) i += 1; i < table.length } def next(): A = - if (hasNext) { i = i + 1; table(i - 1).asInstanceOf[A] } + if (hasNext) { i += 1; table(i - 1).asInstanceOf[A] } else Iterator.empty.next } diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 7138fdd677..71ed732204 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -23,7 +23,7 @@ import Predef._ final class ListBuffer[A] extends Buffer[A] { private var start: List[A] = Nil private var last0: ::[A] = _ - private var exported: boolean = false + private var exported: Boolean = false /** Prepends a single element to this buffer. * @@ -42,7 +42,7 @@ final class ListBuffer[A] extends Buffer[A] { * * @param x the element to append. */ - override def += (x: A): unit = { + override def += (x: A) { if (exported) copy() if (start.isEmpty) { last0 = new scala.:: (x, Nil) @@ -66,7 +66,7 @@ final class ListBuffer[A] extends Buffer[A] { * * @param x the element to remove. */ - override def -= (x: A): unit = { + override def -= (x: A) { if (exported) copy() if (start.isEmpty) {} else if (start.head == x) start = start.tail @@ -75,7 +75,7 @@ final class ListBuffer[A] extends Buffer[A] { while (!cursor.tail.isEmpty && cursor.tail.head != x) { cursor = cursor.tail } if (!cursor.tail.isEmpty) { val z = cursor.asInstanceOf[scala.::[A]] - if(z.tl == last0) + if (z.tl == last0) last0 = z z.tl = cursor.tail.tail } @@ -99,13 +99,13 @@ final class ListBuffer[A] extends Buffer[A] { /** Clears the buffer contents. */ - def clear(): unit = { + def clear() { start = Nil exported = false } /** Copy contents of this buffer */ - private def copy() = { + private def copy() { var cursor = start val limit = last0.tail clear @@ -119,7 +119,7 @@ final class ListBuffer[A] extends Buffer[A] { * * @return the length of this buffer. */ - def length: int = start.length + def length: Int = start.length /** Returns the n-th element of this list. This method * yields an error if the element does not exist. @@ -142,25 +142,27 @@ final class ListBuffer[A] extends Buffer[A] { * @param x the new element. * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds. */ - def update(n: Int, x: A): unit = try { - if (exported) copy() - if (n == 0) { - val newElem = new scala.:: (x, start.tail); - if (last0 eq start) last0 = newElem - start = newElem - } else { - var cursor = start; - var i = 1; - while (i < n) { - cursor = cursor.tail - i = i + 1 + def update(n: Int, x: A) { + try { + if (exported) copy() + if (n == 0) { + val newElem = new scala.:: (x, start.tail); + if (last0 eq start) last0 = newElem + start = newElem + } else { + var cursor = start + var i = 1 + while (i < n) { + cursor = cursor.tail + i += 1 + } + val newElem = new scala.:: (x, cursor.tail.tail) + if (last0 eq cursor.tail) last0 = newElem + cursor.asInstanceOf[scala.::[A]].tl = newElem } - val newElem = new scala.:: (x, cursor.tail.tail) - if (last0 eq cursor.tail) last0 = newElem - cursor.asInstanceOf[scala.::[A]].tl = newElem + } catch { + case ex: Exception => throw new IndexOutOfBoundsException(n.toString()) } - } catch { - case ex: Exception => throw new IndexOutOfBoundsException(n.toString()) } /** Inserts new elements at the index <code>n</code>. Opposed to method @@ -171,36 +173,37 @@ final class ListBuffer[A] extends Buffer[A] { * @param iter the iterable object providing all elements to insert. * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds. */ - def insertAll(n: Int, iter: Iterable[A]): unit = try { - if (exported) copy() - var elems = iter.elements.toList.reverse - if (n == 0) { - while (!elems.isEmpty) { - val newElem = new scala.:: (elems.head, start) - if (start.isEmpty) last0 = newElem - start = newElem - elems = elems.tail - } - } else { - var cursor = start - var i = 1 - while (i < n) { - cursor = cursor.tail - i = i + 1 - } - while (!elems.isEmpty) { - val newElem = new scala.:: (elems.head, cursor.tail) - if (cursor.tail.isEmpty) last0 = newElem - cursor.asInstanceOf[scala.::[A]].tl = newElem - elems = elems.tail + def insertAll(n: Int, iter: Iterable[A]) { + try { + if (exported) copy() + var elems = iter.elements.toList.reverse + if (n == 0) { + while (!elems.isEmpty) { + val newElem = new scala.:: (elems.head, start) + if (start.isEmpty) last0 = newElem + start = newElem + elems = elems.tail + } + } else { + var cursor = start + var i = 1 + while (i < n) { + cursor = cursor.tail + i += 1 + } + while (!elems.isEmpty) { + val newElem = new scala.:: (elems.head, cursor.tail) + if (cursor.tail.isEmpty) last0 = newElem + cursor.asInstanceOf[scala.::[A]].tl = newElem + elems = elems.tail + } } + } catch { + case ex: Exception => + throw new IndexOutOfBoundsException(n.toString()) } - } catch { - case ex: Exception => - throw new IndexOutOfBoundsException(n.toString()) } - /** Removes the element on a given index position. * * @param n the index which refers to the element to delete. @@ -218,7 +221,7 @@ final class ListBuffer[A] extends Buffer[A] { var i = 1 while (i < n) { cursor = cursor.tail - i = i + 1 + i += 1 } old = cursor.tail.head if (last0 eq cursor.tail) last0 = cursor.asInstanceOf[scala.::[A]] diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala index 67e510e38e..1c14765e88 100644 --- a/src/library/scala/collection/mutable/SynchronizedMap.scala +++ b/src/library/scala/collection/mutable/SynchronizedMap.scala @@ -135,7 +135,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] { super.equals(that) } - override def hashCode(): int = synchronized { + override def hashCode(): Int = synchronized { super.hashCode() } diff --git a/src/library/scala/concurrent/Actor.scala b/src/library/scala/concurrent/Actor.scala index 4e15220a37..a4d0bac02c 100644 --- a/src/library/scala/concurrent/Actor.scala +++ b/src/library/scala/concurrent/Actor.scala @@ -27,11 +27,11 @@ abstract class Actor extends Thread { def send(msg: in.Message) = in.send(msg) - def receive[a](f: PartialFunction[in.Message, a]): a = + def receive[A](f: PartialFunction[in.Message, A]): A = if (currentThread == this) in.receive(f) else throw new IllegalArgumentException("receive called not on own process") - def receiveWithin[a](msec: long)(f: PartialFunction[in.Message, a]): a = + def receiveWithin[A](msec: Long)(f: PartialFunction[in.Message, A]): A = if (currentThread == this) in.receiveWithin(msec)(f) else throw new IllegalArgumentException("receiveWithin called not on own process") diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala index 04a172bff4..8488dd7ed2 100644 --- a/src/library/scala/concurrent/MailBox.scala +++ b/src/library/scala/concurrent/MailBox.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -23,19 +23,19 @@ class MailBox extends AnyRef with ListQueueCreator { private abstract class PreReceiver { var msg: Message = null - def isDefinedAt(msg: Message): boolean + def isDefinedAt(msg: Message): Boolean } - private class Receiver[a](receiver: PartialFunction[Message, a]) extends PreReceiver { + private class Receiver[A](receiver: PartialFunction[Message, A]) extends PreReceiver { def isDefinedAt(msg: Message) = receiver.isDefinedAt(msg) - def receive(): a = synchronized { + def receive(): A = synchronized { while (msg eq null) wait() receiver(msg) } - def receiveWithin(msec: long): a = synchronized { + def receiveWithin(msec: Long): A = synchronized { if (msg eq null) wait(msec) receiver(if (msg ne null) msg else TIMEOUT) } @@ -55,7 +55,7 @@ class MailBox extends AnyRef with ListQueueCreator { * If yes, the message is extracted and associated with the receiver. * Otherwise the receiver is appended to the list of pending receivers. */ - private def scanSentMsgs[a](receiver: Receiver[a]): unit = synchronized { + private def scanSentMsgs[A](receiver: Receiver[A]): Unit = synchronized { messageQueue.extractFirst(sent, msg => receiver.isDefinedAt(msg)) match { case None => receivers = receiverQueue.append(receivers, receiver) case Some((msg, withoutMsg)) => { @@ -70,7 +70,7 @@ class MailBox extends AnyRef with ListQueueCreator { * message. If yes, the receiver is notified. Otherwise the message * is appended to the linked list of sent messages. */ - def send(msg: Message): unit = synchronized { + def send(msg: Message): Unit = synchronized { receiverQueue.extractFirst(receivers, r => r.isDefinedAt(msg)) match { case None => sent = messageQueue.append(sent, msg) case Some((receiver, withoutReceiver)) => { @@ -85,7 +85,7 @@ class MailBox extends AnyRef with ListQueueCreator { * Block until there is a message in the mailbox for which the processor * <code>f</code> is defined. */ - def receive[a](f: PartialFunction[Message, a]): a = { + def receive[A](f: PartialFunction[Message, A]): A = { val r = new Receiver(f) scanSentMsgs(r) r.receive() @@ -95,7 +95,7 @@ class MailBox extends AnyRef with ListQueueCreator { * Block until there is a message in the mailbox for which the processor * <code>f</code> is defined or the timeout is over. */ - def receiveWithin[a](msec: long)(f: PartialFunction[Message, a]): a = { + def receiveWithin[A](msec: Long)(f: PartialFunction[Message, A]): A = { val r = new Receiver(f) scanSentMsgs(r) r.receiveWithin(msec) @@ -108,24 +108,24 @@ class MailBox extends AnyRef with ListQueueCreator { /** * Module for dealing with queues. */ -trait QueueModule[a] { +trait QueueModule[A] { /** Type of queues. */ - type t + type T /** Create an empty queue. */ - def make: t + def make: T /** Append an element to a queue. */ - def append(l: t, x: a): t + def append(l: T, x: A): T /** Extract an element satisfying a predicate from a queue. */ - def extractFirst(l: t, p: a => boolean): Option[(a, t)] + def extractFirst(l: T, p: A => Boolean): Option[(A, T)] } /** Inefficient but simple queue module creator. */ trait ListQueueCreator { - def queueCreate[a]: QueueModule[a] = new QueueModule[a] { - type t = List[a] - def make: t = Nil - def append(l: t, x: a): t = l ::: x :: Nil - def extractFirst(l: t, p: a => boolean): Option[(a, t)] = + def queueCreate[A]: QueueModule[A] = new QueueModule[A] { + type T = List[A] + def make: T = Nil + def append(l: T, x: A): T = l ::: x :: Nil + def extractFirst(l: T, p: A => Boolean): Option[(A, T)] = l match { case Nil => None case head :: tail => @@ -143,18 +143,18 @@ trait ListQueueCreator { /** Efficient queue module creator based on linked lists. */ trait LinkedListQueueCreator { import scala.collection.mutable.LinkedList - def queueCreate[a >: Null <: AnyRef]: QueueModule[a] = new QueueModule[a] { - type t = (LinkedList[a], LinkedList[a]) // fst = the list, snd = last elem - def make: t = { - val l = new LinkedList[a](null, null) + def queueCreate[A >: Null <: AnyRef]: QueueModule[A] = new QueueModule[A] { + type T = (LinkedList[A], LinkedList[A]) // fst = the list, snd = last elem + def make: T = { + val l = new LinkedList[A](null, null) (l, l) } - def append(l: t, x: a): t = { + def append(l: T, x: A): T = { val atTail = new LinkedList(x, null) l._2 append atTail; (l._1, atTail) } - def extractFirst(l: t, p: a => boolean): Option[(a, t)] = { + def extractFirst(l: T, p: A => Boolean): Option[(A, T)] = { var xs = l._1 var xs1 = xs.next while ((xs1 ne null) && !p(xs1.elem)) { diff --git a/src/library/scala/concurrent/Process.scala b/src/library/scala/concurrent/Process.scala index 421e82e7fe..eaf572c316 100644 --- a/src/library/scala/concurrent/Process.scala +++ b/src/library/scala/concurrent/Process.scala @@ -34,10 +34,10 @@ object Process { def send(p: Process, msg: MailBox#Message) = p.send(msg) - def receive[a](f: PartialFunction[MailBox#Message, a]): a = + def receive[A](f: PartialFunction[MailBox#Message, A]): A = self.receive(f) - def receiveWithin[a](msec: long)(f: PartialFunction[MailBox#Message, a]): a = + def receiveWithin[A](msec: Long)(f: PartialFunction[MailBox#Message, A]): A = self.receiveWithin(msec)(f) /** diff --git a/src/library/scala/concurrent/jolib.scala b/src/library/scala/concurrent/jolib.scala index 2897857066..315a5a59ba 100644 --- a/src/library/scala/concurrent/jolib.scala +++ b/src/library/scala/concurrent/jolib.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -22,7 +22,7 @@ object jolib { type Pattern = List[Signal] - type Rule = PartialFunction[List[Any], unit] + type Rule = PartialFunction[List[Any], Unit] /////////////////// JOIN DEFINITION ///////////////////////// @@ -55,7 +55,7 @@ object jolib { abstract class Signal(join: Join) { type C val queue = new collection.mutable.Queue[C] - def tryReduction(x: C): unit = { + def tryReduction(x: C) { val continuation = join synchronized { queue.enqueue(x) join.tryMatch @@ -65,12 +65,12 @@ object jolib { } abstract class Asynchr(join: Join) extends Signal(join) { - def apply(x: C): unit = tryReduction(x) + def apply(x: C): Unit = tryReduction(x) } - abstract class Synchr[a](join: Join) extends Signal(join) { - type C <: SyncVar[a] - def apply(x: C): a = { + abstract class Synchr[A](join: Join) extends Signal(join) { + type C <: SyncVar[A] + def apply(x: C): A = { tryReduction(x) x.get } diff --git a/src/library/scala/concurrent/pilib.scala b/src/library/scala/concurrent/pilib.scala index 33a79b85b0..7acfbc2728 100644 --- a/src/library/scala/concurrent/pilib.scala +++ b/src/library/scala/concurrent/pilib.scala @@ -40,15 +40,15 @@ object pilib { * <code>spawn < p<sub>1</sub> | ... | p<sub>n</sub> ></code> */ abstract class Spawn { - def <(p: => unit): Spawn - def |(p: => unit): Spawn - def > : unit + def <(p: => Unit): Spawn + def |(p: => Unit): Spawn + def > : Unit } val spawn = new Spawn { //object spawn extends Spawn { // BUG ! - def <(p: => unit): Spawn = { scala.concurrent.ops.spawn(p); this } - def |(p: => unit): Spawn = { scala.concurrent.ops.spawn(p); this } - def > : unit = () + def <(p: => Unit): Spawn = { scala.concurrent.ops.spawn(p); this } + def |(p: => Unit): Spawn = { scala.concurrent.ops.spawn(p); this } + def > : Unit = () } /////////////////////////// GUARDED PROCESSES ////////////////////////// @@ -66,10 +66,10 @@ object pilib { * @param v transmitted value * @param c continuation */ - case class UGP(n: UChan, polarity: boolean, v: Any, c: Any => Any) + case class UGP(n: UChan, polarity: Boolean, v: Any, c: Any => Any) /** Typed guarded process. */ - class GP[a](n: UChan, polarity: boolean, v: Any, c: Any => a) { + class GP[a](n: UChan, polarity: Boolean, v: Any, c: Any => a) { val untyped = UGP(n, polarity, v, c) } @@ -79,46 +79,46 @@ object pilib { * Name on which one can emit, receive or that can be emitted or received * during a communication. */ - class Chan[a] extends UChan with Function1[a, Product[a]] { + class Chan[A] extends UChan with Function1[A, Product[A]] { - var defaultValue: a = _ + var defaultValue: A = _ /** Creates an input guarded process. */ - def input[b](c: a => b) = - new GP(this, true, (), x => c(x.asInstanceOf[a])) + def input[B](c: A => B) = + new GP(this, true, (), x => c(x.asInstanceOf[A])) /** Creates an input guarded process. */ - def output[b](v: a, c: () => b) = + def output[B](v: A, c: () => B) = new GP(this, false, v, x => c()) /** Blocking read. */ def read = { - var res: a = defaultValue + var res: A = defaultValue choice ( input(x => res = x) ) res } /** Blocking write. */ - def write(x: a) = + def write(x: A) = choice ( output(x, () => ()) ) /** Syntactic sugar for input. */ - def *[b](f: a => b) = - input(f); + def *[B](f: A => B) = + input(f) /** Syntactic sugar for output. */ - def apply(v: a) = + def apply(v: A) = new Product(this, v) /** Attach a function to be evaluated at each communication event * on this channel. Replace previous attached function. */ - def attach(f: a => unit) = - log = x => f(x.asInstanceOf[a]) + def attach(f: A => Unit) = + log = x => f(x.asInstanceOf[A]) } - class Product[a](c: Chan[a], v: a) { - def *[b](f: => b) = c.output(v, () => f) + class Product[A](c: Chan[A], v: A) { + def *[B](f: => B) = c.output(v, () => f) } /////////////////////// SUM OF GUARDED PROCESSES /////////////////////// @@ -159,7 +159,7 @@ object pilib { * @param gs2 ... * @return ... */ - private def matches(gs1: List[UGP], gs2: List[UGP]): Option[(() => unit, () => Any, () => Any)] = + private def matches(gs1: List[UGP], gs2: List[UGP]): Option[(() => Unit, () => Any, () => Any)] = (gs1, gs2) match { case (Nil, _) => None case (_, Nil) => None @@ -198,10 +198,10 @@ object pilib { * @param s ... * @return ... */ - def choice[a](s: GP[a]*): a = { - val sum = Sum(s.toList map { x => x.untyped }) + def choice[A](s: GP[A]*): A = { + val sum = Sum(s.toList map { _.untyped }) synchronized { sums = compare(sum, sums) } - (sum.continue).asInstanceOf[a] + (sum.continue).asInstanceOf[A] } } diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala index 772b1246bc..a9baa43d89 100644 --- a/src/library/scala/io/BytePickle.scala +++ b/src/library/scala/io/BytePickle.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -23,52 +23,52 @@ import scala.collection.mutable.{HashMap, ArrayBuffer} * @version 1.1 */ object BytePickle { - abstract class SPU[t] { - def appP(a: t, state: PicklerState): PicklerState - def appU(state: UnPicklerState): (t, UnPicklerState) + abstract class SPU[T] { + def appP(a: T, state: PicklerState): PicklerState + def appU(state: UnPicklerState): (T, UnPicklerState) } - def pickle[t](p: SPU[t], a: t): Array[byte] = - p.appP(a, new PicklerState(new Array[byte](0), new PicklerEnv)).stream + def pickle[T](p: SPU[T], a: T): Array[Byte] = + p.appP(a, new PicklerState(new Array[Byte](0), new PicklerEnv)).stream - def unpickle[t](p: SPU[t], stream: Array[byte]): t = + def unpickle[T](p: SPU[T], stream: Array[Byte]): T = p.appU(new UnPicklerState(stream, new UnPicklerEnv))._1 - abstract class PU[t] { - def appP(a: t, state: Array[byte]): Array[byte] - def appU(state: Array[byte]): (t, Array[byte]) + abstract class PU[T] { + def appP(a: T, state: Array[Byte]): Array[Byte] + def appU(state: Array[Byte]): (T, Array[Byte]) } - def upickle[t](p: PU[t], a: t): Array[byte] = - p.appP(a, new Array[byte](0)) + def upickle[T](p: PU[T], a: T): Array[Byte] = + p.appP(a, new Array[Byte](0)) - def uunpickle[t](p: PU[t], stream: Array[byte]): t = + def uunpickle[T](p: PU[T], stream: Array[Byte]): T = p.appU(stream)._1 - class PicklerEnv extends HashMap[Any, int] { - private var cnt: int = 64 - def nextLoc() = { cnt = cnt + 1; cnt } + class PicklerEnv extends HashMap[Any, Int] { + private var cnt: Int = 64 + def nextLoc() = { cnt += 1; cnt } } - class UnPicklerEnv extends HashMap[int, Any] { - private var cnt: int = 64 - def nextLoc() = { cnt = cnt + 1; cnt } + class UnPicklerEnv extends HashMap[Int, Any] { + private var cnt: Int = 64 + def nextLoc() = { cnt += 1; cnt } } - class PicklerState(val stream: Array[byte], val dict: PicklerEnv) - class UnPicklerState(val stream: Array[byte], val dict: UnPicklerEnv) + class PicklerState(val stream: Array[Byte], val dict: PicklerEnv) + class UnPicklerState(val stream: Array[Byte], val dict: UnPicklerEnv) abstract class RefDef case class Ref() extends RefDef case class Def() extends RefDef def refDef: PU[RefDef] = new PU[RefDef] { - def appP(b: RefDef, s: Array[byte]): Array[byte] = + def appP(b: RefDef, s: Array[Byte]): Array[Byte] = b match { - case Ref() => Array.concat(s, (List[byte](0)).toArray) - case Def() => Array.concat(s, (List[byte](1)).toArray) + case Ref() => Array.concat(s, (List[Byte](0)).toArray) + case Def() => Array.concat(s, (List[Byte](1)).toArray) }; - def appU(s: Array[byte]): (RefDef, Array[byte]) = + def appU(s: Array[Byte]): (RefDef, Array[Byte]) = if (s(0) == 0) (Ref(), s.subArray(1, s.length)) else (Def(), s.subArray(1, s.length)); } @@ -76,17 +76,17 @@ object BytePickle { val REF = 0 val DEF = 1 - def unat: PU[int] = new PU[int] { - def appP(n: int, s: Array[byte]): Array[byte] = + def unat: PU[Int] = new PU[Int] { + def appP(n: Int, s: Array[Byte]): Array[Byte] = Array.concat(s, nat2Bytes(n)); - def appU(s: Array[byte]): (int, Array[byte]) = { + def appU(s: Array[Byte]): (Int, Array[Byte]) = { var num = 0 - def readNat: int = { + def readNat: Int = { var b = 0; var x = 0; do { b = s(num) - num = num + 1 + num += 1 x = (x << 7) + (b & 0x7f); } while ((b & 0x80) != 0); x @@ -153,28 +153,28 @@ object BytePickle { } def ulift[t](x: t): PU[t] = new PU[t] { - def appP(a: t, state: Array[byte]): Array[byte] = + def appP(a: t, state: Array[Byte]): Array[Byte] = if (x != a) { throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x); state } else state; - def appU(state: Array[byte]) = (x, state); + def appU(state: Array[Byte]) = (x, state) } def lift[t](x: t): SPU[t] = new SPU[t] { def appP(a: t, state: PicklerState): PicklerState = if (x != a) { /*throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x);*/ state } else state; - def appU(state: UnPicklerState) = (x, state); + def appU(state: UnPicklerState) = (x, state) } def usequ[t,u](f: u => t, pa: PU[t], k: t => PU[u]): PU[u] = new PU[u] { - def appP(b: u, s: Array[byte]): Array[byte] = { + def appP(b: u, s: Array[Byte]): Array[Byte] = { val a = f(b) val sPrime = pa.appP(a, s) val pb = k(a) val sPrimePrime = pb.appP(b, sPrime) sPrimePrime } - def appU(s: Array[byte]): (u, Array[byte]) = { + def appU(s: Array[Byte]): (u, Array[Byte]) = { val resPa = pa.appU(s) val a = resPa._1 val sPrime = resPa._2 @@ -228,34 +228,34 @@ object BytePickle { def wrap[a,b](i: a => b, j: b => a, pa: SPU[a]): SPU[b] = sequ(j, pa, (x: a) => lift(i(x))) - def appendByte(a: Array[byte], b: int): Array[byte] = - Array.concat(a, (List[byte](b.asInstanceOf[byte])).toArray) + def appendByte(a: Array[Byte], b: Int): Array[Byte] = + Array.concat(a, (List[Byte](b.asInstanceOf[Byte])).toArray) - def nat2Bytes(x: int): Array[byte] = { - val buf = new ArrayBuffer[byte] - def writeNatPrefix(x: int): unit = { + def nat2Bytes(x: Int): Array[Byte] = { + val buf = new ArrayBuffer[Byte] + def writeNatPrefix(x: Int) { val y = x >>> 7; if (y != 0) writeNatPrefix(y); - buf += ((x & 0x7f) | 0x80).asInstanceOf[byte]; + buf += ((x & 0x7f) | 0x80).asInstanceOf[Byte]; } val y = x >>> 7; if (y != 0) writeNatPrefix(y); - buf += (x & 0x7f).asInstanceOf[byte]; + buf += (x & 0x7f).asInstanceOf[Byte]; buf.toArray } - def nat: SPU[int] = new SPU[int] { - def appP(n: int, s: PicklerState): PicklerState = { + def nat: SPU[Int] = new SPU[Int] { + def appP(n: Int, s: PicklerState): PicklerState = { new PicklerState(Array.concat(s.stream, nat2Bytes(n)), s.dict); } - def appU(s: UnPicklerState): (int,UnPicklerState) = { + def appU(s: UnPicklerState): (Int,UnPicklerState) = { var num = 0 - def readNat: int = { + def readNat: Int = { var b = 0 var x = 0 do { b = s.stream(num) - num = num + 1 + num += 1 x = (x << 7) + (b & 0x7f); } while ((b & 0x80) != 0); x @@ -264,30 +264,30 @@ object BytePickle { } } - def byte: SPU[byte] = new SPU[byte] { - def appP(b: byte, s: PicklerState): PicklerState = - new PicklerState(Array.concat(s.stream, (List[byte](b)).toArray), s.dict); - def appU(s: UnPicklerState): (byte, UnPicklerState) = + def byte: SPU[Byte] = new SPU[Byte] { + def appP(b: Byte, s: PicklerState): PicklerState = + new PicklerState(Array.concat(s.stream, (List[Byte](b)).toArray), s.dict); + def appU(s: UnPicklerState): (Byte, UnPicklerState) = (s.stream(0), new UnPicklerState(s.stream.subArray(1, s.stream.length), s.dict)); } def string: SPU[String] = - share(wrap((a:Array[byte]) => UTF8Codec.decode(a, 0, a.length), (s:String) => UTF8Codec.encode(s), bytearray)); + share(wrap((a: Array[Byte]) => UTF8Codec.decode(a, 0, a.length), (s:String) => UTF8Codec.encode(s), bytearray)); - def bytearray: SPU[Array[byte]] = { - wrap((l:List[byte]) => l.toArray, (_.toList), list(byte)) + def bytearray: SPU[Array[Byte]] = { + wrap((l:List[Byte]) => l.toArray, (_.toList), list(byte)) } - def bool: SPU[boolean] = { - def toEnum(b: boolean) = if (b) 1 else 0 - def fromEnum(n: int) = if (n == 0) false else true + def bool: SPU[Boolean] = { + def toEnum(b: Boolean) = if (b) 1 else 0 + def fromEnum(n: Int) = if (n == 0) false else true wrap(fromEnum, toEnum, nat) } - def ufixedList[a](pa: PU[a])(n: int): PU[List[a]] = { - def pairToList(p: (a,List[a])): List[a] = + def ufixedList[A](pa: PU[A])(n: Int): PU[List[A]] = { + def pairToList(p: (A, List[A])): List[A] = p._1 :: p._2; - def listToPair(l: List[a]): (a,List[a]) = + def listToPair(l: List[A]): (A, List[A]) = (l: @unchecked) match { case x :: xs => (x, xs) } if (n == 0) ulift(Nil) @@ -295,7 +295,7 @@ object BytePickle { uwrap(pairToList, listToPair, upair(pa, ufixedList(pa)(n-1))) } - def fixedList[a](pa: SPU[a])(n: int): SPU[List[a]] = { + def fixedList[a](pa: SPU[a])(n: Int): SPU[List[a]] = { def pairToList(p: (a,List[a])): List[a] = p._1 :: p._2; def listToPair(l: List[a]): (a,List[a]) = @@ -312,6 +312,6 @@ object BytePickle { def ulist[a](pa: PU[a]): PU[List[a]] = usequ((l:List[a]) => l.length, unat, ufixedList(pa)); - def data[a](tag: a => int, ps: List[()=>SPU[a]]): SPU[a] = - sequ(tag, nat, (x: int)=> ps.apply(x)()); + def data[a](tag: a => Int, ps: List[()=>SPU[a]]): SPU[a] = + sequ(tag, nat, (x: Int)=> ps.apply(x)()); } diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index f9d34fa024..55629d1acc 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -12,7 +12,9 @@ package scala.io -import java.io.{File, FileInputStream, InputStream, PrintStream} +import java.io.{BufferedInputStream, File, FileInputStream, InputStream, + PrintStream} +import java.net.{URI, URL} import compat.StringBuilder @@ -96,13 +98,13 @@ object Source { /** creates Source from file with given file: URI */ - def fromFile(uri: java.net.URI): Source = + def fromFile(uri: URI): Source = fromFile(new File(uri)) /** creates Source from file, using default character encoding, setting its * description to filename. */ - def fromFile(file: java.io.File): Source = { + def fromFile(file: File): Source = { val arr: Array[Byte] = new Array[Byte](file.length().asInstanceOf[Int]) val is = new FileInputStream(file) is.read(arr) @@ -117,7 +119,7 @@ object Source { * @param enc ... * @return ... */ - def fromFile(file: java.io.File, enc: String): Source = { + def fromFile(file: File, enc: String): Source = { val arr: Array[Byte] = new Array[Byte](file.length().asInstanceOf[Int]) val is = new FileInputStream(file) is.read(arr) @@ -141,19 +143,19 @@ object Source { * @return ... */ def fromURL(s: String): Source = - fromURL(new java.net.URL(s)) + fromURL(new URL(s)) /** * @param url ... * @return ... */ - def fromURL(url: java.net.URL): Source = { + def fromURL(url: URL): Source = { val it = new Iterator[Char] { var data: Int = _ def hasNext = {data != -1} - def next = {val x = data.asInstanceOf[char]; data = bufIn.read(); x} + def next = {val x = data.asInstanceOf[Char]; data = bufIn.read(); x} val in = url.openStream() - val bufIn = new java.io.BufferedInputStream(in) + val bufIn = new BufferedInputStream(in) data = bufIn.read() } val s = new Source { @@ -175,11 +177,11 @@ object Source { def fromInputStream(istream: InputStream, enc: String, maxlen: Option[Int]): Source = { val BUFSIZE = 1024 val limit = maxlen match { case Some(i) => i; case None => 0 } - val bi = new java.io.BufferedInputStream(istream, BUFSIZE) + val bi = new BufferedInputStream(istream, BUFSIZE) val bytes = new collection.mutable.ArrayBuffer[Byte]() var b = 0 var i = 0 - while( {b = bi.read; i = i + 1; b} != -1 && (limit <= 0 || i < limit)) { + while( {b = bi.read; i += 1; b} != -1 && (limit <= 0 || i < limit)) { bytes += b.toByte; } if(limit <= 0) bi.close @@ -251,7 +253,7 @@ abstract class Source extends Iterator[Char] { while (it.hasNext && i < (line-1)) if ('\n' == it.next) - i = i + 1; + i += 1; if (!it.hasNext) // this should not happen throw new IllegalArgumentException( @@ -299,11 +301,11 @@ abstract class Source extends Iterator[Char] { ch match { case '\n' => ccol = 1 - cline = cline + 1 + cline += 1 case '\t' => - ccol = ccol + tabinc + ccol += tabinc case _ => - ccol = ccol + 1 + ccol += 1 } ch } @@ -313,8 +315,9 @@ abstract class Source extends Iterator[Char] { * @param pos ... * @param msg the error message to report */ - def reportError(pos: Int, msg: String): Unit = + def reportError(pos: Int, msg: String) { reportError(pos, msg, java.lang.System.out) + } /** Reports an error message to the output stream <code>out</code>. * @@ -322,7 +325,7 @@ abstract class Source extends Iterator[Char] { * @param msg the error message to report * @param out ... */ - def reportError(pos: Int, msg: String, out: PrintStream): Unit = { + def reportError(pos: Int, msg: String, out: PrintStream) { nerrors = nerrors + 1 report(pos, msg, out) } @@ -332,7 +335,7 @@ abstract class Source extends Iterator[Char] { * @param msg the error message to report * @param out ... */ - def report(pos: Int, msg: String, out: PrintStream): Unit = { + def report(pos: Int, msg: String, out: PrintStream) { val buf = new StringBuilder val line = Position.line(pos) val col = Position.column(pos) @@ -341,7 +344,7 @@ abstract class Source extends Iterator[Char] { var i = 1 while (i < col) { buf.append(' ') - i = i + 1 + i += 1 } buf.append('^') out.println(buf.toString) @@ -352,15 +355,16 @@ abstract class Source extends Iterator[Char] { * @param pos ... * @param msg the warning message to report */ - def reportWarning(pos: Int, msg: String): Unit = + def reportWarning(pos: Int, msg: String) { reportWarning(pos, msg, java.lang.System.out) + } /** * @param pos ... * @param msg the warning message to report * @param out ... */ - def reportWarning(pos: Int, msg: String, out: PrintStream): Unit = { + def reportWarning(pos: Int, msg: String, out: PrintStream) { nwarnings = nwarnings + 1 report(pos, "warning! " + msg, out) } diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala index 0808714c9d..39aea9ec81 100644 --- a/src/library/scala/text/Document.scala +++ b/src/library/scala/text/Document.scala @@ -25,10 +25,9 @@ case class DocCons(hd: Document, tl: Document) extends Document * A basic pretty-printing library, based on Lindig's strict version * of Wadler's adaptation of Hughes' pretty-printer. * - * @version 1.0 * @author Michel Schinz + * @version 1.0 */ - abstract class Document { def ::(hd: Document): Document = DocCons(hd, this) def ::(hd: String): Document = DocCons(DocText(hd), this) @@ -45,7 +44,7 @@ abstract class Document { def format(width: Int, writer: Writer) { type FmtState = (Int, Boolean, Document) - def fits(w: Int, state: List[FmtState]): boolean = state match { + def fits(w: Int, state: List[FmtState]): Boolean = state match { case _ if w < 0 => false case List() => diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala index 2d590a0edf..ba3d0b9a45 100644 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ b/src/library/scala/util/automata/BaseBerrySethi.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -35,7 +35,7 @@ abstract class BaseBerrySethi { protected var finalTag: Int = _ - protected var finals: immutable.TreeMap[int,int] = _ // final states + protected var finals: immutable.TreeMap[Int, Int] = _ // final states // constants -------------------------- @@ -48,9 +48,11 @@ abstract class BaseBerrySethi { val it = x.rs.elements // union while (it.hasNext) { tmp = tmp incl compFirst(it.next) } tmp - case Eps => emptySet + case Eps => + emptySet //case x:Letter => emptySet + posMap(x); // singleton set - case x:Meta => compFirst(x.r) + case x:Meta => + compFirst(x.r) case x:Sequ => var tmp = emptySet; val it = x.rs.elements; // union diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index a268344557..8c306369af 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -94,7 +94,7 @@ abstract class WordBerrySethi extends BaseBerrySethi { /** called at the leaves of the regexp */ - protected def seenLabel(r: RegExp, i: Int, label: _labelT): Unit = { + protected def seenLabel(r: RegExp, i: Int, label: _labelT) { //Console.println("seenLabel (1)"); //this.posMap.update(r, i) this.labelAt = this.labelAt.update(i, label) @@ -119,7 +119,7 @@ abstract class WordBerrySethi extends BaseBerrySethi { } - protected def makeTransition(src: Int, dest: Int, label: _labelT ): Unit = { + protected def makeTransition(src: Int, dest: Int, label: _labelT ) { //@ifdef compiler if( label == Wildcard ) //@ifdef compiler defaultq.update(src, dest::defaultq( src )) //@ifdef compiler else @@ -148,7 +148,7 @@ abstract class WordBerrySethi extends BaseBerrySethi { this.initials = emptySet + 0 } - protected def initializeAutom(): Unit = { + protected def initializeAutom() { finals = immutable.TreeMap.empty[Int, Int] // final states deltaq = new Array[mutable.HashMap[_labelT, List[Int]]](pos) // delta defaultq = new Array[List[Int]](pos) // default transitions diff --git a/src/library/scala/util/parsing/CharInputStreamIterator.scala b/src/library/scala/util/parsing/CharInputStreamIterator.scala index af14e1fce0..bc712f74bf 100644 --- a/src/library/scala/util/parsing/CharInputStreamIterator.scala +++ b/src/library/scala/util/parsing/CharInputStreamIterator.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -20,27 +20,27 @@ import java.io.{IOException, EOFException} * @author Burak Emir * @version 1.0 */ -class CharInputStreamIterator(in: InputStream) extends Iterator[char] { +class CharInputStreamIterator(in: InputStream) extends Iterator[Char] { - private var ch: int = _ + private var ch: Int = _ private var chSet = false private var error: IOException = null - private def lookahead(): unit = try { + private def lookahead(): Unit = try { ch = in.read(); chSet = ch >= 0 } catch { case ex: EOFException => ch = -1 case ex: IOException => ch = 1; error = ex } - def hasNext: boolean = { + def hasNext: Boolean = { if (!chSet) lookahead chSet } - def next(): char = { + def next(): Char = { if (!chSet) lookahead chSet = false - ch.asInstanceOf[char] + ch.asInstanceOf[Char] } } diff --git a/src/library/scala/util/parsing/Parsers.scala b/src/library/scala/util/parsing/Parsers.scala index f046318c85..604b064ad6 100644 --- a/src/library/scala/util/parsing/Parsers.scala +++ b/src/library/scala/util/parsing/Parsers.scala @@ -22,64 +22,64 @@ abstract class Parsers { type inputType - abstract class Parser[a] { + abstract class Parser[A] { - type Result = Option[(a, inputType)] + type Result = Option[(A, inputType)] def apply(in: inputType): Result - def filter(pred: a => boolean) = new Parser[a] { + def filter(pred: A => Boolean) = new Parser[A] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None case Some((x, in1)) => if (pred(x)) Some((x, in1)) else None } } - def map[b](f: a => b) = new Parser[b] { + def map[B](f: A => B) = new Parser[B] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None case Some((x, in1)) => Some((f(x), in1)) } } - def flatMap[b](f: a => Parser[b]) = new Parser[b] { + def flatMap[B](f: A => Parser[B]) = new Parser[B] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None case Some((x, in1)) => f(x).apply(in1) } } - def ||| (p: => Parser[a]) = new Parser[a] { + def ||| (p: => Parser[A]) = new Parser[A] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => p(in) case s => s } } - def &&& [b](p: => Parser[b]): Parser[b] = + def &&& [B](p: => Parser[B]): Parser[B] = for (_ <- this; val x <- p) yield x } - def not[a](p: Parser[a]) = new Parser[unit] { + def not[A](p: Parser[A]) = new Parser[Unit] { def apply(in: inputType): Result = p.apply(in) match { case None => Some(((), in)) case Some(_) => None } } - def succeed[a](x: a) = new Parser[a] { + def succeed[A](x: A) = new Parser[A] { def apply(in: inputType): Result = Some((x, in)) } - def rep[a](p: Parser[a]): Parser[List[a]] = + def rep[A](p: Parser[A]): Parser[List[A]] = rep1(p) ||| succeed(List()) - def rep1[a](p: Parser[a]): Parser[List[a]] = + def rep1[A](p: Parser[A]): Parser[List[A]] = for (x <- p; val xs <- rep(p)) yield x :: xs - def repWith[a, b](p: Parser[a], sep: Parser[b]): Parser[List[a]] = + def repWith[A, B](p: Parser[A], sep: Parser[B]): Parser[List[A]] = for (x <- p; val xs <- rep(sep &&& p)) yield x :: xs - def opt[a](p: Parser[a]): Parser[List[a]] = + def opt[A](p: Parser[A]): Parser[List[A]] = (for (x <- p) yield List(x)) ||| succeed(List()) } diff --git a/src/library/scala/util/parsing/SimpleTokenizer.scala b/src/library/scala/util/parsing/SimpleTokenizer.scala index 483edd459e..1edc67a355 100644 --- a/src/library/scala/util/parsing/SimpleTokenizer.scala +++ b/src/library/scala/util/parsing/SimpleTokenizer.scala @@ -16,31 +16,31 @@ package scala.util.parsing * @author Burak Emir * @version 1.0 */ -class SimpleTokenizer(in: Iterator[char], delimiters: String) extends Iterator[String] { +class SimpleTokenizer(in: Iterator[Char], delimiters: String) extends Iterator[String] { - private def max(x: int, y: char): int = if (x > y) x else y + private def max(x: Int, y: Char): Int = if (x > y) x else y val tracing = false - private def delimArray: Array[boolean] = { + private def delimArray: Array[Boolean] = { val ds = List.fromString(delimiters) - val da = new Array[boolean]((0 /: ds)(max) + 1) + val da = new Array[Boolean]((0 /: ds)(max) + 1) for (ch <- ds) { da(ch) = true } da } private val isdelim = delimArray - private def isDelimiter(ch: int) = ch >= 0 && ch < isdelim.length && isdelim(ch) + private def isDelimiter(ch: Int) = ch >= 0 && ch < isdelim.length && isdelim(ch) private val EOI = -1 - private def nextChar(): int = if (in.hasNext) in.next else EOI + private def nextChar(): Int = if (in.hasNext) in.next else EOI - private var ch: int = nextChar + private var ch: Int = nextChar private val buf = new StringBuilder() - def hasNext: boolean = ch != EOI + def hasNext: Boolean = ch != EOI def next(): String = { while (ch <= ' ' && ch != EOI) ch = nextChar() @@ -48,10 +48,10 @@ class SimpleTokenizer(in: Iterator[char], delimiters: String) extends Iterator[S else { buf.setLength(0) if (isDelimiter(ch)) { - buf append ch.asInstanceOf[char]; ch = nextChar() + buf append ch.asInstanceOf[Char]; ch = nextChar() } else { while (ch > ' ' && ch != EOI && !isDelimiter(ch)) { - buf append ch.asInstanceOf[char] + buf append ch.asInstanceOf[Char] ch = nextChar() } } diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala index f48d04ece9..bc39b3514d 100644 --- a/src/library/scala/xml/TextBuffer.scala +++ b/src/library/scala/xml/TextBuffer.scala @@ -27,7 +27,7 @@ class TextBuffer { var ws = true def appendSpace = if(!ws) { ws = true; sb.append(' ') } else {} - def appendChar(c: char) = { ws = false; sb.append( c ) } + def appendChar(c: Char) = { ws = false; sb.append( c ) } /** Appends this string to the text buffer, trimming whitespaces as needed. * diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index d257ea2faf..229f580bcc 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -22,10 +22,12 @@ import collection.mutable.{Set, HashSet} object Utility extends AnyRef with parsing.TokenTests { - /** trims an element - call this method, when you know that it is an element (and not a text node) - * so you know that it will not be trimmed away. With this assumption, the function can - * return a Node, rather than a Seq[Node]. If you don't know, call trimProper and account for - * the fact that you may get back an empty sequence of nodes + /** trims an element - call this method, when you know that it is an + * element (and not a text node) so you know that it will not be trimmed + * away. With this assumption, the function can return a <code>Node</code>, + * rather than a <code>Seq[Node]</code>. If you don't know, call + * <code>trimProper</code> and account for the fact that you may get back + * an empty sequence of nodes. * * precondition: node is not a text node (it might be trimmed) */ @@ -474,7 +476,7 @@ object Utility extends AnyRef with parsing.TokenTests { } nextch() } - i.asInstanceOf[char].toString() + i.asInstanceOf[Char].toString() } } diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala index 9b30ba5ab6..9ccc167fa5 100644 --- a/src/library/scala/xml/dtd/Scanner.scala +++ b/src/library/scala/xml/dtd/Scanner.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -9,7 +9,7 @@ // $Id$ -package scala.xml.dtd; +package scala.xml.dtd /** Scanner for regexps (content models in DTD element declarations) @@ -18,29 +18,28 @@ package scala.xml.dtd; class Scanner extends Tokens with parsing.TokenTests { // zzz constants zzz - final val ENDCH = '\u0000'; + final val ENDCH = '\u0000' // zzz fields zzz - var token:Int = END; - var value:String = _; - - private var it:Iterator[Char] = null; - private var c:Char = 'z'; + var token:Int = END + var value:String = _ + private var it: Iterator[Char] = null + private var c: Char = 'z' /** initializes the scanner on input s */ - final def initScanner( s:String ) = { + final def initScanner(s: String) { //Console.println("[scanner init on \""+s+"\"]"); - value = ""; - it = Iterator.fromString( s ); - token = 1+END; - next; - nextToken; + value = "" + it = Iterator.fromString(s) + token = 1+END + next + nextToken } /** scans the next token */ - final def nextToken:Unit = { - if( token != END ) token = readToken; + final def nextToken { + if (token != END) token = readToken; //Console.println("["+token2string( token )+"]"); } @@ -50,13 +49,14 @@ class Scanner extends Tokens with parsing.TokenTests { final def isIdentChar = ( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')); - final def next = if( it.hasNext ) c = it.next else c = ENDCH; + final def next = if (it.hasNext) c = it.next else c = ENDCH - final def acc( d:char ):Unit = - if( c == d ) next; else error("expected '"+d+"' found '"+c+"' !"); + final def acc(d: Char) { + if (c == d) next else error("expected '"+d+"' found '"+c+"' !"); + } - final def accS( ds:Seq[Char] ):Unit = { - val jt = ds.elements; while( jt.hasNext ) { acc( jt.next ) } + final def accS(ds: Seq[Char]) { + val jt = ds.elements; while (jt.hasNext) { acc(jt.next) } } /* @@ -67,10 +67,8 @@ class Scanner extends Tokens with parsing.TokenTests { */ final def readToken: Int = - if(isSpace(c)) { - while( isSpace(c) ) { - c = it.next; - } + if (isSpace(c)) { + while (isSpace(c)) c = it.next S } else c match { case '(' => next; LPAREN @@ -81,18 +79,16 @@ class Scanner extends Tokens with parsing.TokenTests { case '?' => next; OPT case '|' => next; CHOICE case '#' => next; accS( "PCDATA" ); TOKEN_PCDATA - case ENDCH => END; + case ENDCH => END case _ => - if( isNameStart( c ) ) name; // NAME - else { - error("unexpected character:"+c); END - } + if (isNameStart(c)) name; // NAME + else { error("unexpected character:"+c); END } } final def name = { - val sb = new compat.StringBuilder(); - do { sb.append( c ); next } while ( isNameChar( c ) ) ; - value = sb.toString(); + val sb = new compat.StringBuilder() + do { sb.append(c); next } while (isNameChar(c)); + value = sb.toString() NAME } diff --git a/src/library/scala/xml/parsing/ConstructingHandler.scala b/src/library/scala/xml/parsing/ConstructingHandler.scala index 93f8a07c92..373e5d8662 100644 --- a/src/library/scala/xml/parsing/ConstructingHandler.scala +++ b/src/library/scala/xml/parsing/ConstructingHandler.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -20,7 +20,8 @@ abstract class ConstructingHandler extends MarkupHandler { val preserveWS: Boolean - def elem(pos: int, pre: String, label: String, attrs: MetaData, pscope: NamespaceBinding, nodes: NodeSeq): NodeSeq = + def elem(pos: Int, pre: String, label: String, attrs: MetaData, + pscope: NamespaceBinding, nodes: NodeSeq): NodeSeq = Elem(pre, label, attrs, pscope, nodes:_*) def procInstr(pos: Int, target: String, txt: String) = diff --git a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala index d9a175218e..228ecbba14 100644 --- a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala +++ b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -9,20 +9,21 @@ // $Id$ -package scala.xml.parsing; +package scala.xml.parsing /** default implemenation of markup handler always returns NodeSeq.Empty */ abstract class DefaultMarkupHandler extends MarkupHandler { - def elem(pos: int, pre: String, label: String, attrs: MetaData, scope:NamespaceBinding, args: NodeSeq) = NodeSeq.Empty; + def elem(pos: Int, pre: String, label: String, attrs: MetaData, + scope:NamespaceBinding, args: NodeSeq) = NodeSeq.Empty - def procInstr(pos: Int, target: String, txt: String) = NodeSeq.Empty; + def procInstr(pos: Int, target: String, txt: String) = NodeSeq.Empty - def comment(pos: Int, comment: String ): NodeSeq = NodeSeq.Empty; + def comment(pos: Int, comment: String ): NodeSeq = NodeSeq.Empty - def entityRef(pos: Int, n: String) = NodeSeq.Empty; + def entityRef(pos: Int, n: String) = NodeSeq.Empty - def text(pos: Int, txt:String) = NodeSeq.Empty; + def text(pos: Int, txt:String) = NodeSeq.Empty } diff --git a/src/library/scala/xml/parsing/MarkupHandler.scala b/src/library/scala/xml/parsing/MarkupHandler.scala index 3510794219..f7d1a799d7 100644 --- a/src/library/scala/xml/parsing/MarkupHandler.scala +++ b/src/library/scala/xml/parsing/MarkupHandler.scala @@ -59,7 +59,7 @@ abstract class MarkupHandler extends AnyRef with Logged { //def checkChildren(pos:int, pre: String, label:String,ns:NodeSeq): Unit = {} - def endDTD(n: String): Unit = {} + def endDTD(n: String): Unit = () /** callback method invoked by MarkupParser after start-tag of element. * @@ -68,7 +68,7 @@ abstract class MarkupHandler extends AnyRef with Logged { * @param label the local name * @param attrs the attributes (metadata) */ - def elemStart(pos: int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding): Unit = {} + def elemStart(pos: Int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding): Unit = () /** callback method invoked by MarkupParser after end-tag of element. * @@ -77,7 +77,7 @@ abstract class MarkupHandler extends AnyRef with Logged { * @param label the local name * @param attrs the attributes (metadata) */ - def elemEnd(pos: int, pre: String, label: String): Unit = {} + def elemEnd(pos: Int, pre: String, label: String): Unit = () /** callback method invoked by MarkupParser after parsing an elementm, * between the elemStart and elemEnd callbacks @@ -89,7 +89,7 @@ abstract class MarkupHandler extends AnyRef with Logged { * @param args the children of this element * @return ... */ - def elem(pos: int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, args: NodeSeq): NodeSeq + def elem(pos: Int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, args: NodeSeq): NodeSeq /** callback method invoked by MarkupParser after parsing PI. * @@ -119,11 +119,11 @@ abstract class MarkupHandler extends AnyRef with Logged { // DTD handler methods - def elemDecl(n: String, cmstr: String): Unit = {} + def elemDecl(n: String, cmstr: String): Unit = () - def attListDecl(name: String, attList: List[AttrDecl]): Unit = {} + def attListDecl(name: String, attList: List[AttrDecl]): Unit = () - def parameterEntityDecl(name: String, edef: EntityDef): Unit = { + def parameterEntityDecl(name: String, edef: EntityDef) { //log("parameterEntityDecl("+name+","+edef+")"); edef match { case _:ExtDef if !isValidating => @@ -148,11 +148,9 @@ abstract class MarkupHandler extends AnyRef with Logged { def unparsedEntityDecl(name: String, extID: ExternalID, notat: String): Unit = {} - def notationDecl(notat: String, extID: ExternalID): Unit = - {} + def notationDecl(notat: String, extID: ExternalID): Unit = () - def peReference(name: String): Unit = - decls = PEReference( name ) :: decls + def peReference(name: String) { decls = PEReference(name) :: decls } /** report a syntax error */ def reportSyntaxError(pos: Int, str: String): Unit diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index f3b0173288..0dc0c03fa2 100644 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -238,7 +238,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar //var xEmbeddedBlock = false; /** this method assign the next character to ch and advances in input */ - def nextch: Unit = { + def nextch { if (curInput.hasNext) { ch = curInput.next pos = curInput.pos @@ -949,7 +949,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar /** "rec-xml/#ExtSubset" pe references may not occur within markup declarations */ - def intSubset(): Unit = { + def intSubset() { //Console.println("(DEBUG) intSubset()") xSpace while (']' != ch) @@ -958,7 +958,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar /** <! element := ELEMENT */ - def elementDecl(): Unit = { + def elementDecl() { xToken("EMENT") xSpace val n = xName @@ -1077,7 +1077,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar /** 'N' notationDecl ::= "OTATION" */ - def notationDecl(): Unit = { + def notationDecl() { xToken("OTATION") xSpace val notat = xName @@ -1109,7 +1109,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar /** * report a syntax error */ - def reportSyntaxError(pos: int, str: String): Unit = { + def reportSyntaxError(pos: Int, str: String) { curInput.reportError(pos, str) //error("MarkupParser::synerr") // DEBUG } @@ -1119,10 +1119,11 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar /** * report a syntax error */ - def reportValidationError(pos: int, str: String): Unit = + def reportValidationError(pos: Int, str: String) { curInput.reportError(pos, str) + } - def push(entityName:String) = { + def push(entityName: String) { //Console.println("BEFORE PUSHING "+ch) //Console.println("BEFORE PUSHING "+pos) //Console.print("[PUSHING "+entityName+"]") @@ -1140,7 +1141,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar } */ - def pushExternal(systemId:String) = { + def pushExternal(systemId: String) { //Console.print("BEFORE PUSH, curInput = $"+curInput.descr) //Console.println(" stack = "+inpStack.map { x => "$"+x.descr }) @@ -1156,7 +1157,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar nextch } - def pop() = { + def pop() { curInput = inpStack.head inpStack = inpStack.tail ch = curInput.ch @@ -1170,7 +1171,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar * see spec 3.3.3 * precond: cbuf empty */ - def normalizeAttributeValue(attval: String) = { + def normalizeAttributeValue(attval: String): String = { val s: Seq[Char] = attval val it = s.elements while(it.hasNext) { @@ -1201,7 +1202,8 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar cbuf.append(';') } } - case c => cbuf.append(c) + case c => + cbuf.append(c) } } val name = cbuf.toString() diff --git a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala index 33413db62c..440b6faece 100644 --- a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala +++ b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala @@ -26,7 +26,7 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { final override val isValidating = true - override def log(msg:String) = {} + override def log(msg: String) {} /* override def checkChildren(pos: Int, pre: String, label:String,ns:NodeSeq): Unit = { @@ -43,7 +43,7 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { override def endDTD(n:String) = { rootLabel = n } - override def elemStart(pos: int, pre: String, label: String, attrs: MetaData, scope:NamespaceBinding): Unit = { + override def elemStart(pos: Int, pre: String, label: String, attrs: MetaData, scope:NamespaceBinding) { def advanceDFA(dm:DFAContentModel) = { val trans = dm.dfa.delta(qCurrent) @@ -55,20 +55,20 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { } } // advance in current automaton - log("[qCurrent = "+qCurrent+" visiting "+label+"]"); + log("[qCurrent = "+qCurrent+" visiting "+label+"]") if (qCurrent == -1) { // root log(" checking root") if (label != rootLabel) - reportValidationError(pos, "this element should be "+rootLabel); + reportValidationError(pos, "this element should be "+rootLabel) } else { - log(" checking node"); + log(" checking node") declCurrent.contentModel match { case ANY => case EMPTY => - reportValidationError(pos, "DTD says, no elems, no text allowed here"); + reportValidationError(pos, "DTD says, no elems, no text allowed here") case PCDATA => - reportValidationError(pos, "DTD says, no elements allowed here"); + reportValidationError(pos, "DTD says, no elements allowed here") case m @ MIXED(r) => advanceDFA(m) case e @ ELEMENTS(r) => @@ -84,7 +84,7 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { log(" done now") } - override def elemEnd(pos: int, pre: String, label: String): Unit = { + override def elemEnd(pos: Int, pre: String, label: String) { log(" elemEnd") qCurrent = qStack.head qStack = qStack.tail @@ -94,23 +94,27 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { log(" declCurrent now" + declCurrent) } - final override def elemDecl(name: String, cmstr: String): Unit = - decls = ElemDecl( name, ContentModel.parse(cmstr)) :: decls; + final override def elemDecl(name: String, cmstr: String) { + decls = ElemDecl(name, ContentModel.parse(cmstr)) :: decls + } - final override def attListDecl(name: String, attList: List[AttrDecl]): Unit = - decls = AttListDecl( name, attList) :: decls; + final override def attListDecl(name: String, attList: List[AttrDecl]) { + decls = AttListDecl(name, attList) :: decls + } - final override def unparsedEntityDecl(name: String, extID: ExternalID, notat: String): Unit = { - decls = UnparsedEntityDecl( name, extID, notat) :: decls; + final override def unparsedEntityDecl(name: String, extID: ExternalID, notat: String) { + decls = UnparsedEntityDecl(name, extID, notat) :: decls } - final override def notationDecl(notat: String, extID: ExternalID): Unit = - decls = NotationDecl( notat, extID) :: decls; + final override def notationDecl(notat: String, extID: ExternalID) { + decls = NotationDecl(notat, extID) :: decls; + } - final override def peReference(name: String): Unit = - decls = PEReference( name ) :: decls; + final override def peReference(name: String) { + decls = PEReference(name) :: decls + } /** report a syntax error */ - def reportValidationError(pos: Int, str: String): Unit; + def reportValidationError(pos: Int, str: String): Unit } diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index c7a9961596..bcc48af1e7 100644 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -54,14 +54,14 @@ class XMLEventReader extends Iterator[XMLEvent] { var continue: Boolean = true def myresume = synchronized { - while(continue) { + while (continue) { wait() } continue = true notifyAll } def getAndClearEvent: XMLEvent = synchronized { - while(xmlEvent eq null) { + while (xmlEvent eq null) { wait() } val r = xmlEvent @@ -96,15 +96,15 @@ class XMLEventReader extends Iterator[XMLEvent] { val preserveWS = true val input = XMLEventReader.this.getSource - override def elemStart(pos:int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding) { + override def elemStart(pos: Int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding) { setEvent(ElemStart(pre, label, attrs, scope)); doNotify } - override def elemEnd(pos: int, pre: String, label: String) { + override def elemEnd(pos: Int, pre: String, label: String) { setEvent(ElemEnd(pre, label)); doNotify } - final def elem(pos: int, pre: String, label: String, attrs: MetaData, pscope: NamespaceBinding, nodes: NodeSeq): NodeSeq = + final def elem(pos: Int, pre: String, label: String, attrs: MetaData, pscope: NamespaceBinding, nodes: NodeSeq): NodeSeq = NodeSeq.Empty def procInstr(pos: Int, target: String, txt: String): NodeSeq = { |