forked from phoedos/pmd
Fixed lexical error when a C++ file contains an empty character literal L''.
This commit fixes a lexical error when a C++ file contains an empty character literal L''. The following code could not be tokenized: std::wstring wsMessage( sMessage.length(), L''); It triggers the following error: net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file 'foo.cpp' at line 1, column 46. Encountered: "\'" (39), after : "\'"
This commit is contained in:
@ -319,7 +319,7 @@ TOKEN :
|
||||
{
|
||||
|
||||
< CHARACTER : ("L")? "'"
|
||||
( (~["'","\\","\n","\r"])+
|
||||
( (~["'","\\","\n","\r"])*
|
||||
| ("\\" (
|
||||
["n","t","v","b","r","f","a","\\","?","'","\""]
|
||||
|
|
||||
|
@ -107,6 +107,12 @@ public class CPPTokenizerTest {
|
||||
parse("#define LSTFVLES_CPP //*" + PMD.EOL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyCharacter() {
|
||||
Tokens tokens = parse("std::wstring wsMessage( sMessage.length(), L'');" + PMD.EOL);
|
||||
assertEquals(15, tokens.size());
|
||||
}
|
||||
|
||||
private Tokens parse(String snippet) {
|
||||
return parse(snippet, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user