summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/scala/Iterable.scala67
-rw-r--r--sources/scala/Iterator.scala82
-rw-r--r--sources/scala/List.scala49
-rw-r--r--sources/scala/Option.scala6
-rw-r--r--sources/scala/Stream.scala13
-rw-r--r--sources/scala/collection/Map.scala10
-rw-r--r--sources/scala/collection/Set.scala31
-rw-r--r--sources/scala/collection/immutable/ListMap.scala7
-rw-r--r--sources/scala/collection/immutable/Stack.scala2
-rw-r--r--sources/scala/collection/mutable/MutableList.scala2
-rw-r--r--sources/scala/collection/mutable/SingleLinkedList.scala2
-rw-r--r--sources/scala/tools/scala4ant/AntTask.scala2
-rw-r--r--sources/scala/tools/scalac/ast/parser/Parser.scala473
-rw-r--r--sources/scala/tools/scalac/ast/parser/Scanner.scala3
-rw-r--r--sources/scala/tools/scalac/ast/parser/Tokens.scala134
-rw-r--r--sources/scala/tools/scalac/typechecker/Analyzer.scala6
16 files changed, 506 insertions, 383 deletions
diff --git a/sources/scala/Iterable.scala b/sources/scala/Iterable.scala
index 5a71864148..58949bae9f 100644
--- a/sources/scala/Iterable.scala
+++ b/sources/scala/Iterable.scala
@@ -15,7 +15,7 @@ package scala;
* elements contained in the collection.
*
* @author Matthias Zenger
- * @version 1.0, 16/07/2003
+ * @version 1.1, 04/02/2004
*/
trait Iterable[+A] {
@@ -25,4 +25,69 @@ trait Iterable[+A] {
* @return the new iterator
*/
def elements: Iterator[A];
+
+ /** Apply a function <code>f</code> to all elements of this
+ * iterable object.
+ *
+ * @param f a function that is applied to every element.
+ */
+ def foreach(f: A => Unit): Unit = elements foreach f;
+
+ /** Apply a predicate <code>p</code> to all elements of this
+ * iterable object and return true, iff the predicate yields
+ * true for all elements.
+ *
+ * @param p the predicate
+ * @returns true, iff the predicate yields true for all elements.
+ */
+ def forall(p: A => Boolean): Boolean = elements forall p;
+
+ /** Apply a predicate <code>p</code> to all elements of this
+ * iterable object and return true, iff there is at least one
+ * element for which <code>p</code> yields true.
+ *
+ * @param p the predicate
+ * @returns true, iff the predicate yields true for at least one element.
+ */
+ def exists(p: A => Boolean): Boolean = elements exists p;
+
+ /** Combines the elements of this list together using the binary
+ * operator <code>op</code>, from left to right, and starting with
+ * the value <code>z</code>.
+ * @return <code>op(... (op(op(z,a0),a1) ...), an)</code> if the list
+ * is <code>List(a0, a1, ..., an)</code>.
+ */
+ def foldLeft[B](z: B)(op: (B, A) => B): B = elements.foldLeft(z)(op);
+
+ /** Combines the elements of this list together using the binary
+ * operator <code>op</code>, from rigth to left, and starting with
+ * the value <code>z</code>.
+ * @return <code>a0 op (... op (an op z)...)</code> if the list
+ * is <code>[a0, a1, ..., an]</code>.
+ */
+ def foldRight[B](z: B)(f: (A, B) => B): B = match {
+ case Nil => z
+ case x :: xs => f(x, xs.foldRight(z)(f))
+ }
+
+ /** Similar to <code>foldLeft</code> but can be used as
+ * an operator with the order of list and zero arguments reversed.
+ * That is, <code>z /: xs</code> is the same as <code>xs foldLeft z</code>
+ */
+ def /:[B](z: B)(f: (B, A) => B): B = foldLeft(z)(f);
+
+ /** An alias for <code>foldRight</code>.
+ * That is, <code>xs :\ z</code> is the same as <code>xs foldRight z</code>
+ */
+ def :\[B](z: B)(f: (A, B) => B): B = foldRight(z)(f);
+
+ /** Transform this iterable object into a list of all elements.
+ *
+ * @return a list which enumerates all elements of this set.
+ */
+ def toList: List[A] = {
+ var res: List[A] = Nil;
+ elements foreach { elem => res = elem :: res; }
+ res.reverse
+ }
}
diff --git a/sources/scala/Iterator.scala b/sources/scala/Iterator.scala
index 0f02c1cd05..40528e9d58 100644
--- a/sources/scala/Iterator.scala
+++ b/sources/scala/Iterator.scala
@@ -13,8 +13,8 @@ package scala;
/** The <code>Iterator</code> object provides various functions for
* creating specialized iterators.
*
- * @author Martin Odersky
- * @version 1.0, 16/07/2003
+ * @author Martin Odersky, Matthias Zenger
+ * @version 1.1, 04/02/2004
*/
object Iterator {
@@ -23,35 +23,36 @@ object Iterator {
def next: a = error("next on empty iterator");
}
- def fromSeq[a](xs: a*) = xs.elements;
+ def fromValues[a](xs: a*) = xs.elements;
def fromArray[a](xs: Array[a]) = new Iterator[a] {
private var i = 0;
- def hasNext: Boolean =
- i < xs.length;
+ def hasNext: Boolean = i < xs.length;
def next: a =
if (i < xs.length) { val x = xs(i) ; i = i + 1 ; x }
else error("next on empty iterator");
}
+ def fromString(str: String): Iterator[Char] = new Iterator[Char] {
+ private var i = 0;
+ private val len = str.length();
+ def hasNext = i < len;
+ def next = str charAt i;
+ }
+
def range(lo: Int, end: Int) = new Iterator[Int] {
private var i = lo;
- def hasNext: Boolean =
- i < end;
+ def hasNext: Boolean = i < end;
def next: Int =
- if (i < end) { i = i + 1 ; i - 1 }
- else error("next on empty iterator");
+ if (i < end) { i = i + 1 ; i - 1 } else error("next on empty iterator");
def head: Int =
- if (i < end) i
- else error("head on empty iterator");
+ if (i < end) i else error("head on empty iterator");
}
def from(lo: Int) = new Iterator[Int] {
private var i = 0;
- def hasNext: Boolean =
- true;
- def next: Int =
- { i = i + 1 ; i - 1 }
+ def hasNext: Boolean = true;
+ def next: Int = { i = i + 1 ; i - 1 }
}
}
@@ -60,23 +61,23 @@ object Iterator {
* if there is a next element available, and a <code>next</code> method
* which returns the next element and discards it from the iterator.
*
- * @author Martin Odersky
- * @version 1.0, 16/07/2003
+ * @author Martin Odersky, Matthias Zenger
+ * @version 1.1, 04/02/2004
*/
trait Iterator[+a] with Iterable[a] {
def hasNext: Boolean;
def next: a;
- def foreach(f: a => Unit): Unit =
+ override def foreach(f: a => Unit): Unit =
while (hasNext) { f(next) }
- def forall(p: a => Boolean): Boolean = {
+ override def forall(p: a => Boolean): Boolean = {
var res = true;
while (res && hasNext) { res = p(next); }
res;
}
- def exists(p: a => Boolean): Boolean = {
+ override def exists(p: a => Boolean): Boolean = {
var res = false;
while (!res && hasNext) { res = p(next); }
res;
@@ -97,15 +98,16 @@ trait Iterator[+a] with Iterable[a] {
def next = f(Iterator.this.next)
}
- def foldLeft[b] ( z:b ) ( f: (b,a)=>b ): b = {
+ override def foldLeft[b](z: b)(f: (b, a) => b): b = {
var acc = z;
while( hasNext ) {
- acc = f( acc, next)
+ acc = f(acc, next)
}
acc
}
- def /:[b](z: b)(f: (b, a) => b): b = foldLeft(z)(f);
+ override def foldRight[b](z: b)(f: (a, b) => b): b =
+ if (hasNext) f(next, foldRight(z)(f)) else z;
def append[b >: a](that: Iterator[b]) = new Iterator[b] {
def hasNext = Iterator.this.hasNext || that.hasNext;
@@ -158,5 +160,37 @@ trait Iterator[+a] with Iterable[a] {
}
def elements: Iterator[a] = this;
-}
+ def duplicate: Pair[Iterator[a], Iterator[a]] = {
+ var xs: List[a] = Nil;
+ var ahead: Iterator[a] = null;
+ class Partner extends Iterator[a] {
+ var ys: List[a] = Nil;
+ def hasNext: Boolean = Iterator.this.synchronized {
+ ((this == ahead) && Iterator.this.hasNext) ||
+ ((this != ahead) && (!xs.isEmpty || !ys.isEmpty || Iterator.this.hasNext));
+ }
+ def next: a = Iterator.this.synchronized {
+ if (this == ahead) {
+ val e = Iterator.this.next;
+ xs = e :: xs; e
+ } else {
+ if (ys.isEmpty) {
+ ys = xs.reverse;
+ xs = Nil;
+ }
+ ys match {
+ case Nil =>
+ val e = Iterator.this.next;
+ ahead = this;
+ xs = e :: xs; e
+ case z :: zs =>
+ ys = zs; z
+ }
+ }
+ }
+ }
+ ahead = new Partner;
+ Pair(ahead, new Partner)
+ }
+}
diff --git a/sources/scala/List.scala b/sources/scala/List.scala
index 35c0cf0d6a..efbc84edd3 100644
--- a/sources/scala/List.scala
+++ b/sources/scala/List.scala
@@ -123,6 +123,34 @@ object List {
}
res.reverse
}
+
+ /** Returns the given string as a list of characters.
+ * @param str the string to convert.
+ * @return the string as a list of characters.
+ */
+ def fromString(str: String): List[Char] = {
+ var res: List[Char] = Nil;
+ var i = str.length();
+ while (i > 0) {
+ i = i - 1;
+ res = str.charAt(i) :: res;
+ }
+ res
+ }
+
+ /** Returns the given list of characters as a string.
+ * @param xs the list to convert.
+ * @return the list in form of a string.
+ */
+ def toString(xs: List[Char]): String = {
+ val sb = new StringBuffer();
+ var ys = xs;
+ while (!ys.isEmpty) {
+ sb.append(ys.head);
+ ys = ys.tail;
+ }
+ sb.toString()
+ }
}
@@ -376,7 +404,7 @@ trait List[+a] extends Seq[a] {
* (while respecting the order of the elements).
* @param f the treatment to apply to each element.
*/
- def foreach(f: a => Unit): Unit = match {
+ override def foreach(f: a => Unit): Unit = match {
case Nil => ()
case head :: tail => f(head); tail foreach f
};
@@ -487,7 +515,7 @@ trait List[+a] extends Seq[a] {
* @param p the test predicate.
* @return True iff all elements of this list satisfy the predicate <code>p</code>.
*/
- def forall(p: a => Boolean): Boolean =
+ override def forall(p: a => Boolean): Boolean =
isEmpty || (p(head) && (tail forall p));
/** Tests the existence in this list of an element that satisfies the predicate
@@ -496,7 +524,7 @@ trait List[+a] extends Seq[a] {
* @return true iff there exists an element in this list that satisfies
* the predicate <code>p</code>.
*/
- def exists(p: a => Boolean): Boolean =
+ override def exists(p: a => Boolean): Boolean =
!isEmpty && (p(head) || (tail exists p));
/** Find and return the first element of the list satisfying a
@@ -516,7 +544,7 @@ trait List[+a] extends Seq[a] {
* @return <code>op(... (op(op(z,a0),a1) ...), an)</code> if the list
* is <code>[a0, a1, ..., an]</code>.
*/
- def foldLeft[b](z: b)(f: (b, a) => b): b = match {
+ override def foldLeft[b](z: b)(f: (b, a) => b): b = match {
case Nil => z
case x :: xs => xs.foldLeft[b](f(z, x))(f)
};
@@ -527,22 +555,11 @@ trait List[+a] extends Seq[a] {
* @return <code>a0 op (... op (an op z)...)</code> if the list
* is <code>[a0, a1, ..., an]</code>.
*/
- def foldRight[b](z: b)(f: (a, b) => b): b = match {
+ override def foldRight[b](z: b)(f: (a, b) => b): b = match {
case Nil => z
case x :: xs => f(x, xs.foldRight(z)(f))
};
- /** Similar to <code>foldLeft</code> but can be used as
- * an operator with the order of list and zero arguments reversed.
- * That is, <code>z /: xs</code> is the same as <code>xs foldLeft z</code>
- */
- def /:[b](z: b)(f: (b, a) => b): b = foldLeft(z)(f);
-
- /** An alias for <code>foldRight</code>.
- * That is, <code>xs :\ z</code> is the same as <code>xs foldRight z</code>
- */
- def :\[b](z: b)(f: (a, b) => b): b = foldRight(z)(f);
-
def reduceLeft[b >: a](f: (b, b) => b): b = this match {
case Nil => error("Nil.reduceLeft")
case x :: xs => ((xs: List[b]) foldLeft (x: b))(f)
diff --git a/sources/scala/Option.scala b/sources/scala/Option.scala
index 1407f00b4f..e0a5e2d999 100644
--- a/sources/scala/Option.scala
+++ b/sources/scala/Option.scala
@@ -50,17 +50,17 @@ trait Option[+A] extends Iterable[A] {
case Some(x) => if (p(x)) Some(x) else None
}
- def foreach(f: A => Unit): Unit = match {
+ override def foreach(f: A => Unit): Unit = match {
case None => ()
case Some(x) => f(x)
}
def elements: Iterator[A] = match {
case None => Iterator.empty
- case Some(x) => Iterator.fromSeq(x)
+ case Some(x) => Iterator.fromValues(x)
}
- def toList: List[A] = match {
+ override def toList: List[A] = match {
case None => List()
case Some(x) => List(x)
}
diff --git a/sources/scala/Stream.scala b/sources/scala/Stream.scala
index 7714ca7f41..1898848a38 100644
--- a/sources/scala/Stream.scala
+++ b/sources/scala/Stream.scala
@@ -61,7 +61,7 @@ trait Stream[+a] extends Seq[a] {
if (isEmpty) Stream.empty
else Stream.cons(f(head), tail.map(f));
- def foreach(f: a => unit): unit =
+ override def foreach(f: a => unit): unit =
if (isEmpty) {}
else { f(head); tail.foreach(f) }
@@ -70,23 +70,20 @@ trait Stream[+a] extends Seq[a] {
else if (p(head)) Stream.cons(head, tail.filter(p))
else tail.filter(p);
- def forall(p: a => Boolean): Boolean =
+ override def forall(p: a => Boolean): Boolean =
isEmpty || (p(head) && tail.forall(p));
- def exists(p: a => Boolean): Boolean =
+ override def exists(p: a => Boolean): Boolean =
!isEmpty && (p(head) || tail.exists(p));
- def foldLeft[b](z: b)(f: (b, a) => b): b =
+ override def foldLeft[b](z: b)(f: (b, a) => b): b =
if (isEmpty) z
else tail.foldLeft[b](f(z, head))(f);
- def foldRight[b](z: b)(f: (a, b) => b): b =
+ override def foldRight[b](z: b)(f: (a, b) => b): b =
if (isEmpty) z
else f(head, tail.foldRight(z)(f));
- def /:[b](z: b)(f: (b, a) => b): b = foldLeft(z)(f);
- def :/[b](z: b)(f: (a, b) => b): b = foldRight(z)(f);
-
def reduceLeft[b >: a](f: (b, b) => b): b =
if (isEmpty) error("Stream.empty.reduceLeft")
else ((tail: Stream[b]) foldLeft (head: b))(f);
diff --git a/sources/scala/collection/Map.scala b/sources/scala/collection/Map.scala
index ff156cf3b5..1d226b4560 100644
--- a/sources/scala/collection/Map.scala
+++ b/sources/scala/collection/Map.scala
@@ -132,16 +132,6 @@ trait Map[A, +B] with PartialFunction[A, B]
case Pair(key, value) => p(key, value)
}
- /** Creates a list of all (key, value) mappings.
- *
- * @return the list of all mappings
- */
- def toList: List[Pair[A, B]] = {
- var res: List[Pair[A, B]] = Nil;
- elements.foreach { mapping => res = mapping :: res; };
- res;
- }
-
/** Compares two maps structurally; i.e. checks if all mappings
* contained in this map are also contained in the other map,
* and vice versa.
diff --git a/sources/scala/collection/Set.scala b/sources/scala/collection/Set.scala
index 8cec4c200c..59b8eed07b 100644
--- a/sources/scala/collection/Set.scala
+++ b/sources/scala/collection/Set.scala
@@ -59,37 +59,6 @@ trait Set[A] with Function1[A, Boolean] with Iterable[A] {
*/
def subsetOf(that: Set[A]): Boolean = forall(that.contains);
- /** Execute the statement <code>f</code> for every element in this set.
- *
- * @param f a function that is applied to every element in this set.
- */
- def foreach(f: A => Unit): Unit = elements.foreach(f);
-
- /** Checks if a given predicate is true for all elements in this set.
- *
- * @param p the predicate
- * @returns true, iff the predicate yields true for all elements.
- */
- def forall(p: A => Boolean): Boolean = elements.forall(p);
-
- /** Checks if a given predicate is true for at least one element
- * in this set.
- *
- * @param p the predicate
- * @returns true, iff the predicate yields true for at least one element.
- */
- def exists(p: A => Boolean): Boolean = elements.exists(p);
-
- /** Transform this set into a list of all elements.
- *
- * @return a list which enumerates all elements of this set.
- */
- def toList: List[A] = {
- var res: List[A] = Nil;
- elements.foreach { elem => res = elem :: res; }
- res;
- }
-
/** Compares this set with another object and returns true, iff the
* other object is also a set which contains the same elements as
* this set.
diff --git a/sources/scala/collection/immutable/ListMap.scala b/sources/scala/collection/immutable/ListMap.scala
index 5109188a46..dd6e981c9b 100644
--- a/sources/scala/collection/immutable/ListMap.scala
+++ b/sources/scala/collection/immutable/ListMap.scala
@@ -12,13 +12,6 @@ package scala.collection.immutable;
object ListMap {
def Empty[A, B] = new ListMap[A, B];
-
- /** bug: crashes analzyer with NullPointerException */
- /*
- def fromList[A,B]( list:List[Pair[A,B]] ):ListMap[A,B] =
- list.foldLeft (Empty[A,B]) { ( x:ListMap[A,B],y:Pair[A,B] ) =>
- x.update( y._1, y._2 ) };
- */
}
/** This class implements immutable maps using a list-based data
diff --git a/sources/scala/collection/immutable/Stack.scala b/sources/scala/collection/immutable/Stack.scala
index e648eace40..7fe660e2c0 100644
--- a/sources/scala/collection/immutable/Stack.scala
+++ b/sources/scala/collection/immutable/Stack.scala
@@ -97,7 +97,7 @@ class Stack[+A] with Seq[A] {
*
* @return the created list.
*/
- def toList: List[A] = Nil;
+ override def toList: List[A] = Nil;
/** Compares this stack with the given object.
*
diff --git a/sources/scala/collection/mutable/MutableList.scala b/sources/scala/collection/mutable/MutableList.scala
index 8996da246a..0ce691ef61 100644
--- a/sources/scala/collection/mutable/MutableList.scala
+++ b/sources/scala/collection/mutable/MutableList.scala
@@ -58,7 +58,7 @@ class MutableList[A] with Seq[A] with PartialFunction[Int, A] {
def elements: Iterator[A] =
if (first == null) Nil.elements else first.elements;
- def toList: List[A] = if (first == null) Nil else first.toList;
+ override def toList: List[A] = if (first == null) Nil else first.toList;
override def toString() = toList.toString();
}
diff --git a/sources/scala/collection/mutable/SingleLinkedList.scala b/sources/scala/collection/mutable/SingleLinkedList.scala
index 1f0ee45bae..30d7796df2 100644
--- a/sources/scala/collection/mutable/SingleLinkedList.scala
+++ b/sources/scala/collection/mutable/SingleLinkedList.scala
@@ -56,7 +56,7 @@ abstract class SingleLinkedList[A, This <: SingleLinkedList[A, This]]: This with
}
}
- def toList: List[A] =
+ override def toList: List[A] =
if (next == null) (elem :: Nil) else (elem :: next.toList);
}
diff --git a/sources/scala/tools/scala4ant/AntTask.scala b/sources/scala/tools/scala4ant/AntTask.scala
index 11381176c7..569cdd85fc 100644
--- a/sources/scala/tools/scala4ant/AntTask.scala
+++ b/sources/scala/tools/scala4ant/AntTask.scala
@@ -116,7 +116,7 @@ class AntTask extends Javac {
if( force ) {
val newCompileList = new Array[File]( compileList.length + files.length );
System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
- var j = 0, i = 0;
+ var j, i = 0;
def handleFile( theFile:String ):unit = { // this, because wile create anon-class -> access violation
if( hasLegalSuffix(sfx, theFile )) {
diff --git a/sources/scala/tools/scalac/ast/parser/Parser.scala b/sources/scala/tools/scalac/ast/parser/Parser.scala
index bd22ef19f2..b1fb1c8bcb 100644
--- a/sources/scala/tools/scalac/ast/parser/Parser.scala
+++ b/sources/scala/tools/scalac/ast/parser/Parser.scala
@@ -16,6 +16,7 @@ import java.util.{Map, Stack, ArrayList, LinkedList};
import java.lang.{Integer, Long, Float, Double};
import scala.Iterator;
import scala.tools.scalac.util.NewArray;
+import scala.collection.mutable.Buffer;
package scala.tools.scalac.ast.parser {
@@ -79,7 +80,7 @@ class Parser(unit: Unit) {
nparens = nparens + 1;
case LBRACE =>
nbraces = nbraces + 1;
- case _ =>
+ case _ =>
}
s.nextToken();
}
@@ -102,7 +103,7 @@ class Parser(unit: Unit) {
if (s.token != token) {
val errpos = if ((s.pos >>> Position.COLUMN_BITS) >
(s.lastpos >>> Position.COLUMN_BITS)) s.lastpos
- else s.pos;
+ else s.pos;
syntaxError(errpos, s.token2string(token) + " expected but " +
s.token2string(s.token) + " found.", true);
}
@@ -141,9 +142,9 @@ class Parser(unit: Unit) {
def isExprIntro(): boolean = s.token match {
case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT |
- STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL | IDENTIFIER |
- THIS | SUPER | IF | FOR | NEW | USCORE | TRY | WHILE |
- DO | RETURN | THROW | LPAREN | LBRACE =>
+ STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL | IDENTIFIER |
+ THIS | SUPER | IF | FOR | NEW | USCORE | TRY | WHILE |
+ DO | RETURN | THROW | LPAREN | LBRACE =>
true;
case _ =>
false;
@@ -201,12 +202,12 @@ class Parser(unit: Unit) {
while (true) {
val templ = make.Template(pos, Tree.EMPTY_ARRAY, stats);
pkg match {
- case Tree$Select(qual, name) =>
- stats = NewArray.Tree(
- make.PackageDef(pos, make.Ident(pkg.pos, name), templ));
- pkg = qual;
- case _ =>
- return make.PackageDef(pos, pkg, templ);
+ case Tree$Select(qual, name) =>
+ stats = NewArray.Tree(
+ make.PackageDef(pos, make.Ident(pkg.pos, name), templ));
+ pkg = qual;
+ case _ =>
+ return make.PackageDef(pos, pkg, templ);
}
}
null//dummy
@@ -218,23 +219,23 @@ class Parser(unit: Unit) {
if (isExpr) {
if (op.isLeftAssoc()) {
make.Apply(
- pos,
- make.Select(pos, left, NameTransformer.encode(op)),
- NewArray.Tree(right));
+ pos,
+ make.Select(pos, left, NameTransformer.encode(op)),
+ NewArray.Tree(right));
} else {
val x: Name = fresh();
make.Block(
- pos,
- NewArray.Tree(
+ pos,
+ NewArray.Tree(
make.ValDef(pos, 0, x, Tree.Empty, left),
make.Apply(
- pos,
+ pos,
make.Select(pos, right, NameTransformer.encode(op)),
NewArray.Tree(make.Ident(left.pos, x)))));
}
} else {
make.Apply(
- pos,
+ pos,
make.Ident(pos, NameTransformer.encode(op).toTypeName()),
NewArray.Tree(left, right));
}
@@ -279,8 +280,8 @@ class Parser(unit: Unit) {
make.ValDef(
pat.pos, Modifiers.PARAM, name1, Tree.Empty, Tree.Empty)),
body);
- case _ =>
- make.Visitor(pos, NewArray.CaseDef(
+ case _ =>
+ make.Visitor(pos, NewArray.CaseDef(
make.CaseDef(pos, pat, Tree.Empty, body)));
}
}
@@ -289,13 +290,13 @@ class Parser(unit: Unit) {
case Tree$PatDef(mods, pat, rhs) =>
if (enums.length == 1) {
makeFor1(pos, mapName, pat, rhs, body);
- } else {
- val newenums = new Array[Tree](enums.length - 1);
+ } else {
+ val newenums = new Array[Tree](enums.length - 1);
enums(1) match {
case Tree$PatDef(mods2, pat2, rhs2) =>
System.arraycopy(enums, 1, newenums, 0, newenums.length);
makeFor1(
- pos, flatmapName, pat, rhs,
+ pos, flatmapName, pat, rhs,
makeFor(enums(1).pos, newenums, mapName, flatmapName, body));
case _ =>
System.arraycopy(enums, 2, newenums, 1, newenums.length - 1);
@@ -304,7 +305,7 @@ class Parser(unit: Unit) {
makeFor1(enums(1).pos, Names.filter, pat.duplicate(), rhs, enums(1)));
makeFor(pos, newenums, mapName, flatmapName, body);
}
- }
+ }
}
}
@@ -606,7 +607,7 @@ class Parser(unit: Unit) {
val ts = new myTreeList();
ts.append(t);
if (s.token == LPAREN || s.token == LBRACE)
- ts.append(argumentExprs());
+ ts.append(argumentExprs());
make.Apply(pos, symt, ts.toArray());
} else {
t
@@ -671,7 +672,7 @@ class Parser(unit: Unit) {
return make.FunType(pos, ts.toArray(), typ());
} else {
accept(RPAREN);
- }
+ }
}
} else {
t = type1()
@@ -711,12 +712,12 @@ class Parser(unit: Unit) {
val pos = s.pos;
var t: Tree =
if (s.token == LPAREN) {
- s.nextToken();
- val t = typ();
- accept(RPAREN);
- t
+ s.nextToken();
+ val t = typ();
+ accept(RPAREN);
+ t
} else {
- convertToTypeId(stableRef(false, true));
+ convertToTypeId(stableRef(false, true));
}
while (true) {
if (s.token == HASH)
@@ -724,7 +725,7 @@ class Parser(unit: Unit) {
else if (s.token == LBRACKET)
t = make.AppliedType(pos, t, typeArgs());
else
- return t;
+ return t;
}
null; //dummy
}
@@ -776,18 +777,18 @@ class Parser(unit: Unit) {
* ResultExpr ::= Bindings `=>' Block
* | Expr1
* Expr1 ::= (' Expr `)' Expr [[`;'] else Expr]
- * | try `{' block `}' [catch Expr] [finally Expr]
- * | while `(' Expr `)' Expr
- * | do Expr [`;'] while `(' Expr `)'
- * | for `(' Enumerators `)' (do | yield) Expr
- * | throw Expr
- * | return [Expr]
- * | [SimpleExpr `.'] Id `=' Expr
- * | SimpleExpr ArgumentExprs `=' Expr
- * | PostfixExpr [`:' Type1]
- * Bindings ::= Id [`:' Type1]
- * | `(' [Binding {`,' Binding}] `)'
- * Binding ::= Id [`:' Type]
+ * | try `{' block `}' [catch Expr] [finally Expr]
+ * | while `(' Expr `)' Expr
+ * | do Expr [`;'] while `(' Expr `)'
+ * | for `(' Enumerators `)' (do | yield) Expr
+ * | throw Expr
+ * | return [Expr]
+ * | [SimpleExpr `.'] Id `=' Expr
+ * | SimpleExpr ArgumentExprs `=' Expr
+ * | PostfixExpr [`:' Type1]
+ * Bindings ::= Id [`:' Type1]
+ * | `(' [Binding {`,' Binding}] `)'
+ * Binding ::= Id [`:' Type]
*/
def expr(): Tree =
@@ -801,8 +802,8 @@ class Parser(unit: Unit) {
accept(RPAREN);
val thenp = expr();
val elsep =
- if (s.token == ELSE) { s.nextToken(); expr() }
- else Tree.Empty;
+ if (s.token == ELSE) { s.nextToken(); expr() }
+ else Tree.Empty;
make.If(pos, cond, thenp, elsep)
} else if (s.token == TRY) {
val pos = s.skipToken();
@@ -811,10 +812,10 @@ class Parser(unit: Unit) {
accept(RBRACE);
val catcher =
if (s.token == CATCH) { s.nextToken(); expr() }
- else Tree.Empty;
+ else Tree.Empty;
val finalizer =
if (s.token == FINALLY) { s.nextToken(); expr() }
- else Tree.Empty;
+ else Tree.Empty;
makeTry(pos, body, catcher, finalizer)
} else if (s.token == WHILE) {
val lname = Name.fromString("label$" + loopNestingDepth);
@@ -850,8 +851,8 @@ class Parser(unit: Unit) {
} else if (s.token == RETURN) {
val pos = s.skipToken();
val e =
- if (isExprIntro()) expr()
- else make.Block(pos, Tree.EMPTY_ARRAY);
+ if (isExprIntro()) expr()
+ else make.Block(pos, Tree.EMPTY_ARRAY);
make.Return(pos, e)
} else if (s.token == THROW) {
val pos = s.skipToken();
@@ -862,7 +863,7 @@ class Parser(unit: Unit) {
t match {
case Tree$Ident(_) | Tree$Select(_, _) | Tree$Apply(_, _) =>
t = make.Assign(s.skipToken(), t, expr());
- case _ =>
+ case _ =>
}
} else if (s.token == COLON) {
val pos = s.skipToken();
@@ -883,9 +884,9 @@ class Parser(unit: Unit) {
}
}
if (s.token == ARROW) {
- val arrowpos = s.skipToken();
+ val arrowpos = s.skipToken();
t = make.Function(arrowpos, convertToParams(t),
- if (isInBlock) block(arrowpos) else expr());
+ if (isInBlock) block(arrowpos) else expr());
}
t
}
@@ -949,10 +950,10 @@ class Parser(unit: Unit) {
t = stableRef(true, false);
case LPAREN =>
val pos = s.skipToken();
- if (s.token == RPAREN) {
+ if (s.token == RPAREN) {
s.nextToken();
t = make.Block(pos, Tree.EMPTY_ARRAY);
- } else {
+ } else {
t = expr();
if (s.token == COMMA) {
val commapos = s.skipToken();
@@ -1021,15 +1022,15 @@ class Parser(unit: Unit) {
val pos = accept(LBRACE);
val res =
if (s.token == CASE) {
- val stats = new myTreeList();
- do {
- stats.append(caseClause());
- } while (s.token == CASE);
- make.Visitor(pos,
- stats.copyTo(new Array[Tree$CaseDef](stats.length()))
- .asInstanceOf[Array[Tree$CaseDef]])
+ val stats = new myTreeList();
+ do {
+ stats.append(caseClause());
+ } while (s.token == CASE);
+ make.Visitor(pos,
+ stats.copyTo(new Array[Tree$CaseDef](stats.length()))
+ .asInstanceOf[Array[Tree$CaseDef]])
} else {
- block(pos);
+ block(pos);
}
accept(RBRACE);
local = local - 1;
@@ -1087,10 +1088,10 @@ class Parser(unit: Unit) {
NewArray.CaseDef(
make.CaseDef(
rhs.pos, pat.duplicate(),
- Tree.Empty, gen.mkBooleanLit(s.pos, true)),
+ Tree.Empty, gen.mkBooleanLit(s.pos, true)),
make.CaseDef(
rhs.pos, make.Ident(rhs.pos, Names.PATTERN_WILDCARD),
- Tree.Empty, gen.mkBooleanLit(s.pos, false))))));
+ Tree.Empty, gen.mkBooleanLit(s.pos, false))))));
make.PatDef(pos, 0, pat, rhs)
}
@@ -1172,7 +1173,7 @@ class Parser(unit: Unit) {
p match {
case Tree$Ident(name) =>
if (name == Names.PATTERN_WILDCARD) return pattern3()
- case _ =>
+ case _ =>
}
make.Bind(s.skipToken(), p.asInstanceOf[Tree$Ident].name, pattern3());
} else {
@@ -1192,8 +1193,8 @@ class Parser(unit: Unit) {
val zname = fresh();
val zvar = make.Ident(s.pos, zname);
return make.Bind(
- s.pos, zname,
- pN.flattenAlternative(
+ s.pos, zname,
+ pN.flattenAlternative(
make.Alternative(s.pos, NewArray.Tree(
make.Sequence(s.pos, Tree.EMPTY_ARRAY),
pN.flattenSequence(make.Sequence(s.pos, NewArray.Tree(
@@ -1203,7 +1204,7 @@ class Parser(unit: Unit) {
val zname = fresh();
val zvar = make.Ident(s.pos, zname);
return make.Bind(
- s.pos, zname,
+ s.pos, zname,
pN.flattenSequence(make.Sequence(s.pos, NewArray.Tree(
top,
pN.flattenAlternative(make.Alternative(s.pos, NewArray.Tree(
@@ -1390,7 +1391,7 @@ class Parser(unit: Unit) {
s.nextToken();
mods = mods | Modifiers.REPEATED;
tp = make.AppliedType(
- tp.pos,
+ tp.pos,
scalaDot(tp.pos, Names.Seq.toTypeName()),
NewArray.Tree(tp));
}
@@ -1538,141 +1539,170 @@ class Parser(unit: Unit) {
false
}
- /** Def ::= val PatDef {`,' PatDef}
- * | var VarDef {`,' VarDef}
- * | def FunDef {`,' FunDef}
- * | type TypeDef {`,' TypeDef}
- * | ClsDef
- * Dcl ::= val ValDcl {`,' ValDcl}
- * | var ValDcl {`,' ValDcl}
- * | def FunDcl {`,' FunDcl}
- * | type TypeDcl {`,' TypeDcl}
- */
+ /** Def ::= val PatDef
+ * | var VarDef
+ * | def FunDef
+ * | type TypeDef
+ * | ClsDef
+ * Dcl ::= val ValDcl
+ * | var ValDcl
+ * | def FunDcl
+ * | type TypeDcl
+ */
def defOrDcl(mods: int): Array[Tree] = {
- val ts = new myTreeList();
s.token match {
case VAL =>
- do {
- s.nextToken();
- ts.append(popComment(patDefOrDcl(mods)));
- } while (s.token == COMMA);
- ts.toArray()
+ patDefOrDcl(mods);
case VAR =>
- do {
- s.nextToken();
- ts.append(popComment(varDefOrDcl(mods)));
- } while (s.token == COMMA);
- ts.toArray()
+ varDefOrDcl(mods);
case DEF =>
- do {
- s.nextToken();
- ts.append(popComment(funDefOrDcl(mods)));
- } while (s.token == COMMA);
- ts.toArray()
+ funDefOrDcl(mods);
case TYPE =>
- do {
- s.nextToken();
- ts.append(popComment(typeDefOrDcl(mods)));
- } while (s.token == COMMA);
- ts.toArray()
+ s.nextToken();
+ val ts = new myTreeList();
+ ts.append(popComment(typeDefOrDcl(mods)));
+ ts.toArray()
case _ =>
clsDef(mods)
}
}
/** ClsDef ::= ([case] class | trait) ClassDef {`,' ClassDef}
- * | [case] object ObjectDef {`,' ObjectDef}
- */
- def clsDef(_mods: int): Array[Tree] = {
- var mods = _mods;
- val ts = new myTreeList();
+ * | [case] object ObjectDef {`,' ObjectDef}
+ */
+ def clsDef(mods: int): Array[Tree] = {
s.token match {
- case CLASS | CASECLASS | TRAIT =>
- if (s.token == CASECLASS)
- mods = mods | Modifiers.CASE;
- else if (s.token == TRAIT)
- mods = mods | Modifiers.TRAIT | Modifiers.ABSTRACT;
- do {
- s.nextToken();
- ts.append(classDef(mods));
- } while (s.token == COMMA);
- ts.toArray()
- case OBJECT | CASEOBJECT =>
- if (s.token == CASEOBJECT)
- mods = mods | Modifiers.CASE;
- do {
- s.nextToken();
- ts.append(objectDef(mods));
- } while (s.token == COMMA);
- ts.toArray()
+ case TRAIT =>
+ classDef(mods | Modifiers.TRAIT | Modifiers.ABSTRACT);
+ case CLASS =>
+ classDef(mods);
+ case CASECLASS =>
+ classDef(mods | Modifiers.CASE);
+ case OBJECT =>
+ objectDef(mods);
+ case CASEOBJECT =>
+ objectDef(mods | Modifiers.CASE);
case _ =>
NewArray.Tree(syntaxError("illegal start of definition", true))
}
}
/** PatDef ::= Pattern2 [`:' Type] `=' Expr
- * ValDcl ::= Id `:' Type
- */
- def patDefOrDcl(mods: int): Tree = {
- val pos = s.pos;
- val pat = pattern2();
- val tp = if (s.token == COLON) typedOpt() else Tree.Empty;
- pat match {
- case Tree$Ident(name) =>
- if (tp == Tree.Empty || s.token == EQUALS)
- make.ValDef(pos, mods, name, tp, equalsExpr())
- else
- make.ValDef(pos, mods | Modifiers.DEFERRED, name, tp, Tree.Empty)
- case _ =>
- make.PatDef(pos, mods, pat, equalsExpr())
- }
+ * ValDcl ::= Id `:' Type
+ */
+ def patDefOrDcl(mods: int): Array[Tree] = {
+ var lhs = new myTreeList();
+ do {
+ s.nextToken();
+ lhs.append(pattern2());
+ } while (s.token == COMMA);
+ val tp = typedOpt();
+ val rhs = if (tp == Tree.Empty || s.token == EQUALS) equalsExpr() else Tree.Empty;
+ val ls = lhs.toArray();
+ val ts = new myTreeList();
+ var i = 0;
+ if (rhs == Tree.Empty) {
+ while (i < ls.length) {
+ ls(i) match {
+ case Tree$Ident(name) =>
+ ts.append(popComment(
+ make.ValDef(ls(i).pos, mods | Modifiers.DEFERRED, name, tp.duplicate(), Tree.Empty)));
+ case t =>
+ syntaxError(t.pos, "cannot defer pattern definition", false);
+ }
+ i = i + 1;
+ }
+ } else {
+ while (i < ls.length) {
+ ls(i) match {
+ case Tree$Ident(name) =>
+ ts.append(popComment(
+ make.ValDef(ls(i).pos, mods, name, tp.duplicate(), rhs.duplicate())));
+ case t =>
+ ts.append(popComment(
+ make.PatDef(t.pos, mods, t, rhs.duplicate())));
+ }
+ i = i + 1;
+ }
+ }
+ ts.toArray()
}
/** VarDef ::= Id [`:' Type] `=' Expr
- * | Id `:' Type `=' `_'
- * VarDcl ::= Id `:' Type
- */
- def varDefOrDcl(mods: int): Tree = {
- val pos = s.pos;
- val name = ident();
- val tp = typedOpt();
- if (tp == Tree.Empty || s.token == EQUALS) {
- accept(EQUALS);
- val rhs =
- if (tp != Tree.Empty && s.token == USCORE) { s.nextToken(); Tree.Empty }
- else expr();
- make.ValDef(pos, mods | Modifiers.MUTABLE, name, tp, rhs)
- } else {
- make.ValDef(pos, mods | Modifiers.MUTABLE | Modifiers.DEFERRED,
- name, tp, Tree.Empty);
- }
+ * | Id `:' Type `=' `_'
+ * VarDcl ::= Id `:' Type
+ */
+ def varDefOrDcl(mods: int): Array[Tree] = {
+ var newmods = mods | Modifiers.MUTABLE;
+ val names = new Buffer[Pair[Int, Name]];
+ do {
+ s.nextToken();
+ names.append(Pair(s.pos, ident()));
+ } while (s.token == COMMA);
+ val tp = typedOpt();
+ val rhs = if (tp == Tree.Empty || s.token == EQUALS) {
+ accept(EQUALS);
+ if (tp != Tree.Empty && s.token == USCORE) {
+ s.nextToken();
+ Tree.Empty
+ } else
+ expr();
+ } else {
+ newmods = newmods | Modifiers.DEFERRED;
+ Tree.Empty;
+ }
+ val ts = new myTreeList();
+ names foreach { case Pair(p, n) =>
+ ts.append(popComment(
+ make.ValDef(p, newmods, n, tp.duplicate(), rhs.duplicate())));
+ }
+ ts.toArray()
}
/** FunDef ::= Id [FunTypeParamClause] {ParamClauses} [`:' Type] `=' Expr
- * | this ParamClause `=' ConstrExpr
- * FunDcl ::= Id [FunTypeParamClause] {ParamClauses} `:' Type
- */
- def funDefOrDcl(mods: int): Tree = {
- val pos = s.pos;
+ * | this ParamClause `=' ConstrExpr
+ * FunDcl ::= Id [FunTypeParamClause] {ParamClauses} `:' Type
+ */
+ def funDefOrDcl(mods: int): Array[Tree] = {
+ val ts = new myTreeList();
+ s.nextToken();
if (s.token == THIS) {
+ val pos = s.pos;
s.nextToken();
val vparams = NewArray.ValDefArray(paramClause());
accept(EQUALS);
- make.DefDef(
- pos, mods, Names.CONSTRUCTOR,
- Tree.AbsTypeDef_EMPTY_ARRAY, vparams, Tree.Empty,
- constrExpr());
+ ts.append(popComment(
+ make.DefDef(
+ pos, mods, Names.CONSTRUCTOR,
+ Tree.AbsTypeDef_EMPTY_ARRAY, vparams, Tree.Empty,
+ constrExpr())));
} else {
- val name = ident();
- val tparams = typeParamClauseOpt(false);
- val vparams = paramClauses();
- val restype = typedOpt();
- if (s.token == EQUALS || restype == Tree.Empty)
- make.DefDef(pos, mods, name, tparams, vparams, restype, equalsExpr());
- else
- make.DefDef(pos, mods | Modifiers.DEFERRED, name,
- tparams, vparams, restype, Tree.Empty);
- }
+ var newmods = mods;
+ val lhs = new Buffer[Tuple4[Int, Name, Array[Tree$AbsTypeDef], Array[Array[Tree$ValDef]]]];
+ var loop = true;
+ while (loop) {
+ lhs.append(Tuple4(s.pos, ident(),
+ typeParamClauseOpt(false),
+ paramClauses()));
+ if (s.token == COMMA)
+ s.nextToken();
+ else
+ loop = false;
+ }
+ val restype = typedOpt();
+ val rhs = if (restype == Tree.Empty || s.token == EQUALS) {
+ equalsExpr();
+ } else {
+ newmods = newmods | Modifiers.DEFERRED;
+ Tree.Empty;
+ }
+ lhs foreach { case Tuple4(p, n, tp, vp) =>
+ ts.append(popComment(
+ make.DefDef(p, newmods, n, tp, vp, restype.duplicate(),
+ rhs.duplicate())));
+ }
+ }
+ ts.toArray()
}
/** ConstrExpr ::= SelfInvocation
@@ -1686,7 +1716,7 @@ class Parser(unit: Unit) {
statlist.append(selfInvocation());
val stats =
if (s.token == SEMI) { s.nextToken(); blockStatSeq(statlist) }
- else statlist.toArray();
+ else statlist.toArray();
accept(RBRACE);
make.Block(pos, stats)
} else {
@@ -1711,11 +1741,11 @@ class Parser(unit: Unit) {
s.token match {
case LBRACKET =>
val tparams = typeParamClauseOpt(true);
- accept(EQUALS);
- make.AliasTypeDef(pos, mods, name, tparams, typ())
+ accept(EQUALS);
+ make.AliasTypeDef(pos, mods, name, tparams, typ())
case EQUALS =>
s.nextToken();
- make.AliasTypeDef(pos, mods, name, Tree.AbsTypeDef_EMPTY_ARRAY, typ())
+ make.AliasTypeDef(pos, mods, name, Tree.AbsTypeDef_EMPTY_ARRAY, typ())
case SUPERTYPE | SUBTYPE | SEMI | COMMA | RBRACE =>
typeBounds(pos, mods | Modifiers.DEFERRED, name)
case _ =>
@@ -1724,25 +1754,50 @@ class Parser(unit: Unit) {
}
/** ClassDef ::= Id [TypeParamClause] [ParamClause] [`:' SimpleType] ClassTemplate
- */
- def classDef(mods: int): Tree = {
- val pos = s.pos;
- val clazzname = ident().toTypeName();
- val tparams = typeParamClauseOpt(true);
- val params = paramClauseOpt();
- val result = new myTreeList();
- popComment(make.ClassDef(pos, mods, clazzname, tparams, params,
- simpleTypedOpt(), classTemplate()))
+ */
+ def classDef(mods: int): Array[Tree] = {
+ val lhs = new Buffer[Tuple4[Int, Name, Array[Tree$AbsTypeDef], Array[Array[Tree$ValDef]]]];
+ do {
+ s.nextToken();
+ lhs.append(Tuple4(s.pos,
+ ident().toTypeName(),
+ typeParamClauseOpt(true),
+ paramClauseOpt()));
+ } while (s.token == COMMA);
+ val thistpe = simpleTypedOpt();
+ val template = classTemplate();
+ val ts = new myTreeList();
+ lhs foreach { case Tuple4(p, n, tp, vp) =>
+ ts.append(popComment(
+ make.ClassDef(p, mods, n, tp, vp,
+ thistpe.duplicate(),
+ template.duplicate().asInstanceOf[Tree$Template])));
+ }
+ ts.toArray()
}
/** ObjectDef ::= Id [`:' SimpleType] ClassTemplate
- */
- def objectDef(mods: int): Tree =
- popComment(make.ModuleDef(
- s.pos, mods, ident(), simpleTypedOpt(), classTemplate()));
+ */
+ def objectDef(mods: int): Array[Tree] = {
+ val lhs = new Buffer[Pair[Int, Name]];
+ do {
+ s.nextToken();
+ lhs.append(Pair(s.pos, ident()));
+ } while (s.token == COMMA);
+ val thistpe = simpleTypedOpt();
+ val template = classTemplate();
+ val ts = new myTreeList();
+ lhs foreach { case Pair(p, n) =>
+ ts.append(popComment(
+ make.ModuleDef(
+ p, mods, n, thistpe.duplicate(),
+ template.duplicate().asInstanceOf[Tree$Template])));
+ }
+ ts.toArray()
+ }
/** ClassTemplate ::= [`extends' Constr] {`with' Constr} [TemplateBody]
- */
+ */
def classTemplate(): Tree$Template = {
val pos = s.pos;
val parents = new myTreeList();
@@ -1858,12 +1913,12 @@ class Parser(unit: Unit) {
}
/** TemplateStatSeq ::= TemplateStat {`;' TemplateStat}
- * TemplateStat ::= Import
- * | Modifiers Def
- * | Modifiers Dcl
- * | Expr
- * |
- */
+ * TemplateStat ::= Import
+ * | Modifiers Def
+ * | Modifiers Dcl
+ * | Expr
+ * |
+ */
def templateStatSeq(): Array[Tree] = {
val stats = new myTreeList();
while (s.token != RBRACE && s.token != EOF) {
@@ -1882,10 +1937,10 @@ class Parser(unit: Unit) {
}
/** RefineStatSeq ::= RefineStat {`;' RefineStat}
- * RefineStat ::= Dcl
- * | type TypeDef {`,' TypeDef}
- * |
- */
+ * RefineStat ::= Dcl
+ * | type TypeDef
+ * |
+ */
def refineStatSeq(): Array[Tree] = {
val stats = new myTreeList();
while (s.token != RBRACE && s.token != EOF) {
@@ -1900,12 +1955,12 @@ class Parser(unit: Unit) {
}
/** BlockStatSeq ::= { BlockStat `;' } [Expr]
- * BlockStat ::= Import
- * | Def
- * | LocalModifiers ClsDef
- * | Expr
- * |
- */
+ * BlockStat ::= Import
+ * | Def
+ * | LocalModifiers ClsDef
+ * | Expr
+ * |
+ */
def blockStatSeq(stats: myTreeList): Array[Tree] = {
while ((s.token != RBRACE) && (s.token != EOF) && (s.token != CASE)) {
if (s.token == IMPORT) {
diff --git a/sources/scala/tools/scalac/ast/parser/Scanner.scala b/sources/scala/tools/scalac/ast/parser/Scanner.scala
index 51c9c9ff16..2bbb15801b 100644
--- a/sources/scala/tools/scalac/ast/parser/Scanner.scala
+++ b/sources/scala/tools/scalac/ast/parser/Scanner.scala
@@ -58,7 +58,8 @@ class Scanner(_unit: Unit) extends TokenData {
/** we need one token lookahead
*/
- val next = new TokenData(), prev = new TokenData();
+ val next = new TokenData();
+ val prev = new TokenData();
/** the first character position after the previous token
*/
diff --git a/sources/scala/tools/scalac/ast/parser/Tokens.scala b/sources/scala/tools/scalac/ast/parser/Tokens.scala
index 76d5732ed8..c94e4b7c22 100644
--- a/sources/scala/tools/scalac/ast/parser/Tokens.scala
+++ b/sources/scala/tools/scalac/ast/parser/Tokens.scala
@@ -9,84 +9,84 @@
package scala.tools.scalac.ast.parser;
object Tokens {
- val EMPTY = -3,
- UNDEF = -2,
- ERROR = -1,
- EOF = 0,
+ val EMPTY = -3;
+ val UNDEF = -2;
+ val ERROR = -1;
+ val EOF = 0;
/* literals */
- CHARLIT = 1,
- INTLIT = 2,
- LONGLIT = 3,
- FLOATLIT = 4,
- DOUBLELIT = 5,
- STRINGLIT = 6,
- SYMBOLLIT = 7,
+ val CHARLIT = 1;
+ val INTLIT = 2;
+ val LONGLIT = 3;
+ val FLOATLIT = 4;
+ val DOUBLELIT = 5;
+ val STRINGLIT = 6;
+ val SYMBOLLIT = 7;
/* identifier */
- IDENTIFIER = 10,
+ val IDENTIFIER = 10;
/* keywords */
- IF = 20,
- FOR = 21,
- ELSE = 22,
- THIS = 23,
- NULL = 24,
- NEW = 25,
- WITH = 26,
- SUPER = 27,
- CASE = 28,
- CASECLASS = 29,
- CASEOBJECT = 30,
- VAL = 31,
- ABSTRACT = 32,
- FINAL = 33,
- PRIVATE = 34,
- PROTECTED = 35,
- OVERRIDE = 36,
- VAR = 37,
- DEF = 38,
- TYPE = 39,
- EXTENDS = 40,
- TRUE = 41,
- FALSE = 42,
- OBJECT = 43,
- CLASS = 44,
+ val IF = 20;
+ val FOR = 21;
+ val ELSE = 22;
+ val THIS = 23;
+ val NULL = 24;
+ val NEW = 25;
+ val WITH = 26;
+ val SUPER = 27;
+ val CASE = 28;
+ val CASECLASS = 29;
+ val CASEOBJECT = 30;
+ val VAL = 31;
+ val ABSTRACT = 32;
+ val FINAL = 33;
+ val PRIVATE = 34;
+ val PROTECTED = 35;
+ val OVERRIDE = 36;
+ val VAR = 37;
+ val DEF = 38;
+ val TYPE = 39;
+ val EXTENDS = 40;
+ val TRUE = 41;
+ val FALSE = 42;
+ val OBJECT = 43;
+ val CLASS = 44;
- IMPORT = 46,
- PACKAGE = 47,
- YIELD = 48,
- DO = 49,
- TRAIT = 50,
- SEALED = 51,
- THROW = 52,
- TRY = 53,
- CATCH = 54,
- FINALLY = 55,
- WHILE = 56,
- RETURN = 57,
+ val IMPORT = 46;
+ val PACKAGE = 47;
+ val YIELD = 48;
+ val DO = 49;
+ val TRAIT = 50;
+ val SEALED = 51;
+ val THROW = 52;
+ val TRY = 53;
+ val CATCH = 54;
+ val FINALLY = 55;
+ val WHILE = 56;
+ val RETURN = 57;
/* special symbols */
- COMMA = 61,
- SEMI = 62,
- DOT = 63,
- USCORE = 64,
- COLON = 65,
- EQUALS = 66,
- LARROW = 67,
- ARROW = 68,
- SUBTYPE = 69,
- SUPERTYPE = 70,
- HASH = 71,
- AT = 72,
+ val COMMA = 61;
+ val SEMI = 62;
+ val DOT = 63;
+ val USCORE = 64;
+ val COLON = 65;
+ val EQUALS = 66;
+ val LARROW = 67;
+ val ARROW = 68;
+ val SUBTYPE = 69;
+ val SUPERTYPE = 70;
+ val HASH = 71;
+ val AT = 72;
/* parenthesis */
- LPAREN = 90,
- RPAREN = 91,
- LBRACKET = 92,
- RBRACKET = 93,
- LBRACE = 94,
- RBRACE = 95;
+ val LPAREN = 90;
+ val RPAREN = 91;
+ val LBRACKET = 92;
+ val RBRACKET = 93;
+ val LBRACE = 94;
+ val RBRACE = 95;
}
diff --git a/sources/scala/tools/scalac/typechecker/Analyzer.scala b/sources/scala/tools/scalac/typechecker/Analyzer.scala
index bfcda113de..b0085163c9 100644
--- a/sources/scala/tools/scalac/typechecker/Analyzer.scala
+++ b/sources/scala/tools/scalac/typechecker/Analyzer.scala
@@ -2216,7 +2216,8 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
case Tree$If(cond, thenp, elsep) =>
val cond1: Tree = transform(cond, EXPRmode, definitions.BOOLEAN_TYPE());
- var thenp1: Tree = _, elsep1: Tree = _;
+ var thenp1: Tree = _;
+ var elsep1: Tree = _;
if (elsep == Tree.Empty) {
thenp1 = transform(thenp, EXPRmode, definitions.UNIT_TYPE());
elsep1 = make.Block(tree.pos, Tree.EMPTY_ARRAY)
@@ -2701,7 +2702,8 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
copy.Ident(tree, context.enclClass.owner)
.setType(context.enclClass.owner.getType());
} else if (((mode & (PATTERNmode | FUNmode)) == PATTERNmode) && name.isVariable()) {
- var vble: Symbol = null, vble2: Symbol = null;
+ var vble: Symbol = null;
+ var vble2: Symbol = null;
// if vble is bound with @, there is already a symbol
if (name != Names.PATTERN_WILDCARD) {