Skip to content

Revert "make RegexParser.err handle whitespace like literal and regex." #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.typesafe.tools.mima.plugin.{MimaPlugin, MimaKeys}
import com.typesafe.tools.mima.core.{ProblemFilters, MissingMethodProblem}

scalaModuleSettings

@@ -32,5 +31,3 @@ test in Test := {
MimaKeys.reportBinaryIssues.value
(test in Test).value
}

MimaKeys.binaryIssueFilters += ProblemFilters.exclude[MissingMethodProblem]("scala.util.parsing.combinator.RegexParsers.scala$util$parsing$combinator$RegexParsers$$super$err")
16 changes: 0 additions & 16 deletions src/main/scala/scala/util/parsing/combinator/RegexParsers.scala
Original file line number Diff line number Diff line change
@@ -137,22 +137,6 @@ trait RegexParsers extends Parsers {
}
}

// we might want to make it public/protected in a future version
private def ws[T](p: Parser[T]): Parser[T] = new Parser[T] {
def apply(in: Input) = {
val offset = in.offset
val start = handleWhiteSpace(in.source, offset)
p(in.drop (start - offset))
}
}

/**
* @inheritdoc
*
* This parser additionnal skips whitespace if `skipWhitespace` returns true.
*/
override def err(msg: String) = ws(super.err(msg))

override def phrase[T](p: Parser[T]): Parser[T] =
super.phrase(p <~ opt("""\z""".r))

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala.util.parsing.combinator

import org.junit.Test
import org.junit.Assert.{assertEquals,assertTrue}
import org.junit.Assert.assertEquals

class RegexParsersTest {
@Test
@@ -73,19 +73,4 @@ class RegexParsersTest {
val success = parseAll(twoWords, "first second").asInstanceOf[Success[(String, String)]]
assertEquals(("second", "first"), success.get)
}

@Test
def errorConsumesWhitespace: Unit = {
object parser extends RegexParsers {
def num = "\\d+".r

def twoNums = num ~ (num | err("error!"))
}
import parser._

// this used to return a Failure (for the second num)
val error = parseAll(twoNums, "458 bar")
assertTrue(s"expected an Error but got: ${error.getClass.getName}", error.isInstanceOf[Error])
assertEquals("error!", error.asInstanceOf[Error].msg)
}
}