I googled for an example of using ANTLR with Python3 and found bentrevett's repo, so I forked it to make a new one, up to date (May 2024) and for JavaScript instead of Java9.
I'm assuming Debian Bookworm or later as the dev environment.
sudo apt install antlr4 python3-antlr4
- Go to https://github.com/antlr/grammars-v4
- Find the language you want to tokenize
- Download the .g4 file(s) for that language
- Get some example code for your desired language
This is all built into the Makefile, so simply: make to download and run.
The parser jsparse.py was adapted from the README of the javascript
grammar page.
- Hello Antlr, Sumeet's introduction to parsing and modifying grammars.
- Fixing lack of Base files