Search in sources :

Example 1 with VisitBag

use of priv.bajdcc.util.VisitBag in project jMiniLang by bajdcc.

the class BranchExp method visit.

@Override
public void visit(ISyntaxComponentVisitor visitor) {
    VisitBag bag = new VisitBag();
    visitor.visitBegin(this, bag);
    if (bag.bVisitChildren) {
        for (ISyntaxComponent exp : arrExpressions) {
            exp.visit(visitor);
        }
    }
    if (bag.bVisitEnd) {
        visitor.visitEnd(this);
    }
}
Also used : ISyntaxComponent(priv.bajdcc.LALR1.syntax.ISyntaxComponent) VisitBag(priv.bajdcc.util.VisitBag)

Example 2 with VisitBag

use of priv.bajdcc.util.VisitBag in project jMiniLang by bajdcc.

the class NGAStatus method visit.

/**
 * 用于遍历包括该状态在内的所有状态(连通),结果存放在PATH中
 *
 * @param bfs
 *            遍历算法
 */
public void visit(BreadthFirstSearch<NGAEdge, NGAStatus> bfs) {
    ArrayList<NGAStatus> stack = bfs.arrStatus;
    HashSet<NGAStatus> set = new HashSet<>();
    stack.clear();
    set.add(this);
    stack.add(this);
    for (int i = 0; i < stack.size(); i++) {
        // 遍历每个状态
        NGAStatus status = stack.get(i);
        VisitBag bag = new VisitBag();
        bfs.visitBegin(status, bag);
        if (bag.bVisitChildren) {
            // 遍历状态的出边
            // 边未被访问,且边类型符合要求
            status.outEdges.stream().filter(edge -> !set.contains(edge.end) && bfs.testEdge(edge)).forEach(edge -> {
                // 边未被访问,且边类型符合要求
                stack.add(edge.end);
                set.add(edge.end);
            });
        }
        if (bag.bVisitEnd) {
            bfs.visitEnd(status);
        }
    }
}
Also used : HashSet(java.util.HashSet) VisitBag(priv.bajdcc.util.VisitBag) BreadthFirstSearch(priv.bajdcc.util.lexer.automata.BreadthFirstSearch) ArrayList(java.util.ArrayList) VisitBag(priv.bajdcc.util.VisitBag) HashSet(java.util.HashSet)

Example 3 with VisitBag

use of priv.bajdcc.util.VisitBag in project jMiniLang by bajdcc.

the class RuleExp method visit.

@Override
public void visit(ISyntaxComponentVisitor visitor) {
    VisitBag bag = new VisitBag();
    visitor.visitBegin(this, bag);
    if (bag.bVisitEnd) {
        visitor.visitEnd(this);
    }
}
Also used : VisitBag(priv.bajdcc.util.VisitBag)

Example 4 with VisitBag

use of priv.bajdcc.util.VisitBag in project jMiniLang by bajdcc.

the class SequenceExp method visit.

@Override
public void visit(ISyntaxComponentVisitor visitor) {
    VisitBag bag = new VisitBag();
    visitor.visitBegin(this, bag);
    if (bag.bVisitChildren) {
        for (ISyntaxComponent exp : arrExpressions) {
            exp.visit(visitor);
        }
    }
    if (bag.bVisitEnd) {
        visitor.visitEnd(this);
    }
}
Also used : ISyntaxComponent(priv.bajdcc.LALR1.syntax.ISyntaxComponent) VisitBag(priv.bajdcc.util.VisitBag)

Example 5 with VisitBag

use of priv.bajdcc.util.VisitBag in project jMiniLang by bajdcc.

the class TokenExp method visit.

@Override
public void visit(ISyntaxComponentVisitor visitor) {
    VisitBag bag = new VisitBag();
    visitor.visitBegin(this, bag);
    if (bag.bVisitEnd) {
        visitor.visitEnd(this);
    }
}
Also used : VisitBag(priv.bajdcc.util.VisitBag)

Aggregations

VisitBag (priv.bajdcc.util.VisitBag)22 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 BreadthFirstSearch (priv.bajdcc.util.lexer.automata.BreadthFirstSearch)4 ISyntaxComponent (priv.bajdcc.OP.syntax.ISyntaxComponent)3 ISyntaxComponent (priv.bajdcc.LALR1.syntax.ISyntaxComponent)2 ISyntaxComponent (priv.bajdcc.LL1.syntax.ISyntaxComponent)2