Setting up Cantor Interpreter involves three things: cloning the repository, installing the Python packages that provide the ANTLR4 runtime, and runningDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/felipenugo/cantor-interpreter/llms.txt
Use this file to discover all available pages before exploring further.
make to generate the parser files from the grammar. The steps below walk through each one.
Requirements
| Requirement | Minimum version | Purpose |
|---|---|---|
| Python | 3.12 | Running the interpreter |
| Java | 11 or newer | Running the ANTLR4 tool during code generation |
antlr4-python3-runtime | 4.13.1 | ANTLR4 runtime used at parse time |
antlr4-tools | latest | Provides the antlr4 CLI that generates parser source files |
Java is only required during the
make step that generates the parser files. Once cantorLexer.py, cantorParser.py, and cantorVisitor.py have been created, you do not need Java to run Cantor programs.Installation steps
Install Python dependencies
Install the two required packages — the ANTLR4 Python runtime and the ANTLR4 tools — using either of the following commands:Or, using the provided Makefile target:Both commands install exactly the packages listed in
requirements.txt:Generate the ANTLR4 parser
Run The Makefile runs ANTLR4 inside the After this step, the following files appear in
make (with no arguments) to invoke ANTLR4 on the grammar file and generate the Python source files:src/ directory so that all generated files are placed there:src/:| Generated file | Description |
|---|---|
cantorLexer.py | Tokenises .cantor source files |
cantorParser.py | Builds the parse tree from the token stream |
cantorVisitor.py | Base visitor class used by CantorInterpreter |
cantor.interp, cantor.tokens, cantorLexer.interp, cantorLexer.tokens | ANTLR4 metadata files (not used directly) |
The generated files are produced entirely from
src/cantor.g4. Do not edit them by hand — any changes will be overwritten the next time you run make.Utility Makefile targets
Beyond the default build, the Makefile provides several helpful targets.make clean
Removes all ANTLR4-generated Python source files, metadata files, and Python cache directories (__pycache__, .ruff_cache, .antlr):
make re
Equivalent to make clean && make — rebuilds everything from scratch. Use this if you modify the grammar file src/cantor.g4 and need a guaranteed clean rebuild:
make deps
Installs Python dependencies via pip. Useful as a quick shorthand instead of typing the full pip install command:
Verifying the installation
Oncemake completes, confirm the generated files exist:
5, the interpreter is correctly installed and the parser was generated successfully.