antlr/antlr4 · error · NotSupportedException

Unrecognized ATN transition type.

Error message

Unrecognized ATN transition type.

What it means

Error "Unrecognized ATN transition type." thrown in antlr/antlr4.

Source

Thrown at runtime/CSharp/src/ParserInterpreter.cs:277

                case TransitionType.ACTION:
                {
                    ActionTransition actionTransition = (ActionTransition)transition;
					Action(RuleContext, actionTransition.ruleIndex, actionTransition.actionIndex);
                    break;
                }

                case TransitionType.PRECEDENCE:
                {
					if (!Precpred(RuleContext, ((PrecedencePredicateTransition)transition).precedence))
                    {
                        throw new FailedPredicateException(this, string.Format("precpred(_ctx, {0})", ((PrecedencePredicateTransition)transition).precedence));
                    }
                    break;
                }

                default:
                {
                    throw new NotSupportedException("Unrecognized ATN transition type.");
                }
            }
            State = transition.target.stateNumber;
        }

        protected internal virtual void VisitRuleStopState(ATNState p)
        {
            RuleStartState ruleStartState = _atn.ruleToStartState[p.ruleIndex];
            if (ruleStartState.isPrecedenceRule)
            {
                Tuple<ParserRuleContext, int> parentContext = _parentContextStack.Pop();
                UnrollRecursionContexts(parentContext.Item1);
                State = parentContext.Item2;
            }
            else
            {
                ExitRule();
            }

View on GitHub (pinned to 7d5770395b)

Solutions

  1. The serialized ATN was produced by an incompatible tool version; regenerate the parser with an ANTLR tool whose version matches the runtime.
  2. Do not hand-edit generated .interp/serialized ATN data.

Example fix

// match Antlr4.Runtime.Standard package version with the ANTLR generator version

When it happens

Trigger: ParserInterpreter encounters a transition type it does not recognize while visiting the ATN.

Common situations: Verify the serialized ATN matches the runtime version; regenerated corrupted or mismatched ATNs cause this.


AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14). Data as JSON: /api/errors/1459c85c9d6edd43. Report an issue: GitHub.