Skip to content

Commit b6fcfa1

Browse files
committed
Don't check opening quote in quotedByWithEscapes()
1 parent 0cd4517 commit b6fcfa1

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

dot-parse/src/main/java/com/google/common/labs/parse/Parser.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ private static Parser<String> quotedBy(Parser<?> before, Parser<?> after) {
349349
}
350350

351351
/**
352-
* String literal quoted by {@code quoteChar} with backslash escapes.
352+
* String literal quoted by {@code before} and {@code after} with backslash escapes.
353353
*
354354
* <p>When a backslash is encountered, the {@code escaped} parser is used to parse the escaped
355355
* character(s).
@@ -375,8 +375,6 @@ private static Parser<String> quotedBy(Parser<?> before, Parser<?> after) {
375375
*/
376376
public static Parser<String> quotedByWithEscapes(
377377
char before, char after, Parser<? extends CharSequence> escaped) {
378-
checkArgument(before != '\\', "quoteChar cannot be '\\'");
379-
checkArgument(!Character.isISOControl(before), "quoteChar cannot be a control character");
380378
return quotedByWithEscapes(Character.toString(before), after, escaped);
381379
}
382380

dot-parse/src/test/java/com/google/common/labs/parse/MiniSearchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static SearchCriteria parse(String input) {
6767
// A search term is either quoted, or unquoted (but cannot be a keyword)
6868
Parser<Term> unquoted =
6969
word().suchThat(w -> !keywords.contains(w), "search term").map(Term::new);
70-
Parser<Term> quoted = Parser.quotedByWithEscapes('"', '"', (Parser<? extends CharSequence>) Parser.chars(1)).map(Term::new);
70+
Parser<Term> quoted = Parser.quotedByWithEscapes('"', '"', Parser.chars(1)).map(Term::new);
7171

7272
// Leaf-level search term can be a quoted, unquoted term, or a sub-criteria inside parentheses.
7373
// They are then grouped by the boolean operators.

dot-parse/src/test/java/com/google/common/labs/parse/ParserTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,6 @@ public void quotedByWithEscapes_failures() {
450450

451451
@Test
452452
public void quotedByWithEscapes_invalidQuoteChar_throws() {
453-
assertThrows(
454-
IllegalArgumentException.class, () -> Parser.quotedByWithEscapes('\\', '"', chars(1)));
455-
assertThrows(
456-
IllegalArgumentException.class, () -> Parser.quotedByWithEscapes('\n', '"', chars(1)));
457-
assertThrows(
458-
IllegalArgumentException.class, () -> Parser.quotedByWithEscapes('\r', '"', chars(1)));
459-
assertThrows(
460-
IllegalArgumentException.class, () -> Parser.quotedByWithEscapes('\t', '"', chars(1)));
461453
assertThrows(
462454
IllegalArgumentException.class, () -> Parser.quotedByWithEscapes('"', '\\', chars(1)));
463455
assertThrows(

0 commit comments

Comments
 (0)