What's the naming convention of a lexer?
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.
精彩评论