Search in sources :

Example 11 with CallExpr

use of org.batfish.datamodel.routing_policy.expr.CallExpr in project batfish by batfish.

the class AstVisitor method visit.

/*
   * Walk starting from an AST boolean expression
   */
public void visit(Configuration conf, BooleanExpr e, Consumer<Statement> fs, Consumer<BooleanExpr> fe) {
    fe.accept(e);
    if (e instanceof Conjunction) {
        Conjunction c = (Conjunction) e;
        for (BooleanExpr be : c.getConjuncts()) {
            visit(conf, be, fs, fe);
        }
    } else if (e instanceof Disjunction) {
        Disjunction d = (Disjunction) e;
        for (BooleanExpr be : d.getDisjuncts()) {
            visit(conf, be, fs, fe);
        }
    } else if (e instanceof ConjunctionChain) {
        ConjunctionChain c = (ConjunctionChain) e;
        for (BooleanExpr be : c.getSubroutines()) {
            visit(conf, be, fs, fe);
        }
    } else if (e instanceof DisjunctionChain) {
        DisjunctionChain d = (DisjunctionChain) e;
        for (BooleanExpr be : d.getSubroutines()) {
            visit(conf, be, fs, fe);
        }
    } else if (e instanceof Not) {
        Not n = (Not) e;
        visit(conf, n.getExpr(), fs, fe);
    } else if (e instanceof CallExpr) {
        CallExpr c = (CallExpr) e;
        RoutingPolicy rp = conf.getRoutingPolicies().get(c.getCalledPolicyName());
        visit(conf, rp.getStatements(), fs, fe);
    }
}
Also used : Disjunction(org.batfish.datamodel.routing_policy.expr.Disjunction) Not(org.batfish.datamodel.routing_policy.expr.Not) Conjunction(org.batfish.datamodel.routing_policy.expr.Conjunction) CallExpr(org.batfish.datamodel.routing_policy.expr.CallExpr) RoutingPolicy(org.batfish.datamodel.routing_policy.RoutingPolicy) ConjunctionChain(org.batfish.datamodel.routing_policy.expr.ConjunctionChain) DisjunctionChain(org.batfish.datamodel.routing_policy.expr.DisjunctionChain) BooleanExpr(org.batfish.datamodel.routing_policy.expr.BooleanExpr)

Aggregations

CallExpr (org.batfish.datamodel.routing_policy.expr.CallExpr)11 RoutingPolicy (org.batfish.datamodel.routing_policy.RoutingPolicy)10 If (org.batfish.datamodel.routing_policy.statement.If)8 Disjunction (org.batfish.datamodel.routing_policy.expr.Disjunction)7 BooleanExpr (org.batfish.datamodel.routing_policy.expr.BooleanExpr)6 Conjunction (org.batfish.datamodel.routing_policy.expr.Conjunction)6 MatchProtocol (org.batfish.datamodel.routing_policy.expr.MatchProtocol)6 Not (org.batfish.datamodel.routing_policy.expr.Not)6 ArrayList (java.util.ArrayList)5 MatchPrefixSet (org.batfish.datamodel.routing_policy.expr.MatchPrefixSet)5 Prefix (org.batfish.datamodel.Prefix)4 DisjunctionChain (org.batfish.datamodel.routing_policy.expr.DisjunctionChain)4 GeneratedRoute (org.batfish.datamodel.GeneratedRoute)3 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)3 Ip (org.batfish.datamodel.Ip)3 PrefixRange (org.batfish.datamodel.PrefixRange)3 PrefixSpace (org.batfish.datamodel.PrefixSpace)3 SubRange (org.batfish.datamodel.SubRange)3 Statement (org.batfish.datamodel.routing_policy.statement.Statement)3 BatfishException (org.batfish.common.BatfishException)2