Happy 中的 %% 代表什么?

发布于 2024-12-20 08:17:01 字数 230 浏览 3 评论 0原文

我正在使用 Happy 构建一个解析器,并注意到这是在线文档 :

像 yacc 一样,我们在这里包含 %%,但没有真正的原因。

%%

但一定有一个原因,即使它是微不足道的。有谁知道它是什么?

I'm building a parser with Happy and noticed this is the online documentation:

Like yacc, we include %% here, for no real reason.

%%

There must be a reason though, even if it's trivial. Does anyone know what it is?

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

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

发布评论

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

评论(1

她说她爱他 2024-12-27 08:17:01

它分隔 Yacc 源文件中的各个部分。例如参见 http://dinosaur.compilertools.net/yacc/

Names refer to either tokens or nonterminal symbols. Yacc requires token names 
to be declared as such. In addition, for reasons discussed in Section 3, it is 
often desirable to include the lexical analyzer as part of the specification 
file; it may be useful to include other programs as well. Thus, every 
specification file consists of three sections: the declarations, (grammar) 
rules, and programs. The sections are separated by double percent ``%%'' marks. 
(The percent ``%'' is generally used in Yacc specifications as an escape 
character.)

In other words, a full specification file looks like

        declarations
        %%
        rules
        %%
        programs
The declaration section may be empty. Moreover, if the programs section is 
omitted, the second %% mark may be omitted also; thus, the smallest legal Yacc 
specification is

        %%
        rules

It separates the sections in a Yacc source file. e.g. See http://dinosaur.compilertools.net/yacc/

Names refer to either tokens or nonterminal symbols. Yacc requires token names 
to be declared as such. In addition, for reasons discussed in Section 3, it is 
often desirable to include the lexical analyzer as part of the specification 
file; it may be useful to include other programs as well. Thus, every 
specification file consists of three sections: the declarations, (grammar) 
rules, and programs. The sections are separated by double percent ``%%'' marks. 
(The percent ``%'' is generally used in Yacc specifications as an escape 
character.)

In other words, a full specification file looks like

        declarations
        %%
        rules
        %%
        programs
The declaration section may be empty. Moreover, if the programs section is 
omitted, the second %% mark may be omitted also; thus, the smallest legal Yacc 
specification is

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