C++: Support single quote digit separator in integer literals

C++14 supports the use of single quotes inserted between integer digits
as a separator.  Updates the built-in C++ code model to recognize such
quotes.  This fixes highlighting and indentation issues.

Change-Id: Ic35ce93060b96700a11d108dce1f3cf6c4543632
Fixes: QTCREATORBUG-14939
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Joel Smith
2019-05-12 20:49:00 -07:00
committed by Nikolai Kosjar
parent 8a9c5a093d
commit 8c437362bc
6 changed files with 21 additions and 5 deletions

View File

@@ -954,7 +954,8 @@ void Lexer::scanNumericLiteral(Token *tok)
yyinp();
while (std::isdigit(_yychar) ||
(_yychar >= 'a' && _yychar <= 'f') ||
(_yychar >= 'A' && _yychar <= 'F')) {
(_yychar >= 'A' && _yychar <= 'F') ||
((_yychar == '\'') && _languageFeatures.cxx14Enabled)) {
yyinp();
}
if (!scanOptionalIntegerSuffix())
@@ -962,7 +963,8 @@ void Lexer::scanNumericLiteral(Token *tok)
goto theEnd;
} else if (_yychar == 'b' || _yychar == 'B') { // see n3472
yyinp();
while (_yychar == '0' || _yychar == '1')
while (_yychar == '0' || _yychar == '1' ||
((_yychar == '\'') && _languageFeatures.cxx14Enabled))
yyinp();
if (!scanOptionalIntegerSuffix())
scanOptionalUserDefinedLiteral(tok);
@@ -970,7 +972,8 @@ void Lexer::scanNumericLiteral(Token *tok)
} else if (_yychar >= '0' && _yychar <= '7') {
do {
yyinp();
} while (_yychar >= '0' && _yychar <= '7');
} while ((_yychar >= '0' && _yychar <= '7') ||
((_yychar == '\'') && _languageFeatures.cxx14Enabled));
if (!scanOptionalIntegerSuffix())
scanOptionalUserDefinedLiteral(tok);
goto theEnd;
@@ -989,7 +992,8 @@ void Lexer::scanNumericLiteral(Token *tok)
if (scanExponentPart() && !scanOptionalFloatingSuffix())
scanOptionalUserDefinedLiteral(tok);
break;
} else if (std::isdigit(_yychar)) {
} else if (std::isdigit(_yychar) ||
((_yychar == '\'') && _languageFeatures.cxx14Enabled)) {
yyinp();
} else {
if (!scanOptionalIntegerSuffix())