Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions tool/src/org/antlr/v4/codegen/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down