3
当我只引用下面代码中显示的名称时,我收到了“子例程深度递归”警告。 use 5.016 … __SUB__
->()也没有帮助。在Hammer解析器组合器中,你如何实现一个引用自身的规则?
构建提示:git clone; scons bindings = perl test; cd build/opt/src/bindings/perl; $ EDITOR h.pl
use 5.024;
use strictures;
use blib;
use hammer qw();
# digits = "0"/"1"/"2"/"3"/"4"/"5"/"6"/"7"/"8"/"9"
sub digits { hammer::many hammer::in 0..9 }
# product = digits "*" digits
sub product {
hammer::sequence digits, hammer::ch('*'), digits
}
product->parse('23*42'); # [[2, 3], '*', [4, 2]]
# mproduct = digits "*" mproduct
sub mproduct;
sub mproduct {
hammer::sequence digits, hammer::ch('*'), mproduct
}
mproduct->parse('8*23*42');
# Deep recursion on subroutine "main::mproduct" at h.pl line 21.
如果[hammer](https://github.com/abiggerhammer/hammer)是一个递归下降解析器,那么是否不允许自引用规则? – jeff6times7
你如何认为它是rec.descent? – daxim
我尽可能多地阅读了docs/hammer-presentation.pdf以及一些源文件。我误解了什么?我不熟悉那些代码,我有兴趣找到更快的解析器,这是作者声称的。你的问题激发了我的兴趣。 – jeff6times7