@Override protected DFAState getExistingTargetState(DFAState previousD, int t) { // this method is called after each time the input position advances // during SLL prediction _sllStopIndex = _input.index(); DFAState existingTargetState = super.getExistingTargetState(previousD, t); if ( existingTargetState!=null ) { decisions[currentDecision].SLL_DFATransitions++; // count only if we transition over a DFA state if ( existingTargetState==ERROR ) { decisions[currentDecision].errors.add( new ErrorInfo(currentDecision, previousD.configs, _input, _startIndex, _sllStopIndex, false) ); } } currentState = existingTargetState; return existingTargetState; }
/** 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; }
_llStopIndex = _input.index();
if ( lastErrorIndex==recognizer.getInputStream().index() && lastErrorStates != null && lastErrorStates.contains(recognizer.getState()) ) { lastErrorIndex = recognizer.getInputStream().index(); if ( lastErrorStates==null ) lastErrorStates = new IntervalSet(); lastErrorStates.add(recognizer.getState());
if ( D.predicates!=null ) { if ( debug ) System.out.println("DFA state has preds in DFA sim LL failover"); int conflictIndex = input.index(); if (conflictIndex != startIndex) { input.seek(startIndex); computeStartState(dfa.atnStartState, outerContext, fullCtx); reportAttemptingFullContext(dfa, conflictingAlts, D.configs, startIndex, input.index()); int alt = execATNWithFullContext(dfa, D, s0_closure, input, startIndex, int stopIndex = input.index(); input.seek(startIndex); BitSet alts = evalSemanticContext(D.predicates, outerContext, true);
int currentPosition = _input.index(); _input.seek(_startIndex); boolean predSucceeds = evalSemanticContext(pt.getPredicate(), _outerContext, config.alt, fullCtx);
int currentPosition = _input.index(); _input.seek(_startIndex); boolean predSucceeds = evalSemanticContext(pt.getPredicate(), _outerContext, config.alt, fullCtx);
@Override protected SimulatorState computeReachSet(DFA dfa, SimulatorState previous, int t, PredictionContextCache contextCache) { SimulatorState reachState = super.computeReachSet(dfa, previous, t, contextCache); if (reachState == null) { // no reach on current lookahead symbol. ERROR. decisions[currentDecision].errors.add( new ErrorInfo(currentDecision, previous, _input, _startIndex, _input.index()) ); } currentState = reachState; return reachState; }
@Override public void recover(Parser recognizer, RecognitionException e) { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recover: error at " + errIndex); TokenStream input = recognizer.getInputStream(); if ( input.index()<input.size()-1 ) { // don't consume() eof recognizer.consume(); // just kill this bad token and let it continue. } }
@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; }
@Override public Token recoverInline(Parser recognizer) throws RecognitionException { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recoverInline: error at " + errIndex); InputMismatchException e = new InputMismatchException(recognizer); // TokenStream input = recognizer.getInputStream(); // seek EOF // input.seek(input.size() - 1); throw e; }
@Override public Token recoverInline(Parser recognizer) throws RecognitionException { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recoverInline: error at " + errIndex); InputMismatchException e = new InputMismatchException(recognizer); // TokenStream input = recognizer.getInputStream(); // seek EOF // input.seek(input.size() - 1); throw e; }
@Override public void recover(Parser recognizer, RecognitionException e) { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recover: error at " + errIndex); TokenStream input = recognizer.getInputStream(); if ( input.index()<input.size()-1 ) { // don't consume() eof recognizer.consume(); // just kill this bad token and let it continue. } }
@Override public void recover(Parser recognizer, RecognitionException e) { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recover: error at " + errIndex); TokenStream input = recognizer.getInputStream(); if ( input.index()<input.size()-1 ) { // don't consume() eof recognizer.consume(); // just kill this bad token and let it continue. } }
@Override public void recover(Parser recognizer, RecognitionException e) { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recover: error at " + errIndex); TokenStream input = recognizer.getInputStream(); if ( input.index()<input.size()-1 ) { // don't consume() eof recognizer.consume(); // just kill this bad token and let it continue. } }
@Override public Token recoverInline(Parser recognizer) throws RecognitionException { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recoverInline: error at " + errIndex); InputMismatchException e = new InputMismatchException(recognizer); // TokenStream input = recognizer.getInputStream(); // seek EOF // input.seek(input.size() - 1); throw e; }
@Override public void recover(Parser recognizer, RecognitionException e) { int errIndex = recognizer.getInputStream().index(); if ( firstErrorTokenIndex == -1 ) { firstErrorTokenIndex = errIndex; // latch } // System.err.println("recover: error at " + errIndex); TokenStream input = recognizer.getInputStream(); if ( input.index()<input.size()-1 ) { // don't consume() eof recognizer.consume(); // just kill this bad token and let it continue. } }
_startIndex = input.index(); _outerContext = outerContext; DFA dfa = decisionToDFA[decision];