protected void predicateDFAState(DFAState dfaState, DecisionState decisionState) { // We need to test all predicates, even in DFA states that // uniquely predict alternative. int nalts = decisionState.getNumberOfTransitions(); // Update DFA so reach becomes accept state with (predicate,alt) // pairs if preds found for conflicting alts BitSet altsToCollectPredsFrom = getConflictingAltsOrUniqueAlt(dfaState.configs); SemanticContext[] altToPred = getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); if ( altToPred!=null ) { dfaState.predicates = getPredicatePredictions(altsToCollectPredsFrom, altToPred); dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds } else { // There are preds in configs but they might go away // when OR'd together like {p}? || NONE == NONE. If neither // alt has preds, resolve to min alt dfaState.prediction = altsToCollectPredsFrom.nextSetBit(0); } }
/** collect and set D's semantic context */ protected DFAState.PredPrediction[] predicateDFAState(DFAState D, ATNConfigSet configs, int nalts) { BitSet conflictingAlts = getConflictingAltsFromConfigSet(configs); if ( debug ) System.out.println("predicateDFAState "+D); SemanticContext[] altToPred = getPredsForAmbigAlts(conflictingAlts, configs, nalts); // altToPred[uniqueAlt] is now our validating predicate (if any) DFAState.PredPrediction[] predPredictions = null; if ( altToPred!=null ) { // we have a validating predicate; test it // Update DFA so reach becomes accept state with predicate predPredictions = getPredicatePredictions(conflictingAlts, altToPred); D.predicates = predPredictions; } return predPredictions; }
protected void predicateDFAState(DFAState dfaState, DecisionState decisionState) { // We need to test all predicates, even in DFA states that // uniquely predict alternative. int nalts = decisionState.getNumberOfTransitions(); // Update DFA so reach becomes accept state with (predicate,alt) // pairs if preds found for conflicting alts BitSet altsToCollectPredsFrom = getConflictingAltsOrUniqueAlt(dfaState.configs); SemanticContext[] altToPred = getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); if ( altToPred!=null ) { dfaState.predicates = getPredicatePredictions(altsToCollectPredsFrom, altToPred); dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds } else { // There are preds in configs but they might go away // when OR'd together like {p}? || NONE == NONE. If neither // alt has preds, resolve to min alt dfaState.prediction = altsToCollectPredsFrom.nextSetBit(0); } }
protected void predicateDFAState(DFAState dfaState, DecisionState decisionState) { // We need to test all predicates, even in DFA states that // uniquely predict alternative. int nalts = decisionState.getNumberOfTransitions(); // Update DFA so reach becomes accept state with (predicate,alt) // pairs if preds found for conflicting alts BitSet altsToCollectPredsFrom = getConflictingAltsOrUniqueAlt(dfaState.configs); SemanticContext[] altToPred = getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); if ( altToPred!=null ) { dfaState.predicates = getPredicatePredictions(altsToCollectPredsFrom, altToPred); dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds } else { // There are preds in configs but they might go away // when OR'd together like {p}? || NONE == NONE. If neither // alt has preds, resolve to min alt dfaState.prediction = altsToCollectPredsFrom.nextSetBit(0); } }
protected void predicateDFAState(DFAState dfaState, DecisionState decisionState) { // We need to test all predicates, even in DFA states that // uniquely predict alternative. int nalts = decisionState.getNumberOfTransitions(); // Update DFA so reach becomes accept state with (predicate,alt) // pairs if preds found for conflicting alts BitSet altsToCollectPredsFrom = getConflictingAltsOrUniqueAlt(dfaState.configs); SemanticContext[] altToPred = getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); if ( altToPred!=null ) { dfaState.predicates = getPredicatePredictions(altsToCollectPredsFrom, altToPred); dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds } else { // There are preds in configs but they might go away // when OR'd together like {p}? || NONE == NONE. If neither // alt has preds, resolve to min alt dfaState.prediction = altsToCollectPredsFrom.nextSetBit(0); } }
SemanticContext[] altToPred = getPredsForAmbigAlts(alts, filteredConfigs, maxAlt); if (altToPred != null) { DFAState.PredPrediction[] predicates = getPredicatePredictions(alts, altToPred);