1
0
forked from phoedos/pmd

Fixed lexical eror when a preprocessor directive is followed by a single line comment that starts with "//*".

This commit fixes a lexical eror when a preprocessor directive is
followed by a single line comment that starts with "//*".

The following code could not be tokenized:

#define LSTFVLES_CPP  //*

It triggers the following error:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file
'foo.cpp' at line 2, column 0.  Encountered: <EOF> after : ""
This commit is contained in:
Jan van Nunen
2015-01-12 17:24:26 +01:00
parent 5c2df4c877
commit ceef6cd236
2 changed files with 6 additions and 0 deletions
pmd-cpp
etc/grammar
src/test/java/net/sourceforge/pmd/cpd

@ -174,6 +174,7 @@ SKIP :
{
"\n" : DEFAULT
| "/*" : IN_PREPROCESSOR_OUTPUT_COMMENT
| "//" : IN_LINE_COMMENT
}
<PREPROCESSOR_OUTPUT> MORE:

@ -102,6 +102,11 @@ public class CPPTokenizerTest {
assertEquals(22, tokens.size());
}
@Test
public void testEOLCommentInPreprocessingDirective() {
parse("#define LSTFVLES_CPP //*" + PMD.EOL);
}
private Tokens parse(String snippet) {
return parse(snippet, false);
}