Search in sources :

Example 1 with StatementContext

use of org.batfish.grammar.flatjuniper.FlatJuniperParser.StatementContext in project batfish by batfish.

the class GroupTreeBuilder method exitS_groups_named.

@Override
public void exitS_groups_named(S_groups_namedContext ctx) {
    String groupName = ctx.name.getText();
    HierarchyTree tree = _hierarchy.getTree(groupName);
    if (tree == null) {
        tree = _hierarchy.newTree(groupName);
    }
    StatementContext statement = ctx.s_groups_tail().statement();
    if (statement == null) {
        return;
    }
    Interval interval = ctx.s_groups_tail().getSourceInterval();
    List<Token> unfilteredTokens = _combinedParser.getTokens().getTokens(interval.a, interval.b);
    HierarchyPath path = new HierarchyPath();
    for (Token currentToken : unfilteredTokens) {
        if (currentToken.getChannel() != Lexer.HIDDEN) {
            String text = currentToken.getText();
            if (currentToken.getType() == FlatJuniperLexer.WILDCARD) {
                path.addWildcardNode(text);
            } else {
                path.addNode(text);
            }
        }
    }
    path.setStatement(statement);
    tree.addPath(path, _currentSetLine, null);
}
Also used : HierarchyPath(org.batfish.grammar.flatjuniper.Hierarchy.HierarchyTree.HierarchyPath) HierarchyTree(org.batfish.grammar.flatjuniper.Hierarchy.HierarchyTree) Token(org.antlr.v4.runtime.Token) StatementContext(org.batfish.grammar.flatjuniper.FlatJuniperParser.StatementContext) Interval(org.antlr.v4.runtime.misc.Interval)

Aggregations

Token (org.antlr.v4.runtime.Token)1 Interval (org.antlr.v4.runtime.misc.Interval)1 StatementContext (org.batfish.grammar.flatjuniper.FlatJuniperParser.StatementContext)1 HierarchyTree (org.batfish.grammar.flatjuniper.Hierarchy.HierarchyTree)1 HierarchyPath (org.batfish.grammar.flatjuniper.Hierarchy.HierarchyTree.HierarchyPath)1