Gold 解析器中的错误? 左旋受体
这是我的 bnf 语法的一部分。
//this works
<ter-stmnt> ::= <rval> '?' <rval> ':' <rval>
//this gets an error
<ter-stmnt> ::= <bool-val> '?' <rval> ':' <rval>
<bool-val> ::= <rval>
这看起来很疯狂,第二个不应该与第一个完全相同吗? 我在阅读时更喜欢第二个 bc ,我看到我期望一个 bool 值,而不是通用的 rval ,它可以意味着任何东西。
我正在使用 Gold Parser 3.4.4
Here is a piece of my bnf grammer.
//this works
<ter-stmnt> ::= <rval> '?' <rval> ':' <rval>
//this gets an error
<ter-stmnt> ::= <bool-val> '?' <rval> ':' <rval>
<bool-val> ::= <rval>
This seems insane, shouldnt the second be EXACTLY the same as the first? i prefer the second bc when reading i see that i expect a bool value as oppose to the generic rval which can mean anything.
I am using Gold Parser 3.4.4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到的错误是:
也就是说,在评估了一些标记后,它无法决定是读取
还是读取
。为了更有意义,您的语法应该具体说明
是什么,然后说
是< ;bool-val>
或其他东西。这是另一个 reduce/reduce 错误的示例,以及 这里是 GOLD 文档。 Gold 将尝试隐藏(即发出警告而不是错误)有关移位/归约的信息,但它将归约/归约视为错误。
我不太明白这一点; 我是解析新手。 也许您认为这是意外行为是对的? 然而,GOLD 邮件列表目前似乎已关闭,可能是因为它已被审核并且 Devin 已经离线数月了。
The error that you're getting is:
It's saying that after it's evaluated some tokens, it's unable to decide whether it's just read a
<bool-val>
or whether it read an<rval>
.To make more sense your grammar ought to say what a
<bool-val>
is, specifically, and then say that an<rval>
is a<bool-val>
or other things.Here's another example of a reduce/reduce error, and here's the GOLD documentation. Gold will try to hide (i.e. emit a warning instead of an error) about a shift/reduce, but it treats reduce/reduce as an error.
I don't entirely understand this; I'm new to parsing. Maybe you're right about this being unexpected behaviour? However the GOLD mailing list seems to be down at the moment, perhaps because it's moderated and Devin has been offline for months.
你得到什么错误? 你能包含你的整个语法文件吗? 如果我声明如下规则,我不会收到任何错误:
What error do you get? Can you include your whole grammar file? I don't get any error if I declare rules like ...