このコードで
import scala.util.parsing.combinator.JavaTokenParsers
class TestKeywords extends JavaTokenParsers {
def keywords: Parser[String] = "update"
def identifier: Parser[String] = not(keywords) ~> """[a-zA-Z0-9_$#]+""".r
def script: Parser[Any] = repsep(identifier,",")
}
object TestKeywordsApp extends TestKeywords with App {
val cmd = """updateDet,update"""
parseAll(script,
cmd.stripMargin) match {
case Success(lup, _) => println(lup)
case x => println(x)
}
}
エラーが発生します
[1.1] 失敗: 文字列に一致する正規表現
\z' expected but
u' が見つかりましたupdateDet,update
修正方法は?updateDet はキーワードとして認識すべきではない
スカラ 2.10.2