org.antlr.v4.runtime.Parser.getInterpreter()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中org.antlr.v4.runtime.Parser.getInterpreter()方法的一些代码示例,展示了Parser.getInterpreter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getInterpreter()方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:getInterpreter

Parser.getInterpreter介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-shardingsphere

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())) {

代码示例来源:origin: org.antlr/antlr4-runtime

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);
  }
}

代码示例来源:origin: org.antlr/antlr4-runtime

@Override
public ParseInfo getParseInfo() {
  ParserATNSimulator interp = getInterpreter();
  if (interp instanceof ProfilingATNSimulator) {
    return new ParseInfo((ProfilingATNSimulator)interp);
  }
  return null;
}

代码示例来源:origin: org.antlr/antlr4-runtime

public IntervalSet getExpectedTokensWithinCurrentRule() {
  ATN atn = getInterpreter().atn;
  ATNState s = atn.states.get(getState());
    return atn.nextTokens(s);
  }

代码示例来源:origin: org.antlr/antlr4-runtime

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);

代码示例来源:origin: org.antlr/antlr4-runtime

/**
 * @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);
}

代码示例来源:origin: org.antlr/antlr4-runtime

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;
  }

代码示例来源:origin: org.antlr/antlr4-runtime

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());
}

代码示例来源:origin: org.antlr/antlr4-runtime

ATN atn = getInterpreter().atn;
ParserRuleContext ctx = _ctx;
ATNState s = atn.states.get(getState());

代码示例来源:origin: org.antlr/antlr4-runtime

/** 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();
  }
}

代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime

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);
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

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);
  }
}

代码示例来源:origin: org.antlr/antlr4-runtime

ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState());

代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime

@Override
public ParseInfo getParseInfo() {
  ParserATNSimulator interp = getInterpreter();
  if (interp instanceof ProfilingATNSimulator) {
    return new ParseInfo((ProfilingATNSimulator)interp);
  }
  return null;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public ParseInfo getParseInfo() {
  ParserATNSimulator interp = getInterpreter();
  if (interp instanceof ProfilingATNSimulator) {
    return new ParseInfo((ProfilingATNSimulator)interp);
  }
  return null;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

@Override
public ParseInfo getParseInfo() {
  ParserATNSimulator interp = getInterpreter();
  if (interp instanceof ProfilingATNSimulator) {
    return new ParseInfo((ProfilingATNSimulator)interp);
  }
  return null;
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime

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);
  }
}

代码示例来源:origin: antlr/codebuff

/** 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;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public IntervalSet getExpectedTokensWithinCurrentRule() {
  ATN atn = getInterpreter().atn;
  ATNState s = atn.states.get(getState());
    return atn.nextTokens(s);
  }

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

public IntervalSet getExpectedTokensWithinCurrentRule() {
  ATN atn = getInterpreter().atn;
  ATNState s = atn.states.get(getState());
    return atn.nextTokens(s);
  }

相关文章