gpt4 book ai didi

java - antlr4编译错误: Serialized ATN data element out of range

转载 作者:行者123 更新时间:2023-12-01 11:45:56 31 4
gpt4 key购买 nike

antlr4.5,目标Java,jdk1.6。

我编译了一个.g4组合文件,并得到了这个错误:

Exception in thread "main" java.lang.UnsupportedOperationException: Serialized ATN data element out of range.
at org.antlr.v4.runtime.atn.ATNSerializer.serialize(ATNSerializer.java:370)
at org.antlr.v4.runtime.atn.ATNSerializer.getSerialized(ATNSerializer.java:547)
at org.antlr.v4.codegen.model.SerializedATN.<init>(SerializedATN.java:46)
at org.antlr.v4.codegen.model.Recognizer.<init>(Recognizer.java:87)
at org.antlr.v4.codegen.model.Lexer.<init>(Lexer.java:51)
at org.antlr.v4.codegen.OutputModelController.lexer(OutputModelController.java:176)
at org.antlr.v4.codegen.OutputModelController.buildLexerOutputModel(OutputModelController.java:129)
at org.antlr.v4.codegen.CodeGenerator.generateLexer(CodeGenerator.java:144)
at org.antlr.v4.codegen.CodeGenPipeline.process(CodeGenPipeline.java:73)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:429)
at org.antlr.v4.Tool.process(Tool.java:379)
at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:346)
at org.antlr.v4.Tool.main(Tool.java:193)
at com.dicp.fdsl.antlr.FDSLCompiler.main(FDSLCompiler.java:13)

这个错误是什么意思?

最佳答案

我遇到了类似的问题,因此我开始注释语法中的行,直到错误消失。

就我而言,问题是我的数字文字规则中的拼写错误:

片段数字:'0'..'9';

将其更改为以下任一内容可使错误消失:

片段数字:'0'..'9';

片段数字:[0123456789];

似乎从“0”到“9”的字符范围被解释为 Unicode 值,并且它产生了一个意外的大范围。这与 https://github.com/antlr/antlr4/issues/840 ANTLR 小组的讨论一致。

关于java - antlr4编译错误: Serialized ATN data element out of range,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29126287/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com