Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import org.parboiled.scala._
import org.parboiled.errors.ErrorUtils
import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.ShouldMatchers
@RunWith(classOf[JUnitRunner])
class IsolationTest extends FlatSpec with ShouldMatchers {
val input = "abcdxyz"
"Text rule" should "parse different lengths" in {
val result = ReportingParseRunner(FailingParser.Input).run(input)
println(ErrorUtils.printParseErrors(result))
result should be ('matched)
}
}
object FailingParser extends Parser {
def Input = rule { Text(4) ~ Text(3) }
// def Text(places: Int) = nTimes(places, ANY) // works
def Text(places: Int) = rule { nTimes(places, ANY) } // doesn't work
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.