Transform() public method

public Transform ( ATNState state, Antlr4 semanticContext, bool checkNonGreedy ) : Antlr4.Runtime.Atn.ATNConfig
state ATNState
semanticContext Antlr4
checkNonGreedy bool
return Antlr4.Runtime.Atn.ATNConfig
Esempio n. 1
0
        /// <summary>
        /// Since the alternatives within any lexer decision are ordered by
        /// preference, this method stops pursuing the closure as soon as an accept
        /// state is reached.
        /// </summary>
        /// <remarks>
        /// Since the alternatives within any lexer decision are ordered by
        /// preference, this method stops pursuing the closure as soon as an accept
        /// state is reached. After the first accept state is reached by depth-first
        /// search from
        /// <paramref name="config"/>
        /// , all other (potentially reachable) states for
        /// this rule would have a lower priority.
        /// </remarks>
        /// <returns>
        ///
        /// <see langword="true"/>
        /// if an accept state is reached, otherwise
        /// <see langword="false"/>
        /// .
        /// </returns>
        protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet configs, bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon)
        {
            if (config.State is RuleStopState)
            {
                PredictionContext context = config.Context;
                if (context.IsEmpty)
                {
                    configs.Add(config);
                    return(true);
                }
                else
                {
                    if (context.HasEmpty)
                    {
                        configs.Add(config.Transform(config.State, PredictionContext.EmptyFull, true));
                        currentAltReachedAcceptState = true;
                    }
                }
                for (int i = 0; i < context.Size; i++)
                {
                    int returnStateNumber = context.GetReturnState(i);
                    if (returnStateNumber == PredictionContext.EmptyFullStateKey)
                    {
                        continue;
                    }
                    PredictionContext newContext = context.GetParent(i);
                    // "pop" return state
                    ATNState  returnState = atn.states[returnStateNumber];
                    ATNConfig c           = config.Transform(returnState, newContext, false);
                    currentAltReachedAcceptState = Closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
                }
                return(currentAltReachedAcceptState);
            }
            // optimization
            if (!config.State.OnlyHasEpsilonTransitions)
            {
                if (!currentAltReachedAcceptState || !config.PassedThroughNonGreedyDecision)
                {
                    configs.Add(config);
                }
            }
            ATNState p = config.State;

            for (int i_1 = 0; i_1 < p.NumberOfOptimizedTransitions; i_1++)
            {
                Transition t = p.GetOptimizedTransition(i_1);
                ATNConfig  c = GetEpsilonTarget(input, config, t, configs, speculative, treatEofAsEpsilon);
                if (c != null)
                {
                    currentAltReachedAcceptState = Closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
                }
            }
            return(currentAltReachedAcceptState);
        }
Esempio n. 2
0
        /// <summary>
        /// Since the alternatives within any lexer decision are ordered by
        /// preference, this method stops pursuing the closure as soon as an accept
        /// state is reached.
        /// </summary>
        /// <remarks>
        /// Since the alternatives within any lexer decision are ordered by
        /// preference, this method stops pursuing the closure as soon as an accept
        /// state is reached. After the first accept state is reached by depth-first
        /// search from
        /// <code>config</code>
        /// , all other (potentially reachable) states for
        /// this rule would have a lower priority.
        /// </remarks>
        /// <returns>
        ///
        /// <code>true</code>
        /// if an accept state is reached, otherwise
        /// <code>false</code>
        /// .
        /// </returns>
        protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet
                                                configs, bool speculative)
        {
            if (config.State is RuleStopState)
            {
                PredictionContext context = config.Context;
                if (context.IsEmpty)
                {
                    configs.AddItem(config);
                    return(true);
                }
                else
                {
                    if (context.HasEmpty)
                    {
                        configs.AddItem(config.Transform(config.State, PredictionContext.EmptyFull));
                        return(true);
                    }
                }
                for (int i = 0; i < context.Size; i++)
                {
                    int returnStateNumber = context.GetReturnState(i);
                    if (returnStateNumber == PredictionContext.EmptyFullStateKey)
                    {
                        continue;
                    }
                    PredictionContext newContext = context.GetParent(i);
                    // "pop" return state
                    ATNState  returnState = atn.states[returnStateNumber];
                    ATNConfig c           = ATNConfig.Create(returnState, config.Alt, newContext);
                    if (Closure(input, c, configs, speculative))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            // optimization
            if (!config.State.OnlyHasEpsilonTransitions)
            {
                configs.AddItem(config);
            }
            ATNState p = config.State;

            for (int i_1 = 0; i_1 < p.NumberOfOptimizedTransitions; i_1++)
            {
                Transition t = p.GetOptimizedTransition(i_1);
                ATNConfig  c = GetEpsilonTarget(input, config, t, configs, speculative);
                if (c != null)
                {
                    if (Closure(input, c, configs, speculative))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConfig config, Transition t, ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon)
        {
            ATNConfig c;

            switch (t.TransitionType)
            {
            case TransitionType.Rule:
            {
                RuleTransition ruleTransition = (RuleTransition)t;
                if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
                {
                    c = config.Transform(t.target, true);
                }
                else
                {
                    PredictionContext newContext = config.Context.GetChild(ruleTransition.followState.stateNumber);
                    c = config.Transform(t.target, newContext, true);
                }
                break;
            }

            case TransitionType.Precedence:
            {
                throw new NotSupportedException("Precedence predicates are not supported in lexers.");
            }

            case TransitionType.Predicate:
            {
                PredicateTransition pt = (PredicateTransition)t;
                configs.MarkExplicitSemanticContext();
                if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
                {
                    c = config.Transform(t.target, true);
                }
                else
                {
                    c = null;
                }
                break;
            }

            case TransitionType.Action:
            {
                if (config.Context.HasEmpty)
                {
                    // execute actions anywhere in the start rule for a token.
                    //
                    // TODO: if the entry rule is invoked recursively, some
                    // actions may be executed during the recursive call. The
                    // problem can appear when hasEmpty() is true but
                    // isEmpty() is false. In this case, the config needs to be
                    // split into two contexts - one with just the empty path
                    // and another with everything but the empty path.
                    // Unfortunately, the current algorithm does not allow
                    // getEpsilonTarget to return two configurations, so
                    // additional modifications are needed before we can support
                    // the split operation.
                    LexerActionExecutor lexerActionExecutor = LexerActionExecutor.Append(config.ActionExecutor, atn.lexerActions[((ActionTransition)t).actionIndex]);
                    c = config.Transform(t.target, lexerActionExecutor, true);
                    break;
                }
                else
                {
                    // ignore actions in referenced rules
                    c = config.Transform(t.target, true);
                    break;
                }
            }

            case TransitionType.Epsilon:
            {
                c = config.Transform(t.target, true);
                break;
            }

            case TransitionType.Atom:
            case TransitionType.Range:
            case TransitionType.Set:
            {
                if (treatEofAsEpsilon)
                {
                    if (t.Matches(IntStreamConstants.Eof, char.MinValue, char.MaxValue))
                    {
                        c = config.Transform(t.target, false);
                        break;
                    }
                }
                c = null;
                break;
            }

            default:
            {
                c = null;
                break;
            }
            }
            return(c);
        }
Esempio n. 4
0
        protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConfig
             config, Transition t, ATNConfigSet configs, bool speculative)
        {
            ATNConfig c;
            switch (t.TransitionType)
            {
                case TransitionType.Rule:
                {
                    RuleTransition ruleTransition = (RuleTransition)t;
                    if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
                    {
                        c = config.Transform(t.target);
                    }
                    else
                    {
                        PredictionContext newContext = config.Context.GetChild(ruleTransition.followState
                            .stateNumber);
                        c = config.Transform(t.target, newContext);
                    }
                    break;
                }

                case TransitionType.Precedence:
                {
                    throw new NotSupportedException("Precedence predicates are not supported in lexers."
                        );
                }

                case TransitionType.Predicate:
                {
                    PredicateTransition pt = (PredicateTransition)t;
                    configs.MarkExplicitSemanticContext();
                    if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
                    {
                        c = config.Transform(t.target);
                    }
                    else
                    {
                        c = null;
                    }
                    break;
                }

                case TransitionType.Action:
                {
                    // ignore actions; just exec one per rule upon accept
                    c = config.Transform(t.target, ((ActionTransition)t).actionIndex);
                    break;
                }

                case TransitionType.Epsilon:
                {
                    c = config.Transform(t.target);
                    break;
                }

                default:
                {
                    c = null;
                    break;
                }
            }
            return c;
        }
Esempio n. 5
0
 /// <summary>
 /// Since the alternatives within any lexer decision are ordered by
 /// preference, this method stops pursuing the closure as soon as an accept
 /// state is reached.
 /// </summary>
 /// <remarks>
 /// Since the alternatives within any lexer decision are ordered by
 /// preference, this method stops pursuing the closure as soon as an accept
 /// state is reached. After the first accept state is reached by depth-first
 /// search from
 /// <code>config</code>
 /// , all other (potentially reachable) states for
 /// this rule would have a lower priority.
 /// </remarks>
 /// <returns>
 /// 
 /// <code>true</code>
 /// if an accept state is reached, otherwise
 /// <code>false</code>
 /// .
 /// </returns>
 protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet
      configs, bool speculative)
 {
     if (config.State is RuleStopState)
     {
         PredictionContext context = config.Context;
         if (context.IsEmpty)
         {
             configs.AddItem(config);
             return true;
         }
         else
         {
             if (context.HasEmpty)
             {
                 configs.AddItem(config.Transform(config.State, PredictionContext.EmptyFull));
                 return true;
             }
         }
         for (int i = 0; i < context.Size; i++)
         {
             int returnStateNumber = context.GetReturnState(i);
             if (returnStateNumber == PredictionContext.EmptyFullStateKey)
             {
                 continue;
             }
             PredictionContext newContext = context.GetParent(i);
             // "pop" return state
             ATNState returnState = atn.states[returnStateNumber];
             ATNConfig c = ATNConfig.Create(returnState, config.Alt, newContext);
             if (Closure(input, c, configs, speculative))
             {
                 return true;
             }
         }
         return false;
     }
     // optimization
     if (!config.State.OnlyHasEpsilonTransitions)
     {
         configs.AddItem(config);
     }
     ATNState p = config.State;
     for (int i_1 = 0; i_1 < p.NumberOfOptimizedTransitions; i_1++)
     {
         Transition t = p.GetOptimizedTransition(i_1);
         ATNConfig c = GetEpsilonTarget(input, config, t, configs, speculative);
         if (c != null)
         {
             if (Closure(input, c, configs, speculative))
             {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 6
0
        protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConfig config, Transition t, ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon)
        {
            ATNConfig c;
            switch (t.TransitionType)
            {
                case TransitionType.Rule:
                {
                    RuleTransition ruleTransition = (RuleTransition)t;
                    if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
                    {
                        c = config.Transform(t.target, true);
                    }
                    else
                    {
                        PredictionContext newContext = config.Context.GetChild(ruleTransition.followState.stateNumber);
                        c = config.Transform(t.target, newContext, true);
                    }
                    break;
                }

                case TransitionType.Precedence:
                {
                    throw new NotSupportedException("Precedence predicates are not supported in lexers.");
                }

                case TransitionType.Predicate:
                {
                    /*  Track traversing semantic predicates. If we traverse,
                    we cannot add a DFA state for this "reach" computation
                    because the DFA would not test the predicate again in the
                    future. Rather than creating collections of semantic predicates
                    like v3 and testing them on prediction, v4 will test them on the
                    fly all the time using the ATN not the DFA. This is slower but
                    semantically it's not used that often. One of the key elements to
                    this predicate mechanism is not adding DFA states that see
                    predicates immediately afterwards in the ATN. For example,
                    
                    a : ID {p1}? | ID {p2}? ;
                    
                    should create the start state for rule 'a' (to save start state
                    competition), but should not create target of ID state. The
                    collection of ATN states the following ID references includes
                    states reached by traversing predicates. Since this is when we
                    test them, we cannot cash the DFA state target of ID.
                    */
                    PredicateTransition pt = (PredicateTransition)t;
                    configs.MarkExplicitSemanticContext();
                    if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
                    {
                        c = config.Transform(t.target, true);
                    }
                    else
                    {
                        c = null;
                    }
                    break;
                }

                case TransitionType.Action:
                {
                    if (config.Context.HasEmpty)
                    {
                        // execute actions anywhere in the start rule for a token.
                        //
                        // TODO: if the entry rule is invoked recursively, some
                        // actions may be executed during the recursive call. The
                        // problem can appear when hasEmpty() is true but
                        // isEmpty() is false. In this case, the config needs to be
                        // split into two contexts - one with just the empty path
                        // and another with everything but the empty path.
                        // Unfortunately, the current algorithm does not allow
                        // getEpsilonTarget to return two configurations, so
                        // additional modifications are needed before we can support
                        // the split operation.
                        LexerActionExecutor lexerActionExecutor = LexerActionExecutor.Append(config.ActionExecutor, atn.lexerActions[((ActionTransition)t).actionIndex]);
                        c = config.Transform(t.target, lexerActionExecutor, true);
                        break;
                    }
                    else
                    {
                        // ignore actions in referenced rules
                        c = config.Transform(t.target, true);
                        break;
                    }
                }

                case TransitionType.Epsilon:
                {
                    c = config.Transform(t.target, true);
                    break;
                }

                case TransitionType.Atom:
                case TransitionType.Range:
                case TransitionType.Set:
                {
                    if (treatEofAsEpsilon)
                    {
                        if (t.Matches(IntStreamConstants.Eof, char.MinValue, char.MaxValue))
                        {
                            c = config.Transform(t.target, false);
                            break;
                        }
                    }
                    c = null;
                    break;
                }

                default:
                {
                    c = null;
                    break;
                }
            }
            return c;
        }
Esempio n. 7
0
 /// <summary>
 /// Since the alternatives within any lexer decision are ordered by
 /// preference, this method stops pursuing the closure as soon as an accept
 /// state is reached.
 /// </summary>
 /// <remarks>
 /// Since the alternatives within any lexer decision are ordered by
 /// preference, this method stops pursuing the closure as soon as an accept
 /// state is reached. After the first accept state is reached by depth-first
 /// search from
 /// <paramref name="config"/>
 /// , all other (potentially reachable) states for
 /// this rule would have a lower priority.
 /// </remarks>
 /// <returns>
 /// 
 /// <see langword="true"/>
 /// if an accept state is reached, otherwise
 /// <see langword="false"/>
 /// .
 /// </returns>
 protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet configs, bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon)
 {
     if (config.State is RuleStopState)
     {
         PredictionContext context = config.Context;
         if (context.IsEmpty)
         {
             configs.Add(config);
             return true;
         }
         else
         {
             if (context.HasEmpty)
             {
                 configs.Add(config.Transform(config.State, PredictionContext.EmptyFull, true));
                 currentAltReachedAcceptState = true;
             }
         }
         for (int i = 0; i < context.Size; i++)
         {
             int returnStateNumber = context.GetReturnState(i);
             if (returnStateNumber == PredictionContext.EmptyFullStateKey)
             {
                 continue;
             }
             PredictionContext newContext = context.GetParent(i);
             // "pop" return state
             ATNState returnState = atn.states[returnStateNumber];
             ATNConfig c = config.Transform(returnState, newContext, false);
             currentAltReachedAcceptState = Closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
         }
         return currentAltReachedAcceptState;
     }
     // optimization
     if (!config.State.OnlyHasEpsilonTransitions)
     {
         if (!currentAltReachedAcceptState || !config.PassedThroughNonGreedyDecision)
         {
             configs.Add(config);
         }
     }
     ATNState p = config.State;
     for (int i_1 = 0; i_1 < p.NumberOfOptimizedTransitions; i_1++)
     {
         Transition t = p.GetOptimizedTransition(i_1);
         ATNConfig c = GetEpsilonTarget(input, config, t, configs, speculative, treatEofAsEpsilon);
         if (c != null)
         {
             currentAltReachedAcceptState = Closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
         }
     }
     return currentAltReachedAcceptState;
 }
Esempio n. 8
0
        protected internal virtual ATNConfig GetEpsilonTarget([NotNull] ICharStream input, [NotNull] ATNConfig config, [NotNull] Transition t, [NotNull] ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon)
        {
            ATNConfig c;

            switch (t.TransitionType)
            {
            case TransitionType.Rule:
            {
                RuleTransition ruleTransition = (RuleTransition)t;
                if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
                {
                    c = config.Transform(t.target, true);
                }
                else
                {
                    PredictionContext newContext = config.Context.GetChild(ruleTransition.followState.stateNumber);
                    c = config.Transform(t.target, newContext, true);
                }
                break;
            }

            case TransitionType.Precedence:
            {
                throw new NotSupportedException("Precedence predicates are not supported in lexers.");
            }

            case TransitionType.Predicate:
            {
                /*  Track traversing semantic predicates. If we traverse,
                 *  we cannot add a DFA state for this "reach" computation
                 *      because the DFA would not test the predicate again in the
                 *      future. Rather than creating collections of semantic predicates
                 *      like v3 and testing them on prediction, v4 will test them on the
                 *      fly all the time using the ATN not the DFA. This is slower but
                 *      semantically it's not used that often. One of the key elements to
                 *      this predicate mechanism is not adding DFA states that see
                 *      predicates immediately afterwards in the ATN. For example,
                 *
                 *      a : ID {p1}? | ID {p2}? ;
                 *
                 *      should create the start state for rule 'a' (to save start state
                 *      competition), but should not create target of ID state. The
                 *      collection of ATN states the following ID references includes
                 *      states reached by traversing predicates. Since this is when we
                 *      test them, we cannot cash the DFA state target of ID.
                 */
                PredicateTransition pt = (PredicateTransition)t;
                configs.MarkExplicitSemanticContext();
                if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
                {
                    c = config.Transform(t.target, true);
                }
                else
                {
                    c = null;
                }
                break;
            }

            case TransitionType.Action:
            {
                if (config.Context.HasEmpty)
                {
                    // execute actions anywhere in the start rule for a token.
                    //
                    // TODO: if the entry rule is invoked recursively, some
                    // actions may be executed during the recursive call. The
                    // problem can appear when hasEmpty() is true but
                    // isEmpty() is false. In this case, the config needs to be
                    // split into two contexts - one with just the empty path
                    // and another with everything but the empty path.
                    // Unfortunately, the current algorithm does not allow
                    // getEpsilonTarget to return two configurations, so
                    // additional modifications are needed before we can support
                    // the split operation.
                    LexerActionExecutor lexerActionExecutor = LexerActionExecutor.Append(config.ActionExecutor, atn.lexerActions[((ActionTransition)t).actionIndex]);
                    c = config.Transform(t.target, lexerActionExecutor, true);
                    break;
                }
                else
                {
                    // ignore actions in referenced rules
                    c = config.Transform(t.target, true);
                    break;
                }
            }

            case TransitionType.Epsilon:
            {
                c = config.Transform(t.target, true);
                break;
            }

            case TransitionType.Atom:
            case TransitionType.Range:
            case TransitionType.Set:
            {
                if (treatEofAsEpsilon)
                {
                    if (t.Matches(IntStreamConstants.Eof, char.MinValue, char.MaxValue))
                    {
                        c = config.Transform(t.target, false);
                        break;
                    }
                }
                c = null;
                break;
            }

            default:
            {
                c = null;
                break;
            }
            }
            return(c);
        }
Esempio n. 9
0
        protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConfig config, Transition t, ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon)
        {
            ATNConfig c;
            switch (t.TransitionType)
            {
                case TransitionType.Rule:
                {
                    RuleTransition ruleTransition = (RuleTransition)t;
                    if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
                    {
                        c = config.Transform(t.target, true);
                    }
                    else
                    {
                        PredictionContext newContext = config.Context.GetChild(ruleTransition.followState.stateNumber);
                        c = config.Transform(t.target, newContext, true);
                    }
                    break;
                }

                case TransitionType.Precedence:
                {
                    throw new NotSupportedException("Precedence predicates are not supported in lexers.");
                }

                case TransitionType.Predicate:
                {
                    PredicateTransition pt = (PredicateTransition)t;
                    configs.MarkExplicitSemanticContext();
                    if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
                    {
                        c = config.Transform(t.target, true);
                    }
                    else
                    {
                        c = null;
                    }
                    break;
                }

                case TransitionType.Action:
                {
                    if (config.Context.HasEmpty)
                    {
                        // execute actions anywhere in the start rule for a token.
                        //
                        // TODO: if the entry rule is invoked recursively, some
                        // actions may be executed during the recursive call. The
                        // problem can appear when hasEmpty() is true but
                        // isEmpty() is false. In this case, the config needs to be
                        // split into two contexts - one with just the empty path
                        // and another with everything but the empty path.
                        // Unfortunately, the current algorithm does not allow
                        // getEpsilonTarget to return two configurations, so
                        // additional modifications are needed before we can support
                        // the split operation.
                        LexerActionExecutor lexerActionExecutor = LexerActionExecutor.Append(config.ActionExecutor, atn.lexerActions[((ActionTransition)t).actionIndex]);
                        c = config.Transform(t.target, lexerActionExecutor, true);
                        break;
                    }
                    else
                    {
                        // ignore actions in referenced rules
                        c = config.Transform(t.target, true);
                        break;
                    }
                }

                case TransitionType.Epsilon:
                {
                    c = config.Transform(t.target, true);
                    break;
                }

                case TransitionType.Atom:
                case TransitionType.Range:
                case TransitionType.Set:
                {
                    if (treatEofAsEpsilon)
                    {
                        if (t.Matches(IntStreamConstants.Eof, char.MinValue, char.MaxValue))
                        {
                            c = config.Transform(t.target, false);
                            break;
                        }
                    }
                    c = null;
                    break;
                }

                default:
                {
                    c = null;
                    break;
                }
            }
            return c;
        }
Esempio n. 10
0
        protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConfig
                                                              config, Transition t, ATNConfigSet configs, bool speculative)
        {
            ATNConfig c;

            switch (t.TransitionType)
            {
            case TransitionType.Rule:
            {
                RuleTransition ruleTransition = (RuleTransition)t;
                if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
                {
                    c = config.Transform(t.target);
                }
                else
                {
                    PredictionContext newContext = config.Context.GetChild(ruleTransition.followState
                                                                           .stateNumber);
                    c = config.Transform(t.target, newContext);
                }
                break;
            }

            case TransitionType.Precedence:
            {
                throw new NotSupportedException("Precedence predicates are not supported in lexers."
                                                );
            }

            case TransitionType.Predicate:
            {
                PredicateTransition pt = (PredicateTransition)t;
                configs.MarkExplicitSemanticContext();
                if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
                {
                    c = config.Transform(t.target);
                }
                else
                {
                    c = null;
                }
                break;
            }

            case TransitionType.Action:
            {
                // ignore actions; just exec one per rule upon accept
                c = config.Transform(t.target, ((ActionTransition)t).actionIndex);
                break;
            }

            case TransitionType.Epsilon:
            {
                c = config.Transform(t.target);
                break;
            }

            default:
            {
                c = null;
                break;
            }
            }
            return(c);
        }