本文整理汇总了Java中org.antlr.v4.runtime.Parser.getInterpreter方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.getInterpreter方法的具体用法?Java Parser.getInterpreter怎么用?Java Parser.getInterpreter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.Parser
的用法示例。
在下文中一共展示了Parser.getInterpreter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportAmbiguity
import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@Override
public void reportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs) {
BitSet sllPredictions = getConflictingAlts(_sllConflict, _sllConfigs);
int sllPrediction = sllPredictions.nextSetBit(0);
BitSet llPredictions = getConflictingAlts(ambigAlts, configs);
int llPrediction = llPredictions.cardinality() == 0 ? ATN.INVALID_ALT_NUMBER : llPredictions.nextSetBit(0);
if (recognizer.getInterpreter() instanceof StatisticsParserATNSimulator) {
if (sllPrediction != llPrediction) {
((StatisticsParserATNSimulator)recognizer.getInterpreter()).nonSll[dfa.decision]++;
}
((StatisticsParserATNSimulator)recognizer.getInterpreter()).ambiguousResult[dfa.decision]++;
}
}
示例2: reportContextSensitivity
import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@Override
public void reportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, SimulatorState acceptState) {
BitSet sllPredictions = getConflictingAlts(_sllConflict, _sllConfigs);
int sllPrediction = sllPredictions.nextSetBit(0);
if (sllPrediction != prediction && recognizer.getInterpreter() instanceof StatisticsParserATNSimulator) {
((StatisticsParserATNSimulator)recognizer.getInterpreter()).nonSll[dfa.decision]++;
}
}
示例3: ProfilingATNSimulator
import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
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);
}
}
示例4: configureParser
import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
protected void configureParser(@NonNull Parser parser, @NonNull ParserConfiguration configuration) {
ParserATNSimulator interpreter = parser.getInterpreter();
// common configuration
interpreter.force_global_context = false;
interpreter.always_try_local_context = true;
interpreter.optimize_tail_calls = true;
parser.setBuildParseTree(true);
parser.removeErrorListeners();
switch (configuration) {
case FASTEST:
interpreter.setPredictionMode(PredictionMode.SLL);
interpreter.tail_call_preserves_sll = false;
interpreter.treat_sllk1_conflict_as_ambiguity = true;
parser.setErrorHandler(new BailErrorStrategy());
break;
case SLL:
throw new UnsupportedOperationException("The tail_call_preserves_sll flag cannot change within a single ATN instance.");
//interpreter.setPredictionMode(PredictionMode.SLL);
//interpreter.tail_call_preserves_sll = true;
//interpreter.treat_sllk1_conflict_as_ambiguity = true;
//parser.setErrorHandler(new BailErrorStrategy<Token>());
//break;
case HYBRID:
interpreter.setPredictionMode(PredictionMode.LL);
interpreter.tail_call_preserves_sll = false;
interpreter.treat_sllk1_conflict_as_ambiguity = true;
parser.setErrorHandler(new BailErrorStrategy());
break;
case HYBRID_SLL:
throw new UnsupportedOperationException("The tail_call_preserves_sll flag cannot change within a single ATN instance.");
//interpreter.setPredictionMode(PredictionMode.LL);
//interpreter.tail_call_preserves_sll = true;
//interpreter.treat_sllk1_conflict_as_ambiguity = true;
//parser.setErrorHandler(new BailErrorStrategy<Token>());
//break;
case PRECISE:
interpreter.setPredictionMode(PredictionMode.LL);
interpreter.tail_call_preserves_sll = false;
interpreter.treat_sllk1_conflict_as_ambiguity = false;
parser.setErrorHandler(new DefaultErrorStrategy());
parser.addErrorListener(DescriptiveErrorListener.INSTANCE);
break;
default:
throw new IllegalArgumentException("Invalid configuration.");
}
}