ANTLR 3.5.1(最新的3.x版本)和Python运行时3.1.3(仅适用于Python运行时)
看起来3.5.1是最新的3.x版本,3.1.3是唯一可用的版本()。但是,当我尝试使用该示例运行解析器时,我收到一个投诉,即我的运行时版本与我的ANTLR版本不兼容:ANTLR 3.5.1(最新的3.x版本)和Python运行时3.1.3(仅适用于Python运行时),python,antlr,antlr3,Python,Antlr,Antlr3,看起来3.5.1是最新的3.x版本,3.1.3是唯一可用的版本()。但是,当我尝试使用该示例运行解析器时,我收到一个投诉,即我的运行时版本与我的ANTLR版本不兼容: $ PYTHONPATH=/home/dustin/build/antlr3/antlr_python_runtime-3.1.3 python SimpleCalcParser.py /tmp/lang Traceback (most recent call last): File "SimpleCalcParser.py
$ PYTHONPATH=/home/dustin/build/antlr3/antlr_python_runtime-3.1.3 python SimpleCalcParser.py /tmp/lang
Traceback (most recent call last):
File "SimpleCalcParser.py", line 231, in <module>
main(sys.argv)
File "SimpleCalcParser.py", line 220, in main
lexer = SimpleCalcLexer(char_stream)
File "/home/dustin/development/antlr/antlr3/hello_world_python/SimpleCalcLexer.py", line 31, in __init__
super(SimpleCalcLexer, self).__init__(input, state)
File "/home/dustin/build/antlr3/antlr_python_runtime-3.1.3/antlr3/recognizers.py", line 1072, in __init__
BaseRecognizer.__init__(self, state)
File "/home/dustin/build/antlr3/antlr_python_runtime-3.1.3/antlr3/recognizers.py", line 184, in __init__
self.antlr_version_str))
RuntimeError: ANTLR version mismatch: The recognizer has been generated by V3.0.1, but this runtime is V3.1.3. Please use the V3.0.1 runtime.
$PYTHONPATH=/home/dustin/build/antlr3/antlr_python_runtime-3.1.3 python SimpleCalcParser.py/tmp/lang
回溯(最近一次呼叫最后一次):
文件“SimpleCalcParser.py”,第231行,在
主(系统argv)
文件“SimpleCalcParser.py”,第220行,在main中
lexer=SimpleCalcLexer(字符流)
文件“/home/dustin/development/antlr/antlr3/hello\u world\u python/SimpleCalcLexer.py”,第31行,在__
super(SimpleCalcLexer,self)。\uuuu init\uuuu(输入,状态)
文件“/home/dustin/build/antlr3/antlr_python_runtime-3.1.3/antlr3/recognizers.py”,第1072行,在__
BaseRecognizer.\uuuu init\uuuu(自,状态)
文件“/home/dustin/build/antlr3/antlr_python_runtime-3.1.3/antlr3/recognizers.py”,第184行,在__
自。antlr_版本_str)
RuntimeError:ANTLR版本不匹配:识别器已由V3.0.1生成,但此运行时为V3.1.3。请使用V3.0.1运行时。
谁能让我走上正确的道路?由于可供下载的版本很少,我似乎没什么可做的。如果您想使用Python运行时,必须使用ANTLR 3.1.3来生成[Python]词法分析器 在此处下载3.1.3:
下面的Q&A提供了一个工作Python示例:已确认。谢谢你,巴特。