diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2009-12-23 11:36:08 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2009-12-23 11:36:08 +0000 |
commit | 4069be072e8ad7ec53a1d91a639c03ad96d98070 (patch) | |
tree | dd49b65b4e9b28e8b47de46448efaedb84046357 /src/library | |
parent | 648a50a76eb865b3891092aff0fc06a92a9edf1c (diff) | |
download | scala-4069be072e8ad7ec53a1d91a639c03ad96d98070.tar.gz scala-4069be072e8ad7ec53a1d91a639c03ad96d98070.tar.bz2 scala-4069be072e8ad7ec53a1d91a639c03ad96d98070.zip |
Merged revisions 20262-20263,20266-20267,20269-...
Merged revisions
20262-20263,20266-20267,20269-20270,20284,20287-20289,20292,20294-20297,
20300 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r20262 | phaller | 2009-12-21 17:03:07 +0100 (Mon, 21 Dec 2009) | 1 line
closed #2829. review by rompf.
........
r20263 | phaller | 2009-12-21 17:36:37 +0100 (Mon, 21 Dec 2009) | 1 line
small correction in doc comment. no review.
........
r20266 | phaller | 2009-12-21 18:16:55 +0100 (Mon, 21 Dec 2009) | 1 line
closed #2181. no review.
........
r20267 | odersky | 2009-12-21 18:30:23 +0100 (Mon, 21 Dec 2009) | 3 lines
(1) Added some classes to allow arbitrary patches to source buffers.
These are not yet complete so do not need a review yet I think. (2)
Avoided reflexive array operations in ScalaRunTime. review by community.
........ r20269 | phaller | 2009-12-21 20:28:18 +0100 (Mon, 21 Dec 2009)
| 1 line
closed #1449. review by community.
........
r20270 | odersky | 2009-12-21 20:41:51 +0100 (Mon, 21 Dec 2009) | 2 lines
Closed #2709. Thanks for the patch! Review by community. ........
r20284 | rytz | 2009-12-22 10:56:21 +0100 (Tue, 22 Dec 2009) | 1 line
close #2809. thanks for the small example. review by community
........ r20287 | rytz | 2009-12-22 13:22:56 +0100 (Tue, 22 Dec 2009) |
1 line
fix the build. no review.
........
r20288 | prokopec | 2009-12-22 15:00:58 +0100 (Tue, 22 Dec 2009) | 2 lines
fixed #2548 - reverse, reverseIterator for views bug. Also - reverseMap for views now should work.
review by phaller.
........
r20289 | prokopec | 2009-12-22 15:32:16 +0100 (Tue, 22 Dec 2009) | 2 lines
Small change in test.
no review
........
r20292 | odersky | 2009-12-22 18:11:54 +0100 (Tue, 22 Dec 2009) | 1 line
Closes #2819, #2705, #2805. Review by community.
........
r20294 | odersky | 2009-12-22 18:57:13 +0100 (Tue, 22 Dec 2009) | 1 line
Closes #2812 (and removed a left-over println in Types). no review
necessary. ........ r20295 | phaller | 2009-12-22 19:15:43 +0100 (Tue,
22 Dec 2009) | 1 line
Closes #2538. no review necessary.
........
r20296 | extempore | 2009-12-22 21:11:29 +0100 (Tue, 22 Dec 2009) | 3 lines
Took full advantage of the new =>? alias for the superverbosely named
PartialFunction by renaming every usage of the latter except when in
comments. ........ r20297 | odersky | 2009-12-23 00:42:37 +0100 (Wed, 23
Dec 2009) | 2 lines
tentative fix for RC5 lift build problem.
........
r20300 | odersky | 2009-12-23 01:22:11 +0100 (Wed, 23 Dec 2009) | 2 lines
Another fix to make lift build under RC5; review by dragos ........
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Option.scala | 2 | ||||
-rw-r--r-- | src/library/scala/PartialFunction.scala | 12 | ||||
-rw-r--r-- | src/library/scala/collection/Iterator.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/SeqViewLike.scala | 11 | ||||
-rw-r--r-- | src/library/scala/collection/TraversableLike.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/TraversableProxyLike.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/interfaces/TraversableMethods.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/Publisher.scala | 3 | ||||
-rw-r--r-- | src/library/scala/concurrent/MailBox.scala | 6 | ||||
-rw-r--r-- | src/library/scala/package.scala | 2 | ||||
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 46 | ||||
-rw-r--r-- | src/library/scala/util/control/Exception.scala | 14 | ||||
-rw-r--r-- | src/library/scala/util/parsing/combinator/Parsers.scala | 14 |
13 files changed, 84 insertions, 36 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 8511fa78a5..6cb0fec929 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -110,7 +110,7 @@ sealed abstract class Option[+A] extends Product { * * @param pf the partial function. */ - def partialMap[B](pf: PartialFunction[A, B]): Option[B] = + def partialMap[B](pf: A =>? B): Option[B] = if (!isEmpty && pf.isDefinedAt(this.get)) Some(pf(this.get)) else None /** If the option is nonempty return it, diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala index 81ca2e4e10..f62fa68565 100644 --- a/src/library/scala/PartialFunction.scala +++ b/src/library/scala/PartialFunction.scala @@ -38,7 +38,7 @@ trait PartialFunction[-A, +B] extends (A => B) { * of this partial function and `that`. The resulting partial function * takes `x` to `this(x)` where `this` is defined, and to `that(x)` where it is not. */ - def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]) : PartialFunction[A1, B1] = + def orElse[A1 <: A, B1 >: B](that: A1 =>? B1) : A1 =>? B1 = new PartialFunction[A1, B1] { def isDefinedAt(x: A1): Boolean = PartialFunction.this.isDefinedAt(x) || that.isDefinedAt(x) @@ -54,7 +54,7 @@ trait PartialFunction[-A, +B] extends (A => B) { * @return a partial function with the same domain as this partial function, which maps * arguments `x` to `k(this(x))`. */ - override def andThen[C](k: B => C) : PartialFunction[A, C] = new PartialFunction[A, C] { + override def andThen[C](k: B => C): A =>? C = new PartialFunction[A, C] { def isDefinedAt(x: A): Boolean = PartialFunction.this.isDefinedAt(x) def apply(x: A): C = k(PartialFunction.this.apply(x)) } @@ -92,18 +92,18 @@ object PartialFunction * @param pf the partial function * @return true, iff `x` is in the domain of `pf` and `pf(x) == true`. */ - def cond[T](x: T)(pf: PartialFunction[T, Boolean]): Boolean = + def cond[T](x: T)(pf: T =>? Boolean): Boolean = (pf isDefinedAt x) && pf(x) - /** Transforms a PartialFunction[T,U] `pf' into Function1[T, Option[U]] `f' + /** Transforms a PartialFunction[T, U] `pf' into Function1[T, Option[U]] `f' * whose result is Some(x) if the argument is in pf's domain and None otherwise, * and applies it to the value `x'. In effect, it is a 'match' statement * which wraps all case results in Some(_) and adds 'case _ => None' to the end. * * @param x the value to test - * @param pf the PartialFunction[T,U] + * @param pf the PartialFunction[T, U] * @return `Some(pf(x))` if `pf isDefinedAt x`, `None` otherwise. */ - def condOpt[T,U](x: T)(pf: PartialFunction[T, U]): Option[U] = + def condOpt[T,U](x: T)(pf: T =>? U): Option[U] = if (pf isDefinedAt x) Some(pf(x)) else None } diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index 54a38848dd..5f28161ed3 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -411,7 +411,7 @@ trait Iterator[+A] { self => * @return a new iterator which yields each value `x` produced by this iterator for * which `pf` is defined the image `pf(x)`. */ - def partialMap[B](pf: PartialFunction[A, B]): Iterator[B] = { + def partialMap[B](pf: A =>? B): Iterator[B] = { val self = buffered new Iterator[B] { private def skip() = while (self.hasNext && !pf.isDefinedAt(self.head)) self.next() diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala index 66345ed311..1a8cd20013 100644 --- a/src/library/scala/collection/SeqViewLike.scala +++ b/src/library/scala/collection/SeqViewLike.scala @@ -117,10 +117,16 @@ trait SeqViewLike[+A, } trait Reversed extends Transformed[A] { - override def iterator: Iterator[A] = self.reverseIterator + override def iterator: Iterator[A] = createReversedIterator override def length: Int = self.length override def apply(idx: Int): A = self.apply(length - 1 - idx) override def stringPrefix = self.stringPrefix+"R" + + private def createReversedIterator = { + var lst = List[A]() + for (elem <- self) lst ::= elem + lst.iterator + } } trait Patched[B >: A] extends Transformed[B] { @@ -166,6 +172,9 @@ trait SeqViewLike[+A, override def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[This, B, That]): That = patch(length, fill(len - length)(elem), 0) + override def reverseMap[B, That](f: A => B)(implicit bf: CanBuildFrom[This, B, That]): That = + reverse.map(f) + override def stringPrefix = "SeqView" } diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 8c8f619b5e..f570c4ca9a 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -292,13 +292,13 @@ self => * `pf` to each element on which it is defined and collecting the results. * The order of the elements is preserved. * - * @usecase def partialMap[B](pf: PartialFunction[A, B]): $Coll[B] + * @usecase def partialMap[B](pf: A =>? B): $Coll[B] * * @return a new $coll resulting from applying the given partial function * `pf` to each element on which it is defined and collecting the results. * The order of the elements is preserved. */ - def partialMap[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { + def partialMap[B, That](pf: A =>? B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) for (x <- this) if (pf.isDefinedAt(x)) b += pf(x) b.result diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala index 24d6c7048d..d8e3ed2a1b 100644 --- a/src/library/scala/collection/TraversableProxyLike.scala +++ b/src/library/scala/collection/TraversableProxyLike.scala @@ -36,7 +36,7 @@ trait TraversableProxyLike[+A, +This <: TraversableLike[A, This] with Traversabl override def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[This, B, That]): That = self.++(that)(bf) override def map[B, That](f: A => B)(implicit bf: CanBuildFrom[This, B, That]): That = self.map(f)(bf) override def flatMap[B, That](f: A => Traversable[B])(implicit bf: CanBuildFrom[This, B, That]): That = self.flatMap(f)(bf) - override def partialMap[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[This, B, That]): That = self.partialMap(pf)(bf) + override def partialMap[B, That](pf: A =>? B)(implicit bf: CanBuildFrom[This, B, That]): That = self.partialMap(pf)(bf) override def filter(p: A => Boolean): This = self.filter(p) override def filterNot(p: A => Boolean): This = self.filterNot(p) override def partition(p: A => Boolean): (This, This) = self.partition(p) diff --git a/src/library/scala/collection/interfaces/TraversableMethods.scala b/src/library/scala/collection/interfaces/TraversableMethods.scala index 08ade7586d..4cf133d36a 100644 --- a/src/library/scala/collection/interfaces/TraversableMethods.scala +++ b/src/library/scala/collection/interfaces/TraversableMethods.scala @@ -24,7 +24,7 @@ trait TraversableMethods[+A, +This <: TraversableLike[A, This] with Traversable[ // maps/iteration def flatMap[B, That](f: A => Traversable[B])(implicit bf: CanBuildFrom[This, B, That]): That def map[B, That](f: A => B)(implicit bf: CanBuildFrom[This, B, That]): That - def partialMap[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[This, B, That]): That + def partialMap[B, That](pf: A =>? B)(implicit bf: CanBuildFrom[This, B, That]): That // new collections def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[This, B, That]): That diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala index da3e0c8238..4f675eff9f 100644 --- a/src/library/scala/collection/mutable/Publisher.scala +++ b/src/library/scala/collection/mutable/Publisher.scala @@ -48,7 +48,8 @@ trait Publisher[Evt] { protected def publish(event: Evt) { filters.keysIterator.foreach(sub => - if (filters.entryExists(sub, p => p(event))) + if (!suspended.contains(sub) && + filters.entryExists(sub, p => p(event))) sub.notify(self, event) ) } diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala index c23bbf1c80..3b00d6165d 100644 --- a/src/library/scala/concurrent/MailBox.scala +++ b/src/library/scala/concurrent/MailBox.scala @@ -26,7 +26,7 @@ class MailBox extends AnyRef with ListQueueCreator { def isDefinedAt(msg: Message): Boolean } - private class Receiver[A](receiver: PartialFunction[Message, A]) extends PreReceiver { + private class Receiver[A](receiver: Message =>? A) extends PreReceiver { def isDefinedAt(msg: Message) = receiver.isDefinedAt(msg) @@ -85,7 +85,7 @@ class MailBox extends AnyRef with ListQueueCreator { * Block until there is a message in the mailbox for which the processor * <code>f</code> is defined. */ - def receive[A](f: PartialFunction[Message, A]): A = { + def receive[A](f: Message =>? A): A = { val r = new Receiver(f) scanSentMsgs(r) r.receive() @@ -95,7 +95,7 @@ class MailBox extends AnyRef with ListQueueCreator { * Block until there is a message in the mailbox for which the processor * <code>f</code> is defined or the timeout is over. */ - def receiveWithin[A](msec: Long)(f: PartialFunction[Message, A]): A = { + def receiveWithin[A](msec: Long)(f: Message =>? A): A = { val r = new Receiver(f) scanSentMsgs(r) r.receiveWithin(msec) diff --git a/src/library/scala/package.scala b/src/library/scala/package.scala index 9fa09e3b72..bc5b5d36f2 100644 --- a/src/library/scala/package.scala +++ b/src/library/scala/package.scala @@ -64,6 +64,8 @@ package object scala { type Range = scala.collection.immutable.Range val Range = scala.collection.immutable.Range + type =>? [-A, +B] = PartialFunction[A, B] + // Migrated from Predef val $scope = scala.xml.TopScope diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index f6c4cf79dc..ebce675347 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -30,13 +30,49 @@ object ScalaRunTime { def isValueClass(clazz: Class[_]) = clazz.isPrimitive() /** Retrieve generic array element */ - def array_apply(xs: AnyRef, idx: Int): Any = java.lang.reflect.Array.get(xs, idx) + def array_apply(xs: AnyRef, idx: Int): Any = xs match { + case x: Array[AnyRef] => x(idx).asInstanceOf[Any] + case x: Array[Int] => x(idx).asInstanceOf[Any] + case x: Array[Double] => x(idx).asInstanceOf[Any] + case x: Array[Long] => x(idx).asInstanceOf[Any] + case x: Array[Float] => x(idx).asInstanceOf[Any] + case x: Array[Char] => x(idx).asInstanceOf[Any] + case x: Array[Byte] => x(idx).asInstanceOf[Any] + case x: Array[Short] => x(idx).asInstanceOf[Any] + case x: Array[Boolean] => x(idx).asInstanceOf[Any] + case x: Array[Unit] => x(idx).asInstanceOf[Any] + case null => throw new NullPointerException + } /** update generic array element */ - def array_update(xs: AnyRef, idx: Int, value: Any): Unit = java.lang.reflect.Array.set(xs, idx, value) + def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match { + case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef] + case x: Array[Int] => x(idx) = value.asInstanceOf[Int] + case x: Array[Double] => x(idx) = value.asInstanceOf[Double] + case x: Array[Long] => x(idx) = value.asInstanceOf[Long] + case x: Array[Float] => x(idx) = value.asInstanceOf[Float] + case x: Array[Char] => x(idx) = value.asInstanceOf[Char] + case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte] + case x: Array[Short] => x(idx) = value.asInstanceOf[Short] + case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean] + case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit] + case null => throw new NullPointerException + } /** Get generic array length */ - def array_length(xs: AnyRef): Int = java.lang.reflect.Array.getLength(xs) + def array_length(xs: AnyRef): Int = xs match { + case x: Array[AnyRef] => x.length + case x: Array[Int] => x.length + case x: Array[Double] => x.length + case x: Array[Long] => x.length + case x: Array[Float] => x.length + case x: Array[Char] => x.length + case x: Array[Byte] => x.length + case x: Array[Short] => x.length + case x: Array[Boolean] => x.length + case x: Array[Unit] => x.length + case null => throw new NullPointerException + } /** Convert a numeric value array to an object array. * Needed to deal with vararg arguments of primtive types that are passed @@ -64,7 +100,7 @@ object ScalaRunTime { if (x == null) throw new UninitializedError else x abstract class Try[+A] { - def Catch[B >: A](handler: PartialFunction[Throwable, B]): B + def Catch[B >: A](handler: Throwable =>? B): B def Finally(fin: => Unit): A } @@ -79,7 +115,7 @@ object ScalaRunTime { def run() { result = block } - def Catch[B >: A](handler: PartialFunction[Throwable, B]): B = + def Catch[B >: A](handler: Throwable =>? B): B = if (exception == null) result else if (handler isDefinedAt exception) handler(exception) else throw exception diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index 356b11df51..67f9ec183b 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -23,14 +23,14 @@ object Exception // We get lots of crashes using this, so for now we just use Class[_] // type ExClass = Class[_ <: Throwable] - type Catcher[+T] = PartialFunction[Throwable, T] - type ExceptionCatcher[+T] = PartialFunction[Exception, T] + type Catcher[+T] = Throwable =>? T + type ExceptionCatcher[+T] = Exception =>? T // due to the magic of contravariance, Throwable => T is a subtype of // Exception => T, not the other way around. So we manually construct // a Throwable => T and simply rethrow the non-Exceptions. implicit def fromExceptionCatcher[T](pf: ExceptionCatcher[T]): Catcher[T] = { - new PartialFunction[Throwable, T] { + new (Throwable =>? T) { def isDefinedAt(x: Throwable) = x match { case e: Exception if pf.isDefinedAt(e) => true case _ => false @@ -101,7 +101,7 @@ object Exception /** Create a new Catch with the same isDefinedAt logic as this one, * but with the supplied apply method replacing the current one. */ def withApply[U](f: (Throwable) => U): Catch[U] = { - val pf2 = new PartialFunction[Throwable, U] { + val pf2 = new (Throwable =>? U) { def isDefinedAt(x: Throwable) = pf isDefinedAt x def apply(x: Throwable) = f(x) } @@ -139,8 +139,8 @@ object Exception override def toString() = List("Try(<body>)", catcher.toString) mkString " " } - final val nothingCatcher: PartialFunction[Throwable, Nothing] = - new PartialFunction[Throwable, Nothing] { + final val nothingCatcher: Throwable =>? Nothing = + new (Throwable =>? Nothing) { def isDefinedAt(x: Throwable) = false def apply(x: Throwable) = throw x } @@ -207,7 +207,7 @@ object Exception classes exists (_ isAssignableFrom x.getClass) private def pfFromExceptions(exceptions: Class[_]*) = - new PartialFunction[Throwable, Nothing] { + new (Throwable =>? Nothing) { def apply(x: Throwable) = throw x def isDefinedAt(x: Throwable) = wouldMatch(x, exceptions) } diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala index 3aa7cc7de1..1205d2f911 100644 --- a/src/library/scala/util/parsing/combinator/Parsers.scala +++ b/src/library/scala/util/parsing/combinator/Parsers.scala @@ -93,7 +93,7 @@ trait Parsers { * `f' applied to the result of this `ParseResult', packaged up as a new `ParseResult'. * If `f' is not defined, `Failure'. */ - def mapPartial[U](f: PartialFunction[T, U], error: T => String): ParseResult[U] + def mapPartial[U](f: T =>? U, error: T => String): ParseResult[U] def flatMapWithNext[U](f: T => Input => ParseResult[U]): ParseResult[U] @@ -119,7 +119,7 @@ trait Parsers { */ case class Success[+T](result: T, override val next: Input) extends ParseResult[T] { def map[U](f: T => U) = Success(f(result), next) - def mapPartial[U](f: PartialFunction[T, U], error: T => String): ParseResult[U] + def mapPartial[U](f: T =>? U, error: T => String): ParseResult[U] = if(f.isDefinedAt(result)) Success(f(result), next) else Failure(error(result), next) @@ -146,7 +146,7 @@ trait Parsers { lastNoSuccess = this def map[U](f: Nothing => U) = this - def mapPartial[U](f: PartialFunction[Nothing, U], error: Nothing => String): ParseResult[U] = this + def mapPartial[U](f: Nothing =>? U, error: Nothing => String): ParseResult[U] = this def flatMapWithNext[U](f: Nothing => Input => ParseResult[U]): ParseResult[U] = this @@ -345,7 +345,7 @@ trait Parsers { * @return a parser that succeeds if the current parser succeeds <i>and</i> `f' is applicable * to the result. If so, the result will be transformed by `f'. */ - def ^? [U](f: PartialFunction[T, U], error: T => String): Parser[U] = Parser{ in => + def ^? [U](f: T =>? U, error: T => String): Parser[U] = Parser{ in => this(in).mapPartial(f, error)}.named(toString+"^?") /** A parser combinator for partial function application @@ -358,7 +358,7 @@ trait Parsers { * @return a parser that succeeds if the current parser succeeds <i>and</i> `f' is applicable * to the result. If so, the result will be transformed by `f'. */ - def ^? [U](f: PartialFunction[T, U]): Parser[U] = ^?(f, r => "Constructor function not defined at "+r) + def ^? [U](f: T =>? U): Parser[U] = ^?(f, r => "Constructor function not defined at "+r) /** A parser combinator that parameterises a subsequent parser with the result of this one @@ -495,7 +495,7 @@ trait Parsers { * @return A parser that succeeds if `f' is applicable to the first element of the input, * applying `f' to it to produce the result. */ - def accept[U](expected: String, f: PartialFunction[Elem, U]): Parser[U] = acceptMatch(expected, f) + def accept[U](expected: String, f: Elem =>? U): Parser[U] = acceptMatch(expected, f) def acceptIf(p: Elem => Boolean)(err: Elem => String): Parser[Elem] = Parser { in => @@ -503,7 +503,7 @@ trait Parsers { else Failure(err(in.first), in) } - def acceptMatch[U](expected: String, f: PartialFunction[Elem, U]): Parser[U] = Parser{ in => + def acceptMatch[U](expected: String, f: Elem =>? U): Parser[U] = Parser{ in => if (f.isDefinedAt(in.first)) Success(f(in.first), in.rest) else Failure(expected+" expected", in) } |