当前,我试图解析Scala中的一个Reader[Token]。因此,我想在分析步骤中检查Token是否是特定类的元素(例如AToken)。 我可以用下面的代码做到这一点很容易: def aToken = acceptIf(_.isInstanceOf[AToken])("Token " + _ + " is not of type AToken")
^^ { _.asInstanceOf
的Wikipedia文章PEG解析器定义了以下组合子:真正需要 2.Given any existing parsing expressions e, e1, and e2,
a new parsing expression can be constructed using the following operators:
Sequence: e1 e2
Ordered choice: e
我想提出以下,从一个动态填充列表: val primitives = "x" | "y" | "z" // what I want
val primitives2 = List("x", "y", "z") // what I need to transform from
我想这样的事情可能工作: primitives2.reduce(_|_)
但没有去。后来我发现这个片段中,其工作原