From f7e038361ae6b1958985a20e30bfa567d6a51b16 Mon Sep 17 00:00:00 2001 From: michelou Date: Mon, 19 Sep 2011 11:03:41 +0000 Subject: fixed svn props, did some cleanup --- .../scala/tools/nsc/ast/parser/MarkupParsers.scala | 9 ++- .../scala/tools/nsc/ast/parser/Scanners.scala | 14 +++-- .../tools/nsc/ast/parser/SyntaxAnalyzer.scala | 2 +- .../scala/tools/nsc/ast/parser/Tokens.scala | 24 ++++---- .../scala/util/continuations/ControlContext.scala | 11 +++- .../library/scala/util/continuations/package.scala | 68 ++++++++++++---------- src/library/scala/collection/TraversableLike.scala | 32 +++++----- src/library/scala/parallel/Future.scala | 28 ++++----- 8 files changed, 108 insertions(+), 80 deletions(-) diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 9eda2e4097..7388ecf163 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -78,9 +78,12 @@ trait MarkupParsers { def ch = input.ch /** this method assign the next character to ch and advances in input */ def nextch() { input.nextChar() } - def ch_returning_nextch = { val result = ch; input.nextChar(); result } - def mkProcInstr(position: Position, name: String, text: String): Tree = + protected def ch_returning_nextch: Char = { + val result = ch; input.nextChar(); result + } + + def mkProcInstr(position: Position, name: String, text: String): ElementType = parser.symbXMLBuilder.procInstr(position, name, text) var xEmbeddedBlock = false @@ -286,7 +289,7 @@ trait MarkupParsers { /** parse character data. * precondition: xEmbeddedBlock == false (we are not in a scala block) */ - def xText: String = { + private def xText: String = { assert(!xEmbeddedBlock, "internal error: encountered embedded block") val buf = new StringBuilder def done = buf.toString diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index e73af5ea86..e3d2525d16 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -10,7 +10,9 @@ import scala.reflect.internal.Chars._ import Tokens._ import scala.annotation.switch import scala.collection.mutable.{ ListBuffer, ArrayBuffer } +/*@XML*/ import scala.xml.Utility.{ isNameStart } +/*XML@*/ /** See Parsers.scala / ParsersCommon for some explanation of ScannersCommon. */ @@ -297,6 +299,7 @@ trait Scanners extends ScannersCommon { putChar(ch) nextChar() getIdentRest() // scala-mode: wrong indent for multi-line case blocks +/*@XML*/ case '<' => // is XMLSTART? val last = if (charOffset >= 2) buf(charOffset - 2) else ' ' nextChar() @@ -308,8 +311,9 @@ trait Scanners extends ScannersCommon { putChar('<') getOperatorRest() } +/*XML@*/ case '~' | '!' | '@' | '#' | '%' | - '^' | '*' | '+' | '-' | /*'<' | */ + '^' | '*' | '+' | '-' | /*'<' | */ /*@NOXML '<' | XMLNO@*/ '>' | '?' | ':' | '=' | '&' | '|' | '\\' => putChar(ch) @@ -489,7 +493,7 @@ trait Scanners extends ScannersCommon { def inLastOfStat(token: Int) = token match { case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | SYMBOLLIT | IDENTIFIER | BACKQUOTED_IDENT | THIS | NULL | TRUE | FALSE | RETURN | USCORE | - TYPE | XMLSTART | RPAREN | RBRACKET | RBRACE => + TYPE /*@XML*/| XMLSTART /*XML@*/ | RPAREN | RBRACKET | RBRACE => true case _ => false @@ -497,10 +501,10 @@ trait Scanners extends ScannersCommon { // Identifiers --------------------------------------------------------------- - private def getBackquotedIdent(): Unit = { + private def getBackquotedIdent() { nextChar() if (getStringLit('`')) { - finishNamed(); + finishNamed() if (name.length == 0) syntaxError("empty quoted identifier") token = BACKQUOTED_IDENT } @@ -1006,7 +1010,9 @@ trait Scanners extends ScannersCommon { case COMMA => "','" case CASECLASS => "case class" case CASEOBJECT => "case object" +/*@XML*/ case XMLSTART => "$XMLSTART$<" +/*XML@*/ case _ => (token2name get token) match { case Some(name) => "'" + name + "'" diff --git a/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala b/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala index b5ec0ceffb..270f50c1c5 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala @@ -10,7 +10,7 @@ import javac._ /** An nsc sub-component. */ -abstract class SyntaxAnalyzer extends SubComponent with Parsers with MarkupParsers with Scanners with JavaParsers with JavaScanners { +abstract class SyntaxAnalyzer extends SubComponent with Parsers /*@XML*/ with MarkupParsers /*XML@*/ with Scanners with JavaParsers with JavaScanners { val phaseName = "parser" diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index 7524f7d5eb..aeb8d5bb8b 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -37,25 +37,25 @@ abstract class Tokens { def isKeyword(code: Int): Boolean def isSymbol(code: Int): Boolean - final def isSpace(at: Char) = at == ' ' || at == '\t' - final def isNewLine(at: Char) = at == CR || at == LF || at == FF - final def isBrace(code : Int) = code >= LPAREN && code <= RBRACE - final def isOpenBrace(code : Int) = isBrace(code) && (code % 2 == 0) - final def isCloseBrace(code : Int) = isBrace(code) && (code % 2 == 1) + final def isSpace(at: Char) = at == ' ' || at == '\t' + final def isNewLine(at: Char) = at == CR || at == LF || at == FF + final def isBrace(code: Int) = code >= LPAREN && code <= RBRACE + final def isOpenBrace(code: Int) = isBrace(code) && (code % 2 == 0) + final def isCloseBrace(code: Int) = isBrace(code) && (code % 2 == 1) } object Tokens extends Tokens { final val SYMBOLLIT = 7 - def isLiteral(code : Int) = + def isLiteral(code: Int) = code >= CHARLIT && code <= SYMBOLLIT /** identifiers */ final val IDENTIFIER = 10 final val BACKQUOTED_IDENT = 11 - def isIdentifier(code : Int) = + def isIdentifier(code: Int) = code >= IDENTIFIER && code <= BACKQUOTED_IDENT - @switch def canBeginExpression(code : Int) = code match { + @switch def canBeginExpression(code: Int) = code match { case IDENTIFIER|BACKQUOTED_IDENT|USCORE => true case LBRACE|LPAREN|LBRACKET|COMMENT|STRINGLIT => true case IF|DO|WHILE|FOR|NEW|TRY|THROW => true @@ -107,10 +107,10 @@ object Tokens extends Tokens { final val FORSOME = 59 final val LAZY = 61 - def isKeyword(code : Int) = + def isKeyword(code: Int) = code >= IF && code <= LAZY - @switch def isDefinition(code : Int) = code match { + @switch def isDefinition(code: Int) = code match { case CLASS|TRAIT|OBJECT => true case CASECLASS|CASEOBJECT => true case DEF|VAL|VAR => true @@ -135,7 +135,7 @@ object Tokens extends Tokens { final val AT = 83 final val VIEWBOUND = 84 - def isSymbol(code : Int) = + def isSymbol(code: Int) = code >= COMMA && code <= VIEWBOUND /** parenthesis */ @@ -146,8 +146,10 @@ object Tokens extends Tokens { final val LBRACE = 94 final val RBRACE = 95 +/*@XML*/ /** XML mode */ final val XMLSTART = 96 +/*XML@*/ /** for IDE only */ final val COMMENT = 97 diff --git a/src/continuations/library/scala/util/continuations/ControlContext.scala b/src/continuations/library/scala/util/continuations/ControlContext.scala index 8059252f80..19c2bc4038 100644 --- a/src/continuations/library/scala/util/continuations/ControlContext.scala +++ b/src/continuations/library/scala/util/continuations/ControlContext.scala @@ -1,6 +1,13 @@ -// $Id$ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ package scala.util.continuations + import annotation.{ Annotation, StaticAnnotation, TypeConstraint } /** This annotation is used to mark a parameter as part of a continuation @@ -121,7 +128,7 @@ final class ControlContext[+A,-B,+C](val fun: (A => B, Exception => B) => C, val /** * Maps and flattens this `ControlContext` with another `ControlContext` generated from the current state. - * @note: The resulting comuptation is still the type `C`. + * @note The resulting comuptation is still the type `C`. * @tparam A1 The new type of the contained state. * @tparam B1 The new type of the state after the stored continuation has executed. * @tparam C1 The result type of the nested `ControlContext`. Because the nested `ControlContext` is executed within diff --git a/src/continuations/library/scala/util/continuations/package.scala b/src/continuations/library/scala/util/continuations/package.scala index 63547fa50a..641f4594e4 100644 --- a/src/continuations/library/scala/util/continuations/package.scala +++ b/src/continuations/library/scala/util/continuations/package.scala @@ -1,5 +1,10 @@ -// $Id$ - +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ package scala.util @@ -25,10 +30,11 @@ package scala.util * } * }}} * - * The `reset` is provided by this package and delimits the extent of the transformation. - * The `ask` is a function that will be defined below. Its effect is to issue a prompt - * and then suspend execution awaiting user input. Once the user provides an input value, - * execution of the suspended block resumes. + * The `reset` is provided by this package and delimits the extent of the + * transformation. The `ask` is a function that will be defined below. Its + * effect is to issue a prompt and then suspend execution awaiting user input. + * Once the user provides an input value, execution of the suspended block + * resumes. * * {{{ * val sessions = new HashMap[UUID, Int=>Unit] @@ -43,43 +49,45 @@ package scala.util * }}} * * The type of `ask` includes a `@cps` annotation which drives the transformation. - * The type signature `Int @cps[Unit]` means that `ask` should be used in a context - * requiring an `Int`, but actually it will suspend and return `Unit`. + * The type signature `Int @cps[Unit]` means that `ask` should be used in a + * context requiring an `Int`, but actually it will suspend and return `Unit`. * - * The computation leading up to the first `ask` is executed normally. The remainder - * of the reset block is wrapped into a closure that is passed as the parameter `k` to - * the `shift` function, which can then decide whether and how to execute the - * continuation. In this example, the continuation is stored in a sessions map for - * later execution. This continuation includes a second call to `ask`, which is treated - * likewise once the execution resumes. + * The computation leading up to the first `ask` is executed normally. The + * remainder of the reset block is wrapped into a closure that is passed as + * the parameter `k` to the `shift` function, which can then decide whether + * and how to execute the continuation. In this example, the continuation is + * stored in a sessions map for later execution. This continuation includes a + * second call to `ask`, which is treated likewise once the execution resumes. * *

CPS Annotation

* - * The aforementioned `@cps[A]` annotation is an alias for the more general `@cpsParam[B,C]` - * where `B=C`. The type `A @cpsParam[B,C]` describes a term which yields a value of type `A` within - * an evaluation context producing a value of type `B`. After the CPS transformation, this return - * type is modified to `C`. + * The aforementioned `@cps[A]` annotation is an alias for the more general + * `@cpsParam[B,C]` where `B=C`. The type `A @cpsParam[B,C]` describes a term + * which yields a value of type `A` within an evaluation context producing a + * value of type `B`. After the CPS transformation, this return type is + * modified to `C`. * - * The `@cpsParam` annotations are introduced by `shift` blocks, and propagate via the return - * types to the dynamically enclosing context. The propagation stops upon reaching a `reset` - * block. + * The `@cpsParam` annotations are introduced by `shift` blocks, and propagate + * via the return types to the dynamically enclosing context. The propagation + * stops upon reaching a `reset` block. */ package object continuations { /** An annotation that denotes a type is part of a continuation context. - * `@cps[A]` is shorthand for `cpsParam[A,A]`. - * @tparam A The return type of the continuation context. + * `@cps[A]` is shorthand for `cpsParam[A,A]`. + * @tparam A The return type of the continuation context. */ type cps[A] = cpsParam[A,A] /** An annotation that denotes a type is part of a side effecting continuation context. - * `@suspendable` is shorthand notation for `@cpsParam[Unit,Unit]` or `@cps[Unit]`. - */ + * `@suspendable` is shorthand notation for `@cpsParam[Unit,Unit]` or `@cps[Unit]`. + */ type suspendable = cps[Unit] /** - * The `shift` function captures the remaining computation in a `reset` block and passes it to a closure provided by the user. + * The `shift` function captures the remaining computation in a `reset` block + * and passes it to a closure provided by the user. * * For example: * {{{ @@ -106,9 +114,9 @@ package object continuations { * `reset` block. This is passed as a function `A => B`. * - The return is the return value of the `ControlContext` which is * generated from this inversion. - * @note: Must be invoked in the context of a call to `reset` This context - * May not be far up the stack, but a call to reset is needed to eventually - * remove the `@cps` annotations from types. + * @note Must be invoked in the context of a call to `reset` This context + * may not be far up the stack, but a call to reset is needed to + * eventually remove the `@cps` annotations from types. */ def shift[A,B,C](fun: (A => B) => C): A @cpsParam[B,C] = { throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled") @@ -147,7 +155,6 @@ package object continuations { shiftUnit[A,B,B](x) } - def shiftUnit[A,B,C>:B](x: A): A @cpsParam[B,C] = { throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled") } @@ -162,6 +169,7 @@ package object continuations { def shiftUnitR[A,B](x: A): ControlContext[A,B,B] = { new ControlContext(null, x) } + /** * Captures a computation into a `ControlContext`. * @param fun The function which accepts the inverted computation and returns diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 32d697ebb4..6fa05bd85b 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -9,7 +9,7 @@ package scala.collection import generic._ -import mutable.{ Builder, ListBuffer } +import mutable.{ Builder } import annotation.{tailrec, migration, bridge} import annotation.unchecked.{ uncheckedVariance => uV } import parallel.ParIterable @@ -193,8 +193,8 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] b.result } - /** As with `++`, returns a new collection containing the elements from the left operand followed by the - * elements from the right operand. + /** As with `++`, returns a new collection containing the elements from the + * left operand followed by the elements from the right operand. * It differs from `++` in that the right operand determines the type of * the resulting collection rather than the left one. * @@ -223,9 +223,6 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] * @param bf $bfinfo * @return a new collection of type `That` which contains all elements * of this $coll followed by all elements of `that`. - * - * @return a new $coll which contains all elements of this $coll - * followed by all elements of `that`. */ def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = (that ++ seq)(breakOut) @@ -423,7 +420,8 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] /** Optionally selects the first element. * $orderDependent - * @return the first element of this $coll if it is nonempty, `None` if it is empty. + * @return the first element of this $coll if it is nonempty, + * `None` if it is empty. */ def headOption: Option[A] = if (isEmpty) None else Some(head) @@ -452,7 +450,8 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] /** Optionally selects the last element. * $orderDependent - * @return the last element of this $coll$ if it is nonempty, `None` if it is empty. + * @return the last element of this $coll$ if it is nonempty, + * `None` if it is empty. */ def lastOption: Option[A] = if (isEmpty) None else Some(last) @@ -486,7 +485,8 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] } else sliceWithKnownDelta(n, Int.MaxValue, -n) - def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until) + def slice(from: Int, until: Int): Repr = + sliceWithKnownBound(math.max(from, 0), until) // Precondition: from >= 0, until > 0, builder already configured for building. private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = { @@ -615,8 +615,8 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] /** Converts this $coll to a string. * * @return a string representation of this collection. By default this - * string consists of the `stringPrefix` of this $coll, - * followed by all elements separated by commas and enclosed in parentheses. + * string consists of the `stringPrefix` of this $coll, followed + * by all elements separated by commas and enclosed in parentheses. */ override def toString = mkString(stringPrefix + "(", ", ", ")") @@ -670,8 +670,8 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] * @param p the predicate used to test elements. * @return an object of class `WithFilter`, which supports * `map`, `flatMap`, `foreach`, and `withFilter` operations. - * All these operations apply to those elements of this $coll which - * satisfy the predicate `p`. + * All these operations apply to those elements of this $coll + * which satisfy the predicate `p`. */ def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p) @@ -719,8 +719,10 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] * * @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B] * - * @return a new $coll resulting from applying the given collection-valued function - * `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results. + * @return a new $coll resulting from applying the given + * collection-valued function `f` to each element of the + * outer $coll that satisfies predicate `p` and concatenating + * the results. */ def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) diff --git a/src/library/scala/parallel/Future.scala b/src/library/scala/parallel/Future.scala index 29faa06148..af06852b32 100644 --- a/src/library/scala/parallel/Future.scala +++ b/src/library/scala/parallel/Future.scala @@ -1,22 +1,24 @@ -package scala.parallel - - - - - +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala.parallel -/** A future is a function without parameters that will block the caller if the - * parallel computation associated with the function is not completed. +/** A future is a function without parameters that will block the caller if + * the parallel computation associated with the function is not completed. * * @since 2.9 */ trait Future[@specialized +R] extends (() => R) { - /** Returns a result once the parallel computation completes. If the computation - * produced an exception, an exception is forwarded. + /** Returns a result once the parallel computation completes. If the + * computation produced an exception, an exception is forwarded. * - * '''Note:''' creating a circular dependency between futures by calling this method will - * result in a deadlock. + * '''Note:''' creating a circular dependency between futures by calling + * this method will result in a deadlock. * * @tparam R the type of the result * @return the result @@ -31,5 +33,3 @@ trait Future[@specialized +R] extends (() => R) { def isDone(): Boolean } - - -- cgit v1.2.3