TokenStream tokens = recognizer.getInputStream(); Token token = tokens.LT(1); ATNState state = recognizer.getInterpreter().atn.states.get(recognizer.getState()); IntervalSet nextTokens = recognizer.getATN().nextTokens(state); if (nextTokens.contains(token.getType())) {
public ProfilingATNSimulator(Parser parser) { super(parser, parser.getInterpreter().atn, parser.getInterpreter().decisionToDFA, parser.getInterpreter().sharedContextCache); numDecisions = atn.decisionToState.size(); decisions = new DecisionInfo[numDecisions]; for (int i=0; i<numDecisions; i++) { decisions[i] = new DecisionInfo(i); } }
@Override public ParseInfo getParseInfo() { ParserATNSimulator interp = getInterpreter(); if (interp instanceof ProfilingATNSimulator) { return new ParseInfo((ProfilingATNSimulator)interp); } return null; }
public IntervalSet getExpectedTokensWithinCurrentRule() { ATN atn = getInterpreter().atn; ATNState s = atn.states.get(getState()); return atn.nextTokens(s); }
ATNState currentState = recognizer.getInterpreter().atn.states.get(recognizer.getState()); ATNState next = currentState.transition(0).target; ATN atn = recognizer.getInterpreter().atn; IntervalSet expectingAtLL2 = atn.nextTokens(next, recognizer._ctx);
/** * @since 4.3 */ public void setProfile(boolean profile) { ParserATNSimulator interp = getInterpreter(); PredictionMode saveMode = interp.getPredictionMode(); if ( profile ) { if ( !(interp instanceof ProfilingATNSimulator) ) { setInterpreter(new ProfilingATNSimulator(this)); } } else if ( interp instanceof ProfilingATNSimulator ) { ParserATNSimulator sim = new ParserATNSimulator(this, getATN(), interp.decisionToDFA, interp.getSharedContextCache()); setInterpreter(sim); } getInterpreter().setPredictionMode(saveMode); }
protected IntervalSet getErrorRecoverySet(Parser recognizer) { ATN atn = recognizer.getInterpreter().atn; RuleContext ctx = recognizer._ctx; IntervalSet recoverSet = new IntervalSet(); while ( ctx!=null && ctx.invokingState>=0 ) { // compute what follows who invoked us ATNState invokingState = atn.states.get(ctx.invokingState); RuleTransition rt = (RuleTransition)invokingState.transition(0); IntervalSet follow = atn.nextTokens(rt.followState); recoverSet.addAll(follow); ctx = ctx.parent; } recoverSet.remove(Token.EPSILON); // System.out.println("recover set "+recoverSet.toString(recognizer.getTokenNames())); return recoverSet; }
public FailedPredicateException(Parser recognizer, String predicate, String message) { super(formatMessage(predicate, message), recognizer, recognizer.getInputStream(), recognizer._ctx); ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState()); AbstractPredicateTransition trans = (AbstractPredicateTransition)s.transition(0); if (trans instanceof PredicateTransition) { this.ruleIndex = ((PredicateTransition)trans).ruleIndex; this.predicateIndex = ((PredicateTransition)trans).predIndex; } else { this.ruleIndex = 0; this.predicateIndex = 0; } this.predicate = predicate; this.setOffendingToken(recognizer.getCurrentToken()); }
ATN atn = getInterpreter().atn; ParserRuleContext ctx = _ctx; ATNState s = atn.states.get(getState());
/** reset the parser's state */ public void reset() { if ( getInputStream()!=null ) getInputStream().seek(0); _errHandler.reset(this); _ctx = null; _syntaxErrors = 0; matchedEOF = false; setTrace(false); _precedenceStack.clear(); _precedenceStack.push(0); ATNSimulator interpreter = getInterpreter(); if (interpreter != null) { interpreter.reset(); } }
public ProfilingATNSimulator(Parser parser) { super(parser, parser.getInterpreter().atn, parser.getInterpreter().decisionToDFA, parser.getInterpreter().sharedContextCache); numDecisions = atn.decisionToState.size(); decisions = new DecisionInfo[numDecisions]; for (int i=0; i<numDecisions; i++) { decisions[i] = new DecisionInfo(i); } }
public ProfilingATNSimulator(Parser parser) { super(parser, parser.getInterpreter().atn, parser.getInterpreter().decisionToDFA, parser.getInterpreter().sharedContextCache); numDecisions = atn.decisionToState.size(); decisions = new DecisionInfo[numDecisions]; for (int i=0; i<numDecisions; i++) { decisions[i] = new DecisionInfo(i); } }
ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState());
@Override public ParseInfo getParseInfo() { ParserATNSimulator interp = getInterpreter(); if (interp instanceof ProfilingATNSimulator) { return new ParseInfo((ProfilingATNSimulator)interp); } return null; }
@Override public ParseInfo getParseInfo() { ParserATNSimulator interp = getInterpreter(); if (interp instanceof ProfilingATNSimulator) { return new ParseInfo((ProfilingATNSimulator)interp); } return null; }
@Override public ParseInfo getParseInfo() { ParserATNSimulator interp = getInterpreter(); if (interp instanceof ProfilingATNSimulator) { return new ParseInfo((ProfilingATNSimulator)interp); } return null; }
public ProfilingATNSimulator(Parser parser) { super(parser, parser.getInterpreter().atn); optimize_ll1 = false; reportAmbiguities = true; numDecisions = atn.decisionToState.size(); decisions = new DecisionInfo[numDecisions]; for (int i=0; i<numDecisions; i++) { decisions[i] = new DecisionInfo(i); } }
/** Get all file contents into input doc list */ public static List<InputDocument> load(List<String> fileNames, LangDescriptor language) throws Exception { List<InputDocument> documents = new ArrayList<>(); for (String fileName : fileNames) { documents.add( parse(fileName, language) ); } if ( documents.size()>0 ) { documents.get(0).parser.getInterpreter().clearDFA(); // free up memory } return documents; }
public IntervalSet getExpectedTokensWithinCurrentRule() { ATN atn = getInterpreter().atn; ATNState s = atn.states.get(getState()); return atn.nextTokens(s); }
public IntervalSet getExpectedTokensWithinCurrentRule() { ATN atn = getInterpreter().atn; ATNState s = atn.states.get(getState()); return atn.nextTokens(s); }