Search in sources :

Example 11 with VisitBag

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

the class PropertyExp method visit.

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

Example 12 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)

Example 13 with VisitBag

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

the class TokenExp method visitReverse.

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

Example 14 with VisitBag

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

the class NFAStatus method visit.

/**
 * 用于遍历包括该状态在内的所有状态(连通),结果存放在PATH中
 *
 * @param bfs
 *            遍历算法
 */
public void visit(BreadthFirstSearch<NFAEdge, NFAStatus> bfs) {
    ArrayList<NFAStatus> stack = bfs.arrStatus;
    HashSet<NFAStatus> set = new HashSet<>();
    stack.clear();
    set.add(this);
    stack.add(this);
    for (int i = 0; i < stack.size(); i++) {
        // 遍历每个状态
        NFAStatus 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 15 with VisitBag

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

the class DFAStatus method visit.

/**
 * 用于遍历包括该状态在内的所有状态(连通),结果存放在PATH中
 *
 * @param bfs
 *            遍历算法
 */
public void visit(BreadthFirstSearch<DFAEdge, DFAStatus> bfs) {
    ArrayList<DFAStatus> stack = bfs.arrStatus;
    HashSet<DFAStatus> set = new HashSet<>();
    stack.clear();
    set.add(this);
    stack.add(this);
    for (int i = 0; i < stack.size(); i++) {
        // 遍历每个状态
        DFAStatus 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)

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