Lexer: Support the integer suffixes LU and LLU also

Before we only supported UL and ULL.

And add tests for all variants of allowed integer suffixes.

Fixes: QTCREATORBUG-25604
Change-Id: Id92f371d2effa7456d2d50891a6c29810c5c4c75
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Andre Hartmann
2021-04-17 18:15:31 +02:00
committed by André Hartmann
parent 2ae36b9e26
commit 2df71c5798
2 changed files with 48 additions and 0 deletions

View File

@@ -926,11 +926,15 @@ bool Lexer::scanOptionalIntegerSuffix(bool allowU)
yyinp();
if (_yychar == 'l')
yyinp();
if (_yychar == 'u' || _yychar == 'U')
yyinp();
return true;
case 'L':
yyinp();
if (_yychar == 'L')
yyinp();
if (_yychar == 'u' || _yychar == 'U')
yyinp();
return true;
default:
return false;

View File

@@ -363,6 +363,50 @@ void tst_SimpleLexer::literals_data()
;
QTest::newRow("microsoft-suffix") << source << expectedTokenKindList;
source =
"42u\n"
"43U\n"
"44ul\n"
"45UL\n"
"46uL\n"
"47Ul\n"
"48ull\n"
"49ULL\n"
"50uLL\n"
"51Ull\n"
"52l\n"
"53L\n"
"54ll\n"
"55LL\n"
"56lu\n"
"57LU\n"
"58lU\n"
"59Lu\n"
"60llu\n"
"61llU\n"
"62LLU\n"
"63LLu\n"
"64lL\n" // wrong
"65Ll\n" // wrong
"66luu\n" // wrong
"67LUU\n" // wrong
"68lul\n" // wrong
"69LUL\n" // wrong
;
expectedTokenKindList =
TokenKindList() << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL
<< T_NUMERIC_LITERAL
<< T_ERROR << T_ERROR << T_ERROR
<< T_ERROR << T_ERROR << T_ERROR
;
QTest::newRow("integer-suffix") << source << expectedTokenKindList;
source =
"R\"(raw text)\"\n"
"R\"delimiter(raw text)delimiter\"\n"