diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp index 4c76e96f08a..ecf7895df6f 100644 --- a/src/libs/3rdparty/cplusplus/Lexer.cpp +++ b/src/libs/3rdparty/cplusplus/Lexer.cpp @@ -135,11 +135,18 @@ void Lexer::scan(Token *tok) tok->f.utf16chars = _currentCharUtf16 - _tokenStartUtf16; } +static bool isRawStringLiteral(unsigned char kind) +{ + return kind >= T_FIRST_RAW_STRING_LITERAL + && kind <= T_LAST_RAW_STRING_LITERAL; +} + static bool isMultiLineToken(unsigned char kind) { return kind == T_EOF_SYMBOL || kind == T_COMMENT - || kind == T_DOXY_COMMENT; + || kind == T_DOXY_COMMENT + || isRawStringLiteral(kind); } void Lexer::scan_helper(Token *tok) @@ -207,7 +214,12 @@ void Lexer::scan_helper(Token *tok) _state = 0; scanCppComment(originalKind); return; - } else { // strings + } else if (isRawStringLiteral(s._tokenKind)) { + tok->f.kind = s._tokenKind; + if (scanUntilRawStringLiteralEndSimple()) + _state = 0; + return; + } else { // non-raw strings tok->f.joined = true; tok->f.kind = s._tokenKind; _state = 0; @@ -740,6 +752,32 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint) tok->f.kind = T_RAW_UTF8_STRING_LITERAL; else tok->f.kind = T_RAW_STRING_LITERAL; + + if (!_yychar) + s._tokenKind = tok->f.kind; +} + +// In the highlighting case we don't have any further information +// like the delimiter or its length, so just match for: ...)..." +bool Lexer::scanUntilRawStringLiteralEndSimple() +{ + bool closingParenthesisPassed = false; + + while (_yychar) { + if (_yychar == ')') { + yyinp(); + closingParenthesisPassed = true; + } else { + if (closingParenthesisPassed && _yychar == '"') { + yyinp(); + return true; + } else { + yyinp(); + } + } + } + + return false; } void Lexer::scanCharLiteral(Token *tok, unsigned char hint) diff --git a/src/libs/3rdparty/cplusplus/Lexer.h b/src/libs/3rdparty/cplusplus/Lexer.h index c19ee904f98..1162d334dfb 100644 --- a/src/libs/3rdparty/cplusplus/Lexer.h +++ b/src/libs/3rdparty/cplusplus/Lexer.h @@ -96,6 +96,7 @@ private: void scanStringLiteral(Token *tok, unsigned char hint = 0); void scanRawStringLiteral(Token *tok, unsigned char hint = 0); + bool scanUntilRawStringLiteralEndSimple(); void scanCharLiteral(Token *tok, unsigned char hint = 0); void scanUntilQuote(Token *tok, unsigned char quote); bool scanDigitSequence(); diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 28836c77726..76dcefe3f40 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -49,11 +49,13 @@ enum Kind { T_UTF8_STRING_LITERAL, T_UTF16_STRING_LITERAL, T_UTF32_STRING_LITERAL, - T_RAW_STRING_LITERAL, + T_FIRST_RAW_STRING_LITERAL, + T_RAW_STRING_LITERAL = T_FIRST_RAW_STRING_LITERAL, T_RAW_WIDE_STRING_LITERAL, T_RAW_UTF8_STRING_LITERAL, T_RAW_UTF16_STRING_LITERAL, T_RAW_UTF32_STRING_LITERAL, + T_LAST_RAW_STRING_LITERAL = T_RAW_UTF32_STRING_LITERAL, T_AT_STRING_LITERAL, T_ANGLE_STRING_LITERAL, T_LAST_STRING_LITERAL = T_ANGLE_STRING_LITERAL,