@Test @DisplayName("Test simple string literals that are syntactically incorrect") void testBadStringLiterals() { final var sut = new StringLiteral(); Assertions.assertThrows(GeciException.class, () -> sut.apply(string("\n"))); Assertions.assertThrows(GeciException.class, () -> sut.apply(string("\r"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(string("\\z"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(string("\\"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(new StringBuilder("\""))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(new StringBuilder("\"\\"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(new StringBuilder("\"bababa"))); }
@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; }