Ejemplo n.º 1
0
        protected internal virtual 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.
             */
            bool suppressEdge = q.HasSemanticContext;

            if (suppressEdge)
            {
                q.ClearExplicitSemanticContext();
            }
            DFAState to = AddDFAState(q);

            if (suppressEdge)
            {
                return(to);
            }
            AddDFAEdge(from, t, to);
            return(to);
        }
Ejemplo n.º 2
0
        protected internal virtual DFAState AddDFAEdge(DFAState from, int t, ATNConfigSet q)
        {
            bool suppressEdge = q.HasSemanticContext;

            if (suppressEdge)
            {
                q.ClearExplicitSemanticContext();
            }
            DFAState to = AddDFAState(q);

            if (suppressEdge)
            {
                return(to);
            }
            AddDFAEdge(from, t, to);
            return(to);
        }
Ejemplo n.º 3
0
        protected internal virtual int MatchATN(ICharStream input)
        {
            ATNState     startState   = atn.modeToStartState[mode];
            ATNConfigSet s0_closure   = ComputeStartState(input, startState);
            bool         suppressEdge = s0_closure.HasSemanticContext;

            if (suppressEdge)
            {
                s0_closure.ClearExplicitSemanticContext();
            }
            DFAState next = AddDFAState(s0_closure);

            if (!suppressEdge)
            {
                if (!atn.modeToDFA[mode].s0.CompareAndSet(null, next))
                {
                    next = atn.modeToDFA[mode].s0.Get();
                }
            }
            int predict = ExecATN(input, next);

            return(predict);
        }