summaryrefslogtreecommitdiff
path: root/src/library
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/library
parente327bbb7bf463195c7eccaa2a399f283a849fdab (diff)
downloadscala-0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4.tar.gz
scala-0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4.tar.bz2
scala-0bc0b0bbc65c4ece2be76c62c1dea58d4358a4d4.zip
fixed #911. Added comments to <~ and ~> methods.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/util/parsing/combinator/Parsers.scala20
1 files changed, 19 insertions, 1 deletions
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] {