Merge branch 'tiobe/raw-CPP11-literals' of https://github.com/tiobe/pmd into pr-27
This commit is contained in:
@ -321,6 +321,8 @@ TOKEN :
|
|||||||
< CHARACTER : ("L")? "'" ( ( ~["'","\\","\r","\n"] ) | ( "\\" ( ~["\n","\r"] ) ) )* "'" >
|
< CHARACTER : ("L")? "'" ( ( ~["'","\\","\r","\n"] ) | ( "\\" ( ~["\n","\r"] ) ) )* "'" >
|
||||||
|
|
||||||
| < STRING : ("L")? "\"" ( ( ~["\"","\\","\r","\n"] ) | ( "\\" ( ~["\n","\r"] | "\n" | "\r\n" ) ) )* "\"" >
|
| < STRING : ("L")? "\"" ( ( ~["\"","\\","\r","\n"] ) | ( "\\" ( ~["\n","\r"] | "\n" | "\r\n" ) ) )* "\"" >
|
||||||
|
|
||||||
|
| < RSTRING : "R\"(" ( ~[")"] | ( ")" ~["\""] ) )* ")\"" >
|
||||||
}
|
}
|
||||||
|
|
||||||
void translation_unit() :
|
void translation_unit() :
|
||||||
|
@ -124,6 +124,21 @@ public class CPPTokenizerTest {
|
|||||||
Tokens tokens = parse("szPath = m_sdcacheDir + _T(\"\\ oMedia\");" + PMD.EOL);
|
Tokens tokens = parse("szPath = m_sdcacheDir + _T(\"\\ oMedia\");" + PMD.EOL);
|
||||||
assertEquals(10, tokens.size());
|
assertEquals(10, tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRawStringLiteral() {
|
||||||
|
String code =
|
||||||
|
"const char* const KDefaultConfig = R\"(\n" +
|
||||||
|
" [Sinks.1]\n" +
|
||||||
|
" Destination=Console\n" +
|
||||||
|
" AutoFlush=true\n" +
|
||||||
|
" Format=\"[%TimeStamp%] %ThreadId% %QueryIdHigh% %QueryIdLow% %LoggerFile%:%Line% (%Severity%) - %Message%\"\n" +
|
||||||
|
" Filter=\"%Severity% >= WRN\"\n" +
|
||||||
|
")\";\n";
|
||||||
|
Tokens tokens = parse(code);
|
||||||
|
assertTrue(TokenEntry.getEOF() != tokens.getTokens().get(0));
|
||||||
|
assertEquals(9, tokens.size());
|
||||||
|
}
|
||||||
|
|
||||||
private Tokens parse(String snippet) {
|
private Tokens parse(String snippet) {
|
||||||
return parse(snippet, false);
|
return parse(snippet, false);
|
||||||
|
Reference in New Issue
Block a user