MCPcopy Create free account
hub / github.com/cschanck/single-file-java / anyOf

Method anyOf

src/main/java/org/sfj/PegLegParser.java:682–692  ·  view source on GitHub ↗

Generates a rule which matches any single char in the char sequence. @param string candidate chars. @return rule

(CharSequence string)

Source from the content-addressed store, hash-verified

680 * @return rule
681 */
682 public CharTerminal<V> anyOf(CharSequence string) {
683 return new CharTerminal<>((ignoreCase) -> {
684 get().pushFrame("anyOf(" + string + ")");
685 int n = get().nextChar();
686 if (n < 0) { return get().ruleReturn(false, false); }
687 for (int i = 0; i < string.length(); i++) {
688 if (isCharMatch(ignoreCase, string.charAt(i), (char) n)) { return get().ruleReturn(true, true); }
689 }
690 return get().ruleReturn(false, false);
691 });
692 }
693
694 /**
695 * Dictionary lookup, optimized.

Callers 7

expressionMethod · 0.80
termMethod · 0.80
SMethod · 0.80
escapedCharMethod · 0.80
escapedCharMethod · 0.80
integerMethod · 0.80
expMethod · 0.80

Calls 5

getMethod · 0.95
isCharMatchMethod · 0.95
pushFrameMethod · 0.80
ruleReturnMethod · 0.80
nextCharMethod · 0.45

Tested by 4

expressionMethod · 0.64
termMethod · 0.64
SMethod · 0.64
escapedCharMethod · 0.64