我有以下解析器来解析包含 Float 和 RDD 的算术表达式:
import scalaz._
import Scalaz._
def term2: Parser[List[\/[Float, RDD[(Int,Array[Float])]]]] = rep(factor2)
def factor2: Parser[\/[Float, RDD[(Int,Array[Float])]]] = pathxml | num
def pathxml: Parser[ RDD[(Int,Array[Float])]] = pathIdent ^^ { s => pathToRDD(s)} //pathToRDD is a function that gets the path in string and create an RDD from the file inside that path and pathIdent parse to see whether the input string is a path or not
def num: Parser[\/[Float, RDD[(Int,Array[Float])]]] = floatingPointNumber ^^ (n => n.left[RDD[(Int,Array[Float])]].toFloat)
收到以下错误:
[error] type mismatch;
[error] found : ParseExp.this.Parser[Serializable]
[error] required: ParseExp.this.Parser[scalaz.\/[Float,org.apache.spark.rdd.RDD[(Int, Array[Float])]]]
[error] def factor2: Parser[\/[Float, RDD[(Int,Array[Float])]]] = pathxml | num
[error] ^
我是 Scala 新手,不知道如何解决这个错误