diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/models/SemanticTokens.scala | 78 | ||||
-rw-r--r-- | src/library/scala/Iterator.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Option.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/Map.scala | 26 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Set.scala | 20 | ||||
-rw-r--r-- | src/library/scala/io/Source.scala | 16 | ||||
-rw-r--r-- | src/library/scala/util/automata/BaseBerrySethi.scala | 39 |
7 files changed, 92 insertions, 93 deletions
diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala index 3cafc191e1..caef645fef 100644 --- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala +++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala @@ -1,18 +1,19 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc.models -import java.lang.Thread import java.lang.Character.isJavaIdentifierPart -import scala.collection.mutable.{HashMap,HashSet} +import java.lang.Thread + +import scala.collection.mutable.{HashMap, HashSet} import scala.tools.nsc.Global -import scala.tools.nsc.symtab.{Flags,Names} -import scala.tools.nsc.util.{NameTransformer,Position,SourceFile,BatchSourceFile, NoPosition} +import scala.tools.nsc.symtab.{Flags, Names} import scala.tools.nsc.symtab.Flags.DEFERRED +import scala.tools.nsc.util.{BatchSourceFile, NameTransformer, NoPosition, Position, SourceFile} class SemanticTokens(val compiler: Global) { import compiler._ @@ -69,7 +70,7 @@ class SemanticTokens(val compiler: Global) { } abstract class Actual extends HasNext with HasPrev { - def convertToGap: (Int, Actual) = { + def convertToGap: (Int, Actual) = { val nextGap = next.isInstanceOf[Gap] val prevGap = prev.isInstanceOf[Gap] @@ -103,7 +104,7 @@ class SemanticTokens(val compiler: Global) { } } - def insert(prev1: HasNext) = { + def insert(prev1: HasNext) { next0 = prev1.next prev0 = prev1 prev0.next0 = this @@ -117,7 +118,7 @@ class SemanticTokens(val compiler: Global) { this() insert(prev1) } - override def toString() = "gap-" + length; + override def toString() = "gap-" + length var length0: Int = -1 def length: Int = length0 @@ -142,8 +143,7 @@ class SemanticTokens(val compiler: Global) { treePos.dbgString )} - val symbols = new HashMap[Symbol,Info]; - + val symbols = new HashMap[Symbol, Info] class Info(val symbol: Symbol) { var defined : Def = _ @@ -156,17 +156,17 @@ class SemanticTokens(val compiler: Global) { else new Info(symbol) abstract class Semantic(val symbol: Symbol) extends Actual { - val name = NameTransformer.decode(symbol.name.toString()).toString().trim(); - assert(symbol != NoSymbol); + val name = NameTransformer.decode(symbol.name.toString()).toString().trim() + assert(symbol != NoSymbol) def myOuter = Process.this - def tpe: Type = symbol.tpe; + def tpe: Type = symbol.tpe - def length = name.length(); - def info: Info = if (symbols.contains(symbol)) symbols(symbol) else new Info(symbol); + def length = name.length() + def info: Info = if (symbols.contains(symbol)) symbols(symbol) else new Info(symbol) def kind = { - val term0 = symbol; + val term0 = symbol if (false) null else if (term0.isVariable) VAR else if (term0.isValueParameter) ARG @@ -261,7 +261,7 @@ class SemanticTokens(val compiler: Global) { case tree: PackageDef => //Console.err.println("PACKAGE: " + tree.name); if (false) { - val pos = eatKeywords(unit.source.asInstanceOf[BatchSourceFile], tree.pos.offset.get(-1)) + val pos = eatKeywords(unit.source.asInstanceOf[BatchSourceFile], tree.pos.offset.getOrElse(-1)) if (pos != -1) buildDef(tree.symbol, pos) } @@ -270,8 +270,8 @@ class SemanticTokens(val compiler: Global) { for (val arg <- tree.vparams) if (arg.pos != NoPosition) { val name = arg.name.toString().trim() val pos: Int = - if (unit.source.beginsWith(arg.pos.offset.get(-1), "val ")) - unit.source.skipWhitespace(arg.pos.offset.get(-1) + ("val ").length()) + if (unit.source.beginsWith(arg.pos.offset.getOrElse(-1), "val ")) + unit.source.skipWhitespace(arg.pos.offset.getOrElse(-1) + ("val ").length()) else if (unit.source.asInstanceOf[BatchSourceFile].content(arg.pos.offset.get) == ':') { var posx : Int = arg.pos.offset.get while (unit.source.asInstanceOf[BatchSourceFile].content(posx - 1).isWhitespace) posx = posx - 1 @@ -294,13 +294,13 @@ class SemanticTokens(val compiler: Global) { def buildT( tree : Tree, tpe : Type) : Unit = if (tree.pos != NoPosition) tpe match { case tpe0 : TypeRef => tree match { case apt : AppliedTypeTree => - buildUse(tpe.typeSymbol, apt.tpt.pos.offset.get(-1), tpe0); + buildUse(tpe.typeSymbol, apt.tpt.pos.offset.getOrElse(-1), tpe0); //Console.err.println("APT: " + treex + " vs. " + treex.original); //Console.err.println("APT: " + treex.pos + " vs. " + treex.original.pos + " " + unit.source.dbg(treex.original.pos)); //Console.err.println("APT: " + apt.tpt + " sym0=" + apt.tpt.symbol + " sym1=" + tpe0.sym + " apt.args=" + apt.args + " tpe0.args=" + tpe0.args); buildTs (apt.args, tpe0.args); - case ident : Ident => buildUse(tpe0.sym, ident.pos.offset.get(-1), tpe0); + case ident : Ident => buildUse(tpe0.sym, ident.pos.offset.getOrElse(-1), tpe0); case select : Select => if (select.symbol == NoSymbol) try { @@ -316,10 +316,10 @@ class SemanticTokens(val compiler: Global) { case tpt : TypeTree => if (tpt.symbol ne null) { Console.err.println("SYM0 " + tpt.symbol + " " + (tpt.pos).dbgString); - buildUse(tpt.symbol, tpt.pos.offset.get(-1), tpe0); + buildUse(tpt.symbol, tpt.pos.offset.getOrElse(-1), tpe0); } else if (tpe0.typeSymbol ne null) { //Console.err.println("TYPE_SYM1 " + tpe0.symbol + " " + unit.source.dbg(tpt.pos)); - buildUse(tpe0.typeSymbol, tpt.pos.offset.get(-1), tpe0); + buildUse(tpe0.typeSymbol, tpt.pos.offset.getOrElse(-1), tpe0); } else { Console.err.println("UNKNOWN TPT0: " + (tpt.pos).dbgString + " tpt=" + tpt + " " + tpt.symbol + " tpe0="+ tpe0 + " " + tpe0.typeSymbol + " tpe0.args=" + tpe0.args); } @@ -365,7 +365,7 @@ class SemanticTokens(val compiler: Global) { if (false) Console.err.println("UNKNOWN TPE10: " + tpe0 + " " + tree + " " + tree.getClass() + " " + (tree.pos).dbgString); } case tpe0 : SingleType => tree match { - case ident : Ident => buildUse(tpe0.sym, ident.pos.offset.get(-1), tpe0); + case ident : Ident => buildUse(tpe0.sym, ident.pos.offset.getOrElse(-1), tpe0); case select : Select => buildUse(tpe0.termSymbol, selectPos(select), tpe0); //Console.err.println("QUALIFIER-0: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString); @@ -399,16 +399,16 @@ class SemanticTokens(val compiler: Global) { case tree: AbsTypeDef => //Console.err.println("ABS: " + tree.symbol + " " + unit.source.dbg(tree.namePos) + " " + tree.pos.dbgString); buildDef(tree.symbol, tree.namePos) - buildDef(tree.symbol, tree.pos.offset.get(-1)) + buildDef(tree.symbol, tree.pos.offset.getOrElse(-1)) build(tree.tparams); //@M build(tree.lo) build(tree.hi) */ case tree: Bind => - buildDef(tree.symbol, tree.pos.offset.get(-1)) + buildDef(tree.symbol, tree.pos.offset.getOrElse(-1)) build(tree.body) case tree: Ident => - buildUse(tree.symbol, tree.pos.offset.get(-1), tree.tpe) + buildUse(tree.symbol, tree.pos.offset.getOrElse(-1), tree.tpe) case tree: Select => try { build(tree.qualifier) @@ -470,11 +470,11 @@ class SemanticTokens(val compiler: Global) { case tree : Alternative => build(tree.trees); case tree : This => - if (tree.symbol ne null) buildUse(tree.symbol, tree.pos.offset.get(-1), tree.tpe); + if (tree.symbol ne null) buildUse(tree.symbol, tree.pos.offset.getOrElse(-1), tree.tpe); //Thread.dumpStack(); case tree : TypeDef => //Console.err.println("ALIAS: " + tree); - build(tree.rhs); build(tree.tparams); buildDef(tree.symbol, tree.pos.offset.get(-1)); + build(tree.rhs); build(tree.tparams); buildDef(tree.symbol, tree.pos.offset.getOrElse(-1)); case tree : DocDef => build(tree.definition); case tree: Import => build(tree.expr) case tree: AppliedTypeTree => ; @@ -528,7 +528,7 @@ class SemanticTokens(val compiler: Global) { } } - def selectPos(tree : Select): Int = if (tree.pos == NoPosition) -1 else { + def selectPos(tree: Select): Int = if (tree.pos == NoPosition) -1 else { val buf = unit.source.asInstanceOf[BatchSourceFile].content if (tree.pos.offset.get >= buf.length) { if (false) { @@ -576,7 +576,7 @@ class SemanticTokens(val compiler: Global) { case gap: Gap => } - def put(offset: Int, tok: Semantic): Unit = { + def put(offset: Int, tok: Semantic) { cursor.seek(offset); if (cursor.token == end) { assert(offset >= cursor.offset); @@ -632,7 +632,7 @@ class SemanticTokens(val compiler: Global) { } } - override def toString() = { + override def toString(): String = { var node = begin.next var str = "" while (node != end) { @@ -654,7 +654,7 @@ class SemanticTokens(val compiler: Global) { offset = offset - token.prev.length token = token.prev } - def seek(soffset : Int) : Unit = if (soffset == 0) { + def seek(soffset: Int): Unit = if (soffset == 0) { token = begin.next offset = 0 } else { @@ -676,14 +676,14 @@ class SemanticTokens(val compiler: Global) { def adjust(offset: Int, /* where */ length: Int, /* how many characters are modified */ to : Int /* length of new string */) = { - cursor.seek(offset); + cursor.seek(offset) if (cursor.token != end) { - cursor.convertToGap; + cursor.convertToGap while (cursor.offset + cursor.token.length < offset + length && cursor.token.next != end) { - val save = cursor.offset; - cursor.next; - cursor.convertToGap; - assert(cursor.offset == save); + val save = cursor.offset + cursor.next + cursor.convertToGap + assert(cursor.offset == save) } if (length != to && cursor.token != end) { val diff = to - length; diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala index eb9ebc8275..15247578ec 100644 --- a/src/library/scala/Iterator.scala +++ b/src/library/scala/Iterator.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -46,7 +46,7 @@ object Iterator { /** * @param xs the array of elements * @return the iterator on <code>xs</code>. - * @deprecated replaced by RandomAccessSeq.elements and slice + * @deprecated replaced by <code>RandomAccessSeq.elements</code> and </code>slice</code>. */ @deprecated def fromArray[a](xs: Array[a]): Iterator[a] = fromArray(xs, 0, xs.length) diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index f3c413bbb4..8652386975 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala index fafdf8e175..3de844ca48 100644 --- a/src/library/scala/collection/Map.scala +++ b/src/library/scala/collection/Map.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -14,7 +14,7 @@ package scala.collection import Predef._ object Map { - trait Projection[A, +B] extends Iterable.Projection[(A,B)] with Map[A,B]; + trait Projection[A, +B] extends Iterable.Projection[(A, B)] with Map[A, B] } @@ -57,7 +57,7 @@ trait Map[A, +B] extends PartialFunction[A, B] with Collection[(A, B)] { /** Check if this map maps <code>key</code> to a value. * Return that value if it exists, otherwise return <code>default</code>. */ - def getOrElse[B2 >: B](key: A, default: =>B2): B2 = + def getOrElse[B2 >: B](key: A, default: => B2): B2 = get(key) match { case Some(v) => v case None => default @@ -168,31 +168,31 @@ trait Map[A, +B] extends PartialFunction[A, B] with Collection[(A, B)] { def default(key: A): B = throw new NoSuchElementException("key not found: " + key) - override def projection : Map.Projection[A,B] = new Map.Projection[A,B] { + override def projection: Map.Projection[A,B] = new Map.Projection[A, B] { override def elements = Map.this.elements override def size = Map.this.size - override def get(key : A) : Option[B] = Map.this.get(key) + override def get(key: A): Option[B] = Map.this.get(key) } /** non-strict filter based on keys only */ - def filterKeys(p : A => Boolean) : Map.Projection[A,B] = new Map.Projection[A,B] { + def filterKeys(p: A => Boolean): Map.Projection[A, B] = new Map.Projection[A, B] { def elements = Map.this.elements.filter(x => p(x._1)) def size = { var sz = 0 Map.this.foreach(x => if (p(x._1)) sz = sz + 1) sz } - override def contains(key : A) = Map.this.contains(key) && p(key) - override def get(key : A) = if (!p(key)) None else Map.this.get(key) + override def contains(key: A) = Map.this.contains(key) && p(key) + override def get(key: A) = if (!p(key)) None else Map.this.get(key) } /** non-strict map elements using existing key set */ - def mapElements[C](f : B => C) : Map.Projection[A,C] = new Map.Projection[A,C] { + def mapElements[C](f: B => C) : Map.Projection[A,C] = new Map.Projection[A,C] { def elements = Map.this.elements.map(e => (e._1, f(e._2))) def size = Map.this.size - override def contains(key : A) = Map.this.contains(key) - override def get(key : A) = Map.this.get(key).map(f) + override def contains(key: A) = Map.this.contains(key) + override def get(key: A) = Map.this.get(key).map(f) } /** Defines the prefix of this object's <code>toString</code> representation. */ - override protected def stringPrefix : String = "Map" + override protected def stringPrefix: String = "Map" } diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala index 2fe3da1ff2..52e50b6861 100644 --- a/src/library/scala/collection/immutable/Set.scala +++ b/src/library/scala/collection/immutable/Set.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -30,11 +30,10 @@ object Set { * on an immutable set leave the original set unchanged, and return * a new set if needed. * </p> - - * <p>Concrete set implementations - * just have to provide functionality for the abstract methods in - * <code>scala.collection.Set</code> as well as for <code>+</code> and - * <code>-</code>. + * <p> + * Concrete set implementations just have to provide functionality for + * the abstract methods in <code>scala.collection.Set</code> as well as + * for <code>+</code> and <code>-</code>. * </p> * <p> * Note that abstract immutable.Set's are not covariant in their type @@ -102,6 +101,7 @@ trait Set[A] extends AnyRef with collection.Set[A] { def -(elem: A): Set[A] /** Remove two or more elements from this set. + * * @param elem1 the first element. * @param elem2 the second element. * @param elems the remaining elements. @@ -120,6 +120,7 @@ trait Set[A] extends AnyRef with collection.Set[A] { /** Remove all the elements provided by an iterator * <code>elems</code> from the set. + * * @param elems An iterator containing the elements to remove from the set. * @return a new set with the elements removed. */ @@ -133,6 +134,8 @@ trait Set[A] extends AnyRef with collection.Set[A] { /** This method removes all the elements provided by an iterator * of the iterable object <code>that</code> from the set. + * + * @param that the iterable collection. */ @deprecated def excl(that: Iterable[A]): Set[A] = @@ -141,7 +144,7 @@ trait Set[A] extends AnyRef with collection.Set[A] { /** This method computes an intersection with set <code>that</code>. * It removes all the elements that are not present in <code>that</code>. * - * @param that the set to intersect with + * @param that the set to intersect with. */ def intersect(that: collection.Set[A]): Set[A] = filter(that.contains) @@ -165,12 +168,13 @@ trait Set[A] extends AnyRef with collection.Set[A] { /** Applies the given function <code>f</code> to each element of * this set, then forms the union of all results. + * * @param f function to apply to each element. * @return a set containing all elements in each <code>f(a0), ..., f(an)</code> * if this set contains <code>a0, ..., an</code>. */ override def flatMap[B](f: A => Iterable[B]): Set[B] = - foldLeft(empty[B])((set: Set[B], elem: A) => set + f(elem)) + foldLeft(empty[B])((set: Set[B], elem: A) => set ++ f(elem)) /** Method <code>filter</code> removes all elements from the set for * which the predicate <code>p</code> yields the value <code>false</code>. diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index 3c13210863..a9b5b1f495 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -16,8 +16,6 @@ import java.io.{BufferedInputStream, File, FileInputStream, InputStream, PrintStream} import java.net.{URI, URL} -import compat.StringBuilder - /** This object provides convenience methods to create an iterable * representation of a source file. * @@ -64,7 +62,7 @@ object Source { * @return ... */ def fromChars(chars: Array[Char]): Source = { - val it = Iterator.fromArray(chars) + val it = chars.elements new Source { def reset() = fromChars(chars) val iter = it @@ -134,7 +132,7 @@ object Source { * @return ... */ def setFileDescriptor(file: File, s: Source): Source = { - s.descr = new StringBuilder().append( "file:" ).append(file.getAbsolutePath()).toString(); + s.descr = new StringBuilder("file:").append(file.getAbsolutePath()).toString(); s } @@ -262,11 +260,11 @@ abstract class Source extends Iterator[Char] { var ch = it.next while (it.hasNext && '\n' != ch) { - buf.append(ch) + buf append ch ch = it.next } val res = buf.toString() - buf.setLength(0) // hopefully help collector to deallocate StringBuilder + buf setLength 0 // hopefully help collector to deallocate StringBuilder res } @@ -278,12 +276,12 @@ abstract class Source extends Iterator[Char] { def next = { var ch = iter.next while(ch != '\n' && iter.hasNext) { - buf.append(ch) + buf append ch ch = iter.next } buf.append(ch) val res = buf.toString() - buf.setLength(0) // clean things up for next call of "next" + buf setLength 0 // clean things up for next call of "next" res } def hasNext = iter.hasNext diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala index ba3d0b9a45..d1c82e560d 100644 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ b/src/library/scala/util/automata/BaseBerrySethi.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -46,7 +46,7 @@ abstract class BaseBerrySethi { case x:Alt => var tmp = emptySet val it = x.rs.elements // union - while (it.hasNext) { tmp = tmp incl compFirst(it.next) } + while (it.hasNext) { tmp = tmp ++ compFirst(it.next) } tmp case Eps => emptySet @@ -58,12 +58,13 @@ abstract class BaseBerrySethi { val it = x.rs.elements; // union while (it.hasNext) { val z = it.next - tmp = tmp incl compFirst(z) + tmp = tmp ++ compFirst(z) if (!z.isNullable) return tmp } tmp - case Star(t) => compFirst(t) + case Star(t) => + compFirst(t) case _ => throw new IllegalArgumentException("unexpected pattern " + r.getClass()) } @@ -73,23 +74,26 @@ abstract class BaseBerrySethi { case x:Alt => var tmp = emptySet val it = x.rs.elements // union - while (it.hasNext) { tmp = tmp incl compFirst(it.next) } + while (it.hasNext) { tmp = tmp ++ compFirst(it.next) } tmp - case Eps => emptySet + case Eps => + emptySet //case x:Letter => emptySet + posMap(x) // singleton set - case x:Meta => compLast(x.r) + case x:Meta => + compLast(x.r) case x:Sequ => var tmp = emptySet val it = x.rs.elements.toList.reverse.elements // union while (it.hasNext) { val z = it.next - tmp = tmp incl compLast(z) + tmp = tmp ++ compLast(z) if (!z.isNullable) return tmp } tmp - case Star(t) => compLast(t) - case _ => + case Star(t) => + compLast(t) + case _ => throw new IllegalArgumentException("unexpected pattern " + r.getClass()) } @@ -101,7 +105,6 @@ abstract class BaseBerrySethi { * @return ... */ protected def compFollow(r: Seq[RegExp]): immutable.Set[Int] = { - //Console.println("compFollow( "+r.toList) var first = emptySet var fol = emptySet if (r.length > 0) {//non-empty expr @@ -111,18 +114,13 @@ abstract class BaseBerrySethi { fol = fol + pos // don't modify pos ! while (it.hasNext) { val p = it.next - //Console.println(" p now = "+p) first = compFollow1(fol, p) - //Console.println(" first = "+first) - //Console.println(" fol before = "+fol) fol = - if (p.isNullable) fol incl first + if (p.isNullable) fol ++ first else first - //Console.println(" fol after = "+fol) } } this.follow.update(0, fol /*first*/) - //Console.println("follow(0) = "+fol) fol } @@ -135,14 +133,13 @@ abstract class BaseBerrySethi { */ protected def compFollow1(fol1: immutable.Set[Int], r: RegExp): immutable.Set[Int] = { var fol = fol1 - //System.out.println("compFollow1("+fol+","+r+")") r match { case x:Alt => var first = emptySet val it = x.rs.elements.toList.reverse.elements while (it.hasNext) - first = first incl compFollow1(fol, it.next); + first = first ++ compFollow1(fol, it.next); first /* @@ -155,7 +152,7 @@ abstract class BaseBerrySethi { compFollow1(fol1, x.r) case x:Star => - fol = fol incl compFirst(x.r) + fol = fol ++ compFirst(x.r) compFollow1(fol, x.r) case x:Sequ => @@ -165,7 +162,7 @@ abstract class BaseBerrySethi { val p = it.next first = compFollow1(fol, p) fol = - if (p.isNullable) fol incl first + if (p.isNullable) fol ++ first else first } first |