aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/anarres/cpp/LexerSource.java
diff options
context:
space:
mode:
authorShevek <[email protected]>2012-09-04 01:01:06 -0700
committerShevek <[email protected]>2012-09-04 01:01:06 -0700
commit83c866c1ecdbb701a48f57d7eb104a0d9d156bc6 (patch)
tree56e5e1b45345493f4f9f70a57d94bc1fe83f9aff /src/java/org/anarres/cpp/LexerSource.java
parent943775515e684e1845abbdd6be52678028272399 (diff)
Support single-quoted strings properly, as a variant of 'character'.
Diffstat (limited to 'src/java/org/anarres/cpp/LexerSource.java')
-rw-r--r--src/java/org/anarres/cpp/LexerSource.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/java/org/anarres/cpp/LexerSource.java b/src/java/org/anarres/cpp/LexerSource.java
index b696c9c..5f3bfc7 100644
--- a/src/java/org/anarres/cpp/LexerSource.java
+++ b/src/java/org/anarres/cpp/LexerSource.java
@@ -431,8 +431,23 @@ public class LexerSource extends Source {
}
}
text.append(close);
- return new Token(close == '>' ? HEADER : STRING,
+ switch (close) {
+ case '"':
+ return new Token(STRING,
+ text.toString(), buf.toString());
+ case '>':
+ return new Token(HEADER,
+ text.toString(), buf.toString());
+ case '\'':
+ if (buf.length() == 1)
+ return new Token(CHARACTER,
text.toString(), buf.toString());
+ return new Token(SQSTRING,
+ text.toString(), buf.toString());
+ default:
+ throw new IllegalStateException(
+ "Unknown closing character " + (char)close);
+ }
}
private Token _number_suffix(StringBuilder text, NumericValue value, int d)
@@ -819,7 +834,7 @@ public class LexerSource extends Source {
break;
case '\'':
- tok = character();
+ tok = string('\'', '\'');
break;
case '"':