private static void checkChoice(BnfChoice choice, ProblemsHolder problemsHolder) { Set<BnfRule> visited = new THashSet<BnfRule>(); THashSet<BnfExpression> first = new THashSet<BnfExpression>(); BnfFirstNextAnalyzer analyzer = new BnfFirstNextAnalyzer(); List<BnfExpression> list = choice.getExpressionList(); for (int i = 0, listSize = list.size() - 1; i < listSize; i++) { BnfExpression child = list.get(i); Set<String> firstSet = analyzer.asStrings(analyzer.calcFirstInner(child, first, visited)); if (firstSet.contains(BnfFirstNextAnalyzer.MATCHES_NOTHING)) { registerProblem( choice, child, "Branch is unable to match anything due to & or ! conditions", problemsHolder); } else if (firstSet.contains(BnfFirstNextAnalyzer.MATCHES_EOF)) { registerProblem( choice, child, "Branch matches empty input making the rest branches unreachable", problemsHolder); break; } first.clear(); visited.clear(); } }
/** * Clear all stopwords from this stopword list object. * * @since 1.1.0 */ public void clear() { stopWords.clear(); }