These directions are geared towards people who are going to develop ANTLR projects using Python3.
python (or just py)
and see if you get a >>> prompt. If you don't but
you know that Python3 is installed:
py. In some cases, you may need to
re-install Python3: see the next step.
pip is checked.
py. You should see a >>>
prompt. If not, you may need to add Python3 to your path (see the
directions above).
py at the Command
Prompt. If you aren't used to it, this is the interactive Python shell
where you can type Python code. For example, enter
def cube(n):
return n * n * n
(noting that you indent the return line by at least a couple spaces) and
hit an extra return. You can then test it:
cube(9999)
and you should get back 999700029999.
exit().
pip at the command prompt. You will likely get a
"command not found" message. You can follow the above directions to
add pip to your path, or you can just execute the command
directly. The trick is to find it. The brute-force way is to enter
cd \
dir/s pip.exe
This searches your full computer and will take a while. But you can
probably find it in
C:\users\username\AppData\Local\Programs\Python\PythonXXX\Scripts
where username is your MSOE login name
and XXX is something like 39-64. Use cd to get
to this directory, noting you can hit the Tab key to fill out
filenames. For me, I type
cd c:\users\hasker\AppData\Local\Programs\Python
cd Python39-64\scripts
pip, type
python -m pip install antlr4-python3-runtime
choco install openjdk11, but you can probably find an
installer online. Make sure java is in your PATH variable.
https://levlaz.org/setting-up-antlr4-on-windows/
to set up antlr4. You will need to create a command
called antlr4.bat and put it in your path as the blog
indicates (so you can type antlr4 at the command prompt),
but you will not need grun.bat.
antlr4 -Dlanguage=Python3 adder.g4
py adder.py
(where you might use python3 instead of py)
If you get a "command not found" for either one, try closing the command
prompt and re-opening it. Otherwise post your error message to the
General channel of your class's Teams site and ask for help - it's very
likely someone else has run into the same issue.
Windows users are likely to get the warning messages
ANTLR runtime and generated code versions disagree: 4.8!=4.5.3
This has to do with a mismatch between libraries; you can ignore it.