可以在 Raku 中编写 NQP 的优先级解析器

It is possible to write NQP's precedence parser in Raku

我正在尝试弄清楚如何在 Raku 中重写 NQP 的优先级解析器:

优先解析器在此处实现:https://github.com/Raku/nqp/blob/master/src/HLL/Grammar.nqp#L384 NQP 应该是 Raku 的一个子集,但语法部分似乎是专门的。

如果我想在 Raku 中重写 EXPR() 中的 Precedence Parser, 要使用的 Raku Grammar 原语是什么? IE。 cursor_start_cur() 会翻译成什么? Raku 语法中有 cursor 吗?如何设置 Raku Match 对象的 pos$termcur.MATCH() 会翻译成什么,等等...

我不是在寻找编写优先解析器的不同方法, 但想知道它是否可以像 NQP 那样在 Raku 中完成。

jnthn 在 IRC 中写道:

rule EXPR { <termish> [<infix> <termish>]* } 
token termish { <prefix>* <term> <postfix>* }

然后在 action 方法中完成优先排序。

有一个示例 https://github.com/Apress/perl-6-regexes-and-grammars/blob/master/chapter-13-case-studies/operator-precedence-parser-class.p6 from the book https://www.apress.com/us/book/9781484232279 实现了相同的结构。