@Test @DisplayName("Test multi line string literals that are syntactically correct") void testMultiLineStringLiterals() { final var sut = new StringLiteral(); Assertions.assertEquals("\n", sut.apply(mlstring("")).lexeme); Assertions.assertEquals("\na", sut.apply(mlstring("a")).lexeme); Assertions.assertEquals("\n\r", sut.apply(mlstring("\\r")).lexeme); Assertions.assertEquals("\n\n", sut.apply(mlstring("\\n")).lexeme); Assertions.assertEquals("\n\b", sut.apply(mlstring("\\b")).lexeme); Assertions.assertEquals("\n\t", sut.apply(mlstring("\\t")).lexeme); Assertions.assertEquals("\n\f", sut.apply(mlstring("\\f")).lexeme); Assertions.assertEquals("\n\'", sut.apply(mlstring("\\'")).lexeme); Assertions.assertEquals("\n\"", sut.apply(mlstring("\\\"")).lexeme); Assertions.assertEquals("\n\773", sut.apply(mlstring("\\773")).lexeme); Assertions.assertEquals("\n\073", sut.apply(mlstring("\\073")).lexeme); Assertions.assertEquals("\n\079", sut.apply(mlstring("\\079")).lexeme); Assertions.assertEquals("\na\nb", sut.apply(mlstring("a\n\rb")).lexeme); Assertions.assertEquals("\na\nb", sut.apply(mlstring("a\rb")).lexeme); }
@Override public LexicalElement.StringLiteral apply(StringBuilder sb) { if (sb.length() == 0 || sb.charAt(0) != ENCLOSING_CH) { return null; } final var output = createOutput(sb, STRING); final var original = createOutput(sb, STRING); if (sb.length() >= 3 && sb.subSequence(0, 3).equals(MULTI_LINE_STRING_DELIMITER)) { return getMultiLineStringLiteral(sb, output,original); } else { return getSimpleStringLiteral(sb, output,original); } }
StringLiteral implements LexEater { @Override public LexicalElement.StringLiteral apply(StringBuilder sb) { if (sb.length() == 0 || sb.charAt(0) != ENCLOSING_CH) { return null; } final var output = createOutput(sb, STRING); final var original = createOutput(sb, STRING); if (sb.length() >= 3 && sb.subSequence(0, 3).equals(MULTI_LINE_STRING_DELIMITER)) { return getMultiLineStringLiteral(sb, output,original); } else { return getSimpleStringLiteral(sb, output,original); } } }
StringLiteral implements LexEater { @Override public LexicalElement.StringLiteral apply(StringBuilder sb) { if (sb.length() == 0 || sb.charAt(0) != ENCLOSING_CH) { return null; } final var output = createOutput(sb, STRING); final var original = createOutput(sb, STRING); if (sb.length() >= 3 && sb.subSequence(0, 3).equals(MULTI_LINE_STRING_DELIMITER)) { return getMultiLineStringLiteral(sb, output,original); } else { return getSimpleStringLiteral(sb, output,original); } }  }
StringLiteral implements LexEater { @Override public LexicalElement.StringLiteral apply(StringBuilder sb) { if (sb.length() == 0 || sb.charAt(0) != ENCLOSING_CH) { return null; } final var output = createOutput(sb, STRING); final var original = createOutput(sb, STRING); if (sb.length() >= 3 && sb.subSequence(0, 3).equals(MULTI_LINE_STRING_DELIMITER)) { return getMultiLineStringLiteral(sb, output,original); } else { return getSimpleStringLiteral(sb, output,original); } }  @Override LexicalElement.StringLiteral apply(StringBuilder sb); }
StringLiteral implements LexEater { @Override public LexicalElement.StringLiteral apply(StringBuilder sb) { if (sb.length() == 0 || sb.charAt(0) != ENCLOSING_CH) { return null; } final var output = createOutput(sb, STRING); final var original = createOutput(sb, STRING); if (sb.length() >= 3 && sb.subSequence(0, 3).equals(MULTI_LINE_STRING_DELIMITER)) { return getMultiLineStringLiteral(sb, output,original); } else { return getSimpleStringLiteral(sb, output,original); } }  @Override LexicalElement.StringLiteral apply(StringBuilder sb); static final String MULTI_LINE_STRING_DELIMITER; }