Skip to content

Commit aa1f1f1

Browse files
committed
Add Windows doc for antlr4-tool usage
Signed-off-by: Terence Parr <[email protected]>
1 parent b979bbb commit aa1f1f1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

doc/getting-started.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Hi and welcome to the version 4 release of ANTLR! See [Why do we need ANTLR v4?]
44

55
## Getting started the easy way using antlr4-tools
66

7-
To play around with ANTLR without having to worry about installing it and the Java needed to execute it, use [antlr4-tools](https://github.com/antlr/antlr4-tools). The only requirement is Python3, which is typically installed on all developer machines on all operating systems.
7+
To play around with ANTLR without having to worry about installing it and the Java needed to execute it, use [antlr4-tools](https://github.com/antlr/antlr4-tools). The only requirement is Python3, which is typically installed on all developer machines on all operating systems. (See below for Windows issue.)
88

99
```bash
1010
$ pip install antlr4-tools
@@ -23,8 +23,6 @@ ANTLR Parser Generator Version 4.11.1
2323
...
2424
```
2525

26-
On Windows, the `pip` command doesn't just work---you need to add the `...\local-packages\python38\scripts` dir to your `PATH`, which itself might require a fun reboot. If you use WSL on Windows, then the pip install will also properly at the scripts directly (if you run from bash shell).
27-
2826
Let's play with a simple grammar:
2927

3028
```
@@ -39,6 +37,22 @@ NEWLINE : [\r\n]+ -> skip;
3937
INT : [0-9]+ ;
4038
```
4139

40+
### Windows-specific issues
41+
42+
On Windows, the `pip` command doesn't just work---you need to add the `...\local-packages\python38\scripts` dir to your `PATH`, which itself might require a fun reboot. If you use WSL on Windows, then the pip install will also properly at the scripts directly (if you run from bash shell).
43+
44+
45+
1. Go to the Microsoft Store
46+
2. Search in Microsoft Store for Python
47+
3. Select the newest version of Python (3.10).
48+
4. Click the "Get" button. Store installs python and pip at "c:\Users...\AppData\Local\Microsoft\WindowsApps\python.exe" and "c:\Users...\AppData\Local\Microsoft\WindowsApps\pip.exe", respectively. And, it updates the search path immediately with the install.
49+
5. Open a "cmd" terminal.
50+
6. You can now type "python" and "pip", and "pip install antlr4-tools". 7. Unfortunately, it does not add that to the search path.
51+
7. Update the search path to contain `c:\Users...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p8\LocalCache\local-packages\Python310\Scripts`. You may need to install MSYS2, then do a `find /c/ -name antlr4.exe 2> /dev/null` and enter that path.
52+
8. Or, you can set up an alias to antlr4.exe on that path.
53+
54+
The good news is that the ANTLR4 Python tool downloads the ANTLR jar in a standard location, and you don't need to do that manually. It's also possible to go in a browser, go to python.org, and download the python package. But, it's likely you will need to update the path for antlr4.exe as before.
55+
4256
### Try parsing with a sample grammar
4357

4458
To parse and get the parse tree in text form, use:

0 commit comments

Comments
 (0)