词法分析的状态/转移图 - *(星号)收回前向指针有什么意义?

发布于 2024-12-23 02:10:17 字数 355 浏览 1 评论 0原文

我正在阅读《编译器:原理、技术和工具》,但不明白这一点:

另外,如果需要将前向指针缩回一个位置 (即,词位不包括让我们接受的符号 状态),那么我们将在该接受状态附近另外放置一个 * 。在 在我们的例子中,永远不需要向前缩回超过一 位置,但如果是的话,我们可以将任意数量的 * 附加到接受的位置 状态。

这一切都有道理,但我不明白星号的意义。这本书只是在正则表达式中使用它(Kleene 星/闭包),它是否被用来表示其他东西,或者仍然是 Kleene 星?

I'm reading Compilers: Principles, Techniques, and Tools and don't understand this:

In addition, if it is necessary to retract the forward pointer one position
(i.e., the lexeme does not include the symbol that got us to the accepting
state), then we shall additionally place a * near that accepting state. In
our example, it is never necessary to retract forward by more than one
position, but if it were, we could attach any number of *'s to the accepting
state.

That all makes sense, but I don't understand the significance of the asterisk. The book was just using it in regular expressions (Kleene star/closure), is it being used to represent something else, or still Kleene star?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒废 2024-12-30 02:10:17

不,这不是 Kleene 星,文本对此进行了解释,它实质上是说放回最后一个标记,因为该字符不属于可接受的字符。例如,如果您考虑只是一个 <,那么您在 RE 中读取了两个字符,但您实际上并不想读取第二个字符,因此您将其放回去,以便任何后续读取都将先找到它。

一般来说,在完整的 FSM(有限状态机)中,您不会遇到这种情况,因为它将处理完整的词法语法,但由于它们仅显示语法的一部分,因此需要使用此设备。在此示例中,“其他”弧将进入另一个状态(作为更多弧)。

No, it's not the Kleene star, the text explains it, it says essentially to put back the last token because that character is not part of the accepted characters. If you consider for example just a <, then you read two characters in the RE, but you don't actually want to read the 2nd one, so you put it back so that any subsequent read will find it first.

Generally in a complete FSM (finite state machine), you would not have this situation as it would deal with the complete lexical syntax, but since they are showing just a part of a syntax they need to use this device. In this example, the "other" arc would go to another states (as more arcs).

反话 2024-12-30 02:10:17

对于缩回部分->考虑x

for the retraction part -> consider x<y, here y is the "other" we are talking about.
after reading "x<y", we need to put y back to the buffer since it maybe of any requirement for next lexeme processing.
This "putting back to the buffer" is referred as retracting

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文