Skip to content

Add a more understandable message than "Serialized ATN data element .... element ... out of range 0..65535" #1863

@jbarotin

Description

@jbarotin

Hi,

I tried to build a big grammar file with antlr4. I've got the following message when I execute the ANTLR code that generate java source :

Exception in thread "main" java.lang.UnsupportedOperationException: Serialized ATN data element ```
101246 element 11 out of range 0..65535
        at org.antlr.v4.runtime.atn.ATNSerializer.serialize(ATNSerializer.java:361)
        at org.antlr.v4.runtime.atn.ATNSerializer.getSerialized(ATNSerializer.java:601)
        at org.antlr.v4.codegen.model.SerializedATN.<init>(SerializedATN.java:22)
        at org.antlr.v4.codegen.model.Recognizer.<init>(Recognizer.java:64)
        at org.antlr.v4.codegen.model.Lexer.<init>(Lexer.java:27)
        at org.antlr.v4.codegen.OutputModelController.lexer(OutputModelController.java:151)
        at org.antlr.v4.codegen.OutputModelController.buildLexerOutputModel(OutputModelController.java:104)
        at org.antlr.v4.codegen.CodeGenerator.generateLexer(CodeGenerator.java:119)
        at org.antlr.v4.codegen.CodeGenPipeline.process(CodeGenPipeline.java:54)
        at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:404)
        at org.antlr.v4.Tool.process(Tool.java:354)
        at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:321)
        at org.antlr.v4.Tool.main(Tool.java:168)

From what I understand, my grammar file is too long.

Is that possible to get a message to explain that the limitation of the library is reached ?

For your test, here it is my grammar file ( a bit cryptic cause I anonymize it) :
https://gist.github.com/jbarotin/7f7caf419b9038c2a548969265788392

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions