summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-05-22 13:00:42 +0000
committerMartin Odersky <odersky@gmail.com>2008-05-22 13:00:42 +0000
commit0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4 (patch)
treec094dde843c92f9a72d59380bd22db31f9033b26 /src
parente327bbb7bf463195c7eccaa2a399f283a849fdab (diff)
downloadscala-0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4.tar.gz
scala-0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4.tar.bz2
scala-0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4.zip
fixed #911. Added comments to <~ and ~> methods.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala13
-rw-r--r--src/library/scala/util/parsing/combinator/Parsers.scala20
2 files changed, 27 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index e971e4138d..216029b64f 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -446,11 +446,14 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
if (tree.symbol.isClassConstructor) {
atOwner(tree.symbol) {
val rhs1 = (rhs: @unchecked) match {
- case Block(stat :: stats, expr) =>
- copy.Block(
- rhs,
- withInConstructorFlag(INCONSTRUCTOR) { transform(stat) } :: transformTrees(stats),
- transform(expr));
+ case Block(stats, expr) =>
+ def transformInConstructor(stat: Tree) =
+ withInConstructorFlag(INCONSTRUCTOR) { transform(stat) }
+ val presupers = treeInfo.preSuperFields(stats) map transformInConstructor
+ val rest = stats drop presupers.length
+ val supercalls = rest take 1 map transformInConstructor
+ val others = rest drop 1 map transform
+ copy.Block(rhs, presupers ::: supercalls ::: others, transform(expr))
}
copy.DefDef(
tree, mods, name, transformTypeDefs(tparams),
diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala
index b6c30abe17..1061b85ac8 100644
--- a/src/library/scala/util/parsing/combinator/Parsers.scala
+++ b/src/library/scala/util/parsing/combinator/Parsers.scala
@@ -230,9 +230,27 @@ trait Parsers {
*/
def ~ [U](p: => Parser[U]): Parser[~[T, U]] = (for(a <- this; b <- p) yield new ~(a,b)).named("~")
+ /** A parser combinator for sequential composition which keeps only the right result
+ *
+ * <p> `p ~> q' succeeds if `p' succeeds and `q' succeeds on the input
+ * left over by `p'.</p>
+ *
+ * @param q a parser that will be executed after `p' (this parser) succeeds
+ * @return a `Parser' that -- on success -- returns the result of `q'.
+ */
def ~> [U](p: => Parser[U]): Parser[U] = (for(a <- this; b <- p) yield b).named("~>")
- def <~ [U](p: => Parser[U]): Parser[T] = (for(a <- this; b <- p) yield a).named("<~")
+ /** A parser combinator for sequential composition which keeps only the left result
+ *
+ * <p> `p &lt;~ q' succeeds if `p' succeeds and `q' succeeds on the input
+ * left over by `p'.</p>
+ *
+ * <b>Note:</b> &lt;~ has lower operator precedence than ~ or ~>.
+ *
+ * @param q a parser that will be executed after `p' (this parser) succeeds
+ * @return a `Parser' that -- on success -- returns the result of `p'.
+ */
+ def <~ [U](p: => Parser[U]): Parser[T] = (for(a <- this; b <- p) yield a).named("<~")
/* not really useful: V cannot be inferred because Parser is covariant in first type parameter (V is always trivially Nothing)
def ~~ [U, V](q: => Parser[U])(implicit combine: (T, U) => V): Parser[V] = new Parser[V] {