当前位置: 首页>>代码示例>>Java>>正文


Java Parser.getInterpreter方法代码示例

本文整理汇总了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]++;
    }
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:15,代码来源:StatisticsParserErrorListener.java

示例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]++;
    }
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:9,代码来源:StatisticsParserErrorListener.java

示例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);
	}
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:12,代码来源:ProfilingATNSimulator.java

示例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.");
    }
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:54,代码来源:GoParserFactory.java


注:本文中的org.antlr.v4.runtime.Parser.getInterpreter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。