diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java index 763166d1a..420ef991d 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java @@ -46,7 +46,6 @@ public class ATN { public static final int PARSER = 1; public static final int LEXER = 2; - public static final int TREE_PARSER = 3; @NotNull public final List states = new ArrayList(); diff --git a/tool/src/org/antlr/v4/automata/ATNSerializer.java b/tool/src/org/antlr/v4/automata/ATNSerializer.java index c989a4f8a..41c95300a 100644 --- a/tool/src/org/antlr/v4/automata/ATNSerializer.java +++ b/tool/src/org/antlr/v4/automata/ATNSerializer.java @@ -90,9 +90,20 @@ public class ATNSerializer { IntegerList data = new IntegerList(); data.add(ATNSimulator.SERIALIZED_VERSION); // convert grammar type to ATN const to avoid dependence on ANTLRParser - if ( g.getType()== ANTLRParser.LEXER ) data.add(ATN.LEXER); - else if ( g.getType()== ANTLRParser.PARSER ) data.add(ATN.PARSER); - else data.add(ATN.TREE_PARSER); + switch (g.getType()) { + case ANTLRParser.LEXER: + data.add(ATN.LEXER); + break; + + case ANTLRParser.PARSER: + case ANTLRParser.COMBINED: + data.add(ATN.PARSER); + break; + + default: + throw new UnsupportedOperationException("Invalid grammar type."); + } + data.add(g.getMaxTokenType()); int nedges = 0;