/** Method visitDecisionState() is called when the interpreter reaches * a decision state (instance of DecisionState). It gives an opportunity * for subclasses to track interesting things. */ protected int visitDecisionState(DecisionState p) { int predictedAlt = 1; if ( p.getNumberOfTransitions()>1 ) { getErrorHandler().sync(this); int decision = p.decision; if ( decision == overrideDecision && _input.index() == overrideDecisionInputIndex && !overrideDecisionReached ) { predictedAlt = overrideDecisionAlt; overrideDecisionReached = true; } else { predictedAlt = getInterpreter().adaptivePredict(_input, decision, _ctx); } } return predictedAlt; }
for (int i = 0; i < decision.getNumberOfTransitions(); i++) { Transition epsTransition = decision.transition(i); if (!(epsTransition instanceof EpsilonTransition)) { continue; ATNState blockEndState = decision.transition(interval.a).target.transition(0).target; IntervalSet matchSet = new IntervalSet(); for (int j = interval.a; j <= interval.b; j++) { Transition matchTransition = decision.transition(j).target.transition(0); if (matchTransition instanceof NotSetTransition) { throw new UnsupportedOperationException("Not yet implemented."); decision.transition(interval.a).target.setTransition(0, newTransition); for (int j = interval.a + 1; j <= interval.b; j++) { Transition removed = decision.removeTransition(interval.a + 1); atn.removeState(removed.target); removedStates++;
protected int visitDecisionState(DecisionState p) { int predictedAlt = super.visitDecisionState(p); if( p.getNumberOfTransitions() > 1) { int[] alts = stateToAltsMap[p.stateNumber]; LeftRecursiveRule lr = (LeftRecursiveRule) g.getRule(p.ruleIndex); if (p.getStateType() == ATNState.BLOCK_START) { if ( alts==null ) { alts = lr.getPrimaryAlts(); else if ( p.getStateType() == ATNState.STAR_BLOCK_START ) { if ( alts==null ) { alts = lr.getRecursiveOpAlts();
for (int alt=1; alt<=decisionState.getTransitions().length; alt++) {
for (int i = 0; i < decision.getNumberOfTransitions(); i++) { Transition epsTransition = decision.transition(i); if (!(epsTransition instanceof EpsilonTransition)) { continue; ATNState blockEndState = decision.transition(interval.a).target.transition(0).target; IntervalSet matchSet = new IntervalSet(); for (int j = interval.a; j <= interval.b; j++) { Transition matchTransition = decision.transition(j).target.transition(0); if (matchTransition instanceof NotSetTransition) { throw new UnsupportedOperationException("Not yet implemented."); decision.transition(interval.a).target.setTransition(0, newTransition); for (int j = interval.a + 1; j <= interval.b; j++) { Transition removed = decision.removeTransition(interval.a + 1); atn.removeState(removed.target); removedStates++;
protected int visitDecisionState(DecisionState p) { int predictedAlt = super.visitDecisionState(p); if( p.getNumberOfTransitions() > 1) { int[] alts = stateToAltsMap[p.stateNumber]; LeftRecursiveRule lr = (LeftRecursiveRule) g.getRule(p.ruleIndex); if (p.getStateType() == ATNState.BLOCK_START) { if ( alts==null ) { alts = lr.getPrimaryAlts(); else if ( p.getStateType() == ATNState.STAR_BLOCK_START ) { if ( alts==null ) { alts = lr.getRecursiveOpAlts();
for (int alt = 1; alt<=decisionState.getTransitions().length; alt++) {
for (int i = 0; i < decision.getNumberOfTransitions(); i++) { Transition epsTransition = decision.transition(i); if (!(epsTransition instanceof EpsilonTransition)) { continue; ATNState blockEndState = decision.transition(interval.a).target.transition(0).target; IntervalSet matchSet = new IntervalSet(); for (int j = interval.a; j <= interval.b; j++) { Transition matchTransition = decision.transition(j).target.transition(0); if (matchTransition instanceof NotSetTransition) { throw new UnsupportedOperationException("Not yet implemented."); decision.transition(interval.a).target.setTransition(0, newTransition); for (int j = interval.a + 1; j <= interval.b; j++) { Transition removed = decision.removeTransition(interval.a + 1); atn.removeState(removed.target); removedStates++;
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 int visitDecisionState(DecisionState p) { int predictedAlt = super.visitDecisionState(p); if( p.getNumberOfTransitions() > 1) { int[] alts = stateToAltsMap[p.stateNumber]; LeftRecursiveRule lr = (LeftRecursiveRule) g.getRule(p.ruleIndex); if (p.getStateType() == ATNState.BLOCK_START) { if ( alts==null ) { alts = lr.getPrimaryAlts(); else if ( p.getStateType() == ATNState.STAR_BLOCK_START ) { if ( alts==null ) { alts = lr.getRecursiveOpAlts();
for (int alt = 1; alt<=decisionState.getTransitions().length; alt++) {
for (int i = 0; i < decision.getNumberOfTransitions(); i++) { Transition epsTransition = decision.transition(i); if (!(epsTransition instanceof EpsilonTransition)) { continue; ATNState blockEndState = decision.transition(interval.a).target.transition(0).target; IntervalSet matchSet = new IntervalSet(); for (int j = interval.a; j <= interval.b; j++) { Transition matchTransition = decision.transition(j).target.transition(0); if (matchTransition instanceof NotSetTransition) { throw new UnsupportedOperationException("Not yet implemented."); decision.transition(interval.a).target.setTransition(0, newTransition); for (int j = interval.a + 1; j <= interval.b; j++) { Transition removed = decision.removeTransition(interval.a + 1); atn.removeState(removed.target); removedStates++;
@Override protected int visitDecisionState(DecisionState p) { int predictedAlt = super.visitDecisionState(p); if ( p.getNumberOfTransitions()>1 ) { // System.out.println("decision "+p.decision+": "+predictedAlt); if ( p.decision==this.overrideDecision && this._input.index()==this.overrideDecisionInputIndex ) { ((PreviewInterpreterRuleContext)overrideDecisionRoot).isDecisionOverrideRoot = true; } } return predictedAlt; }
protected int visitDecisionState(DecisionState p) { int predictedAlt = super.visitDecisionState(p); if( p.getNumberOfTransitions() > 1) { int[] alts = stateToAltsMap[p.stateNumber]; LeftRecursiveRule lr = (LeftRecursiveRule) g.getRule(p.ruleIndex); if (p.getStateType() == ATNState.BLOCK_START) { if ( alts==null ) { alts = lr.getPrimaryAlts(); else if ( p.getStateType() == ATNState.STAR_BLOCK_START ) { if ( alts==null ) { alts = lr.getRecursiveOpAlts();
for (int alt = 1; alt<=decisionState.getTransitions().length; alt++) {
for (int i = 0; i < decision.getNumberOfTransitions(); i++) { Transition epsTransition = decision.transition(i); if (!(epsTransition instanceof EpsilonTransition)) { continue; ATNState blockEndState = decision.transition(interval.a).target.transition(0).target; IntervalSet matchSet = new IntervalSet(); for (int j = interval.a; j <= interval.b; j++) { Transition matchTransition = decision.transition(j).target.transition(0); if (matchTransition instanceof NotSetTransition) { throw new UnsupportedOperationException("Not yet implemented."); decision.transition(interval.a).target.setTransition(0, newTransition); for (int j = interval.a + 1; j <= interval.b; j++) { Transition removed = decision.removeTransition(interval.a + 1); atn.removeState(removed.target); removedStates++;
checkCondition(decisionState.getNumberOfTransitions() <= 1 || decisionState.decision >= 0);
/** Method visitDecisionState() is called when the interpreter reaches * a decision state (instance of DecisionState). It gives an opportunity * for subclasses to track interesting things. */ protected int visitDecisionState(DecisionState p) { int predictedAlt = 1; if ( p.getNumberOfTransitions()>1 ) { getErrorHandler().sync(this); int decision = p.decision; if ( decision == overrideDecision && _input.index() == overrideDecisionInputIndex && !overrideDecisionReached ) { predictedAlt = overrideDecisionAlt; overrideDecisionReached = true; } else { predictedAlt = getInterpreter().adaptivePredict(_input, decision, _ctx); } } return predictedAlt; }
/** Method visitDecisionState() is called when the interpreter reaches * a decision state (instance of DecisionState). It gives an opportunity * for subclasses to track interesting things. */ protected int visitDecisionState(DecisionState p) { int predictedAlt = 1; if ( p.getNumberOfTransitions()>1 ) { getErrorHandler().sync(this); int decision = p.decision; if ( decision == overrideDecision && _input.index() == overrideDecisionInputIndex && !overrideDecisionReached ) { predictedAlt = overrideDecisionAlt; overrideDecisionReached = true; } else { predictedAlt = getInterpreter().adaptivePredict(_input, decision, _ctx); } } return predictedAlt; }
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); } }