ANTLR 3.5.1 (latest 3.x release) with Python runtime 3.1.3 (only available Python runtime)

StackOverflow https://stackoverflow.com/questions/19670153

  •  01-07-2022
  •  | 
  •  

Question

It looks like 3.5.1 is the latest 3.x version, and 3.1.3 is the only available version (http://www.antlr.org/download/Python/). However, when I try to run the parser using the example, I get a complaint that my runtime version is not compatible with my ANTLR version:

$ 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.

Can anyone put me on the right path? I doesn't seem like there's much I can do, due to the scarcity of versions available for download.

Was it helpful?

Solution

If you want to use the Python runtime, you must use ANTLR 3.1.3 to generate your [Python] lexer and parser.

Download 3.1.3 here: http://www.antlr3.org/download/antlr-3.1.3.jar

The following Q&A provides a working Python example: ANTLR parsing MismatchedTokenException

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top