GCC源代码中的C语法

发布于 2024-08-30 14:32:22 字数 51 浏览 3 评论 0原文

我正在 GCC 源代码中寻找 C 语法,更具体地说是 yacc/bison 形式的语法。

I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form.

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

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

发布评论

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

评论(7

转角预定愛 2024-09-06 14:32:22

在文件“c-parse.y”中找到GCC 3.3版本中Yacc规范中的C语法

Found the C grammar in Yacc specification in the GCC version 3.3 in the file "c-parse.y"

自由如风 2024-09-06 14:32:22

您在当前的 GCC 源代码中找不到 C 语法 yacc/bison 文件。这是过去在egcs fork之前完成的。我无法给你确切的版本和位置,但我可以告诉你它应该在 2.x 版本中

当前版本的 GCC 有自己的 C 解析器

You will not find a C grammar yacc/bison file within the current GCC source code. It was done in the past, before the egcs fork stuff. I cannot give you the exact version and location, but i can tell you that it should be in the 2.x release

The current version of GCC has its own C parser

夜未央樱花落 2024-09-06 14:32:22

GCC 的 g++ 多年前(可能至少 5 年)从基于 yacc (bison) 的解析器切换过来。他们开始使用递归体面的解析器,因为 C++ 在 yacc 中很难。

在 C++ 中使用这个解析器几年后,他们也将 C 转为使用递归体例进行解析。

您必须返回几个版本才能找到 bison 格式的语法,但它就在那里。您应该尝试使用 google 的代码搜索

gcc yyparse

更新:Google 代码搜索于 2012 年关闭

http://en.wikipedia.org/wiki/Google_Code_Search

旧版:http://yaxx.googlecode.com/svn/branches/yaxx-proc/gcc-3.4.0/gcc/c- parse.y

找到包含它的 gcc 版本,然后您应该能够在其中找到 yacc/bison 源文件。但它会很旧。

GCC's g++ switched from a yacc (bison) based parser years ago (probably at least 5 years). They started using a recursive decent parser because C++ is difficult in yacc.

After using this parser in for C++ for several years they switched C to parsing using recursive decent as well.

You will have to go back several versions to locate the grammar in bison format, but it is out there. You should try google's code search with

gcc yyparse

Update: Google Code Search Shutdown in 2012

http://en.wikipedia.org/wiki/Google_Code_Search

Old: http://yaxx.googlecode.com/svn/branches/yaxx-proc/gcc-3.4.0/gcc/c-parse.y

to find a version of gcc that has it and then you should be able to find the yacc/bison source file in there. It will be old, though.

无需解释 2024-09-06 14:32:22

4.3 版本的 GCC 不包含显式编写的 C 语法。语法分析和语义分析同时进行,无需将语法树呈现为单独的数据结构。

信息来源:我阅读了GCC源代码。

GCC of version 4.3 did not contain explicitly written C grammar. Parsing and semantical analysis were performed simultaneously, without presenting syntax tree as a separate data structure.

Information source: I read the GCC source code.

以酷 2024-09-06 14:32:22

GCC 不使用生成的解析器;它的解析器是一个手写的递归下降解析器。

GCC doesn't use a generated parser; its parser is a hand-written recursive-descent parser.

一人独醉 2024-09-06 14:32:22

C 语法可以在 GCC 源代码中的 c-parser.c 文件的注释中找到。
正如已经说过的那样,它不是 yacc/bison。

The C grammar can be found in comments in c-parser.c file in GCC sources.
It is not a yacc/bison though as it has already been said.

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