diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/anarres/cpp/LexerSource.java | 16 | ||||
-rw-r--r-- | src/tests/org/anarres/cpp/LexerSourceTestCase.java | 16 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/java/org/anarres/cpp/LexerSource.java b/src/java/org/anarres/cpp/LexerSource.java index 90869bc..c38ff6a 100644 --- a/src/java/org/anarres/cpp/LexerSource.java +++ b/src/java/org/anarres/cpp/LexerSource.java @@ -318,14 +318,18 @@ public class LexerSource extends Source { return val; case 'x': + text.append((char)d); len = 0; val = 0; - do { + while (len++ < 2) { + d = read(); + if (Character.digit(d, 16) == -1) { + unread(d); + break; + } val = (val << 4) + Character.digit(d, 16); text.append((char)d); - d = read(); - } while (++len < 2 && Character.digit(d, 16) != -1); - unread(d); + } return val; /* Exclude two cases from the warning. */ @@ -444,14 +448,14 @@ public class LexerSource extends Source { } else if (d == 'L' || d == 'l') { if ((bits & 4) != 0) - /* XXX warn */ ; + warning("Conflicting numeric suffices: I and L."); bits |= 2; text.append((char)d); d = read(); } else if (d == 'I' || d == 'i') { if ((bits & 2) != 0) - /* XXX warn */ ; + warning("Conflicting numeric suffices: L and I."); bits |= 4; text.append((char)d); d = read(); diff --git a/src/tests/org/anarres/cpp/LexerSourceTestCase.java b/src/tests/org/anarres/cpp/LexerSourceTestCase.java index 7fa788c..828ee9c 100644 --- a/src/tests/org/anarres/cpp/LexerSourceTestCase.java +++ b/src/tests/org/anarres/cpp/LexerSourceTestCase.java @@ -60,6 +60,22 @@ public class LexerSourceTestCase extends BaseTestCase implements Test { XOR_EQ, WHITESPACE, IDENTIFIER); + testLexerSource("/**/", CCOMMENT); + testLexerSource("/** ** **/", CCOMMENT); + testLexerSource("//* ** **/", CPPCOMMENT); + testLexerSource("'\\r' '\\xf' '\\xff' 'x' 'aa' ''", + CHARACTER, WHITESPACE, + CHARACTER, WHITESPACE, + CHARACTER, WHITESPACE, + CHARACTER, WHITESPACE, + INVALID, WHITESPACE, + INVALID); + + testLexerSource("1i1I1l1L1ui1ul", + INTEGER, INTEGER, + INTEGER, INTEGER, + INTEGER, INTEGER); + } } |