Added support for Raw String Literals (C++11).

This commit is contained in:
Jan van Nunen
2015-12-04 14:35:40 +01:00
parent 6a3e7ce6ec
commit c099d50397
2 changed files with 17 additions and 0 deletions

View File

@ -321,6 +321,8 @@ TOKEN :
< CHARACTER : ("L")? "'" ( ( ~["'","\\","\r","\n"] ) | ( "\\" ( ~["\n","\r"] ) ) )* "'" >
| < STRING : ("L")? "\"" ( ( ~["\"","\\","\r","\n"] ) | ( "\\" ( ~["\n","\r"] | "\n" | "\r\n" ) ) )* "\"" >
| < RSTRING : "R\"(" ( ~[")"] | ( ")" ~["\""] ) )* ")\"" >
}
void translation_unit() :

View File

@ -124,6 +124,21 @@ public class CPPTokenizerTest {
Tokens tokens = parse("szPath = m_sdcacheDir + _T(\"\\ oMedia\");" + PMD.EOL);
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) {
return parse(snippet, false);