aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorShevek <[email protected]>2014-09-11 00:16:09 -0700
committerShevek <[email protected]>2014-09-11 00:16:09 -0700
commit2db1eafd535d8db92f76db8ccf45b1b80f6152e3 (patch)
tree83b5b6a9351a820b96755f02901aefbc31d133eb /src/main/java/org
parent9c8391a9591e0332de4c8a9d7662a16c70780ad5 (diff)
LexerSource: Handle invalid number as a single INVALID token and don't consume the entire line.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/anarres/cpp/LexerSource.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/org/anarres/cpp/LexerSource.java b/src/main/java/org/anarres/cpp/LexerSource.java
index ef779b7..82d76b6 100644
--- a/src/main/java/org/anarres/cpp/LexerSource.java
+++ b/src/main/java/org/anarres/cpp/LexerSource.java
@@ -513,13 +513,17 @@ public class LexerSource extends Source {
flags |= NumericValue.F_DOUBLE;
text.append((char) d);
d = read();
- } // This should probably be isPunct() || isWhite().
- else if (Character.isLetter(d) || d == '_') {
+ }
+ else if (Character.isUnicodeIdentifierPart(d)) {
+ String reason = "Invalid suffix \"" + (char) d + "\" on numeric constant";
+ // We've encountered something initially identified as a number.
+ // Read in the rest of this token as an identifer but return it as an invalid.
+ while (Character.isUnicodeIdentifierPart(d)) {
+ text.append((char) d);
+ d = read();
+ }
unread(d);
- value.setFlags(flags);
- return invalid(text,
- "Invalid suffix \"" + (char) d
- + "\" on numeric constant");
+ return new Token(INVALID, text.toString(), reason);
} else {
unread(d);
value.setFlags(flags);