Skip to content

Commit 309912c

Browse files
committed
WORD -> word(), DIGITS -> digits()
1 parent 6ffba6f commit 309912c

File tree

3 files changed

+119
-115
lines changed

3 files changed

+119
-115
lines changed

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,6 @@
6464
* subject to stack overflow error on maliciously crafted input (think of 10K left parens).
6565
*/
6666
public abstract class Parser<T> {
67-
/**
68-
* One or more regex {@code \w+} characters.
69-
*
70-
* @since 9.4
71-
*/
72-
public static final Parser<String> WORD = consecutive(CharPredicate.WORD, "word");
73-
74-
/**
75-
* One or more regex {@code \d+} characters.
76-
*
77-
* @since 9.4
78-
*/
79-
public static final Parser<String> DIGITS = consecutive(CharPredicate.range('0', '9'), "digits");
80-
8167
/**
8268
* Only use in context where input consumption is guaranteed. Do not use within a loop, like
8369
* atLeastOnce(), zeroOrMore()!
@@ -129,6 +115,24 @@ private static Parser<Void> skipConsecutive(CharPredicate matcher, String name)
129115
};
130116
}
131117

118+
/**
119+
* One or more regex {@code \w+} characters.
120+
*
121+
* @since 9.4
122+
*/
123+
public static Parser<String> word() {
124+
return consecutive(CharPredicate.WORD, "word");
125+
}
126+
127+
/**
128+
* One or more regex {@code \d+} characters.
129+
*
130+
* @since 9.4
131+
*/
132+
public static Parser<String> digits() {
133+
return consecutive(CharPredicate.range('0', '9'), "digits");
134+
}
135+
132136
/** Matches a literal {@code string}. */
133137
public static Parser<String> string(String value) {
134138
checkArgument(value.length() > 0, "value cannot be empty");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.google.common.labs.parse;
22

3-
import static com.google.common.labs.parse.Parser.WORD;
3+
import static com.google.common.labs.parse.Parser.word;
44
import static com.google.common.truth.Truth.assertThat;
55

66
import java.util.Set;
@@ -66,7 +66,7 @@ static SearchCriteria parse(String input) {
6666

6767
// A search term is either quoted, or unquoted (but cannot be a keyword)
6868
Parser<Term> unquoted =
69-
WORD.suchThat(w -> !keywords.contains(w), "search term").map(Term::new);
69+
word().suchThat(w -> !keywords.contains(w), "search term").map(Term::new);
7070
Parser<Term> quoted = Parser.quotedStringWithEscapes('"', Object::toString).map(Term::new);
7171

7272
// Leaf-level search term can be a quoted, unquoted term, or a sub-criteria inside parentheses.

0 commit comments

Comments
 (0)