开发者

What's the naming convention of a lexer?

开发者 https://www.devze.com 2023-02-05 21:59 出处:网络
function yy_r9_1($yy_subpatterns) { $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE; 开发者_高级运维
    function yy_r9_1($yy_subpatterns)
    {

  $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE; 开发者_高级运维 
  $this->yypopstate();
    }

The above is from the lexer of smarty in PHP,anyone knows what yy_r9_1 means?


yy is YACC's prefix to avoid collisions. Back in the days when YACC was built, there were no namespaces or classes, not even structs. Actually YACC was initially written in B, the predecessor of C.

r9 probably stands for rule number 9 and 1 may be an incremental prefix for rules that require multiple functions to be processed.

However, even if I'm wrong and these strings mean something else, I doubt you can make any use of this information. This would require deep understanding of the internals of the lexer and parser and last but not least of the grammar rules. If you understand the grammar, you could as well change it and re-generate the lexer instead of using or even manipulating it's subroutines.

0

精彩评论

暂无评论...
验证码 换一张
取 消