【问题标题】:4.10.1 Python ATNDeserializer broken?4.10.1 Python ATNDeserializer 坏了?
【发布时间】:2022-06-23 19:45:42
【问题描述】:

Java 实现继续正常工作,但 Python 实现在升级到 4.10.1 之前也一直正常工作,现在在调整 ATNDeserializer.py 时在第 89 行抛出 TypeError

这是一个已知的错误吗?

Traceback (most recent call last):
  File "/Users/vickery/Projects/dgw_processor/dgw_parser.py", line 15, in <module>
    from ReqBlockLexer import ReqBlockLexer
  File "/Users/vickery/Projects/dgw_processor/ReqBlockLexer.py", line 421, in <module>
    class ReqBlockLexer(Lexer):
  File "/Users/vickery/Projects/dgw_processor/ReqBlockLexer.py", line 423, in ReqBlockLexer
    atn = ATNDeserializer().deserialize(serializedATN())
  File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 61, in deserialize
    self.reset(data)
  File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 91, in reset
    temp = [ adjust(c) for c in data ]
  File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 91, in <listcomp>
    temp = [ adjust(c) for c in data ]
  File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 89, in adjust
    v = ord(c)
TypeError: ord() expected string of length 1, but int found

【问题讨论】:

    标签: python antlr


    【解决方案1】:

    我未能更新 antlr4-python3-runtime。

    【讨论】:

      【解决方案2】:

      您是否重新生成了词法分析器和解析器? 当我使用 v4.9.2 生成我的代码时,我遇到了同样的错误。但是当我将 antlr4-python3-runtime 更新到 v4.10 时,错误得到了修复。

      【讨论】:

        猜你喜欢
        • 2012-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-22
        • 2015-11-27
        • 1970-01-01
        • 2020-04-13
        • 2011-02-14
        相关资源
        最近更新 更多