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

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

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

Parser.getATN介绍

[英]The ATN with bypass alternatives is expensive to create so we create it lazily.
[中]带有旁路替代方案的ATN创建成本很高,所以我们懒散地创建它。

代码示例

代码示例来源:origin: prestodb/presto

Parser parser = (Parser) recognizer;
ATN atn = parser.getATN();

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

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())) {
  nextTokensContext = null;

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

/**
 * @deprecated Use
 * {@link #enterRecursionRule(ParserRuleContext, int, int, int)} instead.
 */
@Deprecated
public void enterRecursionRule(ParserRuleContext localctx, int ruleIndex) {
  enterRecursionRule(localctx, getATN().ruleToStartState[ruleIndex].stateNumber, ruleIndex, 0);
}

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

/**
 * Computes the set of input symbols which could follow the current parser
 * state and context, as given by {@link #getState} and {@link #getContext},
 * respectively.
 *
 * @see ATN#getExpectedTokens(int, RuleContext)
 */
public IntervalSet getExpectedTokens() {
  return getATN().getExpectedTokens(getState(), getContext());
}

代码示例来源: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: com.tunnelvisionlabs/antlr4-runtime

/**
 * @deprecated Use
 * {@link #enterRecursionRule(ParserRuleContext, int, int, int)} instead.
 */
@Deprecated
public void enterRecursionRule(ParserRuleContext localctx, int ruleIndex) {
  enterRecursionRule(localctx, getATN().ruleToStartState[ruleIndex].stateNumber, ruleIndex, 0);
}

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

IntervalSet nextTokens = recognizer.getATN().nextTokens(s);
if (nextTokens.contains(la)) {

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

/**
 * @deprecated Use
 * {@link #enterRecursionRule(ParserRuleContext, int, int, int)} instead.
 */
@Deprecated
public void enterRecursionRule(ParserRuleContext localctx, int ruleIndex) {
  enterRecursionRule(localctx, getATN().ruleToStartState[ruleIndex].stateNumber, ruleIndex, 0);
}

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

/**
 * @deprecated Use
 * {@link #enterRecursionRule(ParserRuleContext, int, int, int)} instead.
 */
@Deprecated
public void enterRecursionRule(ParserRuleContext localctx, int ruleIndex) {
  enterRecursionRule(localctx, getATN().ruleToStartState[ruleIndex].stateNumber, ruleIndex, 0);
}

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

/**
 * @deprecated Use
 * {@link #enterRecursionRule(ParserRuleContext, int, int, int)} instead.
 */
@Deprecated
public void enterRecursionRule(ParserRuleContext localctx, int ruleIndex) {
  enterRecursionRule(localctx, getATN().ruleToStartState[ruleIndex].stateNumber, ruleIndex, 0);
}

代码示例来源:origin: antlr/intellij-plugin-v4

public static String getSemanticContextDisplayString(PredicateEvalInfo pred,
                           PreviewState previewState,
                           SemanticContext semctx,
                           int alt,
                           boolean result) {
  Grammar g = previewState.g;
  String semanticContextDisplayString = g.getSemanticContextDisplayString(semctx);
  if ( semctx instanceof SemanticContext.PrecedencePredicate ) {
    int ruleIndex = previewState.parsingResult.parser.getATN().decisionToState.get(pred.decision).ruleIndex;
    Rule rule = g.getRule(ruleIndex);
    int precedence = ((SemanticContext.PrecedencePredicate) semctx).precedence;
    // precedence = n - originalAlt + 1, So:
    int originalAlt = rule.getOriginalNumberOfAlts()-precedence+1;
    alt = originalAlt;
  }
  return semanticContextDisplayString+" => alt "+alt+" is "+result;
}

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

/**
 * Computes the set of input symbols which could follow the current parser
 * state and context, as given by {@link #getState} and {@link #getContext},
 * respectively.
 *
 * @see ATN#getExpectedTokens(int, RuleContext)
 */
public IntervalSet getExpectedTokens() {
  return getATN().getExpectedTokens(getState(), getContext());
}

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

/**
 * Computes the set of input symbols which could follow the current parser
 * state and context, as given by {@link #getState} and {@link #getContext},
 * respectively.
 *
 * @see ATN#getExpectedTokens(int, RuleContext)
 */
public IntervalSet getExpectedTokens() {
  return getATN().getExpectedTokens(getState(), getContext());
}

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

/**
 * Computes the set of input symbols which could follow the current parser
 * state and context, as given by {@link #getState} and {@link #getContext},
 * respectively.
 *
 * @see ATN#getExpectedTokens(int, RuleContext)
 */
public IntervalSet getExpectedTokens() {
  return getATN().getExpectedTokens(getState(), getContext());
}

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

/**
 * @since 4.3
 */
public void setProfile(boolean profile) {
  ParserATNSimulator interp = getInterpreter();
  if ( profile ) {
    if (!(interp instanceof ProfilingATNSimulator)) {
      setInterpreter(new ProfilingATNSimulator(this));
    }
  }
  else if (interp instanceof ProfilingATNSimulator) {
    setInterpreter(new ParserATNSimulator(this, getATN(), interp.decisionToDFA, interp.getSharedContextCache()));
  }
}

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

/**
 * Computes the set of input symbols which could follow the current parser
 * state and context, as given by {@link #getState} and {@link #getContext},
 * respectively.
 *
 * @see ATN#getExpectedTokens(int, RuleContext)
 */
@NotNull
public IntervalSet getExpectedTokens() {
  return getATN().getExpectedTokens(getState(), getContext());
}

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

try {
  Constructor<? extends ParserInterpreter> ctor = c.getConstructor(Grammar.class, ATN.class, TokenStream.class);
  parser = ctor.newInstance(g, originalParser.getATN(), originalParser.getTokenStream());
char[] serializedAtn = ATNSerializer.getSerializedAsChars(originalParser.getATN());
ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
parser = new ParserInterpreter(originalParser.getGrammarFileName(),

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

/**
 * @since 4.3
 */
public void setProfile(boolean profile) {
  ParserATNSimulator interp = getInterpreter();
  if ( profile ) {
    if (!(interp instanceof ProfilingATNSimulator)) {
      setInterpreter(new ProfilingATNSimulator(this));
    }
  }
  else if (interp instanceof ProfilingATNSimulator) {
    setInterpreter(new ParserATNSimulator(this, getATN()));
  }
  getInterpreter().setPredictionMode(interp.getPredictionMode());
}

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

/**
 * @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: uk.co.nichesolutions/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);
}

相关文章