为什么需要 lex 中的规则?
就像此文件一样,我认为仅声明就足够了。
谁能解释为什么词法分析中需要规则?
在我看来,它们只在 .y
文件中是必要的...
根据规则,我谈论的是这样的块:
rdels {
if ($this->smarty->auto_literal) {
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
} else {
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
$this->yypopstate();
}
}
何时yypopstate
,和 yypushstate ?
Like this file,in my opinion only declaration is enough.
Can anyone explain why rules are necessary in lexical analysis?
In my opinion they're only necessary in .y
files...
By rule I'm talking about blocks like :
rdels {
if ($this->smarty->auto_literal) {
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
} else {
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
$this->yypopstate();
}
}
When to yypopstate
,and yypushstate
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当字符输入的含义可能不明确时,您将进入状态。
如果词法分析器遇到
"
(引号),您可能会输入一个名为“string”的状态 (yypushstate
),其中任何后续字符(否则将具有特殊含义)即+
、-
等)被视为字符串的一部分,当词法分析器遇到时,“string”状态已完成 (yypopstate
)。另一个"
。在 Flex 中,这些状态称为启动条件。
You enter states, when there can be ambiguous meanings to character input.
If the lexer encounters a
"
(quote), you might enter a state (yypushstate
) called "string" in which any following character, which would otherwise have a special meaning (i.e.+
,-
, etc.) is considered part of the string. The "string" state is finished (yypopstate
) when the lexer encounters another"
.In flex, these states are called start conditions.