diff --git a/tool/src/org/antlr/v4/codegen/Target.java b/tool/src/org/antlr/v4/codegen/Target.java index be1791eeb4..343ebb8720 100644 --- a/tool/src/org/antlr/v4/codegen/Target.java +++ b/tool/src/org/antlr/v4/codegen/Target.java @@ -478,17 +478,30 @@ public String getBaseVisitorFileName(boolean header) { /** * Gets the maximum number of 16-bit unsigned integers that can be encoded - * in a single segment of the serialized ATN. + * in a single segment (a declaration in target language) of the serialized ATN. + * E.g., in C++, a small segment length results in multiple decls like: + * + * static const uint16_t serializedATNSegment1[] = { + * 0x7, 0x12, 0x2, 0x13, 0x7, 0x13, 0x2, 0x14, 0x7, 0x14, 0x2, 0x15, 0x7, + * 0x15, 0x2, 0x16, 0x7, 0x16, 0x2, 0x17, 0x7, 0x17, 0x2, 0x18, 0x7, + * 0x18, 0x2, 0x19, 0x7, 0x19, 0x2, 0x1a, 0x7, 0x1a, 0x2, 0x1b, 0x7, + * 0x1b, 0x2, 0x1c, 0x7, 0x1c, 0x2, 0x1d, 0x7, 0x1d, 0x2, 0x1e, 0x7, + * 0x1e, 0x2, 0x1f, 0x7, 0x1f, 0x2, 0x20, 0x7, 0x20, 0x2, 0x21, 0x7, + * 0x21, 0x2, 0x22, 0x7, 0x22, 0x2, 0x23, 0x7, 0x23, 0x2, 0x24, 0x7, + * 0x24, 0x2, 0x25, 0x7, 0x25, 0x2, 0x26, + * }; + * + * instead of one big one. Targets are free to ignore this like JavaScript does. + * + * This is primarily needed by Java target to limit size of any single ATN string + * to 65k length. * * @see SerializedATN#getSegments * * @return the serialized ATN segment limit */ public int getSerializedATNSegmentLimit() { - // Make strings encoding ATN fit on a single line conveniently so - // we can march through generated code more easily. Only Java has - // an actual string len limit (16 bits). - return 80; + return Integer.MAX_VALUE; } /** How many bits should be used to do inline token type tests? Java assumes