[英]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的代码搜索
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.