HashSet<State> followers = new HashSet<State>();
if(s==null){
}
else{
NodeProvider node = s.getNode();
LinkedList<NodeProvider> stack = s.getStack();
int nodeType = node.getType();
switch(nodeType){
case NodeProvider.eps:
State follower2 = getNextState(s);
followers.addAll(calculateFollowers(follower2));
break;
case NodeProvider.opt:
case NodeProvider.iter:
State sub = new State(node.getSub(), stack);
State next = getNextState(s);
followers.addAll(calculateFollowers(sub));
followers.addAll(calculateFollowers(next));
break;
case NodeProvider.alt:
State alt1 = new State(node.getSub(), stack);
State alt2 = new State(node.getDown(), stack);
followers.addAll(calculateFollowers(alt1));
if(alt2.getNode().getNode()!=null){
followers.addAll(calculateFollowers(alt2));
}
break;
case NodeProvider.nt:
//only continue if the peek token is a terminal follower of the nt
// BitSet terminalFollowers = node.getSymbol().getTerminalFollowers();
// BitSet nonTerminalFollowers = node.getSymbol().getNonTerminalFollowers();
BitSet startSymbols = node.getSymbol().getStartSymbols();
// System.out.println(getPeekTokenKind() + " " + node.getSymbol().getName());
// for(int i = 0; i < startSymbols.size(); i++){
// System.out.print(i + " " +startSymbols.get(i) + " ");
// }
// System.out.println();
if(startSymbols.get(getPeekTokenKind())){
stack.add(node);
State first = new State(node.getSymbol().getGraph(), stack);
followers.addAll(calculateFollowers(first));
}
else if(node.getSymbol().isDeletable()){
State over = getNextState(s);
followers.addAll(calculateFollowers(over));
}
break;
case NodeProvider.t:
case NodeProvider.wt:
if(getPeekTokenKind() == node.getSymbol().getNumber()){
followers.add(s);
}
break;
default: