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

Method charRange

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

Generate a terminal rule for a range of characters. @param from lower bound @param to upper bound. @return rule

(char from, char to)

Source from the content-addressed store, hash-verified

605 * @return rule
606 */
607 public CharTerminal<V> charRange(char from, char to) {
608 if ((int) from > (int) to) { throw error("Char range is illegal: [" + from + " to " + to + "]"); }
609 return new CharTerminal<>((ignoreCase) -> {
610 get().pushFrame("charRange(" + from + "," + to + ")");
611 int n = get().nextChar();
612 if (n >= 0) {
613 for (int i = from; i <= (int) to; i++) {
614 if (isCharMatch(ignoreCase, (char) n, (char) i)) {
615 return get().ruleReturn(true, true);
616 }
617 }
618 }
619 return get().ruleReturn(false, false);
620 });
621 }
622
623 /**
624 * Generate a rule for a specific string (char sequence)

Callers 8

numberMethod · 0.80
digitMethod · 0.80
alphaMethod · 0.80
hexMethod · 0.80
argMethod · 0.80
integerMethod · 0.80
digitMethod · 0.80
hexMethod · 0.80

Calls 6

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

Tested by 5

numberMethod · 0.64
digitMethod · 0.64
alphaMethod · 0.64
hexMethod · 0.64
argMethod · 0.64