简体   繁体   English

GCC源代码中的C语法

[英]C grammar in GCC source code

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

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

You will not find a C grammar yacc/bison file within the current GCC source code. 您将无法在当前GCC源代码中找到C语法yacc / bison文件。 It was done in the past, before the egcs fork stuff. 它是在过去,在egcs fork之前完成的。 I cannot give you the exact version and location, but i can tell you that it should be in the 2.x release 我不能给你确切的版本和位置,但我可以告诉你它应该在2.x版本中

The current version of GCC has its own C parser 当前版本的GCC有自己的C解析器

GCC of version 4.3 did not contain explicitly written C grammar. 版本4.3的GCC不包含明确编写的C语法。 Parsing and semantical analysis were performed simultaneously, without presenting syntax tree as a separate data structure. 同时进行解析和语义分析,而不将语法树作为单独的数据结构呈现。

Information source: I read the GCC source code. 信息来源:我阅读了GCC源代码。

GCC's g++ switched from a yacc (bison) based parser years ago (probably at least 5 years). GCC的g ++几年前从基于yacc(bison)的解析器切换(可能至少5年)。 They started using a recursive decent parser because C++ is difficult in yacc. 他们开始使用递归的正确解析器,因为在yacc中C ++很难。

After using this parser in for C++ for several years they switched C to parsing using recursive decent as well. 在C ++中使用这个解析器几年之后,他们还使用递归的体系将C切换为解析。

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 您应该尝试google的代码搜索

\n

gcc yyparse gcc yyparse

Update: Google Code Search Shutdown in 2012 更新:2012年Google代码搜索关闭

http://en.wikipedia.org/wiki/Google_Code_Search 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 旧: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. 找到有它的gcc版本然后你应该能够在那里找到yacc / bison源文件。 It will be old, though. 不过,它会变老。

GCC doesn't use a generated parser; GCC不使用生成的解析器; its parser is a hand-written recursive-descent parser. 它的解析器是一个手写的递归下降解析器。

The C grammar can be found in comments in c-parser.c file in GCC sources. C语法可以在GCC源代码中的c-parser.c文件的注释中找到。 It is not a yacc/bison though as it has already been said. 虽然它已经说过,但它不是一个yacc / bison。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gcc无法将* .C源代码识别为有效的c程序 - gcc not recognize *.C source code as valid c program 是否可以从gcc中的C源代码内部链接到数学库? - Is it possible to link to the math library from inside the C source code in gcc? 将 libsndfile 源代码与 gcc 链接 - Link libsndfile source code with gcc 如何在一行源代码中包含几行 C 代码(AVR-GCC) - how to include several lines of C code in one line of source code (AVR-GCC) 是否可以强制说“ gcc”为C和C ++中相同的源代码片段生成相同的二进制文件? - Is it possible to force say, `gcc`, to produce identical binaries for identical pieces of source code in C and C++? 你可以在你的c源代码中手动执行所有gcc优化(-O2,-O3)吗? - Can you do all gcc optimizations (-O2, -O3) manually in your c source code? 使用 MinGW GCC 更改 Windows CMD 上的代码页时,将 _POSIX_C_SOURCE 定义为 2 会导致错误 - Defining _POSIX_C_SOURCE as 2 causes error when changing code page on Windows CMD with MinGW GCC 我在哪里可以获得gcc / clang等C标准函数的源代码? - Where can I get the source code of the C standard functions in gcc/clang etc? 在2个不同版本的gcc上编译源代码 - compiling source code on 2 different versions of gcc 如何使用最新的GCC构建旧的源代码? - How to build old source code with latest GCC?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM