我是 Scala 的新手,一直在尝试使用其出色的组合解析器库。我一直试图让这段代码编译:
import scala.util.parsing.combinator._
...
val r:Parsers#ParseResult[Node] = parser.parseAll(parser.suite,reader)
r match {
case Success(r, n) => println(r)
case Failure(msg, n) => println(msg)
case Error(msg, n) => println(msg)
}
...
但我不断收到这些错误:
TowelParser.scala:97: error: not found: value Success
case Success(r, n) => println(r)
^
TowelParser.scala:98: error: not found: value Failure
case Failure(msg, n) => println(msg)
TowelParser.scala:99: error: object Error is not a case class constructor, nor does it have an unapply/unapplySeq method
case Error(msg, n) => println(msg)
我尝试了很多不同的方法,例如:
case Parsers#Success(r, n) => println(r)
和
case Parsers.Success(r, n) => println(r)
和
import scala.util.parsing.combinator.Parsers.Success
但我似乎无法编译它。我确信我可能缺少一些明显的东西,但我已经做了一段时间了,谷歌似乎没有任何好的例子。
谢谢!