Handle string literals that contain ASCII_SUB
It's also used to indicate EOF, so we have to check whether the input is
exhausted after seeing ASCII_SUB in a string literal. The lexer was
failing to save the ASCII_SUB character in the case where there is more
input to be processed.
MOE_MIGRATED_REVID=137219497
diff --git a/java/com/google/turbine/parse/StreamLexer.java b/java/com/google/turbine/parse/StreamLexer.java
index 1bf6a2f..f2850a6 100644
--- a/java/com/google/turbine/parse/StreamLexer.java
+++ b/java/com/google/turbine/parse/StreamLexer.java
@@ -376,8 +376,7 @@
if (reader.done()) {
return Token.EOF;
}
- eat();
- continue STRING;
+ // falls through
default:
sb.append(ch);
eat();
diff --git a/javatests/com/google/turbine/lower/LowerIntegrationTest.java b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
index d48a51f..d3f2ce1 100644
--- a/javatests/com/google/turbine/lower/LowerIntegrationTest.java
+++ b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
@@ -240,6 +240,7 @@
"private_member.test",
"visible_nested.test",
"visible_qualified.test",
+ "ascii_sub.test",
};
List<Object[]> tests =
ImmutableList.copyOf(testCases).stream().map(x -> new Object[] {x}).collect(toList());
diff --git a/javatests/com/google/turbine/lower/testdata/ascii_sub.test b/javatests/com/google/turbine/lower/testdata/ascii_sub.test
new file mode 100644
index 0000000..c7bf74d
--- /dev/null
+++ b/javatests/com/google/turbine/lower/testdata/ascii_sub.test
@@ -0,0 +1,4 @@
+=== Test.java ===
+class Test {
+ public static final String S = "\u001a";
+}
\ No newline at end of file