antlr/antlr4 · error · NotSupportedException
Not yet implemented.
Error message
Not yet implemented.
What it means
During ATN edge-factoring (set transition optimization), when a candidate set transition resolves through a NotSetTransition, the C# runtime cannot merge it and throws NotSupportedException('Not yet implemented.'). The equivalent Java code contains the same unimplemented branch, so hitting it means the optimizer encountered a ~ (not-set) transition shape it cannot factor.
Source
Thrown at runtime/CSharp/src/Atn/ATNDeserializer.cs:834
IList<Transition> optimizedTransitions = new List<Transition>();
for (int i_1 = 0; i_1 < decision.NumberOfOptimizedTransitions; i_1++)
{
if (!setTransitions.Contains(i_1))
{
optimizedTransitions.Add(decision.GetOptimizedTransition(i_1));
}
}
ATNState blockEndState = decision.GetOptimizedTransition(setTransitions.MinElement).target.GetOptimizedTransition(0).target;
IntervalSet matchSet = new IntervalSet();
for (int i_2 = 0; i_2 < setTransitions.GetIntervals().Count; i_2++)
{
Interval interval = setTransitions.GetIntervals()[i_2];
for (int j = interval.a; j <= interval.b; j++)
{
Transition matchTransition = decision.GetOptimizedTransition(j).target.GetOptimizedTransition(0);
if (matchTransition is NotSetTransition)
{
throw new NotSupportedException("Not yet implemented.");
}
else
{
matchSet.AddAll(matchTransition.Label);
}
}
}
Transition newTransition;
if (matchSet.GetIntervals().Count == 1)
{
if (matchSet.Count == 1)
{
newTransition = new AtomTransition(blockEndState, matchSet.MinElement);
}
else
{
Interval matchInterval = matchSet.GetIntervals()[0];
newTransition = new RangeTransition(blockEndState, matchInterval.a, matchInterval.b);View on GitHub (pinned to 7d5770395b)
Solutions
- Disable ATN optimization for deserialization (options with Optimize = false) so edge factoring is skipped
- Regenerate the grammar with the matching tool/runtime version so serialized ATN matches optimizer expectations
- If reproducible on the current release, report upstream — the branch is a known TODO
Example fix
// before var options = ATNDeserializationOptions.Default; // optimize on new ATNDeserializer(options).Deserialize(data); // after var options = new ATNDeserializationOptions(); options.Optimize = false; options.MakeReadOnly(); new ATNDeserializer(options).Deserialize(data);
Defensive patterns
Strategy: fallback
Validate before calling
var opts = new ATNDeserializationOptions(); opts.Optimize = false; opts.MakeReadOnly(); // avoids the unimplemented optimizer branch
Try / catch
try { new ATNDeserializer(options).Deserialize(data); } catch (NotSupportedException e) { when (e.Message == "Not yet implemented.") { /* retry with Optimize=false */ } } Prevention
- If a grammar uses negated sets in decisions and you deserialize ATNs at runtime, keep optimization off
- Report reproducible grammars upstream so the TODO gets implemented
When it happens
Trigger: Deserializing an ATN (LexerInterpreter, ParserInterpreter, or generated code with optimization enabled) whose decision contains NotSet transitions participating in a factorable set — typically grammars using '~' token sets inside decisions, combined with edge optimization.
Common situations: Complex lexer rules with negated sets ('~[...])'; older serialized ATNs reprocessed by a runtime whose optimizer added this path; rare even with such grammars because the branch needs a specific state arrangement.
Related errors
- Invalid state number.
- The object is read only.
- Couldn't identify final state of the precedence rule prefix
- Could not deserialize ATN with version {0} (expected {1}).
- The specified transition type is not valid.
AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14).
Data as JSON: /api/errors/4f15a179bc73084b.
Report an issue: GitHub.