public void addNtElem(String ntName, BioFuzzParseNode elem) { // logger.debug("add " + ntName + "to set of NTs"); // root is a non-terminal but should not be in this set // since it is required for crossover if (elem.getAtagType() == TagType.ROOT || elem.getAtagType() == TagType.TERMINAL || elem.getAtagType() == TagType.TOK_TERMINAL) { return; } assert (elem != null); // this part is important for crossover if (elem.getTokIdx() > this.pfxBarrier) { this.ntSuffixSet.add(ntName); } this.ntSet.add(ntName); if (!this.ntDict.containsKey(ntName)) { this.ntDict.put(ntName, new ArrayList<BioFuzzParseNode>()); } this.ntDict.get(ntName).add(elem); }
private String genStr(BioFuzzParseNode node, int level) { String s = ""; List<BioFuzzParseNode> children = null; // if ((children = node.getChildren()) != null) { if (node.hasChildren()) { children = node.getChildren(); assert (children != null); Iterator<BioFuzzParseNode> iter = children.iterator(); while (iter.hasNext()) { BioFuzzParseNode child = iter.next(); s += StringUtils.repeat(" ", level) + "|--" + child.toString(); s += "[AttackTag: " + child.getAtagName() + "(" + child.getAtagType().toString() + ")" + "(" + child.getVal() + ")]\n" + genStr(child, level + 1); } } else { if (this.tokLst != null) { s += StringUtils.repeat(" ", level) + "|--" + node.toString(); s += "[Tok: " + this.tokLst.get(node.getTokIdx()) + "(" + node.getAtagType().toString() + ")" + "(" + node.getVal() + ")]\n"; } } // } return s; }