从操作接受 yacc 规则

发布于 2024-08-25 15:31:12 字数 149 浏览 7 评论 0原文

是否可以结合 %glr-parser 指令活动接受来自操作的野牛规则?

如下所示:

aRule : 'a' 'b' 'c' { /* 进行一些计算,并根据您允许/禁止此规则的内容进行一些计算,并继续解析而不从 yyparse 函数返回。 */ } ;

Is it possible to accept a bison-rule from the action in combination with the %glr-parser directive active?

Something like the following:

aRule : 'a' 'b' 'c' { /* Do some calculations and depending on those you allow/disallow this rule and continue the parsing without returning from the yyparse function. */ } ;

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

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

发布评论

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

评论(1

长安忆 2024-09-01 15:31:12

AFAICS 无法动态启用或禁用语法的某些部分。作为一种破解,您可以在分支中添加特殊标记作为防护,并让标记生成器在满足某些条件时生成此额外标记(我有时使用额外的 FORCE_ERROR 标记来强制解析错误)。是的,这很丑陋。

AFAICS there is no way to dynamically enable or disable some parts of the grammer. As a hack you can add special tokens as guards in the branches and let the tokenizer yield this extra tokens when some condition is met (I sometimes use an extra FORCE_ERROR token to force parse errors). And yes, this is ugly.

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