aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Lexer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* C++: Fix crash with invalid raw string literalNikolai Kosjar2017-09-201-6/+10
| | | | | | | | | | | | | | | | While parsing a document Bind::asStringLiteral() Token::spell() was called for a raw string literal token with a Token::literal nullptr. This is due scanRawStringLiteral() not properly aborting for invalid/incomplete code and that the code paths handling multi-line-raw-strings were not limited to the highlighting case. Address both cases. Task-number: QTCREATORBUG-18941 Change-Id: I489d288ccbd7b59be396dada846613ff555436cf Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Fix that raw string literals that close on same line were not terminatedEike Ziller2017-05-191-1/+3
| | | | | | | | With the built-in model, which affects basic highlighting. Task-number: QTCREATORBUG-17720 Change-Id: I7369d7288d9c2c8e5ef36fc27549121014527e58 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* C++: Fix lexing of >> / >>=Philip Lorenz2016-06-221-3/+3
| | | | | | | | The current code always ends up setting the token to T_GREATER_GREATER. Change-Id: If75ff1f5bccffd5918ec2bf491724cd0981220ae Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: fix digraph parsing for <:: exception.Francois Ferrand2016-03-081-2/+6
| | | | | | | | | | | | | According to section 2.5 from the standard: """ If the input stream has been parsed into preprocessing tokens up to a given character: ... Otherwise, if the next three characters are <:: and the subsequent character is neither : nor >, the < is treated as a preprocessor token by itself and not as the first character of the alternative token <:. """ Change-Id: Ib9cdac61e3c2243d1bc1d4471a09ae6bd839fdda Task-number: QTCREATORBUG-13253 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: fix lexing POUND_POUND token with digraphs.Francois Ferrand2016-03-081-2/+8
| | | | | Change-Id: I9204b827c60b283cc4e6b88c810b31eb7587c7db Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: fix trigraph parsing in macros.Francois Ferrand2016-03-081-1/+43
| | | | | | | | | | | | Trigraphs must only be parsed before/during preprocessing. The preprocessor will now replace trigraphs with their standard form, and re-lexing in TranslationUnit will not try to parse any trigraph. Also added a few missing trigraphs: ??=, ??', ??! and ??-. Task-number: QTCREATORBUG-13253 Change-Id: I1723ed53b00090b878c22b83b7e963b647b65f72 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* Lexer: Support Microsoft suffix (u)i64Andre Hartmann2016-01-121-0/+11
| | | | | | | | MSVC2010 supports all combinations of upper- and lowercase U/I. Task-number: QTCREATORBUG-15554 Change-Id: I0106e6b5038a62aebe5a6c1eb0467d693befb4b0 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* CPlusPlus: Remove used Lexer::translationUnit() functionhjk2015-11-021-3/+0
| | | | | Change-Id: I81ec60c1d2b670b85bfeda25e6388a12c2cd0305 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Highlight multi-line raw string literalsNikolai Kosjar2015-09-231-2/+40
| | | | | | | Task-number: QTCREATORBUG-13094 Change-Id: I4e6b8c202677f4c1cd4df95d59130ba8379e72fe Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: Mini refactorings in LexerNikolai Kosjar2015-09-231-22/+16
| | | | | | | | ...that will reduce noise in a follow-up change. Change-Id: I39253fa631019c6d3177d2f8b2c521ec85bfba4b Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Fix change-of-sign warning with ICCThiago Macieira2015-08-171-1/+1
| | | | | | | src/libs/3rdparty/cplusplus/Lexer.cpp(88): warning #68: integer conversion resulted in a change of sign Change-Id: I7de033f80b0e4431b7f1ffff13fa771758c95611 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Basic support for C++11 user-defined literalsAdam Strzelecki2015-02-171-15/+36
| | | | | | | | | | | | | | | | | | | | | | | | 1. Extends lexer so digit or string can be followed by underscore '_' and alphanumeric defining literal. 2. Extends parser so it accepts operator"" _abc(...) user-defined literal definition. 3. Adds Token::Flags.userDefinedLiteral bool flag field representing if token carries user-defined literal. 4. Adds C++11 auto tests case with: 12_km, 0.5_Pa, 'c'_X, "abd"_L, u"xyz"_M 5. All optional suffix scanning methods now return boolean if the suffix was found. 6. Adds C++ Lexer tests for user-defined literals with C++11 feature enabled. This change however does not make QtCreator understand user-defined literal semantics, e.g. properly resolve type when applying custom literal operator. Change-Id: I30e62f025ec9fb11c39261985ea4d772b1a80949 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: clean up numeric literal parsing and add support for n3472.Erik Verbruggen2014-12-181-23/+144
| | | | | | | | | | | | Separate the messy pp-number parsing from the numeric literal parsing. The C/C++ preprocessor makes a grown man cry, but at least we have "proper" literal parsing when we want it, including C++1y binary literals. Next step is digit separators (n3781). Change-Id: Ia069eef454ed5c056f77694a5b8a595d0b76adc4 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: remove reserved names.Erik Verbruggen2014-08-281-7/+7
| | | | | | | See [global.names] (17.6.4.3.2 in the C++11 spec.) Change-Id: I8434496dbe392b52d339d5f17cfaeee8dbd88995 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Add utf16 indices to Macro and Document::MacroUseNikolai Kosjar2014-05-231-0/+15
| | | | | | | | | In most cases we need to work with the utf16 indices. Only in cppfindreferences the byte interface is still needed since there we read in files and work on a QByteArray to save memory. Change-Id: I6ef6a93fc1875a8c9a305c075d51a9ca034c41bb Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: TranslationUnit::getPosition takes utf16char offsetsNikolai Kosjar2014-05-231-1/+1
| | | | | | | | | ...and not byte offsets anymore. This is necessary in order to calculate the line and column numbers correctly with respect to unicode code points. Change-Id: I5d79857b3eaefeb8d563b4f1e3938a64debc5e08 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Support for UTF-8 in the lexerNikolai Kosjar2014-05-231-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will save us toLatin1() conversations in CppTools (which already holds UTF-8 encoded QByteArrays) and thus loss of information (see QTCREATORBUG-7356). It also gives us support for non-latin1 identifiers. API-wise the following functions are added to Token. In follow-up patches these will become handy in combination with QStrings. utf16chars() - aequivalent of bytes() utf16charsBegin() - aequivalent of bytesBegin() utf16charsEnd() - aequivalent of bytesEnd() Next steps: * Adapt functions from TranslationUnit. They should work with utf16 chars in order to calculate lines and columns correctly also for UTF-8 multi-byte code points. * Adapt the higher level clients: * Cpp{Tools,Editor} should expect UTF-8 encoded Literals. * Cpp{Tools,Editor}: When dealing with identifiers on the QString/QTextDocument layer, code points represendet by two QChars need to be respected, too. * Ensure Macro::offsets() and Document::MacroUse::{begin,end}() report offsets usable in CppEditor/CppTools. Addresses QTCREATORBUG-7356. Change-Id: I0791b5236be8215d24fb8e38a1f7cb0d279454c0 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Clarify units of a TokenNikolai Kosjar2014-05-151-2/+2
| | | | | | | | | | | | | This will avoid confusion when later more length and indices methods are added. In Token: length() --> bytes() begin() --> bytesBegin() end() --> bytesEnd() Change-Id: I244c69b022e239ee762b4114559e707f93ff344f Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Remove Lexer::{tokenOffset(),tokenLength()}Nikolai Kosjar2014-05-151-6/+0
| | | | | | | The necessary data can be retrieved by the resulting Token. Change-Id: I79afb23183c156240c690beff30bb11dfe943e61 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Remove unused functions in LexerNikolai Kosjar2014-05-151-9/+0
| | | | | Change-Id: I78b70eead1c64b9925272c50cc6109c5b415574d Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Lexer: Skip also joined commentsOrgad Shaneh2014-02-051-5/+8
| | | | | Change-Id: Ic854958642bf1eedeb7d90ae74fb72993594b8d6 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Fix support for incremental input with \nOrgad Shaneh2014-02-041-22/+33
| | | | | | | | | | | | Also fix false positive line continuation on blank line e.g. "foo \ bar" Change-Id: Ic6d345a4b578c955411d119b8438c8dc5065c072 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Support multiline strings and commentsOrgad Shaneh2014-01-211-20/+61
| | | | | | Task-number: QTCREATORBUG-662 Change-Id: I0997fe2afaba71998d5da549b7141df0c023ff12 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Store token kind as lexer stateOrgad Shaneh2014-01-201-12/+12
| | | | | | | ... when needed Change-Id: I32a1649c87e1fa42da80eff5003b2f5714062064 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Remove unused functions in LexerOrgad Shaneh2014-01-201-6/+0
| | | | | Change-Id: I79285a9fc72f26bdfb7c1600d4e7680e02062593 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* CPlusPlus: Fix parsing of ??< ??> ??( ??) trigraphshjk2013-11-271-1/+18
| | | | | | | | Almost most useful feature ever. Task-number: QTCREATORBUG-2474 Change-Id: If1ad661fab58ffb4a0b9ddb8ba771f2fde3b54ec Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* CPlusPlus: Make (sub-)languague selection more generichjk2013-10-151-20/+2
| | | | | Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* CPlusPlus: Fix parsing of <: :> <% %> %: digraphshjk2013-10-071-0/+15
| | | | | | | | See 2.5/2.12. Most useful feature ever. Change-Id: I3f92256733e15078df56205dba9746ffff8ed145 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Use soft asserts instead of assert()Nikolai Kosjar2013-05-131-7/+9
| | | | | | | Some qmake versions ignore "DEFINES += NDEBUG" on Windows. Change-Id: Ibdf3b1036c2331dcef61dcd278463c02754044d2 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Inline Lexer::control()hjk2013-04-181-8/+2
| | | | | Change-Id: Ia37ec33fb031fdea4ad1890fcea3a80b7b46e272 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Consider '^//[/!][^\n]*' as doxygen commentNikolai Kosjar2013-03-121-5/+1
| | | | | | | | | | | | | Now everything following '///' or '//!' is a doxygen comment. This simplification fixes also the bug ('\n' was considered as part of the doxygen comment and led to strange highlighting). Task-number: QTCREATORBUG-8921 Change-Id: I6dae3b80ec11400f2f623897257782a80860a7f3 Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Fix highlighting of doxygen's "///"Nikolai Kosjar2013-02-191-3/+2
| | | | | | | | | | | | The color scheme changed for "///\n" lines: "///\n" - "Doxygen Comment" (was "Comment") "/// hello\n" - "Doxygen Comment" (as before) "////...\n" - "Comment" (as before) Change-Id: I6bdaf471760bb05547385fd4821eded6cefed4d7 Reviewed-by: Knut Petter Svendsen <knutpett@pvv.org> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Introduce C++11 raw string literalsLeandro Melo2012-08-231-2/+82
| | | | | | | | | | | | Although they are now supported by the lexer and parser, it is worth to remind that we still need to address an issue concerning the highlight of multiline literals (which with the advent of the new raw strings will become more common). Task-number: QTCREATORBUG-6722 Change-Id: I137337a9ac0152a1f8b9faded0b960c6fe3dd38a Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Avoid looking ahead when lexing u8"literal"Leandro Melo2012-08-171-10/+6
| | | | | | | | | | This makes things slightly more efficient. But it will be more significant when we introduce R"rawliterals" since we would avoid an even further lookahead for cases like u8R"string". Change-Id: Id4bad8b917752d23daf2f4989330434979cf602f Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com> Reviewed-by: hjk <qthjk@ovi.com>
* C++: Lex correctly a u8"literal"Leandro Melo2012-08-171-16/+14
| | | | | | | | Previously it was considering invalid things `such as U8"literal". Change-Id: Icf4d051a26617ac2c6cb35d5a98f8af0ed801556 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com> Reviewed-by: hjk <qthjk@ovi.com>
* C++: Break on newline when lexing char/string literalsLeandro Melo2012-06-081-2/+3
| | | | | | | | | Actually this behavior was already in the Lexer for regular string literals (although erroneously not for wide ones) and was lost in the recent commit 23c637c4f677ab2f19793f409297b0131b21dcaa. Change-Id: I36609038ce22dc6389e9da5b078f7bf7f6c031be Reviewed-by: hjk <qthjk@ovi.com>
* C++: Introduce unicode char/strings supportLeandro Melo2012-06-061-114/+126
| | | | | | | | | | | | | | Those are the types char16_t and char32_t along with the new char/string literals u'', U'', u"", u8"", and U"". This is particularly important for the use of QStringLiteral since in some platforms it relies on expansion such as above. Note: The string literals quickfixes still need some tunning. Task-number: QTCREATORBUG-7449 Change-Id: Iebcfea15677dc8e0ebb6143def89a5477e1be7d4 Reviewed-by: hjk <qthjk@ovi.com>
* Revert "Editor: Highlight background for whitespaces in strings and comments"David Schulz2012-02-031-9/+3
| | | | | | | | The change brokes the Lexer. This reverts commit e46a5579d368162034813cc4b27d8d5c9f0716d9. Change-Id: I3363c6eff74b53a7f2d9f417941cde07aaa92619 Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
* Editor: Highlight background for whitespaces in strings and commentsDavid Schulz2012-02-011-3/+9
| | | | | | | | | | The whitespaces are now highlighted with the same backgroundcolor as the characters. Also added a test for the Lexer. Task-number: QTCREATORBUG-5802 Change-Id: Ic1bcd8cfe30d6b8a0281b7963eaab310f972b9d2 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Remove some dead stores pointed out by clang.Christian Kamm2011-09-021-1/+0
| | | | | | | Change-Id: I919a2e98474fec42861391d11d2ba1225eb2adf9 Reviewed-on: http://codereview.qt.nokia.com/4083 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
* remove nokia copyrights from roberto's codeOswald Buddenhagen2011-05-161-31/+0
| | | | | | | | they are lying. nokia has no copyright on this code. and the double license in a single file looks weird. that's why we moved it to 3rdparty/, so it is clear it is not nokia's. Approved-by: legal
* move src/shared/cplusplus/ -> src/libs/3rdparty/cplusplus/Oswald Buddenhagen2011-05-161-0/+732
Approved-by: legal