private char advance() { if (!isAtEnd()) current++; return previous(); }
private char advance() { if (!isAtEnd()) current++; return previous(); }
/** Return the matcher for the top level expression. */ Matcher parse() { Matcher m = expr(); if (!isAtEnd()) { throw error("unmatched closing parenthesis"); } return m; }
/** Return the matcher for the top level expression. */ Matcher parse() { Matcher m = expr(); if (!isAtEnd()) { throw error("unmatched closing parenthesis"); } return m; }
@SuppressWarnings("PMD.AvoidBranchingStatementAsLastInLoop") private void advance(IntPredicate condition) { while (!isAtEnd() && condition.test(advance())) { continue; // loop is just used to advance the position } } }
@SuppressWarnings("PMD.AvoidBranchingStatementAsLastInLoop") private void advance(IntPredicate condition) { while (!isAtEnd() && condition.test(advance())) { continue; // loop is just used to advance the position } } }
private Matcher term() { List<Matcher> matchers = new ArrayList<>(); while (!isAtEnd() && peek() != ')' && peek() != '|') { char c = advance(); switch (c) {
private Matcher term() { List<Matcher> matchers = new ArrayList<>(); while (!isAtEnd() && peek() != ')' && peek() != '|') { char c = advance(); switch (c) {
private Matcher group() { if (peek() == '?') { advance(); char c = advance(); switch (c) { case '<': // Named capturing group advance(v -> v != '>'); if (isAtEnd()) { throw error("unclosed name for capturing group"); } return groupExpr(); case ':': // Non-capturing group return groupExpr(); case '=': return new PositiveLookaheadMatcher(expr()); case '!': return new NegativeLookaheadMatcher(expr()); default: throw unsupported("inline flags"); } } else { return groupExpr(); } }
private Matcher group() { if (peek() == '?') { advance(); char c = advance(); switch (c) { case '<': // Named capturing group advance(v -> v != '>'); if (isAtEnd()) { throw error("unclosed name for capturing group"); } return groupExpr(); case ':': // Non-capturing group return groupExpr(); case '=': return new PositiveLookaheadMatcher(expr()); case '!': return new NegativeLookaheadMatcher(expr()); default: throw unsupported("inline flags"); } } else { return groupExpr(); } }
set = update(set, AsciiSet.fromPattern(Character.toString(c)), invert); while (!isAtEnd() && peek() != ']') { char c = advance(); switch (c) {
set = update(set, AsciiSet.fromPattern(Character.toString(c)), invert); while (!isAtEnd() && peek() != ']') { char c = advance(); switch (c) {