Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找玩 perl 解析器操作。看起来各种B::Hooks模块都是人们使用的。我想知道:
B::Hooks
对于没有XS经验的人来说,最好的起点(还)。有没有相关的博文?
XS
创建一个新的算子需要做多少工作,例如:
$a~>one~>two~>three
~>会正常工作,->但它不会尝试调用,undef而是简单地返回undefLHS。
~>
->
undef
尽管源过滤器可以工作——我更感兴趣的是了解如何在更深层次上操作解析器。
我不相信您可以添加中缀运算符(操作数在运算符之前和之后的运算符),更不用说符号运算符(与命名运算符相反),但是您可以编写一个替换方法调用的操作检查器。这意味着您可能会导致->foo行为不同。通过将模块编写为编译指示,您可以将模块的效果限制在词法范围内(例如{ use mypragma; ...})。
->foo
{ use mypragma; ...}