生产中可选的非终端

发布于 2024-12-05 10:28:38 字数 461 浏览 1 评论 0原文

有谁知道以下情况如何处理?

if-section:
    if-group [ elif-groups ] [ else-group ] endif-line

if-group:
    ....

elif-groups:
    elif-group
    elif-groups elif-group

elif-group:
    "#" "elif" constant-expression new-line [ group ]

else-group:
    "#" "else" new-line [ group ]

endif-line:
    "#" "endif" new-line

if-group 后的 if-section 中的所有非终结符均以“#”开头。我认为在这种情况下,左因式分解是不可能的。是否有任何“默认解决方案”来确定我是否必须调用两个(或两个)可选非终端之一?

谢谢。

Does anyone know how to handle the following case?

if-section:
    if-group [ elif-groups ] [ else-group ] endif-line

if-group:
    ....

elif-groups:
    elif-group
    elif-groups elif-group

elif-group:
    "#" "elif" constant-expression new-line [ group ]

else-group:
    "#" "else" new-line [ group ]

endif-line:
    "#" "endif" new-line

All non-terminals in if-section after if-group starting with "#". I think in this case there is left-factoring impossible. Are there any "default solutions" to identify if I have to call one of the both (or both) optional non-terminals?

Thanks.

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

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

发布评论

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

评论(1

桃酥萝莉 2024-12-12 10:28:39

我不清楚需要处理什么。当您只看到 # 时,您无法区分 [ elif-groups ][ else-group ] ,不。但如果你向前看另一个令牌,你就可以。即两个令牌足以决定。

到目前为止,这还不是 C++ 语法中最糟糕的部分。

I'm unclear what needs handling. You can't distinguish between [ elif-groups ] and [ else-group ] when you've seen just #, no. But if you look ahead another token, you can. I.e. two tokens is enough to decide.

This isn't the worse bit of C++ grammar by far.

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