use of org.antlr.v4.misc.FrequencySet in project antlr4 by tunnelvisionlabs.
the class RuleFunction method getElementFrequenciesForAlt.
/**
* Given list of X and r refs in alt, compute how many of each there are
*/
protected Tuple2<FrequencySet<String>, FrequencySet<String>> getElementFrequenciesForAlt(AltAST ast) {
try {
ElementFrequenciesVisitor visitor = new ElementFrequenciesVisitor(rule.g, new CommonTreeNodeStream(new GrammarASTAdaptor(), ast));
visitor.outerAlternative();
if (visitor.frequencies.size() != 1) {
factory.getGrammar().tool.errMgr.toolError(ErrorType.INTERNAL_ERROR);
return Tuple.create(new FrequencySet<String>(), new FrequencySet<String>());
}
return Tuple.create(visitor.getMinFrequencies(), visitor.frequencies.peek());
} catch (RecognitionException ex) {
factory.getGrammar().tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, ex);
return Tuple.create(new FrequencySet<String>(), new FrequencySet<String>());
}
}
Aggregations