grammar - 使用 $/ 与在语法操作中使用任何其他变量并不完全相同
问题描述
理论上,根据文档,您可以在语法操作中为方法使用任何参数。
grammar G {
token TOP { \w+ }
}
class Action-Arg {
method TOP ($match) { $match.make: ~$match }
}
class Action {
method TOP ($/) { make ~$/ }
}
class Action-Fails {
method TOP ($match) { make ~$match }
}
say G.parse( "zipi", actions => Action-Arg );
say G.parse( "zape", actions => Action );
say G.parse( "pantuflo", actions => Action-Fails );
但是,前两个版本按预期工作。但是第三个(这将是第二个的直接翻译)失败了
Cannot bind attributes in a Nil type object
in method TOP at match-and-match.p6 line 19
in regex TOP at match-and-match.p6 line 7
in block <unit> at match-and-match.p6 line 24
可能有一些特殊的语法正在发生(make
实际上$/.make
,可能),但我想澄清一下这是否符合规范或者是一个错误。
解决方案
推荐阅读
- javascript - 复选框永远不会检查 - 即使值为 true
- jfrog - 无法登录到 jfrog 中的虚拟存储库
- python - 如何将由 json/dict 条目制成的数据框拆分为多个列以进行遍历?
- google-cloud-platform - 谷歌云存储桶的扩容授权
- wordpress - 单个 wordpress 安装 + IIS 反向代理 = 主页上的重定向太多
- node.js - Mineflayer 可以在携带版服务器上运行吗?
- reactjs - 通过道具后无法查看倒计时时间
- alert - 根据图纸创建警报?
- mule - 在 mule 的安全属性中接受的特殊字符
- json - 我无法从 Parse 获取 sessionToken