Review Request: Add "language features" to the C++ parser

Alexandre Courbot gnurou at gmail.com
Sun May 13 06:35:30 UTC 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/104930/#review13763
-----------------------------------------------------------


This current version is not meant to be merged (it is quickly hacked, and I am pretty sure I missed a couple of C++ keywords to isolate) but rather to get early feedback and make sure the basic idea is valid before I go any further with this. Based on this is should not be difficult to have KDevelop officially support C (Linux kernel error-less parsing is pretty close with this in!) without having C support interfering with C++. C-specific constructs like designated initializers can easily be disabled for C++. I actually already have a patch that does that, but would like to clear this one first.

FWIW, this "language features" thing is pretty close (although a bit simpler) to what CLang is doing to support all C-based specifications with the same parser.

- Alexandre Courbot


On May 13, 2012, 6:31 a.m., Alexandre Courbot wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/104930/
> -----------------------------------------------------------
> 
> (Updated May 13, 2012, 6:31 a.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Description
> -------
> 
>    Currently the parser is a pure C++ parser with C++11 elements, without
>     any option to disable C++11 or to make it more C compatible. C
>     compatibility in particular is a big challenge since many C++ tokens can
>     be used as identifiers in C, and C also has some constructs that are not
>     valid in C++ (like designated initializers or casted braced init lists).
>     
>     This patch adds "language features" which are flags that enable specific
>     language support in the parser. Currently flags exist for C99, C++ and
>     C++11. Code that invokes the parser can use the new
>     setLanguageFeatures() method to change the current set of supported
>     features (the default is C++ | C++11). This is useful for instance for
>     C-specific projects.
>     
>     CppLanguageSupport::createParseJob has been modified to check for a
>     "Language" entry in the configuration of the project the parsed file
>     belongs to. Project controllers can set this option if they know that
>     the project is limited to C, C++ or C++11 files. Other means (for
>     instance, based on file extension of Makefile analysis) could be
>     implemented in the future.
> 
> 
> Diffs
> -----
> 
>   languages/cpp/cpplanguagesupport.cpp 4ee1ffe 
>   languages/cpp/cppparsejob.h debb1b0 
>   languages/cpp/cppparsejob.cpp 1e0a51b 
>   languages/cpp/parser/languagefeatures.h PRE-CREATION 
>   languages/cpp/parser/lexer.h 3494cbd 
>   languages/cpp/parser/lexer.cpp 81302d7 
>   languages/cpp/parser/parser.h c519891 
>   languages/cpp/parser/parser.cpp edeab85 
>   languages/cpp/preprocessjob.cpp 803c237 
> 
> Diff: http://git.reviewboard.kde.org/r/104930/diff/
> 
> 
> Testing
> -------
> 
> Modified kdev-kernel to set that "Language=C" option to the projects it manages. Checked that C++ keywords like "class", "private" were indeed treated as identifiers. This alone improves kernel parsing quality a great deal.
> 
> Made sure that parsing of C++ projects is not affected in any way by this patch.
> 
> 
> Thanks,
> 
> Alexandre Courbot
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20120513/6d7ff808/attachment.html>


More information about the KDevelop-devel mailing list