比较解决相互递归性

发布于 2024-12-20 21:49:19 字数 133 浏览 3 评论 0原文

在这种情况下如何解决相互递归?

value : comparison | 'A' | 'B' | 'C';

comparison : value comparison_operator value;

How can I solve mutual recursivity in this case?

value : comparison | 'A' | 'B' | 'C';

comparison : value comparison_operator value;

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

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

发布评论

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

评论(2

旧伤慢歌 2024-12-27 21:49:19

嗯,问题在于它的给出的含义是模糊的。您希望它对 A这样的输入执行什么操作? BC 其中 与您的 Comparison_operator 规则相匹配?如果您想要相当于 A; (BC) 那么它就很简单了:

primary: 'A' | 'B' | 'C';
comparison: primary | primary comparison_operator comparison;
value: comparison;

如果你想要别的东西,它就会变得更复杂。

Well, the problem is that its ambiguous as given. What do you want it to do for an input like A <op> B <op> C where <op> is something that matches your comparison_operator rule? If you want the equivalent of A <op> (B <op> C) then its quite easy:

primary: 'A' | 'B' | 'C';
comparison: primary | primary comparison_operator comparison;
value: comparison;

If you want something else, it becomes more complex.

╭ゆ眷念 2024-12-27 21:49:19

像这样固定:

atom : variable | literal | call | constructor | (PARAM_START comparison PARAM_END);

comparison : (atom comparison_operator atom);

value : atom | comparison;

Fixed like so:

atom : variable | literal | call | constructor | (PARAM_START comparison PARAM_END);

comparison : (atom comparison_operator atom);

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