/** Look through a list of predicate/alt pairs, returning alts for the
* pairs that win. A {@code NONE} predicate indicates an alt containing an
* unpredicated config which behaves as "always true." If !complete
* then we stop at the first predicate that evaluates to true. This
* includes pairs with null predicates.
*/
protected BitSet evalSemanticContext(@NotNull DFAState.PredPrediction[] predPredictions,
ParserRuleContext outerContext,
boolean complete)
{
BitSet predictions = new BitSet();
for (DFAState.PredPrediction pair : predPredictions) {
if ( pair.pred==SemanticContext.NONE ) {
predictions.set(pair.alt);
if (!complete) {
break;
}
continue;
}
boolean fullCtx = false; // in dfa
boolean predicateEvaluationResult = evalSemanticContext(pair.pred, outerContext, pair.alt, fullCtx);
if ( debug || dfa_debug ) {
System.out.println("eval pred "+pair+"="+predicateEvaluationResult);
}
if ( predicateEvaluationResult ) {
if ( debug || dfa_debug ) System.out.println("PREDICT "+pair.alt);
predictions.set(pair.alt);
if (!complete) {
break;
}
}
}
return predictions;
}
ParserATNSimulator.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:Scratch-ApuC
作者:
评论列表
文章目录