@Test @DisplayName("Test simple string literals that are syntactically correct") void testStringLiterals() { final var sut = new StringLiteral(); Assertions.assertEquals("", sut.apply(string("")).lexeme); Assertions.assertEquals("a", sut.apply(string("a")).lexeme); Assertions.assertEquals("\r", sut.apply(string("\\r")).lexeme); Assertions.assertEquals("\n", sut.apply(string("\\n")).lexeme); Assertions.assertEquals("\b", sut.apply(string("\\b")).lexeme); Assertions.assertEquals("\t", sut.apply(string("\\t")).lexeme); Assertions.assertEquals("\f", sut.apply(string("\\f")).lexeme); Assertions.assertEquals("\'", sut.apply(string("\\'")).lexeme); Assertions.assertEquals("\"", sut.apply(string("\\\"")).lexeme); Assertions.assertEquals("\773", sut.apply(string("\\773")).lexeme); Assertions.assertEquals("\073", sut.apply(string("\\073")).lexeme); Assertions.assertEquals("\079", sut.apply(string("\\079")).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; }