當前位置: 首頁>>代碼示例>>Java>>正文


Java DFA類代碼示例

本文整理匯總了Java中org.antlr.v4.runtime.dfa.DFA的典型用法代碼示例。如果您正苦於以下問題:Java DFA類的具體用法?Java DFA怎麽用?Java DFA使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DFA類屬於org.antlr.v4.runtime.dfa包,在下文中一共展示了DFA類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reportAttemptingFullContext

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, SimulatorState conflictState, int startIndex, int stopIndex) {
    super.reportAttemptingFullContext(dfa, conflictingAlts, conflictState, startIndex, stopIndex);
        int k;
        if (startIndex == stopIndex) {
            k = 1;
        } else if (startIndex == stopIndex - 1) {
            k = 2;
        } else {
            k = 0;
            for (int i = startIndex; i <= stopIndex; i++) {
                parser.getInputStream().seek(i);
                if (parser.getInputStream().LT(1).getChannel() == Token.DEFAULT_CHANNEL) {
                    k++;
                }
            }
        }

    fullContextFallback[dfa.decision]++;
    totalLookaheadSll[dfa.decision] += k;
    minLookaheadSll[dfa.decision] = Math.min(minLookaheadSll[dfa.decision], k);
    maxLookaheadSll[dfa.decision] = Math.max(maxLookaheadSll[dfa.decision], k);
}
 
開發者ID:tunnelvisionlabs,項目名稱:goworks,代碼行數:24,代碼來源:StatisticsParserATNSimulator.java

示例2: LexerInterpreter

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
public LexerInterpreter(String grammarFileName, Collection<String> tokenNames, Collection<String> ruleNames, Collection<String> modeNames, ATN atn, CharStream input) {
	super(input);

	if (atn.grammarType != ATNType.LEXER) {
		throw new IllegalArgumentException("The ATN must be a lexer ATN.");
	}

	this.grammarFileName = grammarFileName;
	this.atn = atn;
	this.tokenNames = tokenNames.toArray(new String[tokenNames.size()]);
	this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]);
	this.modeNames = modeNames.toArray(new String[modeNames.size()]);

	this._decisionToDFA = new DFA[atn.getNumberOfDecisions()];
	for (int i = 0; i < _decisionToDFA.length; i++) {
		_decisionToDFA[i] = new DFA(atn.getDecisionState(i), i);
	}
	this._interp = new LexerATNSimulator(this,atn,_decisionToDFA,_sharedContextCache);
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:20,代碼來源:LexerInterpreter.java

示例3: reportAmbiguity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportAmbiguity(@NotNull Parser recognizer,
							@NotNull DFA dfa,
							int startIndex,
							int stopIndex,
							boolean exact,
							@Nullable BitSet ambigAlts,
							@NotNull ATNConfigSet configs)
{
	if (exactOnly && !exact) {
		return;
	}

	String format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'";
	String decision = getDecisionDescription(recognizer, dfa);
	BitSet conflictingAlts = getConflictingAlts(ambigAlts, configs);
	String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
	String message = String.format(format, decision, conflictingAlts, text);
	recognizer.notifyErrorListeners(message);
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:21,代碼來源:DiagnosticErrorListener.java

示例4: getDecisionDescription

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
protected String getDecisionDescription(@NotNull Parser recognizer, @NotNull DFA dfa) {
	int decision = dfa.decision;
	int ruleIndex = dfa.atnStartState.ruleIndex;

	String[] ruleNames = recognizer.getRuleNames();
	if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
		return String.valueOf(decision);
	}

	String ruleName = ruleNames[ruleIndex];
	if (ruleName == null || ruleName.isEmpty()) {
		return String.valueOf(decision);
	}

	return String.format("%d (%s)", decision, ruleName);
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:17,代碼來源:DiagnosticErrorListener.java

示例5: addDFAState

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
/**
 * Add state {@code D} to the DFA if it is not already present, and return
 * the actual instance stored in the DFA. If a state equivalent to {@code D}
 * is already in the DFA, the existing state is returned. Otherwise this
 * method returns {@code D} after adding it to the DFA.
 *
 * <p>If {@code D} is {@link #ERROR}, this method returns {@link #ERROR} and
 * does not change the DFA.</p>
 *
 * @param dfa The dfa
 * @param D The DFA state to add
 * @return The state stored in the DFA. This will be either the existing
 * state if {@code D} is already in the DFA, or {@code D} itself if the
 * state was not already present.
 */
@NotNull
protected DFAState addDFAState(@NotNull DFA dfa, @NotNull DFAState D) {
	if (D == ERROR) {
		return D;
	}

	synchronized (dfa.states) {
		DFAState existing = dfa.states.get(D);
		if ( existing!=null ) return existing;

		D.stateNumber = dfa.states.size();
		if (!D.configs.isReadonly()) {
			D.configs.optimizeConfigs(this);
			D.configs.setReadonly(true);
		}
		dfa.states.put(D, D);
		if ( debug ) System.out.println("adding new DFA state: "+D);
		return D;
	}
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:36,代碼來源:ParserATNSimulator.java

示例6: reportAmbiguity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
protected void reportAmbiguity(@NotNull DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact,
							   @Nullable BitSet ambigAlts, @NotNull ATNConfigSet configs)
{
	int prediction;
	if ( ambigAlts!=null ) {
		prediction = ambigAlts.nextSetBit(0);
	}
	else {
		prediction = configs.getAlts().nextSetBit(0);
	}
	if ( configs.fullCtx && prediction != conflictingAltResolvedBySLL ) {
		// Even though this is an ambiguity we are reporting, we can
		// still detect some context sensitivities.  Both SLL and LL
		// are showing a conflict, hence an ambiguity, but if they resolve
		// to different minimum alternatives we have also identified a
		// context sensitivity.
		decisions[currentDecision].contextSensitivities.add(
				new ContextSensitivityInfo(currentDecision, configs, _input, startIndex, stopIndex)
		);
	}
	decisions[currentDecision].ambiguities.add(
		new AmbiguityInfo(currentDecision, configs, _input, startIndex, stopIndex, configs.fullCtx)
	);
	super.reportAmbiguity(dfa, D, startIndex, stopIndex, exact, ambigAlts, configs);
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:27,代碼來源:ProfilingATNSimulator.java

示例7: match

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
public int match(@NotNull CharStream input, int mode) {
	match_calls++;
	this.mode = mode;
	int mark = input.mark();
	try {
		this.startIndex = input.index();
		this.prevAccept.reset();
		DFA dfa = decisionToDFA[mode];
		if ( dfa.s0==null ) {
			return matchATN(input);
		}
		else {
			return execATN(input, dfa.s0);
		}
	}
	finally {
		input.release(mark);
	}
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:20,代碼來源:LexerATNSimulator.java

示例8: reportAmbiguity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportAmbiguity(@NotNull Parser recognizer,
							@NotNull DFA dfa,
							int startIndex,
							int stopIndex,
							boolean exact,
							@Nullable BitSet ambigAlts,
							@NotNull ATNConfigSet configs)
{
}
 
開發者ID:paypal,項目名稱:digraph-parser,代碼行數:11,代碼來源:GraphParser.java

示例9: reportAttemptingFullContext

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportAttemptingFullContext(@NotNull Parser recognizer,
										@NotNull DFA dfa,
										int startIndex,
										int stopIndex,
										@Nullable BitSet conflictingAlts,
										@NotNull ATNConfigSet configs)
{
}
 
開發者ID:paypal,項目名稱:digraph-parser,代碼行數:10,代碼來源:GraphParser.java

示例10: reportContextSensitivity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportContextSensitivity(@NotNull Parser recognizer,
									 @NotNull DFA dfa,
									 int startIndex,
									 int stopIndex,
									 int prediction,
									 @NotNull ATNConfigSet configs)
{
}
 
開發者ID:paypal,項目名稱:digraph-parser,代碼行數:10,代碼來源:GraphParser.java

示例11: reportAmbiguity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
    public void reportAmbiguity(
            Parser recognizer,
            DFA dfa,
            int startIndex,
            int stopIndex,
            boolean exact,
            BitSet ambigAlts,
            ATNConfigSet configs) {
        hasAmbiguity = true;
        ambiguityCount++;
//        allFields.put("__Ambiguity__",new AgentField("true"));
    }
 
開發者ID:nielsbasjes,項目名稱:yauaa,代碼行數:14,代碼來源:UserAgent.java

示例12: reportAttemptingFullContext

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportAttemptingFullContext(
        Parser recognizer,
        DFA dfa,
        int startIndex,
        int stopIndex,
        BitSet conflictingAlts,
        ATNConfigSet configs) {
}
 
開發者ID:nielsbasjes,項目名稱:yauaa,代碼行數:10,代碼來源:UserAgent.java

示例13: reportContextSensitivity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportContextSensitivity(
        Parser recognizer,
        DFA dfa,
        int startIndex,
        int stopIndex,
        int prediction,
        ATNConfigSet configs) {

}
 
開發者ID:nielsbasjes,項目名稱:yauaa,代碼行數:11,代碼來源:UserAgent.java

示例14: reportAmbiguity

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportAmbiguity(
        Parser recognizer,
        DFA dfa,
        int startIndex,
        int stopIndex,
        boolean exact,
        BitSet ambigAlts,
        ATNConfigSet configs) {
    // Ignore this type of problem
}
 
開發者ID:nielsbasjes,項目名稱:yauaa,代碼行數:12,代碼來源:MatcherAction.java

示例15: reportAttemptingFullContext

import org.antlr.v4.runtime.dfa.DFA; //導入依賴的package包/類
@Override
public void reportAttemptingFullContext(
        Parser recognizer,
        DFA dfa,
        int startIndex,
        int stopIndex,
        BitSet conflictingAlts,
        ATNConfigSet configs) {
    // Ignore this type of problem
}
 
開發者ID:nielsbasjes,項目名稱:yauaa,代碼行數:11,代碼來源:MatcherAction.java


注:本文中的org.antlr.v4.runtime.dfa.DFA類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。