當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。