private RENode.CharacterClassExpr _parseCharacterClass() throws SyntaxException { if (lexer.next(Kind.CC_OPEN)) { boolean negated = lexer.getToken().length() > 1; RENode.CharacterClassExpr expr = parseCharacterClassExpression(); if (expr != null) { if (lexer.next(Kind.CC_CLOSE)) { return negated ? new RENode.CharacterClassExpr.Not(expr) : expr; } else { throw new SyntaxException(""); } } else { throw new SyntaxException(""); } } else { return null; } }
protected void visit(RENode.CharacterClassExpr.Not expr) throws IOException { boolean needBrace = false; for (RENode current = expr.getParent();current != null;current = current.getParent()) { if (current instanceof RENode.CharacterClassExpr.Or) { needBrace = true; break; } else if (current instanceof RENode.CharacterClassExpr.And) { needBrace = true; break; } else if (current instanceof RENode.CharacterClassExpr.Not) { needBrace = true; break; } } if (needBrace) { appendable.append("["); } appendable.append("^"); expr.getNegated().accept(this); if (needBrace) { appendable.append(']'); } }
private void negate(RENode.CharacterClassExpr negated) throws RuntimeException { if (negated instanceof RENode.CharacterClassExpr.Not) { RENode.CharacterClassExpr nested = ((RENode.CharacterClassExpr.Not)negated).getNegated(); if (nested != null) { nested.accept(this);
private void negate(RENode.CharacterClassExpr negated) throws RuntimeException { if (negated instanceof RENode.CharacterClassExpr.Not) { RENode.CharacterClassExpr nested = ((RENode.CharacterClassExpr.Not)negated).getNegated(); if (nested != null) { nested.accept(this);
protected void visit(RENode.CharacterClassExpr.Not expr) throws IOException { boolean needBrace = false; for (RENode current = expr.getParent();current != null;current = current.getParent()) { if (current instanceof RENode.CharacterClassExpr.Or) { needBrace = true; break; } else if (current instanceof RENode.CharacterClassExpr.And) { needBrace = true; break; } else if (current instanceof RENode.CharacterClassExpr.Not) { needBrace = true; break; } } if (needBrace) { appendable.append("["); } appendable.append("^"); expr.getNegated().accept(this); if (needBrace) { appendable.append(']'); } }
private RENode.CharacterClassExpr _parseCharacterClass() throws SyntaxException { if (lexer.next(Kind.CC_OPEN)) { boolean negated = lexer.getToken().length() > 1; RENode.CharacterClassExpr expr = parseCharacterClassExpression(); if (expr != null) { if (lexer.next(Kind.CC_CLOSE)) { return negated ? new RENode.CharacterClassExpr.Not(expr) : expr; } else { throw new SyntaxException(""); } } else { throw new SyntaxException(""); } } else { return null; } }
protected void visit(RENode.CharacterClassExpr.Not expr) throws E { RENode.CharacterClassExpr negated = expr.getNegated(); if (negated != null) { negated.accept(this); } }
@Override protected void visit(RENode.Any expr) throws MalformedRouteException { RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/'))); repl.setQuantifier(expr.getQuantifier()); expr.replaceBy(repl); }
@Override protected void visit(RENode.Any expr) throws MalformedRouteException { RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/'))); repl.setQuantifier(expr.getQuantifier()); expr.replaceBy(repl); }
@Override protected void visit(RENode.CharacterClassExpr.Not expr) throws RuntimeException { RENode.CharacterClassExpr negated = expr.getNegated(); if (negated == null) { // Do nothing ? } else { negate(negated); } }
@Override protected void visit(RENode.Any expr) throws MalformedRouteException { RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/'))); repl.setQuantifier(expr.getQuantifier()); expr.replaceBy(repl); }
@Override protected void visit(RENode.CharacterClassExpr.Not expr) throws RuntimeException { RENode.CharacterClassExpr negated = expr.getNegated(); if (negated == null) { // Do nothing ? } else { negate(negated); } }
protected void visit(RENode.CharacterClassExpr.Not expr) throws E { RENode.CharacterClassExpr negated = expr.getNegated(); if (negated != null) { negated.accept(this); } }
@Override protected void visit(RENode.Any expr) throws MalformedRouteException { RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/'))); repl.setQuantifier(expr.getQuantifier()); expr.replaceBy(repl); }