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

Alexandre Courbot gnurou at gmail.com
Sun May 13 06:31:23 UTC 2012


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

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/f866ac05/attachment.html>


More information about the KDevelop-devel mailing list