2016-10-03 308 views
1

我在读sbt documentation on Commands,想知道^^^~>是什么意思?`^^^`和`〜>`是什么意思?

我试图谷歌,但没有发现,这些字符是由谷歌躲过我猜......非常感谢

// Demonstration of a custom parser. 
    // The command changes the foreground or background terminal color 
    // according to the input. 
    lazy val change = Space ~> (reset | setColor) 
    lazy val reset = token("reset" ^^^ "\033[0m") 
    lazy val color = token(Space ~> ("blue" ^^^ "4" | "green" ^^^ "2")) 
    lazy val select = token("fg" ^^^ "3" | "bg" ^^^ "4") 
    lazy val setColor = (select ~ color) map { case (g, c) => "\033[" + g + c + "m" } 

    def changeColor = Command("color")(_ => change) { (state, ansicode) => 
    print(ansicode) 
    state 
    } 

完整的代码为例project/CommandExample.scalahttp://www.scala-sbt.org/0.13/docs/Commands.html

回答

7

这些都是对方法RichParser类。

http://www.scala-sbt.org/0.13/api/#sbt.complete.RichParser

提示。如果您查找符号方法,请单击api文档页面左上角的'#'。

  • ^^^[B](value: B): Parser[B]:应用原始解析器,但如果成功则提供值作为结果。
  • ~>[B](b: Parser[B]): Parser[B]:生成应用原始解析器的解析器,然后应用下一个(按顺序),放弃原解析器的结果。
+0

谢谢,正是我在找的:) – keypoint