Search in sources :

Example 21 with ATNConfigSet

use of org.antlr.v4.runtime.atn.ATNConfigSet in project antlr4 by tunnelvisionlabs.

the class LexerATNSimulator method addDFAEdge.

@NotNull
protected DFAState addDFAEdge(@NotNull DFAState from, int t, @NotNull ATNConfigSet q) {
    /* leading to this call, ATNConfigSet.hasSemanticContext is used as a
		 * marker indicating dynamic predicate evaluation makes this edge
		 * dependent on the specific input sequence, so the static edge in the
		 * DFA should be omitted. The target DFAState is still created since
		 * execATN has the ability to resynchronize with the DFA state cache
		 * following the predicate evaluation step.
		 *
		 * TJP notes: next time through the DFA, we see a pred again and eval.
		 * If that gets us to a previously created (but dangling) DFA
		 * state, we can continue in pure DFA mode from there.
		 */
    boolean suppressEdge = q.hasSemanticContext();
    if (suppressEdge) {
        q.clearExplicitSemanticContext();
    }
    @NotNull DFAState to = addDFAState(q);
    if (suppressEdge) {
        return to;
    }
    addDFAEdge(from, t, to);
    return to;
}
Also used : DFAState(org.antlr.v4.runtime.dfa.DFAState) NotNull(org.antlr.v4.runtime.misc.NotNull) NotNull(org.antlr.v4.runtime.misc.NotNull)

Aggregations

DFAState (org.antlr.v4.runtime.dfa.DFAState)13 NotNull (org.antlr.v4.runtime.misc.NotNull)6 BitSet (java.util.BitSet)5 DFA (org.antlr.v4.runtime.dfa.DFA)4 Interval (org.antlr.v4.runtime.misc.Interval)4 ArrayList (java.util.ArrayList)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 NoViableAltException (org.antlr.v4.runtime.NoViableAltException)2 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)2 RecognitionException (org.antlr.v4.runtime.RecognitionException)2 ATNConfigSet (org.antlr.v4.runtime.atn.ATNConfigSet)2 AcceptStateInfo (org.antlr.v4.runtime.dfa.AcceptStateInfo)2 Pair (com.abubusoft.kripton.common.Pair)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ANTLRErrorListener (org.antlr.v4.runtime.ANTLRErrorListener)1 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)1 Parser (org.antlr.v4.runtime.Parser)1 IntegerList (org.antlr.v4.runtime.misc.IntegerList)1 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)1 CommentLineContext (org.springframework.ide.vscode.java.properties.antlr.parser.JavaPropertiesParser.CommentLineContext)1