微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Scala解析组合器语法错误~函数

如何解决Scala解析组合器语法错误~函数

我正在制作一个带有 Scala 解析组合器的空闲时间项目,遵循 this guide添加到带有 sbt 的项目中:

b= img(:,:,1)
 g=img(:,2)
 r=img(:,3)

我有一个可以编译的词法分析器,但解析器在这代码中给了我这个错误libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.0.0"

method ~ in class Parser has changed semantics in version SpecificScalaVersion(2,9,Final): The call-by-name argument is evaluated at most once per constructed Parser object,instead of on every need that arises during parsing.

这是import scala.util.parsing.input.Positional sealed trait AbstractSyntaxTree extends Positional sealed trait Instruction extends AbstractSyntaxTree final case class Label(text: String) extends Instruction package svm.parser import scala.util.parsing.combinator.Parsers import scala.util.parsing.input.{noposition,Position,Reader} import svm.{ParserError,Location} import svm.lexer._ object SVMParser extends Parsers { def label: Parser[Label] = positioned { identifier ~ COL() ^^ { case IDENTIFIER(s) ~ _ => Label(s) } } } 输出

sbt compile

我用错了 [error] -- [E114] Syntax Error: /home/ap/Documents/scala/simple-stack-virtual-machine/src/main/scala/svm/parser/SVMParser.scala:59:15 [error] 59 | identifier ~ COL() ^^ { case IDENTIFIER(s) ~ _ => Label(s) } [error] | ^^^^^^^^^^^^ [error] | |method ~ in class Parser has changed semantics in version SpecificScalaVersion(2,instead of on every need that arises during parsing. [error] Explanation [error] =========== [error] The |method ~ in class Parser is marked with @migration indicating it has changed semantics [error] between versions and the -Xmigration settings is used to warn about constructs [error] whose behavior may have changed since version change. 运算符?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。